/* * * ProLinga-Run * * Copyright (C) 2002-2008 Xobas Software. * All rights reserved. * * This file is part of ProLinga-Run. * * ProLinga-Run 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-Run 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-Run. If not, see . * * More information is available at the following addresses: * * Website : http://www.prolinga.org * * Email : prolinga-list@prolinga.org * * */ #include "RunCommon.h" #include #include #include #include #include #include "RunInit.hpp" #include "RunClose.hpp" #include "RunShare.hpp" #include "LogicCommandDef.hpp" #include "DataRef.hpp" #include "Logic.hpp" #include "Thread.hpp" #include "LogicCommands.hpp" #include "RepositoryCommand.hpp" #include "RunCommand.hpp" #include "Logon.hpp" #include "CmdList.hpp" #include "RunConfig.hpp" #include "BuiltIn.hpp" //#include "InitRunEnvironment.hpp" #if BUILD_DATA #include #endif #if BUILD_REPOSITORY #include #endif #if BUILD_VALIDATE #include #endif /* Global settings */ GtkWidget *activeScreen; pthread_t mainThreadId; /* Store application/user from command line */ extern BiAppnPtr biAppnPtr; extern BiUserPtr biUserPtr; /* Only used for web */ BiWebParameterPtr biWebPtr = NULL; //class ConfigSetting configSetting; ConfigRunPtr confRunPtr = NULL; #ifdef BUILD_DATA PlDataPtr datRunPtr = NULL; #else char *dataEndPoint = NULL; int dataCompressionLevel = 0; #endif #ifdef BUILD_REPOSITORY PlRepositoryPtr repRunPtr = NULL; #else char *repositoryEndPoint = NULL; int repositoryCompressionLevel = 0; #endif #ifdef BUILD_VALIDATE PlValidatePtr valRunPtr = NULL; #else char *validateEndPoint = NULL; int validateCompressionLevel = 0; #endif void Usage(const char *progName) { printf("Usage : %s [ [[--user user_name] [--application application_name] [--noconnectiondialog] || [--version] || [--config file_name] ] \n", progName); } int main(int argc, char *argv[]) { xmlDocPtr docConf = NULL; char *configFileName = NULL, logon_appn[32], logon_user[32]; int i; bool appn_once = false, user_once = false, nocon_dialog_once = false, noconnectiondialog = false; /* Init */ strcpy(logon_appn, ""); strcpy(logon_user, ""); /* Process command line arguments */ if (argc > 1) { for (i = 1; i= argc) { Usage(argv[0]); return 0; } if ((!strcmp(argv[i], "-user")) || (!strcmp(argv[i], "--user"))) { if (user_once == true) { Usage(argv[0]); return 0; } strcpy(logon_user,argv[i+1]); user_once = true; } else if ((!strcmp(argv[i], "-application")) || (!strcmp(argv[i], "--application"))) { if (appn_once == true) { Usage(argv[0]); return 0; } strcpy(logon_appn,argv[i+1]); appn_once = true; } i++; } else if ((!strcmp(argv[i], "-noconnectiondialog")) || (!strcmp(argv[i], "--noconnectiondialog"))) { if (nocon_dialog_once == true) { Usage(argv[0]); return 0; } noconnectiondialog = true; } else if ((!strcmp(argv[i], "-version")) || (!strcmp(argv[i], "--version"))) { fprintf(stderr,"%s version: %s\n", argv[0], VERSION); fprintf(stderr,"Configuration file: %s\n", DEF_CONFIG_FILE); fprintf(stderr,"Compiled with the following components:\n"); fprintf(stderr," -GNOME/GTK+ GUI\n"); fprintf(stderr," -4GL Interpreter\n"); #ifndef NO_BUILD_SOAP // fprintf(stderr," -SOAP\n"); #endif #ifdef BUILD_REPOSITORY fprintf(stderr," -Repository\n"); #endif #ifdef BUILD_VALIDATE fprintf(stderr," -Validate-engine\n"); #endif #ifdef BUILD_DATA fprintf(stderr," -Data-engine\n"); #endif fprintf(stderr,"Copyright © 2002-2008 The ProLinga Team.\n"); fprintf(stderr,"All rights reserved.\n"); return 0; } else if ((!strcmp(argv[i], "-config")) || (!strcmp(argv[i], "--config"))) { if ((i+1) >= argc) { Usage(argv[0]); return 0; } i++; configFileName = argv[i]; } else { Usage(argv[0]); return 0; } } } #if !defined(BUILD_REPOSITORY) || !defined(BUILD_VALIDATE) || !defined(BUILD_DATA) GtkWidget *Logon; #endif /* Basic check if config file is loadable TODO: XSD validation */ if (configFileName != NULL) { docConf = xmlParseFile(configFileName); if (docConf == NULL) { fprintf(stderr, "Error parsing config file : %s. \n", configFileName); xmlFreeDoc(docConf); return -1; } /* File seems OK */ xmlFreeDoc(docConf); } /* Set Locale */ gtk_set_locale(); /* Init Main Thread & GTK+ */ if (! g_thread_supported ()) g_thread_init(NULL); gdk_threads_init(); gtk_init(&argc, &argv); /* Get name Configuration File */ if (configFileName == NULL) configFileName = DEF_CONFIG_FILE; /* Init environment */ RunInit(configFileName, argc, argv); /* Set logon appn and user */ biAppnPtr->setAppn(logon_appn); biUserPtr->setUser(logon_user); #if defined(BUILD_REPOSITORY) && defined(BUILD_VALIDATE) && defined(BUILD_DATA) /* Call Main logon administrator */ AdmLogon(); #else if (noconnectiondialog == true) { /* Direct Logon Screen */ AdmLogon(); } else { /* Create and Display Remote Repository Logon Screen */ Logon = create_Logon(); gtk_widget_show(Logon); } #endif /* Start GTK+ loop */ gdk_threads_enter(); gtk_main(); gdk_threads_leave(); /* Close environment */ RunClose(); /* Clean up */ delete confRunPtr; /* Return */ return 0; }