Currently para_filter -h and para_audiod -h print the available
filters in a single line which exceeds 80 characters if many
filters are supported.
This patch makes printf_or_die() return the number of characters
printed. This allows to add line breaks to format the filter list.
*/
void print_filter_helps(int detailed)
{
- int i;
+ int i, num = 0;
- printf_or_die("\nAvailable filters: \n\t");
- FOR_EACH_SUPPORTED_FILTER(i)
- printf_or_die("%s%s", i? " " : "", filters[i].name);
- printf_or_die("\n\n");
+ printf_or_die("\nAvailable filters: ");
+ FOR_EACH_SUPPORTED_FILTER(i) {
+ if (num > 50) {
+ printf_or_die("\n ");
+ num = 0;
+ }
+ num += printf_or_die("%s%s", i? " " : "", filters[i].name);
+ }
+ printf_or_die("\n");
FOR_EACH_SUPPORTED_FILTER(i) {
struct filter *f = filters + i;
*
* \param fmt Usual format string.
*/
-__printf_1_2 void printf_or_die(const char *fmt, ...)
+__printf_1_2 int printf_or_die(const char *fmt, ...)
{
va_list argp;
int ret;
ret = vprintf(fmt, argp);
va_end(argp);
if (ret >= 0)
- return;
+ return ret;
exit(EXIT_FAILURE);
}
};
void ggo_print_help(struct ggo_help *help, int detailed_help);
-__printf_1_2 void printf_or_die(const char *fmt, ...);
+__printf_1_2 int printf_or_die(const char *fmt, ...);