Esempio n. 1
0
static void parseEventDescription(void *data, enum ER round) {
    assert(GetDescriptorTag(data) == 0x4D);
    struct descr_short_event *evtdesc = data;
    char evt[256];
    char dsc[256];

    int evtlen = evtdesc->event_name_length;
    if (round == TITLE) {
        if (!evtlen)
            return;
        assert(evtlen < sizeof(evt));
        memcpy(evt, (char *)&evtdesc->data, evtlen);
        evt[evtlen] = '\0';
        printf("\t<title lang=\"%s\">%s</title>\n", xmllang(&evtdesc->lang_code1), xmlify(evt));
        return;
    }

    if (round == SUB_TITLE) {
        int dsclen = evtdesc->data[evtlen];
        assert(dsclen < sizeof(dsc));
        memcpy(dsc, (char *)&evtdesc->data[evtlen+1], dsclen);
        dsc[dsclen] = '\0';

        if (*dsc) {
            char *d = xmlify(dsc);
            if (d && *d)
                printf("\t<sub-title lang=\"%s\">%s</sub-title>\n", xmllang(&evtdesc->lang_code1), d);
        }
    }
} /*}}}*/
Esempio n. 2
0
File: gdlme2.c Progetto: oracc/oracc
void
gdlme_eH(void *userData, const char *name)
{
  if (gdlme)
    {
      unsigned char *gdlinput = (unsigned char *)charData_retrieve();
      struct node *res = NULL;
      if (pi_file)
	{
	  file = (char*)pi_file;
	  lnum = pi_line;
	}
      if (gdlme_debug)
	fprintf(f_log, "%s:%d: gdlme processing `%s'\n", pi_file, pi_line, gdlinput);

      res = gdl(gdlinput, GDL_FRAG_OK);
      if (res && res->children.lastused)
	{
	  int i;
	  for (i = 0; i < res->children.lastused; ++i)
	    serialize(res->children.nodes[i],0);
	}
      else
	fprintf(f_log,"%s:%d: conversion of '%s' failed\n", pi_file, pi_line, gdlinput);
      gdlme = 0;
    }
  else
    {
      const char *s = charData_retrieve();
      fprintf(f_xml,"%s",(const char*)xmlify((unsigned char *)s));
    }
  if (*name != 'r' || strcmp(name,"rp-wrap"))
    fprintf(f_xml,"</%s>",name);
}
Esempio n. 3
0
static void
lem_serialize_one_xml(FILE *fp, struct ilem_form *f, struct serializer_frame *sfp)
{
  if (sfp->lit)
    {
      fputs((char*)xmlify((unsigned char*)sfp->lit),fp);
    }
  else
    {
      if (*sfp->pre)
	fputs((char*)xmlify((unsigned char *)sfp->pre), fp);

      /*warning("weird error: form->literal is NULL");*/
      if (f->f2.norm || f->f2.cf)
	{
	  if (strcmp((char*)f->f2.lang,"sux") && f->f2.norm)
	    fputs((char*)xmlify((unsigned char*)f->f2.norm),fp);
	  else
	    fputs((char*)xmlify(f->f2.cf),fp);
	  if (f->f2.sense)
	    fprintf(fp,"[%s]",(char*)xmlify((unsigned char *)f->f2.sense));
	  else
	    fprintf(fp,"[%s]",xmlify(f->f2.gw));
	  if (f->f2.epos && strcmp((char*)f->f2.pos,(char*)f->f2.epos))
	    fprintf(fp,"'%s",xmlify(f->f2.epos));
	  else
	    fputs((char*)xmlify(f->f2.pos),fp);
	}
      else if (f->f2.pos)
	{
	  fputs((char*)xmlify(f->f2.pos),fp);
	}
      else
	{
	  fputs("???",fp);
	}

      if (*sfp->pst)
	fputs((char*)xmlify((unsigned char *)sfp->pst), fp);
    }
  if (f->ambig)
    {
      fputc('|', fp);
      lem_serialize_one_xml(fp,f->ambig,sfp);
    }
}
Esempio n. 4
0
void QgsGPSPoint::writeXML( QTextStream& stream )
{
  QgsGPSObject::writeXML( stream );
  if ( ele != -std::numeric_limits<double>::max() )
    stream << "<ele>" << ele << "</ele>\n";
  if ( !sym.isEmpty() )
    stream << "<sym>" << xmlify( sym ) << "</sym>\n";
}
Esempio n. 5
0
/* Parse 0x4E Extended Event Descriptor. {{{ */
void parseLongEventDescription(void *data) {
    assert(GetDescriptorTag(data) == 0x4E);
    struct descr_extended_event *levt = data;
    char dsc[256];
    bool non_empty = (levt->descriptor_number || levt->last_descriptor_number || levt->length_of_items || levt->data[0]);

    if (non_empty && levt->descriptor_number == 0)
        printf("\t<desc lang=\"%s\">", xmllang(&levt->lang_code1));

    void *p = &levt->data;
    void *data_end = data + DESCR_GEN_LEN + GetDescriptorLength(data);
    while (p < (void *)levt->data + levt->length_of_items) {
        struct item_extended_event *name = p;
        int name_len = name->item_description_length;
        assert(p + ITEM_EXTENDED_EVENT_LEN + name_len < data_end);
        assert(name_len < sizeof(dsc));
        memcpy(dsc, (char *)&name->data, name_len);
        dsc[name_len] = '\0';
        printf("%s: ", xmlify(dsc));

        p += ITEM_EXTENDED_EVENT_LEN + name_len;

        struct item_extended_event *value = p;
        int value_len = value->item_description_length;
        assert(p + ITEM_EXTENDED_EVENT_LEN + value_len < data_end);
        assert(value_len < sizeof(dsc));
        memcpy(dsc, (char *)&value->data, value_len);
        dsc[value_len] = '\0';
        printf("%s; ", xmlify(dsc));

        p += ITEM_EXTENDED_EVENT_LEN + value_len;
    }
    struct item_extended_event *text = p;
    int len = text->item_description_length;
    if (non_empty && len) {
        assert(len < sizeof(dsc));
        memcpy(dsc, (char *)&text->data, len);
        dsc[len] = '\0';
        printf("%s", xmlify(dsc));
    }

    //printf("/%d/%d/%s", levt->descriptor_number, levt->last_descriptor_number, xmlify(dsc));
    if (non_empty && levt->descriptor_number == levt->last_descriptor_number)
        printf("</desc>\n");
} /*}}}*/
Esempio n. 6
0
static void
field_writer(struct cdt_field *fp)
{
  fprintf(wfile,"<oracc:field oracc:name=\"%s\">",fp->name);
  if (fp->inp)
    cdt_write_node_public(fp->inp);
  else
    fputs((const char *)xmlify(fp->text),wfile);
  fputs("</oracc:field>",wfile);
}
Esempio n. 7
0
File: gdlme2.c Progetto: oracc/oracc
static void
gdlme_sH(void *userData, const char *name, const char **atts)
{
  fprintf(f_xml,"%s",charData_retrieve());
  if (atts[0])
    {
      const char **attsp = atts;
      fprintf(f_xml,"<%s",name);
      while (attsp[0])
	{
	  if (!strcmp(attsp[0],"project"))
	    {
	      if (!xpd)
		xpd = xpd_init(attsp[1],gdl_pool);
	      fprintf(f_xml," %s=\"%s\"",attsp[0],xmlify((unsigned char *)attsp[1]));
	    }
	  else if (!strcmp(attsp[0],"g:me"))
	    gdlme = 1;
	  else if (!strcmp(attsp[0],"g:file"))
	    {
	      if (gdl_file_len <= strlen(attsp[1])+1)
		{
		  gdl_file_len = 2*strlen(attsp[1]);
		  gdl_file = realloc(gdl_file, gdl_file_len);
		}
	      file = strcpy(gdl_file,attsp[1]);
	    }
	  else if (!strcmp(attsp[0],"g:line"))
	    lnum = gdl_line = atoi(attsp[1]);
	  else
	    fprintf(f_xml," %s=\"%s\"",attsp[0],xmlify((unsigned char *)attsp[1]));
	  attsp += 2;
	}
      fputc('>',f_xml);
    }
  else
    {
      if (*name != 'r' || strcmp(name,"rp-wrap"))
	fprintf(f_xml,"<%s>",name);
    }
}
Esempio n. 8
0
void
lem_ods_serialize(FILE *fp)
{
  extern int ods_cols;
  /*extern char *odsods_fn;*/
  int i;
  fprintf(fp,"<lem cols=\"%d\">", ods_cols);
  for (i = 0; i < lem_lines_used; ++i)
    {
      if (lem_lines[i].forms)
	{
	  int j;
	  fprintf(fp,"<l n=\"%d\">",lem_lines[i].lnum);
	  for (j = 0; j < lem_lines[i].forms_used; ++j)
	    {
	      struct ilem_form *f = lem_lines[i].forms[j];
	      fprintf(fp,"<c n=\"%d\">",lem_lines[i].cells[j]);
	      if (use_literal(f->literal))
		{
		  fputs((char*)xmlify((unsigned char*)f->literal),fp);
		}
	      else
		{
		  static struct serializer_frame sframe;
		  set_sframe(&sframe, f->literal);

		  if (!f->f2.pos || (*f->f2.pos == 'X' && !f->f2.pos[1]) || *f->f2.pos == 'L')
		    f->f2.pos = (unsigned char*)lem_base_type((char*)f->f2.form);
		multi_entry:
		  lem_serialize_one_xml(fp,f,&sframe);
		  if (f->multi)
		    {
		      f = f->multi;
		      fputs("&amp;", fp);
		      goto multi_entry;
		    }
		}
#if 1
	      fputs("</c>",fp);
#else
	      if (j + 1 < lem_lines[i].forms_used)
		fputs("; ", fp);
#endif
	    }
	  fputs("</l>\n",fp);
	}
    }
  fputs("<xi:include xmlns:xi=\"http://www.w3.org/2001/XInclude\""
	" href=\"orig-content.xml\"/></lem>", 
	fp);
}
Esempio n. 9
0
/* See ETSI TS 102 323, section 12 */
void parseContentIdentifierDescription(void *data) {
    assert(GetDescriptorTag(data) == 0x76);
    struct descr_content_identifier *ci = data;
    void *p;
    for (p = &ci->data; p < data + ci->descriptor_length; /* at end */) {
        struct descr_content_identifier_crid *crid = p;
        struct descr_content_identifier_crid_local *crid_data;

        int crid_length = 3;

        char type_buf[32];
        char *type;
        char buf[256];

        type = lookup(crid_type_table, crid->crid_type);
        if (type == NULL)
        {
            type = type_buf;
            sprintf(type_buf, "0x%2x", crid->crid_type);
        }

        switch (crid->crid_location)
        {
        case 0x00: /* Carried explicitly within descriptor */
            crid_data = (descr_content_identifier_crid_local_t *)&crid->crid_ref_data;
            int cridlen = crid_data->crid_length;
            assert(cridlen < sizeof(buf));
            memcpy(buf, (char *)&crid_data->crid_byte, cridlen);
            buf[cridlen] = '\0';

            printf("\t<crid type='%s'>%s</crid>\n", type, xmlify(buf));
            crid_length = 2 + crid_data->crid_length;
            break;
        case 0x01: /* Carried in Content Identifier Table (CIT) */
            break;
        default:
            break;
        }

        p += crid_length;
    }
} /*}}}*/
Esempio n. 10
0
void QgsGPSObject::writeXML( QTextStream& stream )
{
  if ( !name.isEmpty() )
    stream << "<name>" << xmlify( name ) << "</name>\n";
  if ( !cmt.isEmpty() )
    stream << "<cmt>" << xmlify( cmt ) << "</cmt>\n";
  if ( !desc.isEmpty() )
    stream << "<desc>" << xmlify( desc ) << "</desc>\n";
  if ( !src.isEmpty() )
    stream << "<src>" << xmlify( src ) << "</src>\n";
  if ( !url.isEmpty() )
    stream << "<url>" << xmlify( url ) << "</url>\n";
  if ( !urlname.isEmpty() )
    stream << "<urlname>" << xmlify( urlname ) << "</urlname>\n";
}
Esempio n. 11
0
/*
 * Convert the DVB text in the string passed in.
 * If the buffer is Freesat huffman encoded, then decode that.
 * Text is converted to UTF-8 and XML entities are encoded.
 */
const char *convert_text(const char *s) {
	char cs_new[16];
	size_t ret;

	int i = (int) (unsigned char) s[0];
	if (i < 0x1F) {
		if (encoding[i].handler(cs_new, &s, encoding[i].data))
			return "";
	} else {
		if (encoding_default(cs_new, &s, NULL))
			return "";
	}
	if (i == 0x1F) {
		s = (char *) freesat_huffman_to_string((unsigned char *) s, strlen(s));
	}
	if (strncmp(cs_old, cs_new, 16)) {
		if (cd) {
			iconv_close(cd);
			cd = NULL;
		} // if
		cd = iconv_open("UTF-8", cs_new);
		if (cd == (iconv_t) - 1) {
			log_message(ERROR, "iconv_open() failed: %s", strerror(errno));
			exit(1);
		} // if
		strncpy(cs_old, cs_new, 16);
	} // if

	char *inbuf = (char *) s;
	size_t inbytesleft = strlen(s);
	char *outbuf = (char *) buf;
	size_t outbytesleft = sizeof(buf);
	ret = iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
	*outbuf = 0;
	// FIXME: handle errors
	return xmlify(buf);
}
Esempio n. 12
0
void
x2_attr(FILE *f_xcl, const char *name, const char *value)
{
  if (value && *value)
    fprintf(f_xcl, " %s=\"%s\"", name, xmlify((unsigned char *)value));
}
Esempio n. 13
0
static void
serialize_one_psu(const unsigned char*psu)
{
  fprintf(static_f_xcl,"<psu lang=\"%s\">%s</psu>",psu_list_lang,xmlify(psu));
}
Esempio n. 14
0
static void
serialize_m(unsigned char *key,void*val)
{
  if ('#' != *key)
    fprintf(static_f_xcl,"<m k=\"%s\">%s</m>",key,xmlify((char*)val));
}
Esempio n. 15
0
/* Previous version had this:

   Hack designation/primary_publication issues: if 0 is empty, use 1;
     if 0 == 1, empty 1 
  if (!strcmp(print_ptrs[0]," "))
    {
      print_ptrs[0] = print_ptrs[1];
      print_ptrs[1] = " ";
    }
  else if (!strcmp(print_ptrs[0], print_ptrs[1]))
    print_ptrs[1] = " ";
 */
void
xmdprinter2(const char *pq)
{
  static int nth = 0;
  extern int in_group;

  if ('#' == *pq)
    {
      if (in_group)
	fputs("</ce:group>", stdout);
      else
	in_group = 1;
      fputs("<ce:group>", stdout);
      fprintf(stdout, "<ce:heading>%s</ce:heading>", ++pq);
    }
  else
    {
      Hash_table *fields = NULL;
      int i;
      const char *designation = NULL;
      const char *icon = NULL, *icon_alt;
      const char *id = NULL;

      ++nth;
      xmd_init();

      if (!url_base)
	url_base = malloc(strlen(project) + strlen("javascript:catItemView('xtf',)")+8);
#if 0
      sprintf(url_base,"http://oracc.museum.upenn.edu/%s/cat",project);
#else
      if (p3)
	sprintf(url_base, "javascript:p3item('xtf',%d)", item_offset+nth);
      else
	sprintf(url_base, "javascript:catItemView(%d)", item_offset+nth);
#endif

      /* pq is a qualified ID, so use the project from that */
      if (strchr(pq, ':'))
	fields = l2_xmd_load(NULL, pq);
      else
	fields = l2_xmd_load(project, pq);

      if (!in_group)
	{
	  in_group = 1;
	  fputs("<ce:group>", stdout);
	}

      fputs("<ce:data><tr xmlns=\"http://www.w3.org/1999/xhtml\">",stdout);

      if ((id = hash_find(fields, (unsigned char *)"id_text")))
	{
	  if (*id == 'P')
	    {
	      icon = "cdli-icon.png";
	      /* url_base = "http://oracc.museum.upenn.edu/%s/cat"; */
	      /* url_base = "http://cdli.ucla.edu"; */
	      icon_alt = "CDLI catalog";
	    }
	  else
	    {
	      static char projurl[128];
	      icon = "xnum-icon.png";
	      sprintf(projurl, "/%s", project);
	      /* url_base = "http://oracc.museum.upenn.edu/cat"; */
	      icon_alt = "project catalog";
	    }
	}
      else if ((id = hash_find(fields, (unsigned char *)"id_composite")))
	{
	  icon = "Qcat-icon.png";
	  /* url_base = "http://oracc.museum.upenn.edu/cat"; */
	  icon_alt = "Q catalog";
	}
#if 0
      fprintf(stdout, "<td class=\"ce-xmd-icon\"><a href=\"%s/%s\"><img src=\"/img/%s\" alt=\"%s in %s\"/></a></td>", url_base, id, icon, id, icon_alt);
#else
      /* fprintf(stdout, "<td class=\"ce-xmd-icon\"><a href=\"%s\"><img src=\"/img/%s\" alt=\"%s in %s\"/></a></td>", url_base, icon, id, icon_alt); */
      fprintf(stdout, "<td class=\"ce-xmd-icon\"><a href=\"%s\"><img src=\"/img/viewtext.png\" alt=\"View text\"/></a></td>", url_base, icon, id, icon_alt);
#endif
      for (i = 0; width_specs[i]; ++i)
	{
	  List *tmp = field_lists[i];
	  const char *pct = width_specs[i];
	  const char *field, *value, *field_used = "";
	  char pctbuf[4];
	  int this_is_designation = 0;

	  for (field = list_first(tmp); field; field = list_next(tmp))
	    {
	      if ((value = hash_find(fields, (unsigned char *)field)) && strlen(value))
		{
		  field_used = field;
		  break;
		}
	    }
	  if (!strcmp(field_used, "designation"))
	    {
	      designation = value;
	      this_is_designation = 1;
	    }
	  if (!value || !strlen(value)
	      || (designation 
		  && !strcmp(field_used, "primary_publication")
		  && !strcmp(designation, value)))
	    value = " ";
	  if (alldigit(pct))
	    {
	      strncpy(pctbuf,pct,2);
	      pctbuf[2] = '%';
	      pctbuf[3] = '\0';
	      pct = pctbuf;
	    }
	  if (p3)
	    {
	      if (this_is_designation || i < link_fields)
		fprintf(stdout, "<td style=\"width: %s\"><a href=\"javascript:p3item('xtf',%d)\">%s</a></td>", pct, item_offset+nth, xmlify(value));
	      else
		fprintf(stdout, "<td style=\"width: %s;\">%s</td>", pct, xmlify(value));
	    }
	  else
	    {
	      if (this_is_designation || i < link_fields)
		fprintf(stdout, "<td style=\"width: %s\"><a href=\"javascript:itemView(%d)\">%s</a></td>", pct, item_offset+nth, xmlify(value));
	      else
		fprintf(stdout, "<td style=\"width: %s;\">%s</td>", pct, xmlify(value));
	    }
	}
      fputs("</tr></ce:data>",stdout);
    }
}