chromium/third_party/brotli/tools/brotli.c

/* Copyright 2014 Google Inc. All Rights Reserved.

   Distributed under MIT license.
   See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
*/

/* Command line interface for Brotli library. */

/* Mute strerror/strcpy warnings. */
#if !defined(_CRT_SECURE_NO_WARNINGS)
#define _CRT_SECURE_NO_WARNINGS
#endif

#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <time.h>

#include "../common/constants.h"
#include "../common/version.h"
#include <brotli/decode.h>
#include <brotli/encode.h>

#if !defined(_WIN32)
#include <unistd.h>
#include <utime.h>
#define MAKE_BINARY(FILENO)
#else
#include <io.h>
#include <share.h>
#include <sys/utime.h>

#define MAKE_BINARY

#if !defined(__MINGW32__)
#define STDIN_FILENO
#define STDOUT_FILENO
#define S_IRUSR
#define S_IWUSR
#endif

#define fdopen
#define isatty
#define unlink
#define utimbuf
#define utime

#define fopen
#define open

#define chmod
#define chown

#if defined(_MSC_VER) && (_MSC_VER >= 1400)
#define fseek
#define ftell
#endif

static FILE* ms_fopen(const char* filename, const char* mode) {
  FILE* result = 0;
  fopen_s(&result, filename, mode);
  return result;
}

static int ms_open(const char* filename, int oflag, int pmode) {
  int result = -1;
  _sopen_s(&result, filename, oflag | O_BINARY, _SH_DENYNO, pmode);
  return result;
}
#endif  /* WIN32 */

Command;

#define DEFAULT_LGWIN
#define DEFAULT_SUFFIX
#define MAX_OPTIONS

Context;

/* Parse up to 5 decimal digits. */
static BROTLI_BOOL ParseInt(const char* s, int low, int high, int* result) {}

/* Returns "base file name" or its tail, if it contains '/' or '\'. */
static const char* FileName(const char* path) {}

/* Detect if the program name is a special alias that infers a command type. */
static Command ParseAlias(const char* name) {}

static Command ParseParams(Context* params) {}

static void PrintVersion(void) {}

static void PrintHelp(const char* name, BROTLI_BOOL error) {}

static const char* PrintablePath(const char* path) {}

static BROTLI_BOOL OpenInputFile(const char* input_path, FILE** f) {}

static BROTLI_BOOL OpenOutputFile(const char* output_path, FILE** f,
                                  BROTLI_BOOL force) {}

static int64_t FileSize(const char* path) {}

/* Copy file times and permissions.
   TODO(eustas): this is a "best effort" implementation; honest cross-platform
   fully featured implementation is way too hacky; add more hacks by request. */
static void CopyStat(const char* input_path, const char* output_path) {}

/* Result ownership is passed to caller.
   |*dictionary_size| is set to resulting buffer size. */
static BROTLI_BOOL ReadDictionary(Context* context, Command command) {}

static BROTLI_BOOL NextFile(Context* context) {}

static BROTLI_BOOL OpenFiles(Context* context) {}

static BROTLI_BOOL CloseFiles(Context* context, BROTLI_BOOL success) {}

static const size_t kFileBufferSize =;

static void InitializeBuffers(Context* context) {}

/* This method might give the false-negative result.
   However, after an empty / incomplete read it should tell the truth. */
static BROTLI_BOOL HasMoreInput(Context* context) {}

static BROTLI_BOOL ProvideInput(Context* context) {}

/* Internal: should be used only in Provide-/Flush-Output. */
static BROTLI_BOOL WriteOutput(Context* context) {}

static BROTLI_BOOL ProvideOutput(Context* context) {}

static BROTLI_BOOL FlushOutput(Context* context) {}

static void PrintBytes(size_t value) {}

static void PrintFileProcessingProgress(Context* context) {}

static BROTLI_BOOL DecompressFile(Context* context, BrotliDecoderState* s) {}

static BROTLI_BOOL DecompressFiles(Context* context) {}

static BROTLI_BOOL CompressFile(Context* context, BrotliEncoderState* s) {}

static BROTLI_BOOL CompressFiles(Context* context) {}

int main(int argc, char** argv) {}