test.cpp

00001 /*   
00002  *   (c) Copyright 2008 Philipp Skadorov (philipp_s@users.sourceforge.net)
00003  *
00004  *   This file is part of FREESECS.
00005  *
00006  *   FREESECS is free software: you can redistribute it and/or modify
00007  *   it under the terms of the GNU General Public License as published by
00008  *   the Free Software Foundation, either version 3 of the License, or
00009  *   (at your option) any later version.
00010  *
00011  *   FREESECS is distributed in the hope that it will be useful,
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *   GNU General Public License for more details.
00015  *
00016  *   You should have received a copy of the GNU General Public License
00017  *   along with FREESECS, see COPYING.
00018  *   If not, see <http://www.gnu.org/licenses/>.
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 

Generated on Fri Oct 3 15:30:01 2008 for FREESECS hsms by  doxygen 1.5.1