You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

188 lines
4.8 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: test/scratch/test.scratch.pseudoUNIX/test.scratch.pseudoUNIX.c
  3. *
  4. * Purpose: Implementation file for the pseudoUNIX.test project.
  5. *
  6. * Created: 23rd September 2006
  7. * Updated: 6th August 2012
  8. *
  9. * Status: Wizard-generated
  10. *
  11. * License: (Licensed under the Synesis Software Open License)
  12. *
  13. * Copyright (c) 2006-2012, Synesis Software Pty Ltd.
  14. * All rights reserved.
  15. *
  16. * www: http://www.synesis.com.au/software
  17. *
  18. * ////////////////////////////////////////////////////////////////////// */
  19. /* Pantheios Header Files */
  20. #include <pantheios/pantheios.h>
  21. #include <pantheios/implicit_link/core.h>
  22. #include <pantheios/implicit_link/fe.simple.h>
  23. #if defined(unix) || \
  24. defined(__unix) || \
  25. defined(__unix__)
  26. # include <pantheios/implicit_link/be.fprintf.h>
  27. #elif defined(_WIN32) || \
  28. defined(WIN32)
  29. # include <pantheios/implicit_link/be.WindowsConsole.h>
  30. #endif /* operating system */
  31. /* STLSoft Header Files */
  32. #include <stlsoft/stlsoft.h>
  33. /* PlatformSTL Header Files */
  34. #include <platformstl/platformstl.h>
  35. /* UNIXEm Header Files */
  36. #include <unixem/unixem.h>
  37. #include <unixem/implicit_link.h>
  38. /* Standard C Header Files */
  39. #include <stdio.h>
  40. #include <stdlib.h>
  41. /* /////////////////////////////////////////////////////////////////////////
  42. * Macros and definitions
  43. */
  44. #ifdef true
  45. # undef true
  46. #endif /* true */
  47. #ifdef false
  48. # undef false
  49. #endif /* false */
  50. #define true (1)
  51. #define false (0)
  52. /* /////////////////////////////////////////////////////////////////////////
  53. * Globals
  54. */
  55. #if defined(_DEBUG) || \
  56. defined(_SYB_DEBUG)
  57. static int s_bDebugging = true;
  58. #else /* ? debug */
  59. static int s_bDebugging = false;
  60. #endif /* debug */
  61. PANTHEIOS_EXTERN_C PAN_CHAR_T const PANTHEIOS_FE_PROCESS_IDENTITY[] = PANTHEIOS_LITERAL_STRING("pseudoUNIX.test");
  62. /* /////////////////////////////////////////////////////////////////////////
  63. * Typedefs
  64. */
  65. /* /////////////////////////////////////////////////////////////////////////
  66. * Forward declarations
  67. */
  68. static void usage(int bExit, char const *reason, int invalidArg, int argc, char **argv);
  69. /* ////////////////////////////////////////////////////////////////////// */
  70. int main(int argc, char *argv[])
  71. {
  72. int bVerbose = 1;
  73. if(pantheios_init() < 0)
  74. {
  75. return EXIT_FAILURE;
  76. }
  77. else
  78. {
  79. pantheios_init();
  80. pantheios_init();
  81. pantheios_uninit();
  82. pantheios_init();
  83. pantheios_uninit();
  84. pantheios_getNextBackEndId();
  85. { int i; for(i = 1; i < argc; ++i)
  86. {
  87. char const *const arg = argv[i];
  88. if(arg[0] == '-')
  89. {
  90. if(arg[1] == '-')
  91. {
  92. /* -- arguments */
  93. usage(1, "Invalid argument(s) specified", i, argc, argv);
  94. }
  95. else
  96. {
  97. /* - arguments */
  98. switch(arg[1])
  99. {
  100. case '?':
  101. usage(1, NULL, -1, argc, argv);
  102. break;
  103. case 's':
  104. bVerbose = 0;
  105. break;
  106. case 'v':
  107. bVerbose = 1;
  108. break;
  109. default:
  110. usage(1, "Invalid argument(s) specified", i, argc, argv);
  111. break;
  112. }
  113. }
  114. }
  115. else
  116. {
  117. /* other arguments */
  118. usage(1, "Invalid argument(s) specified", i, argc, argv);
  119. }
  120. }}
  121. pantheios_uninit();
  122. pantheios_uninit();
  123. return EXIT_SUCCESS;
  124. }
  125. }
  126. /* ////////////////////////////////////////////////////////////////////// */
  127. static void usage(int bExit, char const *reason, int invalidArg, int argc, char **argv)
  128. {
  129. FILE *stm = (NULL == reason) ? stdout : stderr;
  130. fprintf(stm, "\n");
  131. fprintf(stm, " pseudoUNIX.test\n\n");
  132. fprintf(stm, "\n");
  133. if(NULL != reason)
  134. {
  135. fprintf(stm, " Error: %s\n", reason);
  136. fprintf(stm, "\n");
  137. }
  138. if(0 < invalidArg)
  139. {
  140. fprintf(stm, " First invalid argument #%d: %s\n", invalidArg, argv[invalidArg]);
  141. fprintf(stm, " Arguments were (first bad marked *):\n\n");
  142. { int i; for(i = 1; i < argc; ++i)
  143. {
  144. fprintf(stm, " %s%s\n", (i == invalidArg) ? "* " : " ", argv[i]);
  145. }}
  146. fprintf(stm, "\n");
  147. }
  148. if(bExit)
  149. {
  150. exit(EXIT_FAILURE);
  151. }
  152. }
  153. /* ///////////////////////////// end of file //////////////////////////// */