/* * * ProLinga-Data * * Copyright (C) 2002-2009 Xobas Software. * All rights reserved. * * This file is part of ProLinga-Data. * * ProLinga-Data 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-Data 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-Data. If not, see . * * More information is available at the following addresses: * * Website : http://www.prolinga.org * * Email : prolinga-list@prolinga.org * * */ #include "DatCommon.h" #include #include "DatConfig.hpp" #include "DatMain.hpp" void Usage(const char *progName) { printf("Usage : %s [ [--version] || [--config file_name] --in input_DC_file_name --out output_DC_file_name ] \n", progName); } int main (int argc, char* argv[]) { xmlDocPtr docIn, docOut; xmlNodePtr curOut; xmlBufferPtr bufOut; int i, clientPort, clientCompressionLevel; char *response, serviceEndpoint[255], *clientHost; char *configFileName = DEF_CONFIG_FILE, *inFileName = NULL, *outFileName = NULL; FILE *fpOut; PlSoapClient sclient; ConfigDatPtr confDatPtr; /* 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], "-in")) || (!strcmp(argv[i], "--in"))) { if ((i+1) >= argc) { Usage(argv[0]); return 0; } i++; inFileName = argv[i]; } else if ((!strcmp(argv[i], "-out")) || (!strcmp(argv[i], "--out"))) { if ((i+1) >= argc) { Usage(argv[0]); return 0; } i++; outFileName = argv[i]; } } /* Check if file names have values */ if (inFileName == NULL || outFileName == NULL) { Usage(argv[0]); return 0; } /* Get Config */ confDatPtr = new ConfigDat(configFileName); /* Get service end point */ clientHost = confDatPtr->getStringValue("ClientHost", DEF_CLIENT_HOST); clientPort = confDatPtr->getNumberValue("ClientPort", DEF_CLIENT_PORT); sprintf(serviceEndpoint, "%s:%d", clientHost, clientPort); /* Get client compression level */ clientCompressionLevel = confDatPtr->getNumberValue("ClientCompressionLevel", DEF_CLIENT_COMP_LEVEL); /* Don't need Config any longer */ delete confDatPtr; /* Load request file */ docIn = xmlParseFile(inFileName); if (docIn == NULL) { printf("Error reading doc.\n"); exit (1); } /* Process Request */ docOut = sclient.soapCall(docIn, serviceEndpoint, clientCompressionLevel); /* Dump document as string */ bufOut = xmlBufferCreate(); curOut = xmlDocGetRootElement(docOut); xmlNodeDump(bufOut, docOut, curOut, 0, 1); //printf("%s\n", (char *)xmlBufferContent(bufOut)); response = (char *)xmlBufferContent(bufOut); /* Write response to file */ fpOut = fopen(outFileName, "w"); fprintf(fpOut, "%s", response); fclose(fpOut); /* Clean up */ xmlBufferFree(bufOut); xmlFreeDoc(docOut); xmlFreeDoc(docIn); xmlCleanupParser(); /* Return */ return 0; }