Archive-Unzip-Burst

 view release on metacpan or  search on metacpan

unzip-6.0/windll/uzexampl.c  view on Meta::CPAN

if ( (lpUzVersInfo->unzip.major < UZDLL_MINVERS_MAJOR) ||
     ((lpUzVersInfo->unzip.major == UZDLL_MINVERS_MAJOR) &&
      ((lpUzVersInfo->unzip.minor < UZDLL_MINVERS_MINOR) ||
       ((lpUzVersInfo->unzip.minor == UZDLL_MINVERS_MINOR) &&
        (lpUzVersInfo->unzip.patchlevel < UZDLL_MINVERS_PATCHLEVEL)
       )
      )
     ) )
{
  char str[256];
  wsprintf(str, "The version %u.%u%u of the loaded UnZip DLL is too old!",
           lpUzVersInfo->unzip.major, lpUzVersInfo->unzip.minor,
           lpUzVersInfo->unzip.patchlevel);
  printf("%s\n", str);
  FreeLibrary(hUnzipDll);
  FreeUpMemory();
  return -1;
}

if (lpUzVersInfo->structlen >=
    (offsetof(UzpVer, dllapimin) + sizeof(_version_type)))
{
  if ( (lpUzVersInfo->dllapimin.major > UZ_WINAPI_COMP_MAJOR) ||
       ((lpUzVersInfo->dllapimin.major == UZ_WINAPI_COMP_MAJOR) &&
        ((lpUzVersInfo->dllapimin.minor > UZ_WINAPI_COMP_MINOR) ||
         ((lpUzVersInfo->dllapimin.minor == UZ_WINAPI_COMP_MINOR) &&
          (lpUzVersInfo->dllapimin.patchlevel > UZ_WINAPI_COMP_REVIS)
         )
        )
       ) )
  {
    char str[256];
    wsprintf(str, "Found incompatible WinDLL API version %u.%u%u, aborting!",
             lpUzVersInfo->dllapimin.major, lpUzVersInfo->dllapimin.minor,
             lpUzVersInfo->dllapimin.patchlevel);
    printf("%s\n", str);
    FreeLibrary(hUnzipDll);
    FreeUpMemory();
    return -1;
  }
}

/*
   Here is where the actual extraction process begins. First we set up the
   flags to be passed into the dll.
 */
lpDCL->StructVersID = UZ_DCL_STRUCTVER; /* version of this structure */
lpDCL->ncflag = 0;              /* write to stdout if true */
lpDCL->fQuiet = 0;              /* we want all messages
                                   1 = fewer messages,
                                   2 = no messages */
lpDCL->ntflag = 0;              /* test zip file if true */
lpDCL->nvflag = 0;              /* give a verbose listing if true */
lpDCL->nzflag = 0;              /* display zip file comment if true */
lpDCL->ndflag = 1;              /* recreate directories != 0,
                                   skip "../" if < 2 */
lpDCL->naflag = 0;              /* do not convert CR to CRLF */
lpDCL->nfflag = 0;              /* do not freshen existing files only */
lpDCL->noflag = 1;              /* over-write all files if true */
lpDCL->nZIflag = 0;             /* no ZipInfo output mode */
lpDCL->B_flag = 0;              /* do not backup existing files */
lpDCL->C_flag = 0;              /* do not match case-insensitive */
lpDCL->D_flag = 0;              /* restore all timestamps */
lpDCL->U_flag = 0;              /* do not disable UTF-8 support */
lpDCL->ExtractOnlyNewer = 0;    /* do not extract only newer */
lpDCL->SpaceToUnderscore = 0;   /* do not convert space to '_' in filenames */
lpDCL->PromptToOverwrite = 0;   /* "overwrite all" selected -> no query mode */
lpDCL->lpszZipFN = argv[1];     /* the archive name */
lpDCL->lpszExtractDir = NULL;   /* the directory to extract to.
                                   This is set to NULL if you are extracting
                                   to the current directory.
                                 */
/*
   As this is a quite short example, intended primarily to show how to
   load and call in to the dll, the command-line parameters are only
   parsed in a very simplistic way:
   We assume that the command-line parameters after the zip archive
   make up a list of file patterns:
   " [file_i1] [file_i2] ... [file_iN] [-x file_x1 [file_x2] ...]".
   We scan for an argument "-x"; all arguments in front are
   "include file patterns", all arguments after are "exclude file patterns".
   If no more arguments are given, we extract ALL files.

   In summary, the example program should be run like:
   example <archive.name> [files to include] [-x files to exclude]
   ("<...> denotes mandatory arguments, "[...]" optional arguments)
 */
x_opt = NULL;
if (argc > 2) {
  infv = &argv[2];
  for (infc = 0; infc < argc-2; infc++)
    if (!strcmp("-x", infv[infc])) {
        x_opt = infv[infc];
        infv[infc] = NULL;
        break;
    }
  exfc = argc - infc - 3;
  if (exfc > 0)
    exfv = &argv[infc+3];
  else {
    exfc = 0;
    exfv = NULL;
  }
} else {
  infc = exfc = 0;
  infv = exfv = NULL;
}
retcode = (*pWiz_SingleEntryUnzip)(infc, infv, exfc, exfv, lpDCL,
                                   lpUserFunctions);
if (x_opt) {
  infv[infc] = x_opt;
  x_opt = NULL;
}

if (retcode != 0)
   printf("Error unzipping (error/warning code %d)...\n", retcode);

FreeLibrary(hUnzipDll);
FreeUpMemory();
return retcode;
}



( run in 1.946 second using v1.01-cache-2.11-cpan-a9496e3eb41 )