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 #ifdef STANDALONE
00063 
00064 PR_BEGIN_EXTERN_C
00065 
00066 /* Open and close the archive 
00067  *
00068  * If successful OpenArchive returns a handle in the hZip parameter
00069  * that must be passed to all subsequent operations on the archive
00070  */
00071 PR_EXTERN(PRInt32) ZIP_OpenArchive( const char * zipname, void** hZip );
00072 PR_EXTERN(PRInt32) ZIP_CloseArchive( void** hZip );
00073 
00074 
00075 /* Test the integrity of every item in this open archive
00076  * by verifying each item's checksum against the stored
00077  * CRC32 value.
00078  */
00079 PR_EXTERN(PRInt32) ZIP_TestArchive( void* hZip );
00080 
00081 /* Extract the named file in the archive to disk. 
00082  * This function will happily overwrite an existing Outfile if it can.
00083  * It's up to the caller to detect or move it out of the way if it's important.
00084  */
00085 PR_EXTERN(PRInt32) ZIP_ExtractFile( void* hZip, const char * filename, const char * outname );
00086 
00087 
00088 /* Functions to list the files contained in the archive
00089  *
00090  * FindInit() initializes the search with the pattern and returns a find token, 
00091  * or NULL on an error.  Then FindNext() is called with the token to get the 
00092  * matching filenames if any. When done you must call FindFree() with the 
00093  * token to release memory.
00094  * 
00095  * a NULL pattern will find all the files in the archive, otherwise the 
00096  * pattern must be a shell regexp type pattern.
00097  *
00098  * if a matching filename is too small for the passed buffer FindNext()
00099  * will return ZIP_ERR_SMALLBUF. When no more matches can be found in
00100  * the archive it will return ZIP_ERR_FNF
00101  */
00102 PR_EXTERN(void*) ZIP_FindInit( void* hZip, const char * pattern );
00103 PR_EXTERN(PRInt32) ZIP_FindNext( void* hFind, char * outbuf, PRUint16 bufsize );
00104 PR_EXTERN(PRInt32) ZIP_FindFree( void* hFind );
00105 
00106 
00107 PR_END_EXTERN_C
00108 
00109 #endif /* STANDALONE */
00110 
00111 
00112 #endif /* _zipfile_h */