main.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with this
  4. * work for additional information regarding copyright ownership. The ASF
  5. * licenses this file to you under the Apache License, Version 2.0 (the
  6. * "License"); you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  13. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  14. * License for the specific language governing permissions and limitations under
  15. * the License.
  16. */
  17. #include "winutils.h"
  18. static void Usage(LPCWSTR program);
  19. int wmain(__in int argc, __in_ecount(argc) wchar_t* argv[])
  20. {
  21. LPCWSTR cmd = NULL;
  22. if (argc < 2)
  23. {
  24. Usage(argv[0]);
  25. return EXIT_FAILURE;
  26. }
  27. cmd = argv[1];
  28. if (wcscmp(L"ls", cmd) == 0)
  29. {
  30. return Ls(argc - 1, argv + 1);
  31. }
  32. else if (wcscmp(L"chmod", cmd) == 0)
  33. {
  34. return Chmod(argc - 1, argv + 1);
  35. }
  36. else if (wcscmp(L"chown", cmd) == 0)
  37. {
  38. return Chown(argc - 1, argv + 1);
  39. }
  40. else if (wcscmp(L"groups", cmd) == 0)
  41. {
  42. return Groups(argc - 1, argv + 1);
  43. }
  44. else if (wcscmp(L"hardlink", cmd) == 0)
  45. {
  46. return Hardlink(argc - 1, argv + 1);
  47. }
  48. else if (wcscmp(L"symlink", cmd) == 0)
  49. {
  50. return Symlink(argc - 1, argv + 1);
  51. }
  52. else if (wcscmp(L"readlink", cmd) == 0)
  53. {
  54. return Readlink(argc - 1, argv + 1);
  55. }
  56. else if (wcscmp(L"task", cmd) == 0)
  57. {
  58. return Task(argc - 1, argv + 1);
  59. }
  60. else if (wcscmp(L"systeminfo", cmd) == 0)
  61. {
  62. return SystemInfo();
  63. }
  64. else if (wcscmp(L"help", cmd) == 0)
  65. {
  66. Usage(argv[0]);
  67. return EXIT_SUCCESS;
  68. }
  69. else
  70. {
  71. Usage(argv[0]);
  72. return EXIT_FAILURE;
  73. }
  74. }
  75. static void Usage(LPCWSTR program)
  76. {
  77. fwprintf(stdout, L"Usage: %s [command] ...\n\
  78. Provide basic command line utilities for Hadoop on Windows.\n\n\
  79. The available commands and their usages are:\n\n", program);
  80. fwprintf(stdout, L"%-15s%s\n\n", L"chmod", L"Change file mode bits.");
  81. ChmodUsage(L"chmod");
  82. fwprintf(stdout, L"\n\n");
  83. fwprintf(stdout, L"%-15s%s\n\n", L"chown", L"Change file owner.");
  84. ChownUsage(L"chown");
  85. fwprintf(stdout, L"\n\n");
  86. fwprintf(stdout, L"%-15s%s\n\n", L"groups", L"List user groups.");
  87. GroupsUsage(L"groups");
  88. fwprintf(stdout, L"\n\n");
  89. fwprintf(stdout, L"%-15s%s\n\n", L"hardlink", L"Hard link operations.");
  90. HardlinkUsage();
  91. fwprintf(stdout, L"\n\n");
  92. fwprintf(stdout, L"%-15s%s\n\n", L"ls", L"List file information.");
  93. LsUsage(L"ls");
  94. fwprintf(stdout, L"\n\n");
  95. fwprintf(stdout, L"%-10s%s\n\n", L"symlink", L"Create a symbolic link.");
  96. SymlinkUsage();
  97. fwprintf(stdout, L"\n\n");
  98. fwprintf(stdout, L"%-10s%s\n\n", L"readlink", L"Print the target of a symbolic link.");
  99. ReadlinkUsage();
  100. fwprintf(stdout, L"\n\n");
  101. fwprintf(stdout, L"%-15s%s\n\n", L"systeminfo", L"System information.");
  102. SystemInfoUsage();
  103. fwprintf(stdout, L"\n\n");
  104. fwprintf(stdout, L"%-15s%s\n\n", L"task", L"Task operations.");
  105. TaskUsage();
  106. fwprintf(stdout, L"\n\n");
  107. }