Back to index

lightning-sunbird  0.9+nobinonly
jarint.h
Go to the documentation of this file.
00001 /* ***** BEGIN LICENSE BLOCK *****
00002  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00003  *
00004  * The contents of this file are subject to the Mozilla Public License Version
00005  * 1.1 (the "License"); you may not use this file except in compliance with
00006  * the License. You may obtain a copy of the License at
00007  * http://www.mozilla.org/MPL/
00008  *
00009  * Software distributed under the License is distributed on an "AS IS" basis,
00010  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00011  * for the specific language governing rights and limitations under the
00012  * License.
00013  *
00014  * The Original Code is the Netscape security libraries.
00015  *
00016  * The Initial Developer of the Original Code is
00017  * Netscape Communications Corporation.
00018  * Portions created by the Initial Developer are Copyright (C) 1994-2000
00019  * the Initial Developer. All Rights Reserved.
00020  *
00021  * Contributor(s):
00022  *
00023  * Alternatively, the contents of this file may be used under the terms of
00024  * either the GNU General Public License Version 2 or later (the "GPL"), or
00025  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00026  * in which case the provisions of the GPL or the LGPL are applicable instead
00027  * of those above. If you wish to allow use of your version of this file only
00028  * under the terms of either the GPL or the LGPL, and not to allow others to
00029  * use your version of this file under the terms of the MPL, indicate your
00030  * decision by deleting the provisions above and replace them with the notice
00031  * and other provisions required by the GPL or the LGPL. If you do not delete
00032  * the provisions above, a recipient may use your version of this file under
00033  * the terms of any one of the MPL, the GPL or the LGPL.
00034  *
00035  * ***** END LICENSE BLOCK ***** */
00036 
00037 /* JAR internal routines */
00038 
00039 #include "nspr.h"
00040 
00041 /* definitely required */
00042 /*#include "certdb.h" */
00043 #include "key.h"
00044 #include "base64.h"
00045 
00046 extern CERTCertDBHandle *JAR_open_database (void);
00047 
00048 extern int JAR_close_database (CERTCertDBHandle *certdb);
00049 
00050 extern int jar_close_key_database (void *keydb);
00051 
00052 extern void *jar_open_key_database (void);
00053 
00054 extern JAR_Signer *JAR_new_signer (void);
00055 
00056 extern void JAR_destroy_signer (JAR_Signer *signer);
00057 
00058 extern JAR_Signer *jar_get_signer (JAR *jar, char *basename);
00059 
00060 extern int jar_append (ZZList *list, int type,
00061    char *pathname, void *data, size_t size);
00062 
00063 /* Translate fopen mode arg to PR_Open flags and mode */
00064 PRFileDesc*
00065 JAR_FOPEN_to_PR_Open(const char *name, const char *mode);
00066 
00067 
00068 #define ADDITEM(list,type,pathname,data,size) \
00069   { int err; err = jar_append (list, type, pathname, data, size); \
00070     if (err < 0) return err; }
00071 
00072 /* Here is some ugliness in the event it is necessary to link
00073    with NSPR 1.0 libraries, which do not include an FSEEK. It is 
00074    difficult to fudge an FSEEK into 1.0 so we use stdio. */
00075 
00076 /* stdio */
00077 #if 0
00078 #define JAR_FILE FILE *
00079 #define JAR_FOPEN(fn,mode) fopen(fn,mode)
00080 #define JAR_FCLOSE fclose
00081 #define JAR_FSEEK fseek
00082 #define JAR_FREAD(fp,buf,siz) fread(buf,1,siz,fp)
00083 #define JAR_FWRITE(fp,buf,siz) fwrite(buf,1,siz,fp) 
00084 #endif
00085 
00086 #if 0
00087 /* nspr 1.0 suite */
00088 #define JAR_FILE PRFileHandle
00089 #define JAR_FOPEN(fn,mode) PR_OpenFile(fn,0,mode)
00090 #define JAR_FCLOSE PR_CLOSE
00091 #define JAR_FSEEK (no-equivalent)
00092 #define JAR_FREAD PR_READ
00093 #define JAR_FWRITE PR_WRITE
00094 #endif
00095 
00096 /* nspr 2.0 suite */
00097 #define JAR_FILE PRFileDesc *
00098 /* #define JAR_FOPEN(fn,mode) PR_Open(fn,0,0) */
00099 #define JAR_FOPEN(fn,mode) JAR_FOPEN_to_PR_Open(fn,mode)
00100 #define JAR_FCLOSE PR_Close
00101 #define JAR_FSEEK PR_Seek
00102 #define JAR_FREAD PR_Read
00103 #define JAR_FWRITE PR_Write
00104 
00105 #if 0
00106 /* nav XP suite, note argument order */
00107 #define JAR_FILE XP_File
00108 #define JAR_FOPEN(fn,mode) XP_FileOpen(fn,xpURL,mode)
00109 #define JAR_FCLOSE XP_FileClose
00110 #define JAR_FSEEK XP_FileSeek
00111 #define JAR_FREAD(fp,buf,siz) XP_FileRead(buf,siz,fp)
00112 #define JAR_FWRITE(fp,buf,siz) XP_FileWrite(buf,siz,fp)
00113 #endif
00114 
00115 int jar_create_pk7
00116    (CERTCertDBHandle *certdb, void *keydb,
00117        CERTCertificate *cert, char *password, JAR_FILE infp, 
00118        JAR_FILE outfp);
00119