check-net: replace exit() to return with value
authorMunkyu Im <munkyu.im@samsung.com>
Wed, 24 Jun 2015 02:00:33 +0000 (11:00 +0900)
committerMunkyu Im <munkyu.im@samsung.com>
Fri, 26 Jun 2015 09:04:45 +0000 (18:04 +0900)
Change-Id: I56be60617b51c846e0fe90893343584d1f22d26a
Signed-off-by: Munkyu Im <munkyu.im@samsung.com>
tizen/src/util/check_net.c
tizen/src/util/check_net.h
tizen/src/util/check_net_darwin.c
tizen/src/util/check_net_linux.c
tizen/src/util/check_net_win32.c

index aae1a18..6c6b02a 100644 (file)
@@ -86,22 +86,23 @@ inline void remove_string(char *src, char *dst, const char *toremove)
     dst[j] = '\0';
 }
 
-void main(int argc, char *argv[])
+int main(int argc, char *argv[])
 {
     if (argc != 2) {
         fprintf(stderr, " Usage: check-net --proxy\n");
         fprintf(stderr, "        check-net --interface-all\n");
         fprintf(stderr, "        check-net --bridge\n");
         fprintf(stderr, "        check-net --host-ip\n");
-        return;
+        return 1;
     }
     if (strcmp(argv[1], ARG_PROXY) == 0) {
         get_host_proxy_os();
     } else if (strcmp(argv[1], ARG_INTERFACE_ALL) == 0) {
-        get_host_interface_all_os();
+        return get_host_interface_all_os();
     } else if (strcmp(argv[1], ARG_BRIDGE) == 0) {
-        get_host_bridge_os();
+        return get_host_bridge_os();
     } else if (strcmp(argv[1], ARG_HOST_IP) == 0) {
         get_host_ip_os();
     }
+    return 0;
 }
index e519408..06945f4 100644 (file)
@@ -71,8 +71,8 @@
 extern const char *pac_tempfile;
 
 void get_host_proxy_os(void);
-void get_host_interface_all_os(void);
-void get_host_bridge_os(void);
+int get_host_interface_all_os(void);
+int get_host_bridge_os(void);
 
 void download_url(char *);
 size_t write_data(void *, size_t, size_t, FILE *);
index 81193d6..cdc0b1a 100644 (file)
@@ -196,21 +196,25 @@ void get_host_proxy_os(void)
     }
 }
 
-void get_host_interface_all_os(void)
+int get_host_interface_all_os(void)
 {
     if (access(PATH_IFCONFIG, F_OK) != -1) {
         system("/sbin/ifconfig -a");
+        return 0;
     } else {
         fprintf(stderr, "ifconfig does not exist!\n");
+        return 1;
     }
 }
 
-void get_host_bridge_os(void)
+int get_host_bridge_os(void)
 {
     if (access(PATH_IFCONFIG, F_OK) != -1) {
         system("/sbin/ifconfig bridge1");
+        return 0;
     } else {
         fprintf(stderr, "ifconfig does not exist!\n");
+        return 1;
     }
 }
 
index 5ad1a0e..dc5545b 100644 (file)
@@ -240,21 +240,25 @@ void get_host_proxy_os(void)
     pclose(output);
 }
 
-void get_host_interface_all_os(void)
+int get_host_interface_all_os(void)
 {
     if (access(PATH_IFCONFIG, F_OK) != -1) {
         system("/sbin/ifconfig -a");
+        return 0;
     } else {
         fprintf(stderr, "ifconfig does not exist!\n");
+        return 1;
     }
 }
 
-void get_host_bridge_os(void)
+int get_host_bridge_os(void)
 {
     if (access(PATH_IFCONFIG, F_OK) != -1) {
         system("/sbin/ifconfig bridge1");
+        return 0;
     } else {
         fprintf(stderr, "ifconfig does not exist!\n");
+        return 1;
     }
 }
 
index cc64c73..0570ae3 100644 (file)
@@ -262,7 +262,7 @@ static print_interface(PIP_ADAPTER_INFO pAdapter, PIP_ADAPTER_ADDRESSES pAddress
     fprintf(stdout, "\n");
 }
 
-static void get_host_interface(int value)
+static int get_host_interface(int value)
 {
     PIP_ADAPTER_ADDRESSES pAddresses = NULL;
     PIP_ADAPTER_ADDRESSES pCurrAddresses = NULL;
@@ -283,7 +283,7 @@ static void get_host_interface(int value)
         pAddresses = (IP_ADAPTER_ADDRESSES *) MALLOC(outBufLen);
         if (pAddresses == NULL) {
             fprintf(stderr, "Memory allocation failed for IP_ADAPTER_ADDRESSES struct\n");
-            return;
+            return 1;
         }
 
         dwRetAddressVal = GetAdaptersAddresses(AF_INET, flags, NULL, pAddresses, &outBufLen);
@@ -304,14 +304,14 @@ static void get_host_interface(int value)
     pAdapterInfo = (IP_ADAPTER_INFO *) MALLOC(sizeof (IP_ADAPTER_INFO));
     if (pAdapterInfo == NULL) {
         fprintf(stderr, "Error allocating memory needed to call GetAdaptersinfo\n");
-        return;
+        return 1;
     }
     if (GetAdaptersInfo(pAdapterInfo, &ulOutBufLen) == ERROR_BUFFER_OVERFLOW) {
         FREE(pAdapterInfo);
         pAdapterInfo = (IP_ADAPTER_INFO *) MALLOC(ulOutBufLen);
         if (pAdapterInfo == NULL) {
             fprintf(stderr, "Error allocating memory needed to call GetAdaptersinfo\n");
-            return;
+            return 1;
         }
     }
     dwRetVal = GetAdaptersInfo(pAdapterInfo, &ulOutBufLen);
@@ -334,20 +334,21 @@ static void get_host_interface(int value)
         }
     } else {
         fprintf(stderr, "GetAdaptersInfo failed with error: %d\n", dwRetVal);
-        return;
+        return 1;
     }
     if (pAdapterInfo)
         FREE(pAdapterInfo);
+    return 0;
 }
 
-void get_host_interface_all_os(void)
+int get_host_interface_all_os(void)
 {
-    get_host_interface(ALL_INTERFACE);
+    return get_host_interface(ALL_INTERFACE);
 }
 
-void get_host_bridge_os(void)
+int get_host_bridge_os(void)
 {
-    get_host_interface(BRIDGE_ONLY);
+    return get_host_interface(BRIDGE_ONLY);
 }
 
 void get_host_ip_os(void)