Software: Apache/2.0.54 (Fedora). PHP/5.0.4 uname -a: Linux mina-info.me 2.6.17-1.2142_FC4smp #1 SMP Tue Jul 11 22:57:02 EDT 2006 i686 uid=48(apache) gid=48(apache) groups=48(apache) Safe-mode: OFF (not secure) /usr/share/gtk-doc/html/glib/ drwxr-xr-x |
Viewing file: Select action/file-type:
Synopsis#include <glib.h> enum GOptionError; #define G_OPTION_ERROR gboolean (*GOptionArgFunc) (const gchar *option_name, const gchar *value, gpointer data, GError **error); GOptionContext; GOptionContext* g_option_context_new (const gchar *parameter_string); void g_option_context_free (GOptionContext *context); gboolean g_option_context_parse (GOptionContext *context, gint *argc, gchar ***argv, GError **error); void g_option_context_set_help_enabled (GOptionContext *context, gboolean help_enabled); gboolean g_option_context_get_help_enabled (GOptionContext *context); void g_option_context_set_ignore_unknown_options (GOptionContext *context, gboolean ignore_unknown); gboolean g_option_context_get_ignore_unknown_options (GOptionContext *context); enum GOptionArg; enum GOptionFlags; #define G_OPTION_REMAINING GOptionEntry; void g_option_context_add_main_entries (GOptionContext *context, const GOptionEntry *entries, const gchar *translation_domain); GOptionGroup; void g_option_context_add_group (GOptionContext *context, GOptionGroup *group); void g_option_context_set_main_group (GOptionContext *context, GOptionGroup *group); GOptionGroup* g_option_context_get_main_group (GOptionContext *context); GOptionGroup* g_option_group_new (const gchar *name, const gchar *description, const gchar *help_description, gpointer user_data, GDestroyNotify destroy); void g_option_group_free (GOptionGroup *group); void g_option_group_add_entries (GOptionGroup *group, const GOptionEntry *entries); gboolean (*GOptionParseFunc) (GOptionContext *context, GOptionGroup *group, gpointer data, GError **error); void g_option_group_set_parse_hooks (GOptionGroup *group, GOptionParseFunc pre_parse_func, GOptionParseFunc post_parse_func); void (*GOptionErrorFunc) (GOptionContext *context, GOptionGroup *group, gpointer data, GError **error); void g_option_group_set_error_hook (GOptionGroup *group, GOptionErrorFunc error_func); const gchar* (*GTranslateFunc) (const gchar *str, gpointer data); void g_option_group_set_translate_func (GOptionGroup *group, GTranslateFunc func, gpointer data, GDestroyNotify destroy_notify); void g_option_group_set_translation_domain (GOptionGroup *group, const gchar *domain); DescriptionThe GOption commandline parser is intended to be a simpler replacement for the popt library. It supports short and long commandline options, as shown in the following example:
The example demonstrates a number of features of the GOption commandline parser
Another important feature of GOption is that it can automatically generate nicely
formatted help output. Unless it is explicitly turned off with
Usage: testtreemodel [OPTION...] - test tree model performance Help Options: -?, --help Show help options --help-all Show all help options --help-gtk Show GTK+ Options Application Options: -r, --repeats=N Average over N repetitions -m, --max-size=M Test up to 2^M items --display=DISPLAY X display to use -v, --verbose Be verbose -b, --beep Beep when done --rand Randomize the data
GOption groups options in GOptionGroups, which makes it easy to
incorporate options from multiple sources. The intended use for this is
to let applications collect option groups from the libraries it uses,
add them to their GOptionContext, and parse all options by a single call
to If an option is declared to be of type string or filename, GOption takes care of converting it to the right encoding; strings are returned in UTF-8, filenames are returned in the GLib filename encoding. Here is a complete example of setting up GOption to parse the example commandline above and produce the example help output. static gint repeats = 2; static gint max_size = 8; static gboolean verbose = FALSE; static gboolean beep = FALSE; static gboolean rand = FALSE; static GOptionEntry entries[] = { { "repeats", 'r', 0, G_OPTION_ARG_INT, &repeats, "Average over N repetitions", "N" }, { "max-size", 'm', 0, G_OPTION_ARG_INT, &max_size, "Test up to 2^M items", "M" }, { "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, "Be verbose", NULL }, { "beep", 'b', 0, G_OPTION_ARG_NONE, &beep, "Beep when done", NULL }, { "rand", 0, 0, G_OPTION_ARG_NONE, &rand, "Randomize the data", NULL }, { NULL } }; int main (int argc, char *argv[]) { GError *error = NULL; context = g_option_context_new ("- test tree model performance"); g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE); g_option_context_add_group (context, gtk_get_option_group (TRUE)); g_option_context_parse (context, &argc, &argv, &error); /* ... */ } Detailsenum GOptionErrortypedef enum { G_OPTION_ERROR_UNKNOWN_OPTION, G_OPTION_ERROR_BAD_VALUE, G_OPTION_ERROR_FAILED } GOptionError; Error codes returned by option parsing.
G_OPTION_ERROR#define G_OPTION_ERROR (g_option_error_quark ()) Error domain for option parsing. Errors in this domain will be from the GOptionError enumeration. See GError for information on error domains. GOptionArgFunc ()gboolean (*GOptionArgFunc) (const gchar *option_name, const gchar *value, gpointer data, GError **error);
The type of function to be passed as callback for
GOptionContexttypedef struct _GOptionContext GOptionContext; A GOptionContext struct defines which options are accepted by the commandline option parser. The struct has only private fields and should not be directly accessed. g_option_context_new ()GOptionContext* g_option_context_new (const gchar *parameter_string); Creates a new option context.
Since 2.6 g_option_context_free ()void g_option_context_free (GOptionContext *context); Frees context and all the groups which have been added to it.
Since 2.6 g_option_context_parse ()gboolean g_option_context_parse (GOptionContext *context, gint *argc, gchar ***argv, GError **error);
Parses the command line arguments, recognizing options
which have been added to
If the parsing is successful, any parsed arguments are
removed from the array and
If automatic
Since 2.6 g_option_context_set_help_enabled ()void g_option_context_set_help_enabled (GOptionContext *context, gboolean help_enabled);
Enables or disables automatic generation of
Since 2.6 g_option_context_get_help_enabled ()gboolean g_option_context_get_help_enabled (GOptionContext *context);
Returns whether automatic
Since 2.6 g_option_context_set_ignore_unknown_options ()void g_option_context_set_ignore_unknown_options (GOptionContext *context, gboolean ignore_unknown);
Sets whether to ignore unknown options or not. If an argument is
ignored, it is left in the This setting does not affect non-option arguments (i.e. arguments which don't start with a dash). But note that GOption cannot reliably determine whether a non-option belongs to a preceding unknown option.
Since 2.6 g_option_context_get_ignore_unknown_options ()gboolean g_option_context_get_ignore_unknown_options (GOptionContext *context);
Returns whether unknown options are ignored or not. See
Since 2.6 enum GOptionArgtypedef enum { G_OPTION_ARG_NONE, G_OPTION_ARG_STRING, G_OPTION_ARG_INT, G_OPTION_ARG_CALLBACK, G_OPTION_ARG_FILENAME, G_OPTION_ARG_STRING_ARRAY, G_OPTION_ARG_FILENAME_ARRAY } GOptionArg;
The GOptionArg enum values determine which type of extra argument the
options expect to find. If an option expects an extra argument, it
can be specified in several ways; with a short option:
enum GOptionFlagstypedef enum { G_OPTION_FLAG_HIDDEN = 1 << 0, G_OPTION_FLAG_IN_MAIN = 1 << 1, G_OPTION_FLAG_REVERSE = 1 << 2 } GOptionFlags; Flags which modify individual options.
G_OPTION_REMAINING#define G_OPTION_REMAINING ""
If a long option in the main group has this name, it is not treated as a
regular option. Instead it collects all non-option arguments which would
otherwise be left in
Using G_OPTION_REMAINING instead of simply scanning Since 2.6 GOptionEntrytypedef struct { const gchar *long_name; gchar short_name; gint flags; GOptionArg arg; gpointer arg_data; const gchar *description; const gchar *arg_description; } GOptionEntry;
A GOptionEntry defines a single option.
To have an effect, they must be added to a GOptionGroup with
g_option_context_add_main_entries ()void g_option_context_add_main_entries (GOptionContext *context, const GOptionEntry *entries, const gchar *translation_domain);
A convenience function which creates a main group if it doesn't
exist, adds the
Since 2.6 GOptionGrouptypedef struct _GOptionGroup GOptionGroup; A GOptionGroup struct defines the options in a single group. The struct has only private fields and should not be directly accessed. All options in a group share the same translation function. Libaries which need to parse commandline options are expected to provide a function for getting a GOptionGroup holding their options, which the application can then add to its GOptionContext. g_option_context_add_group ()void g_option_context_add_group (GOptionContext *context, GOptionGroup *group);
Adds a GOptionGroup to the
Since 2.6 g_option_context_set_main_group ()void g_option_context_set_main_group (GOptionContext *context, GOptionGroup *group);
Sets a GOptionGroup as main group of the
Since 2.6 g_option_context_get_main_group ()GOptionGroup* g_option_context_get_main_group (GOptionContext *context);
Returns a pointer to the main group of
Since 2.6 g_option_group_new ()GOptionGroup* g_option_group_new (const gchar *name, const gchar *description, const gchar *help_description, gpointer user_data, GDestroyNotify destroy); Creates a new GOptionGroup.
Since 2.6 g_option_group_free ()void g_option_group_free (GOptionGroup *group); Frees a GOptionGroup. Note that you must not free groups which have been added to a GOptionContext.
Since 2.6 g_option_group_add_entries ()void g_option_group_add_entries (GOptionGroup *group, const GOptionEntry *entries);
Adds the options specified in
Since 2.6 GOptionParseFunc ()gboolean (*GOptionParseFunc) (GOptionContext *context, GOptionGroup *group, gpointer data, GError **error); The type of function that can be called before and after parsing. context The active GOptionContext
g_option_group_set_parse_hooks ()void g_option_group_set_parse_hooks (GOptionGroup *group, GOptionParseFunc pre_parse_func, GOptionParseFunc post_parse_func);
Associates two functions with
Note that the user data to be passed to
Since 2.6 GOptionErrorFunc ()void (*GOptionErrorFunc) (GOptionContext *context, GOptionGroup *group, gpointer data, GError **error); The type of function to be used as callback when a parse error occurs. context The active GOptionContext
g_option_group_set_error_hook ()void g_option_group_set_error_hook (GOptionGroup *group, GOptionErrorFunc error_func);
Associates a function with
Note that the user data to be passed to
Since 2.6 GTranslateFunc ()const gchar* (*GTranslateFunc) (const gchar *str, gpointer data);
The type of functions which are used to translate user-visible
strings, for
g_option_group_set_translate_func ()void g_option_group_set_translate_func (GOptionGroup *group, GTranslateFunc func, gpointer data, GDestroyNotify destroy_notify);
Sets the function which is used to translate user-visible
strings, for
If you are using
Since 2.6 g_option_group_set_translation_domain ()void g_option_group_set_translation_domain (GOptionGroup *group, const gchar *domain);
A convenience function to use
Since 2.6
|
:: Command execute :: | |
--[ c99shell v. 1.0 pre-release build #16 powered by Captain Crunch Security Team | http://ccteam.ru | Generation time: 0.0041 ]-- |