System.h.in 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /*============================================================================
  2. KWSys - Kitware System Library
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #ifndef @KWSYS_NAMESPACE@_System_h
  11. #define @KWSYS_NAMESPACE@_System_h
  12. #include <@KWSYS_NAMESPACE@/Configure.h>
  13. /* Redefine all public interface symbol names to be in the proper
  14. namespace. These macros are used internally to kwsys only, and are
  15. not visible to user code. Use kwsysHeaderDump.pl to reproduce
  16. these macros after making changes to the interface. */
  17. #if !defined(KWSYS_NAMESPACE)
  18. # define kwsys_ns(x) @KWSYS_NAMESPACE@##x
  19. # define kwsysEXPORT @KWSYS_NAMESPACE@_EXPORT
  20. #endif
  21. #if !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
  22. # define kwsysSystem_Parse_CommandForUnix kwsys_ns(System_Parse_CommandForUnix)
  23. # define kwsysSystem_Shell_GetArgumentForWindows kwsys_ns(System_Shell_GetArgumentForWindows)
  24. # define kwsysSystem_Shell_GetArgumentForUnix kwsys_ns(System_Shell_GetArgumentForUnix)
  25. # define kwsysSystem_Shell_GetArgumentSizeForWindows kwsys_ns(System_Shell_GetArgumentSizeForWindows)
  26. # define kwsysSystem_Shell_GetArgumentSizeForUnix kwsys_ns(System_Shell_GetArgumentSizeForUnix)
  27. # define kwsysSystem_Shell_Flag_e kwsys_ns(System_Shell_Flag_e)
  28. # define kwsysSystem_Shell_Flag_Make kwsys_ns(System_Shell_Flag_Make)
  29. # define kwsysSystem_Shell_Flag_VSIDE kwsys_ns(System_Shell_Flag_VSIDE)
  30. # define kwsysSystem_Shell_Flag_EchoWindows kwsys_ns(System_Shell_Flag_EchoWindows)
  31. # define kwsysSystem_Shell_Flag_WatcomWMake kwsys_ns(System_Shell_Flag_WatcomWMake)
  32. # define kwsysSystem_Shell_Flag_MinGWMake kwsys_ns(System_Shell_Flag_MinGWMake)
  33. # define kwsysSystem_Shell_Flag_NMake kwsys_ns(System_Shell_Flag_NMake)
  34. # define kwsysSystem_Shell_Flag_AllowMakeVariables kwsys_ns(System_Shell_Flag_AllowMakeVariables)
  35. #endif
  36. #ifdef __VMS
  37. #define @KWSYS_NAMESPACE@System_Shell_GetArgumentForUnix \
  38. @KWSYS_NAMESPACE@System_Shell_UnixGA
  39. #define @KWSYS_NAMESPACE@System_Shell_GetArgumentSizeForUnix \
  40. @KWSYS_NAMESPACE@System_Shell_UnixGAS
  41. #define @KWSYS_NAMESPACE@System_Shell_GetArgumentForWindows \
  42. @KWSYS_NAMESPACE@System_Shell_WindowsGA
  43. #endif
  44. #if defined(__cplusplus)
  45. extern "C"
  46. {
  47. #endif
  48. /**
  49. * Transform the given command line argument for use in a Windows or
  50. * Unix shell. Returns a pointer to the end of the command line
  51. * argument in the provided output buffer. Flags may be passed to
  52. * modify the generated quoting and escape sequences to work under
  53. * alternative environments.
  54. */
  55. kwsysEXPORT char* kwsysSystem_Shell_GetArgumentForWindows(const char* in,
  56. char* out,
  57. int flags);
  58. kwsysEXPORT char* kwsysSystem_Shell_GetArgumentForUnix(const char* in,
  59. char* out,
  60. int flags);
  61. /**
  62. * Compute the size of the buffer required to store the output from
  63. * kwsysSystem_Shell_GetArgumentForWindows or
  64. * kwsysSystem_Shell_GetArgumentForUnix. The flags passed must be
  65. * identical between the two calls.
  66. */
  67. kwsysEXPORT int kwsysSystem_Shell_GetArgumentSizeForWindows(const char* in,
  68. int flags);
  69. kwsysEXPORT int kwsysSystem_Shell_GetArgumentSizeForUnix(const char* in,
  70. int flags);
  71. /**
  72. * Flags to pass to kwsysSystem_Shell_GetArgumentForWindows or
  73. * kwsysSystem_Shell_GetArgumentForUnix. These modify the generated
  74. * quoting and escape sequences to work under alternative
  75. * environments.
  76. */
  77. enum kwsysSystem_Shell_Flag_e
  78. {
  79. /** The target shell is in a makefile. */
  80. kwsysSystem_Shell_Flag_Make = (1<<0),
  81. /** The target shell is in a VS project file. Do not use with
  82. Shell_Flag_Make. */
  83. kwsysSystem_Shell_Flag_VSIDE = (1<<1),
  84. /** In a windows shell the argument is being passed to "echo". */
  85. kwsysSystem_Shell_Flag_EchoWindows = (1<<2),
  86. /** The target shell is in a Watcom WMake makefile. */
  87. kwsysSystem_Shell_Flag_WatcomWMake = (1<<3),
  88. /** The target shell is in a MinGW Make makefile. */
  89. kwsysSystem_Shell_Flag_MinGWMake = (1<<4),
  90. /** The target shell is in a NMake makefile. */
  91. kwsysSystem_Shell_Flag_NMake = (1<<6),
  92. /** Make variable reference syntax $(MAKEVAR) should not be escaped
  93. to allow a build tool to replace it. Replacement values
  94. containing spaces, quotes, backslashes, or other
  95. non-alphanumeric characters that have significance to some makes
  96. or shells produce undefined behavior. */
  97. kwsysSystem_Shell_Flag_AllowMakeVariables = (1<<5)
  98. };
  99. /**
  100. * Parse a unix-style command line string into separate arguments.
  101. *
  102. * On success, returns a pointer to an array of pointers to individual
  103. * argument strings. Each string is null-terminated and the last
  104. * entry in the array is a NULL pointer (just like argv). It is the
  105. * caller's responsibility to free() the strings and the array of
  106. * pointers to them.
  107. *
  108. * On failure, returns NULL. Failure occurs only on invalid flags or
  109. * when memory cannot be allocated; never due to content of the input
  110. * string. Missing close-quotes are treated as if the necessary
  111. * closing quote appears.
  112. *
  113. * By default single- and double-quoted arguments are supported, and
  114. * any character may be escaped by a backslash. The flags argument is
  115. * reserved for future use, and must be zero (or the call will fail).
  116. */
  117. kwsysEXPORT char** kwsysSystem_Parse_CommandForUnix(const char* command,
  118. int flags);
  119. #if defined(__cplusplus)
  120. } /* extern "C" */
  121. #endif
  122. /* If we are building a kwsys .c or .cxx file, let it use these macros.
  123. Otherwise, undefine them to keep the namespace clean. */
  124. #if !defined(KWSYS_NAMESPACE)
  125. # undef kwsys_ns
  126. # undef kwsysEXPORT
  127. # if !defined(KWSYS_NAMESPACE) && !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
  128. # undef kwsysSystem_Parse_CommandForUnix
  129. # undef kwsysSystem_Shell_GetArgumentForWindows
  130. # undef kwsysSystem_Shell_GetArgumentForUnix
  131. # undef kwsysSystem_Shell_GetArgumentSizeForWindows
  132. # undef kwsysSystem_Shell_GetArgumentSizeForUnix
  133. # undef kwsysSystem_Shell_Flag_e
  134. # undef kwsysSystem_Shell_Flag_Make
  135. # undef kwsysSystem_Shell_Flag_VSIDE
  136. # undef kwsysSystem_Shell_Flag_EchoWindows
  137. # undef kwsysSystem_Shell_Flag_WatcomWMake
  138. # undef kwsysSystem_Shell_Flag_MinGWMake
  139. # undef kwsysSystem_Shell_Flag_NMake
  140. # undef kwsysSystem_Shell_Flag_AllowMakeVariables
  141. # endif
  142. #endif
  143. #endif