better lookup
This commit is contained in:
parent
7575a9e1bb
commit
2eef1fa316
2 changed files with 29 additions and 14 deletions
|
|
@ -17,7 +17,6 @@ static int nsaved;
|
||||||
static char *facedom;
|
static char *facedom;
|
||||||
static char *libface;
|
static char *libface;
|
||||||
static char *homeface;
|
static char *homeface;
|
||||||
static char *machinelist;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Loading the files is slow enough on a dial-up line to be worth this trouble
|
* 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*
|
static char*
|
||||||
tryfindfiledir(char *dom, char *user, char *dir)
|
tryfindfiledir(char *dom, char *user, char *dir)
|
||||||
{
|
{
|
||||||
char *dict, *ndir, *x;
|
char *dict, *ndir, *x, *odom;
|
||||||
int fd;
|
int fd;
|
||||||
int i, n;
|
int i, n;
|
||||||
Dir *d;
|
Dir *d;
|
||||||
|
|
@ -269,7 +268,6 @@ tryfindfiledir(char *dom, char *user, char *dir)
|
||||||
x = estrstrdup(dir, "/.machinelist");
|
x = estrstrdup(dir, "/.machinelist");
|
||||||
dom = estrdup(translatedomain(dom, x));
|
dom = estrdup(translatedomain(dom, x));
|
||||||
free(x);
|
free(x);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If this directory has a .dict, use it.
|
* If this directory has a .dict, use it.
|
||||||
*/
|
*/
|
||||||
|
|
@ -354,12 +352,9 @@ findfile(Face *f, char *dom, char *user)
|
||||||
}
|
}
|
||||||
if(libface == nil)
|
if(libface == nil)
|
||||||
libface = unsharp("#9/face");
|
libface = unsharp("#9/face");
|
||||||
if(machinelist == nil)
|
|
||||||
machinelist = estrstrdup(libface, "/.machinelist");
|
|
||||||
if(homeface == nil)
|
if(homeface == nil)
|
||||||
homeface = smprint("%s/lib/face", getenv("HOME"));
|
homeface = smprint("%s/lib/face", getenv("HOME"));
|
||||||
|
|
||||||
dom = translatedomain(dom, machinelist);
|
|
||||||
if(dom == nil)
|
if(dom == nil)
|
||||||
dom = facedom;
|
dom = facedom;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -81,6 +81,16 @@ setname(Face *f, char *sender)
|
||||||
{
|
{
|
||||||
char *at, *bang;
|
char *at, *bang;
|
||||||
char *p;
|
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 */
|
/* works with UTF-8, although it's written as ASCII */
|
||||||
for(p=sender; *p!='\0'; p++)
|
for(p=sender; *p!='\0'; p++)
|
||||||
|
|
@ -189,7 +199,7 @@ nextface(void)
|
||||||
int i;
|
int i;
|
||||||
Face *f;
|
Face *f;
|
||||||
Plumbmsg *m;
|
Plumbmsg *m;
|
||||||
char *t, *senderp, *showmailp, *digestp;
|
char *t, *data, *showmailp, *digestp;
|
||||||
ulong xtime;
|
ulong xtime;
|
||||||
|
|
||||||
f = emalloc(sizeof(Face));
|
f = emalloc(sizeof(Face));
|
||||||
|
|
@ -197,13 +207,18 @@ nextface(void)
|
||||||
m = plumbrecvfid(seefd);
|
m = plumbrecvfid(seefd);
|
||||||
if(m == nil)
|
if(m == nil)
|
||||||
killall("error on seemail plumb port");
|
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", "");
|
t = value(m->attr, "mailtype", "");
|
||||||
if(strcmp(t, "delete") == 0)
|
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)
|
else if(strcmp(t, "new") != 0)
|
||||||
fprint(2, "faces: unknown plumb message type %s\n", t);
|
fprint(2, "faces: unknown plumb message type %s\n", t);
|
||||||
else for(i=0; i<nmaildirs; i++)
|
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;
|
goto Found;
|
||||||
plumbfree(m);
|
plumbfree(m);
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -216,11 +231,16 @@ nextface(void)
|
||||||
plumbfree(m);
|
plumbfree(m);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
senderp = estrdup(value(m->attr, "sender", "???"));
|
showmailp = estrdup(data);
|
||||||
showmailp = estrdup(m->data);
|
|
||||||
if(digestp)
|
if(digestp)
|
||||||
digestp = estrdup(digestp);
|
digestp = estrdup(digestp);
|
||||||
|
setname(f, value(m->attr, "sender", "???"));
|
||||||
plumbfree(m);
|
plumbfree(m);
|
||||||
|
f->time = xtime;
|
||||||
|
f->tm = *localtime(xtime);
|
||||||
|
f->str[Sshow] = showmailp;
|
||||||
|
f->str[Sdigest] = digestp;
|
||||||
|
return f;
|
||||||
}
|
}
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
@ -244,7 +264,7 @@ Face*
|
||||||
dirface(char *dir, char *num)
|
dirface(char *dir, char *num)
|
||||||
{
|
{
|
||||||
Face *f;
|
Face *f;
|
||||||
char buf[1024], *fld[3], *info, *p, *t, *s;
|
char buf[1024], *info, *p, *t, *s;
|
||||||
int n;
|
int n;
|
||||||
ulong len;
|
ulong len;
|
||||||
CFid *fid;
|
CFid *fid;
|
||||||
|
|
@ -274,8 +294,8 @@ dirface(char *dir, char *num)
|
||||||
f->time = atoi(t);
|
f->time = atoi(t);
|
||||||
f->tm = *localtime(f->time);
|
f->tm = *localtime(f->time);
|
||||||
}
|
}
|
||||||
else if(strcmp(s, "from") == 0 && tokenize(t, fld, 3) >= 2)
|
else if(strcmp(s, "from") == 0)
|
||||||
setname(f, estrdup(fld[1]));
|
setname(f, t);
|
||||||
else if(strcmp(s, "digest") == 0)
|
else if(strcmp(s, "digest") == 0)
|
||||||
f->str[Sdigest] = estrdup(t);
|
f->str[Sdigest] = estrdup(t);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue