home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 9 Archive / 09-Archive.zip / unzip531.zip / apihelp.c < prev    next >
C/C++ Source or Header  |  1997-02-23  |  5KB  |  145 lines

  1. /* apihelp.c */
  2.  
  3. #ifdef API_DOC
  4.  
  5. #define UNZIP_INTERNAL
  6. #include "unzip.h"
  7. #include "version.h"
  8.  
  9.  
  10. APIDocStruct APIDoc[] = {
  11.     {
  12.         "UZPVERSION"  , "UzpVersion"  ,
  13.         "UzpVer *UzpVersion(void);",
  14.         "Get version numbers of the API and the underlying UnZip code.\n\n"
  15.         "\t\tThis is used for comparing the version numbers of the run-time\n"
  16.         "\t\tDLL code with those expected from the unzip.h at compile time.\n"
  17.         "\t\tIf the version numbers don't match, there may be compatibility\n"
  18.         "\t\tproblems with further use of the DLL.\n\n"
  19.         "  Example:\t/* Check the major version number of the DLL code. */\n"
  20.         "\t\tUzpVer *pVersion;\n"
  21.         "\t\tpVersion = UzpVersion();\n"
  22.         "\t\tif (pVersion->unzip.major != UZ_MAJORVER)\n"
  23.         "\t\t  fprintf(stderr, \"error: using wrong version of DLL\\n\");\n\n"
  24.         "\t\tSee unzip.h for details and unzipstb.c for an example.\n"
  25.     },
  26.   
  27.     {
  28.         "UZPMAIN"  , "UzpMain"  ,
  29.         "int UzpMain(int argc, char *argv[]);",
  30.         "Provide a direct entry point to the command line interface.\n\n"
  31.         "\t\tThis is used by the UnZip stub but you can use it in your\n"
  32.         "\t\town program as well.  Output is sent to stdout.\n"
  33.         "\t\t0 on return indicates success.\n\n"
  34.         "  Example:\t/* Extract 'test.zip' silently, junking paths. */\n"
  35.         "\t\tchar *argv[] = { \"-q\", \"-j\", \"test.zip\" };\n"
  36.         "\t\tint argc = 3;\n"
  37.         "\t\tif (UzpMain(argc,argv))\n"
  38.         "\t\t  printf(\"error: unzip failed\\n\");\n\n"
  39.         "\t\tSee unzip.h for details.\n"
  40.     },
  41.   
  42.     {
  43.         "UZPALTMAIN"  , "UzpAltMain"  ,
  44.         "int UzpAltMain(int argc, char *argv[], UzpInit *init);",
  45.         "Provide a direct entry point to the command line interface,\n"
  46.         "optionally installing replacement I/O handler functions.\n\n"
  47.         "\t\tAs with UzpMain(), output is sent to stdout by default.\n"
  48.         "\t\t`InputFn *inputfn' is not yet implemented.  0 on return\n"
  49.         "\t\tindicates success.\n\n"
  50.         "  Example:\t/* Replace normal output and `more' functions. */\n"
  51.         "\t\tchar *argv[] = { \"-q\", \"-j\", \"test.zip\" };\n"
  52.         "\t\tint argc = 3;\n"
  53.         "\t\tUzpInit init = { 16, MyMessageFn, NULL, MyPauseFn };\n"
  54.         "\t\tif (UzpAltMain(argc,argv,&init))\n"
  55.         "\t\t  printf(\"error: unzip failed\\n\");\n\n"
  56.         "\t\tSee unzip.h for details.\n"
  57.     },
  58.   
  59.     {
  60.         "UZPUNZIPTOMEMORY", "UzpUnzipToMemory",
  61.         "int UzpUnzipToMemory(char *zip, char *file, UzpBuffer *retstr);",
  62.         "Pass the name of the zip file and the name of the file\n"
  63.         "\t\tyou wish to extract.  UzpUnzipToMemory will create a\n"
  64.         "\t\tbuffer and return it in *retstr;  0 on return indicates\n"
  65.         "\t\tfailure.\n\n"
  66.         "\t\tSee unzip.h for details.\n"
  67.     },
  68.   
  69.     {
  70.         "UZPFILETREE", "UzpFileTree",
  71.         "int UzpFileTree(char *name, cbList(callBack),\n"
  72.         "\t\t\tchar *cpInclude[], char *cpExclude[]);",
  73.         "Pass the name of the zip file, a callback function, an\n"
  74.         "\t\tinclude and exclude file list. UzpUnzipToMemory calls\n"
  75.         "\t\tthe callback for each valid file found in the zip file.\n"
  76.         "\t\t0 on return indicates failure.\n\n"
  77.         "\t\tSee unzip.h for details.\n"
  78.     },
  79.   
  80.     { 0 }
  81. };
  82.  
  83.  
  84.  
  85. int function_help(__G__ doc, fname)
  86.     __GDEF
  87.     APIDocStruct *doc;
  88.     char *fname;
  89. {
  90.     strcpy(slide, fname);
  91.     strupr(slide);
  92.     while (doc->compare && strcmp(doc->compare,slide))
  93.         doc++;
  94.     if (!doc->compare)
  95.         return 0;
  96.     else
  97.         Info(slide, 0, ((char *)slide,
  98.           "  Function:\t%s\n\n  Syntax:\t%s\n\n  Purpose:\t%s",
  99.           doc->function, doc->syntax, doc->purpose));
  100.  
  101.     return 1;
  102. }  
  103.  
  104.  
  105.  
  106. void APIhelp(__G__ argc, argv)
  107.     __GDEF
  108.     int argc;
  109.     char **argv;
  110. {
  111.     if (argc > 1) {
  112.         struct APIDocStruct *doc;
  113.  
  114.         if (function_help(__G__ APIDoc, argv[1]))
  115.             return;
  116. #ifdef SYSTEM_API_DETAILS
  117.         if (function_help(__G__ SYSTEM_API_DETAILS, argv[1]))
  118.             return;
  119. #endif
  120.         Info(slide, 0, ((char *)slide,
  121.           "%s is not a documented command.\n\n", argv[1]));
  122.     }
  123.  
  124.     Info(slide, 0, ((char *)slide, "\
  125. This API provides a number of external C and REXX functions for handling\n\
  126. zipfiles in OS/2.  Programmers are encouraged to expand this API.\n\
  127. \n\
  128. C functions: -- See unzip.h for details\n\
  129.   UzpVer *UzpVersion(void);\n\
  130.   int UzpMain(int argc, char *argv[]);\n\
  131.   int UzpAltMain(int argc, char *argv[], UzpInit *init);\n\
  132.   int UzpUnzipToMemory(char *zip, char *file, UzpBuffer *retstr);\n\
  133.   int UzpFileTree(char *name, cbList(callBack),\n\
  134.                   char *cpInclude[], char *cpExclude[]);\n\n"));
  135.  
  136. #ifdef SYSTEM_API_BRIEF
  137.     Info(slide, 0, ((char *)slide, SYSTEM_API_BRIEF));
  138. #endif
  139.  
  140.     Info(slide, 0, ((char *)slide,
  141.       "\nFor more information, type 'unzip -A <function-name>'\n"));
  142. }
  143.  
  144. #endif /* API_DOC */
  145.