Source code of Windows XP (NT5)
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.

110 lines
3.7 KiB

  1. /*++
  2. CLIENT.H
  3. header file for OPT_FUNC2 or better functions.
  4. This file exposes the freelist API used internally by the program. This
  5. assures the caller that CleanupDataEx will obliterate any memory used by
  6. the option system.
  7. It is important that client code not corrupt the internal freelist, or
  8. unpredictable results may occur.
  9. Created, 9/6/1997 by DavidCHR
  10. Copyright (C) 1997 Microsoft Corporation, all rights reserved.
  11. --*/
  12. /* When a FUNC2 function is called, it will be passed a SaveQueue.
  13. This queue is guaranteed not to be null by the calling function (unless
  14. the HELP parameter is TRUE) and should be considered opaque.
  15. The only means of accessing the queue are with OptionAlloc and
  16. CleanupOptionDataEx. */
  17. BOOL
  18. OptionAlloc( IN PVOID pSaveQueue, /* if NULL, no list is used, and you
  19. must call OptionDealloc to free the
  20. memory */
  21. OUT PVOID *ppTarget,
  22. IN ULONG size );
  23. VOID
  24. OptionDealloc( IN PVOID pTarget );
  25. /* note that ppResizedMemory must have been allocated with OptionAlloc--
  26. e.g.:
  27. OptionAlloc( pSave, &pTarget, sizeof( "foo" ) );
  28. OptionResizeMemory( pSave, &pTarget, sizeof( "fooooooo" ) );
  29. */
  30. BOOL
  31. OptionResizeMemory( IN PVOID pSaveQueue, // same as in OptionAlloc
  32. OUT PVOID *ppResizedMemory, // same as in OptionAlloc
  33. IN ULONG newSize ); // same as in OptionAlloc
  34. /* PrintUsageEntry:
  35. formats a single line of text and sends it out.
  36. This is where all the output goes, so we can be assured that it all ends
  37. up formatted the same. It uses the following globals so that clients
  38. can adjust the values if needed. The defaults are in comments */
  39. extern ULONG OptMaxHeaderLength /* 5 */;
  40. extern ULONG OptMaxCommandLength /* 13 */;
  41. extern ULONG OptMaxSeparatorLength /* 3 */;
  42. extern ULONG OptMaxDescriptionLength /* 58 */;
  43. VOID
  44. PrintUsageEntry( FILE *output, // output file stream (must be stderr)
  45. PCHAR Header, // usually SlashVector, BoolVector or NULL
  46. PCHAR Command, // command name or NULL
  47. PCHAR aSeparator, // between command and description
  48. PCHAR Description, // description string
  49. BOOL fRepeatSeparator );
  50. /* PrintUsage should be used to print the usage data for an option vector.
  51. Useful if your function takes suboptions. */
  52. VOID
  53. PrintUsage( FILE *output, // output file stream (must be stderr)
  54. ULONG flags, // option flags (as ParseOptionsEx)
  55. optionStruct *options, // option vector,
  56. PCHAR prefix ); // prefix (optional; currently ignored)
  57. #define OPT_FUNC_PARAMETER_VERSION 1
  58. typedef struct {
  59. IN ULONG optionVersion; // will be set to OPT_FUNC_PARAMETER_VERSION.
  60. IN PVOID dataFieldPointer; // points to the variable in the optStruct
  61. IN INT argc; // argc following the option calling the func
  62. IN PCHAR *argv; /* argv (argv[0] is the command invoked)
  63. NOTE: this pointer will ALWAYS exist, even
  64. if the Help Flag is set. HOWEVER, it is
  65. the only option that's guaranteed to be
  66. there. */
  67. IN ULONG optionFlags; // as ParseOptionsEx
  68. IN PVOID pSaveQueue; // input memorylist.
  69. OUT INT argsused; // set this to the number of args you used.
  70. /* parameters may be added to the end, depending on the optionVersion.
  71. an option function should only be concerned if the optionVersion is
  72. LESS than the optionVersion it knows about. If greater, no big deal. */
  73. } OPT_FUNC_PARAMETER_DATA, *POPT_FUNC_PARAMETER_DATA;
  74. // this is the function expected by OPT_FUNC2
  75. typedef BOOL (OPTFUNC2)( IN BOOL, // if TRUE, just print help.
  76. IN POPT_FUNC_PARAMETER_DATA );