hc
2023-12-06 08f87f769b595151be1afeff53e144f543faa614
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <stdbool.h>
#include <sys/types.h>
#include <unistd.h>
#include <ctype.h>
#include <inttypes.h>
 
#include <glib.h>
 
#include <pthread.h>
 
#include <libxml/parser.h>
 
#include "json-c/json.h"
#include "dbserver.h"
 
void parsingxml(char *xmlfile)
{
    xmlDocPtr doc;
    xmlNodePtr curNode = NULL;
    xmlNodePtr lowNode = NULL;
 
    doc = xmlReadFile(xmlfile, "UTF-8", XML_PARSE_NOBLANKS);
 
    curNode = xmlDocGetRootElement(doc);
    printf("begin\n");
    if (g_str_equal(curNode->name, "sqlcmds")) {
        curNode = curNode->xmlChildrenNode;
        while (curNode) {
            char *sql = (char*)XML_GET_CONTENT(curNode->xmlChildrenNode);
            printf("%s\n",sql);
            char *json_str = dbserver_sql(sql, DBSERVER_STORAGE_INTERFACE);
            printf("%s\n", json_str);
            if (json_str)
                g_free(json_str);
            curNode = curNode->next;
        }
    }
    printf("end\n");
}
 
int main( int argc , char ** argv)
{
    if (argc == 2)
        parsingxml(argv[1]);
 
    return 0;
}