Deleted Added
full compact
options.c (278433) options.c (291125)
1///////////////////////////////////////////////////////////////////////////////
2//
3/// \file options.c
4/// \brief Parser for filter-specific options
5//
6// Author: Lasse Collin
7//
8// This file has been put into the public domain.

--- 45 unchanged lines hidden (view full) ---

54/// \param set Filter-specific function to update filter_options
55/// \param filter_options Pointer to filter-specific options structure
56///
57/// \return Returns only if no errors occur.
58///
59static void
60parse_options(const char *str, const option_map *opts,
61 void (*set)(void *filter_options,
1///////////////////////////////////////////////////////////////////////////////
2//
3/// \file options.c
4/// \brief Parser for filter-specific options
5//
6// Author: Lasse Collin
7//
8// This file has been put into the public domain.

--- 45 unchanged lines hidden (view full) ---

54/// \param set Filter-specific function to update filter_options
55/// \param filter_options Pointer to filter-specific options structure
56///
57/// \return Returns only if no errors occur.
58///
59static void
60parse_options(const char *str, const option_map *opts,
61 void (*set)(void *filter_options,
62 uint32_t key, uint64_t value, const char *valuestr),
62 unsigned key, uint64_t value, const char *valuestr),
63 void *filter_options)
64{
65 if (str == NULL || str[0] == '\0')
66 return;
67
68 char *s = xstrdup(str);
69 char *name = s;
70

--- 11 unchanged lines hidden (view full) ---

82 if (value != NULL)
83 *value++ = '\0';
84
85 if (value == NULL || value[0] == '\0')
86 message_fatal(_("%s: Options must be `name=value' "
87 "pairs separated with commas"), str);
88
89 // Look for the option name from the option map.
63 void *filter_options)
64{
65 if (str == NULL || str[0] == '\0')
66 return;
67
68 char *s = xstrdup(str);
69 char *name = s;
70

--- 11 unchanged lines hidden (view full) ---

82 if (value != NULL)
83 *value++ = '\0';
84
85 if (value == NULL || value[0] == '\0')
86 message_fatal(_("%s: Options must be `name=value' "
87 "pairs separated with commas"), str);
88
89 // Look for the option name from the option map.
90 size_t i = 0;
90 unsigned i = 0;
91 while (true) {
92 if (opts[i].name == NULL)
93 message_fatal(_("%s: Invalid option name"),
94 name);
95
96 if (strcmp(name, opts[i].name) == 0)
97 break;
98
99 ++i;
100 }
101
102 // Option was found from the map. See how we should handle it.
103 if (opts[i].map != NULL) {
104 // value is a string which we should map
105 // to an integer.
91 while (true) {
92 if (opts[i].name == NULL)
93 message_fatal(_("%s: Invalid option name"),
94 name);
95
96 if (strcmp(name, opts[i].name) == 0)
97 break;
98
99 ++i;
100 }
101
102 // Option was found from the map. See how we should handle it.
103 if (opts[i].map != NULL) {
104 // value is a string which we should map
105 // to an integer.
106 size_t j;
106 unsigned j;
107 for (j = 0; opts[i].map[j].name != NULL; ++j) {
108 if (strcmp(opts[i].map[j].name, value) == 0)
109 break;
110 }
111
112 if (opts[i].map[j].name == NULL)
113 message_fatal(_("%s: Invalid option value"),
114 value);

--- 29 unchanged lines hidden (view full) ---

144///////////
145
146enum {
147 OPT_DIST,
148};
149
150
151static void
107 for (j = 0; opts[i].map[j].name != NULL; ++j) {
108 if (strcmp(opts[i].map[j].name, value) == 0)
109 break;
110 }
111
112 if (opts[i].map[j].name == NULL)
113 message_fatal(_("%s: Invalid option value"),
114 value);

--- 29 unchanged lines hidden (view full) ---

144///////////
145
146enum {
147 OPT_DIST,
148};
149
150
151static void
152set_delta(void *options, uint32_t key, uint64_t value,
152set_delta(void *options, unsigned key, uint64_t value,
153 const char *valuestr lzma_attribute((__unused__)))
154{
155 lzma_options_delta *opt = options;
156 switch (key) {
157 case OPT_DIST:
158 opt->dist = value;
159 break;
160 }

--- 27 unchanged lines hidden (view full) ---

188/////////
189
190enum {
191 OPT_START_OFFSET,
192};
193
194
195static void
153 const char *valuestr lzma_attribute((__unused__)))
154{
155 lzma_options_delta *opt = options;
156 switch (key) {
157 case OPT_DIST:
158 opt->dist = value;
159 break;
160 }

--- 27 unchanged lines hidden (view full) ---

188/////////
189
190enum {
191 OPT_START_OFFSET,
192};
193
194
195static void
196set_bcj(void *options, uint32_t key, uint64_t value,
196set_bcj(void *options, unsigned key, uint64_t value,
197 const char *valuestr lzma_attribute((__unused__)))
198{
199 lzma_options_bcj *opt = options;
200 switch (key) {
201 case OPT_START_OFFSET:
202 opt->start_offset = value;
203 break;
204 }

--- 39 unchanged lines hidden (view full) ---

244static void lzma_attribute((__noreturn__))
245error_lzma_preset(const char *valuestr)
246{
247 message_fatal(_("Unsupported LZMA1/LZMA2 preset: %s"), valuestr);
248}
249
250
251static void
197 const char *valuestr lzma_attribute((__unused__)))
198{
199 lzma_options_bcj *opt = options;
200 switch (key) {
201 case OPT_START_OFFSET:
202 opt->start_offset = value;
203 break;
204 }

--- 39 unchanged lines hidden (view full) ---

244static void lzma_attribute((__noreturn__))
245error_lzma_preset(const char *valuestr)
246{
247 message_fatal(_("Unsupported LZMA1/LZMA2 preset: %s"), valuestr);
248}
249
250
251static void
252set_lzma(void *options, uint32_t key, uint64_t value, const char *valuestr)
252set_lzma(void *options, unsigned key, uint64_t value, const char *valuestr)
253{
254 lzma_options_lzma *opt = options;
255
256 switch (key) {
257 case OPT_PRESET: {
258 if (valuestr[0] < '0' || valuestr[0] > '9')
259 error_lzma_preset(valuestr);
260

--- 103 unchanged lines hidden ---
253{
254 lzma_options_lzma *opt = options;
255
256 switch (key) {
257 case OPT_PRESET: {
258 if (valuestr[0] < '0' || valuestr[0] > '9')
259 error_lzma_preset(valuestr);
260

--- 103 unchanged lines hidden ---