applied Eric's config.def.h patch

This commit is contained in:
Anselm R Garbe 2014-11-02 09:23:48 +01:00
parent 7cfa52d6eb
commit f87d3f5bef
3 changed files with 19 additions and 5 deletions

View File

@ -17,7 +17,11 @@ options:
@echo CC $<
@${CC} -c ${CFLAGS} $<
${OBJ}: config.mk util.c
${OBJ}: config.h config.mk util.c
config.h:
@echo creating $@ from config.def.h
@cp config.def.h $@
sic: ${OBJ}
@echo CC -o $@

8
config.def.h Normal file
View File

@ -0,0 +1,8 @@
// Host used when "-h" is not given
#define DEFAULT_HOST "irc.oftc.net"
// Port used when "-p" is not given
#define DEFAULT_PORT "6667"
// Timestamp format; see strftime(3)
#define TIMESTAMP_FORMAT "%F %R"

10
sic.c
View File

@ -8,8 +8,10 @@
#include <time.h>
#include <unistd.h>
static char *host = "irc.oftc.net";
static char *port = "6667";
#include "config.h"
static char *host = DEFAULT_HOST;
static char *port = DEFAULT_PORT;
static char *password;
static char nick[32];
static char bufin[4096];
@ -22,7 +24,7 @@ static FILE *srv;
static void
pout(char *channel, char *fmt, ...) {
static char timestr[18];
static char timestr[80];
time_t t;
va_list ap;
@ -30,7 +32,7 @@ pout(char *channel, char *fmt, ...) {
vsnprintf(bufout, sizeof bufout, fmt, ap);
va_end(ap);
t = time(NULL);
strftime(timestr, sizeof timestr, "%D %R", localtime(&t));
strftime(timestr, sizeof timestr, TIMESTAMP_FORMAT, localtime(&t));
fprintf(stdout, "%-12s: %s %s\n", channel, timestr, bufout);
}