[xiph-commits] r3513 - liboggz/trunk/src/tools/oggz-chop

conrad at svn.annodex.net conrad at svn.annodex.net
Thu Mar 20 13:50:58 PDT 2008


Author: conrad
Date: 2008-03-20 13:50:57 -0700 (Thu, 20 Mar 2008)
New Revision: 3513

Modified:
   liboggz/trunk/src/tools/oggz-chop/cgi.c
Log:
add If-Modified-Since support to oggz-chop CGI mode


Modified: liboggz/trunk/src/tools/oggz-chop/cgi.c
===================================================================
--- liboggz/trunk/src/tools/oggz-chop/cgi.c	2008-03-20 10:30:14 UTC (rev 3512)
+++ liboggz/trunk/src/tools/oggz-chop/cgi.c	2008-03-20 20:50:57 UTC (rev 3513)
@@ -3,6 +3,10 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
 
 #include "oggz-chop.h"
 #include "header.h"
@@ -139,22 +143,32 @@
 
   /*photo_init (&params->in, path_translated);*/
 
-#if 0
   if (if_modified_since != NULL) {
+    struct stat statbuf;
     int len;
 
     fprintf (stderr, "If-Modified-Since: %s\n", if_modified_since);
 
+    if (stat (path_translated, &statbuf) == -1) {
+      switch (errno) {
+      case ENOENT:
+        return 0;
+      default:
+        fprintf (stderr, "oggz-chop: Error checking %s: %s\n",
+                 path_translated, strerror(errno));
+        return -1;
+      }
+    }
+
     len = strlen (if_modified_since) + 1;
     since_time = httpdate_parse (if_modified_since, len);
 
-    if (state->in.mtime <= since_time) {
+    if (statbuf.st_mtime <= since_time) {
       header_not_modified();
       header_end();
       return 1;
     }
   }
-#endif
 
   header_content_type_ogg ();
 



More information about the commits mailing list