From: <enl...@li...> - 2002-04-29 21:47:40
|
Enlightenment CVS committal Author : mej Project : eterm Module : Eterm Dir : eterm/Eterm/src Modified Files: Tag: ETERM-0_10 options.c options.h startup.c Log Message: Mon Apr 29 17:44:46 2002 Michael Jennings (mej) Use the new option parser in libast. You will need the latest libast from CVS to use this version, but if you have it, and you've always been bugged by that -F -font-name-with-dashes problem, give this a try. This branch is a playground for 0.10 development. Be careful before attempting to use anything you get from here. =================================================================== RCS file: /cvsroot/enlightenment/eterm/Eterm/src/options.c,v retrieving revision 1.102 retrieving revision 1.102.2.1 diff -u -3 -r1.102 -r1.102.2.1 --- options.c 25 Apr 2002 02:35:52 -0000 1.102 +++ options.c 29 Apr 2002 21:47:38 -0000 1.102.2.1 @@ -21,7 +21,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -static const char cvs_ident[] = "$Id: options.c,v 1.102 2002/04/25 02:35:52 mej Exp $"; +static const char cvs_ident[] = "$Id: options.c,v 1.102.2.1 2002/04/29 21:47:38 mej Exp $"; #include "config.h" #include "feature.h" @@ -60,6 +60,9 @@ # define CONFIG_BUFF 20480 #endif +static void usage(void); +static void version(void); +static void handle_attribute(char *); static void *parse_color(char *, void *); static void *parse_attributes(char *, void *); static void *parse_toggles(char *, void *); @@ -148,193 +151,184 @@ #endif /* Options structure */ -static const struct { - char short_opt; - char *long_opt; - const char *const description; - unsigned short flag; - const void *pval; - unsigned long *maskvar; - int mask; -} optList[] = { - - OPT_STR('t', "theme", "select a theme", &rs_theme), - OPT_STR('X', "config-file", "choose an alternate config file", &rs_config_file), - OPT_STR('d', "display", "X server to connect to", &display_name), +spifopt_t option_list[] = { + SPIFOPT_STR('t', "theme", "select a theme", rs_theme), + SPIFOPT_STR('X', "config-file", "choose an alternate config file", rs_config_file), + SPIFOPT_STR('d', "display", "X server to connect to", display_name), #if DEBUG <= 0 - OPT_ILONG("debug", "level of debugging information to show (support not compiled in)", &DEBUG_LEVEL), + SPIFOPT_INT_LONG("debug", "level of debugging information to show (support not compiled in)", DEBUG_LEVEL), #elif DEBUG == 1 - OPT_ILONG("debug", "level of debugging information to show (0-1)", &DEBUG_LEVEL), + SPIFOPT_INT_LONG("debug", "level of debugging information to show (0-1)", DEBUG_LEVEL), #elif DEBUG == 2 - OPT_ILONG("debug", "level of debugging information to show (0-2)", &DEBUG_LEVEL), + SPIFOPT_INT_LONG("debug", "level of debugging information to show (0-2)", DEBUG_LEVEL), #elif DEBUG == 3 - OPT_ILONG("debug", "level of debugging information to show (0-3)", &DEBUG_LEVEL), + SPIFOPT_INT_LONG("debug", "level of debugging information to show (0-3)", DEBUG_LEVEL), #elif DEBUG == 4 - OPT_ILONG("debug", "level of debugging information to show (0-4)", &DEBUG_LEVEL), + SPIFOPT_INT_LONG("debug", "level of debugging information to show (0-4)", DEBUG_LEVEL), #else - OPT_ILONG("debug", "level of debugging information to show (0-5)", &DEBUG_LEVEL), + SPIFOPT_INT_LONG("debug", "level of debugging information to show (0-5)", DEBUG_LEVEL), #endif - OPT_BLONG("install", "install a private colormap", &Options, Opt_install), + SPIFOPT_BOOL_LONG("install", "install a private colormap", Options, Opt_install), - OPT_BOOL('h', "help", "display usage information", NULL, 0), - OPT_BLONG("version", "display version and configuration information", NULL, 0), + SPIFOPT_ABST('h', "help", "display usage information", usage), + SPIFOPT_ABST_LONG("version", "display version and configuration information", version), /* =======[ Color options ]======= */ - OPT_BOOL('r', "reverse-video", "reverse video", &Options, Opt_reverse_video), - OPT_STR('b', "background-color", "background color", &rs_color[bgColor]), - OPT_STR('f', "foreground-color", "foreground color", &rs_color[fgColor]), - OPT_LONG("color0", "color 0", &rs_color[minColor]), - OPT_LONG("color1", "color 1", &rs_color[minColor + 1]), - OPT_LONG("color2", "color 2", &rs_color[minColor + 2]), - OPT_LONG("color3", "color 3", &rs_color[minColor + 3]), - OPT_LONG("color4", "color 4", &rs_color[minColor + 4]), - OPT_LONG("color5", "color 5", &rs_color[minColor + 5]), - OPT_LONG("color6", "color 6", &rs_color[minColor + 6]), - OPT_LONG("color7", "color 7", &rs_color[minColor + 7]), + SPIFOPT_BOOL('r', "reverse-video", "reverse video", Options, Opt_reverse_video), + SPIFOPT_STR('b', "background-color", "background color", rs_color[bgColor]), + SPIFOPT_STR('f', "foreground-color", "foreground color", rs_color[fgColor]), + SPIFOPT_STR_LONG("color0", "color 0", rs_color[minColor]), + SPIFOPT_STR_LONG("color1", "color 1", rs_color[minColor + 1]), + SPIFOPT_STR_LONG("color2", "color 2", rs_color[minColor + 2]), + SPIFOPT_STR_LONG("color3", "color 3", rs_color[minColor + 3]), + SPIFOPT_STR_LONG("color4", "color 4", rs_color[minColor + 4]), + SPIFOPT_STR_LONG("color5", "color 5", rs_color[minColor + 5]), + SPIFOPT_STR_LONG("color6", "color 6", rs_color[minColor + 6]), + SPIFOPT_STR_LONG("color7", "color 7", rs_color[minColor + 7]), #ifndef NO_BRIGHTCOLOR - OPT_LONG("color8", "color 8", &rs_color[minBright]), - OPT_LONG("color9", "color 9", &rs_color[minBright + 1]), - OPT_LONG("color10", "color 10", &rs_color[minBright + 2]), - OPT_LONG("color11", "color 11", &rs_color[minBright + 3]), - OPT_LONG("color12", "color 12", &rs_color[minBright + 4]), - OPT_LONG("color13", "color 13", &rs_color[minBright + 5]), - OPT_LONG("color14", "color 14", &rs_color[minBright + 6]), - OPT_LONG("color15", "color 15", &rs_color[minBright + 7]), + SPIFOPT_STR_LONG("color8", "color 8", rs_color[minBright]), + SPIFOPT_STR_LONG("color9", "color 9", rs_color[minBright + 1]), + SPIFOPT_STR_LONG("color10", "color 10", rs_color[minBright + 2]), + SPIFOPT_STR_LONG("color11", "color 11", rs_color[minBright + 3]), + SPIFOPT_STR_LONG("color12", "color 12", rs_color[minBright + 4]), + SPIFOPT_STR_LONG("color13", "color 13", rs_color[minBright + 5]), + SPIFOPT_STR_LONG("color14", "color 14", rs_color[minBright + 6]), + SPIFOPT_STR_LONG("color15", "color 15", rs_color[minBright + 7]), #endif /* NO_BRIGHTCOLOR */ #ifndef NO_BOLDUNDERLINE - OPT_LONG("colorBD", "bold color", &rs_color[colorBD]), - OPT_LONG("colorUL", "underline color", &rs_color[colorUL]), + SPIFOPT_STR_LONG("colorBD", "bold color", rs_color[colorBD]), + SPIFOPT_STR_LONG("colorUL", "underline color", rs_color[colorUL]), #endif /* NO_BOLDUNDERLINE */ - OPT_LONG("pointer-color", "mouse pointer color", &rs_color[pointerColor]), + SPIFOPT_STR_LONG("pointer-color", "mouse pointer color", rs_color[pointerColor]), #ifndef NO_CURSORCOLOR - OPT_STR('c', "cursor-color", "cursor color", &rs_color[cursorColor]), - OPT_LONG("cursor-text-color", "cursor text color", &rs_color[cursorColor2]), + SPIFOPT_STR('c', "cursor-color", "cursor color", rs_color[cursorColor]), + SPIFOPT_STR_LONG("cursor-text-color", "cursor text color", rs_color[cursorColor2]), #endif /* NO_CURSORCOLOR */ -/* =======[ X11 options ]======= */ - OPT_STR('g', "geometry", "WxH+X+Y = size and position", &rs_geometry), - OPT_BOOL('i', "iconic", "start iconified", &Options, Opt_iconic), - OPT_STR('n', "name", "client instance, icon, and title strings", &rs_name), - OPT_STR('T', "title", "title string", &rs_title), - OPT_LONG("icon-name", "icon name", &rs_iconName), - OPT_STR('B', "scrollbar-type", "choose the scrollbar type (motif, next, xterm)", &rs_scrollbar_type), - OPT_ILONG("scrollbar-width", "choose the width (in pixels) of the scrollbar", &rs_scrollbar_width), - OPT_INT('D', "desktop", "desktop to start on (requires GNOME-compliant window manager)", &rs_desktop), - OPT_ILONG("line-space", "number of extra dots between lines", &rs_line_space), + /* =======[ X11 options ]======= */ + SPIFOPT_STR('g', "geometry", "WxH+X+Y = size and position", rs_geometry), + SPIFOPT_BOOL('i', "iconic", "start iconified", Options, Opt_iconic), + SPIFOPT_STR('n', "name", "client instance, icon, and title strings", rs_name), + SPIFOPT_STR('T', "title", "title string", rs_title), + SPIFOPT_STR_LONG("icon-name", "icon name", rs_iconName), + SPIFOPT_STR('B', "scrollbar-type", "choose the scrollbar type (motif, next, xterm)", rs_scrollbar_type), + SPIFOPT_INT_LONG("scrollbar-width", "choose the width (in pixels) of the scrollbar", rs_scrollbar_width), + SPIFOPT_INT('D', "desktop", "desktop to start on (requires GNOME-compliant window manager)", rs_desktop), + SPIFOPT_INT_LONG("line-space", "number of extra dots between lines", rs_line_space), #ifndef NO_BOLDFONT - OPT_LONG("bold-font", "bold text font", &rs_boldFont), + SPIFOPT_STR_LONG("bold-font", "bold text font", rs_boldFont), #endif - OPT_STR('F', "font", "normal text font", &rs_font[0]), - OPT_ILONG("default-font-index", "set the index of the default font", &def_font_idx), - OPT_LONG("font1", "font 1", &rs_font[1]), - OPT_LONG("font2", "font 2", &rs_font[2]), - OPT_LONG("font3", "font 3", &rs_font[3]), - OPT_LONG("font4", "font 4", &rs_font[4]), - OPT_BLONG("proportional", "toggle proportional font optimizations", &Options, Opt_proportional), - OPT_LONG("font-fx", "specify font effects for the terminal fonts", &rs_font_effects), + SPIFOPT_STR('F', "font", "normal text font", rs_font[0]), + SPIFOPT_INT_LONG("default-font-index", "set the index of the default font", def_font_idx), + SPIFOPT_STR_LONG("font1", "font 1", rs_font[1]), + SPIFOPT_STR_LONG("font2", "font 2", rs_font[2]), + SPIFOPT_STR_LONG("font3", "font 3", rs_font[3]), + SPIFOPT_STR_LONG("font4", "font 4", rs_font[4]), + SPIFOPT_BOOL_LONG("proportional", "toggle proportional font optimizations", Options, Opt_proportional), + SPIFOPT_STR_LONG("font-fx", "specify font effects for the terminal fonts", rs_font_effects), -/* =======[ Pixmap options ]======= */ + /* =======[ Pixmap options ]======= */ #ifdef PIXMAP_SUPPORT - OPT_STR('P', "background-pixmap", "background pixmap [scaling optional]", &rs_pixmaps[image_bg]), - OPT_STR('I', "icon", "icon pixmap", &rs_icon), - OPT_LONG("up-arrow-pixmap", "up arrow pixmap [scaling optional]", &rs_pixmaps[image_up]), - OPT_LONG("down-arrow-pixmap", "down arrow pixmap [scaling optional]", &rs_pixmaps[image_down]), - OPT_LONG("trough-pixmap", "scrollbar background (trough) pixmap [scaling optional]", &rs_pixmaps[image_sb]), - OPT_LONG("anchor-pixmap", "scrollbar anchor pixmap [scaling optional]", &rs_pixmaps[image_sa]), - OPT_LONG("menu-pixmap", "menu pixmap [scaling optional]", &rs_pixmaps[image_menu]), - OPT_BOOL('O', "trans", "creates a pseudo-transparent Eterm", &image_toggles, IMOPT_TRANS), - OPT_BOOL('0', "itrans", "use immotile-optimized transparency", &image_toggles, IMOPT_ITRANS), - OPT_BLONG("viewport-mode", "use viewport mode for the background image", &image_toggles, IMOPT_VIEWPORT), - OPT_ILONG("shade", "old-style shade percentage (deprecated)", &rs_shade), - OPT_LONG("tint", "old-style tint mask (deprecated)", &rs_tint), - OPT_LONG("cmod", "image color modifier (\"brightness contrast gamma\")", &rs_cmod_image), - OPT_LONG("cmod-red", "red-only color modifier (\"brightness contrast gamma\")", &rs_cmod_red), - OPT_LONG("cmod-green", "green-only color modifier (\"brightness contrast gamma\")", &rs_cmod_green), - OPT_LONG("cmod-blue", "blue-only color modifier (\"brightness contrast gamma\")", &rs_cmod_blue), - OPT_STR('p', "path", "pixmap file search path", &rs_path), - OPT_ILONG("cache", "set Imlib2 image/pixmap cache size", &rs_cache_size), + SPIFOPT_STR('P', "background-pixmap", "background pixmap [scaling optional]", rs_pixmaps[image_bg]), + SPIFOPT_STR('I', "icon", "icon pixmap", rs_icon), + SPIFOPT_STR_LONG("up-arrow-pixmap", "up arrow pixmap [scaling optional]", rs_pixmaps[image_up]), + SPIFOPT_STR_LONG("down-arrow-pixmap", "down arrow pixmap [scaling optional]", rs_pixmaps[image_down]), + SPIFOPT_STR_LONG("trough-pixmap", "scrollbar background (trough) pixmap [scaling optional]", rs_pixmaps[image_sb]), + SPIFOPT_STR_LONG("anchor-pixmap", "scrollbar anchor pixmap [scaling optional]", rs_pixmaps[image_sa]), + SPIFOPT_STR_LONG("menu-pixmap", "menu pixmap [scaling optional]", rs_pixmaps[image_menu]), + SPIFOPT_BOOL('O', "trans", "creates a pseudo-transparent Eterm", image_toggles, IMOPT_TRANS), + SPIFOPT_BOOL('0', "itrans", "use immotile-optimized transparency", image_toggles, IMOPT_ITRANS), + SPIFOPT_BOOL_LONG("viewport-mode", "use viewport mode for the background image", image_toggles, IMOPT_VIEWPORT), + SPIFOPT_INT_LONG("shade", "old-style shade percentage (deprecated)", rs_shade), + SPIFOPT_STR_LONG("tint", "old-style tint mask (deprecated)", rs_tint), + SPIFOPT_STR_LONG("cmod", "image color modifier (\"brightness contrast gamma\")", rs_cmod_image), + SPIFOPT_STR_LONG("cmod-red", "red-only color modifier (\"brightness contrast gamma\")", rs_cmod_red), + SPIFOPT_STR_LONG("cmod-green", "green-only color modifier (\"brightness contrast gamma\")", rs_cmod_green), + SPIFOPT_STR_LONG("cmod-blue", "blue-only color modifier (\"brightness contrast gamma\")", rs_cmod_blue), + SPIFOPT_STR('p', "path", "pixmap file search path", rs_path), + SPIFOPT_INT_LONG("cache", "set Imlib2 image/pixmap cache size", rs_cache_size), # ifdef BACKGROUND_CYCLING_SUPPORT - OPT_STR('N', "anim", "a delay and list of pixmaps for cycling", &rs_anim_pixmap_list), + SPIFOPT_STR('N', "anim", "a delay and list of pixmaps for cycling", rs_anim_pixmap_list), # endif /* BACKGROUND_CYCLING_SUPPORT */ #endif /* PIXMAP_SUPPORT */ -/* =======[ Kanji options ]======= */ + /* =======[ Kanji options ]======= */ #ifdef MULTI_CHARSET - OPT_STR('M', "mfont", "normal text multichar font", &rs_mfont[0]), - OPT_LONG("mfont1", "multichar font 1", &rs_mfont[1]), - OPT_LONG("mfont2", "multichar font 2", &rs_mfont[2]), - OPT_LONG("mfont3", "multichar font 3", &rs_mfont[3]), - OPT_LONG("mfont4", "multichar font 4", &rs_mfont[4]), - OPT_LONG("mencoding", "multichar encoding mode (eucj/sjis/euckr/big5/gb)", &rs_multichar_encoding), + SPIFOPT_STR('M', "mfont", "normal text multichar font", rs_mfont[0]), + SPIFOPT_STR_LONG("mfont1", "multichar font 1", rs_mfont[1]), + SPIFOPT_STR_LONG("mfont2", "multichar font 2", rs_mfont[2]), + SPIFOPT_STR_LONG("mfont3", "multichar font 3", rs_mfont[3]), + SPIFOPT_STR_LONG("mfont4", "multichar font 4", rs_mfont[4]), + SPIFOPT_STR_LONG("mencoding", "multichar encoding mode (eucj/sjis/euckr/big5/gb)", rs_multichar_encoding), #endif /* MULTI_CHARSET */ #ifdef USE_XIM - OPT_LONG("input-method", "XIM input method", &rs_input_method), - OPT_LONG("preedit-type", "XIM preedit type", &rs_preedit_type), + SPIFOPT_STR_LONG("input-method", "XIM input method", rs_input_method), + SPIFOPT_STR_LONG("preedit-type", "XIM preedit type", rs_preedit_type), #endif -/* =======[ Toggles ]======= */ - OPT_BOOL('l', "login-shell", "login shell, prepend - to shell name", &Options, Opt_login_shell), - OPT_BOOL('s', "scrollbar", "display scrollbar", &Options, Opt_scrollbar), - OPT_BOOL('u', "utmp-logging", "make a utmp entry", &Options, Opt_write_utmp), - OPT_BOOL('v', "visual-bell", "visual bell", &Options, Opt_visual_bell), - OPT_BOOL('H', "home-on-output", "jump to bottom on output", &Options, Opt_home_on_output), - OPT_BLONG("home-on-input", "jump to bottom on input", &Options, Opt_home_on_input), - OPT_BOOL('q', "no-input", "configure for output only", &Options, Opt_no_input), - OPT_BLONG("scrollbar-right", "display the scrollbar on the right", &Options, Opt_scrollbar_right), - OPT_BLONG("scrollbar-floating", "display the scrollbar with no trough", &Options, Opt_scrollbar_floating), - OPT_BLONG("scrollbar-popup", "popup the scrollbar only when focused", &Options, Opt_scrollbar_popup), - OPT_BOOL('x', "borderless", "force Eterm to have no borders", &Options, Opt_borderless), + /* =======[ Toggles ]======= */ + SPIFOPT_BOOL('l', "login-shell", "login shell, prepend - to shell name", Options, Opt_login_shell), + SPIFOPT_BOOL('s', "scrollbar", "display scrollbar", Options, Opt_scrollbar), + SPIFOPT_BOOL('u', "utmp-logging", "make a utmp entry", Options, Opt_write_utmp), + SPIFOPT_BOOL('v', "visual-bell", "visual bell", Options, Opt_visual_bell), + SPIFOPT_BOOL('H', "home-on-output", "jump to bottom on output", Options, Opt_home_on_output), + SPIFOPT_BOOL_LONG("home-on-input", "jump to bottom on input", Options, Opt_home_on_input), + SPIFOPT_BOOL('q', "no-input", "configure for output only", Options, Opt_no_input), + SPIFOPT_BOOL_LONG("scrollbar-right", "display the scrollbar on the right", Options, Opt_scrollbar_right), + SPIFOPT_BOOL_LONG("scrollbar-floating", "display the scrollbar with no trough", Options, Opt_scrollbar_floating), + SPIFOPT_BOOL_LONG("scrollbar-popup", "popup the scrollbar only when focused", Options, Opt_scrollbar_popup), + SPIFOPT_BOOL('x', "borderless", "force Eterm to have no borders", Options, Opt_borderless), #ifndef NO_MAPALERT # ifdef MAPALERT_OPTION - OPT_BOOL('m', "map-alert", "uniconify on beep", &Options, Opt_map_alert), + SPIFOPT_BOOL('m', "map-alert", "uniconify on beep", Options, Opt_map_alert), # endif #endif #ifdef META8_OPTION - OPT_BOOL('8', "meta-8", "Meta key toggles 8-bit", &Options, Opt_meta8), + SPIFOPT_BOOL('8', "meta-8", "Meta key toggles 8-bit", Options, Opt_meta8), #endif - OPT_BLONG("double-buffer", "use double-buffering to reduce exposes (uses more memory)", &Options, Opt_double_buffer), - OPT_BLONG("no-cursor", "disable the text cursor", &Options, Opt_no_cursor), - OPT_BLONG("pause", "pause after the child process exits", &Options, Opt_pause), - OPT_BLONG("xterm-select", "duplicate xterm's broken selection behavior", &Options, Opt_xterm_select), - OPT_BLONG("select-line", "triple-click selects whole line", &Options, Opt_select_whole_line), - OPT_BLONG("select-trailing-spaces", "do not skip trailing spaces when selecting", &Options, Opt_select_trailing_spaces), - OPT_BLONG("report-as-keysyms", "report special keys as keysyms", &Options, Opt_report_as_keysyms), - OPT_BLONG("buttonbar", "toggle the display of all buttonbars", &rs_buttonbars, BBAR_FORCE_TOGGLE), - OPT_BLONG("resize-gravity", "toggle gravitation to nearest corner on resize", &Options, Opt_resize_gravity), + SPIFOPT_BOOL_LONG("double-buffer", "use double-buffering to reduce exposes (uses more memory)", Options, Opt_double_buffer), + SPIFOPT_BOOL_LONG("no-cursor", "disable the text cursor", Options, Opt_no_cursor), + SPIFOPT_BOOL_LONG("pause", "pause after the child process exits", Options, Opt_pause), + SPIFOPT_BOOL_LONG("xterm-select", "duplicate xterm's broken selection behavior", Options, Opt_xterm_select), + SPIFOPT_BOOL_LONG("select-line", "triple-click selects whole line", Options, Opt_select_whole_line), + SPIFOPT_BOOL_LONG("select-trailing-spaces", "do not skip trailing spaces when selecting", Options, Opt_select_trailing_spaces), + SPIFOPT_BOOL_LONG("report-as-keysyms", "report special keys as keysyms", Options, Opt_report_as_keysyms), + SPIFOPT_BOOL_LONG("buttonbar", "toggle the display of all buttonbars", rs_buttonbars, BBAR_FORCE_TOGGLE), + SPIFOPT_BOOL_LONG("resize-gravity", "toggle gravitation to nearest corner on resize", Options, Opt_resize_gravity), /* =======[ Keyboard options ]======= */ #if defined (HOTKEY_CTRL) || defined (HOTKEY_META) - OPT_LONG("big-font-key", "keysym for font size increase", &rs_bigfont_key), - OPT_LONG("small-font-key", "keysym for font size decrease", &rs_smallfont_key), + SPIFOPT_STR_LONG("big-font-key", "keysym for font size increase", rs_bigfont_key), + SPIFOPT_STR_LONG("small-font-key", "keysym for font size decrease", rs_smallfont_key), #endif - OPT_ILONG("meta-mod", "modifier to interpret as the Meta key", &rs_meta_mod), - OPT_ILONG("alt-mod", "modifier to interpret as the Alt key", &rs_alt_mod), - OPT_ILONG("numlock-mod", "modifier to interpret as the NumLock key", &rs_numlock_mod), + SPIFOPT_INT_LONG("meta-mod", "modifier to interpret as the Meta key", rs_meta_mod), + SPIFOPT_INT_LONG("alt-mod", "modifier to interpret as the Alt key", rs_alt_mod), + SPIFOPT_INT_LONG("numlock-mod", "modifier to interpret as the NumLock key", rs_numlock_mod), #ifdef GREEK_SUPPORT - OPT_LONG("greek-keyboard", "greek keyboard mapping (iso or ibm)", &rs_greek_keyboard), + SPIFOPT_STR_LONG("greek-keyboard", "greek keyboard mapping (iso or ibm)", rs_greek_keyboard), #endif - OPT_BLONG("app-keypad", "application keypad mode", &PrivateModes, PrivMode_aplKP), - OPT_BLONG("app-cursor", "application cursor key mode", &PrivateModes, PrivMode_aplCUR), + SPIFOPT_BOOL_LONG("app-keypad", "application keypad mode", PrivateModes, PrivMode_aplKP), + SPIFOPT_BOOL_LONG("app-cursor", "application cursor key mode", PrivateModes, PrivMode_aplCUR), -/* =======[ Misc options ]======= */ - OPT_INT('L', "save-lines", "lines to save in scrollback buffer", &rs_saveLines), - OPT_ILONG("min-anchor-size", "minimum size of the scrollbar anchor", &rs_min_anchor_size), + /* =======[ Misc options ]======= */ + SPIFOPT_INT('L', "save-lines", "lines to save in scrollback buffer", rs_saveLines), + SPIFOPT_INT_LONG("min-anchor-size", "minimum size of the scrollbar anchor", rs_min_anchor_size), #ifdef BORDER_WIDTH_OPTION - OPT_INT('w', "border-width", "term window border width", &(TermWin.internalBorder)), + SPIFOPT_INT('w', "border-width", "term window border width", TermWin.internalBorder), #endif #ifdef PRINTPIPE - OPT_LONG("print-pipe", "print command", &rs_print_pipe), + SPIFOPT_STR_LONG("print-pipe", "print command", rs_print_pipe), #endif #ifdef CUTCHAR_OPTION - OPT_LONG("cut-chars", "seperators for double-click selection", &rs_cutchars), + SPIFOPT_STR_LONG("cut-chars", "seperators for double-click selection", rs_cutchars), #endif /* CUTCHAR_OPTION */ - OPT_LONG("finished-title", "text to add to window title after program termination", &rs_finished_title), - OPT_LONG("finished-text", "text to output after program termination", &rs_finished_text), - OPT_LONG("term-name", "value to use for setting $TERM", &rs_term_name), - OPT_LONG("pipe-name", "filename of console pipe to emulate -C", &rs_pipe_name), - OPT_STR('a', "attribute", "parse an attribute in the specified context", NULL), - OPT_BOOL('C', "console", "grab console messages", &Options, Opt_console), - OPT_ARGS('e', "exec", "execute a command rather than a shell", &rs_exec_args) + SPIFOPT_STR_LONG("finished-title", "text to add to window title after program termination", rs_finished_title), + SPIFOPT_STR_LONG("finished-text", "text to output after program termination", rs_finished_text), + SPIFOPT_STR_LONG("term-name", "value to use for setting $TERM", rs_term_name), + SPIFOPT_STR_LONG("pipe-name", "filename of console pipe to emulate -C", rs_pipe_name), + SPIFOPT_ABSV('a', "attribute", "parse an attribute in the specified context", handle_attribute), + SPIFOPT_BOOL('C', "console", "grab console messages", Options, Opt_console), + SPIFOPT_ARGS('e', "exec", "execute a command rather than a shell", rs_exec_args) }; /* Print usage information */ @@ -342,28 +336,11 @@ static void usage(void) { - - unsigned short i, col; - printf("Eterm Enlightened Terminal Emulator for the X Window System\n"); printf("Copyright (c) 1997-2002, " AUTHORS "\n\n"); - printf("Usage for " APL_NAME " " VERSION ":\n\n"); - printf("%7s %17s %40s\n", "POSIX", "GNU", "Description"); - printf("%8s %10s %41s\n", "=======", "===============================", - "========================================="); - for (i = 0; i < optList_numoptions(); i++) { - printf("%" INDENT "s", " "); - if (optList[i].short_opt) { - printf("-%c, ", optList[i].short_opt); - } else { - printf(" "); - } - printf("--%s", optList[i].long_opt); - for (col = strlen(optList[i].long_opt); col < 30; col++) { - printf(" "); - } - printf("%s\n", optList[i].description); - } + + spifopt_usage(); + printf("\nOption types:\n"); printf(" (bool) -- Boolean option ('1', 'on', 'yes', or 'true' to activate, '0', 'off', 'no', or 'false' to deactivate)\n"); printf(" (int) -- Integer option (any signed number of reasonable value, usually in decimal/octal/hex)\n"); @@ -805,366 +782,10 @@ exit(EXIT_SUCCESS); } -void -get_options(int argc, char *argv[]) -{ - - register unsigned long i, j, l; - unsigned char bad_opts = 0; - - for (i = 1; i < (unsigned long) argc; i++) { - - register char *opt = argv[i]; - char *val_ptr = NULL; - unsigned char islong = 0, hasequal = 0; - - D_OPTIONS(("argv[%d] == \"%s\"\n", i, argv[i])); - - if (*opt != '-') { - print_error("unexpected argument %s -- expected option\n", opt); - CHECK_BAD(); - continue; - } - if (*(opt + 1) == '-') { - islong = 1; - D_OPTIONS(("Long option detected\n")); - } - if (islong) { - opt += 2; - for (j = 0; j < optList_numoptions(); j++) { - if (!strncasecmp(optList[j].long_opt, opt, (l = strlen(optList[j].long_opt))) && - (opt[l] == '=' || !opt[l])) { - D_OPTIONS(("Match found at %d: %s == %s\n", j, optList[j].long_opt, opt)); - break; - } - } - if (j == optList_numoptions()) { - print_error("unrecognized long option --%s\n", opt); - CHECK_BAD(); - continue; - } - /* Put option-specific warnings here -- mej */ -#if 0 /* No longer needed, since it works :) */ - if (optList[j].short_opt == 'w') { - print_error("warning: Use of the -w / --border-width option is discouraged and unsupported.\n"); - } -#endif - - if ((val_ptr = strchr(opt, '=')) != NULL) { - *val_ptr = 0; - val_ptr++; - hasequal = 1; - } else { - if (argv[i + 1]) { - if (*argv[i + 1] != '-' || strcasestr(optList[j].long_opt, "font") || strcasestr(optList[j].long_opt, "geometry")) { - val_ptr = argv[++i]; - } - } - } - D_OPTIONS(("hasequal == %d val_ptr == %10.8p \"%s\"\n", hasequal, val_ptr, (val_ptr ? val_ptr : "(nil)"))); - if (j == 0 || j == 1) { - continue; - } - if (!(optList[j].flag & OPT_BOOLEAN) && (val_ptr == NULL)) { - print_error("long option --%s requires a%s value\n", opt, - (optList[j].flag & OPT_INTEGER ? "n integer" : " string")); - CHECK_BAD(); - continue; - } - if (!strcasecmp(opt, "exec")) { - D_OPTIONS(("--exec option detected\n")); - if (!hasequal) { - - register unsigned short k, len = argc - i; - - rs_exec_args = (char **) MALLOC(sizeof(char *) * (argc - i + 1)); - - for (k = 0; k < len; k++) { - rs_exec_args[k] = STRDUP(argv[k + i]); - D_OPTIONS(("rs_exec_args[%d] == %s\n", k, rs_exec_args[k])); - } - rs_exec_args[k] = (char *) NULL; - return; - } else { - - register unsigned short k; - - rs_exec_args = (char **) MALLOC(sizeof(char *) * (num_words(val_ptr) + 1)); - - for (k = 0; val_ptr; k++) { - rs_exec_args[k] = get_word(1, val_ptr); - val_ptr = get_pword(2, val_ptr); - D_OPTIONS(("rs_exec_args[%d] == %s\n", k, rs_exec_args[k])); - } - rs_exec_args[k] = (char *) NULL; - } - } else if (!strcasecmp(opt, "help")) { - usage(); - } else if (!strcasecmp(opt, "version")) { - version(); - } else if (!strcasecmp(opt, "attribute")) { - conf_parse_line(NULL, val_ptr); - } else { /* It's not --exec */ - if (optList[j].flag & OPT_BOOLEAN) { /* Boolean value */ - D_OPTIONS(("Boolean option detected\n")); - if (val_ptr) { - if (BOOL_OPT_ISTRUE(val_ptr)) { - D_OPTIONS(("\"%s\" == TRUE\n", val_ptr)); - if (optList[j].maskvar) { - *(optList[j].maskvar) |= optList[j].mask; - } - } else if (BOOL_OPT_ISFALSE(val_ptr)) { - D_OPTIONS(("\"%s\" == FALSE\n", val_ptr)); - if (optList[j].maskvar) { - *(optList[j].maskvar) &= ~(optList[j].mask); - } - } else { - print_error("unrecognized boolean value \"%s\" for option --%s\n", - val_ptr, optList[j].long_opt); - CHECK_BAD(); - } - } else { /* No value, so force it on */ - D_OPTIONS(("Forcing option --%s to TRUE\n", opt)); - if (optList[j].maskvar) { - *(optList[j].maskvar) |= optList[j].mask; - } - } - } else if (optList[j].flag & OPT_INTEGER) { /* Integer value */ - D_OPTIONS(("Integer option detected\n")); - *((int *) optList[j].pval) = strtol(val_ptr, (char **) NULL, 0); - } else { /* String value */ - D_OPTIONS(("String option detected\n")); - if (val_ptr && optList[j].pval) { - *((const char **) optList[j].pval) = STRDUP(val_ptr); - } - } - } - } else { /* It's a POSIX option */ - - register unsigned short pos; - unsigned char done = 0; - - for (pos = 1; opt[pos] && !done; pos++) { - for (j = 0; j < optList_numoptions(); j++) { - if (optList[j].short_opt == opt[pos]) { - D_OPTIONS(("Match found at %d: %c == %c\n", j, optList[j].short_opt, opt[pos])); - break; - } - } - if (j == optList_numoptions()) { - print_error("unrecognized option -%c\n", opt[pos]); - CHECK_BAD(); - continue; - } - /* Put option-specific warnings here -- mej */ -#if 0 /* No longer needed, since it works :) */ - if (optList[j].short_opt == 'w') { - print_error("warning: Use of the -w / --border-width option is discouraged and unsupported.\n"); - } -#endif - - if (!(optList[j].flag & OPT_BOOLEAN)) { - if (opt[pos + 1]) { - val_ptr = opt + pos + 1; - done = 1; - } else if ((val_ptr = argv[++i]) != NULL) { - done = 1; - } - D_OPTIONS(("val_ptr == %s done == %d\n", val_ptr, done)); - if (j == 0 || j == 1) { - continue; - } - if ((val_ptr == NULL) || ((*val_ptr == '-') && (optList[j].short_opt != 'F') && (optList[j].short_opt != 'g'))) { - print_error("option -%c requires a%s value\n", opt[pos], - (optList[j].flag & OPT_INTEGER ? "n integer" : " string")); - CHECK_BAD(); - if (val_ptr) { /* If the "arg" was actually an option, don't skip it */ - i--; - } - continue; - } - } - if (opt[pos] == 'e') { /* It's an exec */ - - register unsigned short k, len; - - D_OPTIONS(("-e option detected\n")); - - if (opt[pos + 1]) { - len = argc - i + 2; - k = i; - } else { - len = argc - i + 1; - k = i + 1; - } - D_OPTIONS(("len == %d k == %d\n", len, k)); - rs_exec_args = (char **) MALLOC(sizeof(char *) * len); - - if (k == i) { - rs_exec_args[0] = STRDUP((char *) (val_ptr)); - D_OPTIONS(("rs_exec_args[0] == %s\n", rs_exec_args[0])); - k++; - } else { - rs_exec_args[0] = STRDUP(argv[k - 1]); - D_OPTIONS(("rs_exec_args[0] == %s\n", rs_exec_args[0])); - } - for (; k < argc; k++) { - rs_exec_args[k - i] = STRDUP(argv[k]); - D_OPTIONS(("rs_exec_args[%d] == %s\n", k - i, rs_exec_args[k - i])); - } - rs_exec_args[len - 1] = (char *) NULL; - return; - } else if (opt[pos] == 'h') { - usage(); - } else if (opt[pos] == 'a') { - conf_parse_line(NULL, val_ptr); - } else { - if (optList[j].flag & OPT_BOOLEAN) { /* Boolean value */ - D_OPTIONS(("Boolean option detected\n")); - if (optList[j].maskvar) { - *(optList[j].maskvar) |= optList[j].mask; - } - } else if (optList[j].flag & OPT_INTEGER) { /* Integer value */ - D_OPTIONS(("Integer option detected\n")); - *((int *) optList[j].pval) = strtol(val_ptr, (char **) NULL, 0); - D_OPTIONS(("Got value %d\n", *((int *) optList[j].pval))); - } else { /* String value */ - D_OPTIONS(("String option detected\n")); - if (optList[j].pval) { - *((const char **) optList[j].pval) = STRDUP(val_ptr); - } - } /* End if value type */ - } /* End if option type */ - } /* End if (exec or help or other) */ - } /* End if (islong) */ - } /* End main for loop */ -} - -void -get_initial_options(int argc, char *argv[]) +static void +handle_attribute(char *val_ptr) { - - register unsigned long i, j; - - for (i = 1; i < (unsigned long) argc; i++) { - - register char *opt = argv[i]; - char *val_ptr = NULL; - unsigned char islong = 0, hasequal = 0; - - D_OPTIONS(("argv[%d] == \"%s\"\n", i, argv[i])); - - if (*opt != '-') { - D_OPTIONS(("Non-option detected.\n")); - continue; - } - if (*(opt + 1) == '-') { - islong = 1; - D_OPTIONS(("Long option detected\n")); - } - if (islong) { - opt += 2; - if (!BEG_STRCASECMP(opt, "theme")) { - j = 0; - } else if (!BEG_STRCASECMP(opt, "config-file")) { - j = 1; - } else if (!BEG_STRCASECMP(opt, "display")) { - j = 2; - } else if (!BEG_STRCASECMP(opt, "debug")) { - j = 3; - } else if (!BEG_STRCASECMP(opt, "install")) { - j = 4; - } else if (!BEG_STRCASECMP(opt, "exec") && (*(opt+4) != '=')) { - i = (unsigned long) argc; - break; - } else - continue; - - if ((val_ptr = strchr(opt, '=')) != NULL) { - *val_ptr = 0; - val_ptr++; - hasequal = 1; - } else { - if (argv[i + 1]) { - if (*argv[i + 1] != '-') { - val_ptr = argv[++i]; - } - } - } - D_OPTIONS(("hasequal == %d val_ptr == %10.8p \"%s\"\n", hasequal, val_ptr, val_ptr)); - if (val_ptr == NULL && j != 4) { - print_error("long option --%s requires a%s value", opt, (j == 3 ? "n integer" : " string\n")); - continue; - } - if (j == 3) { - D_OPTIONS(("Integer option detected\n")); - *((int *) optList[j].pval) = strtol(val_ptr, (char **) NULL, 0); - } else if (j == 4) { - if (val_ptr) { - if (BOOL_OPT_ISTRUE(val_ptr)) { - D_OPTIONS(("\"%s\" == TRUE\n", val_ptr)); - if (optList[j].maskvar) { - *(optList[j].maskvar) |= optList[j].mask; - } - } else if (BOOL_OPT_ISFALSE(val_ptr)) { - D_OPTIONS(("\"%s\" == FALSE\n", val_ptr)); - if (optList[j].maskvar) { - *(optList[j].maskvar) &= ~(optList[j].mask); - } - } - } else { /* No value, so force it on */ - D_OPTIONS(("Forcing option --%s to TRUE\n", opt)); - if (optList[j].maskvar) { - *(optList[j].maskvar) |= optList[j].mask; - } - } - } else { - D_OPTIONS(("String option detected\n")); - if (val_ptr && optList[j].pval) { - *((const char **) optList[j].pval) = STRDUP(val_ptr); - } - } - } else { /* It's a POSIX option */ - - register unsigned short pos; - unsigned char done = 0; - - D_OPTIONS(("Short option detected.\n")); - for (pos = 1; opt[pos] && !done; pos++) { - if (opt[pos] == 't') { - j = 0; - } else if (opt[pos] == 'X') { - j = 1; - } else if (opt[pos] == 'd') { - j = 2; - } else if (opt[pos] == 'e') { - i = (unsigned long) argc; - break; - } else { - continue; - } - - if (opt[pos + 1]) { - val_ptr = opt + pos + 1; - done = 1; - } else if ((val_ptr = argv[++i]) != NULL) { - done = 1; - } - D_OPTIONS(("val_ptr == %s done == %d\n", val_ptr, done)); - if ((val_ptr == NULL) || (*val_ptr == '-')) { - print_error("option -%c requires a string value\n", opt[pos]); - if (val_ptr) { /* If the "arg" was actually an option, don't skip it */ - i--; - } - continue; - } - D_OPTIONS(("String option detected\n")); - if (optList[j].pval) { - *((const char **) optList[j].pval) = STRDUP(val_ptr); - } - } /* End for loop */ - } /* End if (islong) */ - } /* End main for loop */ + conf_parse_line(NULL, val_ptr); } /* The config file parsers. Each function handles a given context. */ @@ -2724,6 +2345,16 @@ return (conf_parse(conf_name, *theme, path)); } return NULL; +} + +void +init_libast(void) +{ + libast_set_program_name(PACKAGE); + libast_set_program_version(VERSION); + SPIFOPT_OPTLIST_SET(option_list); + SPIFOPT_NUMOPTS_SET(sizeof(option_list) / sizeof(spifopt_t)); + SPIFOPT_ALLOWBAD_SET(3); } /* Initialize the default values for everything */ =================================================================== RCS file: /cvsroot/enlightenment/eterm/Eterm/src/options.h,v retrieving revision 1.36 retrieving revision 1.36.2.1 diff -u -3 -r1.36 -r1.36.2.1 --- options.h 21 Feb 2002 21:05:16 -0000 1.36 +++ options.h 29 Apr 2002 21:47:38 -0000 1.36.2.1 @@ -28,20 +28,6 @@ #include <X11/Intrinsic.h> /* Xlib, Xutil, Xresource, Xfuncproto */ /************ Macros and Definitions ************/ -#define OPT_BOOLEAN 0x0001 -#define OPT_INTEGER 0x0002 -#define OPT_STRING 0x0004 -#define OPT_ARGUMENT 0x0008 - -#define OPT_STR(s, l, d, p) { s, l, "(str) " d, OPT_STRING, (const char **) p, 0, 0 } -#define OPT_INT(s, l, d, p) { s, l, "(int) " d, OPT_INTEGER, (const int *) p, 0, 0 } -#define OPT_BOOL(s, l, d, v, m) { s, l, "(bool) " d, OPT_BOOLEAN, NULL, v, m } -#define OPT_LONG(l, d, p) { 0, l, "(str) " d, OPT_STRING, (const char **) p, 0, 0 } -#define OPT_ARGS(s, l, d, p) { s, l, "(str) " d, OPT_ARGUMENT, (const char ***) p, 0, 0 } -#define OPT_BLONG(l, d, v, m) { 0, l, "(bool) " d, OPT_BOOLEAN, NULL, v, m } -#define OPT_ILONG(l, d, p) { 0, l, "(int) " d, OPT_INTEGER, (const int *) p, 0, 0 } -#define optList_numoptions() (sizeof(optList)/sizeof(optList[0])) - # define Opt_console (1LU << 0) # define Opt_login_shell (1LU << 1) # define Opt_iconic (1LU << 2) @@ -84,18 +70,6 @@ #define PARSE_TRY_NO_THEME ((unsigned char) 0x04) #define PARSE_TRY_ALL ((unsigned char) 0x07) -/* This defines how many mistakes to allow before giving up - and printing the usage -- mej */ -#define BAD_THRESHOLD 3 -#define CHECK_BAD() do { \ - if (++bad_opts >= BAD_THRESHOLD) { \ - print_error("Error threshold exceeded, giving up.\n"); \ - usage(); \ - } else { \ - print_error("Attempting to continue, but strange things may happen.\n"); \ - } \ - } while(0) - #define to_keysym(p,s) do { KeySym sym; \ if (s && ((sym = XStringToKeysym(s)) != 0)) *p = sym; \ } while (0) @@ -160,9 +134,8 @@ _XFUNCPROTOBEGIN unsigned long num_words(const char *str); -extern void get_initial_options(int, char **); -extern void get_options(int, char **); extern char *conf_parse_theme(char **theme, char *conf_name, unsigned char fallback); +extern void init_libast(void); extern void init_defaults(void); extern void post_parse(void); unsigned char save_config(char *, unsigned char); =================================================================== RCS file: /cvsroot/enlightenment/eterm/Eterm/src/startup.c,v retrieving revision 1.29 retrieving revision 1.29.2.1 diff -u -3 -r1.29 -r1.29.2.1 --- startup.c 3 Feb 2002 20:53:07 -0000 1.29 +++ startup.c 29 Apr 2002 21:47:38 -0000 1.29.2.1 @@ -21,7 +21,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -static const char cvs_ident[] = "$Id: startup.c,v 1.29 2002/02/03 20:53:07 mej Exp $"; +static const char cvs_ident[] = "$Id: startup.c,v 1.29.2.1 2002/04/29 21:47:38 mej Exp $"; #include "config.h" #include "feature.h" @@ -88,9 +88,7 @@ PABLO_START_TRACING(); getcwd(initial_dir, PATH_MAX); - - libast_set_program_name(PACKAGE); - libast_set_program_version(VERSION); + init_libast(); /* Open display, get options/resources and create the window */ if (getenv("DISPLAY") == NULL) { @@ -101,7 +99,7 @@ /* This MUST be called before any other Xlib functions */ - get_initial_options(argc, argv); + spifopt_parse(argc, argv); init_defaults(); #ifdef NEED_LINUX_HACK @@ -188,7 +186,7 @@ D_OPTIONS(("New rs_path set to \"%s\"\n", rs_path)); } #endif - get_options(argc, argv); + spifopt_parse(argc, argv); D_UTMP(("Saved real uid/gid = [ %d, %d ] effective uid/gid = [ %d, %d ]\n", my_ruid, my_rgid, my_euid, my_egid)); D_UTMP(("Now running with real uid/gid = [ %d, %d ] effective uid/gid = [ %d, %d ]\n", getuid(), getgid(), geteuid(), getegid())); |