graph2svg.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757
  1. /*
  2. * Copyright t lefering
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. *
  17. * These are the four essential freedoms with GNU GPL software:
  18. * 1: freedom to run the program, for any purpose
  19. * 2: freedom to study how the program works, and change it to make it do what you wish
  20. * 3: freedom to redistribute copies to help your Free Software friends
  21. * 4: freedom to distribute copies of your modified versions to your Free Software friends
  22. * , ,
  23. * / \
  24. * ((__-^^-,-^^-__))
  25. * `-_---' `---_-'
  26. * `--|o` 'o|--'
  27. * \ ` /
  28. * ): :(
  29. * :o_o:
  30. * "-"
  31. */
  32. #include <stdio.h>
  33. #include <stdlib.h>
  34. #include <string.h>
  35. #include <sfg.h>
  36. struct inedges {
  37. int fn;
  38. int tn;
  39. struct inedges *next;
  40. };
  41. /* no graph data output svg */
  42. char *nodata = "<svg width=\"120\" height=\"20\">"
  43. " <rect width=\"100%\" height=\"100%\" fill=\"#eceedc\" />"
  44. " <text x=\"5\" y=\"15\" font-family=\"Verdana\" font-size=\"15\""
  45. " fill=\"white\" stroke=\"black\" stroke-width=\"1\">" "No graph data" " </text>" " </svg>";
  46. /* syntax error output svg */
  47. char *syntaxerror1 = "<svg width=\"300\" height=\"20\">"
  48. " <rect width=\"100%\" height=\"100%\" fill=\"#eceedc\" />"
  49. " <text x=\"5\" y=\"15\" font-family=\"Verdana\" font-size=\"15\""
  50. " fill=\"white\" stroke=\"black\" stroke-width=\"1\">" "Syntax error at line ";
  51. char *syntaxerror2 = " </text>" " </svg>";
  52. /* sfg error output svg */
  53. char *sfgstatus1 = "<svg width=\"300\" height=\"20\">"
  54. " <rect width=\"100%\" height=\"100%\" fill=\"#eceedc\" />"
  55. " <text x=\"5\" y=\"15\" font-family=\"Verdana\" font-size=\"15\""
  56. " fill=\"white\" stroke=\"black\" stroke-width=\"1\">" "Status from sfg.c is ";
  57. char *sfgstatus2 = " </text>" " </svg>";
  58. /* no. char in input */
  59. unsigned long ninchars = 0;
  60. /* */
  61. int nrealloc = 0;
  62. /* input pointer */
  63. int ip = 0;
  64. char ibuf[1024];
  65. char lbuf[256];
  66. /* current input line */
  67. int curline = 0;
  68. int curie = 0;
  69. /* output buffer */
  70. int stepobuf = 500 * 1024;
  71. int szobuf = 0;
  72. char *obuf = NULL;
  73. int uobuf = 0;
  74. char *pobuf = NULL;
  75. struct inedges *ie = NULL;
  76. struct inedges *ieend = NULL;
  77. /* forward decl. */
  78. static int parse(void);
  79. static void setparseerror(void);
  80. static void setnodata(void);
  81. static void setsfgstatus(int status);
  82. static void init_obuf(void);
  83. static void realloc_obuf(int len);
  84. static void str2obuf(char *s);
  85. static int nextline(void);
  86. static int tosfg(void);
  87. static int fromsfg(int xs, int ys);
  88. static void ohead(int xs, int ys);
  89. static void otail(void);
  90. static int getnodedataps(int num, int level, int pos, int xpos, int ypos, int tx, int ty, int nselfedges, int type,
  91. int indegree, int outdegree, int ly0, int ly1);
  92. static int getedgedataps(int num, int from, int to, int type, int rev);
  93. int graph2svg(char *str, char *output)
  94. {
  95. int i = 0;
  96. int status = 0;
  97. struct inedges *pie = NULL;
  98. /* first input checks */
  99. if (str == (char *)0) {
  100. /* shouldnothappen */
  101. strcpy(output, nodata);
  102. return (99);
  103. }
  104. /* how long is input string */
  105. ninchars = strlen(str);
  106. /* minimal graph is "0 1" edge */
  107. if (ninchars < 3) {
  108. /* shouldnothappen */
  109. strcpy(output, nodata);
  110. return (99);
  111. }
  112. /* copy str to static buffer before first calloc()
  113. * todo the memory in str gets damaged by calloc()
  114. */
  115. strcpy(ibuf, str);
  116. /* set start of input */
  117. init_obuf();
  118. ip = 0;
  119. curline = 0;
  120. status = parse();
  121. if (status || 0) {
  122. setparseerror();
  123. strcpy(output, obuf);
  124. return (strlen(obuf));
  125. }
  126. pie = ie;
  127. curie = 0;
  128. while (pie) {
  129. curie++;
  130. pie = pie->next;
  131. }
  132. if (curie == 0) {
  133. setnodata();
  134. strcpy(output, obuf);
  135. return (strlen(obuf));
  136. }
  137. status = sfg_init();
  138. if (status || 0) {
  139. setsfgstatus(status);
  140. strcpy(output, obuf);
  141. return (strlen(obuf));
  142. }
  143. status = tosfg();
  144. if (status || 0) {
  145. setsfgstatus(status);
  146. strcpy(output, obuf);
  147. return (strlen(obuf));
  148. }
  149. status = sfg_layout();
  150. if (status || 0) {
  151. setsfgstatus(status);
  152. strcpy(output, obuf);
  153. return (strlen(obuf));
  154. }
  155. status = fromsfg(sfg_maxx(), sfg_maxy());
  156. if (status || 0) {
  157. setsfgstatus(status);
  158. strcpy(output, obuf);
  159. return (strlen(obuf));
  160. }
  161. status = sfg_deinit();
  162. if (status || 0) {
  163. setsfgstatus(status);
  164. strcpy(output, obuf);
  165. return (strlen(obuf));
  166. }
  167. if (strlen(obuf) == 0) {
  168. strcpy(obuf, "oke");
  169. }
  170. /* copy the data in svgdata() below
  171. * memcpy(output, obuf,strlen(obuf));
  172. */
  173. /* return no. of chars in output svg data */
  174. return (strlen(obuf));
  175. }
  176. int svgdata(char *output, int len)
  177. {
  178. int ret = strlen(obuf);
  179. memcpy(output, obuf, len);
  180. return (ret);
  181. }
  182. static void setparseerror(void)
  183. {
  184. memset(obuf, 0, szobuf);
  185. str2obuf(syntaxerror1);
  186. str2obuf(intoa(curline));
  187. str2obuf(syntaxerror2);
  188. return;
  189. }
  190. static void setnodata(void)
  191. {
  192. memset(obuf, 0, szobuf);
  193. str2obuf(nodata);
  194. return;
  195. }
  196. static void setsfgstatus(int status)
  197. {
  198. memset(obuf, 0, szobuf);
  199. str2obuf(sfgstatus1);
  200. str2obuf(intoa(status));
  201. str2obuf(sfgstatus2);
  202. return;
  203. }
  204. /* parse input pointed at ip, return 0 if oke */
  205. static int parse(void)
  206. {
  207. int ll = 0;
  208. char lnum[16];
  209. char rnum[16];
  210. char *p = NULL;
  211. int len = 0;
  212. int fnn = 0;
  213. int tnn = 0;
  214. int ac = 0;
  215. struct inedges *newie = NULL;
  216. for (;;) {
  217. ll = nextline();
  218. if (ll == 0) {
  219. break;
  220. }
  221. curline++;
  222. /* check if line with only spaces */
  223. p = lbuf;
  224. ac = 0;
  225. while ((*p)) {
  226. if ((*p) != ' ') {
  227. ac++;
  228. break;
  229. }
  230. p++;
  231. }
  232. if (ac == 0) {
  233. /* only spaces */
  234. lbuf[0] = 0;
  235. }
  236. if (lbuf[0] == '#') {
  237. /* comment line to skip */
  238. } else if (lbuf[0] == 0) {
  239. /* empty line with only '\n' */
  240. } else {
  241. /* minimum edge entry is 3 chars as in "2 3" */
  242. if (strlen(lbuf) < 3) {
  243. return (1);
  244. }
  245. p = lbuf;
  246. memset(lnum, 0, 16);
  247. memset(rnum, 0, 16);
  248. /* skip leading spaces */
  249. while ((*p) != 0) {
  250. if ((*p) != ' ') {
  251. break;
  252. }
  253. p++;
  254. }
  255. /* copy only max 8 number chars for node number from-node */
  256. len = 0;
  257. while ((*p) != 0) {
  258. /* stop at seperator char */
  259. if ((*p) == ' ') {
  260. break;
  261. }
  262. if (((*p) >= '0') && ((*p) <= '9')) {
  263. lnum[len] = (*p);
  264. len++;
  265. if (len > 8) {
  266. return (1);
  267. }
  268. } else {
  269. return (1);
  270. }
  271. p++;
  272. }
  273. /* at separator char now */
  274. /* skip leading spaces */
  275. while ((*p) != 0) {
  276. if ((*p) != ' ') {
  277. break;
  278. }
  279. p++;
  280. }
  281. /* copy only max 8 number chars for node number to-node */
  282. len = 0;
  283. while ((*p) != 0) {
  284. /* stop at seperator char */
  285. if ((*p) == ' ') {
  286. break;
  287. }
  288. if (((*p) >= '0') && ((*p) <= '9')) {
  289. rnum[len] = (*p);
  290. len++;
  291. if (len > 8) {
  292. return (1);
  293. }
  294. } else {
  295. return (1);
  296. }
  297. p++;
  298. }
  299. /* any more chars on line after two node numbers are silently skipped */
  300. if (strlen(lnum) < 1) {
  301. return (1);
  302. }
  303. if (strlen(rnum) < 1) {
  304. return (1);
  305. }
  306. fnn = atoi(lnum);
  307. tnn = atoi(rnum);
  308. if(fnn==0 || tnn==0){
  309. /* edges with a node number 0 are skipped. */
  310. }else if (fnn == tnn) {
  311. /* skip currently self-edges as in "4 4" */
  312. } else {
  313. newie = calloc(1, sizeof(struct inedges));
  314. newie->fn = fnn;
  315. newie->tn = tnn;
  316. if (ie == NULL) {
  317. ie = newie;
  318. ieend = newie;
  319. } else {
  320. ieend->next = newie;
  321. ieend = newie;
  322. }
  323. }
  324. }
  325. }
  326. /* status parsed oke. */
  327. return (0);
  328. }
  329. static int nextline(void)
  330. {
  331. int len = 0;
  332. char c = 0;
  333. memset(lbuf, 0, 256);
  334. len = 0;
  335. for (;;) {
  336. c = ibuf[ip];
  337. if (c == 0) {
  338. break;
  339. }
  340. if (c == '\n') {
  341. ip++;
  342. len++;
  343. break;
  344. }
  345. /* only copy first 255 chars of one line */
  346. if (len < (256 - 1)) {
  347. lbuf[len] = c;
  348. len++;
  349. }
  350. ip++;
  351. }
  352. return (len);
  353. }
  354. static void init_obuf(void)
  355. {
  356. if (obuf) {
  357. free(obuf);
  358. obuf = NULL;
  359. }
  360. obuf = calloc(1, stepobuf);
  361. szobuf = stepobuf;
  362. uobuf = 0;
  363. pobuf = obuf;
  364. return;
  365. }
  366. static void realloc_obuf(int len)
  367. {
  368. obuf = realloc(obuf, szobuf + stepobuf + len + 1);
  369. /* todo:
  370. char *old = NULL;
  371. int oldsize = szobuf;
  372. old = calloc(1, szobuf);
  373. memcpy(old, obuf, szobuf);
  374. free(obuf);
  375. obuf = calloc(1, szobuf + stepobuf + len + 1);
  376. memcpy(obuf, old, oldsize);
  377. free(old);
  378. szobuf += stepobuf + len + 1;
  379. */
  380. nrealloc++;
  381. return;
  382. }
  383. void str2obuf(char *s)
  384. {
  385. int len = 0;
  386. char *ptr = 0;
  387. if (s == NULL) {
  388. return;
  389. }
  390. if (*s == 0) {
  391. return;
  392. }
  393. len = strlen(s);
  394. if ((uobuf + len) > szobuf) {
  395. realloc_obuf(len);
  396. }
  397. if (uobuf == 0) {
  398. strcpy(obuf, s);
  399. } else {
  400. strcat(obuf, s);
  401. }
  402. uobuf += len;
  403. return;
  404. }
  405. static int tosfg(void)
  406. {
  407. int status = 0;
  408. int en = 0;
  409. struct inedges *pie = NULL;
  410. /* first add all nodes */
  411. pie = ie;
  412. while (pie) {
  413. status = sfg_addnode(pie->fn, /* tx */ 25, /* ty */ 30);
  414. status = sfg_addnode(pie->tn, /* tx */ 25, /* ty */ 30);
  415. pie = pie->next;
  416. }
  417. en = 0;
  418. pie = ie;
  419. while (pie) {
  420. en++;
  421. status = sfg_addedge( /* number */ en, /* from */ pie->fn, /* to */ pie->tn, /* tx */ 0, /* ty */ 0);
  422. pie = pie->next;
  423. }
  424. return (0);
  425. }
  426. /* this gets the node data after layout, see sfg.h */
  427. static int getnodedataps(int num, int level, int pos, int xpos, int ypos, int tx, int ty, int nselfedges, int type,
  428. int indegree, int outdegree, int ly0, int ly1)
  429. {
  430. /* return(1); to stop the callback */
  431. if (num) {
  432. }
  433. if (level) {
  434. }
  435. if (pos) {
  436. }
  437. if (xpos) {
  438. }
  439. if (ypos) {
  440. }
  441. if (nselfedges) {
  442. /* self edges at the node must be drawn here */
  443. }
  444. if (type) {
  445. }
  446. if (indegree) {
  447. }
  448. if (outdegree) {
  449. }
  450. if (ly0) {
  451. }
  452. if (ly1) {
  453. }
  454. /*
  455. * " <rect id=\"node_%d\" height=\"%d\" width=\"%d\" y=\"%d\" x=\"%d\" stroke-linecap=\"null\" stroke-linejoin=\"null\" stroke-dasharray=\"null\" stroke=\"#000000\" fill=\"#7fff00\"/>\n",
  456. * num, ty, tx, ypos, xpos);
  457. */
  458. str2obuf(" <rect id=\"node_");
  459. str2obuf(intoa(num));
  460. str2obuf("\" height=\"");
  461. str2obuf(intoa(ty));
  462. str2obuf("\" width=\"");
  463. str2obuf(intoa(tx));
  464. str2obuf("\" y=\"");
  465. str2obuf(intoa(ypos));
  466. str2obuf("\" x=\"");
  467. str2obuf(intoa(xpos));
  468. str2obuf("\" fill=\"#7fff00\"/>\n");
  469. if (tx && ty) {
  470. /*
  471. * " <text x=\"%d\" y=\"%d\" class=\"small\">%d</text>\n", xpos, ypos + ty, num);
  472. */
  473. str2obuf(" <text x=\"");
  474. str2obuf(intoa(xpos));
  475. str2obuf("\" y=\"");
  476. str2obuf(intoa(ypos + ty));
  477. str2obuf("\" class=\"small\">");
  478. str2obuf(intoa(num));
  479. str2obuf("</text>\n");
  480. }
  481. /* return 0 to continue callbacks */
  482. return (0);
  483. }
  484. /* this gets the edge data after layout, see sfg.h */
  485. static int getedgedataps(int num, int from, int to, int type, int rev)
  486. {
  487. int fx = 0;
  488. int fy = 0;
  489. int tx = 0;
  490. int ty = 0;
  491. int typef = 0;
  492. int typet = 0;
  493. int szxf = 0;
  494. int szyf = 0;
  495. int szxt = 0;
  496. int szyt = 0;
  497. int ly = 0;
  498. int ryf = 0;
  499. int ryt = 0;
  500. char *scolor = "";
  501. /* todo this should also guide the dummy nodes to get a better drawing */
  502. if (num) {
  503. }
  504. if (rev) {
  505. /* draw arrow at from-node */
  506. scolor = "#0f0fff";
  507. } else {
  508. /* draw arrow at to-node */
  509. scolor = "#000000";
  510. }
  511. /* return(1); to stop the callback */
  512. /* get type of nodes */
  513. typef = sfg_nodetype(from);
  514. typet = sfg_nodetype(to);
  515. /* get (x,y) pos of nodes */
  516. fx = sfg_nodexpos(from);
  517. fy = sfg_nodeypos(from);
  518. tx = sfg_nodexpos(to);
  519. ty = sfg_nodeypos(to);
  520. /* get sizes of nodes */
  521. szxf = sfg_nodexsize(from);
  522. szyf = sfg_nodeysize(from);
  523. szxt = sfg_nodexsize(to);
  524. szyt = sfg_nodeysize(to);
  525. /* relative y positions of from/to node */
  526. ryf = sfg_noderelypos(from);
  527. ryt = sfg_noderelypos(to);
  528. if (ryf) {
  529. }
  530. if (ryt) {
  531. }
  532. /* type of edge */
  533. if (type == 3) {
  534. /* this horizontal edge must be drawn different */
  535. if (fy + szyf > ty + szyt) {
  536. ly = fy + szyf;
  537. } else {
  538. ly = ty + szyt;
  539. }
  540. ly = ly + 4;
  541. fx = fx + (szxf / 2);
  542. fy = fy + szyf;
  543. tx = tx + (szxt / 2);
  544. ty = ty + szyt;
  545. /*
  546. * " <line id=\"edge_%d\" y2=\"%d\" x2=\"%d\" y1=\"%d\" x1=\"%d\" stroke-linecap=\"null\" stroke-linejoin=\"null\" stroke-dasharray=\"null\" stroke-width=\"2\" stroke=\"%s\" fill=\"none\"/>\n",
  547. * num, ly, fx, fy, fx, scolor);
  548. */
  549. str2obuf(" <line id=\"edge_");
  550. str2obuf(intoa(num));
  551. str2obuf("\" y2=\"");
  552. str2obuf(intoa(ly));
  553. str2obuf("\" x2=\"");
  554. str2obuf(intoa(fx));
  555. str2obuf("\" y1=\"");
  556. str2obuf(intoa(fy));
  557. str2obuf("\" x1=\"");
  558. str2obuf(intoa(fx));
  559. str2obuf("\" stroke-width=\"2\" stroke=\"");
  560. str2obuf(scolor);
  561. str2obuf("\" fill=\"none\"/>\n");
  562. /*
  563. * " <line id=\"edge_%d\" y2=\"%d\" x2=\"%d\" y1=\"%d\" x1=\"%d\" stroke-linecap=\"null\" stroke-linejoin=\"null\" stroke-dasharray=\"null\" stroke-width=\"2\" stroke=\"%s\" fill=\"none\"/>\n",
  564. * num, ly, tx, ly, fx, scolor);
  565. */
  566. str2obuf(" <line id=\"edge_");
  567. str2obuf(intoa(num));
  568. str2obuf("\" y2=\"");
  569. str2obuf(intoa(ly));
  570. str2obuf("\" x2=\"");
  571. str2obuf(intoa(tx));
  572. str2obuf("\" y1=\"");
  573. str2obuf(intoa(ly));
  574. str2obuf("\" x1=\"");
  575. str2obuf(intoa(fx));
  576. str2obuf("\" stroke-width=\"2\" stroke=\"");
  577. str2obuf(scolor);
  578. str2obuf("\" fill=\"none\"/>\n");
  579. /*
  580. * " <line id=\"edge_%d\" y2=\"%d\" x2=\"%d\" y1=\"%d\" x1=\"%d\" stroke-linecap=\"null\" stroke-linejoin=\"null\" stroke-dasharray=\"null\" stroke-width=\"2\" stroke=\"%s\" fill=\"none\"/>\n",
  581. * num, ty, tx, ly, tx, scolor);
  582. */
  583. str2obuf(" <line id=\"edge_");
  584. str2obuf(intoa(num));
  585. str2obuf("\" y2=\"");
  586. str2obuf(intoa(ty));
  587. str2obuf("\" x2=\"");
  588. str2obuf(intoa(tx));
  589. str2obuf("\" y1=\"");
  590. str2obuf(intoa(ly));
  591. str2obuf("\" x1=\"");
  592. str2obuf(intoa(tx));
  593. str2obuf("\" stroke-width=\"2\" stroke=\"");
  594. str2obuf(scolor);
  595. str2obuf("\" fill=\"none\"/>\n");
  596. } else {
  597. /* if from node is regular, tune the edge conn. point */
  598. if (typef == 1) {
  599. fx = fx + (szxf / 2);
  600. fy = fy + szyf;
  601. }
  602. /* if to node is regular, tune the edge conn. point */
  603. if (typet == 1) {
  604. tx = tx + (szxt / 2);
  605. if (szyt) {
  606. }
  607. }
  608. /*
  609. * " <line id=\"edge_%d\" y2=\"%d\" x2=\"%d\" y1=\"%d\" x1=\"%d\" stroke-linecap=\"null\" stroke-linejoin=\"null\" stroke-dasharray=\"null\" stroke-width=\"2\" stroke=\"%s\" fill=\"none\"/>\n",
  610. * num, ty, tx, fy, fx, scolor);
  611. */
  612. str2obuf(" <line id=\"edge_");
  613. str2obuf(intoa(num));
  614. str2obuf("\" y2=\"");
  615. str2obuf(intoa(ty));
  616. str2obuf("\" x2=\"");
  617. str2obuf(intoa(tx));
  618. str2obuf("\" y1=\"");
  619. str2obuf(intoa(fy));
  620. str2obuf("\" x1=\"");
  621. str2obuf(intoa(fx));
  622. str2obuf("\" stroke-width=\"2\" stroke=\"");
  623. str2obuf(scolor);
  624. str2obuf("\" fill=\"none\"/>\n");
  625. }
  626. /* return 0 to continue callbacks */
  627. return (0);
  628. }
  629. static int fromsfg(int xs, int ys)
  630. {
  631. int status = 0;
  632. memset(obuf, 0, szobuf);
  633. ohead(xs, ys);
  634. /* get node data */
  635. status = sfg_node_foreach(getnodedataps);
  636. if (status < 0) { /* error */
  637. }
  638. /* get edge data */
  639. status = sfg_edge_foreach(getedgedataps);
  640. if (status < 0) { /* error */
  641. }
  642. otail();
  643. return (0);
  644. }
  645. /* header */
  646. static void ohead(int xsize, int ysize)
  647. {
  648. str2obuf("<svg width=\"");
  649. str2obuf(intoa(xsize));
  650. str2obuf("\" height=\"");
  651. str2obuf(intoa(ysize));
  652. str2obuf("\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:svg=\"http://www.w3.org/2000/svg\">\n");
  653. str2obuf(" <g>\n");
  654. str2obuf(" <title>sfgdemo</title>\n");
  655. str2obuf(" <style>\n");
  656. str2obuf(" .small { font: italic 15px sans-serif; }\n");
  657. str2obuf(" </style>\n");
  658. str2obuf(" <rect width=\"100%\" height=\"100%\" fill=\"#eceedc\" />");
  659. return;
  660. }
  661. /* footer */
  662. static void otail(void)
  663. {
  664. str2obuf(" </g>\n");
  665. str2obuf("</svg>\n");
  666. return;
  667. }
  668. /* end */