Commit a0a84bf1 authored by David Anderson's avatar David Anderson

*** empty log message ***

svn path=/trunk/boinc/; revision=3366
parent 8618f342
......@@ -12160,3 +12160,9 @@ David May 10 2004
api/
windows_opengl.cpp
David May 11 2004
- replaced zip/unzip libraries with new code from Carl Christensen
zip/
*
......@@ -29,10 +29,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "upper_case", "upper_case.vc
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "boinc_zip", "boinc_zip.vcproj", "{384D8DF2-F221-4810-ACEC-58866E91C629}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
Debug = Debug
......@@ -63,10 +59,6 @@ Global
{48FB07D8-6E26-4BB1-98AB-22001C0FB0FF}.Debug.Build.0 = Debug|Win32
{48FB07D8-6E26-4BB1-98AB-22001C0FB0FF}.Release.ActiveCfg = Release|Win32
{48FB07D8-6E26-4BB1-98AB-22001C0FB0FF}.Release.Build.0 = Release|Win32
{384D8DF2-F221-4810-ACEC-58866E91C629}.Debug.ActiveCfg = Debug|Win32
{384D8DF2-F221-4810-ACEC-58866E91C629}.Debug.Build.0 = Debug|Win32
{384D8DF2-F221-4810-ACEC-58866E91C629}.Release.ActiveCfg = Release|Win32
{384D8DF2-F221-4810-ACEC-58866E91C629}.Release.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
......
This diff is collapsed.
## $Id$
## note: -D flags taken from a zip config build under Linux
AM_CPPFLAGS = \
-I./zip \
-I./unzip \
-I../lib \
-DUNIX
##noinst_PROGRAMS = test
noinst_LIBRARIES = libboinc_zip.a
libboinc_zip_a_SOURCES = boinc_zip.cpp \
./unzip/apihelp.c \
./unzip/crc32.c \
./unzip/crctab.c \
./unzip/envargs.c \
./unzip/explode.c \
./unzip/extract.c \
./unzip/fileio.c \
./unzip/globals.c \
./unzip/inflate.c \
./unzip/list.c \
./unzip/match.c \
./unzip/process.c \
./unzip/ttyio.c \
./unzip/unreduce.c \
./unzip/unshrink.c \
./unzip/unzip.c \
./unzip/zipinfo.c \
./zip/deflate.c \
./zip/mktime.c \
./zip/trees.c \
./zip/util.c \
./zip/z_fileio.c \
./zip/z_globals.c \
./zip/zip.c \
./zip/zipfile.c \
./zip/zipup.c \
./zip/unix/z_unix.c \
./unzip/unix/unix.c
##test_SOURCES = test.c
##test_LDADD = boinc_zip
##g++ -o test -DHAVE_DIRENT_H -I./ test.c ../lib/filesys.C ../lib/util.C -L./ -lboinc_zip
This diff is collapsed.
This diff is collapsed.
// this is the "wrapper" file for the zip/unzip functions to expose to BOINC clients
#pragma warning( disable : 4786 ) // Disable warning messages for vector
#ifdef __cplusplus
extern "C" {
#else
extern {
#endif
int unzip_main(int argc, char** argv);
int zip_main(int argc, char** argv);
}
#ifndef _WIN32 // only need for Linux & Mac
#include "config.h"
#endif
#include "./unzip/unzip.h"
#include "./zip/zip.h"
#include "boinc_zip.h"
#include "filesys.h" // from BOINC for DirScan
#include <algorithm>
// send in an output filename, advanced options (usually NULL), and numFileIn, szfileIn
#ifndef _MAX_PATH
#define _MAX_PATH 255
#endif
int boinc_zip(int bZipType, const std::string szFileZip, const std::string szFileIn)
{
ZipFileList tempvec;
tempvec.push_back(szFileIn);
return boinc_zip(bZipType, szFileZip, &tempvec);
}
int boinc_zip(int bZipType, const char* szFileZip, const char* szFileIn)
{ // just use the regular boinc_zip
std::string strFileZip, strFileIn;
strFileZip.assign(szFileZip);
strFileIn.assign(szFileIn);
ZipFileList tempvec;
tempvec.push_back(strFileIn);
return boinc_zip(bZipType, strFileZip, &tempvec);
}
int boinc_zip(int bZipType, const std::string szFileZip, const ZipFileList* pvectszFileIn)
{
int carg;
char** av;
int iRet = 0, i = 0, nVecSize = 0;
if (pvectszFileIn) nVecSize = pvectszFileIn->size();
// if unzipping but no file out, so it just uses cwd, only 3 args
//if (bZipType == UNZIP_IT)
// carg = 3 + nVecSize;
//else
carg = 3 + nVecSize;
// make a dynamic array
av = (char**) calloc(carg, sizeof(char*));
for (i=0;i<carg;i++)
av[i] = (char*) calloc(_MAX_PATH,sizeof(char));
// just form an argc/argv to spoof the "main"
// default options are to recurse into directories
//if (options && strlen(options))
// strcpy(av[1], options);
if (bZipType == ZIP_IT)
{
strcpy(av[0], "zip");
// default zip options -- no dir names, no subdirs, highest compression, quiet mode
if (strlen(av[1])==0)
strcpy(av[1], "-j9");
//strcpy(av[1], "-9jq");
strcpy(av[2], szFileZip.c_str());
//sz 3 onward will be each vector
int jj;
for (jj=0; jj<nVecSize; jj++)
strcpy(av[3+jj], pvectszFileIn->at(jj).c_str());
}
else
{
strcpy(av[0], "unzip");
// default unzip options -- preserve subdirs, overwrite
if (strlen(av[1])==0)
strcpy(av[1], "-o");
strcpy(av[2], szFileZip.c_str());
// if they passed in a directory unzip there
if (carg == 4)
sprintf(av[3], "-d%s", pvectszFileIn->at(0).c_str());
}
// strcpy(av[carg-1], ""); // null arg
// printf("args: %s %s %s %s\n", av[0], av[1], av[2], av[3]);
if (bZipType == ZIP_IT)
{
if (access(szFileZip.c_str(), 0) == 0)
{ // old zip file exists so unlink (otherwise zip will reuse, doesn't seem to be a flag to
// bypass zip reusing it
unlink(szFileZip.c_str());
}
iRet = zip_main(carg, av);
}
else {
// make sure zip file exists
if (access(szFileZip.c_str(), 0) == 0)
iRet = unzip_main(carg, av);
else
iRet = 2;
}
for (i=0;i<carg;i++)
free(av[i]);
free(av);
return iRet;
}
// -------------------------------------------------------------------
//
// Function: bool boinc_filelist(const std::string directory
// const std::string pattern,
// ZipFileList* pList)
//
// Description: Supply a directory and a pattern as arguments, along
// with a FileList variable to hold the result list; sorted by name.
// Returns a vector of files in the directory which match the
// pattern. Returns true for success, or false if there was a problem.
//
// CMC Note: this is a 'BOINC-friendly' implementation of "old" CPDN code
// the "wildcard matching"/regexp is a bit crude, it matches substrings in
// order in a file; to match all files such as *.pc.*.x4.*.nc" you would send in
// ".pc|.x4.|.nc" for 'pattern'
//
// --------------------------------------------------------------------
bool boinc_filelist(const std::string directory,
const std::string pattern,
ZipFileList* pList)
{
if (!pList) return false;
pList->clear(); // removes old entries that may be in pList
std::string strDir = directory;
// add final / or \ if doesn't exist
if (directory[directory.size()-1] != '/' && directory[directory.size()-1]!='\\')
#ifdef _WIN32
strDir += '\\';
#else
strDir += '/';
#endif
DirScanner dirscan(strDir);
std::string strFile;
int iPos[3], iFnd, iCtr, i, lastPos; // at most three |'s may be passed in pattern
char strPart[3][32];
memset(strPart, 0x00, 3*32);
while (dirscan.scan(strFile))
{
iCtr = 0;
lastPos = 0;
iPos[0] = -1;
iPos[1] = -1;
iPos[2] = -1;
// match the whole filename returned against the regexp to see if it's a hit
// first get all the |'s to get the pieces to verify
while (iCtr<3 && (iPos[iCtr] = (int) pattern.find('|', lastPos)) > -1)
{
if (iCtr==0) {
strncpy(strPart[0], pattern.c_str(), iPos[iCtr]);
}
else {
strncpy(strPart[iCtr], pattern.c_str()+lastPos, iPos[iCtr]-lastPos);
}
lastPos = iPos[iCtr]+1;
iCtr++;
}
if (iCtr>0) // found a | so need to get the part from lastpos onward
{
strncpy(strPart[iCtr], pattern.c_str()+lastPos, pattern.length() - lastPos);
}
// check no | were found at all
if (iCtr == 0)
{
strcpy(strPart[0], pattern.c_str());
iCtr++; // fake iCtr up 1 to get in the loop below
}
bool bFound = true;
for (i = 0; i <= iCtr && bFound; i++)
{
if (i==0) {
iFnd = (int) strFile.find(strPart[0]);
bFound = (bool) (iFnd > -1);
}
else {
// search forward of the old part found
iFnd = (int) strFile.find(strPart[i], iFnd+1);
bFound = bFound && (bool) (iFnd > -1);
}
}
if (bFound)
{
// this pattern matched the file, add to vector
pList->push_back(strDir + strFile);
}
}
std::sort(pList->begin(), pList->end()); // may as well sort it?
return true;
}
# Microsoft Developer Studio Project File - Name="boinc_zip" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Static Library" 0x0104
CFG=boinc_zip - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "boinc_zip.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "boinc_zip.mak" CFG="boinc_zip - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "boinc_zip - Win32 Release" (based on "Win32 (x86) Static Library")
!MESSAGE "boinc_zip - Win32 Debug" (based on "Win32 (x86) Static Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
F90=df.exe
RSC=rc.exe
!IF "$(CFG)" == "boinc_zip - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
# ADD BASE F90 /compile_only /nologo /warn:nofileopt
# ADD F90 /compile_only /nologo /warn:nofileopt
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\lib" /I "..\\" /I ".\\" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FD /c
# ADD BASE RSC /l 0x809 /d "NDEBUG"
# ADD RSC /l 0x809 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo /out:"boinc_zip.lib"
!ELSEIF "$(CFG)" == "boinc_zip - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Target_Dir ""
# ADD BASE F90 /check:bounds /compile_only /dbglibs /debug:full /nologo /traceback /warn:argument_checking /warn:nofileopt
# ADD F90 /check:bounds /compile_only /dbglibs /debug:full /nologo /traceback /warn:argument_checking /warn:nofileopt
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\lib" /I "..\\" /I ".\\" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FD /GZ /c
# ADD BASE RSC /l 0x809 /d "_DEBUG"
# ADD RSC /l 0x809 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo /out:"boinc_zipd.lib"
!ENDIF
# Begin Target
# Name "boinc_zip - Win32 Release"
# Name "boinc_zip - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat;f90;for;f;fpp"
# Begin Source File
SOURCE=.\boinc_zip.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd"
# Begin Source File
SOURCE=.\boinc_zip.h
# End Source File
# End Group
# Begin Group "Unzip Header Files"
# PROP Default_Filter "*.h"
# Begin Source File
SOURCE=.\unzip\consts.h
# End Source File
# Begin Source File
SOURCE=.\unzip\ebcdic.h
# End Source File
# Begin Source File
SOURCE=.\unzip\globals.h
# End Source File
# Begin Source File
SOURCE=.\unzip\inflate.h
# End Source File
# Begin Source File
SOURCE=.\unzip\tables.h
# End Source File
# Begin Source File
SOURCE=.\unzip\ttyio.h
# End Source File
# Begin Source File
SOURCE=.\unzip\unzip.h
# End Source File
# Begin Source File
SOURCE=.\unzip\unzpriv.h
# End Source File
# Begin Source File
SOURCE=.\unzip\unzvers.h
# End Source File
# Begin Source File
SOURCE=.\unzip\win32\w32cfg.h
# End Source File
# End Group
# Begin Group "Unzip Source Files"
# PROP Default_Filter "*.c"
# Begin Source File
SOURCE=.\unzip\apihelp.c
# End Source File
# Begin Source File
SOURCE=.\unzip\crc32.c
# End Source File
# Begin Source File
SOURCE=.\unzip\crctab.c
# End Source File
# Begin Source File
SOURCE=.\unzip\envargs.c
# End Source File
# Begin Source File
SOURCE=.\unzip\explode.c
# End Source File
# Begin Source File
SOURCE=.\unzip\extract.c
# End Source File
# Begin Source File
SOURCE=.\unzip\fileio.c
# End Source File
# Begin Source File
SOURCE=.\unzip\globals.c
# End Source File
# Begin Source File
SOURCE=.\unzip\inflate.c
# End Source File
# Begin Source File
SOURCE=.\unzip\list.c
# End Source File
# Begin Source File
SOURCE=.\unzip\match.c
# End Source File
# Begin Source File
SOURCE=.\unzip\process.c
# End Source File
# Begin Source File
SOURCE=.\unzip\ttyio.c
# End Source File
# Begin Source File
SOURCE=.\unzip\unreduce.c
# End Source File
# Begin Source File
SOURCE=.\unzip\unshrink.c
# End Source File
# Begin Source File
SOURCE=.\unzip\unzip.c
# End Source File
# Begin Source File
SOURCE=.\unzip\win32\win32.c
# End Source File
# Begin Source File
SOURCE=.\unzip\zipinfo.c
# End Source File
# End Group
# Begin Group "Zip Header Files"
# PROP Default_Filter "*.c"
# Begin Source File
SOURCE=.\zip\win32\osdep.h
# End Source File
# Begin Source File
SOURCE=.\zip\revision.h
# End Source File
# Begin Source File
SOURCE=.\zip\tailor.h
# End Source File
# Begin Source File
SOURCE=.\zip\z_ttyio.h
# End Source File
# Begin Source File
SOURCE=.\zip\zip.h
# End Source File
# Begin Source File
SOURCE=.\zip\ziperr.h
# End Source File
# End Group
# Begin Group "Zip Source Files"
# PROP Default_Filter "*.c"
# Begin Source File
SOURCE=.\zip\deflate.c
# End Source File
# Begin Source File
SOURCE=.\zip\mktime.c
# End Source File
# Begin Source File
SOURCE=.\zip\trees.c
# End Source File
# Begin Source File
SOURCE=.\zip\util.c
# End Source File
# Begin Source File
SOURCE=.\zip\win32\win32zip.c
# End Source File