static int _set_global_option(lua_State * L) { options o = get_global_options(L); push_options(L, o); lua_insert(L, 1); options_update(L); o = to_options(L, -1); set_global_options(L, o); return 0; }
static int output_img_with_config(FILE *img_fp, FILE *cfg_fp) { int entry_count = parse_config_entry_count(cfg_fp); struct dt_image_writer *writer = dt_image_writer_start(img_fp, entry_count); fseek(cfg_fp, 0, SEEK_SET); /* Reset the file pos to head */ int is_entry = 0; char line[1024]; while (fgets(line, sizeof(line), cfg_fp) != NULL) { char *trimmed = trim_line(line); if (trimmed[0] == '\0') { /* empty line, pass */ continue; } if (trimmed == line) { /* This line is a file name, because it start from the first char of the line */ if (dt_image_writer_add_entry(writer, trimmed) != 0) { return -1; } is_entry = 1; continue; } char *option, *value; if (parse_option(&option, &value, trimmed) != 0) { fprintf(stderr, "Wrong syntax: %s\n", trimmed); return -1; } int ret = is_entry ? set_entry_options(writer, option, value) : set_global_options(writer, option, value); if (ret != 0) { fprintf(stderr, "Unknown option: %s\n", option); return -1; } } if (dt_image_writer_end(writer) != 0) { return -1; } return 0; }
static int _set_global_options(lua_State * L) { options o = to_options(L, 1); set_global_options(L, o); return 0; }