Main Page Class Hierarchy Compound List File List Compound Members File Members

# getutil.c

Go to the documentation of this file.

    00001
    00002 /*
    00003  *   THIS FILE IS UNDER RCS - DO NOT MODIFY UNLESS YOU HAVE
    00004  *   CHECKED IT OUT USING THE COMMAND CHECKOUT.
    00005  *
    00006  *    $Id: getutil_8c-source.html,v 1.1 2006/05/19 16:55:02 paulf Exp $
    00007  *
    00008  *    Revision history:
    00009  *     $Log: getutil_8c-source.html,v $
    00009  *     Revision 1.1  2006/05/19 16:55:02  paulf
    00009  *     first inclusion
    00009  *
    00010  *     Revision 1.3  2000/07/27 16:23:31  lucky
    00011  *     Implemented global limits, from earthworm.h, in the sizes of installation ids,
    00012  *     message types, ring names, and module names.
    00013  *
    00014  *     Revision 1.2  2000/07/08 19:49:11  lombard
    00015  *     fprintf statment had extra %s format
    00016  *
    00017  *     Revision 1.1  2000/02/14 18:51:48  lucky
    00018  *     Initial revision
    00019  *
    00020  *
    00021  */
    00022
    00023 /*
    00024  *  getutil.c  functions for looking up shared memory rings,
    00025  *             installations, modules, and message types in
    00026  *             Earthworm tables.  Given a character-string name,
    00027  *             these functions return a numerical value.
    00028  *
    00029  *             The installation table is set up in the include-file
    00030  *             earthworm.h; it is global to all Earthworm installations.
    00031  *             Changes to this table require a recompilation of the
    00032  *             whole Earthworm tree.
    00033  *
    00034  *             The shared memory ring, module, and message type tables
    00035  *             are set up in the ascii table file (whose name is stored
    00036  *             in the global variable, TableFile) which resides in the
    00037  *             EW_PARAMS directory.  Changes to this file do not require
    00038  *             recompilation.
    00039  *
    00040  *  990603:LDD Modified GetUtil_LoadTable to read in installation ids
    00041  *             from an ascii file (instead of being defined in earthworm.h)
    00042  *             so that installations can be added without recompiling!  LDD
    00043  *
    00044  */
    00045
    00046 #include <stdio.h>
    00047 #include <stdlib.h>
    00048 #include <string.h>
    00049 #include <earthworm.h>
    00050 #include <kom.h>
    00051
    00052 /* Table of shared memory ring names & their keys
    00053  ************************************************/
    00054 #define MAXRING 20
    00055 #define RINGLEN MAX_RING_STR
    00056 static struct {
    00057   long   key;
    00058   char   name[RINGLEN+1];
    00059 } EW_Ring[MAXRING];
    00060 static int Max_Ring = 0;      /* # ring/keys currently in table */
    00061
    00062 /* Table of module names and their module_ids
    00063  ********************************************/
    00064 #define MAXMODID 256
    00065 #define MODLEN  MAX_MOD_STR
    00066 static struct {
    00067   unsigned char id;
    00068   char          name[MODLEN+1];
    00069 } EW_Module[MAXMODID];
    00070 static int Max_ModuleId = 0;  /* # modules currently in table */
    00071
    00072 /* Table of message names and their type-values
    00073  **********************************************/
    00074 #define MAXMSGTYPE 256
    00075 #define MSGLEN     MAX_TYPE_STR
    00076 static struct {
    00077   unsigned char type;
    00078   char          name[MSGLEN+1];
    00079 } EW_Message[MAXMSGTYPE];
    00080 static int Max_MessageType = 0;  /* # msg types currently in table */
    00081
    00082 /* Table of Installation names and their instids
    00083  ***********************************************/
    00084 #define MAXINSTID 256
    00085 #define INSTLEN   MAX_INST_STR
    00086 static struct {
    00087   unsigned char id;
    00088   char          name[INSTLEN+1];
    00089 } EW_Installation[MAXINSTID];
    00090 static int Max_Installation = 0;  /* # installations currently in table */
    00091
    00092 #define MAXLEN 255
    00093 static char  FullTablePath[MAXLEN+1];
    00094 static char *TableFile[] = {"earthworm_global.d","earthworm.d"};
    00095 static char  nTableFile  = 2;
    00096 static int   LoadTables  = 1;   /* Do tables need to be loaded from */
    00097                                 /* the TableFile?    1=yes 0=no     */
    00098
    00099          /*******************************************************
    00100           *                      GetKey                         *
    00101           *                                                     *
    00102           *  Convert ring name to key number using table        *
    00103           *  in TableFile                                       *
    00104           *  Return <key number> on success;                    *
    00105           *          -1 if the specified ring name is unknown.  *
    00106           *******************************************************/
    00107 long GetKey( char *ringName )
    00108 {
    00109    int i;
    00110
    00111    if( LoadTables ) {
    00112        GetUtil_LoadTable();
    00113        LoadTables = 0;
    00114    }
    00115
    00116 /* Find transport ring name in earthworm.d table
    00117  ***********************************************/
    00118    for ( i = 0; i < Max_Ring; i++ )
    00119       if ( strcmp( EW_Ring[i].name, ringName ) == 0 )
    00120          break;
    00121
    00122 /* Didn't find ring name in table
    00123  ********************************/
    00124    if ( i == Max_Ring )
    00125    {
    00126       fprintf( stderr, "GetKey: Invalid ring name <%s>\n", ringName );
    00127       return( -1 );
    00128    }
    00129
    00130 /* Found it!
    00131  ***********/
    00132    return( EW_Ring[i].key );
    00133 }
    00134
    00135
    00136          /*******************************************************
    00137           *                   GetLocalInst                      *
    00138           *                                                     *
    00139           *  Convert the local installation name, set by the    *
    00140           *  environment variable EW_INSTALLATION, to a number  *
    00141           *  using the table in earthworm.h                     *
    00142           *  Return  0 on success;                              *
    00143           *         -1 if the environment variable is not       *
    00144           *            defined;                                 *
    00145           *         -2 if the env. variable has no value        *
    00146           *         -3 if the specified installation name is    *
    00147           *            not listed in earthworm.h                *
    00148           *******************************************************/
    00149 int GetLocalInst( unsigned char *localId )
    00150 {
    00151    char *envInst;
    00152
    00153    *localId = 0;
    00154
    00155 /* Get the installation name from environment variable EW_INSTALLATION
    00156    *******************************************************************/
    00157    envInst = getenv( "EW_INSTALLATION" );
    00158
    00159    if ( envInst == (char *) NULL )
    00160    {
    00161       fprintf( stderr,
    00162               "GetLocalInst: Environment variable EW_INSTALLATION not defined.\n" );
    00163       return( -1 );
    00164    }
    00165
    00166    if ( *envInst == '\0' )
    00167    {
    00168       fprintf( stderr, "GetLocalInst: Environment variable EW_INSTALLATION" );
    00169       fprintf( stderr, " defined, but has no value.\n" );
    00170       return( -2 );
    00171    }
    00172
    00173    if( LoadTables ) {
    00174        GetUtil_LoadTable();
    00175        LoadTables = 0;
    00176    }
    00177
    00178 /* Find the id-value in the table
    00179  ********************************/
    00180    if ( GetInst( envInst, localId ) < 0 )
    00181    {
    00182       fprintf( stderr,
    00183               "GetLocalInst: Environment variable EW_INSTALLATION" );
    00184       fprintf( stderr, " has invalid value <%s>\n", envInst );
    00185       return( -3 );
    00186    }
    00187
    00188    return( 0 );
    00189 }
    00190
    00191
    00192          /*******************************************************
    00193           *                      GetInst                        *
    00194           *                                                     *
    00195           *  Convert installation name to number using table    *
    00196           *  in earthworm.h                                     *
    00197           *  Return  0 on success;                              *
    00198           *         -1 if the specified installation name is    *
    00199           *            unknown.                                 *
    00200           *******************************************************/
    00201 int GetInst( char *instName, unsigned char *instId )
    00202 {
    00203    int i;
    00204
    00205    if( LoadTables ) {
    00206        GetUtil_LoadTable();
    00207        LoadTables = 0;
    00208    }
    00209
    00210 /* Find installation name in earthworm.h table
    00211  *********************************************/
    00212    for ( i = 0; i < Max_Installation; i++ )
    00213       if ( strcmp( EW_Installation[i].name, instName ) == 0 )
    00214          break;
    00215
    00216 /* Didn't find installation name in table
    00217  ****************************************/
    00218    if ( i == Max_Installation )
    00219    {
    00220       fprintf( stderr,
    00221               "GetInst: Invalid installation name <%s>\n", instName );
    00222      *instId = 0;
    00223       return( -1 );
    00224    }
    00225
    00226 /* Found it!
    00227  ***********/
    00228   *instId = EW_Installation[i].id;
    00229    return( 0 );
    00230 }
    00231
    00232          /*******************************************************
    00233           *                      GetModId                       *
    00234           *                                                     *
    00235           *  Convert module name to modid number using table    *
    00236           *  defined in TableFile                               *
    00237           *  Return  0 on success;                              *
    00238           *         -1 if the specified module name is unknown. *
    00239           *******************************************************/
    00240 int GetModId( char *modName, unsigned char *modId )
    00241 {
    00242    int i;
    00243
    00244    if( LoadTables ) {
    00245        GetUtil_LoadTable();
    00246        LoadTables = 0;
    00247    }
    00248
    00249 /* Find module name in earthworm.h table
    00250  ***************************************/
    00251    for ( i = 0; i < Max_ModuleId; i++ )
    00252       if ( strcmp( EW_Module[i].name, modName ) == 0 )
    00253          break;
    00254
    00255 /* Didn't find module name in table
    00256  **********************************/
    00257    if ( i == Max_ModuleId )
    00258    {
    00259       fprintf( stderr, "GetModId: Invalid module name <%s>\n", modName );
    00260      *modId = 0;
    00261       return( -1 );
    00262    }
    00263
    00264 /* Found it!
    00265  ***********/
    00266   *modId = EW_Module[i].id;
    00267    return( 0 );
    00268 }
    00269
    00270          /*******************************************************
    00271           *                      GetType                        *
    00272           *                                                     *
    00273           * Convert message-type name to number using table     *
    00274           * defined in TableFile                                *
    00275           * Return  0 on success;                               *
    00276           *        -1 if specified message-type name is unknown *
    00277           *******************************************************/
    00278 int GetType( char *msgName, unsigned char *msgType )
    00279 {
    00280    int i;
    00281
    00282    if( LoadTables ) {
    00283        GetUtil_LoadTable();
    00284        LoadTables = 0;
    00285    }
    00286
    00287 /* Find message-type name in earthworm.h table
    00288  *********************************************/
    00289    for ( i = 0; i < Max_MessageType; i++ )
    00290       if ( strcmp( EW_Message[i].name, msgName ) == 0 )
    00291          break;
    00292
    00293 /* Didn't find message-type name in table
    00294  ****************************************/
    00295    if ( i == Max_MessageType )
    00296    {
    00297       fprintf( stderr,
    00298               "GetType: Invalid message-type name <%s>\n", msgName );
    00299      *msgType = 0;
    00300       return( -1 );
    00301    }
    00302
    00303 /* Found it!
    00304  ***********/
    00305   *msgType = EW_Message[i].type;
    00306    return( 0 );
    00307 }
    00308
    00309   /********************************************************************
    00310    * GetUtil_LoadTable  loads the ring, module, and message tables    *
    00311    *            from ascii files (TableFile) using kom.c functions.   *
    00312    *            Exits if any errors are encountered.                  *
    00313    ********************************************************************/
    00314 void GetUtil_LoadTable( void )
    00315 {
    00316    int      ncommand;     /* # of required commands you expect to process   */
    00317    char     init[10];     /* init flags, one byte for each required command */
    00318    int      nmiss;        /* number of required commands that were missed   */
    00319    char    *paramdir;    /* points to environment variable, EW_PARAMS      */
    00320    char    *com;
    00321    char    *str;
    00322    int      nfiles, nopen;
    00323    int      success;
    00324    long     tmpkey;
    00325    int      tmp;
    00326    int      conflict;
    00327    int      i,it;
    00328    size_t   len;
    00329
    00330 /* Set to zero one init flag for each required command
    00331  *****************************************************/
    00332    ncommand = 4;
    00333    for( i=0; i<ncommand; i++ )  init[i] = 0;
    00334
    00335 /* Get the environment variable, EW_PARAMS
    00336  *****************************************/
    00337    paramdir = getenv( "EW_PARAMS" );
    00338
    00339    if ( paramdir == (char *)NULL )
    00340    {
    00341       printf( "GetUtil_LoadTable: Environment variable EW_PARAMS not defined!" );
    00342       printf( " exiting!\n" );
    00343       exit(-1);
    00344    }
    00345    if ( *paramdir == '\0' )
    00346    {
    00347       printf( "GetUtil_LoadTable: Environment variable EW_PARAMS " );
    00348       printf( "defined, but has no value; exiting!\n" );
    00349       exit( -1 );
    00350    }
    00351
    00352 /* Loop thru all interesting Table files
    00353  ***************************************/
    00354    for( it=0; it<nTableFile; it++ )
    00355    {
    00356
    00357    /* Build full path to table file
    00358     *******************************/
    00359       if( strlen(paramdir)+strlen(TableFile[it])+1 > (size_t)MAXLEN )
    00360       {
    00361          printf("GetUtil_LoadTable: length of EW_PARAMS+TableFile[%d] ",it);
    00362          printf("exceeds FullTablePath, MAXLEN=%d; exiting!\n", MAXLEN );
    00363          exit( -1 );
    00364       }
    00365       strcpy( FullTablePath, paramdir  );
    00366       len = strlen( FullTablePath );
    00367    #ifdef _SOLARIS
    00368       if( FullTablePath[len-1] != '/' )   strcat( FullTablePath, "/" );
    00369    #else  /* OS/2 or NT */
    00370       if( FullTablePath[len-1] != '\\' )  strcat( FullTablePath, "\\" );
    00371    #endif
    00372       strcat( FullTablePath, TableFile[it] );
    00373       /*printf( "path to modid/msgtype table: <%s>\n", FullTablePath );*//*DEBUG*/
    00374
    00375    /* Open the main table file
    00376     **************************/
    00377       nfiles = k_open( FullTablePath );
    00378       if( nfiles == 0 ) {
    00379            fprintf( stderr,
    00380                    "GetUtil_LoadTable: Error opening file <%s>; exiting!\n",
    00381                     FullTablePath );
    00382            exit( -1 );
    00383       }
    00384       nopen = nfiles-1;  /* keep track of # open files before TableFile */
    00385
    00386    /* Process all command files
    00387     ***************************/
    00388       while( nfiles > nopen ) /* While there are getutil-files open */
    00389       {
    00390            while(k_rd())        /* Read next line from active file  */
    00391            {
    00392                com = k_str();         /* Get the first token from line */
    00393
    00394            /* Ignore blank lines & comments
    00395             *******************************/
    00396                if( !com )           continue;
    00397                if( com[0] == '#' )  continue;
    00398
    00399            /* Open a nested configuration file
    00400             **********************************/
    00401                if( com[0] == '@' ) {
    00402                   success = nfiles+1;
    00403                   nfiles  = k_open(&com[1]);
    00404                   if ( nfiles != success ) {
    00405                      fprintf( stderr,
    00406                              "GetUtil_LoadTable: Error opening file <%s>; exiting!\n",
    00407                               &com[1] );
    00408                      exit( -1 );
    00409                   }
    00410                   continue;
    00411                }
    00412
    00413             /* Process anything else as a command:
    00414              *************************************/
    00415
    00416             /* Load shared memory ring name/key table
    00417              ****************************************/
    00418   /*0*/        if( k_its("Ring") )
    00419                {
    00420                 /* see if there's more room in the table */
    00421                    if ( Max_Ring+1 >= MAXRING ) {
    00422                        fprintf( stderr,
    00423                                "GetUtil_LoadTable: Too many <Ring> lines in <%s>",
    00424                                 FullTablePath );
    00425                        fprintf( stderr, "; max=%d; exiting!\n", (int) MAXRING );
    00426                        exit( -1 );
    00427                    }
    00428                    str    = k_str();    /* get ring name from line */
    00429                    tmpkey = k_long();   /* get ring key from line  */
    00430
    00431                 /* check the length of the ringname */
    00432                    if ( strlen(str) > RINGLEN )
    00433                    {
    00434                        fprintf( stderr,
    00435                                "GetUtil_LoadTable: Ring name <%s> too long in <%s>;"
    00436                                " max=%d chars; exiting!\n", str, FullTablePath, RINGLEN );
    00437                        exit( -1 );
    00438                    }
    00439
    00440                 /* look thru current table for duplicate key or name */
    00441                    conflict = 0;
    00442                    for( i=0; i<Max_Ring; i++ ) {
    00443                         if( tmpkey == EW_Ring[i].key ) {
    00444                            if( strcmp( EW_Ring[i].name, str ) != 0 ) conflict=1;
    00445                            break;
    00446                         }
    00447                         if( strcmp( EW_Ring[i].name, str ) == 0 ) {
    00448                            if( tmpkey != EW_Ring[i].key ) conflict=1;
    00449                            break;
    00450                         }
    00451                    }
    00452
    00453                 /* complain if there was a conflict with a previous setting */
    00454                    if( conflict ) {
    00455                         fprintf( stderr,
    00456                                 "GetUtil_LoadTable: conflict in <%s>, new setting ignored\n",
    00457                                  FullTablePath );
    00458                         fprintf( stderr,
    00459                                 "                   original: <Ring %s %ld>\n",
    00460                                  EW_Ring[i].name, EW_Ring[i].key );
    00461                         fprintf( stderr,
    00462                                 "                        new: <Ring %s %ld>\n",
    00463                                  str, tmpkey);
    00464                    }
    00465
    00466                 /* add new entry to table */
    00467                    if( i==Max_Ring ) {
    00468                       strcpy( EW_Ring[Max_Ring].name, str );
    00469                       EW_Ring[Max_Ring].key = tmpkey;
    00470                       Max_Ring++;
    00471                    }
    00472                    init[0] = 1;
    00473                }
    00474
    00475             /* Enter module name/id table
    00476              ****************************/
    00477   /*1*/        else if( k_its("Module") )
    00478                {
    00479                 /* see if there's more room in the table */
    00480                    if ( Max_ModuleId+1 >= MAXMODID ) {
    00481                        fprintf( stderr,
    00482                                "GetUtil_LoadTable: Too many <Module> lines in <%s>",
    00483                                 FullTablePath );
    00484                        fprintf( stderr, "; max=%d; exiting!\n", (int) MAXMODID );
    00485                        exit( -1 );
    00486                    }
    00487                    str = k_str();    /* get module name from line */
    00488                    tmp = k_int();    /* get module id from line   */
    00489
    00490                 /* check validity of module id */
    00491                    if( tmp<0 || tmp>255 ) {
    00492                         fprintf( stderr,
    00493                                 "GetUtil_LoadTable: Invalid module id <%d> in <%s>",
    00494                                  tmp, FullTablePath );
    00495                         fprintf( stderr, " (0-255 are valid); exiting!\n" );
    00496                         exit( -1 );
    00497                    }
    00498
    00499                 /* check the length of the module name */
    00500                    if ( strlen(str) > MODLEN )
    00501                    {
    00502                        fprintf( stderr,
    00503                                "GetUtil_LoadTable: Module name <%s> too long in <%s>;"
    00504                                " max=%d chars; exiting!\n", str, FullTablePath, MODLEN );
    00505                        exit( -1 );
    00506                    }
    00507
    00508                 /* look thru current table for duplicate key or name */
    00509                    conflict = 0;
    00510                    for( i=0; i<Max_ModuleId; i++ ) {
    00511                         if( tmp == (int)EW_Module[i].id ) {
    00512                            if( strcmp( EW_Module[i].name, str ) != 0 ) conflict=1;
    00513                            break;
    00514                         }
    00515                         if( strcmp( EW_Module[i].name, str ) == 0 ) {
    00516                            if( tmp != (int)EW_Module[i].id ) conflict=1;
    00517                            break;
    00518                         }
    00519                    }
    00520
    00521                 /* complain if there was a conflict with a previous setting */
    00522                    if( conflict ) {
    00523                         fprintf( stderr,
    00524                                 "GetUtil_LoadTable: conflict in <%s>, new setting ignored\n",
    00525                                  FullTablePath );
    00526                         fprintf( stderr,
    00527                                 "                   original: <Module %s %d>\n",
    00528                                  EW_Module[i].name, (int) EW_Module[i].id );
    00529                         fprintf( stderr,
    00530                                 "                        new: <Module %s %d>\n",
    00531                                  str, tmp );
    00532                    }
    00533
    00534                 /* add new entry to table */
    00535                    if( i==Max_ModuleId ) {
    00536                        strcpy( EW_Module[Max_ModuleId].name, str );
    00537                        EW_Module[Max_ModuleId].id = (unsigned char) tmp;
    00538                        Max_ModuleId++;
    00539                    }
    00540                    init[1] = 1;
    00541                }
    00542
    00543             /* Enter message name/type table
    00544              *******************************/
    00545   /*2*/        else if( k_its("Message") )
    00546                {
    00547                 /* see if there's more room in the table */
    00548                    if ( Max_MessageType+1 >= MAXMSGTYPE ) {
    00549                        fprintf( stderr,
    00550                                "GetUtil_LoadTable: Too many <Message> lines in <%s>",
    00551                                 FullTablePath );
    00552                        fprintf( stderr, "; max=%d; exiting!\n", (int) MAXMSGTYPE );
    00553                        exit( -1 );
    00554                    }
    00555                    str = k_str();    /* get message name from line */
    00556                    tmp = k_int();    /* get message type from line */
    00557
    00558                 /* check validity of module id */
    00559                    if( tmp<0 || tmp>255 ) {
    00560                         fprintf( stderr,
    00561                                 "GetUtil_LoadTable: Invalid message type <%d> in <%s>",
    00562                                  tmp, FullTablePath );
    00563                         fprintf( stderr, " (0-255 are valid); exiting!\n" );
    00564                         exit( -1 );
    00565                    }
    00566
    00567                 /* check the length of the message */
    00568                    if ( strlen(str) > MSGLEN )
    00569                    {
    00570                        fprintf( stderr,
    00571                                "GetUtil_LoadTable: Message name <%s> too long in <%s>;"
    00572                                " max=%d chars; exiting!\n", str, FullTablePath, MSGLEN );
    00573                        exit( -1 );
    00574                    }
    00575
    00576                 /* look thru current table for duplicate type or name */
    00577                    conflict = 0;
    00578                    for( i=0; i<Max_MessageType; i++ ) {
    00579                         if( tmp == (int)EW_Message[i].type ) {
    00580                            if( strcmp( EW_Message[i].name, str ) != 0 ) conflict=1;
    00581                            break;
    00582                         }
    00583                         if( strcmp( EW_Message[i].name, str ) == 0 ) {
    00584                            if( tmp != (int)EW_Message[i].type ) conflict=1;
    00585                            break;
    00586                         }
    00587                    }
    00588
    00589                 /* complain if there was a conflict with a previous setting */
    00590                    if( conflict ) {
    00591                         fprintf( stderr,
    00592                                 "GetUtil_LoadTable: conflict in <%s>, new setting ignored\n",
    00593                                  FullTablePath );
    00594                         fprintf( stderr,
    00595                                 "                   original: <Message %s %d>\n",
    00596                                  EW_Message[i].name, (int) EW_Message[i].type );
    00597                         fprintf( stderr,
    00598                                 "                        new: <Message %s %d>\n",
    00599                                  str, tmp );
    00600                    }
    00601
    00602                 /* add new entry to table */
    00603                    if( i==Max_MessageType ) {
    00604                        strcpy( EW_Message[Max_MessageType].name, str );
    00605                        EW_Message[Max_MessageType].type = (unsigned char) tmp;
    00606                        Max_MessageType++;
    00607                    }
    00608                    init[2] = 1;
    00609                }
    00610
    00611             /* Enter installation name/type table
    00612              ************************************/
    00613   /*3*/        else if( k_its("Installation") )
    00614                {
    00615                 /* see if there's more room in the table */
    00616                    if ( Max_Installation+1 >= MAXINSTID ) {
    00617                        fprintf( stderr,
    00618                                "GetUtil_LoadTable: Too many <Installation> lines in <%s>"
    00619                                "; max=%d; exiting!\n", FullTablePath, (int) MAXINSTID );
    00620                        exit( -1 );
    00621                    }
    00622                    str = k_str();    /* get installation name from line */
    00623                    tmp = k_int();    /* get instid from line */
    00624
    00625                 /* check validity of instid */
    00626                    if( tmp<0 || tmp>255 ) {
    00627                         fprintf( stderr,
    00628                                 "GetUtil_LoadTable: Invalid installation id <%d> in <%s>"
    00629                                 " (0-255 are valid); exiting!\n", tmp, FullTablePath );
    00630                         exit( -1 );
    00631                    }
    00632
    00633                 /* check the length of the installation name */
    00634                    if ( strlen(str) > INSTLEN )
    00635                    {
    00636                        fprintf( stderr,
    00637                                "GetUtil_LoadTable: Installation name <%s> too long in <%s>;"
    00638                                " max=%d chars; exiting!\n", str, FullTablePath, INSTLEN );
    00639                        exit( -1 );
    00640                    }
    00641
    00642                 /* look thru current table for duplicate instid or name */
    00643                    conflict = 0;
    00644                    for( i=0; i<Max_Installation; i++ ) {
    00645                         if( tmp == (int)EW_Installation[i].id ) {
    00646                            if( strcmp( EW_Installation[i].name, str ) != 0 ) conflict=1;
    00647                            break;
    00648                         }
    00649                         if( strcmp( EW_Installation[i].name, str ) == 0 ) {
    00650                            if( tmp != (int)EW_Installation[i].id ) conflict=1;
    00651                            break;
    00652                         }
    00653                    }
    00654
    00655                 /* complain if there was a conflict with a previous setting */
    00656                    if( conflict ) {
    00657                         fprintf( stderr,
    00658                                 "GetUtil_LoadTable: conflict in <%s>, new setting ignored\n",
    00659                                  FullTablePath );
    00660                         fprintf( stderr,
    00661                                 "                   original: <Installation %s %d>\n",
    00662                                  EW_Installation[i].name, (int) EW_Installation[i].id );
    00663                         fprintf( stderr,
    00664                                 "                        new: <Installation %s %d>\n",
    00665                                  str, tmp );
    00666                    }
    00667
    00668                 /* add new entry to table */
    00669                    if( i==Max_Installation ) {
    00670                        strcpy( EW_Installation[Max_Installation].name, str );
    00671                        EW_Installation[Max_Installation].id = (unsigned char) tmp;
    00672                        Max_Installation++;
    00673                    }
    00674                    init[3] = 1;
    00675                }
    00676
    00677             /* Otherwise, it's unknown
    00678              *************************/
    00679                else
    00680                {
    00681                    fprintf( stderr, "GetUtil_LoadTable: <%s> Unknown command in <%s>.\n",
    00682                             com, FullTablePath );
    00683                    continue;
    00684                }
    00685
    00686            /* See if there were any errors processing the command
    00687             *****************************************************/
    00688                if( k_err() )
    00689                {
    00690                   fprintf( stderr,
    00691                           "GetUtil_LoadTable: Bad <%s> line in <%s>; exiting!\n",
    00692                            com, FullTablePath );
    00693                   exit( -1 );
    00694                }
    00695            }
    00696            nfiles = k_close();
    00697       }
    00698    } /* end-for over all table files */
    00699
    00700 /* After all files are closed, check init flags for missed commands
    00701  ******************************************************************/
    00702    nmiss = 0;
    00703    for ( i=0; i<ncommand; i++ )  if( !init[i] ) nmiss++;
    00704    if ( nmiss ) {
    00705        fprintf( stderr, "GetUtil_LoadTable: ERROR, no "    );
    00706        if ( !init[0] )  fprintf( stderr, "<Ring> "         );
    00707        if ( !init[1] )  fprintf( stderr, "<Module> "       );
    00708        if ( !init[2] )  fprintf( stderr, "<Message> "      );
    00709        if ( !init[3] )  fprintf( stderr, "<Installation> " );
    00710        fprintf( stderr, "line(s) in file(s) " );
    00711        for( it=0; it<nTableFile; it++ ) fprintf( stderr, "<%s> ", TableFile[it] );
    00712        fprintf( stderr, "exiting!\n" );
    00713        exit( -1 );
    00714    }
    00715
    00716    return;
    00717 }