Browse Source

Use util/Defined.h instead of preprocessor macros

Jeff 8 years ago
parent
commit
b5dcd519e9
2 changed files with 17 additions and 16 deletions
  1. 9 9
      client/Configurator.c
  2. 8 7
      client/cjdroute2.c

+ 9 - 9
client/Configurator.c

@@ -449,22 +449,22 @@ static void security(struct Allocator* tempAlloc, List* conf, struct Log* log, s
     int noforks = 1;
     int chroot = 1;
     int setupComplete = 1;
-#ifdef _WIN32
-    int setuser = 0;
-#else
     int setuser = 1;
-#endif
+    if (Defined(win32)) {
+        setuser = 0;
+    }
+
     int uid = -1;
     int keepNetAdmin = 1;
 
     do {
         Dict* d = Dict_new(tempAlloc);
         Dict_putString(d, String_CONST("user"), String_CONST("nobody"), tempAlloc);
-#ifndef _WIN32
-        Dict* ret = NULL;
-        rpcCall0(String_CONST("Security_getUser"), d, ctx, tempAlloc, &ret, true);
-        uid = *Dict_getInt(ret, String_CONST("uid"));
-#endif
+        if (!Defined(win32)) {
+            Dict* ret = NULL;
+            rpcCall0(String_CONST("Security_getUser"), d, ctx, tempAlloc, &ret, true);
+            uid = *Dict_getInt(ret, String_CONST("uid"));
+        }
     } while (0);
 
     for (int i = 0; conf && i < List_size(conf); i++) {

+ 8 - 7
client/cjdroute2.c

@@ -352,13 +352,14 @@ static int genconf(struct Random* rand, bool eth)
            "    },\n"
            "\n"
            "    // If set to non-zero, cjdns will not fork to the background.\n"
-           "    // Recommended for use in conjunction with \"logTo\":\"stdout\".\n"
-#ifdef _WIN32
-           "    \"noBackground\":1,\n"
-#else
-           "    \"noBackground\":0,\n"
-#endif
-           "}\n");
+           "    // Recommended for use in conjunction with \"logTo\":\"stdout\".\n");
+          if (Defined(win32)) {
+    printf("    \"noBackground\":1,\n");
+          }
+          else {
+    printf("    \"noBackground\":0,\n");
+          }
+    printf("}\n");
 
     return 0;
 }