Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

move http_date_snprint into separate httpdate.[ch]

git-svn-id: http://svn.kfish.org/fastphoto/trunk@142 9c49b5d1-7df3-0310-bce2-b7278e68f44c
  • Loading branch information...
commit 6386249ac4836f3116d4475abcc99b06d606cd23 1 parent c11e5f7
conrad authored
Showing with 33 additions and 19 deletions.
  1. +2 −2 src/Makefile.am
  2. +2 −17 src/header.c
  3. +22 −0 src/httpdate.c
  4. +7 −0 src/httpdate.h
View
4 src/Makefile.am
@@ -4,7 +4,7 @@ AM_CFLAGS = $(EPEG_CFLAGS)
bin_PROGRAMS = fastphoto
-noinst_HEADERS = alloc_snprintf.h cache.h cgi.h header.h photo.h resize.h
+noinst_HEADERS = alloc_snprintf.h cache.h cgi.h header.h httpdate.h photo.h resize.h
-fastphoto_SOURCES = main.c alloc_snprintf.c cache.c cgi.c header.c photo.c resize.c
+fastphoto_SOURCES = main.c alloc_snprintf.c cache.c cgi.c header.c httpdate.c photo.c resize.c
fastphoto_LDADD = $(EPEG_LIBS)
View
19 src/header.c
@@ -3,25 +3,10 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <time.h>
-#define CONTENT_TYPE_JPEG "Content-Type: image/jpeg\n"
-
-static char * wdays[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
-static char * months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
- "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
-
-static int
-http_date_snprint (char * buf, int n, time_t mtime)
-{
- struct tm * g;
+#include "httpdate.h"
- g = gmtime (&mtime);
-
- return snprintf (buf, n, "%s, %02d %s %4d %2d:%02d:%02d GMT",
- wdays[g->tm_wday], g->tm_mday, months[g->tm_mon],
- g->tm_year + 1900, g->tm_hour, g->tm_min, g->tm_sec);
-}
+#define CONTENT_TYPE_JPEG "Content-Type: image/jpeg\n"
int
header_last_modified (time_t mtime)
View
22 src/httpdate.c
@@ -0,0 +1,22 @@
+#include "config.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+static char * wdays[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
+static char * months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
+ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
+
+int
+http_date_snprint (char * buf, int n, time_t mtime)
+{
+ struct tm * g;
+
+ g = gmtime (&mtime);
+
+ return snprintf (buf, n, "%s, %02d %s %4d %2d:%02d:%02d GMT",
+ wdays[g->tm_wday], g->tm_mday, months[g->tm_mon],
+ g->tm_year + 1900, g->tm_hour, g->tm_min, g->tm_sec);
+}
View
7 src/httpdate.h
@@ -0,0 +1,7 @@
+#ifndef __HTTPDATE_H__
+#define __HTTPDATE_H__
+
+int http_date_snprint (char * buf, int n, time_t mtime);
+
+
+#endif /* __HTTPDATE_H__ */
Please sign in to comment.
Something went wrong with that request. Please try again.