commit:bd39b527b12337f388e45410b86d223d4cdb16b0
author:Chip Black
committer:Chip Black
date:Fri Dec 31 01:08:08 2010 -0600
parents:96ec261b36bdbb701e05f5ee1aab70dec44085f9
Whoops, shouldn't mix fd and FILE* methods

(especially when you're using the wrong fd)
diff --git a/cgi/cgi_blerg.c b/cgi/cgi_blerg.c
line changes: +6/-6
index 5cd59a8..d0dcdba
--- a/cgi/cgi_blerg.c
+++ b/cgi/cgi_blerg.c
@@ -13,7 +13,7 @@ yajl_gen_config yajl_c = { 0, 0 };
 
 void respond_simple_data(unsigned const char *data, int len) {
 	printf("Content-length: %d\r\n\r\n", len);
-	write(0, data, len);
+	fwrite(data, len, 1, stdout);
 }
 
 void respond_404() {
@@ -60,13 +60,13 @@ void respond_for_range(struct blerg *b, uint64_t from, uint64_t to) {
 	for (i = to; i != from - 1; i--) {
 		json_generate_one_record(g, NULL, b, i);
 		yajl_gen_get_buf(g, &ybuf, &len);
-		write(0, ybuf, len);
+		fwrite(ybuf, len, 1, stdout);
 		yajl_gen_clear(g);
 	}
 
 	yajl_gen_array_close(g);
 	yajl_gen_get_buf(g, &ybuf, &len);
-	write(0, ybuf, len);
+	fwrite(ybuf, len, 1, stdout);
 	yajl_gen_free(g);
 }
 
@@ -90,7 +90,7 @@ void respond_taglist(struct tag *results, int i) {
 			blerg_close(b);
 		}
 		yajl_gen_get_buf(g, &ybuf, &len);
-		write(0, ybuf, len);
+		fwrite(ybuf, len, 1, stdout);
 		yajl_gen_clear(g);
 
 		i--;
@@ -98,7 +98,7 @@ void respond_taglist(struct tag *results, int i) {
 
 	yajl_gen_array_close(g);
 	yajl_gen_get_buf(g, &ybuf, &len);
-	write(0, ybuf, len);
+	write(ybuf, len, 1, stdout);
 	yajl_gen_free(g);
 }
 
@@ -273,7 +273,7 @@ int main(int argc, char *argv[]) {
 
 		printf("Content-type: application/json\r\n");
 		printf("Content-length: %d\r\n\r\n", len);
-		write(0, ybuf, len);
+		write(ybuf, len, 1, stdout);
 
 		yajl_gen_free(g);
 	} else if (strncmp(path, "/create", 8) == 0) {