Skip to content

Commit

Permalink
removed dependency on external bstring lib, added port config
Browse files Browse the repository at this point in the history
  • Loading branch information
mmmmhack committed Apr 6, 2012
1 parent 6b95529 commit 0205009
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 8 deletions.
11 changes: 7 additions & 4 deletions Makefile
Expand Up @@ -5,20 +5,23 @@ CFLAGS += -Wall -g
OS = OS_$(shell uname -s | tr '[:lower:]' '[:upper:]')

defines += -D$(OS)
includes = -I$(bstrlib_dir)/include -I.
libs = -L$(bstrlib_dir)/lib -lbstrlib
objs = util.o gdb.o servsock.o
#includes = -I$(bstrlib_dir)/include -I.
#libs = -L$(bstrlib_dir)/lib -lbstrlib
objs = bstrlib.o util.o gdb.o servsock.o

tests = $(basename $(wildcard test_*.c))

all: gserver gclient
all: gserver gclient hello

gserver: gserver.o $(objs)
$(CC) $(CFLAGS) -o $@ gserver.o $(objs) $(libs)

gclient: gclient.o $(objs)
$(CC) $(CFLAGS) -o $@ gclient.o $(objs) $(libs)

hello: hello.o
$(CC) $(CFLAGS) -o$@ $<

%.o: %.c
$(CC) $(CFLAGS) -o $@ $(defines) $(includes) -c $<

Expand Down
5 changes: 5 additions & 0 deletions devlog-wknight.html
Expand Up @@ -486,6 +486,11 @@ <h2>2011-12-15</h2>
I'm going to add a help command today.
</p>

<h2>2012-04-06</h2>

<p>
Moving to github.
</p>

</body>
</html>
Expand Down
12 changes: 11 additions & 1 deletion gclient.c
Expand Up @@ -17,13 +17,17 @@ const char* PROG_VERSION = "0.1 " __DATE__;

const char* USAGE = \
"gclient - gdb client program\n" \
"A tool for debugging with gdb in other programs such as vim\n" \
"usage: \n"\
" gclient [options] command_string\n"\
"\n" \
"Options:\n" \
" -h List all options, with brief explanations.\n" \
" -v Report program version and exit.\n"\
"\n" \
"Environment variables:\n" \
" GSERVER_PORT : port number to communicate with gclient (default=6667)\n" \
"\n" \
"Commands:\n" \
" start_gdb\n"\
" Starts a gdb child process, terminating any running gdb process first.\n"\
Expand All @@ -43,7 +47,7 @@ const char* USAGE = \
;

static void usage() {
printf(USAGE);
printf("%s", USAGE);
}

static void parse_options(int argc, char** argv) {
Expand Down Expand Up @@ -74,6 +78,12 @@ int main(int argc, char** argv) {
// parse options
parse_options(argc, argv);

// get port from env
char* port_str = getenv("GSERVER_PORT");
if(port_str != NULL) {
port_num = atoi(port_str);
}

if(argc < 2) {
fprintf(stderr, "missing request arg\n");
exit(1);
Expand Down
17 changes: 14 additions & 3 deletions gserver.c
Expand Up @@ -28,12 +28,16 @@ const char* PROG_VERSION = "0.1 " __DATE__;

const char* USAGE = \
"gserver - gdb server program\n" \
"A tool for debugging with gdb in other programs such as vim\n" \
"usage: \n"\
" gserver [options]\n"\
"\n" \
"Options:\n" \
" -h List all options, with brief explanations.\n" \
" -v Report program version and exit.\n";
" -h List all options, with brief explanations.\n" \
" -v Report program version and exit.\n" \
"Environment variables:\n" \
" GSERVER_PORT : port number to communicate with gclient (default=6667)\n" \
;

static in_port_t port_num = 6667;
static const int MAX_PENDING = 0;
Expand Down Expand Up @@ -64,7 +68,7 @@ static struct Cmd cmds[] = {
static const int num_cmds = sizeof(cmds) / sizeof(cmds[0]);

static void usage() {
printf(USAGE);
printf("%s", USAGE);
}

static void parse_options(int argc, char** argv) {
Expand Down Expand Up @@ -305,6 +309,12 @@ int main(int argc, char** argv) {
// parse options
parse_options(argc, argv);

// get port from env
char* port_str = getenv("GSERVER_PORT");
if(port_str != NULL) {
port_num = atoi(port_str);
}

// just fire up a socket to listen and wait for commands

// create
Expand Down Expand Up @@ -333,6 +343,7 @@ int main(int argc, char** argv) {
if(rc < 0)
sys_err("listen failed");
INFO("listening");
printf("listening on port %d\n", port_num);

while(!_quit) {
// accept
Expand Down

0 comments on commit 0205009

Please sign in to comment.