| 1 | /* Copyright 2014 Google Inc. All Rights Reserved. |
| 2 | |
| 3 | Distributed under MIT license. |
| 4 | See file LICENSE for detail or copy at https://opensource.org/licenses/MIT |
| 5 | */ |
| 6 | |
| 7 | /* Command line interface for Brotli library. */ |
| 8 | |
| 9 | /* Mute strerror/strcpy warnings. */ |
| 10 | #include <brotli/shared_dictionary.h>cxx . . $ `<file>/c/include/brotli/shared_dictionary.h`/ |
| 11 | #if !defined(_CRT_SECURE_NO_WARNINGS) |
| 12 | #define _CRT_SECURE_NO_WARNINGScxx . . $ `c/tools/brotli.c:12:9`! |
| 13 | #endif |
| 14 | |
| 15 | #include <errno.h> |
| 16 | #include <fcntl.h> |
| 17 | #include <stdio.h> |
| 18 | #include <stdlib.h> |
| 19 | #include <string.h> |
| 20 | #include <sys/stat.h> |
| 21 | #include <sys/types.h> |
| 22 | #include <time.h> |
| 23 | |
| 24 | #include <brotli/types.h>cxx . . $ `<file>/c/include/brotli/types.h`/ |
| 25 | #include "../common/constants.h"cxx . . $ `<file>/c/common/constants.h`/ |
| 26 | #include "../common/version.h"cxx . . $ `<file>/c/common/version.h`/ |
| 27 | #include <brotli/decode.h>cxx . . $ `<file>/c/include/brotli/decode.h`/ |
| 28 | #include <brotli/encode.h>cxx . . $ `<file>/c/include/brotli/encode.h`/ |
| 29 | |
| 30 | #if defined(_WIN32) |
| 31 | #include <io.h> |
| 32 | #include <share.h> |
| 33 | #include <sys/utime.h> |
| 34 | |
| 35 | #define MAKE_BINARY(FILENO) (_setmode((FILENO), _O_BINARY), (FILENO)) |
| 36 | |
| 37 | #if !defined(__MINGW32__) |
| 38 | #define STDIN_FILENO _fileno(stdin) |
| 39 | #define STDOUT_FILENO _fileno(stdout) |
| 40 | #define S_IRUSR S_IREAD |
| 41 | #define S_IWUSR S_IWRITE |
| 42 | #endif |
| 43 | |
| 44 | #define fdopen _fdopen |
| 45 | #define isatty _isatty |
| 46 | #define unlink _unlink |
| 47 | #define utimbuf _utimbuf |
| 48 | #define utime _utime |
| 49 | |
| 50 | #define fopen ms_fopen |
| 51 | #define open ms_open |
| 52 | |
| 53 | #define chmod(F, P) (0) |
| 54 | #define chown(F, O, G) (0) |
| 55 | |
| 56 | #if defined(_MSC_VER) && (_MSC_VER >= 1400) |
| 57 | #define fseek _fseeki64 |
| 58 | #define ftell _ftelli64 |
| 59 | #endif |
| 60 | |
| 61 | static FILE* ms_fopen(const char* filename, const char* mode) { |
| 62 | FILE* result = 0; |
| 63 | fopen_s(&result, filename, mode); |
| 64 | return result; |
| 65 | } |
| 66 | |
| 67 | static int ms_open(const char* filename, int oflag, int pmode) { |
| 68 | int result = -1; |
| 69 | _sopen_s(&result, filename, oflag | O_BINARY, _SH_DENYNO, pmode); |
| 70 | return result; |
| 71 | } |
| 72 | #else /* !defined(_WIN32) */ |
| 73 | #include <unistd.h> |
| 74 | #include <utime.h> |
| 75 | #define MAKE_BINARYcxx . . $ `c/tools/brotli.c:75:9`!(FILENO) (FILENO) |
| 76 | #endif /* defined(_WIN32) */ |
| 77 | |
| 78 | #if defined(_POSIX_C_SOURCEcxx . . $ `<external>/18206667465210621810/features.h:319:10`!) && (_POSIX_C_SOURCEcxx . . $ `<external>/18206667465210621810/features.h:319:10`! >= 200809L) |
| 79 | #define HAVE_UTIMENSATcxx . . $ `c/tools/brotli.c:79:9`! 1 |
| 80 | #elif defined(_ATFILE_SOURCE) |
| 81 | #define HAVE_UTIMENSAT 1 |
| 82 | #else |
| 83 | #define HAVE_UTIMENSAT 0 |
| 84 | #endif |
| 85 | |
| 86 | #if HAVE_UTIMENSATcxx . . $ `c/tools/brotli.c:79:9`! |
| 87 | #if defined(__APPLE__) |
| 88 | #define ATIME_NSEC(S) ((S)->st_atimespec.tv_nsec) |
| 89 | #define MTIME_NSEC(S) ((S)->st_mtimespec.tv_nsec) |
| 90 | #else /* defined(__APPLE__) */ |
| 91 | #define ATIME_NSECcxx . . $ `c/tools/brotli.c:91:9`!(S) ((S)->st_atim.tv_nsec) |
| 92 | #define MTIME_NSECcxx . . $ `c/tools/brotli.c:92:9`!(S) ((S)->st_mtim.tv_nsec) |
| 93 | #endif |
| 94 | #endif /* HAVE_UTIMENSAT */ |
| 95 | |
| 96 | typedef enumcxx . . $ $anonymous_type_2fa36e8c50d79419_0# { |
| 97 | COMMAND_COMPRESScxx . . $ COMMAND_COMPRESS., |
| 98 | COMMAND_DECOMPRESScxx . . $ COMMAND_DECOMPRESS., |
| 99 | COMMAND_HELPcxx . . $ COMMAND_HELP., |
| 100 | COMMAND_INVALIDcxx . . $ COMMAND_INVALID., |
| 101 | COMMAND_TEST_INTEGRITYcxx . . $ COMMAND_TEST_INTEGRITY., |
| 102 | COMMAND_NOOPcxx . . $ COMMAND_NOOP., |
| 103 | COMMAND_VERSIONcxx . . $ COMMAND_VERSION. |
| 104 | } Commandcxx . . $ Command#; |
| 105 | |
| 106 | typedef enumcxx . . $ $anonymous_type_2fa36e8c50d79419_1# { |
| 107 | COMMENT_INITcxx . . $ COMMENT_INIT., |
| 108 | COMMENT_READcxx . . $ COMMENT_READ., |
| 109 | COMMENT_OKcxx . . $ COMMENT_OK., |
| 110 | COMMENT_BADcxx . . $ COMMENT_BAD., |
| 111 | } CommentStatecxx . . $ CommentState#; |
| 112 | |
| 113 | #define DEFAULT_LGWINcxx . . $ `c/tools/brotli.c:113:9`! 24 |
| 114 | #define DEFAULT_SUFFIXcxx . . $ `c/tools/brotli.c:114:9`! ".br" |
| 115 | #define MAX_OPTIONScxx . . $ `c/tools/brotli.c:115:9`! 24 |
| 116 | #define MAX_COMMENT_LENcxx . . $ `c/tools/brotli.c:116:9`! 80 |
| 117 | |
| 118 | typedef structcxx . . $ $anonymous_type_2fa36e8c50d79419_2# { |
| 119 | /* Parameters */ |
| 120 | int qualitycxx . . $ $anonymous_type_2fa36e8c50d79419_2#quality.; |
| 121 | int lgwincxx . . $ $anonymous_type_2fa36e8c50d79419_2#lgwin.; |
| 122 | int verbositycxx . . $ $anonymous_type_2fa36e8c50d79419_2#verbosity.; |
| 123 | BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! force_overwritecxx . . $ $anonymous_type_2fa36e8c50d79419_2#force_overwrite.; |
| 124 | BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! junk_sourcecxx . . $ $anonymous_type_2fa36e8c50d79419_2#junk_source.; |
| 125 | BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! reject_uncompressiblecxx . . $ $anonymous_type_2fa36e8c50d79419_2#reject_uncompressible.; |
| 126 | BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! copy_statcxx . . $ $anonymous_type_2fa36e8c50d79419_2#copy_stat.; |
| 127 | BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! write_to_stdoutcxx . . $ $anonymous_type_2fa36e8c50d79419_2#write_to_stdout.; |
| 128 | BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! test_integritycxx . . $ $anonymous_type_2fa36e8c50d79419_2#test_integrity.; |
| 129 | BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! decompresscxx . . $ $anonymous_type_2fa36e8c50d79419_2#decompress.; |
| 130 | BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! large_windowcxx . . $ $anonymous_type_2fa36e8c50d79419_2#large_window.; |
| 131 | BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! allow_concatenatedcxx . . $ $anonymous_type_2fa36e8c50d79419_2#allow_concatenated.; |
| 132 | const char* output_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#output_path.; |
| 133 | const char* dictionary_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#dictionary_path.; |
| 134 | const char* suffixcxx . . $ $anonymous_type_2fa36e8c50d79419_2#suffix.; |
| 135 | uint8_tcxx . . $ uint8_t# commentcxx . . $ $anonymous_type_2fa36e8c50d79419_2#comment.[MAX_COMMENT_LENcxx . . $ `c/tools/brotli.c:116:9`!]; |
| 136 | size_t comment_lencxx . . $ $anonymous_type_2fa36e8c50d79419_2#comment_len.; |
| 137 | size_t comment_poscxx . . $ $anonymous_type_2fa36e8c50d79419_2#comment_pos.; |
| 138 | CommentStatecxx . . $ CommentState# comment_statecxx . . $ $anonymous_type_2fa36e8c50d79419_2#comment_state.; |
| 139 | int not_input_indicescxx . . $ $anonymous_type_2fa36e8c50d79419_2#not_input_indices.[MAX_OPTIONScxx . . $ `c/tools/brotli.c:115:9`!]; |
| 140 | size_t longest_path_lencxx . . $ $anonymous_type_2fa36e8c50d79419_2#longest_path_len.; |
| 141 | size_t input_countcxx . . $ $anonymous_type_2fa36e8c50d79419_2#input_count.; |
| 142 | |
| 143 | /* Inner state */ |
| 144 | int argccxx . . $ $anonymous_type_2fa36e8c50d79419_2#argc.; |
| 145 | char** argvcxx . . $ $anonymous_type_2fa36e8c50d79419_2#argv.; |
| 146 | uint8_tcxx . . $ uint8_t#* dictionarycxx . . $ $anonymous_type_2fa36e8c50d79419_2#dictionary.; |
| 147 | size_t dictionary_sizecxx . . $ $anonymous_type_2fa36e8c50d79419_2#dictionary_size.; |
| 148 | BrotliEncoderPreparedDictionarycxx . . $ BrotliEncoderPreparedDictionary#* prepared_dictionarycxx . . $ $anonymous_type_2fa36e8c50d79419_2#prepared_dictionary.; |
| 149 | BrotliDecoderStatecxx . . $ BrotliDecoderState#* decodercxx . . $ $anonymous_type_2fa36e8c50d79419_2#decoder.; |
| 150 | char* modified_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#modified_path.; /* Storage for path with appended / cut suffix */ |
| 151 | int iteratorcxx . . $ $anonymous_type_2fa36e8c50d79419_2#iterator.; |
| 152 | int ignorecxx . . $ $anonymous_type_2fa36e8c50d79419_2#ignore.; |
| 153 | BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! iterator_errorcxx . . $ $anonymous_type_2fa36e8c50d79419_2#iterator_error.; |
| 154 | uint8_tcxx . . $ uint8_t#* buffercxx . . $ $anonymous_type_2fa36e8c50d79419_2#buffer.; |
| 155 | uint8_tcxx . . $ uint8_t#* inputcxx . . $ $anonymous_type_2fa36e8c50d79419_2#input.; |
| 156 | uint8_tcxx . . $ uint8_t#* outputcxx . . $ $anonymous_type_2fa36e8c50d79419_2#output.; |
| 157 | const char* current_input_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#current_input_path.; |
| 158 | const char* current_output_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#current_output_path.; |
| 159 | int64_tcxx . . $ int64_t# input_file_lengthcxx . . $ $anonymous_type_2fa36e8c50d79419_2#input_file_length.; /* -1, if impossible to calculate */ |
| 160 | FILEcxx . . $ FILE#* fincxx . . $ $anonymous_type_2fa36e8c50d79419_2#fin.; |
| 161 | FILEcxx . . $ FILE#* foutcxx . . $ $anonymous_type_2fa36e8c50d79419_2#fout.; |
| 162 | |
| 163 | /* I/O buffers */ |
| 164 | size_t available_incxx . . $ $anonymous_type_2fa36e8c50d79419_2#available_in.; |
| 165 | const uint8_tcxx . . $ uint8_t#* next_incxx . . $ $anonymous_type_2fa36e8c50d79419_2#next_in.; |
| 166 | size_t available_outcxx . . $ $anonymous_type_2fa36e8c50d79419_2#available_out.; |
| 167 | uint8_tcxx . . $ uint8_t#* next_outcxx . . $ $anonymous_type_2fa36e8c50d79419_2#next_out.; |
| 168 | |
| 169 | /* Reporting */ |
| 170 | /* size_t would be large enough, |
| 171 | until 4GiB+ files are compressed / decompressed on 32-bit CPUs. */ |
| 172 | size_t total_incxx . . $ $anonymous_type_2fa36e8c50d79419_2#total_in.; |
| 173 | size_t total_outcxx . . $ $anonymous_type_2fa36e8c50d79419_2#total_out.; |
| 174 | clock_tcxx . . $ clock_t# start_timecxx . . $ $anonymous_type_2fa36e8c50d79419_2#start_time.; |
| 175 | clock_tcxx . . $ clock_t# end_timecxx . . $ $anonymous_type_2fa36e8c50d79419_2#end_time.; |
| 176 | } Contextcxx . . $ Context#; |
| 177 | |
| 178 | /* Parse base 64 encoded string to buffer. Not performance-centric. |
| 179 | |out_len| as input is buffer size; |out_len| as output is decoded length. |
| 180 | Returns BROTLI_FALSE if either input is not (relaxed) base 64 conformant, |
| 181 | or output does not fit buffer. */ |
| 182 | static BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! ParseBase64cxx . . $ ParseBase64(bd6952e4d38265ae).(const char* str, uint8_tcxx . . $ uint8_t#* out, size_t* out_len) { |
| 183 | size_t in_len = strlencxx . . $ strlen(751346f8406fd082).(str); |
| 184 | size_t max_out_len = *out_len; |
| 185 | size_t i; |
| 186 | size_t bit_count = 0; |
| 187 | uint32_tcxx . . $ uint32_t# bits = 0; |
| 188 | size_t padding_count = 0; |
| 189 | size_t octet_count = 0; |
| 190 | for (i = 0; i < in_len; ++i) { |
| 191 | char c = str[i]; |
| 192 | int sextet = 0; |
| 193 | if (c == 9 || c == 10 || c == 13 || c == ' ') { |
| 194 | continue; |
| 195 | } |
| 196 | if (c == '=') { |
| 197 | padding_count++; |
| 198 | continue; |
| 199 | } |
| 200 | if (padding_count) return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 201 | if (c == '+' || c == '-') { |
| 202 | sextet = 62; |
| 203 | } else if (c == '/' || c == '_') { |
| 204 | sextet = 63; |
| 205 | } else if (c >= 'A' && c <= 'Z') { |
| 206 | sextet = c - 'A'; |
| 207 | } else if (c >= 'a' && c <= 'z') { |
| 208 | sextet = c - 'a' + 26; |
| 209 | } else if (c >= '0' && c <= '9') { |
| 210 | sextet = c - '0' + 52; |
| 211 | } else { |
| 212 | return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 213 | } |
| 214 | bits = (bits << 6) | (uint32_tcxx . . $ uint32_t#)sextet; |
| 215 | bit_count += 6; |
| 216 | if (bit_count >= 8) { |
| 217 | if (octet_count == max_out_len) return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 218 | bit_count -= 8; |
| 219 | out[octet_count++] = (bits >> bit_count) & 0xFF; |
| 220 | } |
| 221 | } |
| 222 | if (padding_count > 2) return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 223 | *out_len = octet_count; |
| 224 | return BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 225 | } |
| 226 | |
| 227 | /* Parse up to 5 decimal digits. */ |
| 228 | static BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! ParseIntcxx . . $ ParseInt(b3ffa29e2487c42f).(const char* s, int low, int high, int* result) { |
| 229 | int value = 0; |
| 230 | int i; |
| 231 | for (i = 0; i < 5; ++i) { |
| 232 | char c = s[i]; |
| 233 | if (c == 0) break; |
| 234 | if (s[i] < '0' || s[i] > '9') return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 235 | value = (10 * value) + (c - '0'); |
| 236 | } |
| 237 | if (i == 0) return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 238 | if (i > 1 && s[0] == '0') return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 239 | if (s[i] != 0) return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 240 | if (value < low || value > high) return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 241 | *result = value; |
| 242 | return BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 243 | } |
| 244 | |
| 245 | /* Returns "base file name" or its tail, if it contains '/' or '\'. */ |
| 246 | static const char* FileNamecxx . . $ FileName(fb58d2e09a2a1ce6).(const char* path) { |
| 247 | const char* separator_position = strrchrcxx . . $ strrchr(2050848944e00d54).(path, '/'); |
| 248 | if (separator_position) path = separator_position + 1; |
| 249 | separator_position = strrchrcxx . . $ strrchr(2050848944e00d54).(path, '\\'); |
| 250 | if (separator_position) path = separator_position + 1; |
| 251 | return path; |
| 252 | } |
| 253 | |
| 254 | /* Detect if the program name is a special alias that infers a command type. */ |
| 255 | static BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! CheckAliascxx . . $ CheckAlias(5ae29d726ae57f88).(const char* name, const char* alias) { |
| 256 | /* TODO: cast name to lower case? */ |
| 257 | size_t alias_len = strlencxx . . $ strlen(751346f8406fd082).(alias); |
| 258 | name = FileNamecxx . . $ FileName(fb58d2e09a2a1ce6).(name); |
| 259 | /* Partial comparison. On Windows there could be ".exe" suffix. */ |
| 260 | if (strncmpcxx . . $ strncmp(fd278af2f295fa2e).(name, alias, alias_len) == 0) { |
| 261 | char terminator = name[alias_len]; |
| 262 | if (terminator == 0 || terminator == '.') return BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 263 | } |
| 264 | return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 265 | } |
| 266 | |
| 267 | static Commandcxx . . $ Command# ParseParamscxx . . $ ParseParams(6d969980f8fd0953).(Contextcxx . . $ Context#* params) { |
| 268 | int argc = params->argccxx . . $ $anonymous_type_2fa36e8c50d79419_2#argc.; |
| 269 | char** argv = params->argvcxx . . $ $anonymous_type_2fa36e8c50d79419_2#argv.; |
| 270 | int i; |
| 271 | int next_option_index = 0; |
| 272 | size_t input_count = 0; |
| 273 | size_t longest_path_len = 1; |
| 274 | BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! command_set = BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 275 | BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! quality_set = BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 276 | BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! output_set = BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 277 | BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! keep_set = BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 278 | BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! squash_set = BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 279 | BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! lgwin_set = BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 280 | BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! suffix_set = BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 281 | BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! after_dash_dash = BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 282 | BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! comment_set = BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 283 | BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! concatenated_set = BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 284 | Commandcxx . . $ Command# command = COMMAND_COMPRESScxx . . $ COMMAND_COMPRESS.; |
| 285 | |
| 286 | if (CheckAliascxx . . $ CheckAlias(5ae29d726ae57f88).(argv[0], "brcat")) { |
| 287 | command_set = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 288 | command = COMMAND_DECOMPRESScxx . . $ COMMAND_DECOMPRESS.; |
| 289 | concatenated_set = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 290 | params->allow_concatenatedcxx . . $ $anonymous_type_2fa36e8c50d79419_2#allow_concatenated. = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 291 | output_set = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 292 | params->write_to_stdoutcxx . . $ $anonymous_type_2fa36e8c50d79419_2#write_to_stdout. = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 293 | } else if (CheckAliascxx . . $ CheckAlias(5ae29d726ae57f88).(argv[0], "unbrotli")) { |
| 294 | command_set = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 295 | command = COMMAND_DECOMPRESScxx . . $ COMMAND_DECOMPRESS.; |
| 296 | } |
| 297 | |
| 298 | for (i = 1; i < argc; ++i) { |
| 299 | const char* arg = argv[i]; |
| 300 | /* C99 5.1.2.2.1: "members argv[0] through argv[argc-1] inclusive shall |
| 301 | contain pointers to strings"; NULL and 0-length are not forbidden. */ |
| 302 | size_t arg_len = arg ? strlencxx . . $ strlen(751346f8406fd082).(arg) : 0; |
| 303 | |
| 304 | if (arg_len == 0) { |
| 305 | params->not_input_indicescxx . . $ $anonymous_type_2fa36e8c50d79419_2#not_input_indices.[next_option_index++] = i; |
| 306 | continue; |
| 307 | } |
| 308 | |
| 309 | /* Too many options. The expected longest option list is: |
| 310 | "-q 0 -w 10 -o f -D d -S b -d -f -k -n -v -K --", i.e. 17 items in total. |
| 311 | This check is an additional guard that is never triggered, but provides |
| 312 | a guard for future changes. */ |
| 313 | if (next_option_index > (MAX_OPTIONScxx . . $ `c/tools/brotli.c:115:9`! - 2)) { |
| 314 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "too many options passed\n"); |
| 315 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 316 | } |
| 317 | |
| 318 | /* Input file entry. */ |
| 319 | if (after_dash_dash || arg[0] != '-' || arg_len == 1) { |
| 320 | input_count++; |
| 321 | if (longest_path_len < arg_len) longest_path_len = arg_len; |
| 322 | continue; |
| 323 | } |
| 324 | |
| 325 | /* Not a file entry. */ |
| 326 | params->not_input_indicescxx . . $ $anonymous_type_2fa36e8c50d79419_2#not_input_indices.[next_option_index++] = i; |
| 327 | |
| 328 | /* '--' entry stop parsing arguments. */ |
| 329 | if (arg_len == 2 && arg[1] == '-') { |
| 330 | after_dash_dash = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 331 | continue; |
| 332 | } |
| 333 | |
| 334 | /* Simple / coalesced options. */ |
| 335 | if (arg[1] != '-') { |
| 336 | size_t j; |
| 337 | for (j = 1; j < arg_len; ++j) { |
| 338 | char c = arg[j]; |
| 339 | if (c >= '0' && c <= '9') { |
| 340 | if (quality_set) { |
| 341 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "quality already set\n"); |
| 342 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 343 | } |
| 344 | quality_set = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 345 | params->qualitycxx . . $ $anonymous_type_2fa36e8c50d79419_2#quality. = c - '0'; |
| 346 | continue; |
| 347 | } else if (c == 'c') { |
| 348 | if (output_set) { |
| 349 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "write to standard output already set\n"); |
| 350 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 351 | } |
| 352 | output_set = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 353 | params->write_to_stdoutcxx . . $ $anonymous_type_2fa36e8c50d79419_2#write_to_stdout. = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 354 | continue; |
| 355 | } else if (c == 'd') { |
| 356 | if (command_set) { |
| 357 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "command already set when parsing -d\n"); |
| 358 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 359 | } |
| 360 | command_set = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 361 | command = COMMAND_DECOMPRESScxx . . $ COMMAND_DECOMPRESS.; |
| 362 | continue; |
| 363 | } else if (c == 'f') { |
| 364 | if (params->force_overwritecxx . . $ $anonymous_type_2fa36e8c50d79419_2#force_overwrite.) { |
| 365 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "force output overwrite already set\n"); |
| 366 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 367 | } |
| 368 | params->force_overwritecxx . . $ $anonymous_type_2fa36e8c50d79419_2#force_overwrite. = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 369 | continue; |
| 370 | } else if (c == 'h') { |
| 371 | /* Don't parse further. */ |
| 372 | return COMMAND_HELPcxx . . $ COMMAND_HELP.; |
| 373 | } else if (c == 'j' || c == 'k') { |
| 374 | if (keep_set) { |
| 375 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "argument --rm / -j or --keep / -k already set\n"); |
| 376 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 377 | } |
| 378 | keep_set = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 379 | params->junk_sourcecxx . . $ $anonymous_type_2fa36e8c50d79419_2#junk_source. = TO_BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:55:9`!(c == 'j'); |
| 380 | continue; |
| 381 | } else if (c == 'n') { |
| 382 | if (!params->copy_statcxx . . $ $anonymous_type_2fa36e8c50d79419_2#copy_stat.) { |
| 383 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "argument --no-copy-stat / -n already set\n"); |
| 384 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 385 | } |
| 386 | params->copy_statcxx . . $ $anonymous_type_2fa36e8c50d79419_2#copy_stat. = BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 387 | continue; |
| 388 | } else if (c == 's') { |
| 389 | if (squash_set) { |
| 390 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "argument --squash / -s already set\n"); |
| 391 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 392 | } |
| 393 | squash_set = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 394 | params->reject_uncompressiblecxx . . $ $anonymous_type_2fa36e8c50d79419_2#reject_uncompressible. = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 395 | continue; |
| 396 | } else if (c == 't') { |
| 397 | if (command_set) { |
| 398 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "command already set when parsing -t\n"); |
| 399 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 400 | } |
| 401 | command_set = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 402 | command = COMMAND_TEST_INTEGRITYcxx . . $ COMMAND_TEST_INTEGRITY.; |
| 403 | continue; |
| 404 | } else if (c == 'v') { |
| 405 | if (params->verbositycxx . . $ $anonymous_type_2fa36e8c50d79419_2#verbosity. > 0) { |
| 406 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "argument --verbose / -v already set\n"); |
| 407 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 408 | } |
| 409 | params->verbositycxx . . $ $anonymous_type_2fa36e8c50d79419_2#verbosity. = 1; |
| 410 | continue; |
| 411 | } else if (c == 'K') { |
| 412 | if (concatenated_set) { |
| 413 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "argument -K / --concatenated already set\n"); |
| 414 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 415 | } |
| 416 | concatenated_set = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 417 | params->allow_concatenatedcxx . . $ $anonymous_type_2fa36e8c50d79419_2#allow_concatenated. = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 418 | continue; |
| 419 | } else if (c == 'V') { |
| 420 | /* Don't parse further. */ |
| 421 | return COMMAND_VERSIONcxx . . $ COMMAND_VERSION.; |
| 422 | } else if (c == 'Z') { |
| 423 | if (quality_set) { |
| 424 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "quality already set\n"); |
| 425 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 426 | } |
| 427 | quality_set = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 428 | params->qualitycxx . . $ $anonymous_type_2fa36e8c50d79419_2#quality. = 11; |
| 429 | continue; |
| 430 | } |
| 431 | /* o/q/w/C/D/S with parameter is expected */ |
| 432 | if (c != 'o' && c != 'q' && c != 'w' && c != 'C' && c != 'D' && |
| 433 | c != 'S') { |
| 434 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "invalid argument -%c\n", c); |
| 435 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 436 | } |
| 437 | if (j + 1 != arg_len) { |
| 438 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "expected parameter for argument -%c\n", c); |
| 439 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 440 | } |
| 441 | i++; |
| 442 | if (i == argc || !argv[i] || argv[i][0] == 0) { |
| 443 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "expected parameter for argument -%c\n", c); |
| 444 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 445 | } |
| 446 | params->not_input_indicescxx . . $ $anonymous_type_2fa36e8c50d79419_2#not_input_indices.[next_option_index++] = i; |
| 447 | if (c == 'o') { |
| 448 | if (output_set) { |
| 449 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "write to standard output already set (-o)\n"); |
| 450 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 451 | } |
| 452 | params->output_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#output_path. = argv[i]; |
| 453 | } else if (c == 'q') { |
| 454 | if (quality_set) { |
| 455 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "quality already set\n"); |
| 456 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 457 | } |
| 458 | quality_set = ParseIntcxx . . $ ParseInt(b3ffa29e2487c42f).(argv[i], BROTLI_MIN_QUALITYcxx . . $ `c/include/brotli/encode.h:41:9`!, |
| 459 | BROTLI_MAX_QUALITYcxx . . $ `c/include/brotli/encode.h:43:9`!, ¶ms->qualitycxx . . $ $anonymous_type_2fa36e8c50d79419_2#quality.); |
| 460 | if (!quality_set) { |
| 461 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "error parsing quality value [%s]\n", argv[i]); |
| 462 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 463 | } |
| 464 | } else if (c == 'w') { |
| 465 | if (lgwin_set) { |
| 466 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "lgwin parameter already set\n"); |
| 467 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 468 | } |
| 469 | lgwin_set = ParseIntcxx . . $ ParseInt(b3ffa29e2487c42f).(argv[i], 0, |
| 470 | BROTLI_MAX_WINDOW_BITScxx . . $ `c/include/brotli/encode.h:30:9`!, ¶ms->lgwincxx . . $ $anonymous_type_2fa36e8c50d79419_2#lgwin.); |
| 471 | if (!lgwin_set) { |
| 472 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "error parsing lgwin value [%s]\n", argv[i]); |
| 473 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 474 | } |
| 475 | if (params->lgwincxx . . $ $anonymous_type_2fa36e8c50d79419_2#lgwin. != 0 && params->lgwincxx . . $ $anonymous_type_2fa36e8c50d79419_2#lgwin. < BROTLI_MIN_WINDOW_BITScxx . . $ `c/include/brotli/encode.h:24:9`!) { |
| 476 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, |
| 477 | "lgwin parameter (%d) smaller than the minimum (%d)\n", |
| 478 | params->lgwincxx . . $ $anonymous_type_2fa36e8c50d79419_2#lgwin., BROTLI_MIN_WINDOW_BITScxx . . $ `c/include/brotli/encode.h:24:9`!); |
| 479 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 480 | } |
| 481 | } else if (c == 'C') { |
| 482 | if (comment_set) { |
| 483 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "comment already set\n"); |
| 484 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 485 | } |
| 486 | params->comment_lencxx . . $ $anonymous_type_2fa36e8c50d79419_2#comment_len. = MAX_COMMENT_LENcxx . . $ `c/tools/brotli.c:116:9`!; |
| 487 | if (!ParseBase64cxx . . $ ParseBase64(bd6952e4d38265ae).(argv[i], params->commentcxx . . $ $anonymous_type_2fa36e8c50d79419_2#comment., ¶ms->comment_lencxx . . $ $anonymous_type_2fa36e8c50d79419_2#comment_len.)) { |
| 488 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "invalid base64-encoded comment\n"); |
| 489 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 490 | } |
| 491 | comment_set = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 492 | } else if (c == 'D') { |
| 493 | if (params->dictionary_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#dictionary_path.) { |
| 494 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "dictionary path already set\n"); |
| 495 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 496 | } |
| 497 | params->dictionary_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#dictionary_path. = argv[i]; |
| 498 | } else if (c == 'S') { |
| 499 | if (suffix_set) { |
| 500 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "suffix already set\n"); |
| 501 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 502 | } |
| 503 | suffix_set = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 504 | params->suffixcxx . . $ $anonymous_type_2fa36e8c50d79419_2#suffix. = argv[i]; |
| 505 | } |
| 506 | } |
| 507 | } else { /* Double-dash. */ |
| 508 | arg = &arg[2]; |
| 509 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).("best", arg) == 0) { |
| 510 | if (quality_set) { |
| 511 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "quality already set\n"); |
| 512 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 513 | } |
| 514 | quality_set = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 515 | params->qualitycxx . . $ $anonymous_type_2fa36e8c50d79419_2#quality. = 11; |
| 516 | } else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).("concatenated", arg) == 0) { |
| 517 | if (concatenated_set) { |
| 518 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "argument -K / --concatenated already set\n"); |
| 519 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 520 | } |
| 521 | concatenated_set = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 522 | params->allow_concatenatedcxx . . $ $anonymous_type_2fa36e8c50d79419_2#allow_concatenated. = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 523 | continue; |
| 524 | } else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).("decompress", arg) == 0) { |
| 525 | if (command_set) { |
| 526 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "command already set when parsing --decompress\n"); |
| 527 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 528 | } |
| 529 | command_set = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 530 | command = COMMAND_DECOMPRESScxx . . $ COMMAND_DECOMPRESS.; |
| 531 | } else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).("force", arg) == 0) { |
| 532 | if (params->force_overwritecxx . . $ $anonymous_type_2fa36e8c50d79419_2#force_overwrite.) { |
| 533 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "force output overwrite already set\n"); |
| 534 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 535 | } |
| 536 | params->force_overwritecxx . . $ $anonymous_type_2fa36e8c50d79419_2#force_overwrite. = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 537 | } else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).("help", arg) == 0) { |
| 538 | /* Don't parse further. */ |
| 539 | return COMMAND_HELPcxx . . $ COMMAND_HELP.; |
| 540 | } else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).("keep", arg) == 0) { |
| 541 | if (keep_set) { |
| 542 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "argument --rm / -j or --keep / -k already set\n"); |
| 543 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 544 | } |
| 545 | keep_set = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 546 | params->junk_sourcecxx . . $ $anonymous_type_2fa36e8c50d79419_2#junk_source. = BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 547 | } else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).("no-copy-stat", arg) == 0) { |
| 548 | if (!params->copy_statcxx . . $ $anonymous_type_2fa36e8c50d79419_2#copy_stat.) { |
| 549 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "argument --no-copy-stat / -n already set\n"); |
| 550 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 551 | } |
| 552 | params->copy_statcxx . . $ $anonymous_type_2fa36e8c50d79419_2#copy_stat. = BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 553 | } else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).("rm", arg) == 0) { |
| 554 | if (keep_set) { |
| 555 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "argument --rm / -j or --keep / -k already set\n"); |
| 556 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 557 | } |
| 558 | keep_set = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 559 | params->junk_sourcecxx . . $ $anonymous_type_2fa36e8c50d79419_2#junk_source. = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 560 | } else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).("squash", arg) == 0) { |
| 561 | if (squash_set) { |
| 562 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "argument --squash / -s already set\n"); |
| 563 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 564 | } |
| 565 | squash_set = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 566 | params->reject_uncompressiblecxx . . $ $anonymous_type_2fa36e8c50d79419_2#reject_uncompressible. = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 567 | continue; |
| 568 | } else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).("stdout", arg) == 0) { |
| 569 | if (output_set) { |
| 570 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "write to standard output already set\n"); |
| 571 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 572 | } |
| 573 | output_set = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 574 | params->write_to_stdoutcxx . . $ $anonymous_type_2fa36e8c50d79419_2#write_to_stdout. = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 575 | } else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).("test", arg) == 0) { |
| 576 | if (command_set) { |
| 577 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "command already set when parsing --test\n"); |
| 578 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 579 | } |
| 580 | command_set = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 581 | command = COMMAND_TEST_INTEGRITYcxx . . $ COMMAND_TEST_INTEGRITY.; |
| 582 | } else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).("verbose", arg) == 0) { |
| 583 | if (params->verbositycxx . . $ $anonymous_type_2fa36e8c50d79419_2#verbosity. > 0) { |
| 584 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "argument --verbose / -v already set\n"); |
| 585 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 586 | } |
| 587 | params->verbositycxx . . $ $anonymous_type_2fa36e8c50d79419_2#verbosity. = 1; |
| 588 | } else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).("version", arg) == 0) { |
| 589 | /* Don't parse further. */ |
| 590 | return COMMAND_VERSIONcxx . . $ COMMAND_VERSION.; |
| 591 | } else { |
| 592 | /* key=value */ |
| 593 | const char* value = strchrcxx . . $ strchr(2050848944e00d54).(arg, '='); |
| 594 | size_t key_len; |
| 595 | if (!value || value[1] == 0) { |
| 596 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "must pass the parameter as --%s=value\n", arg); |
| 597 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 598 | } |
| 599 | key_len = (size_t)(value - arg); |
| 600 | value++; |
| 601 | if (strncmpcxx . . $ strncmp(fd278af2f295fa2e).("comment", arg, key_len) == 0) { |
| 602 | if (comment_set) { |
| 603 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "comment already set\n"); |
| 604 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 605 | } |
| 606 | params->comment_lencxx . . $ $anonymous_type_2fa36e8c50d79419_2#comment_len. = MAX_COMMENT_LENcxx . . $ `c/tools/brotli.c:116:9`!; |
| 607 | if (!ParseBase64cxx . . $ ParseBase64(bd6952e4d38265ae).(value, params->commentcxx . . $ $anonymous_type_2fa36e8c50d79419_2#comment., ¶ms->comment_lencxx . . $ $anonymous_type_2fa36e8c50d79419_2#comment_len.)) { |
| 608 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "invalid base64-encoded comment\n"); |
| 609 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 610 | } |
| 611 | comment_set = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 612 | } else if (strncmpcxx . . $ strncmp(fd278af2f295fa2e).("dictionary", arg, key_len) == 0) { |
| 613 | if (params->dictionary_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#dictionary_path.) { |
| 614 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "dictionary path already set\n"); |
| 615 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 616 | } |
| 617 | params->dictionary_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#dictionary_path. = value; |
| 618 | } else if (strncmpcxx . . $ strncmp(fd278af2f295fa2e).("lgwin", arg, key_len) == 0) { |
| 619 | if (lgwin_set) { |
| 620 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "lgwin parameter already set\n"); |
| 621 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 622 | } |
| 623 | lgwin_set = ParseIntcxx . . $ ParseInt(b3ffa29e2487c42f).(value, 0, |
| 624 | BROTLI_MAX_WINDOW_BITScxx . . $ `c/include/brotli/encode.h:30:9`!, ¶ms->lgwincxx . . $ $anonymous_type_2fa36e8c50d79419_2#lgwin.); |
| 625 | if (!lgwin_set) { |
| 626 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "error parsing lgwin value [%s]\n", value); |
| 627 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 628 | } |
| 629 | if (params->lgwincxx . . $ $anonymous_type_2fa36e8c50d79419_2#lgwin. != 0 && params->lgwincxx . . $ $anonymous_type_2fa36e8c50d79419_2#lgwin. < BROTLI_MIN_WINDOW_BITScxx . . $ `c/include/brotli/encode.h:24:9`!) { |
| 630 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, |
| 631 | "lgwin parameter (%d) smaller than the minimum (%d)\n", |
| 632 | params->lgwincxx . . $ $anonymous_type_2fa36e8c50d79419_2#lgwin., BROTLI_MIN_WINDOW_BITScxx . . $ `c/include/brotli/encode.h:24:9`!); |
| 633 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 634 | } |
| 635 | } else if (strncmpcxx . . $ strncmp(fd278af2f295fa2e).("large_window", arg, key_len) == 0) { |
| 636 | /* This option is intentionally not mentioned in help. */ |
| 637 | if (lgwin_set) { |
| 638 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "lgwin parameter already set\n"); |
| 639 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 640 | } |
| 641 | lgwin_set = ParseIntcxx . . $ ParseInt(b3ffa29e2487c42f).(value, 0, |
| 642 | BROTLI_LARGE_MAX_WINDOW_BITScxx . . $ `c/include/brotli/encode.h:35:9`!, ¶ms->lgwincxx . . $ $anonymous_type_2fa36e8c50d79419_2#lgwin.); |
| 643 | if (!lgwin_set) { |
| 644 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "error parsing lgwin value [%s]\n", value); |
| 645 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 646 | } |
| 647 | if (params->lgwincxx . . $ $anonymous_type_2fa36e8c50d79419_2#lgwin. != 0 && params->lgwincxx . . $ $anonymous_type_2fa36e8c50d79419_2#lgwin. < BROTLI_MIN_WINDOW_BITScxx . . $ `c/include/brotli/encode.h:24:9`!) { |
| 648 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, |
| 649 | "lgwin parameter (%d) smaller than the minimum (%d)\n", |
| 650 | params->lgwincxx . . $ $anonymous_type_2fa36e8c50d79419_2#lgwin., BROTLI_MIN_WINDOW_BITScxx . . $ `c/include/brotli/encode.h:24:9`!); |
| 651 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 652 | } |
| 653 | } else if (strncmpcxx . . $ strncmp(fd278af2f295fa2e).("output", arg, key_len) == 0) { |
| 654 | if (output_set) { |
| 655 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, |
| 656 | "write to standard output already set (--output)\n"); |
| 657 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 658 | } |
| 659 | params->output_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#output_path. = value; |
| 660 | } else if (strncmpcxx . . $ strncmp(fd278af2f295fa2e).("quality", arg, key_len) == 0) { |
| 661 | if (quality_set) { |
| 662 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "quality already set\n"); |
| 663 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 664 | } |
| 665 | quality_set = ParseIntcxx . . $ ParseInt(b3ffa29e2487c42f).(value, BROTLI_MIN_QUALITYcxx . . $ `c/include/brotli/encode.h:41:9`!, |
| 666 | BROTLI_MAX_QUALITYcxx . . $ `c/include/brotli/encode.h:43:9`!, ¶ms->qualitycxx . . $ $anonymous_type_2fa36e8c50d79419_2#quality.); |
| 667 | if (!quality_set) { |
| 668 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "error parsing quality value [%s]\n", value); |
| 669 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 670 | } |
| 671 | } else if (strncmpcxx . . $ strncmp(fd278af2f295fa2e).("suffix", arg, key_len) == 0) { |
| 672 | if (suffix_set) { |
| 673 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "suffix already set\n"); |
| 674 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 675 | } |
| 676 | suffix_set = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 677 | params->suffixcxx . . $ $anonymous_type_2fa36e8c50d79419_2#suffix. = value; |
| 678 | } else { |
| 679 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "invalid parameter: [%s]\n", arg); |
| 680 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 681 | } |
| 682 | } |
| 683 | } |
| 684 | } |
| 685 | |
| 686 | params->input_countcxx . . $ $anonymous_type_2fa36e8c50d79419_2#input_count. = input_count; |
| 687 | params->longest_path_lencxx . . $ $anonymous_type_2fa36e8c50d79419_2#longest_path_len. = longest_path_len; |
| 688 | params->decompresscxx . . $ $anonymous_type_2fa36e8c50d79419_2#decompress. = (command == COMMAND_DECOMPRESScxx . . $ COMMAND_DECOMPRESS.); |
| 689 | params->test_integritycxx . . $ $anonymous_type_2fa36e8c50d79419_2#test_integrity. = (command == COMMAND_TEST_INTEGRITYcxx . . $ COMMAND_TEST_INTEGRITY.); |
| 690 | |
| 691 | if (input_count > 1 && output_set) return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 692 | if (params->test_integritycxx . . $ $anonymous_type_2fa36e8c50d79419_2#test_integrity.) { |
| 693 | if (params->output_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#output_path.) return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 694 | if (params->write_to_stdoutcxx . . $ $anonymous_type_2fa36e8c50d79419_2#write_to_stdout.) return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 695 | } |
| 696 | if (params->reject_uncompressiblecxx . . $ $anonymous_type_2fa36e8c50d79419_2#reject_uncompressible. && params->write_to_stdoutcxx . . $ $anonymous_type_2fa36e8c50d79419_2#write_to_stdout.) { |
| 697 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 698 | } |
| 699 | if (strchrcxx . . $ strchr(2050848944e00d54).(params->suffixcxx . . $ $anonymous_type_2fa36e8c50d79419_2#suffix., '/') || strchrcxx . . $ strchr(2050848944e00d54).(params->suffixcxx . . $ $anonymous_type_2fa36e8c50d79419_2#suffix., '\\')) { |
| 700 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 701 | } |
| 702 | if (!params->decompresscxx . . $ $anonymous_type_2fa36e8c50d79419_2#decompress. && params->allow_concatenatedcxx . . $ $anonymous_type_2fa36e8c50d79419_2#allow_concatenated.) { |
| 703 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 704 | } |
| 705 | if (params->allow_concatenatedcxx . . $ $anonymous_type_2fa36e8c50d79419_2#allow_concatenated. && params->comment_lencxx . . $ $anonymous_type_2fa36e8c50d79419_2#comment_len.) { |
| 706 | return COMMAND_INVALIDcxx . . $ COMMAND_INVALID.; |
| 707 | } |
| 708 | |
| 709 | return command; |
| 710 | } |
| 711 | |
| 712 | static void PrintVersioncxx . . $ PrintVersion(49f6e7a06ebc5aa8).(void) { |
| 713 | int major = BROTLI_VERSION_MAJORcxx . . $ `c/common/version.h:20:9`!; |
| 714 | int minor = BROTLI_VERSION_MINORcxx . . $ `c/common/version.h:21:9`!; |
| 715 | int patch = BROTLI_VERSION_PATCHcxx . . $ `c/common/version.h:22:9`!; |
| 716 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:158:9`!, "brotli %d.%d.%d\n", major, minor, patch); |
| 717 | } |
| 718 | |
| 719 | static void PrintHelpcxx . . $ PrintHelp(34d26762b42c433a).(const char* name, BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! error) { |
| 720 | FILEcxx . . $ FILE#* media = error ? stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`! : stdoutcxx . . $ `<external>/232824719582829767/stdio.h:158:9`!; |
| 721 | /* String is cut to pieces with length less than 509, to conform C90 spec. */ |
| 722 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(media, |
| 723 | "Usage: %s [OPTION]... [FILE]...\n", |
| 724 | name); |
| 725 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(media, |
| 726 | "Options:\n" |
| 727 | " -# compression level (0-9)\n" |
| 728 | " -c, --stdout write on standard output\n" |
| 729 | " -d, --decompress decompress\n" |
| 730 | " -f, --force force output file overwrite\n" |
| 731 | " -h, --help display this help and exit\n"); |
| 732 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(media, |
| 733 | " -j, --rm remove source file(s)\n" |
| 734 | " -s, --squash remove destination file if larger than source\n" |
| 735 | " -k, --keep keep source file(s) (default)\n" |
| 736 | " -n, --no-copy-stat do not copy source file(s) attributes\n" |
| 737 | " -o FILE, --output=FILE output file (only if 1 input file)\n"); |
| 738 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(media, |
| 739 | " -q NUM, --quality=NUM compression level (%d-%d)\n", |
| 740 | BROTLI_MIN_QUALITYcxx . . $ `c/include/brotli/encode.h:41:9`!, BROTLI_MAX_QUALITYcxx . . $ `c/include/brotli/encode.h:43:9`!); |
| 741 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(media, |
| 742 | " -t, --test test compressed file integrity\n" |
| 743 | " -v, --verbose verbose mode\n"); |
| 744 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(media, |
| 745 | " -w NUM, --lgwin=NUM set LZ77 window size (0, %d-%d)\n" |
| 746 | " window size = 2**NUM - 16\n" |
| 747 | " 0 lets compressor choose the optimal value\n", |
| 748 | BROTLI_MIN_WINDOW_BITScxx . . $ `c/include/brotli/encode.h:24:9`!, BROTLI_MAX_WINDOW_BITScxx . . $ `c/include/brotli/encode.h:30:9`!); |
| 749 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(media, |
| 750 | " --large_window=NUM use incompatible large-window brotli\n" |
| 751 | " bitstream with window size (0, %d-%d)\n" |
| 752 | " WARNING: this format is not compatible\n" |
| 753 | " with brotli RFC 7932 and may not be\n" |
| 754 | " decodable with regular brotli decoders\n", |
| 755 | BROTLI_MIN_WINDOW_BITScxx . . $ `c/include/brotli/encode.h:24:9`!, BROTLI_LARGE_MAX_WINDOW_BITScxx . . $ `c/include/brotli/encode.h:35:9`!); |
| 756 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(media, |
| 757 | " -C B64, --comment=B64 set comment; argument is base64-decoded first;\n" |
| 758 | " (maximal decoded length: %d)\n" |
| 759 | " when decoding: check stream comment;\n" |
| 760 | " when encoding: embed comment (fingerprint)\n", |
| 761 | MAX_COMMENT_LENcxx . . $ `c/tools/brotli.c:116:9`!); |
| 762 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(media, |
| 763 | " -D FILE, --dictionary=FILE use FILE as raw (LZ77) dictionary\n" |
| 764 | " -K, --concatenated allows concatenated brotli streams as input\n"); |
| 765 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(media, |
| 766 | " -S SUF, --suffix=SUF output file suffix (default:'%s')\n", |
| 767 | DEFAULT_SUFFIXcxx . . $ `c/tools/brotli.c:114:9`!); |
| 768 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(media, |
| 769 | " -V, --version display version and exit\n" |
| 770 | " -Z, --best use best compression level (11) (default)\n" |
| 771 | "Simple options could be coalesced, i.e. '-9kf' is equivalent to '-9 -k -f'.\n" |
| 772 | "With no FILE, or when FILE is -, read standard input.\n" |
| 773 | "All arguments after '--' are treated as files.\n"); |
| 774 | } |
| 775 | |
| 776 | static const char* PrintablePathcxx . . $ PrintablePath(fb58d2e09a2a1ce6).(const char* path) { |
| 777 | return path ? path : "con"; |
| 778 | } |
| 779 | |
| 780 | static BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! OpenInputFilecxx . . $ OpenInputFile(42b3e5d80c6aa09f).(const char* input_path, FILEcxx . . $ FILE#** f) { |
| 781 | *f = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!; |
| 782 | if (!input_path) { |
| 783 | *f = fdopencxx . . $ fdopen(8f4e2d7350ebd077).(MAKE_BINARYcxx . . $ `c/tools/brotli.c:75:9`!(STDIN_FILENOcxx . . $ `<external>/12628407106812493757/unistd.h:210:9`!), "rb"); |
| 784 | return BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 785 | } |
| 786 | *f = fopencxx . . $ fopen(82ec0787cd37e0a3).(input_path, "rb"); |
| 787 | if (!*f) { |
| 788 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "failed to open input file [%s]: %s\n", |
| 789 | PrintablePathcxx . . $ PrintablePath(fb58d2e09a2a1ce6).(input_path), strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 790 | return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 791 | } |
| 792 | return BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 793 | } |
| 794 | |
| 795 | static BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! OpenOutputFilecxx . . $ OpenOutputFile(dd5faff425e696c9).(const char* output_path, FILEcxx . . $ FILE#** f, |
| 796 | BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! force) { |
| 797 | int fd; |
| 798 | *f = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!; |
| 799 | if (!output_path) { |
| 800 | *f = fdopencxx . . $ fdopen(8f4e2d7350ebd077).(MAKE_BINARYcxx . . $ `c/tools/brotli.c:75:9`!(STDOUT_FILENOcxx . . $ `<external>/12628407106812493757/unistd.h:211:9`!), "wb"); |
| 801 | return BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 802 | } |
| 803 | fd = opencxx . . $ open(e156e3aa1e5c4ad1).(output_path, O_CREATcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:47:10`! | (force ? 0 : O_EXCLcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:50:10`!) | O_WRONLYcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:44:9`! | O_TRUNCcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:56:10`!, |
| 804 | S_IRUSRcxx . . $ `<external>/531885356569766532/stat.h:168:9`! | S_IWUSRcxx . . $ `<external>/531885356569766532/stat.h:169:9`!); |
| 805 | if (fd < 0) { |
| 806 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "failed to open output file [%s]: %s\n", |
| 807 | PrintablePathcxx . . $ PrintablePath(fb58d2e09a2a1ce6).(output_path), strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 808 | return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 809 | } |
| 810 | *f = fdopencxx . . $ fdopen(8f4e2d7350ebd077).(fd, "wb"); |
| 811 | if (!*f) { |
| 812 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "failed to open output file [%s]: %s\n", |
| 813 | PrintablePathcxx . . $ PrintablePath(fb58d2e09a2a1ce6).(output_path), strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 814 | return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 815 | } |
| 816 | return BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 817 | } |
| 818 | |
| 819 | static int64_tcxx . . $ int64_t# FileSizecxx . . $ FileSize(3c95bd14d5d5d286).(const char* path) { |
| 820 | FILEcxx . . $ FILE#* f = fopencxx . . $ fopen(82ec0787cd37e0a3).(path, "rb"); |
| 821 | int64_tcxx . . $ int64_t# retval; |
| 822 | if (f == NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!) { |
| 823 | return -1; |
| 824 | } |
| 825 | if (fseekcxx . . $ fseek(543fae30d249f6b1).(f, 0L, SEEK_ENDcxx . . $ `<external>/232824719582829767/stdio.h:116:9`!) != 0) { |
| 826 | fclosecxx . . $ fclose(89bc1efcdac0ca22).(f); |
| 827 | return -1; |
| 828 | } |
| 829 | retval = ftellcxx . . $ ftell(1dcafcd8ef4c6e6c).(f); |
| 830 | if (fclosecxx . . $ fclose(89bc1efcdac0ca22).(f) != 0) { |
| 831 | return -1; |
| 832 | } |
| 833 | return retval; |
| 834 | } |
| 835 | |
| 836 | static int CopyTimeStatcxx . . $ CopyTimeStat(92ad11e952c5e2b5).(const struct statcxx . . $ stat#* statbuf, const char* output_path) { |
| 837 | #if HAVE_UTIMENSATcxx . . $ `c/tools/brotli.c:79:9`! |
| 838 | struct timespeccxx . . $ timespec# times[2]; |
| 839 | times[0].tv_seccxx . . $ timespec#tv_sec. = statbuf->st_atimecxx . . $ `<external>/16045971866008360577/struct_stat.h:77:11`!; |
| 840 | times[0].tv_nseccxx . . $ timespec#tv_nsec. = ATIME_NSECcxx . . $ `c/tools/brotli.c:91:9`!(statbuf); |
| 841 | times[1].tv_seccxx . . $ timespec#tv_sec. = statbuf->st_mtimecxx . . $ `<external>/16045971866008360577/struct_stat.h:78:11`!; |
| 842 | times[1].tv_nseccxx . . $ timespec#tv_nsec. = MTIME_NSECcxx . . $ `c/tools/brotli.c:92:9`!(statbuf); |
| 843 | return utimensatcxx . . $ utimensat(4a13aa223d843c59).(AT_FDCWDcxx . . $ `<external>/14710646456994434043/fcntl.h:149:10`!, output_path, times, AT_SYMLINK_NOFOLLOWcxx . . $ `<external>/14710646456994434043/fcntl.h:152:10`!); |
| 844 | #else |
| 845 | struct utimbuf times; |
| 846 | times.actime = statbuf->st_atime; |
| 847 | times.modtime = statbuf->st_mtime; |
| 848 | return utime(output_path, ×); |
| 849 | #endif |
| 850 | } |
| 851 | |
| 852 | /* Copy file times and permissions. |
| 853 | TODO(eustas): this is a "best effort" implementation; honest cross-platform |
| 854 | fully featured implementation is way too hacky; add more hacks by request. */ |
| 855 | static void CopyStatcxx . . $ CopyStat(2fa786934fe80e24).(const char* input_path, const char* output_path) { |
| 856 | struct statcxx . . $ stat# statbuf; |
| 857 | int res; |
| 858 | if (input_path == 0 || output_path == 0) { |
| 859 | return; |
| 860 | } |
| 861 | if (statcxx . . $ stat(a9cd1e23e96f423c).(input_path, &statbuf) != 0) { |
| 862 | return; |
| 863 | } |
| 864 | res = CopyTimeStatcxx . . $ CopyTimeStat(92ad11e952c5e2b5).(&statbuf, output_path); |
| 865 | res = chmodcxx . . $ chmod(1df18506ef0a631b).(output_path, statbuf.st_modecxx . . $ stat#st_mode. & (S_IRWXUcxx . . $ `<external>/531885356569766532/stat.h:172:9`! | S_IRWXGcxx . . $ `<external>/531885356569766532/stat.h:184:9`! | S_IRWXOcxx . . $ `<external>/531885356569766532/stat.h:190:9`!)); |
| 866 | if (res != 0) { |
| 867 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "setting access bits failed for [%s]: %s\n", |
| 868 | PrintablePathcxx . . $ PrintablePath(fb58d2e09a2a1ce6).(output_path), strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 869 | } |
| 870 | res = chowncxx . . $ chown(a017fb26b85e77bb).(output_path, (uid_tcxx . . $ uid_t#)-1, statbuf.st_gidcxx . . $ stat#st_gid.); |
| 871 | if (res != 0) { |
| 872 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "setting group failed for [%s]: %s\n", |
| 873 | PrintablePathcxx . . $ PrintablePath(fb58d2e09a2a1ce6).(output_path), strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 874 | } |
| 875 | res = chowncxx . . $ chown(a017fb26b85e77bb).(output_path, statbuf.st_uidcxx . . $ stat#st_uid., (gid_tcxx . . $ gid_t#)-1); |
| 876 | if (res != 0) { |
| 877 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "setting user failed for [%s]: %s\n", |
| 878 | PrintablePathcxx . . $ PrintablePath(fb58d2e09a2a1ce6).(output_path), strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 879 | } |
| 880 | } |
| 881 | |
| 882 | /* Result ownership is passed to caller. |
| 883 | |*dictionary_size| is set to resulting buffer size. */ |
| 884 | static BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! ReadDictionarycxx . . $ ReadDictionary(6f1c2f27c0d20675).(Contextcxx . . $ Context#* context, Commandcxx . . $ Command# command) { |
| 885 | static const int kMaxDictionarySize = |
| 886 | BROTLI_MAX_DISTANCEcxx . . $ `c/common/constants.h:78:9`! - BROTLI_MAX_BACKWARD_LIMITcxx . . $ `c/common/constants.h:101:9`!(24); |
| 887 | FILEcxx . . $ FILE#* f; |
| 888 | int64_tcxx . . $ int64_t# file_size_64; |
| 889 | uint8_tcxx . . $ uint8_t#* buffer; |
| 890 | size_t bytes_read; |
| 891 | |
| 892 | if (context->dictionary_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#dictionary_path. == NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!) return BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 893 | f = fopencxx . . $ fopen(82ec0787cd37e0a3).(context->dictionary_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#dictionary_path., "rb"); |
| 894 | if (f == NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!) { |
| 895 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "failed to open dictionary file [%s]: %s\n", |
| 896 | PrintablePathcxx . . $ PrintablePath(fb58d2e09a2a1ce6).(context->dictionary_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#dictionary_path.), strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 897 | return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 898 | } |
| 899 | |
| 900 | file_size_64 = FileSizecxx . . $ FileSize(3c95bd14d5d5d286).(context->dictionary_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#dictionary_path.); |
| 901 | if (file_size_64 == -1) { |
| 902 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "could not get size of dictionary file [%s]", |
| 903 | PrintablePathcxx . . $ PrintablePath(fb58d2e09a2a1ce6).(context->dictionary_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#dictionary_path.)); |
| 904 | fclosecxx . . $ fclose(89bc1efcdac0ca22).(f); |
| 905 | return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 906 | } |
| 907 | |
| 908 | if (file_size_64 > kMaxDictionarySize) { |
| 909 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "dictionary [%s] is larger than maximum allowed: %d\n", |
| 910 | PrintablePathcxx . . $ PrintablePath(fb58d2e09a2a1ce6).(context->dictionary_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#dictionary_path.), kMaxDictionarySize); |
| 911 | fclosecxx . . $ fclose(89bc1efcdac0ca22).(f); |
| 912 | return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 913 | } |
| 914 | context->dictionary_sizecxx . . $ $anonymous_type_2fa36e8c50d79419_2#dictionary_size. = (size_t)file_size_64; |
| 915 | |
| 916 | buffer = (uint8_tcxx . . $ uint8_t#*)malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(context->dictionary_sizecxx . . $ $anonymous_type_2fa36e8c50d79419_2#dictionary_size.); |
| 917 | if (!buffer) { |
| 918 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "could not read dictionary: out of memory\n"); |
| 919 | fclosecxx . . $ fclose(89bc1efcdac0ca22).(f); |
| 920 | return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 921 | } |
| 922 | bytes_read = freadcxx . . $ fread(738fc8ac1d711e58).(buffer, sizeof(uint8_tcxx . . $ uint8_t#), context->dictionary_sizecxx . . $ $anonymous_type_2fa36e8c50d79419_2#dictionary_size., f); |
| 923 | if (bytes_read != context->dictionary_sizecxx . . $ $anonymous_type_2fa36e8c50d79419_2#dictionary_size.) { |
| 924 | freecxx . . $ free(5d22bdacc48458e8).(buffer); |
| 925 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "failed to read dictionary [%s]: %s\n", |
| 926 | PrintablePathcxx . . $ PrintablePath(fb58d2e09a2a1ce6).(context->dictionary_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#dictionary_path.), strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 927 | fclosecxx . . $ fclose(89bc1efcdac0ca22).(f); |
| 928 | return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 929 | } |
| 930 | fclosecxx . . $ fclose(89bc1efcdac0ca22).(f); |
| 931 | context->dictionarycxx . . $ $anonymous_type_2fa36e8c50d79419_2#dictionary. = buffer; |
| 932 | if (command == COMMAND_COMPRESScxx . . $ COMMAND_COMPRESS.) { |
| 933 | context->prepared_dictionarycxx . . $ $anonymous_type_2fa36e8c50d79419_2#prepared_dictionary. = BrotliEncoderPrepareDictionarycxx . . $ BrotliEncoderPrepareDictionary(bc56a703e43ec68a).( |
| 934 | BROTLI_SHARED_DICTIONARY_RAWcxx . . $ BROTLI_SHARED_DICTIONARY_RAW., context->dictionary_sizecxx . . $ $anonymous_type_2fa36e8c50d79419_2#dictionary_size., |
| 935 | context->dictionarycxx . . $ $anonymous_type_2fa36e8c50d79419_2#dictionary., BROTLI_MAX_QUALITYcxx . . $ `c/include/brotli/encode.h:43:9`!, NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!, NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!, NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!); |
| 936 | if (context->prepared_dictionarycxx . . $ $anonymous_type_2fa36e8c50d79419_2#prepared_dictionary. == NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!) { |
| 937 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "failed to prepare dictionary [%s]\n", |
| 938 | PrintablePathcxx . . $ PrintablePath(fb58d2e09a2a1ce6).(context->dictionary_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#dictionary_path.)); |
| 939 | return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 940 | } |
| 941 | } |
| 942 | return BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 943 | } |
| 944 | |
| 945 | static BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! NextFilecxx . . $ NextFile(bde9ac7206dc9e17).(Contextcxx . . $ Context#* context) { |
| 946 | const char* arg; |
| 947 | size_t arg_len; |
| 948 | |
| 949 | /* Iterator points to last used arg; increment to search for the next one. */ |
| 950 | context->iteratorcxx . . $ $anonymous_type_2fa36e8c50d79419_2#iterator.++; |
| 951 | |
| 952 | context->input_file_lengthcxx . . $ $anonymous_type_2fa36e8c50d79419_2#input_file_length. = -1; |
| 953 | |
| 954 | /* No input path; read from console. */ |
| 955 | if (context->input_countcxx . . $ $anonymous_type_2fa36e8c50d79419_2#input_count. == 0) { |
| 956 | if (context->iteratorcxx . . $ $anonymous_type_2fa36e8c50d79419_2#iterator. > 1) return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 957 | context->current_input_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#current_input_path. = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!; |
| 958 | /* Either write to the specified path, or to console. */ |
| 959 | context->current_output_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#current_output_path. = context->output_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#output_path.; |
| 960 | return BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 961 | } |
| 962 | |
| 963 | /* Skip option arguments. */ |
| 964 | while (context->iteratorcxx . . $ $anonymous_type_2fa36e8c50d79419_2#iterator. == context->not_input_indicescxx . . $ $anonymous_type_2fa36e8c50d79419_2#not_input_indices.[context->ignorecxx . . $ $anonymous_type_2fa36e8c50d79419_2#ignore.]) { |
| 965 | context->iteratorcxx . . $ $anonymous_type_2fa36e8c50d79419_2#iterator.++; |
| 966 | context->ignorecxx . . $ $anonymous_type_2fa36e8c50d79419_2#ignore.++; |
| 967 | } |
| 968 | |
| 969 | /* All args are scanned already. */ |
| 970 | if (context->iteratorcxx . . $ $anonymous_type_2fa36e8c50d79419_2#iterator. >= context->argccxx . . $ $anonymous_type_2fa36e8c50d79419_2#argc.) return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 971 | |
| 972 | /* Iterator now points to the input file name. */ |
| 973 | arg = context->argvcxx . . $ $anonymous_type_2fa36e8c50d79419_2#argv.[context->iteratorcxx . . $ $anonymous_type_2fa36e8c50d79419_2#iterator.]; |
| 974 | arg_len = strlencxx . . $ strlen(751346f8406fd082).(arg); |
| 975 | /* Read from console. */ |
| 976 | if (arg_len == 1 && arg[0] == '-') { |
| 977 | context->current_input_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#current_input_path. = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!; |
| 978 | context->current_output_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#current_output_path. = context->output_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#output_path.; |
| 979 | return BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 980 | } |
| 981 | |
| 982 | context->current_input_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#current_input_path. = arg; |
| 983 | context->input_file_lengthcxx . . $ $anonymous_type_2fa36e8c50d79419_2#input_file_length. = FileSizecxx . . $ FileSize(3c95bd14d5d5d286).(arg); |
| 984 | context->current_output_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#current_output_path. = context->output_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#output_path.; |
| 985 | |
| 986 | if (context->output_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#output_path.) return BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 987 | if (context->write_to_stdoutcxx . . $ $anonymous_type_2fa36e8c50d79419_2#write_to_stdout.) return BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 988 | |
| 989 | strcpycxx . . $ strcpy(b7b3a83273496486).(context->modified_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#modified_path., arg); |
| 990 | context->current_output_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#current_output_path. = context->modified_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#modified_path.; |
| 991 | /* If output is not specified, input path suffix should match. */ |
| 992 | if (context->decompresscxx . . $ $anonymous_type_2fa36e8c50d79419_2#decompress.) { |
| 993 | size_t suffix_len = strlencxx . . $ strlen(751346f8406fd082).(context->suffixcxx . . $ $anonymous_type_2fa36e8c50d79419_2#suffix.); |
| 994 | char* name = (char*)FileNamecxx . . $ FileName(fb58d2e09a2a1ce6).(context->modified_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#modified_path.); |
| 995 | char* name_suffix; |
| 996 | size_t name_len = strlencxx . . $ strlen(751346f8406fd082).(name); |
| 997 | if (name_len < suffix_len + 1) { |
| 998 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "empty output file name for [%s] input file\n", |
| 999 | PrintablePathcxx . . $ PrintablePath(fb58d2e09a2a1ce6).(arg)); |
| 1000 | context->iterator_errorcxx . . $ $anonymous_type_2fa36e8c50d79419_2#iterator_error. = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 1001 | return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 1002 | } |
| 1003 | name_suffix = name + name_len - suffix_len; |
| 1004 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(context->suffixcxx . . $ $anonymous_type_2fa36e8c50d79419_2#suffix., name_suffix) != 0) { |
| 1005 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "input file [%s] suffix mismatch\n", |
| 1006 | PrintablePathcxx . . $ PrintablePath(fb58d2e09a2a1ce6).(arg)); |
| 1007 | context->iterator_errorcxx . . $ $anonymous_type_2fa36e8c50d79419_2#iterator_error. = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 1008 | return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 1009 | } |
| 1010 | name_suffix[0] = 0; |
| 1011 | return BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 1012 | } else { |
| 1013 | strcpycxx . . $ strcpy(b7b3a83273496486).(context->modified_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#modified_path. + arg_len, context->suffixcxx . . $ $anonymous_type_2fa36e8c50d79419_2#suffix.); |
| 1014 | return BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 1015 | } |
| 1016 | } |
| 1017 | |
| 1018 | static BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! OpenFilescxx . . $ OpenFiles(bde9ac7206dc9e17).(Contextcxx . . $ Context#* context) { |
| 1019 | BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! is_ok = OpenInputFilecxx . . $ OpenInputFile(42b3e5d80c6aa09f).(context->current_input_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#current_input_path., &context->fincxx . . $ $anonymous_type_2fa36e8c50d79419_2#fin.); |
| 1020 | if (!context->test_integritycxx . . $ $anonymous_type_2fa36e8c50d79419_2#test_integrity. && is_ok) { |
| 1021 | is_ok = OpenOutputFilecxx . . $ OpenOutputFile(dd5faff425e696c9).( |
| 1022 | context->current_output_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#current_output_path., &context->foutcxx . . $ $anonymous_type_2fa36e8c50d79419_2#fout., context->force_overwritecxx . . $ $anonymous_type_2fa36e8c50d79419_2#force_overwrite.); |
| 1023 | } |
| 1024 | return is_ok; |
| 1025 | } |
| 1026 | |
| 1027 | static BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! CloseFilescxx . . $ CloseFiles(8b4f405b414d876d).(Contextcxx . . $ Context#* context, BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! rm_input, |
| 1028 | BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! rm_output) { |
| 1029 | BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! is_ok = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 1030 | if (!context->test_integritycxx . . $ $anonymous_type_2fa36e8c50d79419_2#test_integrity. && context->foutcxx . . $ $anonymous_type_2fa36e8c50d79419_2#fout.) { |
| 1031 | if (fclosecxx . . $ fclose(89bc1efcdac0ca22).(context->foutcxx . . $ $anonymous_type_2fa36e8c50d79419_2#fout.) != 0) { |
| 1032 | if (is_ok) { |
| 1033 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "fclose failed [%s]: %s\n", |
| 1034 | PrintablePathcxx . . $ PrintablePath(fb58d2e09a2a1ce6).(context->current_output_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#current_output_path.), strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 1035 | } |
| 1036 | is_ok = BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 1037 | } |
| 1038 | if (rm_output && context->current_output_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#current_output_path.) { |
| 1039 | unlinkcxx . . $ unlink(5c4306d8553b3696).(context->current_output_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#current_output_path.); |
| 1040 | } |
| 1041 | |
| 1042 | /* TOCTOU violation, but otherwise it is impossible to set file times. */ |
| 1043 | if (!rm_output && is_ok && context->copy_statcxx . . $ $anonymous_type_2fa36e8c50d79419_2#copy_stat.) { |
| 1044 | CopyStatcxx . . $ CopyStat(2fa786934fe80e24).(context->current_input_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#current_input_path., context->current_output_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#current_output_path.); |
| 1045 | } |
| 1046 | } |
| 1047 | |
| 1048 | if (context->fincxx . . $ $anonymous_type_2fa36e8c50d79419_2#fin.) { |
| 1049 | if (fclosecxx . . $ fclose(89bc1efcdac0ca22).(context->fincxx . . $ $anonymous_type_2fa36e8c50d79419_2#fin.) != 0) { |
| 1050 | if (is_ok) { |
| 1051 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "fclose failed [%s]: %s\n", |
| 1052 | PrintablePathcxx . . $ PrintablePath(fb58d2e09a2a1ce6).(context->current_input_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#current_input_path.), strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 1053 | } |
| 1054 | is_ok = BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 1055 | } |
| 1056 | } |
| 1057 | if (rm_input && context->current_input_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#current_input_path.) { |
| 1058 | unlinkcxx . . $ unlink(5c4306d8553b3696).(context->current_input_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#current_input_path.); |
| 1059 | } |
| 1060 | |
| 1061 | context->fincxx . . $ $anonymous_type_2fa36e8c50d79419_2#fin. = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!; |
| 1062 | context->foutcxx . . $ $anonymous_type_2fa36e8c50d79419_2#fout. = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!; |
| 1063 | |
| 1064 | return is_ok; |
| 1065 | } |
| 1066 | |
| 1067 | static const size_t kFileBufferSizecxx . . $ kFileBufferSize. = 1 << 19; |
| 1068 | |
| 1069 | static void InitializeBufferscxx . . $ InitializeBuffers(1a28a8c0a491855d).(Contextcxx . . $ Context#* context) { |
| 1070 | context->available_incxx . . $ $anonymous_type_2fa36e8c50d79419_2#available_in. = 0; |
| 1071 | context->next_incxx . . $ $anonymous_type_2fa36e8c50d79419_2#next_in. = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!; |
| 1072 | context->available_outcxx . . $ $anonymous_type_2fa36e8c50d79419_2#available_out. = kFileBufferSizecxx . . $ kFileBufferSize.; |
| 1073 | context->next_outcxx . . $ $anonymous_type_2fa36e8c50d79419_2#next_out. = context->outputcxx . . $ $anonymous_type_2fa36e8c50d79419_2#output.; |
| 1074 | context->total_incxx . . $ $anonymous_type_2fa36e8c50d79419_2#total_in. = 0; |
| 1075 | context->total_outcxx . . $ $anonymous_type_2fa36e8c50d79419_2#total_out. = 0; |
| 1076 | if (context->verbositycxx . . $ $anonymous_type_2fa36e8c50d79419_2#verbosity. > 0) { |
| 1077 | context->start_timecxx . . $ $anonymous_type_2fa36e8c50d79419_2#start_time. = clockcxx . . $ clock(da6335ded91d79c2).(); |
| 1078 | } |
| 1079 | } |
| 1080 | |
| 1081 | /* This method might give the false-negative result. |
| 1082 | However, after an empty / incomplete read it should tell the truth. */ |
| 1083 | static BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! HasMoreInputcxx . . $ HasMoreInput(bde9ac7206dc9e17).(Contextcxx . . $ Context#* context) { |
| 1084 | return feofcxx . . $ feof(89bc1efcdac0ca22).(context->fincxx . . $ $anonymous_type_2fa36e8c50d79419_2#fin.) ? BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`! : BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 1085 | } |
| 1086 | |
| 1087 | static BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! ProvideInputcxx . . $ ProvideInput(bde9ac7206dc9e17).(Contextcxx . . $ Context#* context) { |
| 1088 | context->available_incxx . . $ $anonymous_type_2fa36e8c50d79419_2#available_in. = |
| 1089 | freadcxx . . $ fread(738fc8ac1d711e58).(context->inputcxx . . $ $anonymous_type_2fa36e8c50d79419_2#input., 1, kFileBufferSizecxx . . $ kFileBufferSize., context->fincxx . . $ $anonymous_type_2fa36e8c50d79419_2#fin.); |
| 1090 | context->total_incxx . . $ $anonymous_type_2fa36e8c50d79419_2#total_in. += context->available_incxx . . $ $anonymous_type_2fa36e8c50d79419_2#available_in.; |
| 1091 | context->next_incxx . . $ $anonymous_type_2fa36e8c50d79419_2#next_in. = context->inputcxx . . $ $anonymous_type_2fa36e8c50d79419_2#input.; |
| 1092 | if (ferrorcxx . . $ ferror(89bc1efcdac0ca22).(context->fincxx . . $ $anonymous_type_2fa36e8c50d79419_2#fin.)) { |
| 1093 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "failed to read input [%s]: %s\n", |
| 1094 | PrintablePathcxx . . $ PrintablePath(fb58d2e09a2a1ce6).(context->current_input_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#current_input_path.), strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 1095 | return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 1096 | } |
| 1097 | return BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 1098 | } |
| 1099 | |
| 1100 | /* Internal: should be used only in Provide-/Flush-Output. */ |
| 1101 | static BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! WriteOutputcxx . . $ WriteOutput(bde9ac7206dc9e17).(Contextcxx . . $ Context#* context) { |
| 1102 | size_t out_size = (size_t)(context->next_outcxx . . $ $anonymous_type_2fa36e8c50d79419_2#next_out. - context->outputcxx . . $ $anonymous_type_2fa36e8c50d79419_2#output.); |
| 1103 | context->total_outcxx . . $ $anonymous_type_2fa36e8c50d79419_2#total_out. += out_size; |
| 1104 | if (out_size == 0) return BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 1105 | if (context->test_integritycxx . . $ $anonymous_type_2fa36e8c50d79419_2#test_integrity.) return BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 1106 | |
| 1107 | fwritecxx . . $ fwrite(ab0609fa07c47d6e).(context->outputcxx . . $ $anonymous_type_2fa36e8c50d79419_2#output., 1, out_size, context->foutcxx . . $ $anonymous_type_2fa36e8c50d79419_2#fout.); |
| 1108 | if (ferrorcxx . . $ ferror(89bc1efcdac0ca22).(context->foutcxx . . $ $anonymous_type_2fa36e8c50d79419_2#fout.)) { |
| 1109 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "failed to write output [%s]: %s\n", |
| 1110 | PrintablePathcxx . . $ PrintablePath(fb58d2e09a2a1ce6).(context->current_output_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#current_output_path.), strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 1111 | return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 1112 | } |
| 1113 | return BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 1114 | } |
| 1115 | |
| 1116 | static BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! ProvideOutputcxx . . $ ProvideOutput(bde9ac7206dc9e17).(Contextcxx . . $ Context#* context) { |
| 1117 | if (!WriteOutputcxx . . $ WriteOutput(bde9ac7206dc9e17).(context)) return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 1118 | context->available_outcxx . . $ $anonymous_type_2fa36e8c50d79419_2#available_out. = kFileBufferSizecxx . . $ kFileBufferSize.; |
| 1119 | context->next_outcxx . . $ $anonymous_type_2fa36e8c50d79419_2#next_out. = context->outputcxx . . $ $anonymous_type_2fa36e8c50d79419_2#output.; |
| 1120 | return BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 1121 | } |
| 1122 | |
| 1123 | static BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! FlushOutputcxx . . $ FlushOutput(bde9ac7206dc9e17).(Contextcxx . . $ Context#* context) { |
| 1124 | if (!WriteOutputcxx . . $ WriteOutput(bde9ac7206dc9e17).(context)) return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 1125 | context->available_outcxx . . $ $anonymous_type_2fa36e8c50d79419_2#available_out. = 0; |
| 1126 | context->next_outcxx . . $ $anonymous_type_2fa36e8c50d79419_2#next_out. = context->outputcxx . . $ $anonymous_type_2fa36e8c50d79419_2#output.; |
| 1127 | return BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 1128 | } |
| 1129 | |
| 1130 | static void PrintBytescxx . . $ PrintBytes(2c44cd906ae4e829).(size_t value) { |
| 1131 | if (value < 1024) { |
| 1132 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "%d B", (int)value); |
| 1133 | } else if (value < 1048576) { |
| 1134 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "%0.3f KiB", (double)value / 1024.0); |
| 1135 | } else if (value < 1073741824) { |
| 1136 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "%0.3f MiB", (double)value / 1048576.0); |
| 1137 | } else { |
| 1138 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "%0.3f GiB", (double)value / 1073741824.0); |
| 1139 | } |
| 1140 | } |
| 1141 | |
| 1142 | static void PrintFileProcessingProgresscxx . . $ PrintFileProcessingProgress(1a28a8c0a491855d).(Contextcxx . . $ Context#* context) { |
| 1143 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "[%s]: ", PrintablePathcxx . . $ PrintablePath(fb58d2e09a2a1ce6).(context->current_input_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#current_input_path.)); |
| 1144 | PrintBytescxx . . $ PrintBytes(2c44cd906ae4e829).(context->total_incxx . . $ $anonymous_type_2fa36e8c50d79419_2#total_in.); |
| 1145 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, " -> "); |
| 1146 | PrintBytescxx . . $ PrintBytes(2c44cd906ae4e829).(context->total_outcxx . . $ $anonymous_type_2fa36e8c50d79419_2#total_out.); |
| 1147 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, " in %1.2f sec", (double)(context->end_timecxx . . $ $anonymous_type_2fa36e8c50d79419_2#end_time. - context->start_timecxx . . $ $anonymous_type_2fa36e8c50d79419_2#start_time.) / CLOCKS_PER_SECcxx . . $ `<external>/89459239771508533/time.h:34:9`!); |
| 1148 | } |
| 1149 | |
| 1150 | static const char* PrettyDecoderErrorStringcxx . . $ PrettyDecoderErrorString(305cc0e212fcaf65).(BrotliDecoderErrorCodecxx . . $ BrotliDecoderErrorCode# code) { |
| 1151 | /* "_ERROR_domain_" is in only added in newer versions. If CLI is linked |
| 1152 | against older shared library, return error string as is; result might be |
| 1153 | a bit confusing, e.g. "RESERVED" instead of "FORMAT_RESERVED" */ |
| 1154 | const char* prefix = "_ERROR_"; |
| 1155 | size_t prefix_len = strlencxx . . $ strlen(751346f8406fd082).(prefix); |
| 1156 | const char* error_str = BrotliDecoderErrorStringcxx . . $ BrotliDecoderErrorString(305cc0e212fcaf65).(code); |
| 1157 | size_t error_len = strlencxx . . $ strlen(751346f8406fd082).(error_str); |
| 1158 | if (error_len > prefix_len) { |
| 1159 | if (strncmpcxx . . $ strncmp(fd278af2f295fa2e).(error_str, prefix, prefix_len) == 0) { |
| 1160 | error_str += prefix_len; |
| 1161 | } |
| 1162 | } |
| 1163 | return error_str; |
| 1164 | } |
| 1165 | |
| 1166 | static void OnMetadataStartcxx . . $ OnMetadataStart(5500c4293b1bbef0).(void* opaque, size_t size) { |
| 1167 | Contextcxx . . $ Context#* context = (Contextcxx . . $ Context#*) opaque; |
| 1168 | if (context->comment_statecxx . . $ $anonymous_type_2fa36e8c50d79419_2#comment_state. == COMMENT_INITcxx . . $ COMMENT_INIT.) { |
| 1169 | if (context->comment_lencxx . . $ $anonymous_type_2fa36e8c50d79419_2#comment_len. != size) { |
| 1170 | context->comment_statecxx . . $ $anonymous_type_2fa36e8c50d79419_2#comment_state. = COMMENT_BADcxx . . $ COMMENT_BAD.; |
| 1171 | return; |
| 1172 | } |
| 1173 | context->comment_poscxx . . $ $anonymous_type_2fa36e8c50d79419_2#comment_pos. = 0; |
| 1174 | context->comment_statecxx . . $ $anonymous_type_2fa36e8c50d79419_2#comment_state. = COMMENT_READcxx . . $ COMMENT_READ.; |
| 1175 | } |
| 1176 | } |
| 1177 | |
| 1178 | static void OnMetadataChunkcxx . . $ OnMetadataChunk(18caf9a42595a7ad).(void* opaque, const uint8_tcxx . . $ uint8_t#* data, size_t size) { |
| 1179 | Contextcxx . . $ Context#* context = (Contextcxx . . $ Context#*) opaque; |
| 1180 | if (context->comment_statecxx . . $ $anonymous_type_2fa36e8c50d79419_2#comment_state. == COMMENT_READcxx . . $ COMMENT_READ.) { |
| 1181 | size_t i; |
| 1182 | for (i = 0; i < size; ++i) { |
| 1183 | if (context->comment_poscxx . . $ $anonymous_type_2fa36e8c50d79419_2#comment_pos. >= context->comment_lencxx . . $ $anonymous_type_2fa36e8c50d79419_2#comment_len.) { |
| 1184 | context->comment_statecxx . . $ $anonymous_type_2fa36e8c50d79419_2#comment_state. = COMMENT_BADcxx . . $ COMMENT_BAD.; |
| 1185 | return; |
| 1186 | } |
| 1187 | if (context->commentcxx . . $ $anonymous_type_2fa36e8c50d79419_2#comment.[context->comment_poscxx . . $ $anonymous_type_2fa36e8c50d79419_2#comment_pos.++] != data[i]) { |
| 1188 | context->comment_statecxx . . $ $anonymous_type_2fa36e8c50d79419_2#comment_state. = COMMENT_BADcxx . . $ COMMENT_BAD.; |
| 1189 | return; |
| 1190 | } |
| 1191 | } |
| 1192 | if (context->comment_poscxx . . $ $anonymous_type_2fa36e8c50d79419_2#comment_pos. == context->comment_lencxx . . $ $anonymous_type_2fa36e8c50d79419_2#comment_len.) { |
| 1193 | context->comment_statecxx . . $ $anonymous_type_2fa36e8c50d79419_2#comment_state. = COMMENT_OKcxx . . $ COMMENT_OK.; |
| 1194 | } |
| 1195 | } |
| 1196 | } |
| 1197 | |
| 1198 | static BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! InitDecodercxx . . $ InitDecoder(bde9ac7206dc9e17).(Contextcxx . . $ Context#* context) { |
| 1199 | context->decodercxx . . $ $anonymous_type_2fa36e8c50d79419_2#decoder. = BrotliDecoderCreateInstancecxx . . $ BrotliDecoderCreateInstance(125708fa71c753db).(NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!, NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!, NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!); |
| 1200 | if (!context->decodercxx . . $ $anonymous_type_2fa36e8c50d79419_2#decoder.) { |
| 1201 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "out of memory\n"); |
| 1202 | return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 1203 | } |
| 1204 | /* This allows decoding "large-window" streams. Though it creates |
| 1205 | fragmentation (new builds decode streams that old builds don't), |
| 1206 | it is better from used experience perspective. */ |
| 1207 | BrotliDecoderSetParametercxx . . $ BrotliDecoderSetParameter(605003305ae8af39).( |
| 1208 | context->decodercxx . . $ $anonymous_type_2fa36e8c50d79419_2#decoder., BROTLI_DECODER_PARAM_LARGE_WINDOWcxx . . $ BROTLI_DECODER_PARAM_LARGE_WINDOW., 1u); |
| 1209 | if (context->dictionarycxx . . $ $anonymous_type_2fa36e8c50d79419_2#dictionary.) { |
| 1210 | BrotliDecoderAttachDictionarycxx . . $ BrotliDecoderAttachDictionary(b159b47f130a2167).(context->decodercxx . . $ $anonymous_type_2fa36e8c50d79419_2#decoder., |
| 1211 | BROTLI_SHARED_DICTIONARY_RAWcxx . . $ BROTLI_SHARED_DICTIONARY_RAW., context->dictionary_sizecxx . . $ $anonymous_type_2fa36e8c50d79419_2#dictionary_size., |
| 1212 | context->dictionarycxx . . $ $anonymous_type_2fa36e8c50d79419_2#dictionary.); |
| 1213 | } |
| 1214 | return BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 1215 | } |
| 1216 | |
| 1217 | static BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! DecompressFilecxx . . $ DecompressFile(bde9ac7206dc9e17).(Contextcxx . . $ Context#* context) { |
| 1218 | BrotliDecoderStatecxx . . $ BrotliDecoderState#* s = context->decodercxx . . $ $anonymous_type_2fa36e8c50d79419_2#decoder.; |
| 1219 | BrotliDecoderResultcxx . . $ BrotliDecoderResult# result = BROTLI_DECODER_RESULT_NEEDS_MORE_INPUTcxx . . $ BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT.; |
| 1220 | if (context->comment_lencxx . . $ $anonymous_type_2fa36e8c50d79419_2#comment_len.) { |
| 1221 | context->comment_statecxx . . $ $anonymous_type_2fa36e8c50d79419_2#comment_state. = COMMENT_INITcxx . . $ COMMENT_INIT.; |
| 1222 | BrotliDecoderSetMetadataCallbackscxx . . $ BrotliDecoderSetMetadataCallbacks(d86de944b677b10d).(s, &OnMetadataStartcxx . . $ OnMetadataStart(5500c4293b1bbef0)., &OnMetadataChunkcxx . . $ OnMetadataChunk(18caf9a42595a7ad)., |
| 1223 | (void*)context); |
| 1224 | } else { |
| 1225 | context->comment_statecxx . . $ $anonymous_type_2fa36e8c50d79419_2#comment_state. = COMMENT_OKcxx . . $ COMMENT_OK.; |
| 1226 | } |
| 1227 | |
| 1228 | InitializeBufferscxx . . $ InitializeBuffers(1a28a8c0a491855d).(context); |
| 1229 | for (;;) { |
| 1230 | /* Early check */ |
| 1231 | if (context->comment_statecxx . . $ $anonymous_type_2fa36e8c50d79419_2#comment_state. == COMMENT_BADcxx . . $ COMMENT_BAD.) { |
| 1232 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "corrupt input [%s]\n", |
| 1233 | PrintablePathcxx . . $ PrintablePath(fb58d2e09a2a1ce6).(context->current_input_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#current_input_path.)); |
| 1234 | if (context->verbositycxx . . $ $anonymous_type_2fa36e8c50d79419_2#verbosity. > 0) { |
| 1235 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "reason: comment mismatch\n"); |
| 1236 | } |
| 1237 | return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 1238 | } |
| 1239 | if (result == BROTLI_DECODER_RESULT_NEEDS_MORE_INPUTcxx . . $ BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT.) { |
| 1240 | if (!HasMoreInputcxx . . $ HasMoreInput(bde9ac7206dc9e17).(context)) { |
| 1241 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "corrupt input [%s]\n", |
| 1242 | PrintablePathcxx . . $ PrintablePath(fb58d2e09a2a1ce6).(context->current_input_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#current_input_path.)); |
| 1243 | if (context->verbositycxx . . $ $anonymous_type_2fa36e8c50d79419_2#verbosity. > 0) { |
| 1244 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "reason: truncated input\n"); |
| 1245 | } |
| 1246 | return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 1247 | } |
| 1248 | if (!ProvideInputcxx . . $ ProvideInput(bde9ac7206dc9e17).(context)) return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 1249 | } else if (result == BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUTcxx . . $ BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT.) { |
| 1250 | if (!ProvideOutputcxx . . $ ProvideOutput(bde9ac7206dc9e17).(context)) return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 1251 | } else if (result == BROTLI_DECODER_RESULT_SUCCESScxx . . $ BROTLI_DECODER_RESULT_SUCCESS.) { |
| 1252 | if (!FlushOutputcxx . . $ FlushOutput(bde9ac7206dc9e17).(context)) return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 1253 | BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! has_more_input = (context->available_incxx . . $ $anonymous_type_2fa36e8c50d79419_2#available_in. != 0); |
| 1254 | int extra_char = EOFcxx . . $ `<external>/232824719582829767/stdio.h:109:9`!; |
| 1255 | if (!has_more_input) { |
| 1256 | extra_char = fgetccxx . . $ fgetc(89bc1efcdac0ca22).(context->fincxx . . $ $anonymous_type_2fa36e8c50d79419_2#fin.); |
| 1257 | if (extra_char != EOFcxx . . $ `<external>/232824719582829767/stdio.h:109:9`!) { |
| 1258 | has_more_input = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 1259 | context->inputcxx . . $ $anonymous_type_2fa36e8c50d79419_2#input.[0] = (uint8_tcxx . . $ uint8_t#)extra_char; |
| 1260 | context->next_incxx . . $ $anonymous_type_2fa36e8c50d79419_2#next_in. = context->inputcxx . . $ $anonymous_type_2fa36e8c50d79419_2#input.; |
| 1261 | context->available_incxx . . $ $anonymous_type_2fa36e8c50d79419_2#available_in. = 1; |
| 1262 | } |
| 1263 | } |
| 1264 | if (has_more_input) { |
| 1265 | if (context->allow_concatenatedcxx . . $ $anonymous_type_2fa36e8c50d79419_2#allow_concatenated.) { |
| 1266 | if (context->verbositycxx . . $ $anonymous_type_2fa36e8c50d79419_2#verbosity. > 0) { |
| 1267 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "extra input\n"); |
| 1268 | } |
| 1269 | if (!ProvideOutputcxx . . $ ProvideOutput(bde9ac7206dc9e17).(context)) return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 1270 | BrotliDecoderDestroyInstancecxx . . $ BrotliDecoderDestroyInstance(bb1fb99afd41e748).(context->decodercxx . . $ $anonymous_type_2fa36e8c50d79419_2#decoder.); |
| 1271 | context->decodercxx . . $ $anonymous_type_2fa36e8c50d79419_2#decoder. = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!; |
| 1272 | if (!InitDecodercxx . . $ InitDecoder(bde9ac7206dc9e17).(context)) return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 1273 | s = context->decodercxx . . $ $anonymous_type_2fa36e8c50d79419_2#decoder.; |
| 1274 | } else { |
| 1275 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "corrupt input [%s]\n", |
| 1276 | PrintablePathcxx . . $ PrintablePath(fb58d2e09a2a1ce6).(context->current_input_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#current_input_path.)); |
| 1277 | if (context->verbositycxx . . $ $anonymous_type_2fa36e8c50d79419_2#verbosity. > 0) { |
| 1278 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "reason: extra input\n"); |
| 1279 | } |
| 1280 | return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 1281 | } |
| 1282 | } else { |
| 1283 | if (context->verbositycxx . . $ $anonymous_type_2fa36e8c50d79419_2#verbosity. > 0) { |
| 1284 | context->end_timecxx . . $ $anonymous_type_2fa36e8c50d79419_2#end_time. = clockcxx . . $ clock(da6335ded91d79c2).(); |
| 1285 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "Decompressed "); |
| 1286 | PrintFileProcessingProgresscxx . . $ PrintFileProcessingProgress(1a28a8c0a491855d).(context); |
| 1287 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "\n"); |
| 1288 | } |
| 1289 | /* Final check */ |
| 1290 | if (context->comment_statecxx . . $ $anonymous_type_2fa36e8c50d79419_2#comment_state. != COMMENT_OKcxx . . $ COMMENT_OK.) { |
| 1291 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "corrupt input [%s]\n", |
| 1292 | PrintablePathcxx . . $ PrintablePath(fb58d2e09a2a1ce6).(context->current_input_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#current_input_path.)); |
| 1293 | if (context->verbositycxx . . $ $anonymous_type_2fa36e8c50d79419_2#verbosity. > 0) { |
| 1294 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "reason: comment mismatch\n"); |
| 1295 | } |
| 1296 | } |
| 1297 | return BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 1298 | } |
| 1299 | } else { /* result == BROTLI_DECODER_RESULT_ERROR */ |
| 1300 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "corrupt input [%s]\n", |
| 1301 | PrintablePathcxx . . $ PrintablePath(fb58d2e09a2a1ce6).(context->current_input_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#current_input_path.)); |
| 1302 | if (context->verbositycxx . . $ $anonymous_type_2fa36e8c50d79419_2#verbosity. > 0) { |
| 1303 | BrotliDecoderErrorCodecxx . . $ BrotliDecoderErrorCode# error = BrotliDecoderGetErrorCodecxx . . $ BrotliDecoderGetErrorCode(d2b9c2092cac6c53).(s); |
| 1304 | const char* error_str = PrettyDecoderErrorStringcxx . . $ PrettyDecoderErrorString(305cc0e212fcaf65).(error); |
| 1305 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "reason: %s (%d)\n", error_str, error); |
| 1306 | } |
| 1307 | return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 1308 | } |
| 1309 | |
| 1310 | result = BrotliDecoderDecompressStreamcxx . . $ BrotliDecoderDecompressStream(391610b52170204b).(s, &context->available_incxx . . $ $anonymous_type_2fa36e8c50d79419_2#available_in., |
| 1311 | &context->next_incxx . . $ $anonymous_type_2fa36e8c50d79419_2#next_in., &context->available_outcxx . . $ $anonymous_type_2fa36e8c50d79419_2#available_out., &context->next_outcxx . . $ $anonymous_type_2fa36e8c50d79419_2#next_out., 0); |
| 1312 | } |
| 1313 | } |
| 1314 | |
| 1315 | static BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! DecompressFilescxx . . $ DecompressFiles(bde9ac7206dc9e17).(Contextcxx . . $ Context#* context) { |
| 1316 | while (NextFilecxx . . $ NextFile(bde9ac7206dc9e17).(context)) { |
| 1317 | BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! is_ok = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 1318 | BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! rm_input = BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 1319 | BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! rm_output = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 1320 | if (!InitDecodercxx . . $ InitDecoder(bde9ac7206dc9e17).(context)) return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 1321 | is_ok = OpenFilescxx . . $ OpenFiles(bde9ac7206dc9e17).(context); |
| 1322 | if (is_ok && !context->current_input_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#current_input_path. && |
| 1323 | !context->force_overwritecxx . . $ $anonymous_type_2fa36e8c50d79419_2#force_overwrite. && isattycxx . . $ isatty(7864480464b09eea).(STDIN_FILENOcxx . . $ `<external>/12628407106812493757/unistd.h:210:9`!)) { |
| 1324 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "Use -h help. Use -f to force input from a terminal.\n"); |
| 1325 | is_ok = BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 1326 | } |
| 1327 | if (is_ok) is_ok = DecompressFilecxx . . $ DecompressFile(bde9ac7206dc9e17).(context); |
| 1328 | if (context->decodercxx . . $ $anonymous_type_2fa36e8c50d79419_2#decoder.) BrotliDecoderDestroyInstancecxx . . $ BrotliDecoderDestroyInstance(bb1fb99afd41e748).(context->decodercxx . . $ $anonymous_type_2fa36e8c50d79419_2#decoder.); |
| 1329 | context->decodercxx . . $ $anonymous_type_2fa36e8c50d79419_2#decoder. = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!; |
| 1330 | rm_output = !is_ok; |
| 1331 | rm_input = !rm_output && context->junk_sourcecxx . . $ $anonymous_type_2fa36e8c50d79419_2#junk_source.; |
| 1332 | if (!CloseFilescxx . . $ CloseFiles(8b4f405b414d876d).(context, rm_input, rm_output)) is_ok = BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 1333 | if (!is_ok) return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 1334 | } |
| 1335 | return BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 1336 | } |
| 1337 | |
| 1338 | static BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! CompressFilecxx . . $ CompressFile(63610010b1562128).(Contextcxx . . $ Context#* context, BrotliEncoderStatecxx . . $ BrotliEncoderState#* s) { |
| 1339 | BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! is_eof = BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 1340 | BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! prologue = !!context->comment_lencxx . . $ $anonymous_type_2fa36e8c50d79419_2#comment_len.; |
| 1341 | InitializeBufferscxx . . $ InitializeBuffers(1a28a8c0a491855d).(context); |
| 1342 | for (;;) { |
| 1343 | if (context->available_incxx . . $ $anonymous_type_2fa36e8c50d79419_2#available_in. == 0 && !is_eof) { |
| 1344 | if (!ProvideInputcxx . . $ ProvideInput(bde9ac7206dc9e17).(context)) return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 1345 | is_eof = !HasMoreInputcxx . . $ HasMoreInput(bde9ac7206dc9e17).(context); |
| 1346 | } |
| 1347 | |
| 1348 | if (prologue) { |
| 1349 | prologue = BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 1350 | const uint8_tcxx . . $ uint8_t#* next_meta = context->commentcxx . . $ $anonymous_type_2fa36e8c50d79419_2#comment.; |
| 1351 | size_t available_meta = context->comment_lencxx . . $ $anonymous_type_2fa36e8c50d79419_2#comment_len.; |
| 1352 | if (!BrotliEncoderCompressStreamcxx . . $ BrotliEncoderCompressStream(6714bff7edb0b4c5).(s, |
| 1353 | BROTLI_OPERATION_EMIT_METADATAcxx . . $ BROTLI_OPERATION_EMIT_METADATA., |
| 1354 | &available_meta, &next_meta, |
| 1355 | &context->available_outcxx . . $ $anonymous_type_2fa36e8c50d79419_2#available_out., &context->next_outcxx . . $ $anonymous_type_2fa36e8c50d79419_2#next_out., NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!)) { |
| 1356 | /* Should detect OOM? */ |
| 1357 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "failed to emit metadata [%s]\n", |
| 1358 | PrintablePathcxx . . $ PrintablePath(fb58d2e09a2a1ce6).(context->current_input_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#current_input_path.)); |
| 1359 | return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 1360 | } |
| 1361 | if (available_meta != 0) { |
| 1362 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "failed to emit metadata [%s]\n", |
| 1363 | PrintablePathcxx . . $ PrintablePath(fb58d2e09a2a1ce6).(context->current_input_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#current_input_path.)); |
| 1364 | return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 1365 | } |
| 1366 | } else { |
| 1367 | if (!BrotliEncoderCompressStreamcxx . . $ BrotliEncoderCompressStream(6714bff7edb0b4c5).(s, |
| 1368 | is_eof ? BROTLI_OPERATION_FINISHcxx . . $ BROTLI_OPERATION_FINISH. : BROTLI_OPERATION_PROCESScxx . . $ BROTLI_OPERATION_PROCESS., |
| 1369 | &context->available_incxx . . $ $anonymous_type_2fa36e8c50d79419_2#available_in., &context->next_incxx . . $ $anonymous_type_2fa36e8c50d79419_2#next_in., |
| 1370 | &context->available_outcxx . . $ $anonymous_type_2fa36e8c50d79419_2#available_out., &context->next_outcxx . . $ $anonymous_type_2fa36e8c50d79419_2#next_out., NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!)) { |
| 1371 | /* Should detect OOM? */ |
| 1372 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "failed to compress data [%s]\n", |
| 1373 | PrintablePathcxx . . $ PrintablePath(fb58d2e09a2a1ce6).(context->current_input_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#current_input_path.)); |
| 1374 | return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 1375 | } |
| 1376 | } |
| 1377 | |
| 1378 | if (context->available_outcxx . . $ $anonymous_type_2fa36e8c50d79419_2#available_out. == 0) { |
| 1379 | if (!ProvideOutputcxx . . $ ProvideOutput(bde9ac7206dc9e17).(context)) return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 1380 | } |
| 1381 | |
| 1382 | if (BrotliEncoderIsFinishedcxx . . $ BrotliEncoderIsFinished(57ea683d0f31ecf3).(s)) { |
| 1383 | if (!FlushOutputcxx . . $ FlushOutput(bde9ac7206dc9e17).(context)) return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 1384 | if (context->verbositycxx . . $ $anonymous_type_2fa36e8c50d79419_2#verbosity. > 0) { |
| 1385 | context->end_timecxx . . $ $anonymous_type_2fa36e8c50d79419_2#end_time. = clockcxx . . $ clock(da6335ded91d79c2).(); |
| 1386 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "Compressed "); |
| 1387 | PrintFileProcessingProgresscxx . . $ PrintFileProcessingProgress(1a28a8c0a491855d).(context); |
| 1388 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "\n"); |
| 1389 | } |
| 1390 | return BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 1391 | } |
| 1392 | } |
| 1393 | } |
| 1394 | |
| 1395 | static BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! CompressFilescxx . . $ CompressFiles(bde9ac7206dc9e17).(Contextcxx . . $ Context#* context) { |
| 1396 | while (NextFilecxx . . $ NextFile(bde9ac7206dc9e17).(context)) { |
| 1397 | BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! is_ok = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 1398 | BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! rm_input = BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 1399 | BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! rm_output = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 1400 | BrotliEncoderStatecxx . . $ BrotliEncoderState#* s = BrotliEncoderCreateInstancecxx . . $ BrotliEncoderCreateInstance(d6b750deadac02e5).(NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!, NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!, NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!); |
| 1401 | if (!s) { |
| 1402 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "out of memory\n"); |
| 1403 | return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 1404 | } |
| 1405 | BrotliEncoderSetParametercxx . . $ BrotliEncoderSetParameter(8731835c289da859).(s, |
| 1406 | BROTLI_PARAM_QUALITYcxx . . $ BROTLI_PARAM_QUALITY., (uint32_tcxx . . $ uint32_t#)context->qualitycxx . . $ $anonymous_type_2fa36e8c50d79419_2#quality.); |
| 1407 | if (context->lgwincxx . . $ $anonymous_type_2fa36e8c50d79419_2#lgwin. > 0) { |
| 1408 | /* Specified by user. */ |
| 1409 | /* Do not enable "large-window" extension, if not required. */ |
| 1410 | if (context->lgwincxx . . $ $anonymous_type_2fa36e8c50d79419_2#lgwin. > BROTLI_MAX_WINDOW_BITScxx . . $ `c/include/brotli/encode.h:30:9`!) { |
| 1411 | BrotliEncoderSetParametercxx . . $ BrotliEncoderSetParameter(8731835c289da859).(s, BROTLI_PARAM_LARGE_WINDOWcxx . . $ BROTLI_PARAM_LARGE_WINDOW., 1u); |
| 1412 | } |
| 1413 | BrotliEncoderSetParametercxx . . $ BrotliEncoderSetParameter(8731835c289da859).(s, |
| 1414 | BROTLI_PARAM_LGWINcxx . . $ BROTLI_PARAM_LGWIN., (uint32_tcxx . . $ uint32_t#)context->lgwincxx . . $ $anonymous_type_2fa36e8c50d79419_2#lgwin.); |
| 1415 | } else { |
| 1416 | /* 0, or not specified by user; could be chosen by compressor. */ |
| 1417 | uint32_tcxx . . $ uint32_t# lgwin = DEFAULT_LGWINcxx . . $ `c/tools/brotli.c:113:9`!; |
| 1418 | /* Use file size to limit lgwin. */ |
| 1419 | if (context->input_file_lengthcxx . . $ $anonymous_type_2fa36e8c50d79419_2#input_file_length. >= 0) { |
| 1420 | lgwin = BROTLI_MIN_WINDOW_BITScxx . . $ `c/include/brotli/encode.h:24:9`!; |
| 1421 | while (BROTLI_MAX_BACKWARD_LIMITcxx . . $ `c/common/constants.h:101:9`!(lgwin) < |
| 1422 | (uint64_tcxx . . $ uint64_t#)context->input_file_lengthcxx . . $ $anonymous_type_2fa36e8c50d79419_2#input_file_length.) { |
| 1423 | lgwin++; |
| 1424 | if (lgwin == BROTLI_MAX_WINDOW_BITScxx . . $ `c/include/brotli/encode.h:30:9`!) break; |
| 1425 | } |
| 1426 | } |
| 1427 | BrotliEncoderSetParametercxx . . $ BrotliEncoderSetParameter(8731835c289da859).(s, BROTLI_PARAM_LGWINcxx . . $ BROTLI_PARAM_LGWIN., lgwin); |
| 1428 | } |
| 1429 | if (context->input_file_lengthcxx . . $ $anonymous_type_2fa36e8c50d79419_2#input_file_length. > 0) { |
| 1430 | uint32_tcxx . . $ uint32_t# size_hint = context->input_file_lengthcxx . . $ $anonymous_type_2fa36e8c50d79419_2#input_file_length. < (1 << 30) ? |
| 1431 | (uint32_tcxx . . $ uint32_t#)context->input_file_lengthcxx . . $ $anonymous_type_2fa36e8c50d79419_2#input_file_length. : (1u << 30); |
| 1432 | BrotliEncoderSetParametercxx . . $ BrotliEncoderSetParameter(8731835c289da859).(s, BROTLI_PARAM_SIZE_HINTcxx . . $ BROTLI_PARAM_SIZE_HINT., size_hint); |
| 1433 | } |
| 1434 | if (context->dictionarycxx . . $ $anonymous_type_2fa36e8c50d79419_2#dictionary.) { |
| 1435 | BrotliEncoderAttachPreparedDictionarycxx . . $ BrotliEncoderAttachPreparedDictionary(da2a568dba5b8f72).(s, context->prepared_dictionarycxx . . $ $anonymous_type_2fa36e8c50d79419_2#prepared_dictionary.); |
| 1436 | } |
| 1437 | is_ok = OpenFilescxx . . $ OpenFiles(bde9ac7206dc9e17).(context); |
| 1438 | if (is_ok && !context->current_output_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#current_output_path. && |
| 1439 | !context->force_overwritecxx . . $ $anonymous_type_2fa36e8c50d79419_2#force_overwrite. && isattycxx . . $ isatty(7864480464b09eea).(STDOUT_FILENOcxx . . $ `<external>/12628407106812493757/unistd.h:211:9`!)) { |
| 1440 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "Use -h help. Use -f to force output to a terminal.\n"); |
| 1441 | is_ok = BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 1442 | } |
| 1443 | if (is_ok) is_ok = CompressFilecxx . . $ CompressFile(63610010b1562128).(context, s); |
| 1444 | BrotliEncoderDestroyInstancecxx . . $ BrotliEncoderDestroyInstance(1a02c58e233dd44).(s); |
| 1445 | rm_output = !is_ok; |
| 1446 | if (is_ok && context->reject_uncompressiblecxx . . $ $anonymous_type_2fa36e8c50d79419_2#reject_uncompressible.) { |
| 1447 | if (context->total_outcxx . . $ $anonymous_type_2fa36e8c50d79419_2#total_out. >= context->total_incxx . . $ $anonymous_type_2fa36e8c50d79419_2#total_in.) { |
| 1448 | rm_output = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 1449 | if (context->verbositycxx . . $ $anonymous_type_2fa36e8c50d79419_2#verbosity. > 0) { |
| 1450 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "Output is larger than input\n"); |
| 1451 | } |
| 1452 | } |
| 1453 | } |
| 1454 | rm_input = !rm_output && context->junk_sourcecxx . . $ $anonymous_type_2fa36e8c50d79419_2#junk_source.; |
| 1455 | if (!CloseFilescxx . . $ CloseFiles(8b4f405b414d876d).(context, rm_input, rm_output)) is_ok = BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 1456 | if (!is_ok) return BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 1457 | } |
| 1458 | return BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 1459 | } |
| 1460 | |
| 1461 | int maincxx . . $ main(afcd3168fc1188a4).(int argc, char** argv) { |
| 1462 | Commandcxx . . $ Command# command; |
| 1463 | Contextcxx . . $ Context# context; |
| 1464 | BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! is_ok = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 1465 | int i; |
| 1466 | |
| 1467 | context.qualitycxx . . $ $anonymous_type_2fa36e8c50d79419_2#quality. = 11; |
| 1468 | context.lgwincxx . . $ $anonymous_type_2fa36e8c50d79419_2#lgwin. = -1; |
| 1469 | context.verbositycxx . . $ $anonymous_type_2fa36e8c50d79419_2#verbosity. = 0; |
| 1470 | context.comment_lencxx . . $ $anonymous_type_2fa36e8c50d79419_2#comment_len. = 0; |
| 1471 | context.force_overwritecxx . . $ $anonymous_type_2fa36e8c50d79419_2#force_overwrite. = BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 1472 | context.junk_sourcecxx . . $ $anonymous_type_2fa36e8c50d79419_2#junk_source. = BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 1473 | context.reject_uncompressiblecxx . . $ $anonymous_type_2fa36e8c50d79419_2#reject_uncompressible. = BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 1474 | context.copy_statcxx . . $ $anonymous_type_2fa36e8c50d79419_2#copy_stat. = BROTLI_TRUEcxx . . $ `c/include/brotli/types.h:51:9`!; |
| 1475 | context.test_integritycxx . . $ $anonymous_type_2fa36e8c50d79419_2#test_integrity. = BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 1476 | context.write_to_stdoutcxx . . $ $anonymous_type_2fa36e8c50d79419_2#write_to_stdout. = BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 1477 | context.decompresscxx . . $ $anonymous_type_2fa36e8c50d79419_2#decompress. = BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 1478 | context.large_windowcxx . . $ $anonymous_type_2fa36e8c50d79419_2#large_window. = BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 1479 | context.allow_concatenatedcxx . . $ $anonymous_type_2fa36e8c50d79419_2#allow_concatenated. = BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 1480 | context.output_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#output_path. = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!; |
| 1481 | context.dictionary_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#dictionary_path. = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!; |
| 1482 | context.suffixcxx . . $ $anonymous_type_2fa36e8c50d79419_2#suffix. = DEFAULT_SUFFIXcxx . . $ `c/tools/brotli.c:114:9`!; |
| 1483 | for (i = 0; i < MAX_OPTIONScxx . . $ `c/tools/brotli.c:115:9`!; ++i) context.not_input_indicescxx . . $ $anonymous_type_2fa36e8c50d79419_2#not_input_indices.[i] = 0; |
| 1484 | context.longest_path_lencxx . . $ $anonymous_type_2fa36e8c50d79419_2#longest_path_len. = 1; |
| 1485 | context.input_countcxx . . $ $anonymous_type_2fa36e8c50d79419_2#input_count. = 0; |
| 1486 | |
| 1487 | context.argccxx . . $ $anonymous_type_2fa36e8c50d79419_2#argc. = argc; |
| 1488 | context.argvcxx . . $ $anonymous_type_2fa36e8c50d79419_2#argv. = argv; |
| 1489 | context.dictionarycxx . . $ $anonymous_type_2fa36e8c50d79419_2#dictionary. = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!; |
| 1490 | context.dictionary_sizecxx . . $ $anonymous_type_2fa36e8c50d79419_2#dictionary_size. = 0; |
| 1491 | context.decodercxx . . $ $anonymous_type_2fa36e8c50d79419_2#decoder. = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!; |
| 1492 | context.prepared_dictionarycxx . . $ $anonymous_type_2fa36e8c50d79419_2#prepared_dictionary. = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!; |
| 1493 | context.modified_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#modified_path. = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!; |
| 1494 | context.iteratorcxx . . $ $anonymous_type_2fa36e8c50d79419_2#iterator. = 0; |
| 1495 | context.ignorecxx . . $ $anonymous_type_2fa36e8c50d79419_2#ignore. = 0; |
| 1496 | context.iterator_errorcxx . . $ $anonymous_type_2fa36e8c50d79419_2#iterator_error. = BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 1497 | context.buffercxx . . $ $anonymous_type_2fa36e8c50d79419_2#buffer. = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!; |
| 1498 | context.current_input_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#current_input_path. = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!; |
| 1499 | context.current_output_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#current_output_path. = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!; |
| 1500 | context.fincxx . . $ $anonymous_type_2fa36e8c50d79419_2#fin. = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!; |
| 1501 | context.foutcxx . . $ $anonymous_type_2fa36e8c50d79419_2#fout. = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!; |
| 1502 | |
| 1503 | command = ParseParamscxx . . $ ParseParams(6d969980f8fd0953).(&context); |
| 1504 | |
| 1505 | if (command == COMMAND_COMPRESScxx . . $ COMMAND_COMPRESS. || command == COMMAND_DECOMPRESScxx . . $ COMMAND_DECOMPRESS. || |
| 1506 | command == COMMAND_TEST_INTEGRITYcxx . . $ COMMAND_TEST_INTEGRITY.) { |
| 1507 | if (!ReadDictionarycxx . . $ ReadDictionary(6f1c2f27c0d20675).(&context, command)) is_ok = BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 1508 | if (is_ok) { |
| 1509 | size_t modified_path_len = |
| 1510 | context.longest_path_lencxx . . $ $anonymous_type_2fa36e8c50d79419_2#longest_path_len. + strlencxx . . $ strlen(751346f8406fd082).(context.suffixcxx . . $ $anonymous_type_2fa36e8c50d79419_2#suffix.) + 1; |
| 1511 | context.modified_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#modified_path. = (char*)malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(modified_path_len); |
| 1512 | context.buffercxx . . $ $anonymous_type_2fa36e8c50d79419_2#buffer. = (uint8_tcxx . . $ uint8_t#*)malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(kFileBufferSizecxx . . $ kFileBufferSize. * 2); |
| 1513 | if (!context.modified_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#modified_path. || !context.buffercxx . . $ $anonymous_type_2fa36e8c50d79419_2#buffer.) { |
| 1514 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "out of memory\n"); |
| 1515 | is_ok = BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 1516 | } else { |
| 1517 | context.inputcxx . . $ $anonymous_type_2fa36e8c50d79419_2#input. = context.buffercxx . . $ $anonymous_type_2fa36e8c50d79419_2#buffer.; |
| 1518 | context.outputcxx . . $ $anonymous_type_2fa36e8c50d79419_2#output. = context.buffercxx . . $ $anonymous_type_2fa36e8c50d79419_2#buffer. + kFileBufferSizecxx . . $ kFileBufferSize.; |
| 1519 | } |
| 1520 | } |
| 1521 | } |
| 1522 | |
| 1523 | if (!is_ok) command = COMMAND_NOOPcxx . . $ COMMAND_NOOP.; |
| 1524 | |
| 1525 | switch (command) { |
| 1526 | case COMMAND_NOOPcxx . . $ COMMAND_NOOP.: |
| 1527 | break; |
| 1528 | |
| 1529 | case COMMAND_VERSIONcxx . . $ COMMAND_VERSION.: |
| 1530 | PrintVersioncxx . . $ PrintVersion(49f6e7a06ebc5aa8).(); |
| 1531 | break; |
| 1532 | |
| 1533 | case COMMAND_COMPRESScxx . . $ COMMAND_COMPRESS.: |
| 1534 | is_ok = CompressFilescxx . . $ CompressFiles(bde9ac7206dc9e17).(&context); |
| 1535 | break; |
| 1536 | |
| 1537 | case COMMAND_DECOMPRESScxx . . $ COMMAND_DECOMPRESS.: |
| 1538 | case COMMAND_TEST_INTEGRITYcxx . . $ COMMAND_TEST_INTEGRITY.: |
| 1539 | is_ok = DecompressFilescxx . . $ DecompressFiles(bde9ac7206dc9e17).(&context); |
| 1540 | break; |
| 1541 | |
| 1542 | case COMMAND_HELPcxx . . $ COMMAND_HELP.: |
| 1543 | case COMMAND_INVALIDcxx . . $ COMMAND_INVALID.: |
| 1544 | default: |
| 1545 | is_ok = (command == COMMAND_HELPcxx . . $ COMMAND_HELP.); |
| 1546 | PrintHelpcxx . . $ PrintHelp(34d26762b42c433a).(FileNamecxx . . $ FileName(fb58d2e09a2a1ce6).(argv[0]), is_ok); |
| 1547 | break; |
| 1548 | } |
| 1549 | |
| 1550 | if (context.iterator_errorcxx . . $ $anonymous_type_2fa36e8c50d79419_2#iterator_error.) is_ok = BROTLI_FALSEcxx . . $ `c/include/brotli/types.h:53:9`!; |
| 1551 | |
| 1552 | BrotliEncoderDestroyPreparedDictionarycxx . . $ BrotliEncoderDestroyPreparedDictionary(9fecac003ff0a949).(context.prepared_dictionarycxx . . $ $anonymous_type_2fa36e8c50d79419_2#prepared_dictionary.); |
| 1553 | freecxx . . $ free(5d22bdacc48458e8).(context.dictionarycxx . . $ $anonymous_type_2fa36e8c50d79419_2#dictionary.); |
| 1554 | freecxx . . $ free(5d22bdacc48458e8).(context.modified_pathcxx . . $ $anonymous_type_2fa36e8c50d79419_2#modified_path.); |
| 1555 | freecxx . . $ free(5d22bdacc48458e8).(context.buffercxx . . $ $anonymous_type_2fa36e8c50d79419_2#buffer.); |
| 1556 | |
| 1557 | if (!is_ok) exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 1558 | return 0; |
| 1559 | } |