uriloader/exthandler/mac/nsDecodeAppleFile.h

Thu, 15 Jan 2015 15:59:08 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:59:08 +0100
branch
TOR_BUG_9701
changeset 10
ac0c01689b40
permissions
-rw-r--r--

Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #ifndef nsDecodeAppleFile_h__
     7 #define nsDecodeAppleFile_h__
     9 #include "nscore.h"
    10 #include "nsCOMPtr.h"
    11 #include "nsIFile.h"
    12 #include "nsILocalFileMac.h"
    13 #include "nsIOutputStream.h"
    15 /*
    16 ** applefile definitions used 
    17 */
    18 #if PRAGMA_STRUCT_ALIGN
    19   #pragma options align=mac68k
    20 #endif
    22 #define APPLESINGLE_MAGIC   0x00051600L
    23 #define APPLEDOUBLE_MAGIC 	0x00051607L
    24 #define VERSION             0x00020000
    26 #define NUM_ENTRIES 		6
    28 #define ENT_DFORK   		1L
    29 #define ENT_RFORK   		2L
    30 #define ENT_NAME    		3L
    31 #define ENT_COMMENT 		4L
    32 #define ENT_DATES   		8L
    33 #define ENT_FINFO   		9L
    35 #define CONVERT_TIME 		1265437696L
    37 /*
    38 ** data type used in the header decoder.
    39 */
    40 typedef struct ap_header 
    41 {
    42 	int32_t 	magic;
    43 	int32_t   version;
    44 	int32_t 	fill[4];
    45 	int16_t 	entriesCount;
    47 } ap_header;
    49 typedef struct ap_entry 
    50 {
    51 	int32_t   id;
    52 	int32_t	  offset;
    53 	int32_t	  length;
    55 } ap_entry;
    57 typedef struct ap_dates 
    58 {
    59 	int32_t create, modify, backup, access;
    61 } ap_dates;
    63 #if PRAGMA_STRUCT_ALIGN
    64   #pragma options align=reset
    65 #endif
    67 /*
    68 **Error codes
    69 */
    70 enum {
    71   errADNotEnoughData = -12099,
    72   errADNotSupported,
    73   errADBadVersion
    74 };
    77 class nsDecodeAppleFile : public nsIOutputStream
    78 {
    79 public:
    80   NS_DECL_THREADSAFE_ISUPPORTS
    81   NS_DECL_NSIOUTPUTSTREAM
    83   nsDecodeAppleFile();
    84   virtual ~nsDecodeAppleFile();
    86   nsresult Initialize(nsIOutputStream *output, nsIFile *file);
    88 private:
    89   #define MAX_BUFFERSIZE    1024
    90   enum ParserState {parseHeaders, parseEntries, parseLookupPart, parsePart, parseSkipPart,
    91                     parseDataFork, parseResourceFork, parseWriteThrough};
    93   nsCOMPtr<nsIOutputStream> m_output;
    94   FSSpec            m_fsFileSpec;
    95   SInt16            m_rfRefNum;
    97   unsigned char *   m_dataBuffer;
    98   int32_t           m_dataBufferLength;
    99   ParserState       m_state;
   100   ap_header         m_headers;
   101   ap_entry *        m_entries;
   102   int32_t           m_offset;
   103   int32_t           m_dataForkOffset;
   104   int32_t           m_totalDataForkWritten;
   105   int32_t           m_totalResourceForkWritten;
   106   bool              m_headerOk;
   108   int32_t           m_currentPartID;
   109   int32_t           m_currentPartLength;
   110   int32_t           m_currentPartCount;
   112   Str255            m_comment;
   113   ap_dates          m_dates;
   114   FInfo             m_finderInfo;
   115   FXInfo            m_finderExtraInfo;
   116 };
   118 #endif

mercurial