diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2023-02-11 10:44:16 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2023-02-11 10:44:16 -0800 |
commit | 7825f39cb7d6e1cbfe7fe86efc23e19148253149 (patch) | |
tree | f2eb9ec40fce64f4108035563b6a12c6e8cda616 /xfd.c | |
parent | 9079fc7a7138aaaae6a4bc99e97c8eb073875a93 (diff) |
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'xfd.c')
-rw-r--r-- | xfd.c | 24 |
1 files changed, 20 insertions, 4 deletions
@@ -70,7 +70,7 @@ static XrmOptionDescRec xfd_options[] = { {"-columns", "*grid.cellColumns", XrmoptionSepArg, (caddr_t) NULL }, }; -static void usage(void) _X_NORETURN _X_COLD; +static void usage(int exitval) _X_NORETURN _X_COLD; static void SelectChar(Widget w, XtPointer closure, XtPointer data); static void do_quit(Widget w, XEvent *event, String *params, Cardinal *num_params) _X_NORETURN; @@ -134,7 +134,7 @@ static XtResource Resources[] = { #undef Offset static void -usage(void) +usage(int exitval) { fprintf (stderr, gettext("usage: %s [-options ...] "), ProgramName); fprintf (stderr, "-fn "); @@ -161,7 +161,7 @@ usage(void) fprintf (stderr, gettext("number number of rows in grid\n")); fprintf (stderr, " -columns "); fprintf (stderr, gettext("number number of columns in grid\n")); - exit (1); + exit (exitval); } @@ -190,6 +190,22 @@ main(int argc, char *argv[]) ProgramName = argv[0]; + /* Handle args that don't require opening a display */ + for (int n = 1; n < argc; n++) { + const char *argn = argv[n]; + /* accept single or double dash for -help & -version */ + if (argn[0] == '-' && argn[1] == '-') { + argn++; + } + if (strcmp (argn, "-help") == 0) { + usage (0); + } + if (strcmp (argn, "-version") == 0) { + puts (PACKAGE_STRING); + exit (0); + } + } + toplevel = XtAppInitialize (&xtcontext, "Xfd", xfd_options, XtNumber(xfd_options), &argc, argv, NULL, NULL, 0); @@ -200,7 +216,7 @@ main(int argc, char *argv[]) fprintf(stderr, " %s", argv[n]); } fputs("\n\n", stderr); - usage (); + usage (1); } #ifdef USE_GETTEXT |