Fix various compiler warnings.
[tinc] / src / tincctl.c
index 057ff7c..7e5c635 100644 (file)
 #include "tincctl.h"
 #include "top.h"
 
+#ifdef HAVE_MINGW
+#define mkdir(a, b) mkdir(a)
+#endif
+
 /* The name this program was run with. */
 static char *program_name = NULL;
 
@@ -684,10 +688,8 @@ static int cmd_start(int argc, char *argv[]) {
                slash = c;
 #endif
 
-       if (slash++) {
-               c = xmalloc((slash - argv[0]) + sizeof("tincd"));
-               sprintf(c, "%.*stincd", (int)(slash - argv[0]), argv[0]);
-       }
+       if (slash++)
+               xasprintf(&c, "%.*stincd", (int)(slash - argv[0]), argv[0]);
        else
                c = "tincd";
 
@@ -1354,7 +1356,7 @@ static int cmd_edit(int argc, char *argv[]) {
 #ifndef HAVE_MINGW
        char *editor = getenv("VISUAL") ?: getenv("EDITOR") ?: "vi";
 #else
-       char *editor = "edit"
+       char *editor = "edit";
 #endif
 
        char *command;
@@ -1383,8 +1385,10 @@ static int export(const char *name, FILE *out) {
 
        fprintf(out, "Name = %s\n", name);
        char buf[4096];
-       while(fgets(buf, sizeof buf, in))
-               fputs(buf, out);
+       while(fgets(buf, sizeof buf, in)) {
+               if(strcspn(buf, "\t =") != 4 || strncasecmp(buf, "Name", 4))
+                       fputs(buf, out);
+       }
 
        if(ferror(in)) {
                fprintf(stderr, "Error while reading configuration file %s: %s\n", filename, strerror(errno));