Back to index

lightning-sunbird  0.9+nobinonly
zipfile.h
Go to the documentation of this file.
00001 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is Mozilla Communicator client code, released
00016  * March 31, 1998.
00017  *
00018  * The Initial Developer of the Original Code is
00019  * Netscape Communications Corporation.
00020  * Portions created by the Initial Developer are Copyright (C) 1998
00021  * the Initial Developer. All Rights Reserved.
00022  *
00023  * Contributor(s):
00024  *   Daniel Veditz <dveditz@netscape.com>
00025  *
00026  * Alternatively, the contents of this file may be used under the terms of
00027  * either the GNU General Public License Version 2 or later (the "GPL"), or
00028  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00029  * in which case the provisions of the GPL or the LGPL are applicable instead
00030  * of those above. If you wish to allow use of your version of this file only
00031  * under the terms of either the GPL or the LGPL, and not to allow others to
00032  * use your version of this file under the terms of the MPL, indicate your
00033  * decision by deleting the provisions above and replace them with the notice
00034  * and other provisions required by the GPL or the LGPL. If you do not delete
00035  * the provisions above, a recipient may use your version of this file under
00036  * the terms of any one of the MPL, the GPL or the LGPL.
00037  *
00038  * ***** END LICENSE BLOCK ***** */
00039 
00040 #ifndef _zipfile_h
00041 #define _zipfile_h
00042 /* 
00043  * This module implements a simple archive extractor for the PKZIP format.
00044  *
00045  * All functions return a status/error code, and have an opaque hZip argument 
00046  * that represents an open archive.
00047  *
00048  * Currently only compression mode 8 (or none) is supported.
00049  */
00050 
00051 
00052 #define ZIP_OK                 0
00053 #define ZIP_ERR_GENERAL       -1
00054 #define ZIP_ERR_MEMORY        -2
00055 #define ZIP_ERR_DISK          -3
00056 #define ZIP_ERR_CORRUPT       -4
00057 #define ZIP_ERR_PARAM         -5
00058 #define ZIP_ERR_FNF           -6
00059 #define ZIP_ERR_UNSUPPORTED   -7
00060 #define ZIP_ERR_SMALLBUF      -8
00061 
00062 PR_BEGIN_EXTERN_C
00063 
00064 /* Open and close the archive 
00065  *
00066  * If successful OpenArchive returns a handle in the hZip parameter
00067  * that must be passed to all subsequent operations on the archive
00068  */
00069 extern __declspec(dllexport)int ZIP_OpenArchive( const char * zipname, void** hZip );
00070 extern __declspec(dllexport)int ZIP_CloseArchive( void** hZip );
00071 
00072 
00073 /* Test the integrity of every item in this open archive
00074  * by verifying each item's checksum against the stored
00075  * CRC32 value.
00076  */
00077 extern __declspec(dllexport)int ZIP_TestArchive( void* hZip );
00078 
00079 /* Extract the named file in the archive to disk. 
00080  * This function will happily overwrite an existing Outfile if it can.
00081  * It's up to the caller to detect or move it out of the way if it's important.
00082  */
00083 extern __declspec(dllexport)int ZIP_ExtractFile( void* hZip, const char * filename, const char * outname );
00084 
00085 
00086 /* Functions to list the files contained in the archive
00087  *
00088  * FindInit() initializes the search with the pattern and returns a find token, 
00089  * or NULL on an error.  Then FindNext() is called with the token to get the 
00090  * matching filenames if any. When done you must call FindFree() with the 
00091  * token to release memory.
00092  * 
00093  * a NULL pattern will find all the files in the archive, otherwise the 
00094  * pattern must be a shell regexp type pattern.
00095  *
00096  * if a matching filename is too small for the passed buffer FindNext()
00097  * will return ZIP_ERR_SMALLBUF. When no more matches can be found in
00098  * the archive it will return ZIP_ERR_FNF
00099  */
00100 extern __declspec(dllexport)void* ZIP_FindInit( void* hZip, const char * pattern );
00101 extern __declspec(dllexport)int ZIP_FindNext( void* hFind, char * outbuf, int bufsize );
00102 extern __declspec(dllexport)int ZIP_FindFree( void* hFind );
00103 
00104 
00105 PR_END_EXTERN_C
00106 
00107 #endif /* _zipfile_h */