michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* JAR internal routines */ michael@0: michael@0: #include "nspr.h" michael@0: #include "key.h" michael@0: #include "base64.h" michael@0: michael@0: extern CERTCertDBHandle *JAR_open_database (void); michael@0: michael@0: extern int JAR_close_database (CERTCertDBHandle *certdb); michael@0: michael@0: extern int jar_close_key_database (void *keydb); michael@0: michael@0: extern void *jar_open_key_database (void); michael@0: michael@0: extern JAR_Signer *JAR_new_signer (void); michael@0: michael@0: extern void JAR_destroy_signer (JAR_Signer *signer); michael@0: michael@0: extern JAR_Signer *jar_get_signer (JAR *jar, char *basename); michael@0: michael@0: extern int michael@0: jar_append(ZZList *list, int type, char *pathname, void *data, size_t size); michael@0: michael@0: /* Translate fopen mode arg to PR_Open flags and mode */ michael@0: PRFileDesc* michael@0: JAR_FOPEN_to_PR_Open(const char *name, const char *mode); michael@0: michael@0: #define ADDITEM(list,type,pathname,data,size) \ michael@0: { \ michael@0: int err = jar_append (list, type, pathname, data, size); \ michael@0: if (err < 0) \ michael@0: return err; \ michael@0: } michael@0: michael@0: /* Here is some ugliness in the event it is necessary to link michael@0: with NSPR 1.0 libraries, which do not include an FSEEK. It is michael@0: difficult to fudge an FSEEK into 1.0 so we use stdio. */ michael@0: michael@0: /* nspr 2.0 suite */ michael@0: #define JAR_FILE PRFileDesc * michael@0: #define JAR_FOPEN(fn,mode) JAR_FOPEN_to_PR_Open(fn,mode) michael@0: #define JAR_FCLOSE PR_Close michael@0: #define JAR_FSEEK PR_Seek michael@0: #define JAR_FREAD PR_Read michael@0: #define JAR_FWRITE PR_Write michael@0: michael@0: int michael@0: jar_create_pk7(CERTCertDBHandle *certdb, void *keydb, michael@0: CERTCertificate *cert, char *password, JAR_FILE infp, michael@0: JAR_FILE outfp); michael@0: