home *** CD-ROM | disk | FTP | other *** search
/ C Programming Starter Kit 2.0 / SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso / bc45 / filter.pak / TOOLAPI.H < prev    next >
C/C++ Source or Header  |  1997-07-23  |  10KB  |  261 lines

  1. /*
  2.    ToolAPI.H           copyright (c) Borland International 1993
  3.  
  4.       Borland IDE external tool API definitions
  5.  
  6. */
  7.  
  8. #if !defined( _TOOLAPI_H )
  9. #define _TOOLAPI_H
  10.  
  11. #if !defined( _TRANTYPE_H )
  12. #include "TranType.h"
  13. #endif // _TRANTYPE_H
  14.  
  15. // All of the functions exported from the IDE are C callable
  16. // to allow the use of both C and C++ for tool development
  17. #if defined( __cplusplus )
  18. extern "C" {
  19. #endif // __cplusplus
  20.  
  21. /*
  22.   This first section of the ToolAPI header file show prototypes for functions
  23.   which reside in the IDE.  These functions are passed to the tool DLL as a
  24.   parameter to the Run function in the form of an array of void (*func)(void)
  25.   pointers. Detailed below are macros which correspond to the prototypes which
  26.   allow the tool DLL to use the functions from the pointer array directly as
  27.   they are defined.
  28. */
  29.  
  30. /************************************************/
  31. /* function which must be defined by transfer DLL */
  32. /************************************************/
  33. int far pascal Run( pTransferBlock TransBlock );
  34.  
  35. #if 0
  36. /***********************************/
  37. /* functions exported by Borland IDE */
  38. /***********************************/
  39. /*** IDE versioning functions ***/
  40. //  IDE_Version() fills the tVersion structure with necessary information
  41. //  for the DLL to determine if it is compatible with the caller.
  42. void IDE_Version( tVersion *version );
  43.  
  44. //  IDE_Exec() attempts to launch the program identified by Path.  If
  45. //  searchpath is set, the IDE will look in the current working directory
  46. //  and then look along the path for the program.
  47. //  Returns: exit code of executed program or -1 on failure
  48. int IDE_Exec( const char *Path, BOOL searchpath );
  49.  
  50. /*** File I/O oriented functions ***/
  51. // File I/O maps as closely as possible to standard RTL IO.H functions
  52. FileHandle IDE_Open  ( LPSTR file, mode_t Mode );
  53. FileHandle IDE_SOpen ( LPSTR file, mode_t Mode, share_t Share );
  54. FileHandle IDE_Create( LPSTR file );
  55. WORD       IDE_Read  ( FileHandle fh, LPSTR buffer, WORD len );
  56. WORD       IDE_Write ( FileHandle fh, LPSTR buffer, WORD len );
  57. WORD32     IDE_Seek  ( FileHandle fh, WORD32 offset, WORD whence );
  58. void       IDE_Close ( FileHandle fh );
  59.  
  60. void       IDE_Delete( LPSTR file );
  61.  
  62.  
  63. /*** Memory management oriented functions ***/
  64. // The memory management functions parallel windows functions as closely
  65. // as possible.  A tool DLL can allocate memory via the native environment
  66. // if that is preferred.
  67. HMEM   IDE_memalloc  ( memflags_t memflags, WORD32 size );
  68. LPSTR  IDE_memlock   ( HMEM hMemory );
  69. void   IDE_memunlock ( HMEM hMemory );
  70. HMEM   IDE_memhandle ( LPSTR location );
  71. void   IDE_memfree   ( HMEM hMemory );
  72. WORD32 IDE_memsize   ( HMEM hMemory );
  73. HMEM   IDE_memrealloc( HMEM hMemory, WORD32 size, memflags_t memflags );
  74. memflags_t IDE_memflags ( HMEM hMemory );
  75. WORD32 IDE_freespace( void );
  76.  
  77. /*** Message system oriented functions ***/
  78. // IDE_NewMessageGroup() checks for a group of messages tagged with the
  79. // group name provided.  If it exists, it is cleared if the clear==TRUE.
  80. // The current message group is set to the MsgGroupID for that tag and
  81. // the message group ID is returned to caller.
  82. MsgGroupID IDE_NewMessageGroup( LPSTR GroupName, BOOL clear );
  83.  
  84. // IDE_SetMessageGroup() sets the current message group to MsgGrpID.
  85. // if clear==TRUE, the group is cleared
  86. void       IDE_SetMessageGroup( MsgGroupID MsgGrpID, BOOL clear );
  87.  
  88. // IDE_PostMessage() posts a new message to the MsgGroupID indicated
  89. void       IDE_PostMessage    ( MsgGroupID MsgGrpID, lpMsg Msg );
  90.  
  91. // IDE_ClearMessages() clears all messages in all message groups
  92. void       IDE_ClearMessages  ( void );
  93.  
  94.  
  95. /*** Message Box posting functions ***/
  96. // IDE_ErrorBox() is used to put a message box onto the screen for purposes
  97. // of notifying the user that something has happened.  The box has a singe OK
  98. // button.  The IDE box has an exclamation point and a single ok button
  99. void IDE_ErrorBox( const char *message );
  100.  
  101. #endif
  102.  
  103. /*
  104.   The remaining section of this header file details macros which allow calling
  105.   of functions in the IDE's ToolAPI function pointer array without having to
  106.   typecast or concider array locations or parameters.  The macros cause the
  107.   entries in the IDE_ToolAPI array of void (*func)(void) function pointers to
  108.   be accessed as the corresponding prototypes listed above detail.
  109. */
  110.  
  111. extern _pascal IDE_ToolAPIFunc IDE_ToolAPI[];
  112.  
  113.  
  114. // enumeration for the tool api array of functions
  115. typedef enum
  116. {
  117.   // Version functions
  118.   IDEVersion,
  119.  
  120.   // Task functions
  121.   IDEMonitor,
  122.   IDEExec,
  123.   IDEGetTaskID,
  124.  
  125.   // File I/O functions
  126.   IDEOpen,
  127.   IDESOpen,
  128.   IDECreate,
  129.   IDERead,
  130.   IDEWrite,
  131.   IDEClose,
  132.   IDESeek,
  133.   IDEDelete,
  134.   IDECapture,
  135.  
  136.   // Memory management functions
  137.   IDEMemAlloc,
  138.   IDEMemLock,
  139.   IDEMemUnlock,
  140.   IDEMemHandle,
  141.   IDEMemFree,
  142.   IDEMemSize,
  143.   IDEMemRealloc,
  144.   IDEMemFlags,
  145.   IDEFreeSpace,
  146.  
  147.   // Message system functions
  148.   IDENewMessageGroup,
  149.   IDESetMessageGroup,
  150.   IDEPostMessage,
  151.   IDEClearMessages,
  152.  
  153.   // Error Box functions
  154.   IDEErrorBox,
  155.  
  156.   // End of list, indicate size of array
  157.   IDE_NumFunctions,
  158. } ToolApi;
  159.  
  160. // typedef pointer for the run function exported from the tool DLL
  161. typedef  int far pascal (*runFuncPtr)( pTransferBlock );
  162.  
  163. // Typedefs allow convertion from void (*func)( void ) function pointers
  164. // to functions of the correct type
  165. typedef void far pascal      (*versionptr)   ( tVersion * );
  166.  
  167. typedef monitor_t far pascal (*monitorptr)( TaskID );
  168. typedef TaskID far pascal    (*taskptr)      ( const char *, BOOL );
  169.  
  170. typedef FileHandle far pascal (*openptr)    ( LPSTR, mode_t );
  171. typedef FileHandle far pascal (*sopenptr)   ( LPSTR, mode_t, share_t );
  172. typedef FileHandle far pascal (*creatptr)   ( LPSTR );
  173. typedef WORD       far pascal (*rdwrptr)    ( FileHandle , LPSTR, WORD );
  174. typedef void       far pascal (*closeptr)   ( FileHandle );
  175. typedef WORD32     far pascal (*seekptr)    ( FileHandle, WORD32, WORD );
  176. typedef void       far pascal (*deleteptr)  ( LPSTR );
  177. typedef int        far pascal (*captureptr) ( const char *, LPSTR, LPSTR );
  178.  
  179.  
  180. typedef WORD32 far pascal (*memsizeptr)   ( HMEM );
  181. typedef HMEM   far pascal (*memallocptr)  ( memflags_t, WORD32 );
  182. typedef HMEM   far pascal (*memreallocptr)( HMEM, WORD32, memflags_t );
  183. typedef void   far pascal (*memunlockptr) ( HMEM );
  184. typedef LPSTR  far pascal (*memlockptr)   ( HMEM );
  185. typedef HMEM   far pascal (*memhandleptr) ( LPSTR );
  186. typedef memflags_t far pascal (*memflagsptr) ( HMEM );
  187. typedef WORD32 far pascal (*memfreeptr)( void );
  188.  
  189. typedef MsgGroupID far pascal (*newgroupptr) ( LPSTR, BOOL );
  190. typedef void       far pascal (*setmsgptr)   ( MsgGroupID, BOOL );
  191. typedef void       far pascal (*postmsgptr)  ( MsgGroupID, lpMsg );
  192. typedef void       far pascal (*clearmsgptr) ( void );
  193.  
  194. typedef void       far pascal (*errboxptr)   ( const char * );
  195.  
  196. /*
  197.   For the following, the single letters translate as:
  198.      V   pointer to version structure   ( tVersion * )
  199.      T   TaskID
  200.      S   Search? (boolean)
  201.      CR  Create (boolean)
  202.      FN  FileName
  203.      FH  FileHandle
  204.      M   File open Mode
  205.      SH  Share flags
  206.      H   Handle to memory
  207.      SZ  Size of block (unsigned LONG)
  208.      F   Memory Flags (Type memflags_t )
  209.      L   Lenght  (unsigned LONG)
  210.      B   Buffer (LPSTR)
  211.      CB  const string (const char *)
  212.      P   Path  (LPSTR)
  213.      C   Clear (boolean)
  214.      G   Message Group (MsgGroupID)
  215.      M   pointer to a Message structure ( lpMsg )
  216. */
  217.  
  218. // IDE version
  219. #define IDE_Version( V )       ((versionptr)(*IDE_ToolAPI[IDEVersion]))( V )
  220.  
  221. // Task functions
  222. #define IDE_Monitor( T )       ((monitorptr)(*IDE_ToolAPI[IDEMonitor]))( T )
  223. #define IDE_Exec( P, S )       ((taskptr)(*IDE_ToolAPI[IDEExec]))( P, S )
  224. #define IDE_GetTaskID( P, CR ) ((taskptr)(*IDE_ToolAPI[IDEExec]))( P, CR )
  225.  
  226. // File I/O functions
  227. #define IDE_Open( FN, M )      ((openptr)(*IDE_ToolAPI[IDEOpen]))( FN, M )
  228. #define IDE_SOpen( FN, M, SH ) ((sopenptr)(*IDE_ToolAPI[IDESOpen]))( FN, M, SH )
  229. #define IDE_Create( FN )       ((creatptr)(*IDE_ToolAPI[IDECreate]))( FN )
  230. #define IDE_Read( FH, B, L )   ((rdwrptr)(*IDE_ToolAPI[IDERead]))( FH, B, L )
  231. #define IDE_Write( FH, B, L )  ((rdwrptr)(*IDE_ToolAPI[IDEWrite]))( FH, B, L )
  232. #define IDE_Close( FH )        ((closeptr)(*IDE_ToolAPI[IDEClose]))( FH )
  233. #define IDE_Delete( FN )       ((deleteptr)(*IDE_ToolAPI[IDEDelete]))( FN )
  234. #define IDE_Seek( FH, O, Wh )  ((seekptr)(*IDE_ToolAPI[IDESeek]))( FH, O, Wh )
  235. #define IDE_CaptureToPipe( P, CT, PF ) ((captureptr)(*IDE_ToolAPI[IDECapture]))( P, CT, PF )
  236.  
  237. // Memory management functions
  238. #define IDE_memalloc( F, SZ )     ((memallocptr)(*IDE_ToolAPI[IDEMemAlloc]))( F, SZ )
  239. #define IDE_memlock( H )          ((memlockptr)(*IDE_ToolAPI[IDEMemLock]))( H )
  240. #define IDE_memunlock( H )        ((memunlockptr)(*IDE_ToolAPI[IDEMemUnlock]))( H )
  241. #define IDE_memhandle( B )        ((memhandleptr)(*IDE_ToolAPI[IDEMemHandle]))( B )
  242. #define IDE_memfree( H )          ((memunlockptr)(*IDE_ToolAPI[IDEMemFree]))( H )
  243. #define IDE_memsize( H )          ((memsizeptr)(*IDE_ToolAPI[IDEMemSize]))( H )
  244. #define IDE_memrealloc( H, SZ, F )((memreallocptr)(*IDE_ToolAPI[IDEMemRealloc]))( H, SZ, F )
  245. #define IDE_memflags ( H )        ((memflagsptr)(*IDE_ToolAPI[IDEMemFlags]))( H )
  246. #define IDE_freespace             (*IDE_ToolAPI[IDEFreeSpace])
  247.  
  248. // message system functions
  249. #define IDE_NewMessageGroup( B, C ) ((newgroupptr)(*IDE_ToolAPI[IDENewMessageGroup]))( B, C )
  250. #define IDE_SetMessageGroup( G, C ) ((setmsgptr)(*IDE_ToolAPI[IDESetMessageGroup]))( G, C )
  251. #define IDE_PostMessage( G, M )     ((postmsgptr)(*IDE_ToolAPI[IDEPostMessage]))( G, M )
  252. #define IDE_ClearMessages           (*IDE_ToolAPI[IDEClearMessages])
  253.  
  254. #define IDE_ErrorBox( CB )           ((errboxptr)(*IDE_ToolAPI[IDEErrorBox]))( CB )
  255.  
  256. #if defined( __cplusplus )
  257. }   // matches extern "C" { 
  258. #endif  // __cplusplus
  259.  
  260. #endif // _TOOLAPI_H
  261.