Back to index

lightning-sunbird  0.9+nobinonly
bspatch.h
Go to the documentation of this file.
00001 /*-
00002  * Copyright 2003,2004 Colin Percival
00003  * All rights reserved
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted providing that the following conditions
00007  * are met:
00008  * 1. Redistributions of source code must retain the above copyright
00009  *    notice, this list of conditions and the following disclaimer.
00010  * 2. Redistributions in binary form must reproduce the above copyright
00011  *    notice, this list of conditions and the following disclaimer in the
00012  *    documentation and/or other materials provided with the distribution.
00013  *
00014  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
00015  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00016  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00017  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
00018  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00019  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00020  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00021  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
00022  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
00023  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00024  * POSSIBILITY OF SUCH DAMAGE.
00025  *
00026  * Changelog:
00027  * 2005-04-26 - Define the header as a C structure, add a CRC32 checksum to
00028  *              the header, and make all the types 32-bit.
00029  *                --Benjamin Smedberg <benjamin@smedbergs.us>
00030  */
00031 
00032 #ifndef bspatch_h__
00033 #define bspatch_h__
00034 
00035 // We use the NSPR types, but we don't link with NSPR
00036 #include "prtypes.h"
00037 
00038 typedef struct MBSPatchHeader_ {
00039   /* "MBDIFF10" */
00040   char tag[8];
00041   
00042   /* Length of the file to be patched */
00043   PRUint32 slen;
00044 
00045   /* CRC32 of the file to be patched */
00046   PRUint32 scrc32;
00047 
00048   /* Length of the result file */
00049   PRUint32 dlen;
00050 
00051   /* Length of the control block in bytes */
00052   PRUint32 cblen;
00053 
00054   /* Length of the diff block in bytes */
00055   PRUint32 difflen;
00056 
00057   /* Length of the extra block in bytes */
00058   PRUint32 extralen;
00059 
00060   /* Control block (MBSPatchTriple[]) */
00061   /* Diff block (binary data) */
00062   /* Extra block (binary data) */
00063 } MBSPatchHeader;
00064 
00071 int MBS_ReadHeader(int fd, MBSPatchHeader *header);
00072 
00084 int MBS_ApplyPatch(const MBSPatchHeader *header, int patchfd,
00085                    unsigned char *fbuffer, int filefd);
00086 
00087 typedef struct MBSPatchTriple_ {
00088   PRUint32 x; /* add x bytes from oldfile to x bytes from the diff block */
00089   PRUint32 y; /* copy y bytes from the extra block */
00090   PRInt32  z; /* seek forwards in oldfile by z bytes */
00091 } MBSPatchTriple;
00092 
00093 #endif  // bspatch_h__