/* * * ProLinga-Validate * * Copyright (C) 2002-2008 Xobas Software. * All rights reserved. * * This file is part of ProLinga-Validate. * * ProLinga-Validate is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * ProLinga-Validate is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with ProLinga-Validate. If not, see . * * More information is available at the following addresses: * * Website : http://www.prolinga.org * * Email : prolinga-list@prolinga.org * * */ #include "ValCommon.h" #include "ValConfig.hpp" #include #include #include "VCDocumentParse.hpp" #include "ValidateDocument.hpp" #include void Usage(const char *progName) { printf("Usage : %s [ [--version] || [--config file_name] [--mode transform_only] --appn application_name --in input_file_name ] \n", progName); } int main(int argc, char *argv[]) { xmlDocPtr docVal; xmlNodePtr curVal; xmlBufferPtr bufVal; bool transformOnly = false; char *configFileName = DEF_CONFIG_FILE, *appnName = NULL, *inFileName = NULL; int i; PlValidate val; /* Process command line arguments */ if (argc <= 1) { Usage(argv[0]); return 0; } for (i=1;i= argc) { Usage(argv[0]); return 0; } i++; configFileName = argv[i]; } else if ((!strcmp(argv[i], "-mode")) || (!strcmp(argv[i], "--mode"))) { if ((i+1) >= argc) { Usage(argv[0]); return 0; } i++; transformOnly = true; } else if ((!strcmp(argv[i], "-appn")) || (!strcmp(argv[i], "--appn"))) { if ((i+1) >= argc) { Usage(argv[0]); return 0; } i++; appnName = argv[i]; } else if ((!strcmp(argv[i], "-in")) || (!strcmp(argv[i], "--in"))) { if ((i+1) >= argc) { Usage(argv[0]); return 0; } i++; inFileName = argv[i]; } } /* Check if file names have values */ if (appnName == NULL || inFileName == NULL) { Usage(argv[0]); return 0; } /* Open Validate */ val.validateOpen(configFileName); /* Parse and optional validate document */ docVal = ValidateDoc(transformOnly, appnName, inFileName); /* Close Validate */ val.validateClose(); /* Write output */ bufVal = xmlBufferCreate(); curVal = xmlDocGetRootElement(docVal); xmlNodeDump(bufVal, docVal, curVal, 0, 1); printf("%s\n", (char *)xmlBufferContent(bufVal)); /* Clean up */ xmlBufferFree(bufVal); xmlFreeDoc(docVal); }