From 314fb8c12b376d5e9bc62ec8b5db9458618a162b Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Sun, 4 Mar 2007 10:50:39 +0100 Subject: [PATCH] shared config reader --- client.c | 14 -------------- server.c | 16 ---------------- util.c | 18 ++++++++++++++++++ util.h | 1 + 4 files changed, 19 insertions(+), 30 deletions(-) diff --git a/client.c b/client.c index bd12f8e..a1e284d 100644 --- a/client.c +++ b/client.c @@ -105,20 +105,6 @@ void MapKeys(char *newKeys) exit(1); } -void WriteConf(void) -{ - FILE *file_out; - - file_out = fopen(CONFIG_FILE, "w"); - if (file_out == NULL) - die("Error writing config file"); - - fprintf(file_out, "### NETRIS %s Config file ###\n\n", version_string); - - fclose(file_out); - fprintf(stderr, "Wrote new game configuration to %s\n", CONFIG_FILE); -} - void Usage(void) { Header(); diff --git a/server.c b/server.c index fe7eefc..947c8e1 100644 --- a/server.c +++ b/server.c @@ -455,22 +455,6 @@ void SUsage(void) ); } -void WriteConf(void) -{ - FILE *file_out; - - file_out = fopen(CONFIG_FILE, "w"); - if (file_out == NULL) { - perror("Error writing config file"); - exit(1); - } - - fprintf(file_out, "### NETRIS %s Config file ###\n\n", version_string); - - fclose(file_out); - fprintf(stderr, "Wrote new game configuration to %s\n", CONFIG_FILE); -} - void HandleOption(char tag, char *value) { switch (tag) { diff --git a/util.c b/util.c index e94f526..e3018f9 100644 --- a/util.c +++ b/util.c @@ -160,6 +160,24 @@ int MyWrite(int fd, void *data, int len) return len; } +///////////// CONFIG ///////////// + +void WriteConf(void) +{ + FILE *file_out; + + file_out = fopen(CONFIG_FILE, "w"); + if (file_out == NULL) { + perror("Error writing config file"); + exit(1); + } + + fprintf(file_out, "### NETRIS %s Config file ###\n\n", version_string); + + fclose(file_out); + fprintf(stderr, "Wrote new game configuration to %s\n", CONFIG_FILE); +} + ///////////// TIME ///////////// void NormalizeTime(struct timeval *tv) diff --git a/util.h b/util.h index f9d1966..60bf69a 100644 --- a/util.h +++ b/util.h @@ -12,6 +12,7 @@ extern void SRandom(int seed); extern int Random(int min, int max1); extern int MyRead(int fd, void *data, int len); extern int MyWrite(int fd, void *data, int len); +extern void WriteConf(void); extern void NormalizeTime(struct timeval *tv); extern void CatchAlarm(int sig); extern void SetTimeval(struct timeval *tv, long usec); -- 2.30.0