Skip to content

Commit

Permalink
microrefactor of wmxc
Browse files Browse the repository at this point in the history
  • Loading branch information
NattyNarwhal committed May 26, 2014
1 parent 3ecc8f7 commit 19eca88
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
8 changes: 5 additions & 3 deletions Makefile
Expand Up @@ -36,14 +36,16 @@ WMXCOBJ = wmxc.o
.c.o:
$(CC) -c $(CFLAGS) $<

wmx: libportable.a $(OBJECTS) $(WMXCOBJ)
wmx: libportable.a wmxc $(OBJECTS)
$(CCC) -o wmx $(OBJECTS) $(CCLIBS) # wmx proper
$(CC) -o wmxc $(WMXCOBJ) $(CLIBS) # wmxc

libportable.a: $(LIBOBJ)
$(AR) rcs libportable.a Portable.o

install: wmx
wmxc: libportable.a $(WMXCOBJ)
$(CC) -o wmxc $(WMXCOBJ) $(CLIBS) # wmxc

install: wmx wmxc
install wmx $(BINDIR)
install wmxc $(BINDIR)
install wmx.1 $(MANDIR)
Expand Down
10 changes: 6 additions & 4 deletions wmxc.c
Expand Up @@ -13,13 +13,15 @@
#define CONFIG_DEFAULT_LISTENER "localhost"
#define CONFIG_DEFAULT_PORT "6999"

#define BUFF_SIZE 1024
#define BUFF_SIZE 1024 /* reasonable size for a buffer */
#define HOST_SIZE 65 /* maximum size for a hostname is 64+null byte, also use for port */

void usage(char *progname) {
fprintf(stderr, "usage: %s [-p port] [-q] command [args]\n", progname);
exit(1);
}

// TODO: move fancy strings to wmxc, keeping remote protocol slim
int main(int argc, char **argv) {
struct addrinfo hint, *r;
struct timeval t;
Expand All @@ -29,8 +31,8 @@ int main(int argc, char **argv) {
char recv_buf[BUFF_SIZE] = "";
char send_buf[BUFF_SIZE] = "";

char *addr = CONFIG_DEFAULT_LISTENER;
char *port = CONFIG_DEFAULT_PORT;
char addr[HOST_SIZE] = CONFIG_DEFAULT_LISTENER;
char port[HOST_SIZE] = CONFIG_DEFAULT_PORT;
int quiet = 0;

memset(&hint, 0, sizeof(hint));
Expand All @@ -45,7 +47,7 @@ int main(int argc, char **argv) {
while((c = getopt(argc, argv, "p:q")) != -1 ) {
switch (c) {
case 'p':
port = optarg;
strlcpy(port, optarg, HOST_SIZE);
break;
case 'q':
quiet++;
Expand Down

0 comments on commit 19eca88

Please sign in to comment.