2 * Process in-band messages about window title changes.
3 * The messages are of the form:
7 * where xxx is the new directory. This format was chosen
8 * because it changes the label on xterm windows.
22 char *prog = "/bin/rwd";
27 fprint(2, "usage: conswdir [/bin/rwd]\n");
35 for(i = 0; i < nelem(keep); i++){
37 if((fd = open(keep[i].file, OREAD)) != -1){
38 read(fd, keep[i].name, sizeof(keep[i].name));
48 for(i = 0; i < nelem(keep); i++)
49 if((fd = open(keep[i].file, OWRITE)) != -1){
50 write(fd, keep[i].name, strlen(keep[i].name));
59 switch(rfork(RFPROC|RFFDG|RFNOWAIT)){
61 execl(prog, prog, s, nil);
76 process(char *buf, int n, int *pn)
84 for(p=buf; p<buf+n; p++){
107 else if((uchar)*p < 040)
112 memmove(path, buf+start+3, p - (buf+start+3));
113 path[p-(buf+start+3)] = 0;
115 memmove(buf+start, p, n-(p-buf));
124 /* give up if we go too long without seeing the close */
126 if(state == None || p-(buf+start) >= 2048)
133 catchint(void*, char *msg)
135 if(strstr(msg, "interrupt"))
137 else if(strstr(msg, "kill"))
144 main(int argc, char **argv)
164 m = read(0, buf+n, sizeof buf-n);
166 rerrstr(buf, sizeof buf);
167 if(strstr(buf, "interrupt"))
172 m = process(buf, n, &n);
175 memmove(buf, buf+m, n-m);