diff options
author | rsc <devnull@localhost> | 2005-01-27 06:10:35 +0000 |
---|---|---|
committer | rsc <devnull@localhost> | 2005-01-27 06:10:35 +0000 |
commit | 17ab31aac6639e210613691669163b0c2874d1ce (patch) | |
tree | d64fa43d93a72fe850f6cf936eb1ea2d64b4905f /src/cmd/sam | |
parent | 4ac5f249ad40f3452fc87dc9a3f4b9d9546c83b0 (diff) | |
download | plan9port-17ab31aac6639e210613691669163b0c2874d1ce.tar.gz plan9port-17ab31aac6639e210613691669163b0c2874d1ce.tar.bz2 plan9port-17ab31aac6639e210613691669163b0c2874d1ce.zip |
add autoindent (-a) and chording.
clean up argument parsing.
Diffstat (limited to 'src/cmd/sam')
-rw-r--r-- | src/cmd/sam/io.c | 8 | ||||
-rw-r--r-- | src/cmd/sam/mesg.h | 2 | ||||
-rw-r--r-- | src/cmd/sam/sam.c | 91 | ||||
-rw-r--r-- | src/cmd/sam/sam.h | 2 |
4 files changed, 42 insertions, 61 deletions
diff --git a/src/cmd/sam/io.c b/src/cmd/sam/io.c index cdea842c..95c2e0ce 100644 --- a/src/cmd/sam/io.c +++ b/src/cmd/sam/io.c @@ -176,7 +176,7 @@ int remotefd0 = 0; int remotefd1 = 1; void -bootterm(char *machine, char **argv, char **end) +bootterm(char *machine, char **argv) { int ph2t[2], pt2h[2]; @@ -186,7 +186,6 @@ bootterm(char *machine, char **argv, char **end) close(remotefd0); close(remotefd1); argv[0] = "samterm"; - *end = 0; execvp(samterm, argv); fprint(2, "can't exec %s: %r\n", samterm); _exits("damn"); @@ -202,7 +201,6 @@ bootterm(char *machine, char **argv, char **end) close(pt2h[0]); close(pt2h[1]); argv[0] = "samterm"; - *end = 0; execvp(samterm, argv); fprint(2, "can't exec: "); perror(samterm); @@ -269,12 +267,12 @@ connectto(char *machine, char **argv) } void -startup(char *machine, int Rflag, char **argv, char **end, char **files) +startup(char *machine, int Rflag, char **argv, char **files) { if(machine) connectto(machine, files); if(!Rflag) - bootterm(machine, argv, end); + bootterm(machine, argv); downloaded = 1; outTs(Hversion, VERSION); } diff --git a/src/cmd/sam/mesg.h b/src/cmd/sam/mesg.h index b88bf148..6e34f664 100644 --- a/src/cmd/sam/mesg.h +++ b/src/cmd/sam/mesg.h @@ -66,7 +66,7 @@ typedef enum Hmesg Hsnarflen, /* report length of implicit snarf */ Hack, /* request acknowledgement */ Hexit, - Hplumb, /* return plumb message to terminal */ + Hplumb, /* return plumb message to terminal - version 1 */ HMAX, }Hmesg; typedef struct Header{ diff --git a/src/cmd/sam/sam.c b/src/cmd/sam/sam.c index b5b16a10..acfa4657 100644 --- a/src/cmd/sam/sam.c +++ b/src/cmd/sam/sam.c @@ -42,58 +42,40 @@ main(int volatile argc, char **volatile argv) { int volatile i; String *t; - char **ap, **arg; - - arg = argv++; - ap = argv; - while(argc>1 && argv[0] && argv[0][0]=='-'){ - switch(argv[0][1]){ - case 'd': - dflag++; - break; - - case 'r': - --argc, argv++; - if(argc == 1) - usage(); - machine = *argv; - break; - - case 'R': - Rflag++; - break; - - case 't': - --argc, argv++; - if(argc == 1) - usage(); - samterm = *argv; - break; + char *termargs[10], **ap; + + ap = termargs; + *ap++ = "samterm"; + ARGBEGIN{ + case 'd': + dflag++; + break; + case 'r': + machine = EARGF(usage()); + break; + case 'R': + Rflag++; + break; + case 't': + samterm = EARGF(usage()); + break; + case 's': + rsamname = EARGF(usage()); + break; + default: + dprint("sam: unknown flag %c\n", ARGC()); + usage(); + /* options for samterm */ + case 'a': + *ap++ = "-a"; + break; + case 'W': + *ap++ = "-W"; + *ap++ = EARGF(usage()); + break; + }ARGEND + *ap = nil; - case 's': - --argc, argv++; - if(argc == 1) - usage(); - rsamname = *argv; - break; - - case 'x': /* x11 option - strip the x */ - strcpy(*argv+1, *argv+2); - *ap++ = *argv++; - *ap++ = *argv; - argc--; - break; - - case 'W': - --argc, argv++; - break; - - default: - dprint("sam: unknown flag %c\n", argv[0][1]); - exits("usage"); - } - --argc, argv++; - } Strinit(&cmdstr); Strinit0(&lastpat); Strinit0(&lastregexp); @@ -106,12 +88,13 @@ main(int volatile argc, char **volatile argv) disk = diskinit(); if(home == 0) home = "/"; +fprint(2, "argc %d argv %s\n", argc, *argv); if(!dflag) - startup(machine, Rflag, arg, ap, argv); + startup(machine, Rflag, termargs, argv); notify(notifyf); getcurwd(); - if(argc>1){ - for(i=0; i<argc-1; i++){ + if(argc>0){ + for(i=0; i<argc; i++){ if(!setjmp(mainloop)){ t = tmpcstr(argv[i]); Straddc(t, '\0'); diff --git a/src/cmd/sam/sam.h b/src/cmd/sam/sam.h index 0641be81..eefb4b34 100644 --- a/src/cmd/sam/sam.h +++ b/src/cmd/sam/sam.h @@ -295,7 +295,7 @@ void settempfile(void); int skipbl(void); void snarf(File*, Posn, Posn, Buffer*, int); void sortname(File*); -void startup(char*, int, char**, char**, char**); +void startup(char*, int, char**, char**); void state(File*, int); int statfd(int, ulong*, uvlong*, long*, long*, long*); int statfile(char*, ulong*, uvlong*, long*, long*, long*); |