mailfs: small fixes and plan 9 support
R=rsc CC=plan9port.codebot http://codereview.appspot.com/5429044
This commit is contained in:
parent
bd51695c92
commit
2fc68b6d8e
6 changed files with 35 additions and 5 deletions
|
|
@ -6,6 +6,7 @@
|
||||||
#include <fcall.h>
|
#include <fcall.h>
|
||||||
#include <plumb.h>
|
#include <plumb.h>
|
||||||
#include <9p.h>
|
#include <9p.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
|
@ -44,3 +45,5 @@ extern Imap *imap;
|
||||||
#define erealloc realloc
|
#define erealloc realloc
|
||||||
#define estrdup strdup
|
#define estrdup strdup
|
||||||
|
|
||||||
|
#pragma varargck type "$" Sx*
|
||||||
|
#pragma varargck type "Z" char*
|
||||||
|
|
|
||||||
|
|
@ -208,7 +208,11 @@ msgplumb(Msg *m, int delete)
|
||||||
a[ai].next = nil;
|
a[ai].next = nil;
|
||||||
|
|
||||||
p.attr = a;
|
p.attr = a;
|
||||||
|
#ifdef PLAN9PORT
|
||||||
snprint(buf, sizeof buf, "Mail/%s/%ud", m->box->name, m->id);
|
snprint(buf, sizeof buf, "Mail/%s/%ud", m->box->name, m->id);
|
||||||
|
#else
|
||||||
|
snprint(buf, sizeof buf, "/mail/fs/%s/%ud", m->box->name, m->id);
|
||||||
|
#endif
|
||||||
p.ndata = strlen(buf);
|
p.ndata = strlen(buf);
|
||||||
p.data = buf;
|
p.data = buf;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,7 @@ Srv fs;
|
||||||
Qid rootqid;
|
Qid rootqid;
|
||||||
ulong t0;
|
ulong t0;
|
||||||
|
|
||||||
|
#ifdef PLAN9PORT
|
||||||
void
|
void
|
||||||
responderror(Req *r)
|
responderror(Req *r)
|
||||||
{
|
{
|
||||||
|
|
@ -101,6 +102,7 @@ responderror(Req *r)
|
||||||
rerrstr(e, sizeof e);
|
rerrstr(e, sizeof e);
|
||||||
respond(r, e);
|
respond(r, e);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int
|
int
|
||||||
qtype(Qid q)
|
qtype(Qid q)
|
||||||
|
|
@ -379,6 +381,7 @@ mkbody(Part *p, Qid q)
|
||||||
char *t;
|
char *t;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
|
USED(q);
|
||||||
if(p->msg->part[0] == p)
|
if(p->msg->part[0] == p)
|
||||||
t = p->rawbody;
|
t = p->rawbody;
|
||||||
else
|
else
|
||||||
|
|
@ -571,7 +574,7 @@ filedata(int type, Box *box, Msg *msg, Part *part, char **pp, int *len, int *fre
|
||||||
fmtstrinit(&fmt);
|
fmtstrinit(&fmt);
|
||||||
if(part == msg->part[0]){
|
if(part == msg->part[0]){
|
||||||
if(msg->date)
|
if(msg->date)
|
||||||
fmtprint(&fmt, "unixdate %lud %s", msg->date, ctime(msg->date));
|
fmtprint(&fmt, "unixdate %ud %s", msg->date, ctime(msg->date));
|
||||||
if(msg->flags){
|
if(msg->flags){
|
||||||
filedata(Qflags, box, msg, part, pp, nil, freeme, 0, ZQ);
|
filedata(Qflags, box, msg, part, pp, nil, freeme, 0, ZQ);
|
||||||
fmtprint(&fmt, "flags %s\n", buf);
|
fmtprint(&fmt, "flags %s\n", buf);
|
||||||
|
|
@ -1203,6 +1206,7 @@ fsrecv(void *v)
|
||||||
{
|
{
|
||||||
Req *r;
|
Req *r;
|
||||||
|
|
||||||
|
USED(v);
|
||||||
while((r = recvp(fsreqchan)) != nil){
|
while((r = recvp(fsreqchan)) != nil){
|
||||||
switch(r->ifcall.type){
|
switch(r->ifcall.type){
|
||||||
case Tattach:
|
case Tattach:
|
||||||
|
|
|
||||||
|
|
@ -754,12 +754,16 @@ imapdial(char *server, int mode)
|
||||||
fd[0] = dup(p[0], -1);
|
fd[0] = dup(p[0], -1);
|
||||||
fd[1] = dup(p[0], -1);
|
fd[1] = dup(p[0], -1);
|
||||||
fd[2] = dup(2, -1);
|
fd[2] = dup(2, -1);
|
||||||
|
#ifdef PLAN9PORT
|
||||||
tmp = esmprint("%s:993", server);
|
tmp = esmprint("%s:993", server);
|
||||||
if(threadspawnl(fd, "tlsclient", "tlsclient", tmp, nil) < 0
|
if(threadspawnl(fd, "/usr/sbin/stunnel3", "stunnel3", "-c", "-r", tmp, nil) < 0
|
||||||
&& threadspawnl(fd, "/usr/sbin/stunnel3", "stunnel3", "-c", "-r", tmp, nil) < 0
|
|
||||||
&& threadspawnl(fd, "/usr/bin/stunnel3", "stunnel3", "-c", "-r", tmp, nil) < 0
|
&& threadspawnl(fd, "/usr/bin/stunnel3", "stunnel3", "-c", "-r", tmp, nil) < 0
|
||||||
&& threadspawnl(fd, "/usr/sbin/stunnel", "stunnel", "-c", "-r", tmp, nil) < 0
|
&& threadspawnl(fd, "/usr/sbin/stunnel", "stunnel", "-c", "-r", tmp, nil) < 0
|
||||||
&& threadspawnl(fd, "/usr/bin/stunnel", "stunnel", "-c", "-r", tmp, nil) < 0){
|
&& threadspawnl(fd, "/usr/bin/stunnel", "stunnel", "-c", "-r", tmp, nil) < 0){
|
||||||
|
#else
|
||||||
|
tmp = esmprint("tcp!%s!993", server);
|
||||||
|
if(threadspawnl(fd, "/bin/tlsclient", "tlsclient", tmp, nil) < 0){
|
||||||
|
#endif
|
||||||
free(tmp);
|
free(tmp);
|
||||||
close(p[0]);
|
close(p[0]);
|
||||||
close(p[1]);
|
close(p[1]);
|
||||||
|
|
@ -1300,6 +1304,8 @@ xexists(Imap *z, Sx *sx)
|
||||||
static void
|
static void
|
||||||
xflags(Imap *z, Sx *sx)
|
xflags(Imap *z, Sx *sx)
|
||||||
{
|
{
|
||||||
|
USED(z);
|
||||||
|
USED(sx);
|
||||||
/*
|
/*
|
||||||
* This response contains in sx->sx[2] the list of flags
|
* This response contains in sx->sx[2] the list of flags
|
||||||
* that can be validly attached to messages in z->box.
|
* that can be validly attached to messages in z->box.
|
||||||
|
|
@ -1311,6 +1317,7 @@ xflags(Imap *z, Sx *sx)
|
||||||
static void
|
static void
|
||||||
xbye(Imap *z, Sx *sx)
|
xbye(Imap *z, Sx *sx)
|
||||||
{
|
{
|
||||||
|
USED(sx);
|
||||||
close(z->fd);
|
close(z->fd);
|
||||||
z->fd = -1;
|
z->fd = -1;
|
||||||
z->connected = 0;
|
z->connected = 0;
|
||||||
|
|
@ -1496,6 +1503,7 @@ copyaddrs(Sx *v)
|
||||||
static void
|
static void
|
||||||
xmsgenvelope(Msg *msg, Sx *k, Sx *v)
|
xmsgenvelope(Msg *msg, Sx *k, Sx *v)
|
||||||
{
|
{
|
||||||
|
USED(k);
|
||||||
hdrfree(msg->part[0]->hdr);
|
hdrfree(msg->part[0]->hdr);
|
||||||
msg->part[0]->hdr = parseenvelope(v);
|
msg->part[0]->hdr = parseenvelope(v);
|
||||||
msgplumb(msg, 0);
|
msgplumb(msg, 0);
|
||||||
|
|
@ -1601,6 +1609,7 @@ parsestructure(Part *part, Sx *v)
|
||||||
static void
|
static void
|
||||||
xmsgbody(Msg *msg, Sx *k, Sx *v)
|
xmsgbody(Msg *msg, Sx *k, Sx *v)
|
||||||
{
|
{
|
||||||
|
USED(k);
|
||||||
if(v->type != SxList){
|
if(v->type != SxList){
|
||||||
warn("bad body: %$", v);
|
warn("bad body: %$", v);
|
||||||
return;
|
return;
|
||||||
|
|
@ -1742,24 +1751,32 @@ xokuidvalidity(Imap *z, Sx *sx)
|
||||||
static void
|
static void
|
||||||
xokpermflags(Imap *z, Sx *sx)
|
xokpermflags(Imap *z, Sx *sx)
|
||||||
{
|
{
|
||||||
|
USED(z);
|
||||||
|
USED(sx);
|
||||||
/* z->permflags = parseflags(sx); */
|
/* z->permflags = parseflags(sx); */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xokunseen(Imap *z, Sx *sx)
|
xokunseen(Imap *z, Sx *sx)
|
||||||
{
|
{
|
||||||
|
USED(z);
|
||||||
|
USED(sx);
|
||||||
/* z->unseen = sx->number; */
|
/* z->unseen = sx->number; */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xokreadwrite(Imap *z, Sx *sx)
|
xokreadwrite(Imap *z, Sx *sx)
|
||||||
{
|
{
|
||||||
|
USED(z);
|
||||||
|
USED(sx);
|
||||||
/* z->boxmode = ORDWR; */
|
/* z->boxmode = ORDWR; */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xokreadonly(Imap *z, Sx *sx)
|
xokreadonly(Imap *z, Sx *sx)
|
||||||
{
|
{
|
||||||
|
USED(z);
|
||||||
|
USED(sx);
|
||||||
/* z->boxmode = OREAD; */
|
/* z->boxmode = OREAD; */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
typedef struct Imap Imap;
|
typedef struct Imap Imap;
|
||||||
|
#pragma incomplete Imap
|
||||||
|
|
||||||
void imapcheckbox(Imap *z, Box *b);
|
void imapcheckbox(Imap *z, Box *b);
|
||||||
Imap* imapconnect(char *server, int mode, char *root);
|
Imap* imapconnect(char *server, int mode, char *root);
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ mailproc(void *v)
|
||||||
{
|
{
|
||||||
New n;
|
New n;
|
||||||
|
|
||||||
|
USED(v);
|
||||||
while(recv(mailthreadchan, &n) == 1)
|
while(recv(mailthreadchan, &n) == 1)
|
||||||
threadcreate(n.fn, n.arg, STACK);
|
threadcreate(n.fn, n.arg, STACK);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue