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;
}
Beispiel #2
0
static void
gdaui_entry_string_set_property (GObject *object,
				 guint param_id,
				 const GValue *value,
				 GParamSpec *pspec)
{
	GdauiEntryString *mgstr;

	mgstr = GDAUI_ENTRY_STRING (object);
	GdauiEntryStringPrivate *priv = gdaui_entry_string_get_instance_private (mgstr);
	switch (param_id) {
		case PROP_MULTILINE:
			if (g_value_get_boolean (value) != priv->multiline) {
				priv->multiline = g_value_get_boolean (value);
				if (priv->multiline) {
					gtk_widget_hide (priv->entry);
					gtk_widget_show (priv->sw);
					gtk_widget_set_vexpand (GTK_WIDGET (mgstr), TRUE);
				}
				else {
					gtk_widget_show (priv->entry);
					gtk_widget_hide (priv->sw);
					gtk_widget_set_vexpand (GTK_WIDGET (mgstr), FALSE);
				}
				g_signal_emit_by_name (object, "expand-changed");
			}
			break;
		case PROP_OPTIONS:
			set_entry_options (mgstr, g_value_get_string (value));
			break;
		case PROP_EDITING_CANCELED:
			TO_IMPLEMENT;
			break;
		default:
			G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
			break;
	}
}