00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <unistd.h>
00021 #include <stdlib.h>
00022 #include <stdio.h>
00023 #include <string.h>
00024 #include <expat.h>
00025 #include "hsms_config.h"
00026
00027
00028
00029
00030
00031
00032 int main(int argc, char *argv[])
00033 {
00034 FILE *fp;
00035 hsms_config_parser_t hp;
00036 static char buf[512];
00037 const char *filename;
00038 int done;
00039 int len;
00040
00041 if(argc < 2 || NULL == argv[1] || 0 == strlen(argv[1]))
00042 {
00043 fprintf(stderr, "Please provide filename\n");
00044 exit(-1);
00045 }
00046
00047 if(0 >= (fp = fopen(argv[1], "r")))
00048 {
00049 fprintf(stderr, "Filename %s is invalid.\n", argv[1]);
00050 exit(-1);
00051 }
00052
00053 for(;;)
00054 {
00055 fgets(buf, sizeof(buf), fp);
00056 len = strlen(buf);
00057
00058 if(ferror(fp))
00059 {
00060 fprintf(stderr, "File read error\n");
00061 exit(-1);
00062 }
00063
00064 done = feof(fp);
00065 if (!hp.parse(buf, len, done))
00066 {
00067 fprintf(stderr, "Parse error\n");
00068 exit(-1);
00069 }
00070 if (done)
00071 {
00072 fclose(fp);
00073 break;
00074 }
00075 }
00076 }
00077
00078 hsms_config_t *cnx_cfg;
00079
00080
00081
00082