toolkit/mozapps/update/updater/bspatch.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 /*-
michael@0 2 * Copyright 2003,2004 Colin Percival
michael@0 3 * All rights reserved
michael@0 4 *
michael@0 5 * Redistribution and use in source and binary forms, with or without
michael@0 6 * modification, are permitted providing that the following conditions
michael@0 7 * are met:
michael@0 8 * 1. Redistributions of source code must retain the above copyright
michael@0 9 * notice, this list of conditions and the following disclaimer.
michael@0 10 * 2. Redistributions in binary form must reproduce the above copyright
michael@0 11 * notice, this list of conditions and the following disclaimer in the
michael@0 12 * documentation and/or other materials provided with the distribution.
michael@0 13 *
michael@0 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
michael@0 15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
michael@0 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
michael@0 17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
michael@0 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
michael@0 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
michael@0 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
michael@0 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
michael@0 22 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
michael@0 23 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
michael@0 24 * POSSIBILITY OF SUCH DAMAGE.
michael@0 25 *
michael@0 26 * Changelog:
michael@0 27 * 2005-04-26 - Define the header as a C structure, add a CRC32 checksum to
michael@0 28 * the header, and make all the types 32-bit.
michael@0 29 * --Benjamin Smedberg <benjamin@smedbergs.us>
michael@0 30 */
michael@0 31
michael@0 32 #ifndef bspatch_h__
michael@0 33 #define bspatch_h__
michael@0 34
michael@0 35 #include <stdint.h>
michael@0 36 #include <stdio.h>
michael@0 37
michael@0 38 typedef struct MBSPatchHeader_ {
michael@0 39 /* "MBDIFF10" */
michael@0 40 char tag[8];
michael@0 41
michael@0 42 /* Length of the file to be patched */
michael@0 43 uint32_t slen;
michael@0 44
michael@0 45 /* CRC32 of the file to be patched */
michael@0 46 uint32_t scrc32;
michael@0 47
michael@0 48 /* Length of the result file */
michael@0 49 uint32_t dlen;
michael@0 50
michael@0 51 /* Length of the control block in bytes */
michael@0 52 uint32_t cblen;
michael@0 53
michael@0 54 /* Length of the diff block in bytes */
michael@0 55 uint32_t difflen;
michael@0 56
michael@0 57 /* Length of the extra block in bytes */
michael@0 58 uint32_t extralen;
michael@0 59
michael@0 60 /* Control block (MBSPatchTriple[]) */
michael@0 61 /* Diff block (binary data) */
michael@0 62 /* Extra block (binary data) */
michael@0 63 } MBSPatchHeader;
michael@0 64
michael@0 65 /**
michael@0 66 * Read the header of a patch file into the MBSPatchHeader structure.
michael@0 67 *
michael@0 68 * @param fd Must have been opened for reading, and be at the beginning
michael@0 69 * of the file.
michael@0 70 */
michael@0 71 int MBS_ReadHeader(FILE* file, MBSPatchHeader *header);
michael@0 72
michael@0 73 /**
michael@0 74 * Apply a patch. This method does not validate the checksum of the original
michael@0 75 * file: client code should validate the checksum before calling this method.
michael@0 76 *
michael@0 77 * @param patchfd Must have been processed by MBS_ReadHeader
michael@0 78 * @param fbuffer The original file read into a memory buffer of length
michael@0 79 * header->slen.
michael@0 80 * @param filefd Must have been opened for writing. Should be truncated
michael@0 81 * to header->dlen if it is an existing file. The offset
michael@0 82 * should be at the beginning of the file.
michael@0 83 */
michael@0 84 int MBS_ApplyPatch(const MBSPatchHeader *header, FILE* patchFile,
michael@0 85 unsigned char *fbuffer, FILE* file);
michael@0 86
michael@0 87 typedef struct MBSPatchTriple_ {
michael@0 88 uint32_t x; /* add x bytes from oldfile to x bytes from the diff block */
michael@0 89 uint32_t y; /* copy y bytes from the extra block */
michael@0 90 int32_t z; /* seek forwards in oldfile by z bytes */
michael@0 91 } MBSPatchTriple;
michael@0 92
michael@0 93 #endif // bspatch_h__

mercurial