bool q_cmd(File *f, Cmd *cp) { trytoquit(); if(downloaded){ outT0(Hexit); return true; } return false; }
int q_cmd(File *f, Cmd *cp) { USED(cp); USED(f); trytoquit(); if(downloaded){ outT0(Hexit); return TRUE; } return FALSE; }
int main(int argc, char *argv[]) { int i, o; String *t; char *arg[argc + 1], **ap; int targc = 1; ap = &arg[argc]; arg[0] = "samterm"; setlocale(LC_ALL, ""); while ((o = getopt(argc, argv, "efdRr:t:s:")) != -1) { switch (o) { case 'e': arg[targc++] = "-e"; break; case 'f': arg[targc++] = "-f"; break; case 'd': dflag = true; break; case 'r': machine = optarg; rsamname = "rsam"; arg[targc++] = "-r"; arg[targc++] = optarg; break; case 'R': Rflag = true; break; case 't': samterm = optarg; break; case 's': rsamname = optarg; break; default: usage(); } } argv += optind; argc -= optind; arg[targc] = NULL; Strinit(&cmdstr); Strinit0(&lastpat); Strinit0(&lastregexp); Strinit0(&genstr); Strinit0(&rhs); Strinit0(&wd); Strinit0(&plan9cmd); tempfile.listptr = emalloc(0); home = getenv("HOME") ? getenv("HOME") : "/"; shpath = getenv("SHELL") ? getenv("SHELL") : shpath; sh = basename(shpath); if(!dflag) startup(machine, Rflag, arg, ap); Fstart(); signal(SIGINT, SIG_IGN); signal(SIGHUP, hup); signal(SIGPIPE, SIG_IGN); if(argc > 0) { for(i=0; i<argc; i++) if(!setjmp(mainloop)) { t = tmpcstr(argv[i]); Straddc(t, '\0'); Strduplstr(&genstr, t); freetmpstr(t); Fsetname(newfile(), &genstr); } } else if(!downloaded) newfile()->state = Clean; modnum++; if(file.nused) current(file.filepptr[0]); atexit(shutdown); setjmp(mainloop); cmdloop(); trytoquit(); /* if we already q'ed, quitok will be true */ exit(EXIT_SUCCESS); }
void main(int argc, char *argv[]) { int i; String *t; 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; } ARGEND *ap = nil; Strinit(&cmdstr); Strinit0(&lastpat); Strinit0(&lastregexp); Strinit0(&genstr); Strinit0(&rhs); Strinit0(&curwd); Strinit0(&plan9cmd); home = getenv(HOME); disk = diskinit(); if(home == 0) home = "/"; if(!dflag) startup(machine, Rflag, termargs, argv); notify(notifyf); getcurwd(); if(argc>0) { for(i=0; i<argc; i++) { if(!setjmp(mainloop)) { t = tmpcstr(argv[i]); Straddc(t, '\0'); Strduplstr(&genstr, t); freetmpstr(t); fixname(&genstr); logsetname(newfile(), &genstr); } } } else if(!downloaded) newfile(); seq++; if(file.nused) current(file.filepptr[0]); setjmp(mainloop); cmdloop(); trytoquit(); /* if we already q'ed, quitok will be TRUE */ exits(0); }
int sammain(int argc, char *argv[]) { bool trylock = true; int i, o; String *t; char *arg[argc + 1], **ap; ap = &arg[argc]; arg[0] = "samterm"; setlocale(LC_ALL, ""); while ((o = getopt(argc, argv, "SedR:r:t:s:")) != -1){ switch (o){ case 'd': dflag = true; break; case 'r': machine = optarg; break; case 'R': rmsocketname = optarg; atexit(rmsocket); break; case 't': samterm = optarg; break; case 's': rsamname = optarg; break; case 'S': trylock = false; break; default: usage(); } } if (trylock && !canlocksocket(machine) && !dflag) return bmain(argc, argv); argv += optind; argc -= optind; Strinit(&cmdstr); Strinit0(&lastpat); Strinit0(&lastregexp); Strinit0(&genstr); Strinit0(&rhs); Strinit0(&wd); Strinit0(&plan9cmd); tempfile.listptr = emalloc(0); home = getenv("HOME") ? getenv("HOME") : "/"; shpath = getenv("SHELL") ? getenv("SHELL") : shpath; sh = basename(shpath); if(!dflag) startup(machine, rmsocketname != NULL, trylock); Fstart(); signal(SIGINT, SIG_IGN); signal(SIGHUP, hup); signal(SIGPIPE, SIG_IGN); if(argc > 0){ for(i=0; i<argc; i++) if(!setjmp(mainloop)){ t = tmpcstr(argv[i]); Straddc(t, '\0'); Strduplstr(&genstr, t); freetmpstr(t); Fsetname(newfile(), &genstr); } }else if(!downloaded) newfile()->state = Clean; modnum++; if(file.nused) current(file.filepptr[0]); atexit(scram); setjmp(mainloop); cmdloop(); trytoquit(); /* if we already q'ed, quitok will be true */ exit(EXIT_SUCCESS); }