shared config reader
[netris.git] / util.c
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)