[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue/geas/src geas-server.c
From: |
Daniel E. Baumann |
Subject: |
gnue/geas/src geas-server.c |
Date: |
Sun, 27 May 2001 08:31:56 -0700 |
CVSROOT: /cvs
Module name: gnue
Changes by: Daniel E. Baumann <address@hidden> 01/05/27 08:31:56
Modified files:
geas/src : geas-server.c
Log message:
(load_class_files): Fix symlink bug, clean up file with indent -nut.
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/src/geas-server.c.diff?cvsroot=OldCVS&tr1=1.86&tr2=1.87&r1=text&r2=text
Patches:
Index: gnue/geas/src/geas-server.c
diff -u gnue/geas/src/geas-server.c:1.86 gnue/geas/src/geas-server.c:1.87
--- gnue/geas/src/geas-server.c:1.86 Fri May 25 16:46:21 2001
+++ gnue/geas/src/geas-server.c Sun May 27 08:31:55 2001
@@ -1,21 +1,21 @@
/*
- GEAS - GNU Enterprise Application Server
+ GEAS - GNU Enterprise Application Server
- Copyright (C) 2000 Free Software Foundation
+ Copyright (C) 2000 Free Software Foundation
- This program 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 2, or (at your option)
- any later version.
+ This program 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 2, or (at your option)
+ any later version.
- This program 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.
+ This program 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 this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
@@ -30,14 +30,16 @@
#include <sys/stat.h>
#ifdef USE_GNU_GETOPT
- #include <getopt.h>
+#include <getopt.h>
#endif
-# include <unistd.h>
+#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <dirent.h>
+#include <errno.h>
+
#include "geas.h"
#include "geas-server.h"
#include "globals.h"
@@ -66,8 +68,8 @@
CosNaming_NamingContext name_srv;
CosNaming_Name *main_name;
-CosNaming_Name *create_name(const char *name);
-static void register_with_name_service( GEAS_ConnectionFactory factory );
+CosNaming_Name *create_name (const char *name);
+static void register_with_name_service (GEAS_ConnectionFactory factory);
#endif
#ifdef ENABLE_INTERCEPT_SIGSEGV
@@ -91,40 +93,45 @@
static int filedebuglevel = DEBUGLEVEL_HIGH;
/* private function prototypes */
-static void readOptions(int argc, char **argv);
-static void usage(void);
-static void usage_debuglevel(void);
-static void loadConfig(const char *filename, const char *shadowname);
-static void load_class_files(void);
-static void reserve_sql_words( const char *file , unsigned long int dbtype );
-static void loadTableAliases( const char *filename );
-
-gboolean allow_show_version ( );
-gboolean allow_show_options ( );
-gboolean allow_show_messages( );
-gboolean allow_show_errors ( );
-gboolean allow_show_config ( );
-gboolean allow_show_classes ( );
+static void readOptions (int argc, char **argv);
+static void usage (void);
+static void usage_debuglevel (void);
+static void loadConfig (const char *filename, const char *shadowname);
+static void load_class_files (void);
+static void reserve_sql_words (const char *file, unsigned long int dbtype);
+static void loadTableAliases (const char *filename);
+
+gboolean allow_show_version ();
+gboolean allow_show_options ();
+gboolean allow_show_messages ();
+gboolean allow_show_errors ();
+gboolean allow_show_config ();
+gboolean allow_show_classes ();
#ifdef ENABLE_INTERCEPT_SIGSEGV
-typedef void (*sighandler_t)(int arg);
+typedef void (*sighandler_t) (int arg);
sighandler_t old_sigsegv = NULL;
-void sigsegv_handler(int arg)
+void
+sigsegv_handler (int arg)
{
- fprintf( stderr , "kernel segmentation fault: root file system corrupted.
system terminating.\n" );
- sleep(3);
- fprintf( stderr , "Just kidding :)\n\n" );
- fprintf( stderr , "Remember: Detailed bug reports are a valuable tool, if
you want the problem fixed.\n\n :)\n\n" );
- fprintf( stderr , "A full stack trace from 'gdb' in particular is useful
for identifying\n"
- "exactly where and why an error occured.\n\n");
- if( old_sigsegv ) old_sigsegv(arg);
- else
- {
- /* restore original handler, and call it */
- signal( SIGSEGV , SIG_DFL );
- raise( SIGSEGV );
- }
+ fprintf (stderr,
+ "kernel segmentation fault: root file system corrupted. system
terminating.\n");
+ sleep (3);
+ fprintf (stderr, "Just kidding :)\n\n");
+ fprintf (stderr,
+ "Remember: Detailed bug reports are a valuable tool, if you want
the problem fixed.\n\n :)\n\n");
+ fprintf (stderr,
+ "A full stack trace from 'gdb' in particular is useful for
identifying\n"
+ "exactly where and why an error occured.\n\n");
+ if (old_sigsegv)
+ old_sigsegv (arg);
+ else
+ {
+ /* restore original handler, and call it */
+ signal (SIGSEGV, SIG_DFL);
+ raise (SIGSEGV);
+ }
}
#endif
@@ -135,332 +142,341 @@
* Reads options, initialises the server, loads class definitions.
*/
int
-main(int argc, char **argv)
- {
+main (int argc, char **argv)
+{
#ifdef SELF_TEST
- int doneselftest = 0;
+ int doneselftest = 0;
#endif
- char *filename = NULL;
- FILE *fp = NULL;
+ char *filename = NULL;
+ FILE *fp = NULL;
- PortableServer_POA root_poa;
- PortableServer_POAManager pm;
- CORBA_Environment ev;
- GEAS_ConnectionFactory factory;
- CORBA_char *objref;
- int i;
+ PortableServer_POA root_poa;
+ PortableServer_POAManager pm;
+ CORBA_Environment ev;
+ GEAS_ConnectionFactory factory;
+ CORBA_char *objref;
+ int i;
#ifdef ENABLE_INTERCEPT_SIGSEGV
- /* initialise SIGSEGV handler */
- old_sigsegv = signal( SIGSEGV , sigsegv_handler );
- if( old_sigsegv == SIG_ERR ) old_sigsegv = NULL;
+ /* initialise SIGSEGV handler */
+ old_sigsegv = signal (SIGSEGV, sigsegv_handler);
+ if (old_sigsegv == SIG_ERR)
+ old_sigsegv = NULL;
#endif
#ifdef DEBUG_SECURITY
- /* NO CODE BEFORE THIS LINE: */
- /* prevents a system compiled with debug security from being used */
- /* accidentally. */
-
- /* this section requires manual confirmation if the security code is */
- /* being debugged prevents accidental writing of passwords and other */
- /* data to plain text logs */
+ /* NO CODE BEFORE THIS LINE: */
+ /* prevents a system compiled with debug security from being used */
+ /* accidentally. */
+
+ /* this section requires manual confirmation if the security code is */
+ /* being debugged prevents accidental writing of passwords and other */
+ /* data to plain text logs */
+ {
+ char buf[8];
+
+ fprintf (stdout,
+ "The security system is being debugged. This may result in weaker
security\nbecause of debugging output.\n\n");
+ fprintf (stdout,
+ "Do you wish to continue? (Type 'yes' to continue.)\n\n> ");
+
+ fgets (buf, 6, stdin);
+ buf[7] = '\0';
+ while (buf[strlen (buf) - 1] == '\r' || buf[strlen (buf) - 1] == '\n')
+ buf[strlen (buf) - 1] = '\0';
+ if (g_strcasecmp (buf, "yes") != 0)
{
- char buf[8];
-
- fprintf(stdout,
- "The security system is being debugged. This may result in
weaker security\nbecause of debugging output.\n\n");
- fprintf(stdout,
- "Do you wish to continue? (Type 'yes' to continue.)\n\n> ");
-
- fgets(buf, 6, stdin);
- buf[7] = '\0';
- while (buf[strlen(buf) - 1] == '\r' || buf[strlen(buf) - 1] == '\n')
- buf[strlen(buf) - 1] = '\0';
- if (g_strcasecmp(buf, "yes") != 0)
- {
- fprintf(stdout,
+ fprintf (stdout,
"\nServer exiting. Recompile the server to turn off debugging
features.\n"
"(Binary distributions should be compiled in release mode. If
you did not compile the\n"
" server yourself, please contact the place you received it
from, or contact the\n"
" GNUe team at http://www.gnue.org/ (email
address@hidden)\n\n");
- exit(0);
- }
- fprintf(stdout, "\nThank you for your cooperation. Have a nice
day.\n\n");
+ exit (0);
}
+ fprintf (stdout,
+ "\nThank you for your cooperation. Have a nice day.\n\n");
+ }
#endif
- /* read command line arguments, including a config file */
- readOptions(argc, argv);
+ /* read command line arguments, including a config file */
+ readOptions (argc, argv);
- /* make lots and lots of OIDs for use */
- refill_oid_buffer( 1024*1024 );
+ /* make lots and lots of OIDs for use */
+ refill_oid_buffer (1024 * 1024);
- /* initialise various modules */
- /* Order of steps is significant */
+ /* initialise various modules */
+ /* Order of steps is significant */
- /* this must be done before any classes are created or loaded */
- message("Preparing server side data handling classes");
- all_classes = odl_create_empty_tree();
- make_server_classes();
+ /* this must be done before any classes are created or loaded */
+ message ("Preparing server side data handling classes");
+ all_classes = odl_create_empty_tree ();
+ make_server_classes ();
#ifdef USE_OAF
- message( "Initialising OAF code" );
- oaf_init(argc,argv);
+ message ("Initialising OAF code");
+ oaf_init (argc, argv);
#endif
- /* initialise all appropriate log files here */
- if( get_global_option(configdata,"mainlog") ) {
- const char *logfile = get_global_option(configdata,"mainlog");
- message( "%s tracks all data accesses." , logfile );
-
- add_datamonitor_logfile( logfile , DM_ALL ,
- DM_LOG_ALLOW_TRANSACTIONS );
- }
- else
- message( "No log file active." );
+ /* initialise all appropriate log files here */
+ if (get_global_option (configdata, "mainlog"))
+ {
+ const char *logfile = get_global_option (configdata, "mainlog");
+ message ("%s tracks all data accesses.", logfile);
+ add_datamonitor_logfile (logfile, DM_ALL, DM_LOG_ALLOW_TRANSACTIONS);
+ }
+ else
+ message ("No log file active.");
+
#ifdef DEBUG
- if( debug_file_name )
- message( "Debugging output logged to '%s'" , debug_file_name );
+ if (debug_file_name)
+ message ("Debugging output logged to '%s'", debug_file_name);
#endif
+
+ /* needs to be done before any SQL queries */
+ message ("Loading initial list of reserved words");
+ filename =
+ (char *) get_global_option_str (configdata, "mysqlreserved",
+ "mysql.reserved.lst");
+ if (filename)
+ reserve_sql_words (filename, OQL_DBTYPE_MYSQL);
+ filename =
+ (char *) get_global_option_str (configdata, "postgresqlreserved",
+ "postgresql.reserved.lst");
+ if (filename)
+ reserve_sql_words (filename, OQL_DBTYPE_POSTGRESQL);
+
+ /* note: server side classes must be first, so can be inherited from */
+ message ("Load business class definitions");
+ load_class_files ();
+
+ /* note: classes must be loaded */
+ message ("Initialising business class method handling.");
+ initialise_method_handling (configdata);
+ i = load_method_handlers ();
+ if (i != 0)
+ {
+ errormsg ("%d method handler%s could not be initialised.", i,
+ (i == 1 ? "" : "s"));
+ }
+
+ message ("Initialising object store.");
+ initialise_objectstore (configdata);
+
+ message ("Initialising object cache.");
+ create_object_cache (settings.cache_maximum_size);
+
+ /* note: requires objectstore and classes to be loaded */
+ message ("Validating/updating database table definitions.");
+ update_objectstore_databases (FALSE);
- /* needs to be done before any SQL queries */
- message( "Loading initial list of reserved words" );
- filename =
- (char *)get_global_option_str(configdata, "mysqlreserved",
"mysql.reserved.lst");
- if( filename )
- reserve_sql_words( filename , OQL_DBTYPE_MYSQL );
- filename =
- (char *)get_global_option_str(configdata,
"postgresqlreserved","postgresql.reserved.lst" );
- if( filename )
- reserve_sql_words( filename , OQL_DBTYPE_POSTGRESQL );
-
- /* note: server side classes must be first, so can be inherited from */
- message("Load business class definitions");
- load_class_files();
-
- /* note: classes must be loaded */
- message("Initialising business class method handling.");
- initialise_method_handling( configdata );
- i = load_method_handlers();
- if( i != 0 )
- {
- errormsg( "%d method handler%s could not be initialised." , i ,
- (i==1?"":"s") );
- }
-
- message("Initialising object store.");
- initialise_objectstore(configdata);
-
- message("Initialising object cache.");
- create_object_cache(settings.cache_maximum_size);
-
- /* note: requires objectstore and classes to be loaded */
- message("Validating/updating database table definitions.");
- update_objectstore_databases(FALSE);
+ message ("Initialising data monitor and log system.");
+ init_datamonitor (); /* set up system */
- message("Initialising data monitor and log system.");
- init_datamonitor(); /* set up system */
+ if (allow_show_classes ())
+ odl_display_tree (stdout, all_classes, FALSE);
- if( allow_show_classes() )
- odl_display_tree(stdout, all_classes,FALSE);
-
#ifdef SELF_TEST
- /* optionally run a self test section */
- fprintf(stdout,
+ /* optionally run a self test section */
+ fprintf (stdout,
"\n\n----------------------------------------------------------------------------\n"
"Self test mode has been enabled. Various modules will have a self
test\n");
- fprintf(stdout,
+ fprintf (stdout,
"function for testing purposes. Please make a selection from
the\n");
- fprintf(stdout, "available tests:\n");
+ fprintf (stdout, "available tests:\n");
- while (doneselftest == 0)
- {
+ while (doneselftest == 0)
+ {
char buf[256];
buf[255] = '\0';
- fprintf(stdout, "\nOptions:\n\n");
- fprintf(stdout, " Q - Exit program\n");
- fprintf(stdout, " S - Start server\n\n");
- fprintf(stdout,
- " 1 - Object store module (SQL database access system)\n");
- fprintf(stdout, " 2 - Object container system\n");
+ fprintf (stdout, "\nOptions:\n\n");
+ fprintf (stdout, " Q - Exit program\n");
+ fprintf (stdout, " S - Start server\n\n");
+ fprintf (stdout,
+ " 1 - Object store module (SQL database access system)\n");
+ fprintf (stdout, " 2 - Object container system\n");
- fprintf(stdout, "\n> ");
- fflush(NULL);
+ fprintf (stdout, "\n> ");
+ fflush (NULL);
- fgets(buf, 254, stdin);
- buf[0] = tolower(buf[0]);
+ fgets (buf, 254, stdin);
+ buf[0] = tolower (buf[0]);
switch (buf[0])
- {
- case 'q':
- fprintf(stdout,
- "\n\nThank you for playing. Please come again.\n\n");
- exit(0);
- case 's':
- doneselftest = 1;
- break;
- case '1':
- self_test_objectstore();
- break;
- case '2':
- self_test_objectcontainer();
- break;
- default:
- break;
- }
- }
+ {
+ case 'q':
+ fprintf (stdout,
+ "\n\nThank you for playing. Please come again.\n\n");
+ exit (0);
+ case 's':
+ doneselftest = 1;
+ break;
+ case '1':
+ self_test_objectstore ();
+ break;
+ case '2':
+ self_test_objectcontainer ();
+ break;
+ default:
+ break;
+ }
+ }
#endif
- /* initialise ORB */
- message("Initialising ORB");
- CORBA_exception_init(&ev);
- the_orb = CORBA_ORB_init(&argc, argv, "orbit-local-orb", &ev);
- root_poa =
- (PortableServer_POA) CORBA_ORB_resolve_initial_references(the_orb,
- "RootPOA", &ev);
- if (ev._major != CORBA_NO_EXCEPTION)
- fatal_error("Could not initialise ORB.");
-
- initialise_object_servants(root_poa);
- /* may not be needed: create_fake_servants( &ev ); if( ev._major !=
- CORBA_NO_EXCEPTION ) fatal_error("error: %s" , CORBA_exception_id(&ev)
- ); */
-
- pm = PortableServer_POA__get_the_POAManager(root_poa, &ev);
- PortableServer_POAManager_activate(pm, &ev);
-
- /* create ConnectionFactory object */
-
- message("Creating ConnectionFactory instance for new connections");
- factory =
- (GEAS_ConnectionFactory) impl_GEAS_ConnectionFactory__create(root_poa,
- &ev);
- if (ev._major != CORBA_NO_EXCEPTION)
- fatal_error("Could not create GEAS.ConnectionFactory object.");
+ /* initialise ORB */
+ message ("Initialising ORB");
+ CORBA_exception_init (&ev);
+ the_orb = CORBA_ORB_init (&argc, argv, "orbit-local-orb", &ev);
+ root_poa =
+ (PortableServer_POA) CORBA_ORB_resolve_initial_references (the_orb,
+ "RootPOA",
+ &ev);
+ if (ev._major != CORBA_NO_EXCEPTION)
+ fatal_error ("Could not initialise ORB.");
+
+ initialise_object_servants (root_poa);
+ /* may not be needed: create_fake_servants( &ev ); if( ev._major !=
+ CORBA_NO_EXCEPTION ) fatal_error("error: %s" , CORBA_exception_id(&ev)
+ ); */
+
+ pm = PortableServer_POA__get_the_POAManager (root_poa, &ev);
+ PortableServer_POAManager_activate (pm, &ev);
+
+ /* create ConnectionFactory object */
+
+ message ("Creating ConnectionFactory instance for new connections");
+ factory =
+ (GEAS_ConnectionFactory) impl_GEAS_ConnectionFactory__create (root_poa,
+ &ev);
+ if (ev._major != CORBA_NO_EXCEPTION)
+ fatal_error ("Could not create GEAS.ConnectionFactory object.");
- /* create a connection for GEAS to use when talking to itself :) */
+ /* create a connection for GEAS to use when talking to itself :) */
- server_connection_id = g_new0(GEAS_object_reference, 1);
- if (server_connection_id)
- {
+ server_connection_id = g_new0 (GEAS_object_reference, 1);
+ if (server_connection_id)
+ {
server_connection_id->listid = NULL;
- server_connection_id->username = g_strdup(SERVER_PRIVATE_USERNAME);
+ server_connection_id->username = g_strdup (SERVER_PRIVATE_USERNAME);
server_connection_id->classname = NULL;
server_connection_id->objectid = NULL;
- }
+ }
- server_connection_object =
- make_connection_reference(server_connection_id->username,
SERVER_OBJECT_CONNECTION_ID, &ev);
-
- /* can't do this til the server is, essentially, active */
- message("Initialising security system");
- init_security_system();
+ server_connection_object =
+ make_connection_reference (server_connection_id->username,
+ SERVER_OBJECT_CONNECTION_ID, &ev);
+
+ /* can't do this til the server is, essentially, active */
+ message ("Initialising security system");
+ init_security_system ();
- /* publish server information */
- message("Publishing server details.");
+ /* publish server information */
+ message ("Publishing server details.");
#ifdef ENABLE_NAMESERVICE
- register_with_name_service( factory );
+ register_with_name_service (factory);
#endif
- filename =
- (char *)get_global_option_str(configdata, "pidfile", DEFAULT_PID_FILE);
- fp = fopen(filename, "w");
- if (fp)
- {
- fprintf(fp, "%lu", getpid());
- fclose(fp);
+ filename =
+ (char *) get_global_option_str (configdata, "pidfile", DEFAULT_PID_FILE);
+ fp = fopen (filename, "w");
+ if (fp)
+ {
+ fprintf (fp, "%lu", getpid ());
+ fclose (fp);
fp = NULL;
- }
- else
- {
- warnmsg("Could not write to file %s", filename);
- }
- message( "PID = %d" , getpid() );
+ }
+ else
+ {
+ warnmsg ("Could not write to file %s", filename);
+ }
+ message ("PID = %d", getpid ());
- objref = CORBA_ORB_object_to_string(the_orb, factory, &ev);
- if (ev._major != CORBA_NO_EXCEPTION)
- fatal_error("Could not create GEAS.ConnectionFactory object reference.");
-
- filename =
- (char *)get_global_option_str(configdata, "iorfile", DEFAULT_IOR_FILE);
- fp = fopen(filename, "w");
- if (!fp)
- {
- fprintf(stderr, "Could not create '%s'\n", filename);
- fprintf(stderr, "IOR String: %s\n", objref);
- }
- else
- {
- fprintf(fp, "%s", objref);
- fclose(fp);
- }
+ objref = CORBA_ORB_object_to_string (the_orb, factory, &ev);
+ if (ev._major != CORBA_NO_EXCEPTION)
+ fatal_error ("Could not create GEAS.ConnectionFactory object reference.");
+
+ filename =
+ (char *) get_global_option_str (configdata, "iorfile", DEFAULT_IOR_FILE);
+ fp = fopen (filename, "w");
+ if (!fp)
+ {
+ fprintf (stderr, "Could not create '%s'\n", filename);
+ fprintf (stderr, "IOR String: %s\n", objref);
+ }
+ else
+ {
+ fprintf (fp, "%s", objref);
+ fclose (fp);
+ }
- /* start server */
- message("Starting server");
+ /* start server */
+ message ("Starting server");
- CORBA_ORB_run(the_orb, &ev);
+ CORBA_ORB_run (the_orb, &ev);
- /* Code reaches here once ORB has been shut down */
- message("Server shutting down.");
+ /* Code reaches here once ORB has been shut down */
+ message ("Server shutting down.");
- /* TODO: really need to put cleanup code here */
+ /* TODO: really need to put cleanup code here */
- message("Server has been shut down.");
- }
+ message ("Server has been shut down.");
+}
/** \brief Used for internal operations only
* Returns a statically allocated CORBA object references, suitable for
* non-transactional internal operations only.
*/
-GEAS_Connection get_server_connection_object()
- {
- return (server_connection_object);
- }
+GEAS_Connection
+get_server_connection_object ()
+{
+ return (server_connection_object);
+}
/** \brief Used for internal oeprations only
* Returns a statically allocated GEAS object identifier, suitable for
* non-transactional internal operations only.
*/
GEAS_object_reference *
-get_server_connection_id()
- {
- return (server_connection_id);
- }
+get_server_connection_id ()
+{
+ return (server_connection_id);
+}
/** \brief Termiante the application
* Displays an error message, and terminates the application.
* Usually called via a macro (fatal_error()) in geas-server.h
*/
void
-do_fatal_error(char *file, int line, char *func, char *fmt, ...)
- {
- va_list a;
-
- /* write to stderr */
- fprintf(stderr, "\n\n*** SERVER EXITING ***\n\n");
- fprintf(stderr, "Error detected in %s() (file %s, at line %d)\n" , func ,
file , line );
- va_start(a, fmt);
- vfprintf(stderr, fmt, a);
- va_end(a);
- fprintf(stderr, "\n\n");
- fprintf(stderr, "Remember the value of a complete bug report: everyone
involved will\n"
- "thank you for a useful description of the problem.\n\n");
-
- /* write to log file */
- va_start(a, fmt);
- dm_vlogentry(DM_EVENT_ERROR,NULL,fmt,a);
- va_end(a);
-
- fflush(NULL);
+do_fatal_error (char *file, int line, char *func, char *fmt, ...)
+{
+ va_list a;
- abort();
- }
+ /* write to stderr */
+ fprintf (stderr, "\n\n*** SERVER EXITING ***\n\n");
+ fprintf (stderr, "Error detected in %s() (file %s, at line %d)\n", func,
+ file, line);
+ va_start (a, fmt);
+ vfprintf (stderr, fmt, a);
+ va_end (a);
+ fprintf (stderr, "\n\n");
+ fprintf (stderr,
+ "Remember the value of a complete bug report: everyone involved
will\n"
+ "thank you for a useful description of the problem.\n\n");
+
+ /* write to log file */
+ va_start (a, fmt);
+ dm_vlogentry (DM_EVENT_ERROR, NULL, fmt, a);
+ va_end (a);
+ fflush (NULL);
+
+ abort ();
+}
+
/* logging function : for debug output */
#ifdef DEBUG
@@ -473,55 +489,56 @@
* called via a macro defined in geas-server.h
*/
void
-debug_output_f(char *type, int minlevel, char *file, char *func,
- unsigned int line, char *msg, ...)
- {
- FILE *debug_out_fp = NULL;
- va_list a;
-
- /* write debugging info to a file */
- if( debug_file_name && ( minlevel == DEBUGLEVEL_ALWAYS || minlevel <=
filedebuglevel ) )
- {
- debug_out_fp = fopen( debug_file_name , "a" );
- if( debug_out_fp )
- {
- fprintf( debug_out_fp , "%02d: " , minlevel );
- if (type)
- fprintf(debug_out_fp, "[%s] ", type);
- if (file != NULL && func != NULL)
- fprintf(debug_out_fp, "[%s/%d] [%s] ", file, line, func);
- va_start(a, msg);
- vfprintf(debug_out_fp, msg, a);
- va_end(a);
- fprintf(debug_out_fp, "\n");
- fclose( debug_out_fp );
- }
- }
-
- /* if minlevl == ALWAYS, always display it */
- if (minlevel != DEBUGLEVEL_ALWAYS)
- {
+debug_output_f (char *type, int minlevel, char *file, char *func,
+ unsigned int line, char *msg, ...)
+{
+ FILE *debug_out_fp = NULL;
+ va_list a;
+
+ /* write debugging info to a file */
+ if (debug_file_name
+ && (minlevel == DEBUGLEVEL_ALWAYS || minlevel <= filedebuglevel))
+ {
+ debug_out_fp = fopen (debug_file_name, "a");
+ if (debug_out_fp)
+ {
+ fprintf (debug_out_fp, "%02d: ", minlevel);
+ if (type)
+ fprintf (debug_out_fp, "[%s] ", type);
+ if (file != NULL && func != NULL)
+ fprintf (debug_out_fp, "[%s/%d] [%s] ", file, line, func);
+ va_start (a, msg);
+ vfprintf (debug_out_fp, msg, a);
+ va_end (a);
+ fprintf (debug_out_fp, "\n");
+ fclose (debug_out_fp);
+ }
+ }
+
+ /* if minlevl == ALWAYS, always display it */
+ if (minlevel != DEBUGLEVEL_ALWAYS)
+ {
/* if debugging is off, don't display it */
/* else if debugging level is lower than the message level */
/* don't display it */
/* eg a 'high' detail message isn't displayed if the */
/* user selected 'medium' detail */
if (debuglevel == DEBUGLEVEL_OFF || minlevel > debuglevel)
- {
- return ;
- }
- }
+ {
+ return;
+ }
+ }
- if (type)
- fprintf(stderr, "[%s] ", type);
- if (file != NULL && func != NULL)
- fprintf(stderr, "[%s/%d] [%s] ", file, line, func);
-
- va_start(a, msg);
- vfprintf(stderr, msg, a);
- va_end(a);
- fprintf(stderr, "\n");
- }
+ if (type)
+ fprintf (stderr, "[%s] ", type);
+ if (file != NULL && func != NULL)
+ fprintf (stderr, "[%s/%d] [%s] ", file, line, func);
+
+ va_start (a, msg);
+ vfprintf (stderr, msg, a);
+ va_end (a);
+ fprintf (stderr, "\n");
+}
#endif
/* function for displaying errors to users. extra info in debug mode */
@@ -532,93 +549,93 @@
* Outputs data to stderr. Usually called via a macro defined in geas-server.h
*/
void
-error_message_out(char *type, char *file, char *func,
- unsigned int line, char *msg, ...)
- {
- va_list a;
- unsigned long int dmtype;
-
- /* write to log file */
- if( g_strcasecmp(type,"error") ) dmtype = DM_EVENT_ERROR;
- if( g_strcasecmp(type,"warning") ) dmtype = DM_EVENT_WARNING;
- va_start(a, msg);
- dm_vlogentry(dmtype,NULL,msg,a);
- va_end(a);
+error_message_out (char *type, char *file, char *func,
+ unsigned int line, char *msg, ...)
+{
+ va_list a;
+ unsigned long int dmtype;
+
+ /* write to log file */
+ if (g_strcasecmp (type, "error"))
+ dmtype = DM_EVENT_ERROR;
+ if (g_strcasecmp (type, "warning"))
+ dmtype = DM_EVENT_WARNING;
+ va_start (a, msg);
+ dm_vlogentry (dmtype, NULL, msg, a);
+ va_end (a);
#ifdef DEBUG
- fprintf(stderr, "%s: ", type);
- /* where was the error detected - debug mode only, because most users
- won't be able to do much with it. */
- if (file != NULL)
- fprintf(stderr, "[%s/%d] [%s] ", file, line, func);
+ fprintf (stderr, "%s: ", type);
+ /* where was the error detected - debug mode only, because most users
+ won't be able to do much with it. */
+ if (file != NULL)
+ fprintf (stderr, "[%s/%d] [%s] ", file, line, func);
#else
- /* if quiet, no errors are printed to stderr, but are still logged */
- if (settings.quiet)
- return ;
- fprintf(stderr, "%s: ", type);
+ /* if quiet, no errors are printed to stderr, but are still logged */
+ if (settings.quiet)
+ return;
+ fprintf (stderr, "%s: ", type);
#endif
- va_start(a, msg);
- vfprintf(stderr, msg, a);
- va_end(a);
- fprintf(stderr, "\n");
- }
+ va_start (a, msg);
+ vfprintf (stderr, msg, a);
+ va_end (a);
+ fprintf (stderr, "\n");
+}
/** \brief Display the program version
*/
void
-show_version(FILE * fp)
- {
- fprintf(fp, "\nGNU Enterprise Application Server\nVersion " VERSION);
-
- fprintf(fp, "" /* blank bit so that in the worst
- case, the function still
- compiles */
+show_version (FILE * fp)
+{
+ fprintf (fp, "\nGNU Enterprise Application Server\nVersion " VERSION);
+
+ fprintf (fp, "" /* blank bit so that in the worst
+ case, the function still
+ compiles */
#ifdef DEBUG
- " DEBUG"
+ " DEBUG"
#endif
#ifdef DEBUG_SECURITY
- " (Security debugging)"
+ " (Security debugging)"
#endif
#ifdef SELF_TEST
- " SELF TEST"
+ " SELF TEST"
#endif
- "\nDatabase support compiled for:"
+ "\nDatabase support compiled for:"
#ifdef USE_MYSQL
- " MySQL"
+ " MySQL"
#endif
#ifdef USE_POSTGRESQL
- " PostgreSQL"
+ " PostgreSQL"
#endif
#ifdef USE_LIBGDA
- " All libgda supported databases"
+ " All libgda supported databases"
#endif
- );
+ );
- fprintf(fp,
+ fprintf (fp,
"\nCopyright 2001 Free Software Foundation\n"
"\nSee the file 'COPYING' for details of"
" the Gnu Public License\nthat covers this program\n\n"
"http://www.gnue.org/\n\n");
- }
+}
/** \brief Long command line options options
*/
#ifdef USE_GNU_GETOPT
-static struct option long_options[] =
- {
- {"config", 1, 0, 'c'
- },
- {"debug", 1, 0, 'd'},
- {"usage", 0, 0, 'h'},
- {"help", 0, 0, 'h'},
- {"verbose", 0, 0, 'v'},
- {"version", 0, 0, 'V'},
- {"quiet", 0, 0, 'q'},
- {"showconfig", 0, 0, 'C'},
- {"classes",0,0,'l'},
- {0, 0, 0, 0}
/* end of table marker */
- };
+static struct option long_options[] = {
+ {"config", 1, 0, 'c'},
+ {"debug", 1, 0, 'd'},
+ {"usage", 0, 0, 'h'},
+ {"help", 0, 0, 'h'},
+ {"verbose", 0, 0, 'v'},
+ {"version", 0, 0, 'V'},
+ {"quiet", 0, 0, 'q'},
+ {"showconfig", 0, 0, 'C'},
+ {"classes", 0, 0, 'l'},
+ {0, 0, 0, 0} /* end of table marker */
+};
#endif
#define OPTION_STRING "c:d:hvVqClO:"
@@ -629,742 +646,781 @@
* if neither the configuration system or command line specify an option.
*/
static void
-readOptions(int argc, char **argv)
- {
- int c;
- int digit_optind = 0;
- int i;
- int fatal = 0; /* set fatal > 0 to
quit. if fatal > 1 print
-
-
usage first */
- char *shadowfile = "shadowpw";
- gboolean firstoption = TRUE;
-
- /* some deaults. order for determining an oiption is: * 1: this default *
- 2: config file (overrides default) * 3: cmd line options (overrides
- config file) */
- settings.cache_maximum_size = 50;
- settings.loggeasclasses = CORBA_FALSE;
+readOptions (int argc, char **argv)
+{
+ int c;
+ int digit_optind = 0;
+ int i;
+ int fatal = 0; /* set fatal > 0 to quit. if fatal > 1 print
+
+ usage first */
+ char *shadowfile = "shadowpw";
+ gboolean firstoption = TRUE;
+
+ /* some deaults. order for determining an oiption is: * 1: this default *
+ 2: config file (overrides default) * 3: cmd line options (overrides
+ config file) */
+ settings.cache_maximum_size = 50;
+ settings.loggeasclasses = CORBA_FALSE;
#ifdef DEBUG
- /* in debuyg mode, default to verbose, so will display config */
- settings.verbose = CORBA_TRUE;
+ /* in debuyg mode, default to verbose, so will display config */
+ settings.verbose = CORBA_TRUE;
#else
-settings.verbose = CORBA_FALSE;
+ settings.verbose = CORBA_FALSE;
#endif
- settings.showconfig = FALSE;
+ settings.showconfig = FALSE;
#ifdef DEBUG
- /* default to low debug */
- debuglevel = DEBUGLEVEL_LOW;
+ /* default to low debug */
+ debuglevel = DEBUGLEVEL_LOW;
#else
- /* debugging not needed */
- debuglevel = DEBUGLEVEL_OFF;
+ /* debugging not needed */
+ debuglevel = DEBUGLEVEL_OFF;
#endif
- settings.showclasses = FALSE;
+ settings.showclasses = FALSE;
- /* command line args override config file */
- while (1)
- {
+ /* command line args override config file */
+ while (1)
+ {
int this_option_optind = optind ? optind : 1;
int option_index = 0;
#ifdef USE_GNU_GETOPT
c =
- getopt_long(argc, argv, OPTION_STRING, long_options, &option_index);
+ getopt_long (argc, argv, OPTION_STRING, long_options, &option_index);
#else
- c =
- getopt(argc, argv, OPTION_STRING);
+ c = getopt (argc, argv, OPTION_STRING);
#endif
/* if the very first option is a different configuration file, use
that. */
if (firstoption == TRUE)
- {
- char *tmp;
- firstoption = FALSE;
+ {
+ char *tmp;
+ firstoption = FALSE;
- if (c == 'c')
+ if (c == 'c')
+ {
+ /* printf("Using config file '%s'\n" , optarg ); */
+ settings.configfile = g_strdup (optarg);
+ loadConfig (settings.configfile, shadowfile);
+ }
+ else
{
- /* printf("Using config file '%s'\n" , optarg ); */
- settings.configfile = g_strdup(optarg);
- loadConfig(settings.configfile, shadowfile);
+ /* old: settings.configfile = g_strdup("geas.conf"); */
+ settings.configfile = g_strdup (DEFAULT_CONFIG_FILE);
+ /* printf("Using default config file '%s'\n" ,
settings.configfile ); */
+ loadConfig (settings.configfile, shadowfile);
}
- else
+ debug_file_name =
+ (char *) get_global_option (configdata, "debugfile");
+ if (debug_file_name)
{
- /* old: settings.configfile = g_strdup("geas.conf"); */
- settings.configfile = g_strdup( DEFAULT_CONFIG_FILE );
- /* printf("Using default config file '%s'\n" , settings.configfile
); */
- loadConfig(settings.configfile, shadowfile);
+ FILE *fp;
+ debug_file_name = g_strdup (debug_file_name);
+ fp = fopen (debug_file_name, "w");
+ if (fp)
+ {
+ fprintf (fp, "GEAS debugging log\n------------------\n\n");
+ fclose (fp);
+ }
}
- debug_file_name = (char *)get_global_option( configdata , "debugfile"
);
- if( debug_file_name )
- {
- FILE *fp;
- debug_file_name = g_strdup( debug_file_name );
- fp = fopen( debug_file_name , "w" );
- if( fp ) {
- fprintf( fp , "GEAS debugging log\n------------------\n\n"
);
- fclose( fp );
- }
- }
- tmp = (char *)get_global_option( configdata , "debugfilelevel" );
- if( tmp ) {
- filedebuglevel = atoi( tmp );
- }
-
- /* use global settings from config file, set defaults if not
- in the config * file - uses defaults as set at the start of
- this function: * get_global_option() returns the last
- argument with no changes * so this effectively means "if
- not defined, then no change" */
- tmp = (char *)get_global_option(configdata, "debuglevel");
- if (tmp)
+ tmp = (char *) get_global_option (configdata, "debugfilelevel");
+ if (tmp)
+ {
+ filedebuglevel = atoi (tmp);
+ }
+
+ /* use global settings from config file, set defaults if not
+ in the config * file - uses defaults as set at the start of
+ this function: * get_global_option() returns the last
+ argument with no changes * so this effectively means "if
+ not defined, then no change" */
+ tmp = (char *) get_global_option (configdata, "debuglevel");
+ if (tmp)
{
- if (g_strcasecmp(tmp, "high") == 0)
- debuglevel = DEBUGLEVEL_HIGH;
- else if (g_strcasecmp(tmp, "med") == 0)
- debuglevel = DEBUGLEVEL_MEDIUM;
- else if (g_strcasecmp(tmp, "medium") == 0)
- debuglevel = DEBUGLEVEL_MEDIUM;
- else if (g_strcasecmp(tmp, "low") == 0)
- debuglevel = DEBUGLEVEL_LOW;
- else if (g_strcasecmp(tmp, "off") == 0)
- debuglevel = DEBUGLEVEL_OFF;
- else
- debuglevel =
- get_global_option_int(configdata, "debuglevel",
- debuglevel);
+ if (g_strcasecmp (tmp, "high") == 0)
+ debuglevel = DEBUGLEVEL_HIGH;
+ else if (g_strcasecmp (tmp, "med") == 0)
+ debuglevel = DEBUGLEVEL_MEDIUM;
+ else if (g_strcasecmp (tmp, "medium") == 0)
+ debuglevel = DEBUGLEVEL_MEDIUM;
+ else if (g_strcasecmp (tmp, "low") == 0)
+ debuglevel = DEBUGLEVEL_LOW;
+ else if (g_strcasecmp (tmp, "off") == 0)
+ debuglevel = DEBUGLEVEL_OFF;
+ else
+ debuglevel =
+ get_global_option_int (configdata, "debuglevel",
+ debuglevel);
}
- settings.verbose =
- get_global_option_bool(configdata, "verbose",
- settings.verbose);
- settings.loggeasclasses =
- get_global_option_bool(configdata,"logserverclasses",
- settings.loggeasclasses);
-
- settings.cache_maximum_size =
- get_global_option_int(configdata, "maximumcache",
- settings.cache_maximum_size);
- firstoption = FALSE;
-
- /* if used a different config file, get next option */
- if( c == 'c' )
- continue;
- }
+ settings.verbose =
+ get_global_option_bool (configdata, "verbose", settings.verbose);
+ settings.loggeasclasses =
+ get_global_option_bool (configdata, "logserverclasses",
+ settings.loggeasclasses);
+
+ settings.cache_maximum_size =
+ get_global_option_int (configdata, "maximumcache",
+ settings.cache_maximum_size);
+ firstoption = FALSE;
+
+ /* if used a different config file, get next option */
+ if (c == 'c')
+ continue;
+ }
if (c == -1)
- break;
+ break;
switch (c)
- {
- case 'O':
- /* ignore - is an ORBit option */
- break;
- case 'C':
- settings.showconfig = TRUE;
- break;
- case 'l':
- settings.showclasses = TRUE;
- break;
- case 'q':
- settings.quiet = TRUE;
- break;
- case 'V':
- /* display version then quit */
- show_version(stdout);
- if (fatal < 1)
+ {
+ case 'O':
+ /* ignore - is an ORBit option */
+ break;
+ case 'C':
+ settings.showconfig = TRUE;
+ break;
+ case 'l':
+ settings.showclasses = TRUE;
+ break;
+ case 'q':
+ settings.quiet = TRUE;
+ break;
+ case 'V':
+ /* display version then quit */
+ show_version (stdout);
+ if (fatal < 1)
fatal = 1;
- break;
- case 'c':
- fprintf(stderr,
- "error: option -c or -config must be the first option
given.\n");
- if (fatal < 2)
+ break;
+ case 'c':
+ fprintf (stderr,
+ "error: option -c or -config must be the first option
given.\n");
+ if (fatal < 2)
fatal = 2;
- break;
- case 'd':
- if (g_strcasecmp(optarg, "off") == 0
- || g_strcasecmp(optarg, "0") == 0)
+ break;
+ case 'd':
+ if (g_strcasecmp (optarg, "off") == 0
+ || g_strcasecmp (optarg, "0") == 0)
debuglevel = DEBUGLEVEL_OFF;
- else if (g_strcasecmp(optarg, "low") == 0)
+ else if (g_strcasecmp (optarg, "low") == 0)
debuglevel = DEBUGLEVEL_LOW;
- else if (g_strcasecmp(optarg, "medium") == 0)
+ else if (g_strcasecmp (optarg, "medium") == 0)
debuglevel = DEBUGLEVEL_MEDIUM;
- else if (g_strcasecmp(optarg, "high") == 0)
+ else if (g_strcasecmp (optarg, "high") == 0)
debuglevel = DEBUGLEVEL_HIGH;
- else
+ else
{
- /* check it's just numbers */
- for (i = 0; i < strlen(optarg); i++)
- if (!isdigit(optarg[i]))
+ /* check it's just numbers */
+ for (i = 0; i < strlen (optarg); i++)
+ if (!isdigit (optarg[i]))
{
- i = strlen(optarg);
- usage_debuglevel();
- if (fatal < 1)
- fatal = 1;
+ i = strlen (optarg);
+ usage_debuglevel ();
+ if (fatal < 1)
+ fatal = 1;
}
- debuglevel = atoi(optarg);
- /* check it's in range */
- if (debuglevel < DEBUGLEVEL_LOW
- || debuglevel > DEBUGLEVEL_HIGH)
- {
- usage_debuglevel();
- if (fatal < 1)
- fatal = 1;
- }
+ debuglevel = atoi (optarg);
+ /* check it's in range */
+ if (debuglevel < DEBUGLEVEL_LOW || debuglevel > DEBUGLEVEL_HIGH)
+ {
+ usage_debuglevel ();
+ if (fatal < 1)
+ fatal = 1;
+ }
}
- break;
- case 'v':
- settings.verbose = CORBA_TRUE;
- break;
- case 'h':
- usage();
- exit(0);
- case '?':
- if (fatal < 2)
- fatal = 2; /* show usage */
- break;
- default:
- fprintf(stderr, "Unknown option (ASCII 0x%02x)\n", c);
- if (fatal < 2)
- fatal = 2; /* show usage */
- break;
- }
- }
+ break;
+ case 'v':
+ settings.verbose = CORBA_TRUE;
+ break;
+ case 'h':
+ usage ();
+ exit (0);
+ case '?':
+ if (fatal < 2)
+ fatal = 2; /* show usage */
+ break;
+ default:
+ fprintf (stderr, "Unknown option (ASCII 0x%02x)\n", c);
+ if (fatal < 2)
+ fatal = 2; /* show usage */
+ break;
+ }
+ }
- /* stop now if there was an error */
- if (fatal > 1)
- usage();
/* print usage? */
- if (fatal > 0)
- exit(0);
/* exit now if any errors */
+ /* stop now if there was an error */
+ if (fatal > 1)
+ usage (); /* print usage? */
+ if (fatal > 0)
+ exit (0); /* exit now if any errors */
#ifndef DEBUG
- /* warning for debug level option in non debug version */
- if (debuglevel > 0)
- {
+ /* warning for debug level option in non debug version */
+ if (debuglevel > 0)
+ {
warnmsg
- ("Debugging support has not been compiled in. (Debug level %d ignored.)",
- debuglevel);
+ ("Debugging support has not been compiled in. (Debug level %d
ignored.)",
+ debuglevel);
debuglevel = DEBUGLEVEL_OFF;
- }
+ }
#endif
#ifdef SELF_TEST
- if (settings.verbose == CORBA_TRUE)
- {
+ if (settings.verbose == CORBA_TRUE)
+ {
if (settings.quiet)
- message("Self test mode active (quiet mode ignored)");
+ message ("Self test mode active (quiet mode ignored)");
else
- message("Self test mode active");
+ message ("Self test mode active");
settings.quiet = FALSE;
- }
- else
- {
+ }
+ else
+ {
if (settings.quiet)
- message
- ("Self test mode active: verbose mode turned on automatically (quiet
mode ignored)");
+ message
+ ("Self test mode active: verbose mode turned on automatically (quiet
mode ignored)");
else
- message
- ("Self test mode active: verbose mode turned on automatically");
+ message
+ ("Self test mode active: verbose mode turned on automatically");
settings.quiet = FALSE;
settings.verbose = CORBA_TRUE;
- }
+ }
#endif
- if (allow_show_version())
- show_version(stdout);
+ if (allow_show_version ())
+ show_version (stdout);
- /* display options in debug mode */
- if (allow_show_config())
- {
+ /* display options in debug mode */
+ if (allow_show_config ())
+ {
char *msg;
- fprintf(stdout, "Configuration file loaded:\n\n");
+ fprintf (stdout, "Configuration file loaded:\n\n");
#ifdef DEBUG
if (debuglevel >= DEBUGLEVEL_1)
- {
+ {
#ifdef DEBUG_SECURITY
- /* show passwords for security debugging */
- show_configuration(configdata, TRUE);
+ /* show passwords for security debugging */
+ show_configuration (configdata, TRUE);
#else
-/* hide passwords when not debugging security */
- show_configuration(configdata, FALSE);
+ /* hide passwords when not debugging security */
+ show_configuration (configdata, FALSE);
#endif
- fprintf(stdout, "\n");
- }
+ fprintf (stdout, "\n");
+ }
#endif
if (debuglevel < 4)
- msg = "low detail"; /* 1 2 3 */
+ msg = "low detail"; /* 1 2 3 */
else if (debuglevel < 8)
- msg = "medium detail"; /* 4 5 6 7 */
+ msg = "medium detail"; /* 4 5 6 7 */
else
- msg = "high detail"; /* 8 9 10 */
+ msg = "high detail"; /* 8 9 10 */
if (debuglevel != DEBUGLEVEL_OFF)
- fprintf(stdout, "Debug level : %d (%s)\n", debuglevel, msg);
+ fprintf (stdout, "Debug level : %d (%s)\n", debuglevel, msg);
else
- fprintf(stdout, "Debug level : off\n");
+ fprintf (stdout, "Debug level : off\n");
- fprintf(stdout, "Verbose : %s\n",
- (settings.verbose == CORBA_TRUE) ? "On" : "Off");
- fprintf(stdout, "Max cache size : %d\n",
- settings.cache_maximum_size);
- fprintf(stdout, "Log geas classes : %s\n" ,
- (settings.loggeasclasses ? "Yes" : "No") );
- fprintf(stdout, "\n");
- fprintf(stdout, "PID file : %s\n",
- (char *)get_global_option_str(configdata, "pidfile",
- DEFAULT_PID_FILE));
- fprintf(stdout, "IOR file : %s\n",
- (char *)get_global_option_str(configdata, "iorfile",
- DEFAULT_IOR_FILE));
-
- fprintf(stdout, "GCD directory : %s\n",
- (char *)get_global_option_str(configdata, "classdir", "."));
- fprintf(stdout, "Database change log : %s\n",
- (char *)get_global_option_str(configdata, "databasechangefile",
- "database.changes.txt"));
- fprintf(stdout, "\n");
+ fprintf (stdout, "Verbose : %s\n",
+ (settings.verbose == CORBA_TRUE) ? "On" : "Off");
+ fprintf (stdout, "Max cache size : %d\n",
+ settings.cache_maximum_size);
+ fprintf (stdout, "Log geas classes : %s\n",
+ (settings.loggeasclasses ? "Yes" : "No"));
+ fprintf (stdout, "\n");
+ fprintf (stdout, "PID file : %s\n",
+ (char *) get_global_option_str (configdata, "pidfile",
+ DEFAULT_PID_FILE));
+ fprintf (stdout, "IOR file : %s\n",
+ (char *) get_global_option_str (configdata, "iorfile",
+ DEFAULT_IOR_FILE));
+
+ fprintf (stdout, "GCD directory : %s\n",
+ (char *) get_global_option_str (configdata, "classdir", "."));
+ fprintf (stdout, "Database change log : %s\n",
+ (char *) get_global_option_str (configdata,
+ "databasechangefile",
+ "database.changes.txt"));
+ fprintf (stdout, "\n");
if (optind < argc)
- {
- fprintf(stdout, "Non-option arguments: (ignored)\n");
- while (optind < argc)
- fprintf(stdout, " %s\n", argv[optind++]);
- fprintf(stdout, "\n");
- }
- }
- else
- {
+ {
+ fprintf (stdout, "Non-option arguments: (ignored)\n");
+ while (optind < argc)
+ fprintf (stdout, " %s\n", argv[optind++]);
+ fprintf (stdout, "\n");
+ }
+ }
+ else
+ {
#ifdef DEBUG
/* DEBUG mode, but debuglevel == DEBUGLEVEL_OFF */
if (debuglevel == DEBUGLEVEL_OFF)
- warnmsg("Debugging support has been turned off.");
+ warnmsg ("Debugging support has been turned off.");
#endif
- }
+ }
- if (fatal > 1)
- usage();
/* print usage? */
- if (fatal > 0)
- exit(0);
/* exit now if any errors */
- }
+ if (fatal > 1)
+ usage (); /* print usage? */
+ if (fatal > 0)
+ exit (0); /* exit now if any errors */
+}
/** \brief Test if the version should be displayed
*/
gboolean
-allow_show_version()
- {
- if (settings.verbose == CORBA_TRUE && !settings.quiet)
- return (TRUE);
- else
- return (FALSE);
- }
+allow_show_version ()
+{
+ if (settings.verbose == CORBA_TRUE && !settings.quiet)
+ return (TRUE);
+ else
+ return (FALSE);
+}
/** \brief Test if informational messages should be displayed
*/
gboolean
-allow_show_message()
- {
- if (settings.verbose == CORBA_TRUE && !settings.quiet)
- return (TRUE);
- else
- return (FALSE);
- }
+allow_show_message ()
+{
+ if (settings.verbose == CORBA_TRUE && !settings.quiet)
+ return (TRUE);
+ else
+ return (FALSE);
+}
/** \brief Test if the current configuration should be displayed
*/
gboolean
-allow_show_config()
- {
- if (settings.showconfig == CORBA_TRUE)
- return (TRUE);
- else
- return (FALSE);
- }
+allow_show_config ()
+{
+ if (settings.showconfig == CORBA_TRUE)
+ return (TRUE);
+ else
+ return (FALSE);
+}
/** \brief Test if error messages should be displayed
*/
gboolean
-allow_show_errors()
- {
- if (!settings.quiet)
- return (TRUE);
- else
- return (FALSE);
- }
+allow_show_errors ()
+{
+ if (!settings.quiet)
+ return (TRUE);
+ else
+ return (FALSE);
+}
/** \brief Test if the options in use should be displayed
*/
gboolean
-allow_show_options()
- {
- if (debuglevel >= DEBUGLEVEL_LOW || settings.verbose == TRUE)
- return (TRUE);
- else
- return (FALSE);
- }
+allow_show_options ()
+{
+ if (debuglevel >= DEBUGLEVEL_LOW || settings.verbose == TRUE)
+ return (TRUE);
+ else
+ return (FALSE);
+}
/** \brief Test if the class tree should be shown
*/
gboolean
-allow_show_classes()
- {
- if (settings.quiet == FALSE && settings.showclasses == TRUE )
- return (TRUE);
- else
- return (FALSE);
- }
+allow_show_classes ()
+{
+ if (settings.quiet == FALSE && settings.showclasses == TRUE)
+ return (TRUE);
+ else
+ return (FALSE);
+}
/** \brief Test if the logfile should include server private classes
*/
gboolean
-allow_log_class_event( const char *classname )
+allow_log_class_event (const char *classname)
{
#ifdef DEBUG
- /* debug mode */
- if( strncmp(classname,"geas::",6) == 0 ) {
+ /* debug mode */
+ if (strncmp (classname, "geas::", 6) == 0)
+ {
/* in the GEAS module, only log if configured to log GEAS classes */
- if( settings.loggeasclasses == CORBA_TRUE )
- return( TRUE );
- return( FALSE );
- }
- /* always log non geas:: classes */
- return( TRUE );
+ if (settings.loggeasclasses == CORBA_TRUE)
+ return (TRUE);
+ return (FALSE);
+ }
+ /* always log non geas:: classes */
+ return (TRUE);
#else
- /* normal mode */
- if( strncmp(classname,"geas::",6) == 0 ) {
+ /* normal mode */
+ if (strncmp (classname, "geas::", 6) == 0)
+ {
/* in the GEAS module, do not log geas:: classes */
- return( FALSE );
- }
- /* always log non geas:: classes */
- return( TRUE );
+ return (FALSE);
+ }
+ /* always log non geas:: classes */
+ return (TRUE);
#endif
}
/** \brief Display valid command line options
*/
static void
-usage()
- {
- fprintf(stdout, "\nUsage: geas-server [-c configfile] [other options]\n\n");
+usage ()
+{
+ fprintf (stdout,
+ "\nUsage: geas-server [-c configfile] [other options]\n\n");
#ifdef USE_GNU_GETOPT
- fprintf(stdout,
+ fprintf (stdout,
"--config FILE, -c FILE : Set configuration file to use.\n");
- #ifdef DEBUG
- fprintf(stdout,
+#ifdef DEBUG
+ fprintf (stdout,
"--debug LEVEL, -d LEVEL : Set debug level to 'LEVEL'.\n");
- #endif
+#endif
- fprintf(stdout,
+ fprintf (stdout,
"--verbose, -v : Verbose server output on. (Defaults
to 'off'.)\n");
- fprintf(stdout,
+ fprintf (stdout,
"--quiet, -q : Hide error messages (Defaults to
'off')\n");
- fprintf(stdout,
+ fprintf (stdout,
"--version, -V : Show version, then quit
immediately.\n");
- fprintf(stdout, "--showconfig, -C : Show configuration file.\n");
+ fprintf (stdout, "--showconfig, -C : Show configuration file.\n");
- fprintf(stdout, "--usage, -u :\n");
- fprintf(stdout, "--help, -h : Show this help text.\n");
+ fprintf (stdout, "--usage, -u :\n");
+ fprintf (stdout, "--help, -h : Show this help text.\n");
- fprintf(stdout, "\n(Note: -c must be the first command line option, if it
is used.)\n\n");
+ fprintf (stdout,
+ "\n(Note: -c must be the first command line option, if it is
used.)\n\n");
- fprintf(stdout, "ORBit related options:\n\n" );
- fprintf(stdout, "-ORBIIOPIPv4=1 : Enable IIOP over TCP/IPIP\n");
- fprintf(stdout, "-ORBIIOPIPv4=0 : Disable IIOP over
TCP/IPIP\n");
- fprintf(stdout, "-ORBIIOPUSock=1 : Enable IIOP over UNIX
sockets\n");
- fprintf(stdout, "-ORBIIOPUSock=0 : Disable IIOP over UNIX
sockets\n");
- fprintf(stdout, "\n" );
+ fprintf (stdout, "ORBit related options:\n\n");
+ fprintf (stdout,
+ "-ORBIIOPIPv4=1 : Enable IIOP over TCP/IPIP\n");
+ fprintf (stdout,
+ "-ORBIIOPIPv4=0 : Disable IIOP over TCP/IPIP\n");
+ fprintf (stdout,
+ "-ORBIIOPUSock=1 : Enable IIOP over UNIX sockets\n");
+ fprintf (stdout,
+ "-ORBIIOPUSock=0 : Disable IIOP over UNIX sockets\n");
+ fprintf (stdout, "\n");
#else
- fprintf(stdout,
- " -c FILE : Set configuration file to use.\n");
+ fprintf (stdout, " -c FILE : Set configuration file to use.\n");
- #ifdef DEBUG
- fprintf(stdout,
- " -d LEVEL : Set debug level to 'LEVEL'.\n");
- #endif
+#ifdef DEBUG
+ fprintf (stdout, " -d LEVEL : Set debug level to 'LEVEL'.\n");
+#endif
- fprintf(stdout,
+ fprintf (stdout,
" -v : Verbose server output on. (Defaults to
'off'.)\n");
- fprintf(stdout,
+ fprintf (stdout,
" -q : Hide error messages (Defaults to 'off')\n");
- fprintf(stdout,
+ fprintf (stdout,
" -V : Show version, then quit immediately.\n");
- fprintf(stdout, " -C : Show configuration file.\n");
+ fprintf (stdout, " -C : Show configuration file.\n");
- fprintf(stdout, " -u OR -h : Show this help text.\n");
- fprintf(stdout, "\n");
- fprintf(stdout, "ORBit related options:\n\n" );
- fprintf(stdout, "-ORBIIOPIPv4=1 : Enable IIOP over TCP/IPIP\n");
- fprintf(stdout, "-ORBIIOPIPv4=0 : Disable IIOP over TCP/IPIP\n");
- fprintf(stdout, "-ORBIIOPUSock=1 : Enable IIOP over UNIX sockets\n");
- fprintf(stdout, "-ORBIIOPUSock=0 : Disable IIOP over UNIX sockets\n");
- fprintf(stdout, "\n" );
+ fprintf (stdout, " -u OR -h : Show this help text.\n");
+ fprintf (stdout, "\n");
+ fprintf (stdout, "ORBit related options:\n\n");
+ fprintf (stdout, "-ORBIIOPIPv4=1 : Enable IIOP over TCP/IPIP\n");
+ fprintf (stdout, "-ORBIIOPIPv4=0 : Disable IIOP over TCP/IPIP\n");
+ fprintf (stdout, "-ORBIIOPUSock=1 : Enable IIOP over UNIX sockets\n");
+ fprintf (stdout, "-ORBIIOPUSock=0 : Disable IIOP over UNIX sockets\n");
+ fprintf (stdout, "\n");
#endif
- fprintf(stdout,
+ fprintf (stdout,
"Debug level: This sets the level of debugging output. It can be
one of 'off',\n");
- fprintf(stdout,
+ fprintf (stdout,
"'low', 'medium' or 'high'. Alternatively, an integer from 0 to 10
may be used,\n");
- fprintf(stdout, "where '0' is 'off' and '10' is maximum detail.\n\n");
- fprintf(stdout, "Note: 'quiet' mode cancels 'verbose' mode.\n");
+ fprintf (stdout, "where '0' is 'off' and '10' is maximum detail.\n\n");
+ fprintf (stdout, "Note: 'quiet' mode cancels 'verbose' mode.\n");
#ifdef SELF_TEST
- fprintf(stdout,
+ fprintf (stdout,
"In self test mode, verbose is turned on automatically, but\n");
- fprintf(stdout, "quiet mode can cancel this.\n");
+ fprintf (stdout, "quiet mode can cancel this.\n");
#endif
- fprintf(stdout, "\n");
- }
+ fprintf (stdout, "\n");
+}
/** \brief Describe the debuglevel system
*/
static void
-usage_debuglevel()
- {
- fprintf(stdout,
+usage_debuglevel ()
+{
+ fprintf (stdout,
"\nDebug level must be either off, low, medium, or high. Numeric
values must be\n"
"between %d and %d (inclusive).\n\n",
DEBUGLEVEL_LOW, DEBUGLEVEL_HIGH);
- }
+}
/** \brief Load the configuration file
*/
static void
-loadConfig(const char *filename, const char *shadowpasswordfile)
- {
- configuration c;
- FILE *fp;
-
- fp = fopen( filename , "r" );
- if( fp != NULL )
- {
- /* file exists! :) */
- fclose( fp );
- }
- else
- {
- /* nope, so try a final fallback */
- filename = "geas.conf";
- /* printf( "nope, so trying config file '%s'\n" , filename ); */
- }
+loadConfig (const char *filename, const char *shadowpasswordfile)
+{
+ configuration c;
+ FILE *fp;
+
+ fp = fopen (filename, "r");
+ if (fp != NULL)
+ {
+ /* file exists! :) */
+ fclose (fp);
+ }
+ else
+ {
+ /* nope, so try a final fallback */
+ filename = "geas.conf";
+ /* printf( "nope, so trying config file '%s'\n" , filename ); */
+ }
- debug_output( DEBUGLEVEL_2 , "Loading configuration from: %s",filename);
+ debug_output (DEBUGLEVEL_2, "Loading configuration from: %s", filename);
- c = load_configuration_file(filename, shadowpasswordfile);
- if (!c)
+ c = load_configuration_file (filename, shadowpasswordfile);
+ if (!c)
+ {
{
- {
- /* load_configuration() prints error messages to stderr */
- errormsg("Failed to read configuration data.");
- exit(0);
- }
+ /* load_configuration() prints error messages to stderr */
+ errormsg ("Failed to read configuration data.");
+ exit (0);
}
- if( get_global_option(c,"configfile") != NULL &&
- strcmp("unknown",get_global_option_str(c,"configfile","unknown")) == 0 )
- {
- /* load_configuration() prints error messages to stderr */
- errormsg("Failed to find or load the configuration file.");
- exit(0);
- }
+ }
+ if (get_global_option (c, "configfile") != NULL &&
+ strcmp ("unknown",
+ get_global_option_str (c, "configfile", "unknown")) == 0)
+ {
+ /* load_configuration() prints error messages to stderr */
+ errormsg ("Failed to find or load the configuration file.");
+ exit (0);
+ }
- /* store the config data */
- configdata = c;
+ /* store the config data */
+ configdata = c;
- loadTableAliases(
get_global_option_str(configdata,"tablealiases","./geas-table-aliases") );
- }
+ loadTableAliases (get_global_option_str
+ (configdata, "tablealiases", "./geas-table-aliases"));
+}
/* always printed */
/** \brief Display serious errors (can not be disabled at run time)
*/
-void criticalerror (char *fmt, ...)
+void
+criticalerror (char *fmt, ...)
{
- va_list a;
+ va_list a;
- fprintf(stderr,
"\n\n**********************************************************************\n");
- va_start(a, fmt);
- vfprintf(stderr, fmt, a);
- va_end(a);
- fprintf(stderr, "\n");
+ fprintf (stderr,
+
"\n\n**********************************************************************\n");
+ va_start (a, fmt);
+ vfprintf (stderr, fmt, a);
+ va_end (a);
+ fprintf (stderr, "\n");
}
/** \brief Display tect messages (if not in 'quiet' mode)
*/
void
-message(char *fmt, ...)
- {
- va_list a;
-
- /* write to log file */
- va_start(a, fmt);
- dm_vlogentry(DM_EVENT_MESSAGE,NULL,fmt,a);
- va_end(a);
-
- if (!allow_show_message())
- return ;
-
- va_start(a, fmt);
- vfprintf(stdout, fmt, a);
- va_end(a);
- fprintf(stdout, "\n");
- }
+message (char *fmt, ...)
+{
+ va_list a;
+ /* write to log file */
+ va_start (a, fmt);
+ dm_vlogentry (DM_EVENT_MESSAGE, NULL, fmt, a);
+ va_end (a);
+
+ if (!allow_show_message ())
+ return;
+
+ va_start (a, fmt);
+ vfprintf (stdout, fmt, a);
+ va_end (a);
+ fprintf (stdout, "\n");
+}
+
#ifdef SELF_TEST
void
-do_self_test_message(char *fmt, ...)
- {
- va_list a;
-
- if (settings.quiet == TRUE)
- return ;
-
- if (settings.quiet)
- return ;
-
- va_start(a, fmt);
- vfprintf(stderr, fmt, a);
- va_end(a);
- fprintf(stderr, "\n");
- }
+do_self_test_message (char *fmt, ...)
+{
+ va_list a;
+
+ if (settings.quiet == TRUE)
+ return;
+
+ if (settings.quiet)
+ return;
+
+ va_start (a, fmt);
+ vfprintf (stderr, fmt, a);
+ va_end (a);
+ fprintf (stderr, "\n");
+}
#endif
/** \brief Test if a file ends with a particular extension
*/
gboolean
-is_extension(char *filename, char *ext)
- {
- int flen = strlen(filename);
- int elen = strlen(ext);
-
- /* printf( "filename: '%s' (%d)\n" , filename , strlen(filename) ); *
- printf( "ext : '%s' (%d)\n" , ext , strlen(ext) ); printf( *
- "compare(%s,%s)\n" , &filename[flen - elen], ext ); */
+is_extension (char *filename, char *ext)
+{
+ int flen = strlen (filename);
+ int elen = strlen (ext);
- if ((elen + 1) > flen)
- return (FALSE);
- if (g_strcasecmp(&filename[flen - elen], ext) == 0 &&
- filename[flen - elen - 1] == '.')
- return (TRUE);
+ /* printf( "filename: '%s' (%d)\n" , filename , strlen(filename) ); *
+ printf( "ext : '%s' (%d)\n" , ext , strlen(ext) ); printf( *
+ "compare(%s,%s)\n" , &filename[flen - elen], ext ); */
+
+ if ((elen + 1) > flen)
+ return (FALSE);
+ if (g_strcasecmp (&filename[flen - elen], ext) == 0 &&
+ filename[flen - elen - 1] == '.')
+ return (TRUE);
- return (FALSE);
- }
+ return (FALSE);
+}
/** \brief Load the GCD files
*/
void
-load_class_files(void)
+load_class_files (void)
{
struct dirent *next;
DIR *reading;
- int error;
odl_filenamelist *fl = NULL;
char *name, *linkbuf, *classdir;
GList *l, *subdirs = NULL, *tmp;
GString *currpath = NULL;
struct stat s, s2;
- int linksize;
+ int linksize, err;
gboolean is_dir = FALSE;
- name = (char *)get_global_option_str(configdata, "classdir", ".");
+ name = (char *) get_global_option_str (configdata, "classdir", ".");
if (name == NULL)
{
perror ("Cannot parse classdir option");
exit (-1);
}
- debug_output(DEBUGLEVEL_HIGH,"Name = %s", name);
- classdir = g_strdup(name);
+ debug_output (DEBUGLEVEL_HIGH, "Name = %s", name);
+ classdir = g_strdup (name);
- debug_output(DEBUGLEVEL_HIGH,"Classdir = %s", classdir);
+ debug_output (DEBUGLEVEL_HIGH, "Classdir = %s", classdir);
- /* find GCD files */
+ /* find GCD files */
if (classdir == NULL)
{
- errormsg ("No class definitions were found. Please ensure the
configuration file\ndefines a directory with valid '.gcd' files.");
- exit( -1);
- }
- while (classdir[strlen(classdir) - 1] == '\\' ||
- classdir[strlen(classdir) - 1] == '/')
- classdir[strlen(classdir) - 1] = '\0';
+ errormsg
+ ("No class definitions were found. Please ensure the configuration
file\ndefines a directory with valid '.gcd' files.");
+ exit (-1);
+ }
+ while (classdir[strlen (classdir) - 1] == '\\' ||
+ classdir[strlen (classdir) - 1] == '/')
+ classdir[strlen (classdir) - 1] = '\0';
currpath = g_string_new (classdir);
currpath = g_string_append (currpath, "/");
subdirs = g_list_append (subdirs, g_strdup (classdir));
- debug_output(DEBUGLEVEL_HIGH,"Current path = %s", currpath->str);
+ debug_output (DEBUGLEVEL_HIGH, "Current path = %s", currpath->str);
while (g_list_length (subdirs) != 0)
{
reading = opendir (currpath->str);
if (!reading)
- {
- perror ((const char *)currpath->str);
- closedir (reading);
- exit (-1);
- }
+ {
+ perror ((const char *) currpath->str);
+ closedir (reading);
+ exit (-1);
+ }
else
- {
- /* Skip ./ and ../ directories */
- readdir (reading);
- readdir (reading);
-
- while ((next = readdir(reading)) != NULL)
- {
- lstat (g_strdup_printf ("%s%s", currpath->str, next->d_name), &s);
- if (S_ISLNK (s.st_mode))
- {
- linkbuf = g_new (gchar, PATH_MAX + 2);
- linksize = readlink (g_strdup_printf ("%s/%s", currpath->str,
next->d_name),
- linkbuf, PATH_MAX + 1);
- debug_output(DEBUGLEVEL_HIGH,"Link found: %s -> %s",
g_strdup_printf ("%s%s", currpath->str,
-
next->d_name), linkbuf);
- if (g_strcasecmp (classdir, linkbuf) &&
- g_strcasecmp ("./", linkbuf) &&
- g_strcasecmp ("../", linkbuf) &&
- g_strcasecmp (currpath->str, linkbuf))
- {
- stat (linkbuf, &s2);
- if (S_ISDIR (s2.st_mode))
- {
-#warning "FIXME: Bug in symlinks to directories -- chillywilly"
- debug_output(DEBUGLEVEL_MEDIUM,"Appending %s/",
linkbuf);
- subdirs = g_list_append (subdirs, g_strdup_printf
("%s/", linkbuf));
- }
- }
- g_free (linkbuf);
- }
- if (S_ISDIR (s.st_mode))
+ {
+ /* Skip ./ and ../ directories */
+ readdir (reading);
+ readdir (reading);
+
+ while ((next = readdir (reading)) != NULL)
+ {
+ err = lstat (g_strdup_printf ("%s%s", currpath->str,
next->d_name),
+ &s);
+ if (err == -1)
{
- is_dir = TRUE;
- debug_output(DEBUGLEVEL_MEDIUM,"Appending %s%s/",
currpath->str, next->d_name);
- subdirs = g_list_append (subdirs, g_strdup_printf ("%s%s/",
currpath->str,
-
next->d_name));
+ perror (errno);
+ exit (-1);
}
- if (is_extension(next->d_name, "gcd"))
- {
- char *tmp = g_strdup_printf("%s%s", currpath->str,
next->d_name);
- if( tmp )
+ if (S_ISLNK (s.st_mode))
+ {
+ linkbuf = g_new (gchar*, PATH_MAX + 2);
+ linksize =
+ readlink (g_strdup_printf
+ ("%s/%s", currpath->str, next->d_name), linkbuf,
+ PATH_MAX + 1);
+ if (linksize == -1)
{
- debug_output(DEBUGLEVEL_MEDIUM,"Adding %s to odl file
name list", tmp);
- fl = odl_filenamelist_add( fl , tmp );
- g_free( tmp );
+ perror (errno);
+ exit (-1);
}
- }
- }
- closedir(reading);
- subdirs = g_list_remove (subdirs, (g_list_first (subdirs))->data);
- if (subdirs)
- {
- g_string_free (currpath, TRUE);
- currpath = g_string_new ((g_list_first (subdirs))->data);
- }
- }
+ linkbuf[linksize] = '\0';
+ debug_output (DEBUGLEVEL_HIGH, "Link found: %s -> %s",
+ g_strdup_printf ("%s%s", currpath->str,
+ next->d_name), linkbuf);
+ if (g_strcasecmp (classdir, linkbuf)
+ && g_strncasecmp ("./", linkbuf, 2)
+ && g_strncasecmp ("../", linkbuf, 3)
+ && g_strcasecmp (currpath->str, linkbuf))
+ {
+ err = stat (linkbuf, &s2);
+ if (err == -1)
+ {
+ perror (strerror (errno));
+ exit (-1);
+ }
+ if (S_ISDIR (s2.st_mode))
+ {
+ debug_output (DEBUGLEVEL_MEDIUM, "Appending %s/",
+ linkbuf);
+ subdirs =
+ g_list_append (subdirs,
+ g_strdup_printf ("%s/", linkbuf));
+ }
+ }
+ g_free (linkbuf);
+ }
+ if (S_ISDIR (s.st_mode))
+ {
+ debug_output (DEBUGLEVEL_HIGH, "%s%s/ is a Directory.",
currpath->str, next->d_name);
+ is_dir = TRUE;
+ debug_output (DEBUGLEVEL_MEDIUM, "Appending %s%s/",
+ currpath->str, next->d_name);
+ subdirs =
+ g_list_append (subdirs,
+ g_strdup_printf ("%s%s/", currpath->str,
+ next->d_name));
+ }
+ if (is_extension (next->d_name, "gcd"))
+ {
+ char *tmp =
+ g_strdup_printf ("%s%s", currpath->str, next->d_name);
+ if (tmp)
+ {
+ debug_output (DEBUGLEVEL_MEDIUM,
+ "Adding %s to odl file name list", tmp);
+ fl = odl_filenamelist_add (fl, tmp);
+ g_free (tmp);
+ }
+ }
+ }
+ closedir (reading);
+ subdirs = g_list_remove (subdirs, (g_list_first (subdirs))->data);
+ if (subdirs)
+ {
+ g_string_free (currpath, TRUE);
+ currpath = g_string_new ((g_list_first (subdirs))->data);
+ }
+ }
}
-
- g_free(classdir);
+
+ g_free (classdir);
tmp = subdirs;
while (tmp)
@@ -1377,105 +1433,104 @@
if (!fl)
{
errormsg
- ("No class definitions were found. Please ensure the configuration
file\ndefines a directory with valid '.gcd' files.");
- exit( -1);
+ ("No class definitions were found. Please ensure the configuration
file\ndefines a directory with valid '.gcd' files.");
+ exit (-1);
}
/* load GCD files */
- all_classes = odl_load_files(fl, all_classes);
- odl_filenamelist_free(fl);
+ all_classes = odl_load_files (fl, all_classes);
+ odl_filenamelist_free (fl);
- /* load methods */
- /* TODO: */
+ /* load methods */
+ /* TODO: */
}
#ifdef ENABLE_NAMESERVICE
static void
-register_with_name_service( GEAS_ConnectionFactory factory )
+register_with_name_service (GEAS_ConnectionFactory factory)
{
- CORBA_Environment ev;
- FILE *fp;
- char ior[1024];
-
- fp = fopen(
get_global_option_str(configdata,"nameserviceior","/tmp/orbit-name") , "r" );
- if( !fp )
- {
- errormsg( "Could not read name service IOR" );
- return;
- }
- fgets( ior , 2044 , fp );
- fclose( fp );
- ior[1023] = '\0'; /* make sure it's terminated, just in case */
- while( ior[strlen(ior)-1] == 10 ||
- ior[strlen(ior)-1] == 13 )
- ior[strlen(ior)-1]= '\0';
-
- CORBA_exception_init(&ev);
- message("Attempting to register with naming service");
- name_srv = CORBA_ORB_string_to_object(the_orb,ior,&ev);
- if (ev._major == CORBA_NO_EXCEPTION)
- {
- main_name = create_name("GEAS");
- CosNaming_NamingContext_bind(name_srv, main_name,
- factory, &ev);
+ CORBA_Environment ev;
+ FILE *fp;
+ char ior[1024];
+
+ fp =
+ fopen (get_global_option_str
+ (configdata, "nameserviceior", "/tmp/orbit-name"), "r");
+ if (!fp)
+ {
+ errormsg ("Could not read name service IOR");
+ return;
+ }
+ fgets (ior, 2044, fp);
+ fclose (fp);
+ ior[1023] = '\0'; /* make sure it's terminated, just in case */
+ while (ior[strlen (ior) - 1] == 10 || ior[strlen (ior) - 1] == 13)
+ ior[strlen (ior) - 1] = '\0';
+
+ CORBA_exception_init (&ev);
+ message ("Attempting to register with naming service");
+ name_srv = CORBA_ORB_string_to_object (the_orb, ior, &ev);
+ if (ev._major == CORBA_NO_EXCEPTION)
+ {
+ main_name = create_name ("GEAS");
+ CosNaming_NamingContext_bind (name_srv, main_name, factory, &ev);
if (ev._major != CORBA_NO_EXCEPTION)
- {
- errormsg("Could not bind name to name service : %s",
- CORBA_exception_id(&ev));
- }
- main_name = create_name("ConnectionFactory");
- CosNaming_NamingContext_bind(name_srv, main_name,
- factory, &ev);
+ {
+ errormsg ("Could not bind name to name service : %s",
+ CORBA_exception_id (&ev));
+ }
+ main_name = create_name ("ConnectionFactory");
+ CosNaming_NamingContext_bind (name_srv, main_name, factory, &ev);
if (ev._major != CORBA_NO_EXCEPTION)
- {
- errormsg("Could not bind name to name service : %s",
- CORBA_exception_id(&ev));
- }
- }
- else
- {
- warnmsg("Could not locate name service.");
- }
- CORBA_exception_free(&ev);
+ {
+ errormsg ("Could not bind name to name service : %s",
+ CORBA_exception_id (&ev));
+ }
+ }
+ else
+ {
+ warnmsg ("Could not locate name service.");
+ }
+ CORBA_exception_free (&ev);
}
CosNaming_Name *
-create_name(const char *name)
- {
+create_name (const char *name)
+{
- CosNaming_Name *cos_name;
- CosNaming_NameComponent *cos_name_cmp;
- char *id;
- char *kind;
- char *dummy_kind = "filler";
-
- /* Allocate a CosNaming::Name (sequence of CosNaming::NameComponent) */
- cos_name = (CosNaming_Name *) g_malloc(sizeof(CosNaming_Name));
- cos_name->_maximum = 1L;
- cos_name->_length = 1L;
-
- /* Relinquish ownership of the NameComponent to the sequence. When
- CORBA_free is called on it later, the NameComponent will be freed */
- CORBA_sequence_set_release(cos_name, FALSE);
-
- /* Create the naming component. We don't care about the kind, so
- we give it a dummy value */
- cos_name_cmp = (CosNaming_NameComponent *)
- g_malloc(sizeof(CosNaming_NameComponent));
-
- /* Create id and kind value components. id is the name of our object */
- id = CORBA_string_alloc(strlen(name));
- strcpy(id, name);
- cos_name_cmp->id = id;
- kind = CORBA_string_alloc(strlen(dummy_kind));
- strcpy(kind, dummy_kind);
- cos_name_cmp->kind = kind;
+ CosNaming_Name *cos_name;
+ CosNaming_NameComponent *cos_name_cmp;
+ char *id;
+ char *kind;
+ char *dummy_kind = "filler";
+
+ /* Allocate a CosNaming::Name (sequence of CosNaming::NameComponent) */
+ cos_name = (CosNaming_Name *) g_malloc (sizeof (CosNaming_Name));
+ cos_name->_maximum = 1L;
+ cos_name->_length = 1L;
+
+ /* Relinquish ownership of the NameComponent to the sequence. When
+ CORBA_free is called on it later, the NameComponent will be freed */
+ CORBA_sequence_set_release (cos_name, FALSE);
+
+ /* Create the naming component. We don't care about the kind, so
+ we give it a dummy value */
+ cos_name_cmp = (CosNaming_NameComponent *)
+ g_malloc (sizeof (CosNaming_NameComponent));
+
+ /* Create id and kind value components. id is the name of our object */
+ id = CORBA_string_alloc (strlen (name));
+ strcpy (id, name);
+ cos_name_cmp->id = id;
+ kind = CORBA_string_alloc (strlen (dummy_kind));
+ strcpy (kind, dummy_kind);
+ cos_name_cmp->kind = kind;
- cos_name->_buffer = cos_name_cmp;
+ cos_name->_buffer = cos_name_cmp;
- return cos_name;
- }
+ return cos_name;
+}
#endif
@@ -1483,364 +1538,396 @@
*/
static void
-reserve_sql_words( const char *file , unsigned long int dbtype )
+reserve_sql_words (const char *file, unsigned long int dbtype)
{
- FILE *fp;
- char line[256];
- char *p,*q;
-
- trace_functioncall();
-
- fp = fopen( file , "r" );
- if( !fp ) return;
-
- while( !feof(fp) )
- {
- if( fgets(line,254,fp) != NULL )
- {
- /* remove comments */
- p = strchr( line , '#' );
- if( p ) *p = '\0';
-
- /* trim line */
- line[255] = '\0';
- p = line;
- while( p[ strlen(p) - 1 ] == '\n' || isspace(p[ strlen(p) - 1 ]) )
- p[ strlen(p) - 1 ] = '\0';
- p = line;
- while( isspace(*p) ) p++;
-
- while( (q = strtok(p," \t")) != NULL )
- {
- /* printf( "reserving '%s'\n" , q ); */
- add_reserved_word( q , dbtype , TRUE );
- p = NULL;
- }
- }
- }
- fclose( fp );
-
- /*
- printf( "%s %s reserved in %s\n" ,
- "position" ,
is_word_reserved("position",OQL_DBTYPE_MYSQL)?"is":"isn't" , "MySQL" );
- printf( "%s %s reserved in %s\n" ,
- "all" , is_word_reserved("all",OQL_DBTYPE_MYSQL)?"is":"isn't" ,
"MySQL" );
-
- printf( "%s %s reserved in %s\n" ,
- "position" ,
is_word_reserved("position",OQL_DBTYPE_POSTGRESQL)?"is":"isn't" , "PostgreSQL"
);
- printf( "%s %s reserved in %s\n" ,
- "all" , is_word_reserved("all",OQL_DBTYPE_POSTGRESQL)?"is":"isn't" ,
"PostgreSQL" );
- */
+ FILE *fp;
+ char line[256];
+ char *p, *q;
+
+ trace_functioncall ();
+
+ fp = fopen (file, "r");
+ if (!fp)
+ return;
+
+ while (!feof (fp))
+ {
+ if (fgets (line, 254, fp) != NULL)
+ {
+ /* remove comments */
+ p = strchr (line, '#');
+ if (p)
+ *p = '\0';
+
+ /* trim line */
+ line[255] = '\0';
+ p = line;
+ while (p[strlen (p) - 1] == '\n' || isspace (p[strlen (p) - 1]))
+ p[strlen (p) - 1] = '\0';
+ p = line;
+ while (isspace (*p))
+ p++;
+
+ while ((q = strtok (p, " \t")) != NULL)
+ {
+ /* printf( "reserving '%s'\n" , q ); */
+ add_reserved_word (q, dbtype, TRUE);
+ p = NULL;
+ }
+ }
+ }
+ fclose (fp);
+
+ /*
+ printf( "%s %s reserved in %s\n" ,
+ "position" , is_word_reserved("position",OQL_DBTYPE_MYSQL)?"is":"isn't" ,
"MySQL" );
+ printf( "%s %s reserved in %s\n" ,
+ "all" , is_word_reserved("all",OQL_DBTYPE_MYSQL)?"is":"isn't" , "MySQL" );
+
+ printf( "%s %s reserved in %s\n" ,
+ "position" ,
is_word_reserved("position",OQL_DBTYPE_POSTGRESQL)?"is":"isn't" , "PostgreSQL"
);
+ printf( "%s %s reserved in %s\n" ,
+ "all" , is_word_reserved("all",OQL_DBTYPE_POSTGRESQL)?"is":"isn't" ,
"PostgreSQL" );
+ */
}
struct DatabaseAliases
{
- char *databasename;
- GList *tables;
- GList *columns;
+ char *databasename;
+ GList *tables;
+ GList *columns;
};
struct TableAlias
{
- char *classname;
- char *tablename;
- gboolean modifyable;
- char *pkey;
+ char *classname;
+ char *tablename;
+ gboolean modifyable;
+ char *pkey;
};
struct ColumnAlias
{
- struct TableAlias *table;
- char *fieldname;
- char *columnname;
+ struct TableAlias *table;
+ char *fieldname;
+ char *columnname;
};
GList *database_alias_store = NULL;
struct DatabaseAliases *
-make_database_alias( const char *name )
+make_database_alias (const char *name)
{
- struct DatabaseAliases *d = g_new0( struct DatabaseAliases , 1 );
- if( d )
- {
- d->databasename = g_strdup( name );
- d->tables = NULL;
- d->columns = NULL;
- }
- return( d );
+ struct DatabaseAliases *d = g_new0 (struct DatabaseAliases, 1);
+ if (d)
+ {
+ d->databasename = g_strdup (name);
+ d->tables = NULL;
+ d->columns = NULL;
+ }
+ return (d);
}
struct TableAlias *
-make_table_alias( const char *classname , const char *tablename ,
- gboolean modifyable , const char *pkey )
+make_table_alias (const char *classname, const char *tablename,
+ gboolean modifyable, const char *pkey)
{
- struct TableAlias *a = g_new0( struct TableAlias , 1 );
- if( a )
- {
- a->classname = g_strdup( classname );
- a->tablename = g_strdup( tablename );
- a->modifyable = modifyable;
- a->pkey = g_strdup( pkey );
- }
- return( a );
+ struct TableAlias *a = g_new0 (struct TableAlias, 1);
+ if (a)
+ {
+ a->classname = g_strdup (classname);
+ a->tablename = g_strdup (tablename);
+ a->modifyable = modifyable;
+ a->pkey = g_strdup (pkey);
+ }
+ return (a);
}
struct ColumnAlias *
-make_column_alias( struct TableAlias *table,
- const char *fieldname , const char *columnname )
+make_column_alias (struct TableAlias *table,
+ const char *fieldname, const char *columnname)
+{
+ struct ColumnAlias *c = g_new0 (struct ColumnAlias, 1);
+ if (c)
+ {
+ c->table = table;
+ c->fieldname = g_strdup (fieldname);
+ c->columnname = g_strdup (columnname);
+ }
+ return (c);
+}
+
+static struct DatabaseAliases *
+find_alias_database (char *name)
+{
+ GList *l = database_alias_store;
+ while (l)
+ {
+ struct DatabaseAliases *d = (struct DatabaseAliases *) l->data;
+ if (g_strcasecmp (name, d->databasename) == 0)
+ return (d);
+ l = g_list_next (l);
+ }
+ return (NULL);
+}
+static struct TableAlias *
+find_alias_table (GList * tables, const char *name)
{
- struct ColumnAlias *c = g_new0( struct ColumnAlias , 1 );
- if( c )
- {
- c->table = table;
- c->fieldname = g_strdup( fieldname );
- c->columnname = g_strdup( columnname );
- }
- return( c );
-}
-
-static struct DatabaseAliases *find_alias_database( char *name )
-{
- GList *l = database_alias_store;
- while( l )
- {
- struct DatabaseAliases *d = (struct DatabaseAliases *)l->data;
- if( g_strcasecmp(name,d->databasename)==0 )
- return( d );
- l = g_list_next( l );
- }
- return( NULL );
-}
-static struct TableAlias *find_alias_table( GList *tables , const char *name )
-{
- while( tables )
- {
- struct TableAlias *t = (struct TableAlias *)tables->data;
- if( g_strcasecmp(t->classname,name)==0 ) return( t );
- tables = g_list_next( tables );
- }
- return( NULL );
-}
-static struct ColumnAlias *find_alias_column( GList *cols , const char *name )
-{
- while( cols )
- {
- struct ColumnAlias *c = (struct ColumnAlias *)cols->data;
- if( g_strcasecmp(c->fieldname,name)==0 ) return( c );
- cols = g_list_next( cols );
- }
- return( NULL );
-}
-
-static void loadTableAliases( const char *filename )
-{
- struct DatabaseAliases *db = NULL;
- FILE *fp;
- char buf[1024];
- char *p,*q;
- int lineno;
- char classname[1024];
- char database[1024];
- char tablename[1024];
- char pkey[1024];
- char column[1024];
- gboolean modify;
-
- printf( "Loading aliases from file '%s'\n" , filename );
-
- fp = fopen( filename , "r" );
- if( !fp ) return;
-
- buf[1023] = '\0';
-
- lineno = 0;
- while( !feof(fp) )
- {
- fgets( buf , 1022 , fp );
- lineno++;
- q = strchr( buf , '#' );
- if( q ) *q = '\0';
-
- p = buf;
- while( isspace(p[strlen(p)-1]) ||
- p[strlen(p)-1] == 10 ||
- p[strlen(p)-1] == 12 ||
- p[strlen(p)-1] == 13 )
- p[strlen(p)-1] = '\0';
- if( strlen(p) == 0 )
- continue;
-
- /* get classname */
- while( p && *p != '\0' && isspace(*p) ) p++;
- if( !p || *p == '\0' ) goto linefailed;
-
- q = p;
- while( !isspace(*q) ) q++;
- if( *q == '\0' ) goto linefailed;
- *q = '\0';
- strcpy( classname , p );
- p = strchr( classname , '.' );
- if( p )
- {
- *p = '\0';
- strcpy( column , p+1 );
- }
- else
- strcpy( column , "" );
- p = q+1;
-
-
- /* get tablename */
- while( p && *p != '\0' && isspace(*p) ) p++;
- if( !p || *p == '\0' ) goto linefailed;
-
- if( *p == '"' )
- {
- p++;
- q = p;
- while( *q != '\0' && *q != '"' ) q++;
- if( *q == '\0' ) goto linefailed;
- *q = '\0';
- strcpy( tablename , p );
- p = q+1;
- }
- else
- {
- q = p;
- while( !isspace(*q) ) q++;
- if( *q == '\0' ) goto linefailed;
- *q = '\0';
- strcpy( tablename , p );
- p = q+1;
- }
-
- /* get database */
- while( p && *p != '\0' && isspace(*p) ) p++;
- if( !p || *p == '\0' ) goto linefailed;
-
- q = p;
- while( !isspace(*q) ) q++;
- if( *q == '\0' ) goto linefailed;
- *q = '\0';
- strcpy( database , p );
- p = q+1;
-
- /* get can modify table? */
- if( strlen(column)>0 ) goto linedone;
- while( p && *p != '\0' && isspace(*p) ) p++;
- if( !p || *p == '\0' ) goto linefailed;
-
- q = p;
- while( !isspace(*q) && *q != '\0' ) q++;
- if( *q == '\0' )
- {
- if( g_strcasecmp(p,"YES")==0 || g_strcasecmp(p,"TRUE")==0 )
- modify = TRUE;
- if( g_strcasecmp(p,"NO")==0 || g_strcasecmp(p,"FALSE")==0 )
- modify=FALSE;
- p = q;
- }
- else
- {
- *q = '\0';
- if( g_strcasecmp(p,"YES")==0 || g_strcasecmp(p,"TRUE")==0 )
- modify = TRUE;
- if( g_strcasecmp(p,"NO")==0 || g_strcasecmp(p,"FALSE")==0 )
- modify=FALSE;
- p = q+1;
- }
-
- /* get primary key (in existing table) */
- strcpy( pkey , "" );
- while( p && *p != '\0' && isspace(*p) ) p++;
- if( !p || *p == '\0' ) {
- goto linedone; /* optional part */
- }
-
- q = p;
- while( !isspace(*q) ) q++;
- if( *q == '\0' ) goto linefailed;
- *q = '\0';
- strcpy( pkey , p );
- p = q+1;
-
-linedone:
-
- db = find_alias_database( database );
- if( !db )
- {
- db = make_database_alias( database );
- database_alias_store = g_list_append( database_alias_store , db );
- }
-
- printf( "Classname : %s\n" , classname );
- if( strlen(column) > 0 )
- {
- struct TableAlias *t;
- struct ColumnAlias *c;
- t = find_alias_table( db->tables , classname );
- c = make_column_alias( t , column , tablename );
- db->columns = g_list_append( db->columns , c );
-
- printf( "Field name : %s\n" , column );
- printf( "Column name : %s\n" , tablename );
- printf( "Database : %s\n" , database );
- }
- else
- {
- struct TableAlias *t;
-
- t = find_alias_table( db->tables , classname );
- if( !t )
- {
- t = make_table_alias( classname , tablename , modify , pkey );
- db->tables = g_list_append( db->tables , t );
- }
-
- printf( "Table name : %s\n" , tablename );
- printf( "Database : %s\n" , database );
- printf( "Can modify? : %s\n" , (modify?"YES":"NO") );
-
- }
- if( strlen(pkey)>0 ) printf( "Primary key : %s\n" , pkey );
- printf( "\n" );
- continue; /* go to top of for loop */
-
-linefailed:
- /* reaches here if a line has an error */
- errormsg( "Parse error in line %d of file '%s'" , lineno , filename );
- }
-
-
- {
- GList *l,*m;
- struct DatabaseAliases *d;
- struct TableAlias *t;
- struct ColumnAlias *c;
-
- l = database_alias_store;
- while( l )
- {
- d = l->data;
- printf( "Database: %s\n" , d->databasename );
- m = d->tables;
- while( m )
- {
- t = m->data;
- printf( " Table : %s -> %s\n" , t->classname ,
- t->tablename );
- m = g_list_next( m );
- }
- m = d->columns;
- while( m )
- {
- c = m->data;
- printf( " Column : %s.%s -> %s\n" ,
- (c->table!=NULL?(c->table->tablename):"(unknown)"),
- c->fieldname , c->columnname );
- m = g_list_next( m );
- }
- l = g_list_next( l );
- }
- }
+ while (tables)
+ {
+ struct TableAlias *t = (struct TableAlias *) tables->data;
+ if (g_strcasecmp (t->classname, name) == 0)
+ return (t);
+ tables = g_list_next (tables);
+ }
+ return (NULL);
+}
+static struct ColumnAlias *
+find_alias_column (GList * cols, const char *name)
+{
+ while (cols)
+ {
+ struct ColumnAlias *c = (struct ColumnAlias *) cols->data;
+ if (g_strcasecmp (c->fieldname, name) == 0)
+ return (c);
+ cols = g_list_next (cols);
+ }
+ return (NULL);
+}
+
+static void
+loadTableAliases (const char *filename)
+{
+ struct DatabaseAliases *db = NULL;
+ FILE *fp;
+ char buf[1024];
+ char *p, *q;
+ int lineno;
+ char classname[1024];
+ char database[1024];
+ char tablename[1024];
+ char pkey[1024];
+ char column[1024];
+ gboolean modify;
+
+ printf ("Loading aliases from file '%s'\n", filename);
+
+ fp = fopen (filename, "r");
+ if (!fp)
+ return;
+
+ buf[1023] = '\0';
+
+ lineno = 0;
+ while (!feof (fp))
+ {
+ fgets (buf, 1022, fp);
+ lineno++;
+ q = strchr (buf, '#');
+ if (q)
+ *q = '\0';
+
+ p = buf;
+ while (isspace (p[strlen (p) - 1]) ||
+ p[strlen (p) - 1] == 10 ||
+ p[strlen (p) - 1] == 12 || p[strlen (p) - 1] == 13)
+ p[strlen (p) - 1] = '\0';
+ if (strlen (p) == 0)
+ continue;
+
+ /* get classname */
+ while (p && *p != '\0' && isspace (*p))
+ p++;
+ if (!p || *p == '\0')
+ goto linefailed;
+
+ q = p;
+ while (!isspace (*q))
+ q++;
+ if (*q == '\0')
+ goto linefailed;
+ *q = '\0';
+ strcpy (classname, p);
+ p = strchr (classname, '.');
+ if (p)
+ {
+ *p = '\0';
+ strcpy (column, p + 1);
+ }
+ else
+ strcpy (column, "");
+ p = q + 1;
+
+
+ /* get tablename */
+ while (p && *p != '\0' && isspace (*p))
+ p++;
+ if (!p || *p == '\0')
+ goto linefailed;
+
+ if (*p == '"')
+ {
+ p++;
+ q = p;
+ while (*q != '\0' && *q != '"')
+ q++;
+ if (*q == '\0')
+ goto linefailed;
+ *q = '\0';
+ strcpy (tablename, p);
+ p = q + 1;
+ }
+ else
+ {
+ q = p;
+ while (!isspace (*q))
+ q++;
+ if (*q == '\0')
+ goto linefailed;
+ *q = '\0';
+ strcpy (tablename, p);
+ p = q + 1;
+ }
+
+ /* get database */
+ while (p && *p != '\0' && isspace (*p))
+ p++;
+ if (!p || *p == '\0')
+ goto linefailed;
+
+ q = p;
+ while (!isspace (*q))
+ q++;
+ if (*q == '\0')
+ goto linefailed;
+ *q = '\0';
+ strcpy (database, p);
+ p = q + 1;
+
+ /* get can modify table? */
+ if (strlen (column) > 0)
+ goto linedone;
+ while (p && *p != '\0' && isspace (*p))
+ p++;
+ if (!p || *p == '\0')
+ goto linefailed;
+
+ q = p;
+ while (!isspace (*q) && *q != '\0')
+ q++;
+ if (*q == '\0')
+ {
+ if (g_strcasecmp (p, "YES") == 0 || g_strcasecmp (p, "TRUE") == 0)
+ modify = TRUE;
+ if (g_strcasecmp (p, "NO") == 0 || g_strcasecmp (p, "FALSE") == 0)
+ modify = FALSE;
+ p = q;
+ }
+ else
+ {
+ *q = '\0';
+ if (g_strcasecmp (p, "YES") == 0 || g_strcasecmp (p, "TRUE") == 0)
+ modify = TRUE;
+ if (g_strcasecmp (p, "NO") == 0 || g_strcasecmp (p, "FALSE") == 0)
+ modify = FALSE;
+ p = q + 1;
+ }
+
+ /* get primary key (in existing table) */
+ strcpy (pkey, "");
+ while (p && *p != '\0' && isspace (*p))
+ p++;
+ if (!p || *p == '\0')
+ {
+ goto linedone; /* optional part */
+ }
+
+ q = p;
+ while (!isspace (*q))
+ q++;
+ if (*q == '\0')
+ goto linefailed;
+ *q = '\0';
+ strcpy (pkey, p);
+ p = q + 1;
+
+ linedone:
+
+ db = find_alias_database (database);
+ if (!db)
+ {
+ db = make_database_alias (database);
+ database_alias_store = g_list_append (database_alias_store, db);
+ }
+
+ printf ("Classname : %s\n", classname);
+ if (strlen (column) > 0)
+ {
+ struct TableAlias *t;
+ struct ColumnAlias *c;
+ t = find_alias_table (db->tables, classname);
+ c = make_column_alias (t, column, tablename);
+ db->columns = g_list_append (db->columns, c);
+
+ printf ("Field name : %s\n", column);
+ printf ("Column name : %s\n", tablename);
+ printf ("Database : %s\n", database);
+ }
+ else
+ {
+ struct TableAlias *t;
+
+ t = find_alias_table (db->tables, classname);
+ if (!t)
+ {
+ t = make_table_alias (classname, tablename, modify, pkey);
+ db->tables = g_list_append (db->tables, t);
+ }
+
+ printf ("Table name : %s\n", tablename);
+ printf ("Database : %s\n", database);
+ printf ("Can modify? : %s\n", (modify ? "YES" : "NO"));
+
+ }
+ if (strlen (pkey) > 0)
+ printf ("Primary key : %s\n", pkey);
+ printf ("\n");
+ continue; /* go to top of for loop */
+
+ linefailed:
+ /* reaches here if a line has an error */
+ errormsg ("Parse error in line %d of file '%s'", lineno, filename);
+ }
+
+
+ {
+ GList *l, *m;
+ struct DatabaseAliases *d;
+ struct TableAlias *t;
+ struct ColumnAlias *c;
+
+ l = database_alias_store;
+ while (l)
+ {
+ d = l->data;
+ printf ("Database: %s\n", d->databasename);
+ m = d->tables;
+ while (m)
+ {
+ t = m->data;
+ printf (" Table : %s -> %s\n", t->classname, t->tablename);
+ m = g_list_next (m);
+ }
+ m = d->columns;
+ while (m)
+ {
+ c = m->data;
+ printf (" Column : %s.%s -> %s\n",
+ (c->table != NULL ? (c->table->tablename) : "(unknown)"),
+ c->fieldname, c->columnname);
+ m = g_list_next (m);
+ }
+ l = g_list_next (l);
+ }
+ }
}
- gnue/geas/src geas-server.c,
Daniel E. Baumann <=