[hackers] [libixp] Generally minor cleanup. Add some API docss. || Kris Maglione

From: <hg_AT_suckless.org>
Date: Thu, 3 Sep 2009 18:28:24 +0000 (UTC)

changeset: 111:6c7079a5cc46
tag: tip
user: Kris Maglione <jg_AT_suckless.org>
date: Thu Sep 03 14:28:50 2009 -0400
files: libixp/client.c libixp/request.c libixp/srv_util.c mk/common.mk
description:
Generally minor cleanup. Add some API docss.

diff -r a9349bbf7123 -r 6c7079a5cc46 libixp/client.c
--- a/libixp/client.c Thu Sep 03 14:20:44 2009 -0400
+++ b/libixp/client.c Thu Sep 03 14:28:50 2009 -0400
@@ -126,9 +126,9 @@
  * Params:
  * fd - A file descriptor which is already connected
  * to a 9P server.
- * address - An address (in Plan 9 resource fomat) on
+ * address - An address (in Plan 9 resource fomat) at
  * which to connect to a 9P server.
- * name - The name of the socket in the process's canonical
+ * name - The name of a socket in the process's canonical
  * namespace directory.
  *
  * Initiate a 9P connection with the server at P<address>,
@@ -247,6 +247,7 @@
         return f;
 fail:
         putfid(f);
+ free(p);
         return nil;
 }
 
diff -r a9349bbf7123 -r 6c7079a5cc46 libixp/request.c
--- a/libixp/request.c Thu Sep 03 14:20:44 2009 -0400
+++ b/libixp/request.c Thu Sep 03 14:28:50 2009 -0400
@@ -27,8 +27,9 @@
         Eduptag[] = "tag in use",
         Edupfid[] = "fid in use",
         Enofunc[] = "function not implemented",
- Ebotch[] = "9P protocol botch",
+ Eopen[] = "fid is already open",
         Enofile[] = "file does not exist",
+ Enoread[] = "file not open for reading",
         Enofid[] = "fid does not exist",
         Enotag[] = "tag does not exist",
         Enotdir[] = "not a directory",
@@ -203,7 +204,7 @@
                         return;
                 }
                 if(r->fid->omode != -1) {
- respond(r, Ebotch);
+ respond(r, Eopen);
                         return;
                 }
                 if(!(r->fid->qid.type&QTDIR)) {
@@ -238,7 +239,7 @@
                         return;
                 }
                 if(r->fid->omode == -1 || r->fid->omode == P9_OWRITE) {
- respond(r, Ebotch);
+ respond(r, Enoread);
                         return;
                 }
                 if(!pc->srv->read) {
diff -r a9349bbf7123 -r 6c7079a5cc46 libixp/srv_util.c
--- a/libixp/srv_util.c Thu Sep 03 14:20:44 2009 -0400
+++ b/libixp/srv_util.c Thu Sep 03 14:28:50 2009 -0400
@@ -32,6 +32,9 @@
 static IxpFileId* free_fileid;
 
 /* Utility Functions */
+/**
+ * Obtain an empty, reference counted IxpFileId struct.
+ */
 IxpFileId*
 ixp_srv_getfile(void) {
         IxpFileId *f;
@@ -55,6 +58,10 @@
         return f;
 }
 
+/**
+ * Decrease the reference count of the given IxpFileId,
+ * and push it onto the free list when it reaches 0;
+ */
 void
 ixp_srv_freefile(IxpFileId *f) {
         if(--f->nref)
@@ -64,14 +71,16 @@
         free_fileid = f;
 }
 
-/* Increase the reference counts of the IxpFileId list */
+/**
+ * Increase the reference count of every IxpFileId linked
+ * to 'f'.
+ */
 void
 ixp_srv_clonefiles(IxpFileId *f) {
         for(; f; f=f->next)
                 assert(f->nref++);
 }
 
-/* This should be moved to libixp */
 void
 ixp_srv_readbuf(Ixp9Req *r, char *buf, uint len) {
 
@@ -86,7 +95,6 @@
         r->ofcall.io.count = len;
 }
 
-/* This should be moved to libixp */
 void
 ixp_srv_writebuf(Ixp9Req *r, char **buf, uint *len, uint max) {
         IxpFileId *f;
@@ -118,6 +126,10 @@
         p[offset+count] = '\0';
 }
 
+/**
+ * Ensure that the data member of 'r' is null terminated,
+ * removing any new line from its end.
+ */
 void
 ixp_srv_data2cstring(Ixp9Req *r) {
         char *p, *q;
@@ -125,11 +137,11 @@
 
         i = r->ifcall.io.count;
         p = r->ifcall.io.data;
- q = memchr(p, '\0', i);
         if(i && p[i - 1] == '\n')
                 i--;
- if(q && q-p < i)
- i = q-p;
+ q = memchr(p, '\0', i);
+ if(q)
+ i = q - p;
 
         p = erealloc(r->ifcall.io.data, i+1);
         p[i] = '\0';
@@ -285,15 +297,26 @@
 
 bool
 ixp_pending_clunk(Ixp9Req *r) {
+ IxpPending *p;
         IxpFileId *f;
         IxpPLink *pl;
+ IxpRLink *rl;
         IxpQueue *qu;
         bool more;
 
         f = r->fid->aux;
         pl = f->p;
+
+ p = pl->pending;
+ for(rl=p->req.next; rl != &p->req; rl=rl->next)
+ if(rl->req->fid == pl->fid) {
+ respond(r, "fid in use");
+ return true;
+ }
+
         pl->prev->next = pl->next;
         pl->next->prev = pl->prev;
+
         while((qu = pl->queue)) {
                 pl->queue = qu->link;
                 free(qu->dat);
@@ -344,7 +367,7 @@
 
         f = lookup(f, nil);
         tf = f;
- /* Note: f->tab.name == "." so we skip it */
+ /* Note: The first f is ".", so we skip it. */
         offset = 0;
         for(f=f->next; f; f=f->next) {
                 dostat(&s, f);
diff -r a9349bbf7123 -r 6c7079a5cc46 mk/common.mk
--- a/mk/common.mk Thu Sep 03 14:20:44 2009 -0400
+++ b/mk/common.mk Thu Sep 03 14:28:50 2009 -0400
@@ -4,17 +4,25 @@
 
 MANDIRS=$(MAN)/man1
 mkdirs:
- for i in $(BIN) $(ETC) $(LIBDIR) $(MANDIRS) $(INCLUDE) $(DIRS); do \
- test -d $$i || echo MKDIR $$i; \
- mkdir -pm 0755 $$i; \
+ for i in $(BIN) $(ETC) $(LIBDIR) $(MANDIRS) $(INCLUDE); do \
+ test -d $(DESTDIR)$$i || echo MKDIR $$i; \
+ mkdir -pm 0755 $(DESTDIR)$$i; \
         done
 
 cleandep:
         echo CLEANDEP
         rm .depend 2>/dev/null || true
 
+tags:
+ files=; \
+ for f in $(OBJ); do \
+ [ -f "$$f.c" ] && files="$$files $$f.c"; \
+ done; \
+ echo CTAGS $$files $(TAGFILES) || \
+ ctags $$files $(TAGFILES)
+
 DEP:=${shell if test -f .depend;then echo .depend;else echo /dev/null; fi}
 DEP!=echo /dev/null
 include $(DEP)
 
-.PHONY: all options clean dist install uninstall depend cleandep
+.PHONY: all options clean dist install uninstall depend cleandep tags
Received on Thu Sep 03 2009 - 18:28:24 UTC

This archive was generated by hypermail 2.2.0 : Thu Sep 03 2009 - 18:36:06 UTC