[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Antiright-devel] antiright/xshell arguments.c xshell.c
From: |
Jeffrey Bedard |
Subject: |
[Antiright-devel] antiright/xshell arguments.c xshell.c |
Date: |
Fri, 03 Aug 2007 20:24:30 +0000 |
CVSROOT: /sources/antiright
Module name: antiright
Changes by: Jeffrey Bedard <jefbed> 07/08/03 20:24:30
Modified files:
xshell : arguments.c xshell.c
Log message:
Refactord option handling code, split out addition and option selection.
Added usage display function.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/antiright/xshell/arguments.c?cvsroot=antiright&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/antiright/xshell/xshell.c?cvsroot=antiright&r1=1.2&r2=1.3
Patches:
Index: arguments.c
===================================================================
RCS file: /sources/antiright/antiright/xshell/arguments.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- arguments.c 22 Jul 2007 21:54:10 -0000 1.3
+++ arguments.c 3 Aug 2007 20:24:30 -0000 1.4
@@ -23,14 +23,18 @@
#include "xshell.h"
+void
+xsh_show_usage_and_exit()
+{
+ fprintf(stderr, "Usage: xshell [-[a[]o[[r rows]n[g X+Y]]]"
+ " BUTTON] ...\n");
+ exit(1);
+}
static void
-handle_options(XShell * xsh, int argc, char ** argv, unsigned int * counter)
+handle_add_options(XShell * xsh, int argc, char ** argv,
+ unsigned int * counter)
{
- switch(argv[*counter][1])
- {
- case 'a': /* Add options. */
- {
switch(argv[*counter][2])
{
case 'l': /* Label. */
@@ -45,6 +49,7 @@
xsh->gui.layout.column_count++;
xsh->gui.layout.row_count=0;
break;
+
case 't': /* Field. */
xshell_text_new(xsh, xsh->gui.widgets, 0,
(*counter)*16, "TEXT");
@@ -54,10 +59,12 @@
(*counter)*16, "TEXT");
break;
}
- }
- break;
- case 'o':
- {
+}
+
+static void
+handle_option_options(XShell * xsh, int argc, char ** argv,
+ unsigned int * counter)
+{
switch(argv[*counter][2])
{
case 'g':
@@ -82,9 +89,6 @@
}
break;
case 'n':
- /*xsh->gui.widgets
- ->geometry.override_redirect
- =True;*/
{
XSetWindowAttributes attr;
attr.override_redirect=True;
@@ -106,12 +110,31 @@
printf("%d\n",
xsh->gui.layout.max_row_count);
break;
}
- }
+}
+
+static void
+handle_options(XShell * xsh, int argc, char ** argv, unsigned int * counter)
+{
+ switch(argv[*counter][1])
+ {
+ case '-': /* Handle GNU long options. */
+ xsh_show_usage_and_exit();
+ break;
+ case 'a': /* Add options. */
+ handle_add_options(xsh, argc, argv, counter);
+ break;
+ case 'h':
+ xsh_show_usage_and_exit();
+ break;
+ case 'o':
+ handle_option_options(xsh, argc, argv, counter);
break;
case 't': /* test area */
{
}
break;
+ default:
+ xsh_show_usage_and_exit();
}
}
Index: xshell.c
===================================================================
RCS file: /sources/antiright/antiright/xshell/xshell.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- xshell.c 23 Jul 2007 01:58:46 -0000 1.2
+++ xshell.c 3 Aug 2007 20:24:30 -0000 1.3
@@ -92,6 +92,7 @@
XMapWindow(dpy, toplevel);
}
+
int
main(int argc, char ** argv)
{
@@ -99,11 +100,9 @@
Display * dpy;
if(argc<=1)
{
+
/* This should be split to function and kept with argument
handler code. */
- fprintf(stderr, "Usage: xshell [-[a[]o[[r rows]n[g X+Y]]]"
- " BUTTON] ...\n");
- exit(1);
}
SETUP_XSHELL(xsh);
dpy=xsh.gui.display=XOpenDisplay(NULL);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Antiright-devel] antiright/xshell arguments.c xshell.c,
Jeffrey Bedard <=