Permalink
Browse files

Combining into single executable

  • Loading branch information...
1 parent 1e47656 commit cd4736f9c35460c48bff905b1f8f2da4335e1c3b @abedra committed Jan 5, 2012
Showing with 49 additions and 12 deletions.
  1. +3 −9 Makefile
  2. BIN bungelo
  3. +30 −0 bungelo.c
  4. +1 −1 bungleo-client.c → bungeloClient.c
  5. +6 −0 bungeloClient.h
  6. +1 −1 bungleo-server.c → bungeloServer.c
  7. +6 −0 bungeloServer.h
  8. +2 −1 todo.org
View
@@ -1,11 +1,5 @@
-all: server client
-
-server:
- gcc -o server bungleo-server.c -lzmq -ltofu
-
-client:
- gcc -o client bungleo-client.c -lzmq -ljson -lhiredis
+bungelo:
+ gcc bungeloClient.c bungeloServer.c bungelo.c -o bungelo -lzmq -lhiredis -ljson -ltofu
clean:
- rm server
- rm client
+ rm bungelo
View
BIN bungelo
Binary file not shown.
View
@@ -0,0 +1,30 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include "bungeloClient.h"
+#include "bungeloServer.h"
+
+static void printUsage(void) {
+ printf("Usage: bungelo [--client | --server]\n");
+}
+
+int main(int argc, char **argv)
+{
+ if(argc != 2) {
+ printUsage();
+ return 1;
+ }
+
+ char *mode = argv[1];
+
+ if(strcmp(mode, "--client") == 0) {
+ printf("Starting bungelo client...\n");
+ startBungeloClient();
+ } else if(strcmp(mode, "--server") == 0) {
+ printf("Starting bungelo server...\n");
+ startBungeloServer();
+ } else {
+ printf("Unknown option %s\n", mode);
+ printUsage();
+ return 2;
+ }
+}
@@ -26,7 +26,7 @@ static int persist(redisContext *c, const char *key, const char *value) {
return(response);
}
-int main(void)
+int startBungeloClient(void)
{
void *context = zmq_init(1);
void *receiver = zmq_socket(context, ZMQ_PULL);
View
@@ -0,0 +1,6 @@
+#ifndef __BUNGLEO_CLIENT_H__
+#define __BUNGLEO_CLIENT_H__
+
+extern int startBungleoClient(void);
+
+#endif
@@ -25,7 +25,7 @@ tofu_rep_t *post(tofu_req_t *req, void *socket) {
return rep;
}
-int main() {
+int startBungeloServer() {
char *opts[] = { "0.0.0.0", "5000" };
tofu_ctx_t *ctx = tofu_ctx_init(TOFU_EVHTTP, opts);
void *context = zmq_init(1);
View
@@ -0,0 +1,6 @@
+#ifndef __BUNGLEO_SERVER_H__
+#define __BUNGLEO_SERVER_H__
+
+extern int startBungleoServer(void);
+
+#endif
View
@@ -1,4 +1,5 @@
-* TODO combine into single executable with cli args to start server/client
+* DONE combine into single executable with cli args to start server/client
+ CLOSED: [2012-01-05 Thu 13:21]
* TODO run through valgrind and cleanup mess
* TODO put together proper configure (possibly autoconf)
* TODO add benchmarking bits

0 comments on commit cd4736f

Please sign in to comment.