wmii

git clone git://oldgit.suckless.org/wmii/
Log | Files | Refs | README | LICENSE

commit fed849e2fc6772009bb47e154ed15bc765d4d865
parent b5b3b2f14122e29f16385284338adfda5e6cfff6
Author: Kris Maglione <bsdaemon@wmii.de>
Date:   Thu, 22 Jun 2006 20:47:32 -0400

Moved some defs and structs that might conflict with others to the P9 namespace


Diffstat:
cmd/wm/fs.c | 96++++++++++++++++++++++++++++++++++++++++----------------------------------------
cmd/wm/wm.h | 20++++++++++----------
libixp/ixp.h | 100++++++++++++++++++++++++++++++++++++++++----------------------------------------
libixp/request.c | 28++++++++++++++--------------
4 files changed, 122 insertions(+), 122 deletions(-)

diff --git a/cmd/wm/fs.c b/cmd/wm/fs.c @@ -71,7 +71,7 @@ static char /* Global Vars */ /***************/ FileId *free_fileid = nil; -Req *pending_event_reads = nil; +P9Req *pending_event_reads = nil; FidLink *pending_event_fids; P9Srv p9srv = { .open= fs_open, @@ -90,34 +90,34 @@ P9Srv p9srv = { /* ad-hoc file tree. Empty names ("") indicate a dynamic entry to be filled * in by lookup_file */ static Dirtab -dirtab_root[]= {{".", QTDIR, FsRoot, 0500|DMDIR }, - {"rbar", QTDIR, FsDBars, 0700|DMDIR }, - {"lbar", QTDIR, FsDBars, 0700|DMDIR }, - {"client", QTDIR, FsDClients, 0500|DMDIR }, - {"tag", QTDIR, FsDTags, 0500|DMDIR }, - {"ctl", QTAPPEND, FsFRctl, 0600|DMAPPEND }, - {"colrules", QTFILE, FsFColRules, 0600 }, - {"event", QTFILE, FsFEvent, 0600 }, - {"keys", QTFILE, FsFKeys, 0600 }, - {"tagrules", QTFILE, FsFTagRules, 0600 }, +dirtab_root[]= {{".", P9QTDIR, FsRoot, 0500|P9DMDIR }, + {"rbar", P9QTDIR, FsDBars, 0700|P9DMDIR }, + {"lbar", P9QTDIR, FsDBars, 0700|P9DMDIR }, + {"client", P9QTDIR, FsDClients, 0500|P9DMDIR }, + {"tag", P9QTDIR, FsDTags, 0500|P9DMDIR }, + {"ctl", P9QTAPPEND, FsFRctl, 0600|P9DMAPPEND }, + {"colrules", P9QTFILE, FsFColRules, 0600 }, + {"event", P9QTFILE, FsFEvent, 0600 }, + {"keys", P9QTFILE, FsFKeys, 0600 }, + {"tagrules", P9QTFILE, FsFTagRules, 0600 }, {nil}}, -dirtab_clients[]={{".", QTDIR, FsDClients, 0500|DMDIR }, - {"", QTDIR, FsDClient, 0500|DMDIR }, +dirtab_clients[]={{".", P9QTDIR, FsDClients, 0500|P9DMDIR }, + {"", P9QTDIR, FsDClient, 0500|P9DMDIR }, {nil}}, -dirtab_client[]= {{".", QTDIR, FsDClient, 0500|DMDIR }, - {"ctl", QTAPPEND, FsFCctl, 0600|DMAPPEND }, - {"tags", QTFILE, FsFCtags, 0600 }, - {"props", QTFILE, FsFprops, 0400 }, +dirtab_client[]= {{".", P9QTDIR, FsDClient, 0500|P9DMDIR }, + {"ctl", P9QTAPPEND, FsFCctl, 0600|P9DMAPPEND }, + {"tags", P9QTFILE, FsFCtags, 0600 }, + {"props", P9QTFILE, FsFprops, 0400 }, {nil}}, -dirtab_bars[]= {{".", QTDIR, FsDBars, 0700|DMDIR }, - {"", QTFILE, FsFBar, 0600 }, +dirtab_bars[]= {{".", P9QTDIR, FsDBars, 0700|P9DMDIR }, + {"", P9QTFILE, FsFBar, 0600 }, {nil}}, -dirtab_tags[]= {{".", QTDIR, FsDTags, 0500|DMDIR }, - {"", QTDIR, FsDTag, 0500|DMDIR }, +dirtab_tags[]= {{".", P9QTDIR, FsDTags, 0500|P9DMDIR }, + {"", P9QTDIR, FsDTag, 0500|P9DMDIR }, {nil}}, -dirtab_tag[]= {{".", QTDIR, FsDTag, 0500|DMDIR }, - {"ctl", QTAPPEND, FsFTctl, 0600|DMAPPEND }, - {"index", QTFILE, FsFTindex, 0400 }, +dirtab_tag[]= {{".", P9QTDIR, FsDTag, 0500|P9DMDIR }, + {"ctl", P9QTAPPEND, FsFTctl, 0600|P9DMAPPEND }, + {"index", P9QTFILE, FsFTindex, 0400 }, {nil}}; /* Writing the lists separately and using an array of their references * removes the need for casting and allows for C90 conformance, @@ -174,7 +174,7 @@ clone_files(FileId *f) { /* This should be moved to libixp */ static void -write_buf(Req *r, void *buf, unsigned int len) { +write_buf(P9Req *r, void *buf, unsigned int len) { if(r->ifcall.offset >= len) return; @@ -189,10 +189,10 @@ write_buf(Req *r, void *buf, unsigned int len) { /* This should be moved to libixp */ void -write_to_buf(Req *r, void *buf, unsigned int *len, unsigned int max) { +write_to_buf(P9Req *r, void *buf, unsigned int *len, unsigned int max) { unsigned int offset, count; - offset = (r->fid->omode&OAPPEND) ? *len : r->ifcall.offset; + offset = (r->fid->omode&P9OAPPEND) ? *len : r->ifcall.offset; if(offset > *len || r->ifcall.count == 0) { r->ofcall.count = 0; return; @@ -218,7 +218,7 @@ write_to_buf(Req *r, void *buf, unsigned int *len, unsigned int max) { /* This should be moved to libixp */ void -data_to_cstring(Req *r) { +data_to_cstring(P9Req *r) { unsigned int i; i = r->ifcall.count; if(!i || r->ifcall.data[i - 1] != '\n') @@ -311,7 +311,7 @@ read_root_ctl() void -respond_event(Req *r) { +respond_event(P9Req *r) { FileId *f = r->fid->aux; if(f->buf) { r->ofcall.data = (void *)f->buf; @@ -329,7 +329,7 @@ write_event(char *buf) { unsigned int len, slen; FidLink *f; FileId *fi; - Req *aux; + P9Req *aux; if(!(len = strlen(buf))) return; @@ -377,7 +377,7 @@ lookup_file(FileId *parent, char *name) Bar *b; unsigned int i, id; - if(!(parent->tab.perm & DMDIR)) + if(!(parent->tab.perm & P9DMDIR)) return nil; dir = dirtab[parent->tab.type]; @@ -500,7 +500,7 @@ LastItem: /* Service Functions */ /*********************/ void -fs_attach(Req *r) { +fs_attach(P9Req *r) { FileId *f = get_file(); f->tab = dirtab[FsRoot][0]; f->tab.name = strdup("/"); @@ -513,7 +513,7 @@ fs_attach(Req *r) { } void -fs_walk(Req *r) { +fs_walk(P9Req *r) { FileId *f, *nf; int i; @@ -567,7 +567,7 @@ fs_walk(Req *r) { } void -fs_stat(Req *r) { +fs_stat(P9Req *r) { Stat s; int size; unsigned char *buf; @@ -582,7 +582,7 @@ fs_stat(Req *r) { } void -fs_read(Req *r) { +fs_read(P9Req *r) { char *buf; FileId *f, *tf; int n, offset; @@ -591,7 +591,7 @@ fs_read(Req *r) { offset = 0; f = r->fid->aux; - if(f->tab.perm & DMDIR && f->tab.perm & 0400) { + if(f->tab.perm & P9DMDIR && f->tab.perm & 0400) { Stat s; offset = 0; size = r->ifcall.count; @@ -666,7 +666,7 @@ fs_read(Req *r) { /* This function needs to be seriously cleaned up */ void -fs_write(Req *r) { +fs_write(P9Req *r) { FileId *f; char *buf, *errstr = nil; unsigned int i; @@ -738,7 +738,7 @@ fs_write(Req *r) { } void -fs_open(Req *r) { +fs_open(P9Req *r) { FidLink *fl; FileId *f = r->fid->aux; switch(f->tab.type) { @@ -749,19 +749,19 @@ fs_open(Req *r) { pending_event_fids = fl; break; } - if((r->ifcall.mode&3) == OEXEC) + if((r->ifcall.mode&3) == P9OEXEC) return respond(r, Enoperm); - if((r->ifcall.mode&3) != OREAD && !(f->tab.perm & 0200)) + if((r->ifcall.mode&3) != P9OREAD && !(f->tab.perm & 0200)) return respond(r, Enoperm); - if((r->ifcall.mode&3) != OWRITE && !(f->tab.perm & 0400)) + if((r->ifcall.mode&3) != P9OWRITE && !(f->tab.perm & 0400)) return respond(r, Enoperm); - if((r->ifcall.mode&~(3|OAPPEND))) + if((r->ifcall.mode&~(3|P9OAPPEND))) return respond(r, Enoperm); respond(r, nil); } void -fs_create(Req *r) { +fs_create(P9Req *r) { FileId *f = r->fid->aux; switch(f->tab.type) { default: @@ -784,7 +784,7 @@ fs_create(Req *r) { } void -fs_remove(Req *r) { +fs_remove(P9Req *r) { FileId *f = r->fid->aux; switch(f->tab.type) { default: @@ -798,7 +798,7 @@ fs_remove(Req *r) { } void -fs_clunk(Req *r) { +fs_clunk(P9Req *r) { Client *c; FidLink **fl, *ft; char *buf; @@ -849,9 +849,9 @@ fs_clunk(Req *r) { } void -fs_flush(Req *r) { - Req **t; - for(t=&pending_event_reads; *t; t=(Req **)&(*t)->aux) +fs_flush(P9Req *r) { + P9Req **t; + for(t=&pending_event_reads; *t; t=(P9Req **)&(*t)->aux) if(*t == r->oldreq) { *t = (*t)->aux; respond(r->oldreq, Einterrupted); diff --git a/cmd/wm/wm.h b/cmd/wm/wm.h @@ -268,17 +268,17 @@ void resize_frame(Frame *f); void update_frame_widget_colors(Frame *f); /* fs.c */ -void fs_attach(Req *r); -void fs_clunk(Req *r); -void fs_create(Req *r); -void fs_flush(Req *r); +void fs_attach(P9Req *r); +void fs_clunk(P9Req *r); +void fs_create(P9Req *r); +void fs_flush(P9Req *r); void fs_freefid(Fid *f); -void fs_open(Req *r); -void fs_read(Req *r); -void fs_remove(Req *r); -void fs_stat(Req *r); -void fs_walk(Req *r); -void fs_write(Req *r); +void fs_open(P9Req *r); +void fs_read(P9Req *r); +void fs_remove(P9Req *r); +void fs_stat(P9Req *r); +void fs_walk(P9Req *r); +void fs_write(P9Req *r); void write_event(char *buf); /* geom.c */ diff --git a/libixp/ixp.h b/libixp/ixp.h @@ -58,7 +58,7 @@ enum { IXP_DMDIR = 0x80000000, /* mode bit for directories */ IXP_DMTMP = 0x04000000, /* mode bit for non-backed-up file */ IXP_DMREAD = 0x4<<6, /* mode bit for read permission */ IXP_DMWRITE = 0x2<<6, /* mode bit for write permission */ - IXP_DMEXEC = 0x1<<6 /* mode bit for execute permission */ + IXP_DMEXEC = 0x1<<6 /* mode bit for execute permission */ }; /* modes */ @@ -86,48 +86,48 @@ enum { IXP_QTDIR = 0x80, }; /* from libc.h in p9p */ -enum { OREAD = 0, /* open for read */ - OWRITE = 1, /* write */ - ORDWR = 2, /* read and write */ - OEXEC = 3, /* execute, == read but check execute permission */ - OTRUNC = 16, /* or'ed in (except for exec), truncate file first */ - OCEXEC = 32, /* or'ed in, close on exec */ - ORCLOSE = 64, /* or'ed in, remove on close */ - ODIRECT = 128, /* or'ed in, direct access */ - ONONBLOCK = 256, /* or'ed in, non-blocking call */ - OEXCL = 0x1000, /* or'ed in, exclusive use (create only) */ - OLOCK = 0x2000, /* or'ed in, lock after opening */ - OAPPEND = 0x4000 /* or'ed in, append only */ +enum { P9OREAD = 0, /* open for read */ + P9OWRITE = 1, /* write */ + P9ORDWR = 2, /* read and write */ + P9OEXEC = 3, /* execute, == read but check execute permission */ + P9OTRUNC = 16, /* or'ed in (except for exec), truncate file first */ + P9OCEXEC = 32, /* or'ed in, close on exec */ + P9ORCLOSE = 64, /* or'ed in, remove on close */ + P9ODIRECT = 128, /* or'ed in, direct access */ + P9ONONBLOCK = 256, /* or'ed in, non-blocking call */ + P9OEXCL = 0x1000, /* or'ed in, exclusive use (create only) */ + P9OLOCK = 0x2000, /* or'ed in, lock after opening */ + P9OAPPEND = 0x4000 /* or'ed in, append only */ }; /* bits in Qid.type */ -enum { QTDIR = 0x80, /* type bit for directories */ - QTAPPEND = 0x40, /* type bit for append only files */ - QTEXCL = 0x20, /* type bit for exclusive use files */ - QTMOUNT = 0x10, /* type bit for mounted channel */ - QTAUTH = 0x08, /* type bit for authentication file */ - QTTMP = 0x04, /* type bit for non-backed-up file */ - QTSYMLINK = 0x02, /* type bit for symbolic link */ - QTFILE = 0x00 /* type bits for plain file */ +enum { P9QTDIR = 0x80, /* type bit for directories */ + P9QTAPPEND = 0x40, /* type bit for append only files */ + P9QTEXCL = 0x20, /* type bit for exclusive use files */ + P9QTMOUNT = 0x10, /* type bit for mounted channel */ + P9QTAUTH = 0x08, /* type bit for authentication file */ + P9QTTMP = 0x04, /* type bit for non-backed-up file */ + P9QTSYMLINK = 0x02, /* type bit for symbolic link */ + P9QTFILE = 0x00 /* type bits for plain file */ }; /* bits in Dir.mode */ -#define DMDIR 0x80000000 /* mode bit for directories */ -#define DMAPPEND 0x40000000 /* mode bit for append only files */ -#define DMEXCL 0x20000000 /* mode bit for exclusive use files */ -#define DMMOUNT 0x10000000 /* mode bit for mounted channel */ -#define DMAUTH 0x08000000 /* mode bit for authentication file */ -#define DMTMP 0x04000000 /* mode bit for non-backed-up file */ -#define DMSYMLINK 0x02000000 /* mode bit for symbolic link (Unix, 9P2000.u) */ -#define DMDEVICE 0x00800000 /* mode bit for device file (Unix, 9P2000.u) */ -#define DMNAMEDPIPE 0x00200000 /* mode bit for named pipe (Unix, 9P2000.u) */ -#define DMSOCKET 0x00100000 /* mode bit for socket (Unix, 9P2000.u) */ -#define DMSETUID 0x00080000 /* mode bit for setuid (Unix, 9P2000.u) */ -#define DMSETGID 0x00040000 /* mode bit for setgid (Unix, 9P2000.u) */ +#define P9DMDIR 0x80000000 /* mode bit for directories */ +#define P9DMAPPEND 0x40000000 /* mode bit for append only files */ +#define P9DMEXCL 0x20000000 /* mode bit for exclusive use files */ +#define P9DMMOUNT 0x10000000 /* mode bit for mounted channel */ +#define P9DMAUTH 0x08000000 /* mode bit for authentication file */ +#define P9DMTMP 0x04000000 /* mode bit for non-backed-up file */ +#define P9DMSYMLINK 0x02000000 /* mode bit for symbolic link (Unix, 9P2000.u) */ +#define P9DMDEVICE 0x00800000 /* mode bit for device file (Unix, 9P2000.u) */ +#define P9DMNAMEDPIPE 0x00200000 /* mode bit for named pipe (Unix, 9P2000.u) */ +#define P9DMSOCKET 0x00100000 /* mode bit for socket (Unix, 9P2000.u) */ +#define P9DMSETUID 0x00080000 /* mode bit for setuid (Unix, 9P2000.u) */ +#define P9DMSETGID 0x00040000 /* mode bit for setgid (Unix, 9P2000.u) */ -enum { DMREAD = 0x4, /* mode bit for read permission */ - DMWRITE = 0x2, /* mode bit for write permission */ - DMEXEC = 0x1 /* mode bit for execute permission */ +enum { P9DMREAD = 0x4, /* mode bit for read permission */ + P9DMWRITE = 0x2, /* mode bit for write permission */ + P9DMEXEC = 0x1 /* mode bit for execute permission */ }; @@ -262,28 +262,28 @@ typedef struct Fid { Intmap *map; } Fid; -typedef struct Req Req; -struct Req { +typedef struct P9Req P9Req; +struct P9Req { P9Conn *conn; Fid *fid; Fid *newfid; - Req *oldreq; + P9Req *oldreq; Fcall ifcall; Fcall ofcall; void *aux; }; typedef struct P9Srv { - void (*attach)(Req *r); - void (*clunk)(Req *r); - void (*create)(Req *r); - void (*flush)(Req *r); - void (*open)(Req *r); - void (*read)(Req *r); - void (*remove)(Req *r); - void (*stat)(Req *r); - void (*walk)(Req *r); - void (*write)(Req *r); + void (*attach)(P9Req *r); + void (*clunk)(P9Req *r); + void (*create)(P9Req *r); + void (*flush)(P9Req *r); + void (*open)(P9Req *r); + void (*read)(P9Req *r); + void (*remove)(P9Req *r); + void (*stat)(P9Req *r); + void (*walk)(P9Req *r); + void (*write)(P9Req *r); void (*freefid)(Fid *f); } P9Srv; @@ -333,7 +333,7 @@ void ixp_pack_stat(unsigned char **msg, int *msize, Stat *stat); void ixp_unpack_stat(unsigned char **msg, int *msize, Stat *stat); /* request.c */ -void respond(Req *r, char *error); +void respond(P9Req *r, char *error); void serve_9pcon(IXPConn *c); /* intmap.c */ diff --git a/libixp/request.c b/libixp/request.c @@ -9,7 +9,7 @@ #include <sys/socket.h> #include "ixp.h" -static void ixp_handle_req(Req *r); +static void ixp_handle_req(P9Req *r); /* We use string literals rather than arrays here because * they're allocated in a readonly section */ @@ -75,7 +75,7 @@ ixp_server_handle_fcall(IXPConn *c) { Fcall fcall = {0}; P9Conn *pc = c->aux; - Req *req; + P9Req *req; unsigned int msize; char *errstr = nil; @@ -84,7 +84,7 @@ ixp_server_handle_fcall(IXPConn *c) if(!(msize = ixp_msg2fcall(&fcall, pc->buf, IXP_MAX_MSG))) goto Fail; - req = cext_emallocz(sizeof(Req)); + req = cext_emallocz(sizeof(P9Req)); req->conn = pc; req->ifcall = fcall; pc->conn = c; @@ -100,7 +100,7 @@ Fail: } static void -ixp_handle_req(Req *r) +ixp_handle_req(P9Req *r) { P9Conn *pc = r->conn; P9Srv *srv = pc->srv; @@ -146,7 +146,7 @@ ixp_handle_req(Req *r) return respond(r, Enofid); if(r->fid->omode != -1) return respond(r, Ebotch); - if(!(r->fid->qid.type&QTDIR)) + if(!(r->fid->qid.type&P9QTDIR)) return respond(r, Enotdir); if(!pc->srv->create) return respond(r, Enofunc); @@ -155,7 +155,7 @@ ixp_handle_req(Req *r) case TOPEN: if(!(r->fid = lookupkey(&pc->fidmap, r->ifcall.fid))) return respond(r, Enofid); - if((r->fid->qid.type&QTDIR) && (r->ifcall.mode|ORCLOSE) != (OREAD|ORCLOSE)) + if((r->fid->qid.type&P9QTDIR) && (r->ifcall.mode|P9ORCLOSE) != (P9OREAD|P9ORCLOSE)) return respond(r, Eisdir); r->ofcall.qid = r->fid->qid; if(!pc->srv->open) @@ -165,7 +165,7 @@ ixp_handle_req(Req *r) case TREAD: if(!(r->fid = lookupkey(&pc->fidmap, r->ifcall.fid))) return respond(r, Enofid); - if(r->fid->omode == -1 || r->fid->omode == OWRITE) + if(r->fid->omode == -1 || r->fid->omode == P9OWRITE) return respond(r, Ebotch); if(!pc->srv->read) return respond(r, Enofunc); @@ -190,7 +190,7 @@ ixp_handle_req(Req *r) return respond(r, Enofid); if(r->fid->omode != -1) return respond(r, "cannot walk from an open fid"); - if(r->ifcall.nwname && !(r->fid->qid.type&QTDIR)) + if(r->ifcall.nwname && !(r->fid->qid.type&P9QTDIR)) return respond(r, Enotdir); if((r->ifcall.fid != r->ifcall.newfid)) { if(!(r->newfid = createfid(&pc->fidmap, r->ifcall.newfid, pc))) @@ -204,7 +204,7 @@ ixp_handle_req(Req *r) case TWRITE: if(!(r->fid = lookupkey(&pc->fidmap, r->ifcall.fid))) return respond(r, Enofid); - if((r->fid->omode&3) != OWRITE && (r->fid->omode&3) != ORDWR) + if((r->fid->omode&3) != P9OWRITE && (r->fid->omode&3) != P9ORDWR) return respond(r, "write on fid not opened for writing"); if(!pc->srv->write) return respond(r, Enofunc); @@ -215,7 +215,7 @@ ixp_handle_req(Req *r) } void -respond(Req *r, char *error) { +respond(P9Req *r, char *error) { P9Conn *pc = r->conn; switch(r->ifcall.type) { default: @@ -313,13 +313,13 @@ respond(Req *r, char *error) { /* Pending request cleanup */ static void ixp_void_request(void *t) { - Req *r, *tr; + P9Req *r, *tr; P9Conn *pc; r = t; pc = r->conn; - tr = cext_emallocz(sizeof(Req)); + tr = cext_emallocz(sizeof(P9Req)); tr->conn = pc; tr->ifcall.type = TFLUSH; tr->ifcall.tag = IXP_NOTAG; @@ -331,13 +331,13 @@ ixp_void_request(void *t) { static void ixp_void_fid(void *t) { P9Conn *pc; - Req *tr; + P9Req *tr; Fid *f; f = t; pc = f->conn; - tr = cext_emallocz(sizeof(Req)); + tr = cext_emallocz(sizeof(P9Req)); tr->fid = f; tr->conn = pc; tr->ifcall.type = TCLUNK;