diff options
author | rsc <devnull@localhost> | 2006-02-14 19:42:16 +0000 |
---|---|---|
committer | rsc <devnull@localhost> | 2006-02-14 19:42:16 +0000 |
commit | 2eef1fa31676e58b0038f1c02dcc8df5e23149e6 (patch) | |
tree | f71ebda37f77c0139e60de9cd4e230c92ac4fc29 /src/cmd/faces | |
parent | 7575a9e1bb90c1876999881509797900787bb6b0 (diff) | |
download | plan9port-2eef1fa31676e58b0038f1c02dcc8df5e23149e6.tar.gz plan9port-2eef1fa31676e58b0038f1c02dcc8df5e23149e6.tar.bz2 plan9port-2eef1fa31676e58b0038f1c02dcc8df5e23149e6.zip |
better lookup
Diffstat (limited to 'src/cmd/faces')
-rw-r--r-- | src/cmd/faces/facedb.c | 7 | ||||
-rw-r--r-- | src/cmd/faces/plumb.c | 36 |
2 files changed, 29 insertions, 14 deletions
diff --git a/src/cmd/faces/facedb.c b/src/cmd/faces/facedb.c index b52dcbbb..3fa133a5 100644 --- a/src/cmd/faces/facedb.c +++ b/src/cmd/faces/facedb.c @@ -17,7 +17,6 @@ static int nsaved; static char *facedom; static char *libface; static char *homeface; -static char *machinelist; /* * Loading the files is slow enough on a dial-up line to be worth this trouble @@ -258,7 +257,7 @@ estrstrdup(char *a, char *b) static char* tryfindfiledir(char *dom, char *user, char *dir) { - char *dict, *ndir, *x; + char *dict, *ndir, *x, *odom; int fd; int i, n; Dir *d; @@ -269,7 +268,6 @@ tryfindfiledir(char *dom, char *user, char *dir) x = estrstrdup(dir, "/.machinelist"); dom = estrdup(translatedomain(dom, x)); free(x); - /* * If this directory has a .dict, use it. */ @@ -354,12 +352,9 @@ findfile(Face *f, char *dom, char *user) } if(libface == nil) libface = unsharp("#9/face"); - if(machinelist == nil) - machinelist = estrstrdup(libface, "/.machinelist"); if(homeface == nil) homeface = smprint("%s/lib/face", getenv("HOME")); - dom = translatedomain(dom, machinelist); if(dom == nil) dom = facedom; diff --git a/src/cmd/faces/plumb.c b/src/cmd/faces/plumb.c index 4d246b5c..6d82c779 100644 --- a/src/cmd/faces/plumb.c +++ b/src/cmd/faces/plumb.c @@ -81,6 +81,16 @@ setname(Face *f, char *sender) { char *at, *bang; char *p; + char *fld[3]; + int nf; + + p = estrdup(sender); + nf = tokenize(p, fld, 3); + if(nf <= 1) + sender = estrdup(fld[0]); + else + sender = estrdup(fld[1]); + free(p); /* works with UTF-8, although it's written as ASCII */ for(p=sender; *p!='\0'; p++) @@ -189,7 +199,7 @@ nextface(void) int i; Face *f; Plumbmsg *m; - char *t, *senderp, *showmailp, *digestp; + char *t, *data, *showmailp, *digestp; ulong xtime; f = emalloc(sizeof(Face)); @@ -197,13 +207,18 @@ nextface(void) m = plumbrecvfid(seefd); if(m == nil) killall("error on seemail plumb port"); + if(strncmp(m->data, "Mail/", 5) != 0){ + plumbfree(m); + continue; + } + data = m->data+5; t = value(m->attr, "mailtype", ""); if(strcmp(t, "delete") == 0) - delete(m->data, value(m->attr, "digest", nil)); + delete(data, value(m->attr, "digest", nil)); else if(strcmp(t, "new") != 0) fprint(2, "faces: unknown plumb message type %s\n", t); else for(i=0; i<nmaildirs; i++) - if(strncmp(m->data, maildirs[i], strlen(maildirs[i])) == 0) + if(strncmp(data, maildirs[i], strlen(maildirs[i])) == 0) goto Found; plumbfree(m); continue; @@ -216,11 +231,16 @@ nextface(void) plumbfree(m); continue; } - senderp = estrdup(value(m->attr, "sender", "???")); - showmailp = estrdup(m->data); + showmailp = estrdup(data); if(digestp) digestp = estrdup(digestp); + setname(f, value(m->attr, "sender", "???")); plumbfree(m); + f->time = xtime; + f->tm = *localtime(xtime); + f->str[Sshow] = showmailp; + f->str[Sdigest] = digestp; + return f; } return nil; } @@ -244,7 +264,7 @@ Face* dirface(char *dir, char *num) { Face *f; - char buf[1024], *fld[3], *info, *p, *t, *s; + char buf[1024], *info, *p, *t, *s; int n; ulong len; CFid *fid; @@ -274,8 +294,8 @@ dirface(char *dir, char *num) f->time = atoi(t); f->tm = *localtime(f->time); } - else if(strcmp(s, "from") == 0 && tokenize(t, fld, 3) >= 2) - setname(f, estrdup(fld[1])); + else if(strcmp(s, "from") == 0) + setname(f, t); else if(strcmp(s, "digest") == 0) f->str[Sdigest] = estrdup(t); } |