apihelp.c
Upload User: andy_li
Upload Date: 2007-01-06
Package Size: 1019k
Code Size: 5k
Development Platform:

MultiPlatform

  1. /* apihelp.c */
  2. #ifdef API_DOC
  3. #define UNZIP_INTERNAL
  4. #include "unzip.h"
  5. #include "version.h"
  6. APIDocStruct APIDoc[] = {
  7.     {
  8.         "UZPVERSION"  , "UzpVersion"  ,
  9.         "UzpVer *UzpVersion(void);",
  10.         "Get version numbers of the API and the underlying UnZip code.nn"
  11.         "ttThis is used for comparing the version numbers of the run-timen"
  12.         "ttDLL code with those expected from the unzip.h at compile time.n"
  13.         "ttIf the version numbers do not match, there may be compatibilityn"
  14.         "ttproblems with further use of the DLL.nn"
  15.         "  Example:t/* Check the major version number of the DLL code. */n"
  16.         "ttUzpVer *pVersion;n"
  17.         "ttpVersion = UzpVersion();n"
  18.         "ttif (pVersion->unzip.major != UZ_MAJORVER)n"
  19.         "tt  fprintf(stderr, "error: using wrong version of DLL\n");nn"
  20.         "ttSee unzip.h for details and unzipstb.c for an example.n"
  21.     },
  22.     {
  23.         "UZPMAIN"  , "UzpMain"  ,
  24.         "int UzpMain(int argc, char *argv[]);",
  25.         "Provide a direct entry point to the command line interface.nn"
  26.         "ttThis is used by the UnZip stub but you can use it in yourn"
  27.         "ttown program as well.  Output is sent to stdout.n"
  28.         "tt0 on return indicates success.nn"
  29.         "  Example:t/* Extract 'test.zip' silently, junking paths. */n"
  30.         "ttchar *argv[] = { "-q", "-j", "test.zip" };n"
  31.         "ttint argc = 3;n"
  32.         "ttif (UzpMain(argc,argv))n"
  33.         "tt  printf("error: unzip failed\n");nn"
  34.         "ttSee unzip.h for details.n"
  35.     },
  36.     {
  37.         "UZPALTMAIN"  , "UzpAltMain"  ,
  38.         "int UzpAltMain(int argc, char *argv[], UzpInit *init);",
  39.         "Provide a direct entry point to the command line interface,n"
  40.         "optionally installing replacement I/O handler functions.nn"
  41.         "ttAs with UzpMain(), output is sent to stdout by default.n"
  42.         "tt`InputFn *inputfn' is not yet implemented.  0 on returnn"
  43.         "ttindicates success.nn"
  44.         "  Example:t/* Replace normal output and `more' functions. */n"
  45.         "ttchar *argv[] = { "-q", "-j", "test.zip" };n"
  46.         "ttint argc = 3;n"
  47.         "ttUzpInit init = { 16, MyMessageFn, NULL, MyPauseFn };n"
  48.         "ttif (UzpAltMain(argc,argv,&init))n"
  49.         "tt  printf("error: unzip failed\n");nn"
  50.         "ttSee unzip.h for details.n"
  51.     },
  52.     {
  53.         "UZPUNZIPTOMEMORY", "UzpUnzipToMemory",
  54.         "int UzpUnzipToMemory(char *zip, char *file, UzpBuffer *retstr);",
  55.         "Pass the name of the zip file and the name of the filen"
  56.         "ttyou wish to extract.  UzpUnzipToMemory will create an"
  57.         "ttbuffer and return it in *retstr;  0 on return indicatesn"
  58.         "ttfailure.nn"
  59.         "ttSee unzip.h for details.n"
  60.     },
  61.     {
  62.         "UZPFILETREE", "UzpFileTree",
  63.         "int UzpFileTree(char *name, cbList(callBack),n"
  64.         "tttchar *cpInclude[], char *cpExclude[]);",
  65.         "Pass the name of the zip file, a callback function, ann"
  66.         "ttinclude and exclude file list. UzpFileTree calls then"
  67.         "ttcallback for each valid file found in the zip file.n"
  68.         "tt0 on return indicates failure.nn"
  69.         "ttSee unzip.h for details.n"
  70.     },
  71.     { 0 }
  72. };
  73. static int function_help OF((__GPRO__ APIDocStruct *doc, char *fname));
  74. static int function_help(__G__ doc, fname)
  75.     __GDEF
  76.     APIDocStruct *doc;
  77.     char *fname;
  78. {
  79.     strcpy(slide, fname);
  80.     /* strupr(slide);    non-standard */
  81.     while (doc->compare && STRNICMP(doc->compare,slide,strlen(fname)))
  82.         doc++;
  83.     if (!doc->compare)
  84.         return 0;
  85.     else
  86.         Info(slide, 0, ((char *)slide,
  87.           "  Function:t%snn  Syntax:t%snn  Purpose:t%s",
  88.           doc->function, doc->syntax, doc->purpose));
  89.     return 1;
  90. }
  91. void APIhelp(__G__ argc, argv)
  92.     __GDEF
  93.     int argc;
  94.     char **argv;
  95. {
  96.     if (argc > 1) {
  97.         struct APIDocStruct *doc;
  98.         if (function_help(__G__ APIDoc, argv[1]))
  99.             return;
  100. #ifdef SYSTEM_API_DETAILS
  101.         if (function_help(__G__ SYSTEM_API_DETAILS, argv[1]))
  102.             return;
  103. #endif
  104.         Info(slide, 0, ((char *)slide,
  105.           "%s is not a documented command.nn", argv[1]));
  106.     }
  107.     Info(slide, 0, ((char *)slide, "
  108. This API provides a number of external C and REXX functions for handlingn
  109. zipfiles in OS/2.  Programmers are encouraged to expand this API.n
  110. n
  111. C functions: -- See unzip.h for detailsn
  112.   UzpVer *UzpVersion(void);n
  113.   int UzpMain(int argc, char *argv[]);n
  114.   int UzpAltMain(int argc, char *argv[], UzpInit *init);n
  115.   int UzpUnzipToMemory(char *zip, char *file, UzpBuffer *retstr);n
  116.   int UzpFileTree(char *name, cbList(callBack),n
  117.                   char *cpInclude[], char *cpExclude[]);nn"));
  118. #ifdef SYSTEM_API_BRIEF
  119.     Info(slide, 0, ((char *)slide, SYSTEM_API_BRIEF));
  120. #endif
  121.     Info(slide, 0, ((char *)slide,
  122.       "nFor more information, type 'unzip -A <function-name>'n"));
  123. }
  124. #endif /* API_DOC */