12 Rune samname[] = { '~', '~', 's', 'a', 'm', '~', '~', 0 };
14 static Rune l1[] = { '{', '[', '(', '<', 0253, 0};
15 static Rune l2[] = { '\n', 0};
16 static Rune l3[] = { '\'', '"', '`', 0};
17 Rune *left[]= { l1, l2, l3, 0};
19 static Rune r1[] = {'}', ']', ')', '>', 0273, 0};
20 static Rune r2[] = {'\n', 0};
21 static Rune r3[] = {'\'', '"', '`', 0};
22 Rune *right[]= { r1, r2, r3, 0};
25 #define SAMTERMNAME "samterm"
28 #define TMPDIRNAME "/tmp"
34 #define SHPATHNAME "/bin/sh"
40 #define RXPATHNAME "ssh"
44 char SAMTERM[] = SAMTERMNAME;
46 char TMPDIR[] = TMPDIRNAME;
48 char SHPATH[] = SHPATHNAME;
50 char RXPATH[] = RXPATHNAME;
60 vseprint(buf, &buf[BLOCKSIZE], z, arg);
66 print_ss(char *s, String *a, String *b)
68 dprint("?warning: %s: `%.*S' and `%.*S'\n", s, a->n, a->s, b->n, b->s);
72 print_s(char *s, String *a)
74 dprint("?warning: %s `%.*S'\n", s, a->n, a->s);
82 struct passwd *pw = getpwuid(getuid());
83 strcpy(user, pw ? pw->pw_name : "nobody");
89 statfile(char *name, ulong *dev, uvlong *id, long *time, long *length, long *appendonly)
93 if (stat(name, &dirb) == -1)
100 *time = dirb.st_mtime;
102 *length = dirb.st_size;
109 statfd(int fd, ulong *dev, uvlong *id, long *time, long *length, long *appendonly)
113 if (fstat(fd, &dirb) == -1)
120 *time = dirb.st_mtime;
122 *length = dirb.st_size;
131 panicking = 1; // ???
137 notify(void(*f)(void *, char *))
139 signal(SIGINT, SIG_IGN);
140 signal(SIGPIPE, SIG_IGN); // XXX - bpipeok?
146 notifyf(void *a, char *b) /* never called; hup is instead */
151 temp_file(char *buf, int bufsize)
156 tmp = getenv("TMPDIR");
160 n = snprint(buf, bufsize, "%s/sam.%d.XXXXXXX", tmp, getuid());
163 if ((fd = mkstemp(buf)) < 0) /* SES - linux sometimes uses mode 0666 */
165 if (fcntl(fd, F_SETFD, fcntl(fd,F_GETFD,0) | FD_CLOEXEC) < 0)
174 int fd = temp_file(buf, sizeof buf);
187 do; while((rpid = wait(&wm)) != pid && rpid != -1);
188 return (WEXITSTATUS(wm));
194 sprint(buf, "%s/sam.%s.err", TMPDIR, getuser());
204 panic("malloc fails");
210 erealloc(void *p, ulong n)
214 panic("realloc fails");