Skip to content

Commit

Permalink
Make port configurable via args
Browse files Browse the repository at this point in the history
  • Loading branch information
Josep M. Bach committed Sep 20, 2012
1 parent 0365848 commit e65c81a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Shitty key-value store in C inspired by Redis.
## Usage

$ make
$ bin/shitdb
$ bin/shitdb [port]

Example session:

Expand Down
16 changes: 15 additions & 1 deletion bin/shitdb.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
#include <shitdb/db.h>
#include <shitdb/server.h>

#define DEFAULT_PORT 4999

static int
resolve_port(int argc, char **argv)
{
int port = 0;
if(argc == 2 && (port = atoi(argv[1]))) {
return port;
} else {
return DEFAULT_PORT;
}
}

int main(int argc, char **argv)
{
DB *db = DB_create();

Server_start(db, DEFAULT_PORT);
int port = resolve_port(argc, argv);

Server_start(db, port);

return 0;
}

0 comments on commit e65c81a

Please sign in to comment.