Skip to content

Commit

Permalink
move http_date_snprint into separate httpdate.[ch]
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.kfish.org/fastphoto/trunk@142 9c49b5d1-7df3-0310-bce2-b7278e68f44c
  • Loading branch information
conrad committed Feb 16, 2006
1 parent c11e5f7 commit 6386249
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/Makefile.am
Expand Up @@ -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)
19 changes: 2 additions & 17 deletions src/header.c
Expand Up @@ -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)
Expand Down
22 changes: 22 additions & 0 deletions 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);
}
7 changes: 7 additions & 0 deletions 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__ */

0 comments on commit 6386249

Please sign in to comment.