1 /* interface.c - common parts of the simple LADSPA hosts
2 * Copyright © 2013 Géraud Meyer <graud@gmx.com>
4 * This file is part of ng-jackspa.
6 * ng-jackspa is free software; you can redistribute it and/or modify it under
7 * the terms of the GNU General Public License version 2 as published by the
8 * Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * You should have received a copy of the GNU General Public License along
16 * with ng-jackspa. If not, see <http://www.gnu.org/licenses/>.
19 #include "interface.h"
25 /* PROGRAM_NAME must be defined by the interface */
26 #define PACKAGE_NAME "ng-jackspa"
27 #define PACKAGE_SUMMARY \
28 PACKAGE_NAME " is a set of simple interfaces that host a LADSPA plugin, " \
29 "providing JACK ports for its audio inputs and outputs, and dynamic setting " \
30 "of its control inputs."
31 #define PACKAGE_DESCRIPTION "ng-jackspa is accompanied by a manual page."
34 static gint verbose
= 1;
35 static gboolean
verbose_more(const gchar
*opt
, const gchar
*arg
,
36 gpointer data
, GError
**error
)
37 { verbose
++; return TRUE
; }
38 static gboolean
verbose_less(const gchar
*opt
, const gchar
*arg
,
39 gpointer data
, GError
**error
)
40 { verbose
--; return TRUE
; }
42 static GOptionEntry interface_entries
[] =
44 /* long, short, flags, arg_type, arg_data, description, arg_description */
45 { "verbose", 'v', G_OPTION_FLAG_NO_ARG
, G_OPTION_ARG_CALLBACK
,
46 (gpointer
)verbose_more
, "Be more verbose", NULL
},
47 { "quiet", 'q', G_OPTION_FLAG_NO_ARG
, G_OPTION_ARG_CALLBACK
,
48 (gpointer
)verbose_less
, "Be quieter", NULL
},
52 /* Return a member of a NULL-terminated string array */
53 gchar
*glib_strv_index(unsigned long i
, gchar
**str_array
)
55 for (; str_array
&& *str_array
&& i
; str_array
++, i
--);
56 /* it seems *str_array should be set to NULL to mark the end */
63 GOptionContext
* interface_context()
65 /* Context & Main entries */
66 GOptionContext
*context
;
67 context
= g_option_context_new("PLUGIN_LIBRARY UID");
68 g_option_context_set_help_enabled(context
, TRUE
);
69 g_option_context_set_ignore_unknown_options(context
, TRUE
);
70 g_option_context_set_summary
71 (context
, PROGRAM_NAME
" is part of ng-jackspa.\n\n" PACKAGE_SUMMARY
);
72 g_option_context_set_description(context
, PACKAGE_DESCRIPTION
);
73 g_option_context_add_main_entries(context
, interface_entries
, NULL
);
75 /* Other group of options */
76 GOptionGroup
*control_group
;
77 control_group
= g_option_group_new
78 ( "control", "Control interface",
79 "Show options of the control interface", NULL
, NULL
);
80 g_option_group_add_entries(control_group
, control_entries
);
81 g_option_context_add_group(context
, control_group
);