home *** CD-ROM | disk | FTP | other *** search
/ PC Format (South-Africa) 2001 May / PCFMay2001.iso / Xenon / C++ / FreeCommandLineTools.exe / Include / wildargs.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-01-31  |  4.1 KB  |  100 lines

  1. /*  wildargs.h
  2.  
  3.     Support for overriding the built-in wild card handling routines
  4.     or the entire command line processing routines.
  5.  
  6. */
  7.  
  8. /*
  9.  *      C/C++ Run Time Library - Version 10.0
  10.  *
  11.  *      Copyright (c) 1999, 2000 by Inprise Corporation
  12.  *      All Rights Reserved.
  13.  *
  14.  */
  15.  
  16. /* $Revision:   9.3  $ */
  17.  
  18. #ifndef __WILDARGS_H
  19. #define __WILDARGS_H
  20.  
  21. #include <stddef.h>
  22.  
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26.  
  27. /* _PFN_ADDARG: Typedef for the addarg function pointer.  This pfn parameter
  28.    to the wild card processing routines will contain the function to call to
  29.    add an argument into the argv[] array. The second parameter: _makecopy is
  30.    a bool that specifies to the RTL whether or not this argument should have
  31.    new memory allocated for it and then be copied into.
  32. */
  33. typedef void _RTLENTRY (* _PFN_ADDARG)(void *_arg, int _makecopy);
  34.  
  35.  
  36. /* _argv_expand_ptr: Pointer to wildcard expansion function.  Normally it
  37.    points to a function that simply adds an argument without expansion. To
  38.    cause the built-in wild card expander to be used, simply point this to
  39.    the equivalent version of _expand_wild.  You can also point it to your
  40.    own function and it will be called for every wild card parameter the
  41.    start up code finds.  You can then expand it however you wish, calling
  42.    the passed-in pointer _pfn_addarg() to insert each of the expanded items.
  43. */
  44. extern void _RTLENTRY (* _RTLENTRY _argv_expand_ptr)(char *_arg, _PFN_ADDARG _pfn_addarg);
  45. extern void _RTLENTRY (* _RTLENTRY _wargv_expand_ptr)(wchar_t *_arg, _PFN_ADDARG _pfn_addarg);
  46.  
  47.  
  48. /* _expand_wild: Built-in handler for expanding wild cards.  This is the
  49.    internal function to which _argv_expand_ptr can be pointed in order to
  50.    have wild card arguments expanded.
  51. */
  52. void _RTLENTRY _EXPFUNC _expand_wild(char *_arg, _PFN_ADDARG _pfn_addarg);
  53. void _RTLENTRY _EXPFUNC _wexpand_wild(wchar_t *_arg, _PFN_ADDARG _pfn_addarg);
  54.  
  55.  
  56. /* _handle_setargv: Built-in handler for processing the entire command line.
  57.    This is the name of the function that handles the processing of the
  58.    entire command line. You can implement this function to get control of
  59.    the entire command line argument process. The exe name (for argv[0]) has
  60.    already been allocated and formatted for you and is passed in as _argv0.
  61.    You simply need to call _pfn_addarg(_argv0,0) on it to add it in.  The
  62.    RTL will manage and free the memory assocated with _argv0.  Next the
  63.    entire command line is passed in as _cmdline.  You should handle quotes
  64.    and wild cards however you wish. For each parameter that you isolate into
  65.    a separate string, you should call through the passed-in pointer
  66.    _pfn_addarg() to have it added to the argv[] list.  The second parameter
  67.    to _pfn_addarg() is a bool that specifies to the RTL whether or not this
  68.    argument should have new memory allocated for it and then be copied into.
  69.    Regardless of who allocates the memory for it (you or _pfn_addarg), you
  70.    will be responsible for freeing it.  This should be done from the
  71.    _handle_exitargv() routine.
  72.  
  73.    The return value should be zero for failure (which will cause NULL
  74.    parameters to be passed to main) or non-zero for success.
  75.  
  76.    For an example of this handler see the source for the RTL's default
  77.    version in: CBuilder/Source/rtl/source/process/hsargv.c
  78.  
  79.    NOTE: Only the RTL's internal version of this function will call out
  80.    through _argv_expand_ptr upon each wild card argument found.  If you
  81.    replace _handle_setargv then you'll have to do everything yourself.
  82. */
  83. int _RTLENTRY _handle_setargv(char *_argv0, char *_cmdline, _PFN_ADDARG _pfn_addarg);
  84. int _RTLENTRY _handle_wsetargv(wchar_t *_argv0, wchar_t *_cmdline, _PFN_ADDARG _pfn_addarg);
  85.  
  86.  
  87. /* _handle_exitargv: Built-in cleanup handler for the entire command line
  88.    processor.  Here is where all memory should be freed that you directly
  89.    (or indirectly via _pfn_addarg) caused to be allocated during the
  90.    _handle_setargv routine.
  91. */
  92. void _RTLENTRY _handle_exitargv(void);
  93. void _RTLENTRY _handle_wexitargv(void);
  94.  
  95.  
  96. #ifdef __cplusplus
  97. } // "C"
  98. #endif
  99.  
  100. #endif /* __WILDARGS_H */