/* * * ProLinga-Data * * Copyright (C) 2002-2008 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 #include #include #include "DatMain.hpp" #include "DCAdmin.hpp" #include "DCSession.hpp" #include "DatConfig.hpp" #include "Utility.hpp" int DCListProviders(const char *objName, const xmlDocPtr docObj, const char *sessionId, char **externalError, xmlDocPtr *docReturn) { xmlNodePtr curReturn, curTmp; GList *provList; GList *node; GdaProviderInfo *info; /* Get Provider List. Don't free or modify it! */ provList = gda_config_get_provider_list(); /* Create return document */ *docReturn = xmlNewDoc((const xmlChar *)XML_VERSION); (*docReturn)->children = xmlNewDocNode(*docReturn, NULL, (const xmlChar *)ROOT_ELEM, NULL); curReturn = xmlDocGetRootElement(*docReturn); /* Insert all providers in return document */ for (node = g_list_first (provList); node != NULL; node = g_list_next(node)) { info = (GdaProviderInfo *) node->data; if (WildcardMatch((char *)objName, info->id) == 0) continue; curTmp = xmlNewTextChild(curReturn, NULL, (const xmlChar *)"Object", (const xmlChar *)""); xmlNewProp(curTmp, (const xmlChar *)"Name", (const xmlChar *)info->id); //g_print ("ID: %s\n", info->id); } /* Return */ return 0; } int DCListDataSources(const char *objName, const xmlDocPtr docObj, const char *sessionId, char **externalError, xmlDocPtr *docReturn) { xmlNodePtr curReturn, curTmp; GList *dsList; GList *node; GdaDataSourceInfo *info; /* Get List of Data Sources */ dsList = gda_config_get_data_source_list(); /* Create return document */ *docReturn = xmlNewDoc((const xmlChar *)XML_VERSION); (*docReturn)->children = xmlNewDocNode(*docReturn, NULL, (const xmlChar *)ROOT_ELEM, NULL); curReturn = xmlDocGetRootElement(*docReturn); for (node = g_list_first (dsList); node != NULL; node = g_list_next (node)) { info = (GdaDataSourceInfo *) node->data; if (WildcardMatch((char *)objName, info->name) == 0) continue; curTmp = xmlNewTextChild(curReturn, NULL, (const xmlChar *)"Object", (const xmlChar *)""); xmlNewProp(curTmp, (const xmlChar *)"Name", (const xmlChar *)info->name); xmlNewTextChild(curTmp, NULL, (const xmlChar *)"Provider", (const xmlChar *)info->provider); xmlNewTextChild(curTmp, NULL, (const xmlChar *)"Cnc", (const xmlChar *)info->cnc_string); xmlNewTextChild(curTmp, NULL, (const xmlChar *)"Description", (const xmlChar *)info->description); xmlNewTextChild(curTmp, NULL, (const xmlChar *)"UserName", (const xmlChar *)info->username); xmlNewTextChild(curTmp, NULL, (const xmlChar *)"Password", (const xmlChar *)info->password); } /* Free Resources */ gda_config_free_data_source_list (dsList); /* Return */ return 0; }