cmCPluginAPI.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. /*=========================================================================
  2. Program: Insight Segmentation & Registration Toolkit
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Insight Consortium. All rights reserved.
  8. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. /* This header file defines the API that loadable commands can use. In many
  14. of these commands C++ instances of cmMakefile of cmSourceFile are passed
  15. in as arguments or returned. In these cases they are passed as a void *
  16. argument. In the function prototypes mf is used to represent a makefile
  17. and sf is used to represent a source file. The functions are grouped
  18. loosely into four groups 1) Utility 2) cmMakefile 3) cmSourceFile 4)
  19. cmSystemTools. Within each grouping functions are listed alphabetically */
  20. /*=========================================================================*/
  21. /*=========================================================================*/
  22. /* CM_PLUGIN_EXPORT should be used by plugins */
  23. /*=========================================================================*/
  24. #ifdef _WIN32
  25. #define CM_PLUGIN_EXPORT __declspec( dllexport )
  26. #else
  27. #define CM_PLUGIN_EXPORT
  28. #endif
  29. /*=========================================================================*/
  30. /* define the different types of cache entries, see cmCacheManager.h for more
  31. information */
  32. /*=========================================================================*/#define CM_CACHE_BOOL 0
  33. #define CM_CACHE_PATH 1
  34. #define CM_CACHE_FILEPATH 2
  35. #define CM_CACHE_STRING 3
  36. #define CM_CACHE_INTERNAL 4
  37. #define CM_CACHE_STATIC 5
  38. /*=========================================================================*/
  39. /* define the different types of compiles a library may be */
  40. /*=========================================================================*/
  41. #define CM_LIBRARY_GENERAL 0
  42. #define CM_LIBRARY_DEBUG 1
  43. #define CM_LIBRARY_OPTIMIZED 2
  44. #ifdef __cplusplus
  45. extern "C" {
  46. #endif
  47. /*=========================================================================*/
  48. /* first we define the key data structures and function prototypes */
  49. /*=========================================================================*/
  50. typedef const char* (*CM_DOC_FUNCTION)();
  51. typedef const char* (*CM_NAME_FUNCTION)();
  52. typedef int (*CM_INITIAL_PASS_FUNCTION)(void *info, void *mf,
  53. int argc, char *[]);
  54. typedef void (*CM_FINAL_PASS_FUNCTION)(void *info, void *mf);
  55. typedef struct {
  56. int m_Inherited;
  57. CM_INITIAL_PASS_FUNCTION InitialPass;
  58. CM_FINAL_PASS_FUNCTION FinalPass;
  59. CM_DOC_FUNCTION GetTerseDocumentation;
  60. CM_DOC_FUNCTION GetFullDocumentation;
  61. void *ClientData;
  62. } cmLoadedCommandInfo;
  63. typedef void (*CM_INIT_FUNCTION)(cmLoadedCommandInfo *);
  64. /*=========================================================================*/
  65. /* Finally we define the set of functions that a plugin may call. The first
  66. goup of functions are utility functions that are specific to the plugin
  67. API */
  68. /*=========================================================================*/
  69. /* set/Get the ClientData in the cmLoadedCommandInfo structure, this is how
  70. information is passed from the InitialPass to FInalPass for commands
  71. that need a FinalPass and need information from the InitialPass */
  72. extern void *cmGetClientData(void *info);
  73. /* return the summed size in characters of all the arguments */
  74. extern int cmGetTotalArgumentSize(int argc, char **argv);
  75. /* free all the memory associated with an argc, argv pair */
  76. extern void cmFreeArguments(int argc, char **argv);
  77. /* set/Get the ClientData in the cmLoadedCommandInfo structure, this is how
  78. information is passed from the InitialPass to FInalPass for commands
  79. that need a FinalPass and need information from the InitialPass */
  80. extern void cmSetClientData(void *info, void *cd);
  81. /*=========================================================================*/
  82. /* The following functions all directly map to methods in the cmMakefile
  83. class. See cmMakefile.h for descriptions of what each method does. All
  84. of these methods take the void * makefile pointer as their first
  85. argument. */
  86. /*=========================================================================*/
  87. extern void cmAddCacheDefinition(void *mf, const char* name,
  88. const char* value,
  89. const char* doc,
  90. int cachetype);
  91. extern void cmAddCustomCommand(void *mf, const char* source,
  92. const char* command,
  93. int numArgs,
  94. const char **args,
  95. int numDepends,
  96. const char **depends,
  97. int numOutputs,
  98. const char **outputs,
  99. const char *target);
  100. extern void cmAddDefineFlag(void *mf, const char* definition);
  101. extern void cmAddDefinition(void *mf, const char* name,
  102. const char* value);
  103. extern void cmAddExecutable(void *mf, const char *exename,
  104. int numSrcs, const char **srcs,
  105. int win32);
  106. extern void cmAddLibrary(void *mf, const char *libname,
  107. int shared, int numSrcs,
  108. const char **srcs);
  109. extern void cmAddLinkDirectoryForTarget(void *mf,
  110. const char *tgt,
  111. const char* d);
  112. extern void cmAddLinkLibraryForTarget(void *mf,
  113. const char *tgt,
  114. const char *libname,
  115. int libtype);
  116. extern void cmAddUtilityCommand(void *mf, const char* utilityName,
  117. const char *command,
  118. const char *arguments,
  119. int all, int numDepends,
  120. const char **depends,
  121. int numOutputs,
  122. const char **outputs);
  123. extern int cmCommandExists(void *mf, const char* name);
  124. extern void cmExecuteCommand(void *mf, const char *name,
  125. int numArgs, const char **args);
  126. extern
  127. void cmExpandSourceListArguments(void *mf,int argc, const char **argv,
  128. int *resArgc, char ***resArgv,
  129. unsigned int startArgumentIndex);
  130. extern char *cmExpandVariablesInString(void *mf,
  131. const char *source,
  132. int escapeQuotes,
  133. int atOnly);
  134. extern unsigned int cmGetCacheMajorVersion(void *mf);
  135. extern unsigned int cmGetCacheMinorVersion(void *mf);
  136. extern const char* cmGetCurrentDirectory(void *mf);
  137. extern const char* cmGetCurrentOutputDirectory(void *mf);
  138. extern const char* cmGetDefinition(void *mf, const char *def);
  139. extern const char* cmGetHomeDirectory(void *mf);
  140. extern const char* cmGetHomeOutputDirectory(void *mf);
  141. extern unsigned int cmGetMajorVersion(void *mf);
  142. extern unsigned int cmGetMinorVersion(void *mf);
  143. extern const char* cmGetProjectName(void *mf);
  144. extern const char* cmGetStartDirectory(void *mf);
  145. extern const char* cmGetStartOutputDirectory(void *mf);
  146. extern int cmIsOn(void *mf, const char* name);
  147. /*=========================================================================*/
  148. /* The following functions are designed to operate or manipulate
  149. cmSourceFiles. Please see cmSourceFile.h for additional information on many
  150. of these methods. Some of these methods are in cmMakefile.h. */
  151. /*=========================================================================*/
  152. extern void *cmAddSource(void *mf, void *sf);
  153. extern void *cmCreateSourceFile();
  154. extern void *cmGetSource(void *mf, const char* sourceName);
  155. extern void cmSourceFileAddDepend(void *sf, const char *depend);
  156. extern const char *cmSourceFileGetProperty(void *sf,
  157. const char *prop);
  158. extern int cmSourceFileGetPropertyAsBool(void *sf,
  159. const char *prop);
  160. extern const char *cmSourceFileGetSourceName(void *sf);
  161. extern
  162. void cmSourceFileSetName(void *sf, const char* name, const char* dir,
  163. int numSourceExtensions,
  164. const char **sourceExtensions,
  165. int numHeaderExtensions,
  166. const char **headerExtensions);
  167. extern
  168. void cmSourceFileSetName2(void *sf, const char* name, const char* dir,
  169. const char *ext, int headerFileOnly);
  170. extern void cmSourceFileSetProperty(void *sf, const char *prop,
  171. const char *value);
  172. /*=========================================================================*/
  173. /* the following methods are from cmSystemTools.h see that file for
  174. specific documentaiton on each method. */
  175. /*=========================================================================*/
  176. extern char *cmCapitalized(const char *);
  177. extern void cmCopyFileIfDifferent(const char *f1, const char *f2);
  178. extern char *cmGetFilenameWithoutExtension(const char *);
  179. extern void cmRemoveFile(const char *f1);
  180. #ifdef __cplusplus
  181. }
  182. #endif