Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

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