Deleted Added
full compact
options.c (207842) options.c (213700)
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.

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

134 name = split + 1;
135 }
136
137 free(s);
138 return;
139}
140
141
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.

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

134 name = split + 1;
135 }
136
137 free(s);
138 return;
139}
140
141
142//////////////
143// Subblock //
144//////////////
145
146enum {
147 OPT_SIZE,
148 OPT_RLE,
149 OPT_ALIGN,
150};
151
152
153static void
154set_subblock(void *options, uint32_t key, uint64_t value,
155 const char *valuestr lzma_attribute((unused)))
156{
157 lzma_options_subblock *opt = options;
158
159 switch (key) {
160 case OPT_SIZE:
161 opt->subblock_data_size = value;
162 break;
163
164 case OPT_RLE:
165 opt->rle = value;
166 break;
167
168 case OPT_ALIGN:
169 opt->alignment = value;
170 break;
171 }
172}
173
174
175extern lzma_options_subblock *
176options_subblock(const char *str)
177{
178 static const option_map opts[] = {
179 { "size", NULL, LZMA_SUBBLOCK_DATA_SIZE_MIN,
180 LZMA_SUBBLOCK_DATA_SIZE_MAX },
181 { "rle", NULL, LZMA_SUBBLOCK_RLE_OFF,
182 LZMA_SUBBLOCK_RLE_MAX },
183 { "align",NULL, LZMA_SUBBLOCK_ALIGNMENT_MIN,
184 LZMA_SUBBLOCK_ALIGNMENT_MAX },
185 { NULL, NULL, 0, 0 }
186 };
187
188 lzma_options_subblock *options
189 = xmalloc(sizeof(lzma_options_subblock));
190 *options = (lzma_options_subblock){
191 .allow_subfilters = false,
192 .alignment = LZMA_SUBBLOCK_ALIGNMENT_DEFAULT,
193 .subblock_data_size = LZMA_SUBBLOCK_DATA_SIZE_DEFAULT,
194 .rle = LZMA_SUBBLOCK_RLE_OFF,
195 };
196
197 parse_options(str, opts, &set_subblock, options);
198
199 return options;
200}
201
202
203///////////
204// Delta //
205///////////
206
207enum {
208 OPT_DIST,
209};
210

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

402 { "mode", modes, 0, 0 },
403 { "nice", NULL, 2, 273 },
404 { "mf", mfs, 0, 0 },
405 { "depth", NULL, 0, UINT32_MAX },
406 { NULL, NULL, 0, 0 }
407 };
408
409 lzma_options_lzma *options = xmalloc(sizeof(lzma_options_lzma));
142///////////
143// Delta //
144///////////
145
146enum {
147 OPT_DIST,
148};
149

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

341 { "mode", modes, 0, 0 },
342 { "nice", NULL, 2, 273 },
343 { "mf", mfs, 0, 0 },
344 { "depth", NULL, 0, UINT32_MAX },
345 { NULL, NULL, 0, 0 }
346 };
347
348 lzma_options_lzma *options = xmalloc(sizeof(lzma_options_lzma));
410 *options = (lzma_options_lzma){
411 .dict_size = LZMA_DICT_SIZE_DEFAULT,
412 .preset_dict = NULL,
413 .preset_dict_size = 0,
414 .lc = LZMA_LC_DEFAULT,
415 .lp = LZMA_LP_DEFAULT,
416 .pb = LZMA_PB_DEFAULT,
417 .mode = LZMA_MODE_NORMAL,
418 .nice_len = 64,
419 .mf = LZMA_MF_BT4,
420 .depth = 0,
421 };
349 if (lzma_lzma_preset(options, LZMA_PRESET_DEFAULT))
350 message_bug();
422
423 parse_options(str, opts, &set_lzma, options);
424
425 if (options->lc + options->lp > LZMA_LCLP_MAX)
351
352 parse_options(str, opts, &set_lzma, options);
353
354 if (options->lc + options->lp > LZMA_LCLP_MAX)
426 message_fatal(_("The sum of lc and lp must be at "
427 "maximum of 4"));
355 message_fatal(_("The sum of lc and lp must not exceed 4"));
428
429 const uint32_t nice_len_min = options->mf & 0x0F;
430 if (options->nice_len < nice_len_min)
431 message_fatal(_("The selected match finder requires at "
432 "least nice=%" PRIu32), nice_len_min);
433
434 return options;
435}
356
357 const uint32_t nice_len_min = options->mf & 0x0F;
358 if (options->nice_len < nice_len_min)
359 message_fatal(_("The selected match finder requires at "
360 "least nice=%" PRIu32), nice_len_min);
361
362 return options;
363}