| 238 | } |
| 239 | |
| 240 | static int write_option(void *optctx, const OptionDef *po, const char *opt, |
| 241 | const char *arg, const OptionDef *defs) |
| 242 | { |
| 243 | /* new-style options contain an offset into optctx, old-style address of |
| 244 | * a global var*/ |
| 245 | void *dst = po->flags & OPT_FLAG_OFFSET ? |
| 246 | (uint8_t *)optctx + po->u.off : po->u.dst_ptr; |
| 247 | char *arg_allocated = NULL; |
| 248 | |
| 249 | enum OptionType so_type = po->type; |
| 250 | |
| 251 | SpecifierOptList *sol = NULL; |
| 252 | double num; |
| 253 | int ret = 0; |
| 254 | |
| 255 | if (*opt == '/') { |
| 256 | opt++; |
| 257 | |
| 258 | if (!opt_has_arg(po)) { |
| 259 | av_log(NULL, AV_LOG_FATAL, |
| 260 | "Requested to load an argument from file for an option '%s'" |
| 261 | " which does not take an argument\n", |
| 262 | po->name); |
| 263 | return AVERROR(EINVAL); |
| 264 | } |
| 265 | |
| 266 | arg_allocated = read_file_to_string(arg); |
| 267 | if (!arg_allocated) { |
| 268 | av_log(NULL, AV_LOG_FATAL, |
| 269 | "Error reading the value for option '%s' from file: %s\n", |
| 270 | opt, arg); |
| 271 | return AVERROR(EINVAL); |
| 272 | } |
| 273 | |
| 274 | arg = arg_allocated; |
| 275 | } |
| 276 | |
| 277 | if (po->flags & OPT_FLAG_SPEC) { |
| 278 | const char *p = strchr(opt, ':'); |
| 279 | char *str; |
| 280 | |
| 281 | sol = dst; |
| 282 | ret = GROW_ARRAY(sol->opt, sol->nb_opt); |
| 283 | if (ret < 0) |
| 284 | goto finish; |
| 285 | |
| 286 | str = av_strdup(p ? p + 1 : ""); |
| 287 | if (!str) { |
| 288 | ret = AVERROR(ENOMEM); |
| 289 | goto finish; |
| 290 | } |
| 291 | sol->opt[sol->nb_opt - 1].specifier = str; |
| 292 | |
| 293 | if (po->flags & OPT_FLAG_PERSTREAM) { |
| 294 | ret = stream_specifier_parse(&sol->opt[sol->nb_opt - 1].stream_spec, |
| 295 | str, 0, NULL); |
| 296 | if (ret < 0) |
| 297 | goto finish; |
no test coverage detected