changeset 35:92c813bf6e35

archive: nice title string + assorted sar fixes
author Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
date Fri, 06 Feb 2009 22:12:04 -0500
parents a1cf9bd7860f
children 4955e2383f0a
files archive.c html.h post.c sar.c sar.h
diffstat 5 files changed, 15 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/archive.c	Fri Feb 06 22:10:57 2009 -0500
+++ b/archive.c	Fri Feb 06 22:12:04 2009 -0500
@@ -13,10 +13,13 @@
 	char *path_info;
 	int archid;
 	struct post post;
+	char nicetitle[32];
 
 	clock_gettime(CLOCK_REALTIME, &s);
 
+	memset(&post, 0, sizeof(struct post));
 	post.out = stdout;
+	post.title = nicetitle;
 
 	fprintf(post.out, "Content-Type: text/html\n\n");
 
@@ -29,15 +32,15 @@
 
 	archid = atoi(path_info+1);
 
-	memset(&post, 0, sizeof(struct post));
-	post.out = stdout;
-	post.title = "archive XYZ";
+	snprintf(nicetitle, 32, "%d &raquo; %s", archid/100,
+		 up_month_strs[(archid%100)-1]);
 
 	html_header(&post);
 	html_archive(&post, archid);
 	html_sidebar(&post);
 	html_footer(&post);
 
+	post.title = NULL;
 	destroy_post(&post);
 
 	clock_gettime(CLOCK_REALTIME, &e);
--- a/html.h	Fri Feb 06 22:10:57 2009 -0500
+++ b/html.h	Fri Feb 06 22:12:04 2009 -0500
@@ -5,7 +5,7 @@
 
 extern void html_story(struct post *post);
 extern void html_index(struct post *post);
-extern void html_archive(struct post *post);
+extern void html_archive(struct post *post, int archid);
 extern void html_comments(struct post *post);
 extern void html_sidebar(struct post *post);
 extern void html_header(struct post *post);
--- a/post.c	Fri Feb 06 22:10:57 2009 -0500
+++ b/post.c	Fri Feb 06 22:12:04 2009 -0500
@@ -83,13 +83,15 @@
 				break;
 
 			case CATP_PAR:
+				fwrite(ibuf+sidx, 1, eidx-sidx, post->out);
+				sidx = eidx;
 				if (tmp == '\n') {
-					fwrite(ibuf+sidx, 1, eidx-sidx, post->out);
 					fwrite("</p>\n", 1, 5, post->out);
-					sidx = eidx+1;
 					state = CATP_SKIP;
-				} else
+				} else {
+					fwrite("<br/>\n", 1, 5, post->out);
 					state = CATP_ECHO;
+				}
 				break;
 
 		}
--- a/sar.c	Fri Feb 06 22:10:57 2009 -0500
+++ b/sar.c	Fri Feb 06 22:12:04 2009 -0500
@@ -12,7 +12,7 @@
 	fprintf(post->out, "%d", post->id);
 }
 
-static char* up_month_strs[12] = {
+char* up_month_strs[12] = {
 	"January", "February", "March", "April", "May", "June",
 	"July", "August", "September", "October", "November", "December",
 };
--- a/sar.h	Fri Feb 06 22:10:57 2009 -0500
+++ b/sar.h	Fri Feb 06 22:12:04 2009 -0500
@@ -16,6 +16,8 @@
 extern struct repltab_entry *repltab_cat_html;
 extern struct repltab_entry *repltab_arch_html;
 
+extern char* up_month_strs[12];
+
 #define COPYCHAR(ob, oi, c)	do { \
 					ob[oi] = c; \
 					oi++; \