src/server/safs/service.c

changeset 77
f1cff81e425a
parent 70
4e6e812c1d97
child 87
bdec069d2239
--- a/src/server/safs/service.c	Mon Jun 24 14:41:32 2013 +0200
+++ b/src/server/safs/service.c	Tue Jun 25 15:45:13 2013 +0200
@@ -52,7 +52,7 @@
 SYS_FILE prepare_service_file(Session *sn, Request *rq, struct stat *s) {
     char *ppath = pblock_findkeyval(pb_key_ppath, rq->vars);
 
-    /* open the file */
+    // open the file
     VFSContext *vfs = vfs_request_context(sn, rq);
     SYS_FILE fd = vfs_open(vfs, ppath, O_RDONLY);
     if(!fd) {
@@ -60,7 +60,7 @@
         return NULL;
     }
 
-    /* get stat */
+    // get stat
     if(vfs_fstat(vfs, fd, s) != 0) {
         //perror("prepare_service_file: stat");
         protocol_status(sn, rq, 500, NULL);
@@ -84,13 +84,13 @@
         return fd;
     }
 
-    /* add content-length header*/
+    // add content-length header
     char contentLength[32];
     int len = snprintf(contentLength, 32, "%lld", s->st_size);
 
     pblock_kvinsert(pb_key_content_length, contentLength, len, rq->srvhdrs);
 
-    /* start response */
+    // start response
     protocol_status(sn, rq, 200, NULL);
     http_start_response(sn, rq);
 
@@ -140,23 +140,23 @@
 
     sstr_t r_uri = sstr(uri);
 
-    /* open the file */
+    // open the file
     VFSContext *vfs = vfs_request_context(sn, rq);
     VFS_DIR dir = vfs_opendir(vfs, ppath);
     if(!dir) {
         return REQ_ABORTED;
     }
 
-    sbuf_t *out = sbuf_new(1024); /* output buffer */
+    sbuf_t *out = sbuf_new(1024); // output buffer
 
-    /* write html header  */
+    // write html header
     sbuf_puts(out, "<html>\n<head>\n<title>Index of ");
     sbuf_puts(out, uri);
     sbuf_puts(out, "</title>\n</head><body>\n<h1>Index of ");
     sbuf_puts(out, uri);
     sbuf_puts(out, "</h1><hr>\n\n");
 
-    //struct dirent *f;
+    // list directory
     VFS_ENTRY f;
     while(vfs_readdir(dir, &f)) {
         sstr_t filename = sstr(f.name);
@@ -171,7 +171,7 @@
 
     sbuf_puts(out, "\n</body>\n</html>\n");
 
-    /* send stuff to client */
+    // send stuff to client
     pblock_removekey(pb_key_content_type, rq->srvhdrs);
     pblock_kvinsert(pb_key_content_type, "text/html", 9, rq->srvhdrs);
     pblock_nninsert("content-length", out->length, rq->srvhdrs);
@@ -180,7 +180,7 @@
 
     net_write(sn->csd, out->ptr, out->length);
 
-    /* close */
+    // close
     vfs_closedir(dir);
     sbuf_free(out);
 

mercurial