USE_STL=1\r
\r
SOURCES=\\r
- wv_main.cpp\r
+ wv_main.cpp \\r
+ getopt.cpp\r
\r
INCLUDES=..\..\..\inc;..\..\..\inc\user;\r
\r
TARGETLIBS= \\r
$(SDK_LIB_PATH)\kernel32.lib \\r
$(SDK_LIB_PATH)\advapi32.lib \\r
- $(SDK_LIB_PATH)\user32.lib \\r
- $(SDK_LIB_PATH)\ole32.lib \\r
+ $(SDK_LIB_PATH)\user32.lib \\r
+ $(SDK_LIB_PATH)\ole32.lib \\r
!if $(FREEBUILD)\r
$(TARGETPATH)\*\winverbs.lib\r
!else\r
--- /dev/null
+/*\r
+ * Copyright (c) 2008 Intel Corporation. All rights reserved.\r
+ *\r
+ * This software is available to you under the OpenIB.org BSD license\r
+ * below:\r
+ *\r
+ * Redistribution and use in source and binary forms, with or\r
+ * without modification, are permitted provided that the following\r
+ * conditions are met:\r
+ *\r
+ * - Redistributions of source code must retain the above\r
+ * copyright notice, this list of conditions and the following\r
+ * disclaimer.\r
+ *\r
+ * - Redistributions in binary form must reproduce the above\r
+ * copyright notice, this list of conditions and the following\r
+ * disclaimer in the documentation and/or other materials\r
+ * provided with the distribution.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AWV\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ */\r
+\r
+#include <string.h>\r
+#include "getopt.h"\r
+\r
+char *optarg;\r
+\r
+int getopt(int argc, char **argv, char *opts)\r
+{\r
+ static int index = 1;\r
+ char *opt;\r
+\r
+ if (index >= argc)\r
+ return -1;\r
+\r
+ optarg = NULL;\r
+ if (argv[index][0] != '-' || strlen(argv[index]) != 2)\r
+ goto err;\r
+\r
+ opt = strchr(opts, argv[index][1]);\r
+ if (!opt)\r
+ goto err;\r
+\r
+ if (opt[1] == ':')\r
+ {\r
+ if (++index >= argc)\r
+ goto err;\r
+ optarg = argv[index];\r
+ }\r
+\r
+ index++;\r
+ return *opt;\r
+\r
+err:\r
+ index++;\r
+ return '?';\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2008 Intel Corporation. All rights reserved.\r
+ *\r
+ * This software is available to you under the OpenIB.org BSD license\r
+ * below:\r
+ *\r
+ * Redistribution and use in source and binary forms, with or\r
+ * without modification, are permitted provided that the following\r
+ * conditions are met:\r
+ *\r
+ * - Redistributions of source code must retain the above\r
+ * copyright notice, this list of conditions and the following\r
+ * disclaimer.\r
+ *\r
+ * - Redistributions in binary form must reproduce the above\r
+ * copyright notice, this list of conditions and the following\r
+ * disclaimer in the documentation and/or other materials\r
+ * provided with the distribution.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AWV\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ */\r
+\r
+#pragma once\r
+\r
+#ifndef _GETOPT_H_\r
+#define _GETOPT_H_\r
+\r
+extern char *optarg;\r
+int getopt(int argc, char **argv, char *opts);\r
+\r
+#endif // _GETOPT_H_\r
#include <iostream>\r
using namespace std;\r
\r
+#include "getopt.h"\r
#include <rdma\winverbs.h>\r
\r
static void ShowProviderOptions()\r
{\r
+ cout << "usage: winverb provider [options]" << endl;\r
cout << "provider options" << endl;\r
- cout << "\t" << "--help" << endl;\r
- cout << "\t\t" << "display this message" << endl;\r
+ cout << "\t" << "-?" << "\t" << "display this message" << endl;\r
}\r
\r
static int ProviderTest(int argc, char *argv[])\r
IWVProvider *prov;\r
HRESULT hr;\r
ULONG ref;\r
+ int op;\r
\r
- if (argc > 2)\r
- {\r
+ if ((op = getopt(argc, argv, "?")) != -1)
+ {
ShowProviderOptions();\r
- return 0;\r
+ return -1;\r
}\r
\r
cout << "Validating IWVProvider interface" << endl;\r
\r
static void ShowUsage()\r
{\r
- cout << "winverb <interface> [options]" << endl;\r
+ cout << "usage: winverb <interface> [options]" << endl;\r
cout << "<interface> is one of the following:" << endl;\r
cout << "\t" << "provider" << endl;\r
cout << endl;\r
- cout << "Type 'winverb <interface> --help' for option details" << endl;\r
+ cout << "Type 'winverb <interface> -?' for option details" << endl;\r
}\r
\r
int __cdecl main(int argc, char *argv[])\r
\r
if (!strcmp("provider", argv[1]))\r
{\r
- return ProviderTest(argc, argv);\r
+ return ProviderTest(argc - 1, &argv[1]);\r
}\r
else\r
{\r