sl/roken and parsing ramblings
Love
lha at stacken.kth.se
Sun Jun 21 22:47:36 CEST 1998
John Hawkinson <jhawk at MIT.EDU> writes:
> What does sl stand for?
This is that everstanding questing that everyone ask
Assar and Joda...
(I didn't write it, I just stole it from kth-krb)
> There's an inconsistency in the way sl_command() handles return
> values versus the way fs (et al) do so.
>
> If sl_command returns -1 (should be a constant, proably), fs will
> print out "$argv1: Unknown command".
>
> But various fs commands return -1 to signal
> invalid usage syntaxes.
This is just wrong. 0 means ``ok dont complain'', everything else
means ``go and die''. Like in sl_loop(). Now I added -1 == bad command.
> So probably the interface for sl_command() should be defined a little
> more clearly and the routines called by sl_command() should return
> SL_BADSYNTAX (-2?) instead of SL_BADCOMMAND (-1). Or something.
Index: sl.c
===================================================================
RCS file: /usr/local/cvsroot/arla/lib/sl/sl.c,v
retrieving revision 1.2
diff -u -w -u -w -r1.2 sl.c
--- sl.c 1998/03/31 12:07:00 1.2
+++ sl.c 1998/06/21 20:12:44
@@ -232,7 +232,7 @@
SL_cmd *c;
c = sl_match (cmds, argv[0], 0);
if (c == NULL)
- return -1;
+ return SL_BADCOMMAND;
return (*c->func)(argc, argv);
}
Index: sl.h
===================================================================
RCS file: /usr/local/cvsroot/arla/lib/sl/sl.h,v
retrieving revision 1.1
diff -u -w -u -w -r1.1 sl.h
--- sl.h 1998/01/13 19:33:51 1.1
+++ sl.h 1998/06/21 20:12:44
@@ -41,6 +41,8 @@
#ifndef _SL_H
#define _SL_H
+#define SL_BADCOMMAND -1
+
typedef int (*cmd_func)(int, char **);
struct sl_cmd {
Index: fs.c
===================================================================
RCS file: /usr/local/cvsroot/arla/appl/fs.c,v
retrieving revision 1.33
diff -u -w -u -w -r1.33 fs.c
--- fs.c 1998/05/24 15:40:00 1.33
+++ fs.c 1998/06/21 20:28:19
@@ -42,7 +42,7 @@
#include <kafs.h>
#include "fs_local.h"
-RCSID("$Id$");
+RCSID("$Id: fs.c,v 1.33 1998/05/24 15:40:00 lha Exp $");
static SL_cmd cmds[] = {
{"apropos", empty_cmd, "locate commands by keyword"},
@@ -116,7 +116,7 @@
if (argc > 1) {
ret = sl_command(cmds, argc - 1, argv + 1);
- if (ret == -1)
+ if (ret == SL_BADCOMMAND)
printf ("%s: Unknown command\n", argv[1]);
}
else {
@@ -605,7 +605,7 @@
if (argc == 0) {
printf ("fs: Required parameter '-dir' missing\n");
- return -1;
+ return 0;
}
for (i = 0; i < argc; i++)
@@ -632,7 +632,7 @@
if (argc != 1 && argc != 4) {
setcache_usage();
- return -1;
+ return 0;
}
if (argc == 4) {
@@ -686,7 +686,7 @@
if (argc == 0) {
printf ("fs: Required parameter '-dir' missing\n");
- return -1;
+ return 0;
}
for (i = 0; i < argc; i++)
@@ -817,7 +817,7 @@
printf ("version: extraneous arguments ignored\n");
printf("fs: %s\nfs_lib: %s\n",
- "$Id$",
+ "$Id: fs.c,v 1.33 1998/05/24 15:40:00 lha Exp $",
fslib_version());
return 0;
}
@@ -1335,7 +1335,7 @@
if (k_pioctl(NULL, VIOCSETCACHESIZE, &a_params, 0) == -1) {
fserr(PROGNAME, errno, ".");
- return -1;
+ return 0;
}
return 0;
}
Index: pts.c
===================================================================
RCS file: /usr/local/cvsroot/arla/appl/pts.c,v
retrieving revision 1.4
diff -u -w -u -w -r1.4 pts.c
--- pts.c 1998/05/12 16:08:45 1.4
+++ pts.c 1998/06/21 20:32:24
@@ -44,7 +44,7 @@
#include <kafs.h>
#include <ctype.h>
-RCSID("$Id$");
+RCSID("$Id: pts.c,v 1.4 1998/05/12 16:08:45 hin Exp $");
static int empty_cmd(int, char **);
@@ -132,7 +132,7 @@
noauth);
if (connptdb == NULL)
- return -1;
+ return 0;
error = PR_DumpEntry(connptdb, 0, (struct prdebugentry *) &header);
@@ -140,7 +140,7 @@
printf("dump_cmd: DumpEntry failed with: %s (%d)\n",
koerr_gettext(error),
error);
- return -1;
+ return 0;
}
for (pos = header.headerSize; pos < header.eofPtr; pos += sizeof (struct prdebugentry)) {
> [ about sl_help and it's bloatiness ]
>
> I guess vos is the experiment for sl_help() to see how it's working?
>
I was lazy and didn't want to write a new sl_help() that is more
interactive mode.
And yes you are right, its not friendly/pretty they way vos looks today.
sl_help() has a lot of heritage from mandoc generation. Guess I have
to clean up the sl_help() and make it more pretty.
> because __progname isn't initialized:
>
> p = strrchr(__progname, '/');
>
> Of course, under Solaris, it will work with:
>
> > ( setenv LD_PRELOAD 0 at 0.so.1 ; setenv SLMANDOC 1 ; ./vos help )
>
> but you didn't want to know that, I think :-)
What ? I'm not really sure I don't know what that mean.
> ...fixes things, but again it's not clear whether this really belongs
> in sl_command(), a hypothetical sl_init() function, in vos' main(),
> etc., etc.
All program that uses libroken should call set_progname(argv[0]);
or equivalent since this fixes __progname for those that don't have
__progname (if you happend to have __progname this does nothing).
> I'm unhappy with the choice of __progname, since __ is reserved for
> the operating system's private stuff, and we shouldn't be poking at it.
> It looks like the sl/roken stuff comes from kth-krb (if not other places),
> so maybe it's hard to change and there's a lot of version skew?
sl/roken comes from kth-krb. There should not be that much of version
skew (but i have not diffed it against the lastest roken)
Love
More information about the Arla-drinkers
mailing list