00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __G_OPTION_H__
00023 #define __G_OPTION_H__
00024
00025 #include <_ansi.h>
00026 #include <glib/gerror.h>
00027 #include <glib/gquark.h>
00028
00029 G_BEGIN_DECLS
00030
00031 typedef struct _GOptionContext GOptionContext;
00032 typedef struct _GOptionGroup GOptionGroup;
00033 typedef struct _GOptionEntry GOptionEntry;
00034
00035 typedef enum
00036 {
00037 G_OPTION_FLAG_HIDDEN = 1 << 0,
00038 G_OPTION_FLAG_IN_MAIN = 1 << 1,
00039 G_OPTION_FLAG_REVERSE = 1 << 2,
00040 G_OPTION_FLAG_NO_ARG = 1 << 3,
00041 G_OPTION_FLAG_FILENAME = 1 << 4,
00042 G_OPTION_FLAG_OPTIONAL_ARG = 1 << 5,
00043 G_OPTION_FLAG_NOALIAS = 1 << 6
00044 } GOptionFlags;
00045
00046 typedef enum
00047 {
00048 G_OPTION_ARG_NONE,
00049 G_OPTION_ARG_STRING,
00050 G_OPTION_ARG_INT,
00051 G_OPTION_ARG_CALLBACK,
00052 G_OPTION_ARG_FILENAME,
00053 G_OPTION_ARG_STRING_ARRAY,
00054 G_OPTION_ARG_FILENAME_ARRAY
00055 } GOptionArg;
00056
00057 typedef gboolean (*GOptionArgFunc) (const gchar *option_name,
00058 const gchar *value,
00059 gpointer data,
00060 GError **error);
00061
00062 typedef gboolean (*GOptionParseFunc) (GOptionContext *context,
00063 GOptionGroup *group,
00064 gpointer data,
00065 GError **error);
00066
00067 typedef void (*GOptionErrorFunc) (GOptionContext *context,
00068 GOptionGroup *group,
00069 gpointer data,
00070 GError **error);
00071
00072 #define G_OPTION_ERROR (g_option_error_quark ())
00073
00074 typedef enum
00075 {
00076 G_OPTION_ERROR_UNKNOWN_OPTION,
00077 G_OPTION_ERROR_BAD_VALUE,
00078 G_OPTION_ERROR_FAILED
00079 } GOptionError;
00080
00081 IMPORT_C GQuark g_option_error_quark (void);
00082
00083
00084 struct _GOptionEntry
00085 {
00086 const gchar *long_name;
00087 gchar short_name;
00088 gint flags;
00089
00090 GOptionArg arg;
00091 gpointer arg_data;
00092
00093 const gchar *description;
00094 const gchar *arg_description;
00095 };
00096
00097 #define G_OPTION_REMAINING ""
00098
00099 IMPORT_C GOptionContext *g_option_context_new (const gchar *parameter_string);
00100 IMPORT_C void g_option_context_free (GOptionContext *context);
00101 IMPORT_C void g_option_context_set_help_enabled (GOptionContext *context,
00102 gboolean help_enabled);
00103 IMPORT_C gboolean g_option_context_get_help_enabled (GOptionContext *context);
00104 IMPORT_C void g_option_context_set_ignore_unknown_options (GOptionContext *context,
00105 gboolean ignore_unknown);
00106 IMPORT_C gboolean g_option_context_get_ignore_unknown_options (GOptionContext *context);
00107
00108 IMPORT_C void g_option_context_add_main_entries (GOptionContext *context,
00109 const GOptionEntry *entries,
00110 const gchar *translation_domain);
00111 IMPORT_C gboolean g_option_context_parse (GOptionContext *context,
00112 gint *argc,
00113 gchar ***argv,
00114 GError **error);
00115
00116 IMPORT_C void g_option_context_add_group (GOptionContext *context,
00117 GOptionGroup *group);
00118 IMPORT_C void g_option_context_set_main_group (GOptionContext *context,
00119 GOptionGroup *group);
00120 IMPORT_C GOptionGroup *g_option_context_get_main_group (GOptionContext *context);
00121
00122
00123 IMPORT_C GOptionGroup *g_option_group_new (const gchar *name,
00124 const gchar *description,
00125 const gchar *help_description,
00126 gpointer user_data,
00127 GDestroyNotify destroy);
00128 IMPORT_C void g_option_group_set_parse_hooks (GOptionGroup *group,
00129 GOptionParseFunc pre_parse_func,
00130 GOptionParseFunc post_parse_func);
00131 IMPORT_C void g_option_group_set_error_hook (GOptionGroup *group,
00132 GOptionErrorFunc error_func);
00133 IMPORT_C void g_option_group_free (GOptionGroup *group);
00134 IMPORT_C void g_option_group_add_entries (GOptionGroup *group,
00135 const GOptionEntry *entries);
00136 IMPORT_C void g_option_group_set_translate_func (GOptionGroup *group,
00137 GTranslateFunc func,
00138 gpointer data,
00139 GDestroyNotify destroy_notify);
00140 IMPORT_C void g_option_group_set_translation_domain (GOptionGroup *group,
00141 const gchar *domain);
00142
00143
00144 G_END_DECLS
00145
00146 #endif