[TOOLS] repair ndinstall (installsp.c) return a proper exit code; removed unused...
authorstansmith <stansmith@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Wed, 15 Jul 2009 19:54:00 +0000 (19:54 +0000)
committerstansmith <stansmith@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Wed, 15 Jul 2009 19:54:00 +0000 (19:54 +0000)
git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@2298 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

tools/ndinstall/user/installsp.c

index d8b37c8..315fe6e 100644 (file)
@@ -98,9 +98,10 @@ static void
 show_usage (char *progname)\r
 {\r
        printf("usage: %s\n", progname);\r
 show_usage (char *progname)\r
 {\r
        printf("usage: %s\n", progname);\r
-       printf("\tRemove, install, and list OFA Network Direct providers\n\n");\r
+       printf("\tRemove, install, and list OFA NetworkDirect providers\n\n");\r
        printf("\t[-[i|r] provider_name]  Install/remove the specified provider\n");\r
        printf("\t[-d]                    Install/remove debug version of provider\n");\r
        printf("\t[-[i|r] provider_name]  Install/remove the specified provider\n");\r
        printf("\t[-d]                    Install/remove debug version of provider\n");\r
+       printf("\t[-l]                    list OFA ND providers\n");\r
        printf("\tprovider_name must be one of the following:\n");\r
        printf("\t\tibal\n");\r
        printf("\t\twinverbs\n");\r
        printf("\tprovider_name must be one of the following:\n");\r
        printf("\t\tibal\n");\r
        printf("\t\twinverbs\n");\r
@@ -163,13 +164,10 @@ static void print_providers(void)
  * Windows Sockets Direct Components".\r
  * The direct link is http://msdn.microsoft.com/library/default.asp?url=/library/en-us/network/hh/network/wsdp_2xrb.asp\r
  */\r
  * Windows Sockets Direct Components".\r
  * The direct link is http://msdn.microsoft.com/library/default.asp?url=/library/en-us/network/hh/network/wsdp_2xrb.asp\r
  */\r
-static void install_provider(void)\r
+static int install_provider(void)\r
 {\r
 {\r
-       int rc;\r
-       INT err_no;\r
-       LONG reg_error;\r
+       int rc, err_no;\r
        WSAPROTOCOL_INFOW provider;\r
        WSAPROTOCOL_INFOW provider;\r
-       HKEY hkey;\r
 \r
        /* Setup the values in PROTOCOL_INFO */\r
        provider.dwServiceFlags1 = \r
 \r
        /* Setup the values in PROTOCOL_INFO */\r
        provider.dwServiceFlags1 = \r
@@ -211,29 +209,31 @@ static void install_provider(void)
                        printf("already installed\n");\r
                else\r
                        printf("WSCInstallProvider failed: %d\n", err_no);\r
                        printf("already installed\n");\r
                else\r
                        printf("WSCInstallProvider failed: %d\n", err_no);\r
+                       rc = err_no;\r
        } else {\r
                printf("successful\n");\r
        } else {\r
                printf("successful\n");\r
+               rc = 0;\r
        }\r
        }\r
+       return rc;\r
 }\r
 \r
 /*\r
  * Function: remove_provider\r
  *   Description: removes our provider.\r
  */\r
 }\r
 \r
 /*\r
  * Function: remove_provider\r
  *   Description: removes our provider.\r
  */\r
-static void remove_provider(void)\r
+static int remove_provider(void)\r
 {\r
 {\r
-       int rc;\r
-       int err_no;\r
-       LONG reg_error;\r
-       HKEY hkey;\r
+       int rc=0, err_no, rc1;\r
 \r
        /* Remove from the catalog */\r
        printf("\nRemoving %s provider: ", provider_name[index]);\r
 \r
        /* Remove from the catalog */\r
        printf("\nRemoving %s provider: ", provider_name[index]);\r
-       rc = WSCDeinstallProvider(&provider_guid[index], &err_no);\r
-       if (rc == SOCKET_ERROR) {\r
+       rc1 = WSCDeinstallProvider(&provider_guid[index], &err_no);\r
+       if (rc1 == SOCKET_ERROR) {\r
                printf ("WSCDeinstallProvider failed: %d\n", err_no);\r
                printf ("WSCDeinstallProvider failed: %d\n", err_no);\r
+               rc1 = err_no;\r
        } else {\r
                printf ("successful\n");\r
        } else {\r
                printf ("successful\n");\r
+               rc1 = 0;\r
        }\r
 \r
 #ifdef _WIN64\r
        }\r
 \r
 #ifdef _WIN64\r
@@ -242,10 +242,15 @@ static void remove_provider(void)
        rc = WSCDeinstallProvider32(&provider_guid[index], &err_no);\r
        if (rc == SOCKET_ERROR) {\r
                printf ("WSCDeinstallProvider32 failed: %d\n", err_no);\r
        rc = WSCDeinstallProvider32(&provider_guid[index], &err_no);\r
        if (rc == SOCKET_ERROR) {\r
                printf ("WSCDeinstallProvider32 failed: %d\n", err_no);\r
+               rc = err_no;\r
        } else {\r
                printf ("successful\n");\r
        } else {\r
                printf ("successful\n");\r
+               rc = 0;\r
        }\r
 #endif /* _WIN64 */\r
        }\r
 #endif /* _WIN64 */\r
+       if ( rc || rc1 )\r
+               return (rc ? rc : rc1);\r
+       return 0;\r
 }\r
 \r
 static int get_prov_index(char *name)\r
 }\r
 \r
 static int get_prov_index(char *name)\r
@@ -263,12 +268,12 @@ static int get_prov_index(char *name)
 \r
 int __cdecl main (int argc, char *argv[])\r
 {\r
 \r
 int __cdecl main (int argc, char *argv[])\r
 {\r
-       int ret, op;\r
+       int ret=0, op;\r
        int install = 0, remove = 0, debug = 0;\r
        WSADATA wsd;\r
        char *prov;\r
 \r
        int install = 0, remove = 0, debug = 0;\r
        WSADATA wsd;\r
        char *prov;\r
 \r
-       while ((op = getopt(argc, argv, "i:r:d")) != -1) {\r
+       while ((op = getopt(argc, argv, "i:r:dl")) != -1) {\r
                switch (op) {\r
                case 'i':\r
                        if (install || remove || get_prov_index(optarg)) {\r
                switch (op) {\r
                case 'i':\r
                        if (install || remove || get_prov_index(optarg)) {\r
@@ -285,6 +290,8 @@ int __cdecl main (int argc, char *argv[])
                case 'd':\r
                        debug = 1;\r
                        break;\r
                case 'd':\r
                        debug = 1;\r
                        break;\r
+               case 'l':\r
+                       break;\r
                default:\r
                        goto usage;\r
                }\r
                default:\r
                        goto usage;\r
                }\r
@@ -305,19 +312,9 @@ int __cdecl main (int argc, char *argv[])
        }\r
 \r
        if (install) {\r
        }\r
 \r
        if (install) {\r
-               install_provider();\r
-#ifdef PERFMON_ENABLED\r
-               _IBSPPerfmonIniFilesGenerate();\r
-               if ( _IBSPPerfmonRegisterKeys() == ERROR_SUCCESS )\r
-                               _IBSPPerfmonRegisterCounters();\r
-#endif\r
+               ret = install_provider();\r
        } else if (remove) {\r
        } else if (remove) {\r
-               remove_provider();\r
-#ifdef PERFMON_ENABLED\r
-               _IBSPPerfmonIniFilesRemove();\r
-               if ( _IBSPPerfmonDeregisterCounters() == ERROR_SUCCESS )\r
-                       _IBSPPerfmonDeregisterKeys();\r
-#endif\r
+               ret = remove_provider();\r
        }\r
 \r
        print_providers();\r
        }\r
 \r
        print_providers();\r