[581] in arla-drinkers

home help back first fref pref prev next nref lref last post

fs getarg

daemon@ATHENA.MIT.EDU (Love)
Fri Feb 5 00:34:07 1999

From owner-arla-drinkers@stacken.kth.se Fri Feb 05 05:34:06 1999
Return-Path: <owner-arla-drinkers@stacken.kth.se>
Delivered-To: arla-drinkers-mtg@bloom-picayune.mit.edu
Received: (qmail 1419 invoked from network); 5 Feb 1999 05:34:04 -0000
Received: from unknown (HELO sundance.stacken.kth.se) (130.237.234.41)
  by bloom-picayune.mit.edu with SMTP; 5 Feb 1999 05:34:04 -0000
Received: (from majordom@localhost)
	by sundance.stacken.kth.se (8.8.8/8.8.8) id GAA06865
	for arla-drinkers-list; Fri, 5 Feb 1999 06:29:23 +0100 (MET)
Received: from elixir.e.kth.se (1073744992@elixir.e.kth.se [130.237.48.5])
	by sundance.stacken.kth.se (8.8.8/8.8.8) with ESMTP id GAA06861
	for <arla-drinkers@stacken.kth.se>; Fri, 5 Feb 1999 06:29:16 +0100 (MET)
Received: from anchor.s3.kth.se (anchor.s3.kth.se [130.237.43.59])
	by elixir.e.kth.se (8.9.2/8.9.2) with ESMTP id GAA19464;
	Fri, 5 Feb 1999 06:29:15 +0100 (MET)
Received: (from lha@localhost)
	by anchor.s3.kth.se (8.9.2/8.9.2) id GAA01727;
	Fri, 5 Feb 1999 06:29:14 +0100 (MET)
To: Chuck Lever <cel@monkey.org>
cc: arla-drinkers@stacken.kth.se
References: <199902050206.DAA05697@sundance.stacken.kth.se>
From: Love <lha@stacken.kth.se>
Mime-Version: 1.0 (generated by tm-edit 7.106)
Content-Type: text/plain; charset=US-ASCII
Subject: fs getarg
Date: 05 Feb 1999 06:29:00 +0100
In-Reply-To: owner-arla-drinkers@stacken.kth.se's message of Fri, 5 Feb 1999 03:06:14 +0100 (MET)
Message-ID: <amn22tctb7.fsf@anchor.s3.kth.se>
Lines: 91
X-Mailer: Gnus v5.5/Emacs 20.2
Sender: owner-arla-drinkers@stacken.kth.se
Precedence: bulk

Chuck Lever writes:

> first, "fs wscell" returned the workstation's cellname followed by core
> garbage.  the fix is to change line 2747 of arlad/messages.c:

Fixed that, thanks.

> second, the "newcell" subcommand causes "fs" command to exit quietly when
> an error occurs. the exiting is caused by "return 1;".  i rewrote
> newcell_cmd to use "return 0;" and to print a reasonable error message. 
> the only other subcommand of "fs" that uses "return 1;" is "quit."

The sl stuff in arla should always return 0 if its not supposed to
quit. Fixed some other places too.

I used getarg() to parse the arguments in newcell, will force
getarg to do the right thing any day soon (you have to do
"fs newcell -cell new.cell -server foo -server bar -server baz" now)

Love

Index: fs.c
===================================================================
RCS file: /usr/local/cvsroot/arla/appl/fs.c,v
retrieving revision 1.63
diff -u -w -u -w -r1.63 fs.c
--- fs.c	1999/01/10 02:45:09	1.63
+++ fs.c	1999/02/05 05:18:48
@@ -703,14 +703,56 @@
 static int
 newcell_cmd (int argc, char **argv)
 {
-    argc--;
-    argv++;
+    char *cell = NULL;
+    getarg_strings servers = { 0, NULL };
+    int ret, help = 0;
+    int optind = 0;
 
-    if (argc < 2) {
-	printf ("newcell: Missing required parameter `-cell'\n");
-	return 1;
+    struct getargs ncargs[] = {
+	{"cell", 'c', arg_string,  
+	 NULL, "new cell", NULL},
+	{"servers", 's', arg_strings,
+	 NULL, "server in cell", "one server"},
+	{"help", 'h', arg_flag,
+	 NULL, "get help", NULL},
+        {NULL,      0, arg_end, NULL}}, 
+				  *arg;
+			       
+    arg = ncargs;
+    arg->value = &cell; arg++;
+    arg->value = &servers; arg++;
+    arg->value = &help; arg++;
+
+    if (getarg (ncargs, argc, argv, &optind, ARG_AFSSTYLE)) {
+	arg_printusage(ncargs, "newcell", NULL, ARG_AFSSTYLE);
+	return 0;
     }
-    return fs_newcell (argv[0], argc - 1, argv + 1);
+
+    if (help) {
+	arg_printusage(ncargs, "newcell", NULL, ARG_AFSSTYLE);
+	goto out;
+    }
+
+    if (cell == NULL) {
+	fprintf (stderr, "You have to give a cell\n");
+	goto out;
+    }
+
+    if (servers.num_strings == 0) {
+	fprintf (stderr, "You didn't give servers, will use DNS\n");
+	goto out;
+    }
+
+    ret = fs_newcell (cell, servers.num_strings, servers.strings);
+    if (ret)
+	fprintf (stderr, "fs_newcell failed with %s (%d)\n",
+		 koerr_gettext(ret), ret);
+    
+ out:
+    if (servers.strings)
+	free (servers.strings);
+
+    return 0;
 }
 
 static int

home help back first fref pref prev next nref lref last post