Loading...
Select Version
&pagelevel(3)&pagelevel
#ifndef __SzpZip_h__ #define __SzpZip_h__ /******************************************************************* * BEGIN-INTERFACE SZPZIP.H * * TITLE (/ zip program interface /) * Classes CSzpZip * NAME szpzip.h * DOMAIN BS2ZIP * LANGUAGE CXX * Copyright FUJITSU TECHNOLOGY SOLUTIONS 2014 * All rights reserved * COMPILATION-SCOPE USER * INTERFACE-TYPE CALL * RUN-CONTEXT TU * * VERSION 133 * CRDATE 2014-04-08 * AUTHOR (/ J. Beaume, OSL41 /) * UPDATE (/ BS2ZIP v1.2G10 /) * * END-INTERFACE ************************************************************************/ /* * Version 132
* Date 2013-02-01 * Author P. Louis - OSL EPS * Update BS2ZIP v1.2E05 * * Version 130 * Date 2011-05-18 * Author J. Beaume - OSL EPS * Update BS2ZIP v1.2D05 * * Version 129 * Date 2009-09-30 * Author P. Louis - OSL EPS * Update BS2ZIP v1.2C05 * * Version 128 * Date 2008-11-27 * Author P. Louis - OSL EPS * Update BS2ZIP v1.2B05 * Introduction CpuExhauster (A0571814) * * Version 126 * Date 2008-10-14 * Author Ph/Dumont- OSL EPS * Update BS2ZIP v1.2A25 * Introduction CpuExhauster (A0570787) * * Version 121 * Date 2008-04-18 * Author P.Louis - OSL EPS * Update BS2ZIP v1.2A10 * * Version 118 * Date 2007-12-01 * Author P.Louis - OSL EPS * Update BS2ZIP v1.2A * * Version 116 * Date 2006-12-01 * Author Ph.Dumont - OSL EPS * Update BS2ZIP v1.1C * * Version 115 * Date 2005-06-23 * Author L. Tambour - OSL EPS * Update BS2ZIP v1.1B * * Version 110 * Date 2004-09-30
* Author L. Tambour - OSL EPS * Update BS2ZIP v1.1A * * Version 100 * Date 2003-06-02 * Author J. Beaume - OSL EPS * Update BS2ZIP v1.0B *******************************************************************/ #include "szpzout.h" // SzpZip return codes: #define CSZPZIP_LIB_EXCEPT_ERROR 114 //133 #define CSZPZIP_FILE_EXCEPT_ERROR 113 //133 #define CSZPZIP_LIB_SELECTION_ERROR 112 //133 #define CSZPZIP_FILE_SELECTION_ERROR 111 //133 #define CSZPZIP_DELETE_ORILIBEL_ERROR 110 #define CSZPZIP_DELETE_ORIGFILE_DMS 109 #define CSZPZIP_DELETE_ORIGFILE_ERROR 108 #define CSZPZIP_LMS_ERROR 101 #define CSZPZIP_PARAMETER_ERROR 100 #define CSZPZIP_INCOHERENT_FORMAT 99 #define CSZPZIP_OPEN_ERROR 98 #define CSZPZIP_CONTAINER_EXISTS 97 #define CSZPZIP_NO_CONTAINER_EXISTS 96 #define CSZPZIP_LINKNAME 95 #define CSZPZIP_NO_FILE 94 #define CSZPZIP_FILE_EXISTS 93 #define CSZPZIP_NO_FILE_EXISTS 92 #define CSZPZIP_INTERNAL_ERROR 91 #define CSZPZIP_RSV1 90 #define CSZPZIP_EXTRACT_ERROR 89 #define CSZPZIP_CATALOG 88 #define CSZPZIP_NO_CONTAINER_OPENED 86 #define CSZPZIP_READMODE 85 #define CSZPZIP_ALREADY_ZIPPED 84 #define CSZPZIP_ALREADY_ZIPPED_WLDC 83 #define CSZPZIP_ADD_ERROR 82 #define CSZPZIP_ILLEGAL_NEW_NAME 81 #define CSZPZIP_ILLEGAL_LINK 80 #define CSZPZIP_INVALID_RENAMING 79 #define CSZPZIP_IMPOSSIBLE_RENAMING 39 #define CSZPZIP_REORG_ERROR 78 #define CSZPZIP_DELETE_ERROR 77 #define CSZPZIP_INCON_FORMAT_ERROR 76 #define CSZPZIP_OUCON_DMS_ERROR 75 #define CSZPZIP_INCON_DMS_ERROR 74 #define CSZPZIP_OUCON_EXIST_ERROR 73 #define CSZPZIP_OUCON_NOEXIST_ERROR 72 #define CSZPZIP_INCON_NOEXIST_ERROR 71
#define CSZPZIP_OUCON_LINK_ERROR 70 #define CSZPZIP_INCON_LINK_ERROR 69 #define CSZPZIP_OUCON_FLINK_ERROR 68 #define CSZPZIP_INCON_FLINK_ERROR 67 #define CSZPZIP_INCON_OPEN_ERROR 66 #define CSZPZIP_PSWORDCHECK_ERROR 42 #define CSZPZIP_PSWORDNOTCOR_ERROR 41 #define CSZPZIP_PSWORDNOTGIV_ERROR 40 #define CSZPZIP_DATATYPE_BS2000 37 #define CSZPZIP_DMS_ERROR 31 #define CSZPZIP_INT_ERROR 19 #define CSZPZIP_STD_NAME 2 #define CSZPZIP_SHORT_STD_NAME 1 // Message id #define MSG_K2 "SZP0207" #define MSG_LIB_EXCEPT_ERROR "SZP0114" //133 #define MSG_FILE_EXCEPT_ERROR "SZP0113" //133 #define MSG_LIB_SELECTION_ERROR "SZP0112" //133 #define MSG_FILE_SELECTION_ERROR "SZP0111" //133 #define MSG_DELETE_ORILEL_FILE "SZP0110" //133 #define MSG_DELETE_ORIDMS_FILE "SZP0109" #define MSG_DELETE_ORIGIN_FILE "SZP0108" #define MSG_LMS_ERROR "SZP0101" #define MSG_PARAMETER_ERROR "SZP0100" #define MSG_INCOHERENT_FORMAT "SZP0099" #define MSG_OPEN_ERROR "SZP0098" #define MSG_CONTAINER_EXISTS "SZP0097" #define MSG_NO_CONTAINER_EXISTS "SZP0096" #define MSG_LINKNAME "SZP0095" #define MSG_NO_FILE "SZP0094" #define MSG_FILE_EXISTS "SZP0093" #define MSG_NO_FILE_EXISTS "SZP0092" #define MSG_INTERNAL_ERROR "SZP0091" #define MSG_WARNING1 "SZP0090" #define MSG_EXTRACT_ERROR "SZP0089" #define MSG_CATALOG "SZP0088" #define MSG_NO_CONTAINER_OPENED "SZP0086" #define MSG_READMODE "SZP0085" #define MSG_ALREADY_ZIPPED "SZP0084" #define MSG_ALREADY_ZIPPED_WLDC "SZP0083" #define MSG_ADD_ERROR "SZP0082" #define MSG_ILLEGAL_NEW_NAME "SZP0081" #define MSG_ILLEGAL_LINK "SZP0080" #define MSG_INVALID_RENAMING "SZP0079" #define MSG_IMPOSSIBLE_RENAMING "SZP0039" #define MSG_REORG_ERROR "SZP0078" #define MSG_DELETE_ERROR "SZP0077" #define MSG_INCON_FORMAT_ERROR "SZP0076"
#define MSG_OUCON_DMS_ERROR "SZP0075" #define MSG_INCON_DMS_ERROR "SZP0074" #define MSG_OUCON_EXIST_ERROR "SZP0073" #define MSG_OUCON_NOEXIST_ERROR "SZP0072" #define MSG_INCON_NOEXIST_ERROR "SZP0071" #define MSG_OUCON_LINK_ERROR "SZP0070" #define MSG_INCON_LINK_ERROR "SZP0069" #define MSG_OUCON_FLINK_ERROR "SZP0068" #define MSG_INCON_FLINK_ERROR "SZP0067" #define MSG_INCON_OPEN_ERROR "SZP0066" #define MSG_PSWORDCHECK_ERROR "SZP0042" #define MSG_PSWORDNOTCOR_ERROR "SZP0041" #define MSG_PSWORDNOTGIV_ERROR "SZP0040" #define MSG_DATATYPE_BS2000 "SZP0037" #define MSG_DMS_ERROR "SZP0031" #define MSG_INT_ERROR "SZP0019" /** This class is the C++ api for managing a BS2ZIP container file. This class is able to handle the K2 but not to intercept it. **/ class CSzpZip { public: /** **/ CSzpZip(); /** **/ CSzpZip(bool bOutputMsg); /** **/ virtual ~CSzpZip(); enum szpOpenMode { read, updateAny, updateNew }; enum szpFormat { defaut, compatible, bs2000 }; enum szpConvertMode { std, none, ascii, ebcdic }; enum szpWriteMode {
create, replace, any }; enum szpLink { no, yes }; enum szpDataType { notSpecified, character, binary, sambinary }; enum szpBlkCtrlInfo { keep, ignore }; enum szpLevel { noCompression = 0, bestSpeed = 1, bestCompression = 9, defaultCompression = -1 }; enum szpInfo { infoNone, infoAll, infoSummary }; // 132 enum szpDelete { DeleteOption_No, DeleteOption_Yes }; enum szpTofileOption { TofileOptionVersStd_TypeStd = 0, TofileOptionVersStd_TypeYes = 1, TofileOptionVersStd_TypeNo = 2, TofileOptionVersYes_TypeStd = 10, TofileOptionVersYes_TypeYes = 11, TofileOptionVersYes_TypeNo = 12, TofileOptionVersNo_TypeStd = 20, TofileOptionVersNo_TypeYes = 21, TofileOptionVersNo_TypeNo = 22 }; /** Open a zip container. It returns 0 if ok.
char *pContainer = name of the zip container file this file name must be valid if "link=linkname", the container is opened using this link name int iOpenMode = read, update, create int iFormat = bs2000 or compatible **/ int OpenZip(char *pContainer, int iOpenMode, int iFormat); /** Close the zip container and release eventually file link. It returns 0 if ok. **/ int CloseZip(); /** Add files in the zip container. The filename may contain wildcards. By this way several files can be zipped in a single operation. Eventual data conversion is required as well as the compression level. Files are compressed one by one. If an error occurred, the data already written in the container remain in it but the entry is not visible. If several files have to be written, the processing goes on even in case of error on a previous file. The same behavior is implemented if K2 is handled during the processing of a file but if there are still files to be included, those ones are not processed. To keep the container coherent, the central header is rewritten after each added files and then reread to rebuild the structure in memory. It returns 0 if ok. V01.0B: introduction of the parameter data-type This operand is only significant for adding sam files in compatible format, otherwise, it is ignored. In char mode, each record of a sam file is interpreted as a line. In binary mode, data are interpreted as a simple byte stream. Such a file is extracted as a pam std 16. char *pFileNames = file name (incl. wild cards ev.) int iConvertMode = convert mode int iLevel = compression level int iDataType = data type (not specified, character, binary) char *pToFiles = target construction file name int iDeleteOption = source file delete option 132 **/ int AddFiles(char *pFileNames, int iConvertMode, int iLevel, int iDataType, char *pToFiles, int iDeleteOption); /** Add files in the zip container. Old format for program compatibility. **/ int AddFiles(char *pFileNames, int iConvertMode, int iLevel, int iDataType, char *pToFiles);
/** Add PLAM elements in the zip container. The element names, version, base and type may contain wildcards. Library name may not. By this way several elements can be zipped in a single operation. Eventual data conversion is required as well as the compression level. Elements are compressed one by one. If an error occurred, the data already written in the container remain in it but the entry is not visible. If several elements have to be written, the processing goes on even in case of error on a previous file. The same behavior is implemented if K2 is handled during the processing of a file but if there are still files to be included, those ones are not processed. To keep the container coherent, the central header is rewritten after each added elements and then reread to rebuild the structure in memory. It returns 0 if ok. V01.0B: introduction of the parameter data-type This operand is only significant for adding sam files in compatible format, otherwise, it is ignored. In char mode, each record of a sam file is interpreted as a line. In binary mode, data are interpreted as a simple byte stream. Such a file is extracted as a pam std 16. char *pLibName = library name (excl. wild cards) char *pElements = element name selector (incl. wild cards ev.) char *pVersion = element version selector (incl. wild cards ev.) char *pType = element type selector (incl. wild cards ev.) char *pBase = version base selector int iConvertMode = convert mode int iLevel = compression level int iDataType = data type (not specified, character, binary) char *pToFiles = target construction file name int iTofileOption = specifies if libr element version and/or type are saved in the name int iDeleteOption = library element delete option 132 **/ int AddLibElements(char *pLibName, char *pElements, char *pVersion, char *pType,char *pBase, int iConvertMode, int iLevel, int iDataType, char *pToFiles, int iTofileOption, int iDeleteOption); /** Add PLAM elements in the zip container. Old format for program compatibility. **/ int AddLibElements(char *pLibName, char *pElements, char *pVersion,
char *pType,char *pBase, int iConvertMode, int iLevel, int iDataType, char *pToFiles, int iTofileOption); /** Extract one or several files selected by the pFileNames patterns into BS2000 files named according the rule specified by the pToFiles pattern. If an error occurred during the extract of a file, the extract of this file is interrupted but the other files are processed. If K2 is handled, the current file process is stopped, the output file is deleted and the other extract files are not processed if any. char *pFileNames = file pattern used to select the files that must be extracted from the container char *pToFiles = pattern specifying the output name of the extracted files int iWriteMode = new (default) or replace int iDataType = data type of the file (not specified (default), char or binary) int iConvertMode = convert mode (std (default), none, ascii or ebcdic) int iBlkCtrlInfo = specifies if the original block control must be used or not **/ int ExtractFiles(char *pFileNames, char *pToFiles, int iWriteMode = 0, int iDataType = 0, int iConvertMode = 0, int iBlkCtrlInfo = 0); /** Returns the information about the zipped files selected by the pFileNames pattern that may contain wild cards. Information summary or full is possible. The layout of the output is described in the header file szpzout.h. Data are returned in a buffer requested by this method. Its address and size are returned to the caller who is in charge to release it after use. The number of matching files is returned. -1 is returned in case of error. char *pFileNames = file selection pattern char **pBuf = address where the output buffer address is returned int *iSize = address of an int where the output buffer size is returned int iInfo = information type selection (infoAll default, infoSummary) **/ int ListFiles(char *pFileNames, char **pBuf, int *iSize = 0, int iInfo = infoAll, bool ListFirst = true); /** Delete files from a zip container. The filename may contain wildcards. By this way several files can be deleted in a single operation. If several files have to be deleted, the processing goes on even in case of
error on a previous file. The same behavior is implemented if K2 is handled during the processing of a file but if there are still files to be deleted, those ones are not processed. It returns 0 if ok. char *pFileNames = file name (incl. wild cards ev.) **/ int DeleteFiles(char *pFileNames); /** CONVERT ******************************************** It returns 0 if ok. char *pFromContainer = Output file name char *pToContainer = Input file name int iHuser = Home userid length int iHcat = Home catid length int iWriteMode = new (default) or replace **/ int CnvZip(char *pFromContainer, char *pToContainer, int iHuser, int iHcat, int iWriteMode = 0); /** MODIFY-ZIP-OPTIONS **************************************** It returns 0 if ok. char *pCrypto = crypto password int iLen = length of crypto password int iEncrypt = encryption or not **/ int ModZipopt(char *pCrypto, int iLen, int iEncrypt); /** // reorganize the file by rewriting only the files having a header in the central directory It returns 0 if ok. char *pContainer = name of the zip container file this file name must be valid if "link=linkname", the container is opened using this link name **/ int ReorganizeZip(char *pContainer); /** Activate the trace processing. It returns 0 if ok. char *pFileName = name of the trace file. If NULL, default name is used **/ int ActivateTrace(char *pFileName);
/** Deactivate the trace **/ int DeactivateTrace(); /** Return the zip container comments into the input buffer with the specified input size. If this size is not sufficient, the data are truncated. char *Comments = buffer address int iCommentsSize = buffer size **/ int GetComments(char *Comments, int iCommentsSize); /** Allows to set or reset that K2 has been intercepted at interface level. bool b = indicates that K2 indicator must be set or reset **/ void K2given(bool b); /** Activated if the 'Cpu Exhausted' event occurs. **/ void CpuExhausted(); /** Activated if the 'Term' event occurs. **/ void Term(); /** Global return code **/ //void *pRcErr; // CRcErr m_RcErr; //#define RcErr (*((CRcErr*)pRcErr)) /** Return the last error maincode. Use for LIST problem when -1 is returned **/ int GetLastError(); // private: /** Get the file name according to the link name. The file name is returned in the ContainerName variable. ReadTFT rc is returned. char *pLink = link name **/ long GetFileFromLink(char *pLink, char *pContainer); /** Check if the file exists. It returns 1 if the file exists, -1 if it exists but is empty, 0 if it does not exist. char *pFileName = file name **/ int FileExists(char* pFileName);
/** Build a file name for output: :catid:$uid.FILEyyyymmdd.hhmmss **/ void BuildFileName(char *fn, int i, char *catid=0, char *userid=0); /** Validate if the input file name is a valid file name Return true is bs2000 file name compliant. const char *fn = file name **/ bool IsBS2000FileName(const char *fn); /** Not implemented **/ static void fsRout(const char* fn, int i); /** Convert input string in upper case char *s = string to convert **/ void ToUpperCase(char *s); /** Catalog a container (PAM, STD16) char *cont = container name char *link = link name int format = container format bool space = true (define space in prg) **/ int CatalogContainer(char *cont, char *link, int format, bool space); /** Get new file name using SDF wildcard construction char *selection char *construction char *srcname char *newname **/ int GetNewFileName(char *selection, char *construction, char *srcname, char *newname); /** Get new file name using SDF wildcard construction char *selection char *construction void *src = fileitem object char *newname **/ int GetNewFileName(char *selection, char *construction, void *src, char *newname); /** Common function adding files or lib elements in ZIP container char *pFileNames = files or lib file name
char *pElements = null ptr or element selector char *pVersion = null ptr or version selector char *pType = null ptr or type selector char *pBase = null ptr or base version base selector int iConvertMode = convert mode int iLevel = compression level int iDataType = data type (not specified, character, binary) char *pToFiles = target construction file name int iTofileOption = specifies if libr element version and/or type are saved in the name int iDeleteOption = library element delete option 132 int iLogOption = logging option 133 long nbr = number of added files 133 **/ int AddItems(char *pFileNames, char *pElements, char *pVersion, char *pType, char *pBase, int iConvertMode, int iLevel, int iDataType, char *pToFiles, int iTofileOption, int iDeleteOption, int iLogOption, unsigned long &nbr, void *flist); /* methods added for selection enhancement 1.2G */ /* internal method pre-requisite CAddParam object has been created with all the parameters of the add statement */ int AddToZip(void *paddparam); void SetExtractLogging(bool log); char ContainerName[55]; int iCFormat; void *pZip; //CZipArch m_Zip; #define Zip (*((CZipArch*)pZip)) bool bRelLink; int m_OpenMode; bool k2Pressed; void UpdateUserInfo(); bool bLib; int m_TofileOption; void *pAddParam; // CAddParam instance bool bExtractLoggingMax; // 134 }; // extern bool glb_sysout; // msg on sysout by default #endif // __SzpZip_h__