Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,40 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libxml/parser.h>
#include <libxml/tree.h>
const char *names[] = {
"April", "Tam O'Shanter", "Emily", NULL
};
const char *remarks[] = {
"Bubbly: I'm > Tam and <= Emily",
"Burns: \"When chapman billies leave the street ...\"",
"Short & shrift", NULL
};
int main()
{
xmlDoc *doc = NULL;
xmlNode *root = NULL, *node;
const char **next;
int a;
doc = xmlNewDoc("1.0");
root = xmlNewNode(NULL, "CharacterRemarks");
xmlDocSetRootElement(doc, root);
for(next = names, a = 0; *next != NULL; next++, a++) {
node = xmlNewNode(NULL, "Character");
(void)xmlNewProp(node, "name", *next);
xmlAddChild(node, xmlNewText(remarks[a]));
xmlAddChild(root, node);
}
xmlElemDump(stdout, doc, root);
xmlFreeDoc(doc);
xmlCleanupParser();
return EXIT_SUCCESS;
}

View file

@ -0,0 +1,53 @@
#include <gadget/gadget.h>
LIB_GADGET_START
const char* codes[] = {"&amp;","&gt;","&lt;"};
const char* repl[] = {"&",">","<"};
char* change_codes( const char* xml_line )
{
int i;
String xml;
Let( xml, xml_line );
Iterator up i [0:1:3]{
Get_fn_let( xml, Str_tran( xml, repl[i], codes[i] ) );
}
return xml;
}
char* generate_xml( const char* names[], int lnames, const char* remarks[] )
{
String xml;
char attrib[100];
int i;
Iterator up i [0:1:lnames]{
String remk;
Get_fn_let ( remk, change_codes( remarks[i] ) );
sprintf(attrib,"name=\"%s\"",names[i]);
if(!i) {
Get_fn_let ( xml, Parser("Character", attrib, remk, NORMAL_TAG ));
}else{
Get_fn_cat ( xml, Parser("Character", attrib, remk, NORMAL_TAG ));
}
Free secure remk;
}
Get_fn_let ( xml, Parser("CharacterRemarks", "", xml, NORMAL_TAG ));
Get_fn_let ( xml, Str_tran(xml,"><",">\n<") );
return xml;
}
#define alen(_X_) ( sizeof(_X_) / sizeof(const char*) )
Main
const char *names[] = {
"April", "Tam O'Shanter", "Emily"
};
const char *remarks[] = {
"Bubbly: I'm > Tam and <= Emily",
"Burns: \"When chapman billies leave the street ...\"",
"Short & shrift"
};
char* xml = generate_xml( names, alen(names), remarks );
Print "%s\n", xml;
Free secure xml;
End

View file

@ -0,0 +1,5 @@
<CharacterRemarks>
<Character name="April">Bubbly: I'm &gt; Tam and &lt;= Emily</Character>
<Character name="Tam O'Shanter">Burns: "When chapman billies leave the street ..."</Character>
<Character name="Emily">Short &amp; shrift</Character>
</CharacterRemarks>