Skip to content
This repository has been archived by the owner on Aug 31, 2021. It is now read-only.

Commit

Permalink
refactor stats collection into simplehttp; add generic logging to sim…
Browse files Browse the repository at this point in the history
…plehttp with -V option; update all apps to compile; add gitignore
  • Loading branch information
mreiferson committed Mar 15, 2011
1 parent 0b11575 commit e91b668
Show file tree
Hide file tree
Showing 33 changed files with 446 additions and 591 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.o
*.a
*.dSYM
sortdb/sortdb
1 change: 0 additions & 1 deletion lib/log.h

This file was deleted.

15 changes: 0 additions & 15 deletions lib/timer.h

This file was deleted.

6 changes: 2 additions & 4 deletions ps_to_file/ps_to_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
#include <string.h>
#include <unistd.h>
#include <time.h>

#include "simplehttp/pubsubclient.h"
#include "event.h"
#include "evhttp.h"
#include <simplehttp/pubsubclient.h>
#include <simplehttp/simplehttp.h>

#define DEBUG 0

Expand Down
2 changes: 1 addition & 1 deletion pubsub/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LIBSIMPLEHTTP_INC ?= $(LIBSIMPLEHTTP)/..
LIBSIMPLEHTTP_LIB ?= $(LIBSIMPLEHTTP)

CFLAGS = -I. -I$(LIBSIMPLEHTTP_INC) -I$(LIBEVENT)/include -O2 -g
LIBS = -L. -L$(LIBSIMPLEHTTP_LIB) -L$(LIBEVENT)/lib -levent -lsimplehttp -lpcre
LIBS = -L. -L$(LIBSIMPLEHTTP_LIB) -L$(LIBEVENT)/lib -levent -lsimplehttp -lpcre -lm

pubsub: pubsub.c
$(CC) $(CFLAGS) -o $@ $< $(LIBS)
Expand Down
4 changes: 2 additions & 2 deletions pubsub/pubsub.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#include <stdio.h>
#include <string.h>
#include <time.h>
#include "simplehttp/queue.h"
#include "simplehttp/simplehttp.h"
#include <simplehttp/queue.h>
#include <simplehttp/simplehttp.h>
#include "http-internal.h"

#define BOUNDARY "xXPubSubXx"
Expand Down
2 changes: 1 addition & 1 deletion pubsub_filtered/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LIBSIMPLEHTTP_INC ?= $(LIBSIMPLEHTTP)/..
LIBSIMPLEHTTP_LIB ?= $(LIBSIMPLEHTTP)

CFLAGS = -I. -I$(LIBSIMPLEHTTP_INC) -I$(LIBEVENT)/include -g -O2
LIBS = -L. -L$(LIBSIMPLEHTTP_LIB) -L$(LIBEVENT)/lib -levent -lsimplehttp -ljson -lpcre
LIBS = -L. -L$(LIBSIMPLEHTTP_LIB) -L$(LIBEVENT)/lib -levent -lsimplehttp -ljson -lpcre -lm

pubsub_filtered: pubsub_filtered.c md5.c
$(CC) $(CFLAGS) -o $@ md5.c $< $(LIBS)
Expand Down
7 changes: 3 additions & 4 deletions pubsub_filtered/pubsub_filtered.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
#include <string.h>
#include <unistd.h>
#include <time.h>
#include "simplehttp/queue.h"
#include "simplehttp/simplehttp.h"
#include "event.h"
#include <simplehttp/queue.h>
#include <simplehttp/simplehttp.h>
#include <json/json.h>
#include "http-internal.h"
#include "json/json.h"
#include "md5.h"
#include "pcre.h"

Expand Down
4 changes: 2 additions & 2 deletions pubsub_to_pubsub/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LIBSIMPLEHTTP_INC ?= $(LIBSIMPLEHTTP)/..
LIBSIMPLEHTTP_LIB ?= $(LIBSIMPLEHTTP)

CFLAGS = -I. -I$(LIBSIMPLEHTTP_INC) -I$(LIBEVENT)/include -g -O2
LIBS = -L. -L$(LIBSIMPLEHTTP_LIB) -L$(LIBEVENT)/lib -levent -ljson -ldl -lm -lc
LIBS = -L. -L$(LIBSIMPLEHTTP_LIB) -L$(LIBEVENT)/lib -levent -ljson -ldl -lm -lc -lpubsub_to_pubsub
AR = ar
AR_FLAGS = rc
RANLIB = ranlib
Expand All @@ -16,7 +16,7 @@ libpubsub_to_pubsub.a: pubsub_to_pubsub.o
$(RANLIB) $@

ps_to_ps: ps_to_ps.c
$(CC) $(CFLAGS) -o $@ $< $(LIBS) -lpubsub_to_pubsub
$(CC) $(CFLAGS) -o $@ $< $(LIBS)

all: libpubsub_to_pubsub.a ps_to_ps

Expand Down
7 changes: 2 additions & 5 deletions pubsub_to_pubsub/ps_to_ps.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>


#include "simplehttp/pubsub_to_pubsub.h"
#include "event.h"
#include "evhttp.h"
#include <simplehttp/pubsub_to_pubsub.h>
#include <simplehttp/simplehttp.h>

#define DEBUG 0

Expand Down
4 changes: 2 additions & 2 deletions pubsubclient/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LIBSIMPLEHTTP_INC ?= $(LIBSIMPLEHTTP)/..
LIBSIMPLEHTTP_LIB ?= $(LIBSIMPLEHTTP)

CFLAGS = -I. -I$(LIBSIMPLEHTTP_INC) -I$(LIBEVENT)/include -g
LIBS = -L. -L$(LIBSIMPLEHTTP_LIB) -L$(LIBEVENT)/lib -levent -ldl -lm -lc
LIBS = -L. -L$(LIBSIMPLEHTTP_LIB) -L$(LIBEVENT)/lib -levent -ldl -lm -lc -lsimplehttp -lpubsubclient -lpthread -lcurl
AR = ar
AR_FLAGS = rc
RANLIB = ranlib
Expand All @@ -16,7 +16,7 @@ libpubsubclient.a: pubsubclient.o
$(RANLIB) $@

pubsub-reader: pubsub-reader.o
$(CC) $(CFLAGS) -o $@ $< $(LIBS) -lsimplehttp -lpubsubclient -lpthread -lcurl
$(CC) $(CFLAGS) -o $@ $< $(LIBS)

all: libpubsubclient.a pubsub-reader

Expand Down
6 changes: 3 additions & 3 deletions pubsubclient/pubsubclient.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@

#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "event.h"
#include "evhttp.h"
#include <simplehttp/queue.h>
#include <simplehttp/simplehttp.h>
#include "pubsubclient.h"

#define DEBUG 0
#define BOUNDARY_LENGTH 14
// \r\n--xXPubSubXx\r\n
Expand Down
5 changes: 3 additions & 2 deletions qrencode/qrencode.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#include "queue.h"
#include <stdlib.h>
#include <stdio.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <simplehttp/queue.h>
#include <simplehttp/simplehttp.h>
#include <json/json.h>
#include "png.h"
#include "qrencode.h"
#include "simplehttp.h"

/*
* libqrencode
Expand Down
4 changes: 2 additions & 2 deletions simpleattributes/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ LIBSIMPLEHTTP_INC ?= $(LIBSIMPLEHTTP)/..
LIBSIMPLEHTTP_LIB ?= $(LIBSIMPLEHTTP)

CFLAGS = -I. -I$(LIBSIMPLEHTTP_INC) -I$(LIBEVENT)/include -g
LIBS = -L. -L$(LIBSIMPLEHTTP_LIB) -L$(LIBEVENT)/lib -L/usr/local/lib -levent -ljson -ltokyotyrant -ltokyocabinet -lz -lbz2 -lresolv -ldl -lpthread -lm -lc
LIBS = -L. -L$(LIBSIMPLEHTTP_LIB) -L$(LIBEVENT)/lib -L/usr/local/lib -lsimplehttp -levent -ljson -ltokyotyrant -ltokyocabinet -lz -lbz2 -lresolv -ldl -lpthread -lm -lc


simpleattributes: simpleattributes.c
$(CC) $(CFLAGS) -o $@ $< $(LIBS) -lsimplehttp
$(CC) $(CFLAGS) -o $@ $^ $(LIBS)

install:
/usr/bin/install -d $(TARGET)/bin
Expand Down
16 changes: 8 additions & 8 deletions simpleattributes/simpleattributes.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#include <tcrdb.h>
#include "queue.h"
#include <stdlib.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include "simplehttp.h"
#include "json/json.h"
#include <simplehttp/queue.h>
#include <simplehttp/simplehttp.h>
#include <json/json.h>

#define RECONNECT 5
#define MAXRES 1000
Expand Down Expand Up @@ -37,7 +37,7 @@ void finalize_json(struct evhttp_request *req, struct evbuffer *evb,
char *json, *jsonp;

jsonp = (char *)evhttp_find_header(args, "jsonp");
json = json_object_to_json_string(jsobj);
json = (char *)json_object_to_json_string(jsobj);
if (jsonp) {
evbuffer_add_printf(evb, "%s(%s)\n", jsonp, json);
} else {
Expand Down Expand Up @@ -228,8 +228,8 @@ void put_cb(struct evhttp_request *req, struct evbuffer *evb, void *ctx)

for (i=0; i < json_object_array_length(jsonPtr); i++) {
jsonPtr2 = json_object_array_get_idx(jsonPtr, i);
key = json_object_get_string(json_object_array_get_idx(jsonPtr2, 0));
value = json_object_get_string(json_object_array_get_idx(jsonPtr2, 1));
key = (char *)json_object_get_string(json_object_array_get_idx(jsonPtr2, 0));
value = (char *)json_object_get_string(json_object_array_get_idx(jsonPtr2, 1));
tcmapput2(cols, key, value);
}

Expand Down Expand Up @@ -280,15 +280,15 @@ void get_cb(struct evhttp_request *req, struct evbuffer *evb, void *ctx)


if (key) {
value = tcmapget2(cols, key);
value = (char *)tcmapget2(cols, key);

if (!value) {
value = "";
}

json_object_object_add(jsobj2, key, json_object_new_string(value));
} else {
while ((name = tcmapiternext2(cols)) != NULL) {
while ((name = (char *)tcmapiternext2(cols)) != NULL) {
json_object_object_add(jsobj2, name, json_object_new_string(tcmapget2(cols, name)));
}
}
Expand Down
4 changes: 2 additions & 2 deletions simplegeo/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ LIBSIMPLEHTTP_INC ?= $(LIBSIMPLEHTTP)/..
LIBSIMPLEHTTP_LIB ?= $(LIBSIMPLEHTTP)

CFLAGS = -I. -I$(LIBSIMPLEHTTP_INC) -I$(LIBEVENT)/include -g
LIBS = -L. -L$(LIBSIMPLEHTTP_INC) -L$(LIBEVENT)/lib -L/usr/local/lib -levent -ljson -ltokyotyrant -ltokyocabinet -lz -lbz2 -lresolv -ldl -lpthread -lm -lc
LIBS = -L. -L$(LIBSIMPLEHTTP_INC) -L$(LIBEVENT)/lib -L/usr/local/lib -lsimplehttp -levent -ljson -ltokyotyrant -ltokyocabinet -lz -lbz2 -lresolv -ldl -lpthread -lm -lc

simplegeo: simplegeo.c
$(CC) $(CFLAGS) -o $@ $< $(LIBS) -lsimplehttp
$(CC) $(CFLAGS) -o $@ $^ $(LIBS)

install:
/usr/bin/install -d $(TARGET)/bin
Expand Down
6 changes: 3 additions & 3 deletions simplegeo/simplegeo.c
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#include <tcrdb.h>
#include "queue.h"
#include <stdlib.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "simplehttp.h"
#include "json/json.h"
#include <simplehttp/queue.h>
#include <simplehttp/simplehttp.h>
#include <json/json.h>

#define RECONNECT 5
#define MAXRES 1000
Expand Down
6 changes: 3 additions & 3 deletions simplehttp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ LIBEVENT ?= /usr/local
TARGET ?= /usr/local

CFLAGS = -I. -I$(LIBEVENT)/include -Wall -g -O2
LIBS = -L. -L$(LIBEVENT)/lib -levent
LIBS = -L. -L$(LIBEVENT)/lib -levent -lm

AR = ar
AR_FLAGS = rc
RANLIB = ranlib

libsimplehttp.a: simplehttp.o
libsimplehttp.a: simplehttp.o timer.o log.o util.o stat.o
/bin/rm -f $@
$(AR) $(AR_FLAGS) $@ $<
$(AR) $(AR_FLAGS) $@ $^
$(RANLIB) $@

testserver: testserver.c
Expand Down
File renamed without changes.
Loading

0 comments on commit e91b668

Please sign in to comment.