Пример #1
0
static void
x3p_start_element(G_GNUC_UNUSED GMarkupParseContext *context,
                  const gchar *element_name,
                  G_GNUC_UNUSED const gchar **attribute_names,
                  G_GNUC_UNUSED const gchar **attribute_values,
                  gpointer user_data,
                  GError **error)
{
    X3PFile *x3pfile = (X3PFile*)user_data;
    gchar *path;

    element_name = remove_namespace(element_name);
    g_string_append_c(x3pfile->path, '/');
    g_string_append(x3pfile->path, element_name);
    path = x3pfile->path->str;
    gwy_debug("%s", path);

    if (gwy_strequal(path, "/ISO5436_2/Record3/DataLink")
        || gwy_strequal(path, "/ISO5436_2/Record3/DataList")) {
        if (!data_start(x3pfile, error))
            return;
    }

    if (gwy_strequal(path, "/ISO5436_2/Record3/DataList/Datum"))
        x3pfile->seen_datum = FALSE;
}
Пример #2
0
static int copy_body(void)
{
  int sawcr = 0;		/* Was the last character a CR */
  unsigned linepos = 0;		/* The number of bytes since the last LF */
  int sawperiod = 0;		/* True if the first character was a period */
  char ch;

  data_start();
  while (ibuf_getc(&inbuf, &ch)) {
    switch (ch) {
    case LF:
      if (sawperiod && linepos == 0) { message_end(); return 1; }
      data_byte(ch);
      sawperiod = sawcr = linepos = 0;
      break;
    case CR:
      if (sawcr) { data_byte(CR); ++linepos; }
      sawcr = 1;
      break;
    default:
      if (ch == PERIOD && !sawperiod && linepos == 0)
	sawperiod = 1;
      else {
	sawperiod = 0;
	if (sawcr) { data_byte(CR); ++linepos; sawcr = 0; }
	data_byte(ch); ++linepos;
      }
    }
  }
  return 0;
}