2
0

config.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * Copyright (c) Facebook, Inc.
  3. * All rights reserved.
  4. *
  5. * This source code is licensed under both the BSD-style license (found in the
  6. * LICENSE file in the root directory of this source tree) and the GPLv2 (found
  7. * in the COPYING file in the root directory of this source tree).
  8. * You may select, at your option, one of the above-listed licenses.
  9. */
  10. #ifndef CONFIG_H
  11. #define CONFIG_H
  12. #include <stddef.h>
  13. #define ZSTD_STATIC_LINKING_ONLY
  14. #include <zstd.h>
  15. #include "data.h"
  16. typedef struct {
  17. ZSTD_cParameter param;
  18. int value;
  19. } param_value_t;
  20. typedef struct {
  21. size_t size;
  22. param_value_t const* data;
  23. } param_values_t;
  24. /**
  25. * The config tells the compression method what options to use.
  26. */
  27. typedef struct {
  28. const char* name; /**< Identifies the config in the results table */
  29. /**
  30. * Optional arguments to pass to the CLI. If not set, CLI-based methods
  31. * will skip this config.
  32. */
  33. char const* cli_args;
  34. /**
  35. * Parameters to pass to the advanced API. If the advanced API isn't used,
  36. * the parameters will be derived from these.
  37. */
  38. param_values_t param_values;
  39. /**
  40. * Boolean parameter that says if we should use a dictionary. If the data
  41. * doesn't have a dictionary, this config is skipped. Defaults to no.
  42. */
  43. int use_dictionary;
  44. /**
  45. * Boolean parameter that says if we should pass the pledged source size
  46. * when the method allows it. Defaults to yes.
  47. */
  48. int no_pledged_src_size;
  49. /**
  50. * Boolean parameter that says that this config should only be used
  51. * for methods that use the advanced compression API
  52. */
  53. int advanced_api_only;
  54. } config_t;
  55. /**
  56. * Returns true if the config should skip this data.
  57. * For instance, if the config requires a dictionary but the data doesn't have
  58. * one.
  59. */
  60. int config_skip_data(config_t const* config, data_t const* data);
  61. #define CONFIG_NO_LEVEL (-ZSTD_TARGETLENGTH_MAX - 1)
  62. /**
  63. * Returns the compression level specified by the config, or CONFIG_NO_LEVEL if
  64. * no level is specified. Note that 0 is a valid compression level, meaning
  65. * default.
  66. */
  67. int config_get_level(config_t const* config);
  68. /**
  69. * Returns the compression parameters specified by the config.
  70. */
  71. ZSTD_parameters config_get_zstd_params(
  72. config_t const* config,
  73. uint64_t srcSize,
  74. size_t dictSize);
  75. /**
  76. * The NULL-terminated list of configs.
  77. */
  78. extern config_t const* const* configs;
  79. #endif