diff --git a/draw_fpga.c b/draw_fpga.c index f90f3d1..6a190ce 100644 --- a/draw_fpga.c +++ b/draw_fpga.c @@ -17,19 +17,17 @@ #include #include -static const char* empty_svg = -{ - "\n" +static const xmlChar* empty_svg = (const xmlChar*) + "\n" "\n" + " viewBox=\"0 0 1000 1000\" width=\"1000\" height=\"1000\">\n" + " \n" " \n" " \n" - "\n" -}; + "\n"; int main(int argc, char** argv) { @@ -37,20 +35,10 @@ int main(int argc, char** argv) xmlXPathContextPtr xpathCtx = 0; xmlXPathObjectPtr xpathObj = 0; - // create or overwrite fpga.svg - { - FILE* f = fopen("fpga.svg", "w+"); - if (!f) { - fprintf(stderr, "Cannot create fpga.svg\n"); - goto fail; - } - fprintf(f, empty_svg); - fclose(f); - } xmlInitParser(); - doc = xmlParseFile("fpga.svg"); + doc = xmlParseDoc(empty_svg); if (!doc) { - fprintf(stderr, "Unable to parse fpga.svg.\n"); + fprintf(stderr, "Internal error %i.\n", __LINE__); goto fail_xml; } xpathCtx = xmlXPathNewContext(doc); @@ -79,13 +67,15 @@ int main(int argc, char** argv) for (i = 0; i < 10; i++) { new_node = xmlNewChild(xpathObj->nodesetval->nodeTab[0], 0 /* xmlNsPtr */, BAD_CAST "use", 0 /* content */); - xmlSetProp(new_node, BAD_CAST "xlink:href", BAD_CAST "lib.svg#square"); + xmlSetProp(new_node, BAD_CAST "xlink:href", BAD_CAST "lib.svg#IOB"); xmlSetProp(new_node, BAD_CAST "x", xmlXPathCastNumberToString(50+i*50)); xmlSetProp(new_node, BAD_CAST "y", BAD_CAST "50"); + xmlSetProp(new_node, BAD_CAST "width", BAD_CAST "50"); + xmlSetProp(new_node, BAD_CAST "height", BAD_CAST "50"); } } - xmlSaveFile("fpga.svg", doc); + xmlDocDump(stdout, doc); xmlXPathFreeObject(xpathObj); xmlXPathFreeContext(xpathCtx); @@ -98,6 +88,5 @@ fail_xml: if (xpathCtx) xmlXPathFreeContext(xpathCtx); if (doc) xmlFreeDoc(doc); xmlCleanupParser(); -fail: return EXIT_FAILURE; } diff --git a/lib.svg b/lib.svg index 3df5c66..6e29ce8 100644 --- a/lib.svg +++ b/lib.svg @@ -1,7 +1,7 @@ - + - - - + + + hi +