shared config reader
authorMischa POSLAWSKY <netris@shiar.org>
Sun, 4 Mar 2007 09:50:39 +0000 (10:50 +0100)
committerMischa POSLAWSKY <netris@shiar.org>
Sun, 4 Mar 2007 09:50:39 +0000 (10:50 +0100)
client.c
server.c
util.c
util.h

index bd12f8ec913146649ee64d42efe6ff65f0d05e10..a1e284d39475f5e9d282120ccf1dc1a05487db3d 100644 (file)
--- 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();
index fe7eefc0e59e6dcafd217e480fab0ff824757ee9..947c8e196029dc37d6c1a1722d386469d68ff36b 100644 (file)
--- 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 e94f526aab94a3fe7cd5e75861d6e7971574d6ae..e3018f99012d623c8e7f20f3ca7aef466a61d316 100644 (file)
--- 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 f9d196622181692ec1443e94479d353f54f05527..60bf69af3ed9fdb66e10c60b5f9d5c35b39fce38 100644 (file)
--- 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);