Exemple #1
0
int
main(argc, argv)
{
    MEadvise( ME_INGRES_ALLOC );
    SIprintf( "iimerge is for UNIX only!\n");
    PCexit( FAIL );
}
Exemple #2
0
i4
main( i4  argc, char **argv )
{
    i4  arg = 1;

    MEadvise(ME_INGRES_ALLOC);
    SIeqinit();
    PMinit();

    if ( argc > 1  &&  argv[1][0] == '-' )
    {
        arg++;

        switch( argv[1][1] )
        {
        case 'v' :
            verbose = TRUE;
            break;

        default  :
            usage( argc >= 1 ? argv[0] : NULL );
            PCexit(FAIL);
        }
    }

    if ( arg >= argc )
    {
        usage( argc >= 1 ? argv[0] : NULL );
        PCexit(FAIL);
    }
    else
    {
        analyze( argv[ arg ] );
        PCexit(OK);
    }

    return(OK);
}
Exemple #3
0
int
main(int c, char **v)
{
    i4		msg_id;
    i4		cnt = 0;
    char	mbuf[ER_MAX_LEN];
    i4		ret_len = 0;
    char	msgbuf[101];
    CL_ERR_DESC	clerror;
    CL_ERR_DESC	err_code;
    STATUS	stat;
    i4		flag = 0;
    bool	testsysdep = FALSE;
    bool	logoper = FALSE;

    MEadvise(ME_INGRES_ALLOC);

    for (++v, --c; c > 0; ++v, --c)
    {
	char *w = *v;
	if (w[0] == '-')
	{
	    switch (w[1])
	    {
	        case 't':
		    flag |= ER_TIMESTAMP;
		    break;
	        case 'n':
		    flag |= ER_NOPARAM;
		    break;
	        case 's':
		    testsysdep = TRUE;
		    break;
		case 'o':
		    logoper = TRUE;
		    break;
	        default:
		    SIfprintf(stderr, "only valid options are -t, -s, -n and -o\n");
		    PCexit(FAIL);
	    }
	}
	else
	    SIfprintf(stderr, "ignoring invalid argument \"%s\"\n", v);
    }

    if (testsysdep)    /* test system dependent error reporting */
    {
        extern int    errno;

	errno = 13;    /* EACCES */
	SETCLERR(&clerror, 0x10911, /* ER_INTERR_TESTMSG */  ER_open);
	STcopy("II_MSGDIR/erclf.msg", clerror.moreinfo[0].data.string);
	clerror.moreinfo[0].size = STlength(clerror.moreinfo[0].data.string);
    }

    while ((cnt++) < MAX_NUM_OF_LOOKUPS)
    {
	msg_id = -1;
	SIfprintf(stderr, "msg id, in hex, no 0x%s: ",
	    testsysdep? " (try 10904) " : "");
	if( OK != SIgetrec(msgbuf, 100, stdin) )
           break;
#if defined(any_aix) && defined(BUILD_ARCH64)
	(VOID) STscanf(msgbuf, "%x", &msg_id);
#else
	(VOID) STscanf(msgbuf, "%p", &msg_id);
#endif

	if (msg_id == -1)
	    break;

	if ((stat = ERslookup(msg_id, testsysdep? &clerror : NULL, flag, 
	    (char *) NULL, mbuf, ER_MAX_LEN, -1, &ret_len, &err_code, 5, 
	    er_arg)) != OK)
	{
	    SIfprintf(stderr,
		"ERslookup error. msg id is 0x%x, status is 0x%x\n",
		msg_id, stat);
	}
	else
	{
	    SIfprintf(stderr, "*** ERslookup:\n%s\n", mbuf);
            SIfprintf(stderr, "*** ERget:\n%s\n", ERget(msg_id));
	}

	if (testsysdep)
	{
	    if ((stat = ERslookup(0, &clerror, flag, (char *) NULL, mbuf, 
		ER_MAX_LEN, -1, &ret_len, &err_code, 5, er_arg)) != OK)
	    {
	        SIfprintf(stderr,
		    "ERslookup error on CL_ERR_DESC. Status is 0x%x\n", stat);
	    }
	    else
	        SIfprintf(stderr, "*** ERslookup (CL error):\n%s\n",mbuf);
        }
	
	if (logoper)
	{
	    ERsend( ER_ERROR_MSG|ER_OPER_MSG, mbuf, ret_len, &err_code );
	}
    }
    PCexit(OK);
}
Exemple #4
0
main(int argc, char **argv)
{
	char 			*value = NULL; 
	char			*host, *server_type, *command_line; 
	char 			*server_location, *env, *arguments;
	u_i4 			command_line_length;
	char 			config_string[256];
	char 			iidbms[256];
	STARTUPINFO 		si;
	PROCESS_INFORMATION 	ProcessInfo;
	BOOL 			Status;
	SECURITY_ATTRIBUTES     sa;
	HANDLE			hRead, hWrite;
	HANDLE			hStdout;
	char			buffer[512];
	DWORD			bufferl = sizeof(buffer);
	DWORD			pipe_size = 0;	/* Use default buffer size */
	DWORD			datal = 0;
	bool			havequote, failed = FALSE;


	MEadvise( ME_INGRES_ALLOC );

	switch (argc)
	{

	case 1:
		server_type = ERx("dbms");
		server_location = ERx("*");
		break;

	case 2:
		server_type = argv[1];
		server_location = ERx("*");
		break;

	default:
		server_type = argv[1];
    		if (STcompare(server_type, "recovery") == 0)
			server_location = ERx("*");
		else
			server_location = argv[2];
		break;

	}
	
	get_sys_dependencies();

	/*
	**	Get the host name, formally used iipmhost.
	*/
	host = PMhost();

	/*
	**	Build the string we will search for in the config.dat file.
	*/
	STprintf( config_string,
		  ERx("%s.%s.%s.%s.image_name"),
		  SystemCfgPrefix, host, server_type, server_location );

	/*
	**	Get set up for the PMget call.
	*/
	PMinit();
	if( PMload( NULL, (PM_ERR_FUNC *)NULL ) != OK )
		PCexit( FAIL );

	/*
	**	Go search config.dat for a match on the string we just built.
	*/
	PMget( config_string, &value );

	if ( value == NULL )
	{
		NMgtAt( SystemLocationVariable, &env );
		if (STcompare(server_type, "recovery") == 0)
		{
		    STprintf(iidbms, ERx("%s\\%s\\bin\\%sdbms"),
			     env, SystemLocationSubdirectory, SystemCfgPrefix);
		}
		else
		{
		    STprintf(iidbms, ERx("%s\\%s\\bin\\%s%s"),
			     env, SystemLocationSubdirectory, SystemCfgPrefix,
			     server_type);
		}
	}
	else if ( *value == '/' || 
		  *value == '\\' ||
		  (*(value+1) == ':' && *(value+2) == '\\') )
	{
		/* Must be a qualified path name */
		STcopy( value, iidbms );
	}
	else 
	{
		NMgtAt( SystemLocationVariable, &env );
		STprintf( iidbms, ERx("%s\\%s\\bin\\%s"),
			  env, SystemLocationSubdirectory, value );
	}
	
	/*
 	** 	Initialize the startinfo structure.	
	*/
	ZeroMemory(&si, sizeof(si));
	si.cb = sizeof(si);

	/*
	**	Get the original command line.
	*/
	arguments = GetCommandLine();
        havequote = FALSE;
        while (*arguments != '\0' && *arguments != '\n')
        {
            if ( *arguments == '"' )
                havequote = (havequote) ? FALSE : TRUE;
            if ( CMwhite(arguments) && havequote == FALSE )
                break;
            arguments++;
        }
	/*
	** 	Put together a command line to create a process with.
	**      - 4 blank separators, quotes, null termination 
	*/
	command_line_length = STlength(arguments) + STlength(iidbms) + 
				STlength(iirun) + 6 + 1; 
	if((command_line = (char *)
		MEreqmem(0, command_line_length, TRUE, NULL)) == NULL)
	{
		error(ERx("Request for memory failed"),NULL);
	}

	STprintf( command_line, "%s \"%s\" %s", iirun, iidbms, arguments );

	/*
	**	Save standard out's handle, to be restored later.
	*/
	hStdout = GetStdHandle(STD_OUTPUT_HANDLE);

 	/*
	**      Initialize the security attributes structure that will
	**      be used to make the pipe handles inheritable.
	*/
	sa.nLength = sizeof(sa);
	sa.lpSecurityDescriptor = NULL;
	sa.bInheritHandle = TRUE;       /* Make object inheritable */

	/*
	**	Define a anonymous pipe to catch the server's startup message.
	*/
	if((Status = CreatePipe(&hRead,&hWrite,&sa,pipe_size)) != TRUE)
	{
		error(ERx("CreatePipe failed"),ERx("error code = "));
	}

	SetStdHandle(STD_OUTPUT_HANDLE,hWrite);

 	/*
	**      Initialize the security attributes structure that will
	**      be used to make the pipe handles inheritable.
	*/
	sa.nLength = sizeof(sa);
	sa.lpSecurityDescriptor = NULL;
	sa.bInheritHandle = TRUE;       /* Make object inheritable */

	/*
	**	Initialize the startup information structure.
	*/
	ZeroMemory(&si, sizeof(si));
	si.cb = sizeof(si);
	/* 
	**	Start it up.
	*/
	/*
	**	Start iirun which will start the server.
	*/
	if ((Status = CreateProcess(NULL,command_line,&sa,NULL,TRUE,
		HIGH_PRIORITY_CLASS, NULL,
	     NULL,&si,&ProcessInfo)) != TRUE)
	{
		DWORD dwError = GetLastError();
		switch(dwError)
		{
		     case ERROR_ACCESS_DENIED:
			error(ERROR_REQ_PRIVILEGE, ERx(""));
			break;
		     case ERROR_ELEVATION_REQUIRED:
			error(ERROR_DENIED_PRIVILEGE, ERROR_REQ_ELEVATION);
			break;
		     default:				
			error(ERx("CreateProcess failed"),ERx("error code = "));
			break;
		}
	}

	SetStdHandle(STD_OUTPUT_HANDLE,hStdout);

	for (;;)
	{
	    char	*tmpptr;

	    if((Status = ReadFile(hRead,&buffer,bufferl,&datal,NULL)) != TRUE)
	    {
		error(ERx("ReadFile failed"),ERx("error code = "));
	    }

	    buffer[datal] = '\0';	 		
	    if ((tmpptr = STstrindex(buffer, "PASS\n", 0, FALSE)))
	    {
		*tmpptr = '\0';
		if (STlength(buffer))
		    SIfprintf(stdout, "%s", buffer);

		break;
	    }

	    SIfprintf(stdout, "%s", buffer);

	    if ((tmpptr = STstrindex(buffer, bad_msg, 0, FALSE)))
	    {
		*tmpptr = '\0';
		if (STlength(buffer))
		    SIfprintf(stdout, "%s", buffer);

		failed = TRUE;
		break;
	    }
	}

	/*
	**	Close handles since we don't need them anymore.
	*/
	CloseHandle(ProcessInfo.hThread);
	CloseHandle(ProcessInfo.hProcess);
	CloseHandle(hRead);
	CloseHandle(hWrite);

	if (failed &&
	    STscompare(server_type, STlength(server_type), "gcb", 3) != 0 &&
	    STscompare(server_type, STlength(server_type), "gcc", 3) != 0 &&
	    STscompare(server_type, STlength(server_type), "jdbc", 4) != 0)
	{
		SIfprintf( stderr,"\n%s: server would not start.\n",
			   iirundbms );

		SIfprintf(stderr,
		" %s must be set in your environment.\n", 
		    SystemLocationVariable );

		SIfprintf(stderr,
		" Has the csinstall program been run?\n");

		SIfprintf(stderr,
		" %s_DATABASE, %s_CHECKPOINT, %s_JOURNAL and %s_DUMP\n",
		    SystemVarPrefix,
		    SystemVarPrefix,
		    SystemVarPrefix,
		    SystemVarPrefix );

		SIfprintf(stderr,
		" must also be set. See %s_CONFIG\\symbol.tbl.\n",
		    SystemVarPrefix );

		SIfprintf(stderr,
		" Check the file '%%%s%%\\%s\\files\\errlog.log'\n",
		    SystemLocationVariable, SystemLocationSubdirectory );

		SIfprintf(stderr,
		" for more details concerning internal errors.\n");

		SIfprintf(stderr,
		" See your Installation and Operation Guide for more\n");

		SIfprintf(stderr,
		" information concerning server startup.\n");

		PCexit(FAIL);
	}
	else
	{
		PCexit(OK);
	}
}
Exemple #5
0
int
main( int argc, char **argv )
{
    EX_CONTEXT		context;
    char		name[ GCC_L_PORT + 1 ];
    u_i2		apivers;
    PTR 		hndl;

#ifdef LNX
    PCsetpgrp();
#endif

    MEadvise( ME_INGRES_ALLOC );

    if ( EXdeclare( GCX_exit_handler, &context ) != OK )
    {
	gcu_erlog( 0, 1, E_GC480F_EXCEPTION, NULL, 0, NULL );
	PCexit( OK );
	return( 0 );
    }

    GChostname( GCD_global.host, sizeof( GCD_global.host ) );
    gcu_erinit( GCD_global.host, GCD_LOG_ID, "" );

    if ( initialize( argc, argv ) != OK )  gcd_exit();
    gcd_init_mib();
    if ( gcd_gca_init( ) != OK )  gcd_exit();
    gcu_erinit( GCD_global.host, GCD_LOG_ID, GCD_global.gcd_lcl_id );

    if ( gcd_adm_init() != OK ) gcd_exit();
    apivers = gcd_msg_version( MSG_DFLT_PROTO ); 
    if ( gcd_get_env( apivers, &hndl ) != OK ) gcd_exit();
    if ( gcd_pool_init() != OK )  gcd_exit();
    if ( gcd_gcc_init() != OK )  gcd_exit();

    /*
    ** Log Server startup.
    */
    {
	char		server_flavor[256], server_type[32];
	char		*tmpbuf = PMgetDefault(3);
	ER_ARGUMENT	erlist[2];

	SIstd_write(SI_STD_OUT, "PASS\n");

	if ( ! STbcompare( tmpbuf, 0, "*", 0, TRUE ) )
	    STcopy( "(DEFAULT)", server_flavor );
	else
	    STcopy( tmpbuf, server_flavor );

	STcopy(PMgetDefault(2), server_type);
	CVupper(server_type);

	erlist[0].er_value = server_flavor;
	erlist[0].er_size = STlength(server_flavor);
	erlist[1].er_value = server_type;
	erlist[1].er_size = STlength(server_type);

	gcu_erlog( 0, GCD_global.language, E_GC4802_LOAD_CONFIG, NULL, 2, 
		   (PTR)&erlist );
	gcu_erlog( 0, GCD_global.language, E_GC4800_STARTUP, NULL, 0, NULL );
    }

    GCexec();

    gcd_gcc_term();
    gcd_pool_term();
    gcd_rel_env(0);
    gcd_adm_term();
    gcd_gca_term();
    gcu_erlog( 0, GCD_global.language, E_GC4801_SHUTDOWN, NULL, 0, NULL );

    EXdelete();
    PCexit( OK );
    return( 0 );
}
Exemple #6
0
/*
PROGRAM =	iijobdef
**
NEEDLIBS =	UTILLIB MALLOCLIB COMPATLIB GLLIB
**
UNDEFS =	II_copyright
**
DEST =		utility
*/

# endif /* VMS */
main( i4  argc, char **argv)
{
# ifdef VMS
	char *host;
	i4 i;
	PM_SCAN_REC state;
	STATUS status;
	char *lnm_table_name;
	struct dsc$descriptor lnm_table;
	char *regexp;
	char *name, *value;
	PM_CONTEXT *config;
	struct dsc$descriptor lnm_name;
	ILE3 item_list[ 2 ];
	long access_mode = PSL$C_SUPER;

	bool failed_once = FALSE;		/* lib$set_logical works? */
	const match_1 = LIB$_NOCLI;		/* Process has no CLI. */
	const match_2 = LIB$_UNECLIERR;		/* Unexpected CLI error
						 * (non-standard CLI?).
						 */
	const match_3 = SS$_NORMAL;		/* Normal return. */
	const match_4 = SS$_SUPERSEDE;		/* Replaced old value. */
	const match_5 = SS$_NOLOGNAM;		/* Not currently defined. */

	bool delete_logs = FALSE;		/* What are we doing? */
	char *act_str;				/* String for action. */
	char *err_str;				/* String for error exit. */
	char *log_str;				/* String to log action. */
        char tmp_buf[BIG_ENOUGH];

	MEadvise( ME_INGRES_ALLOC );

	if( argc != 1 )
		delete_logs = TRUE;

	(void) PMmInit( &config );

	if( PMmLoad( config, NULL, PMerror ) != OK )
		PCexit( FAIL );

	host = PMmHost( config );

	PMmSetDefault( config, HOST_PM_IDX, host );

	/* get logical table name */ 

	STprintf (tmp_buf , ERx( "%s.$.lnm.table.id" ), SystemCfgPrefix);

	if( PMmGet( config, tmp_buf , &lnm_table_name )
		!= OK )
	{
		F_ERROR( "%s not found.", PMmExpandRequest( config,
			tmp_buf ) );
	}

	/* set logical name table */
	lnm_table_name = ERx( "LNM$JOB" );

	/* compose string descriptor for logical table name */
	lnm_table.dsc$w_length = STlength( lnm_table_name );
	lnm_table.dsc$a_pointer = lnm_table_name; 
	lnm_table.dsc$b_class = DSC$K_CLASS_S;
	lnm_table.dsc$b_dtype = DSC$K_DTYPE_T;

	if ( delete_logs ) {
	    act_str =  ERx( "\nDeleting %s logicals...\n\n(%s)\n\n" );
	    err_str = ERx( "Unable to deassign %s.\n\n" );
	    log_str = ERx( "" );
	} else {
	    act_str = ERx( "\nDeleting %s logicals...\n\n(%s)\n\n" );
	    err_str = ERx( "Unable to set %s to \"%s\".\n\n" );
	    log_str = ERx( "\"%s\" = \"%s\"\n" );
	}

	F_PRINT2( act_str, SystemDBMSName, lnm_table_name );

	/* scan and set node-specific logicals */

	regexp = PMmExpToRegExp( config, ERx( "ii.$.lnm.%") );
	for(
		status = PMmScan( config, regexp, &state, NULL, &name,
		&value ); status == OK; status = PMmScan( config,
		NULL, &state, NULL, &name, &value ) )
	{
		name = PMmGetElem( config, 3, name );

		lnm_name.dsc$w_length = STlength( name );
		lnm_name.dsc$a_pointer = name;
		lnm_name.dsc$b_class = DSC$K_CLASS_S;
		lnm_name.dsc$b_dtype = DSC$K_DTYPE_T;

		item_list[ 0 ].ile3$w_length = STlength( value );
		item_list[ 0 ].ile3$w_code = LNM$_STRING; 
		item_list[ 0 ].ile3$ps_bufaddr = value; 
		item_list[ 0 ].ile3$ps_retlen_addr = NULL; 
		item_list[ 1 ].ile3$w_length = 0;
		item_list[ 1 ].ile3$w_code = 0;

		if ( !failed_once ) {
		    if ( delete_logs )
			status = lib$delete_logical( &lnm_name, &lnm_table );
		    else
			status = lib$set_logical( &lnm_name, NULL, &lnm_table,
						 NULL, item_list );
		    if ( lib$match_cond( &status, &match_1, &match_2 ))
			failed_once = TRUE;
		}
		if ( failed_once ) {
		    if ( delete_logs )
			status = sys$dellnm( &lnm_table, &lnm_name,
					    &access_mode );
		    else
			status = sys$crelnm( NULL, &lnm_table, &lnm_name,
					    &access_mode, item_list );
		}

		if ( !lib$match_cond( &status, &match_3, &match_4, &match_5 ))
		{
			SIfprintf( stderr, err_str, name, value );
			PCexit( FAIL );
		}

		SIprintf( log_str, name, value );
	}

	PCexit( OK );
# else /* VMS */
	SIprintf( "\nThis doesn't do much.\n\n" );
# endif /* VMS */
}
Exemple #7
0
main(int argc, char **argv)
{
    STATUS status = OK;
    VMS_STATUS vStatus;
    char srcbuf[NAME_FILE_SIZE];
    char dstbuf[NAME_FILE_SIZE];
    char delFile[NAME_FILE_SIZE];
    struct dsc$descriptor_s filename_d = 
        { sizeof (delFile) - 1,
            DSC$K_DTYPE_T,
            DSC$K_CLASS_S,
            delFile
        };
    FILE *srcFile = NULL;
    FILE *dstFile = NULL;
    FILE *nameFile = NULL;
    LOCATION loc;
    bool clusterArg = FALSE;
    bool unclusterArg = FALSE;
    bool writeOutput = FALSE;
    bool validSyntax;
    bool clustered = FALSE;
    bool v1DecryptErr = FALSE;
    bool rewrite = FALSE;
    bool isLogin = FALSE;
    i4   total_recs = 0;
    char local_host[MAX_LOC+CM_MAXATTRNAME];
    char config_host[MAX_LOC+CM_MAXATTRNAME];
    i2 i,j;
    i4 active_rec;
    i4 offset;
    char *onOff = NULL;
    bool srcOpened=FALSE;
    bool dstOpened=FALSE;
    bool printable = TRUE;
    GCN_QUEUE *gcn_q;
    GCN_QUEUE *merge_q;
    i4 rec_len = 0;
    QUEUE *q;
    u_i1  local_mask[ 8 ];        /* Must be 8 bytes */
    char name[MAX_LOC+CM_MAXATTRNAME];
    i4 count;
    char *p = NULL;
    i4 dcryptFail = 0;
    i2 pc;
    char *pv[ 3 ];
    GCN_DB_REC0 tmp_rec;
    SYSTIME timestamp;

    MEadvise(ME_INGRES_ALLOC);
    SIeqinit();
    GChostname( local_host, sizeof(local_host));
    STcopy (PMhost(), config_host);
    if (argc == 1)
       validSyntax = TRUE;
    /*
    ** Parse input arguments.
    */    
    for (i = 1; i < argc; i++)
    {
        validSyntax = FALSE;
        for (j = 0; j < argLen; j++)
        {
            if (!STncasecmp(arg[j],argv[i], STlength(argv[i])))
            {
                switch(j)
                {
                    case HELP1:
                    case HELP2:
                    case HELP3:
                    case HELP4:
                       usage();
                       break;

                    case VERBOSE:
                       validSyntax = TRUE;
                       verboseArg = TRUE;
                       break;

                    case CLUSTER:
                       validSyntax = TRUE;
                       clusterArg = TRUE;
                       writeOutput = TRUE;
                       break;

                    case UNCLUSTER:
                       validSyntax = TRUE;
                       unclusterArg = TRUE;
                       writeOutput = TRUE;
                       break;
                }
            } /* if (!STncasecmp(arg[j],argv[i], STlength(argv[i]))) */
            if (validSyntax)
                break;
        } /* for (j = 0; j < argLen; j++) */
        if (!validSyntax)
            break;
    } /* for (i = 1; i < argc; i++) */

    if (!validSyntax)
    {
        usage();
        PCexit(1);
    }

    if (clusterArg && unclusterArg)
    {
        SIprintf("Cannot specify both -c and -u\n\n");
            usage();
        PCexit(1);
    }

    if (verboseArg)
        SIprintf("Local host is %s\n", local_host);

    /*
    ** Generate key seeds for encoding and decoding.
    */
    STpolycat( 2, GCN_LOGIN_PREFIX, local_host, name );
    gcn_init_mask( name, sizeof( local_mask ), local_mask );

    QUinit(&gcn_qhead);
    QUinit(&merge_qhead);
    PMinit();

    /*
    ** See if this is a clustered installation.  If it is, 
    ** the node, login, and attribute files have no file extension.
    */
    if ( PMload( (LOCATION *)NULL, (PM_ERR_FUNC *)NULL ) != OK )
    {
        SIprintf("Error reading config.dat, exiting\n");
        goto cvt_exit;      
    }

    PMsetDefault( 0, SystemCfgPrefix );
    PMsetDefault( 1, config_host );
    PMsetDefault( 2, ERx("gcn") );

    status = PMget( ERx("!.cluster_mode"), &onOff);
    if (onOff && *onOff)
        ;
    else
        onOff = "OFF";

    if (verboseArg)
        SIprintf("Cluster mode is %s\n", onOff);

    if (!clusterArg && !unclusterArg)
        clustered = !STncasecmp(onOff, "ON", STlength(onOff));

    /*
    ** Rewrite the named GCN files.  For clustered installations, the
    ** node, login and attribute files have no hostname extension.
    */
    for ( i = 0; i < NBR_NAMED_FILES; i++ )
    {  
        /*
        ** Ticket files are simply deleted.
        */
        if (i == IILTICKET || i == IIRTICKET)
        {
            STprintf(delFile, "II_SYSTEM:[INGRES.FILES.NAME]II%s*;*", 
                named_file[i].file);
            if (verboseArg)
                SIprintf("Deleting %s\n", delFile);
            filename_d.dsc$w_length = STlength(delFile);
            vStatus = lib$delete_file(&filename_d,0,0,0,0,0,0,0,0,0);
            if (!vStatus & STS$M_SUCCESS)
                SIprintf("delete of %s failed, status is 0x%d\n", delFile,
                    vStatus);
            continue;
        }    
 
        rewrite = FALSE;
        if (!clusterArg && !unclusterArg)
            writeOutput = FALSE;
        if ( ( status = NMloc( FILES, PATH & FILENAME, 
            (char *)NULL, &loc ) ) != OK )
        {
            SIprintf("iicvtgcn: Could not find II_SYSTEM:[ingres.files]\n");
            goto cvt_exit;
        }
     
        LOfaddpath( &loc, "name", &loc );

        if (clustered || unclusterArg)
        {
            if (named_file[i].add_cluster_node)
                STprintf( srcbuf, "II%s_%s", named_file[i].file,config_host);
            else
                STprintf(srcbuf, "II%s", named_file[i].file);
        }
        else 
            STprintf( srcbuf, "II%s_%s", named_file[i].file,config_host);

        if (verboseArg)
            SIprintf("Opening %s for input\n", srcbuf);

        LOfstfile( srcbuf, &loc );

        /*
        ** Ignore non-existent files.
        */
        if ( LOexist( &loc ) != OK )
        {
            if (verboseArg)
                SIprintf("%s does not exist\n", srcbuf);
            continue;
        }
        /*
        ** Open the existing file as "regular" RACC.
        */
        status = SIfopen( &loc, "r", (i4)SI_RACC, sizeof( GCN_DB_REC0 ), 
            &srcFile );
        /*
        ** If the file exists but can't be opened, it's already optimized.
        */
        if (status == E_CL1904_SI_CANT_OPEN && ( LOexist( &loc ) == OK ) )
        {
            /*
            ** Open the existing file as "optimized" RACC.
            */
            status = SIfopen( &loc, "r", (i4)GCN_RACC_FILE, 
                sizeof( GCN_DB_REC0 ), &srcFile );
            if (status != OK)
            {
                SIprintf( "iicvtgcn: Error opening %s, status is %x\n",
                    srcbuf, status );
                continue;
            }
            if (verboseArg)
                SIprintf("%s is already optimized\n", srcbuf);
        }
        else if (status != OK)
        {
            SIprintf( "iicvtgcn: Error opening %s, status is %x\n",
                srcbuf, status );
            continue;
        }

        /*
        ** A successful open as SI_RACC means the file is not optimized.
        ** This file needs a rewrite.
        */
        else
        {
            if (verboseArg)
                SIprintf("Rewriting %s as optimized\n", srcbuf);
            writeOutput = TRUE;    
        }

        srcOpened = TRUE;

        while ( status == OK )
        {
            /*
            ** Read the source data and store in a queue for analysis.
            */
            status = SIread( srcFile, sizeof( GCN_DB_REC0 ),
                &count, (PTR)&tmp_rec );
            if ( status == ENDFILE )
                break;

            if ( status != OK )
            {
                SIprintf("iicvtgcn: Error reading %s, status is %x\n",
                    srcbuf, status);
                goto cvt_exit;
            }
            else if (tmp_rec.gcn_invalid && tmp_rec.gcn_tup_id != -1)
                continue;
            else
            {
                gcn_q = (GCN_QUEUE *)MEreqmem(0, sizeof(GCN_QUEUE),0,NULL);
                if (!gcn_q)
                {
                    SIprintf("iicvtgcn: Cannot allocate memory, exiting\n");
                    goto cvt_exit;
                }
                MEcopy((PTR)&tmp_rec, sizeof(GCN_DB_REC0), (PTR)&gcn_q->buf);
                QUinsert(&gcn_q->q, &gcn_qhead);
                /*
                ** EOF record found.
                */
                if (gcn_q->buf.gcn_tup_id == -1)
                {
                    gcn_q->buf.gcn_l_uid = 0;
                    gcn_q->buf.gcn_uid[0] = '\0';
                    gcn_q->buf.gcn_l_obj = 0;
                    gcn_q->buf.gcn_obj[0] = '\0';
                    gcn_q->buf.gcn_l_val = 0;
                    gcn_q->buf.gcn_val[0] = '\0';
                    gcn_q->buf.gcn_invalid = TRUE;
                    break;
                }
            }
        } /* while ( status == OK ) */

        /*
        ** Decrypt passwords for IILOGIN files.  If any V1 records are found, 
        ** the IILOGIN file will need to be rewritten.
        */
        isLogin = FALSE;
        for (q = gcn_qhead.q_prev; q != &gcn_qhead; q = q->q_prev)
        {
            gcn_q = (GCN_QUEUE *)q;

            /*
            ** EOF record found.
            */
            if (gcn_q->buf.gcn_tup_id == -1)
            {
                gcn_q->buf.gcn_invalid = TRUE;
                break;
            }

            if (i == IILOGIN)
            {
                isLogin = TRUE;
                MEcopy((PTR)&gcn_q->buf, sizeof(GCN_DB_REC0), (PTR)&tmp_rec);
                if (verboseArg)
                     SIprintf("\tEncoding vnode %s\n", gcn_q->buf.gcn_obj);

                if (unclusterArg)
                    status = gcn_recrypt( FALSE, local_mask, 
                        gcn_q->buf.gcn_val, &v1DecryptErr, &writeOutput);
                else if (clusterArg)
                    status = gcn_recrypt( TRUE, local_mask, 
                    gcn_q->buf.gcn_val, &v1DecryptErr, &writeOutput);
                else
                    status = gcn_recrypt( clustered, local_mask, 
                    gcn_q->buf.gcn_val, &v1DecryptErr, &writeOutput);

                if (status != OK)
                {
                    if (verboseArg)
                        SIprintf("Cannot decrypt password from " \
                            "vnode %s status %x\n", gcn_q->buf.gcn_obj,
                            status);
                    dcryptFail++;
                    MEcopy((PTR)&tmp_rec, sizeof(GCN_DB_REC0), 
                        (PTR)&gcn_q->buf);
                    continue;                
                }
                if (v1DecryptErr)
                {
                    if (verboseArg)
                        SIprintf("Cannot decrypt password from " \
                            "vnode %s\n", gcn_q->buf.gcn_obj);
                    dcryptFail++;
                    MEcopy((PTR)&tmp_rec, sizeof(GCN_DB_REC0), 
                        (PTR)&gcn_q->buf);
                    continue;
                }
            }  /* if (LOGIN) */

        } /* for (q = gcn_qhead.q_prev; q != &gcn_qhead; q = q->q_prev) */
        
        if (dcryptFail && verboseArg && isLogin)
        {
            if (clustered || unclusterArg )
                SIprintf("\n%d vnode(s) could not be decrypted.\n" \
                    "Probably some login entries were created on " \
                    "another node.\nTry executing iicvtgcn on another " \
                    "node to merge the other node's entries.\n\n", dcryptFail);
            else
                SIprintf("\n%d vnode(s) could not be decrypted.\n" \
                    "Probably the login file was created on " \
                    "another host.\nTry executing iicvtgcn on " \
                    "a different host.\n\n", dcryptFail);
        }

        if (!writeOutput)
        {
            if (srcOpened)
                SIclose(srcFile);
            srcOpened = FALSE;
            cleanup_queues();
            continue;
        }
   
        /*
        ** Open the destination file with special GCN_RACC_FILE flag, for 
        ** optimized writes.
        */
        if (clustered || clusterArg) 
        {
            if (named_file[i].add_cluster_node)
                STprintf( dstbuf, "II%s_%s", named_file[i].file, local_host);
            else
                STprintf(dstbuf, "II%s", named_file[i].file);
        }
        else
            STprintf( dstbuf, "II%s_%s", named_file[i].file, local_host);

        if (clusterArg && !named_file[i].add_cluster_node)
            rewrite = TRUE;

        LOfstfile( dstbuf, &loc );

        if (rewrite)
        {
            status = SIfopen( &loc, "rw", (i4)GCN_RACC_FILE, 
                sizeof( GCN_DB_REC0 ), &dstFile );
            if ( status != OK )
            {
                status = SIfopen( &loc, "w", (i4)GCN_RACC_FILE, 
                    sizeof( GCN_DB_REC0 ), &dstFile );
                if (status == OK)
                {
                    SIclose( dstFile);
                    status = SIfopen( &loc, "rw", (i4)GCN_RACC_FILE, 
                        sizeof( GCN_DB_REC0 ), &dstFile );
                }
            }
        }
        else
            status = SIfopen( &loc, "w", (i4)GCN_RACC_FILE, 
                sizeof( GCN_DB_REC0 ), &dstFile );

        if ( status != OK )
        {
            SIprintf( "iicvtgcn: Error opening %s, status is %x\n",dstbuf,
                status );
            goto cvt_exit;
        }

        dstOpened = TRUE;

        if (verboseArg)
            SIprintf("%s %s\n", rewrite ? "Rewriting " : "Writing ", dstbuf);

        /*
        ** If this is a merge operation (-c), login, attribute or
        ** node files may change the location of EOF, since the
        ** file to be merged may have different records than
        ** the destination file. 
        ** Before merging, the output file is read and fed into a queue.
        ** Then each merge record is compared to each output record.
        ** If the entire records match, nothing is done. 
        ** If a global login record matches only the vnode name
        ** global or private records will be added if not present;
        ** otherwise, nothing is done.
        ** Node or attribute records may be added if only one field
        ** fails to match.
        */
        status = SIfseek(dstFile, (i4)0, SI_P_START);
        if (rewrite)
        {
            while ( status == OK )
            {
                /*
                ** Read the source data and store in a queue for analysis.
                */
                status = SIread( dstFile, sizeof( GCN_DB_REC0 ),
                    &count, (PTR)&tmp_rec );
                if ( status == ENDFILE )
                    break;

                if ( status != OK )
                {
                    SIprintf("iicvtgcn: Error reading %s, status is %x\n",
                        dstbuf, status);
                    goto cvt_exit;
                }
                else if (tmp_rec.gcn_invalid && tmp_rec.gcn_tup_id != -1)
                    continue;
                else
                {
                    merge_q = (GCN_QUEUE *)MEreqmem(0, sizeof(GCN_QUEUE),0,NULL);
                    if (!merge_q)
                    {
                        SIprintf("iicvtgcn: Cannot allocate memory, exiting\n");
                        goto cvt_exit;
                    }
                    MEcopy((PTR)&tmp_rec, sizeof(GCN_DB_REC0), 
                        (PTR)&merge_q->buf);
                    QUinsert(&merge_q->q, &merge_qhead);
    
                    /*
                    ** EOF record found.
                    */
                    if (merge_q->buf.gcn_tup_id == -1)
                        break;
                }
                if ( status == ENDFILE )
                    break;

            } /* while ( status == OK ) */

            /*
            ** Go through the input queue.  Compare each record with
            ** the output (merge) queue.  If the record is invalid
            ** or doesn't match, it's ignored.
            */
            dcryptFail = 0;
            total_recs = 0;
            for (q = gcn_qhead.q_prev; q != &gcn_qhead; q = q->q_prev)
            {
                SYSTIME     timestamp;

                gcn_q = (GCN_QUEUE *)q;
                if (gcn_q->buf.gcn_tup_id == -1)
                    break;
                if ( !gcn_merge_rec( gcn_q, isLogin ) )
                    continue;
                if (isLogin)
                {
                    /*
                    ** Login passwords get encrypted as V0 in a cluster
                    ** environment.
                    */
                    MEcopy((PTR)&gcn_q->buf, sizeof(GCN_DB_REC0), 
                        (PTR)&tmp_rec);
                    status = gcn_recrypt( TRUE, local_mask, 
                        gcn_q->buf.gcn_val, &v1DecryptErr, &writeOutput);

                    if (status != OK)
                    {
                        if (verboseArg)
                            SIprintf("Cannot decrypt password from " \
                                "vnode %s status %x\n", gcn_q->buf.gcn_obj,
                                status);
                        dcryptFail++;
                        MEcopy((PTR)&tmp_rec, sizeof(GCN_DB_REC0), 
                            (PTR)&gcn_q->buf);
                        continue;                
                    }
                    if (v1DecryptErr)
                    {
                        if (verboseArg)
                            SIprintf("Cannot decrypt password from " \
                                "vnode %s\n", gcn_q->buf.gcn_obj);
                        dcryptFail++;
                        MEcopy((PTR)&tmp_rec, sizeof(GCN_DB_REC0), 
                            (PTR)&gcn_q->buf);
                        continue;
                    }
                }
                merge_q = (GCN_QUEUE *)MEreqmem(0, sizeof(GCN_QUEUE),0,NULL);
                if (!merge_q)
                {
                    SIprintf("iicvtgcn: Cannot allocate memory, exiting\n");
                    goto cvt_exit;
                }

                MEcopy((PTR)&gcn_q->buf, sizeof(GCN_DB_REC0), 
                    (PTR)&merge_q->buf);
                total_recs++;
              
                QUinsert(&merge_q->q, &merge_qhead);
            }

            if (dcryptFail && verboseArg && isLogin)
            {
                if (clustered || unclusterArg )
                    SIprintf("\n%d vnode(s) could not be decrypted.\n" \
                        "Probably some login entries were created on " \
                        "another node.\nTry executing iicvtgcn on another " \
                        "node to merge the other node's entries.\n\n", 
                        dcryptFail);
                    else
                        SIprintf("\n%d vnode(s) could not be decrypted.\n" \
                            "Probably the login file was created on " \
                            "another host.\nTry executing iicvtgcn on " \
                            "a different host.\n\n", dcryptFail);
            }
            if (verboseArg)
                SIprintf("Total records merged: %d\n", total_recs);

            /*
            ** If no records to merge, clean up and continue.
            */
            if (!total_recs)
            {
                cleanup_queues();
                continue;
            }

            status = SIfseek(dstFile, (i4)0, SI_P_START);
            active_rec = 0;
            for (q = merge_qhead.q_prev; q != &merge_qhead; q = q->q_prev)
            {
                merge_q = (GCN_QUEUE *)q;
                if (verboseArg)
                   SIprintf("Rewriting %s record vnode %s val %s\n", 
                       !STcasecmp("*", merge_q->buf.gcn_uid) ? "global" : 
                       "private", merge_q->buf.gcn_obj, merge_q->buf.gcn_val);
                if (merge_q->buf.gcn_tup_id == -1)
                    continue;
                status = SIwrite(sizeof( GCN_DB_REC0 ), 
                    (char *)&merge_q->buf, &count, dstFile );
                if ( status != OK)
                {
                    SIprintf( "iicvtgcn: Failed to write file %s, " \
                        "status is %x\n", srcbuf, status );
                    goto cvt_exit;
                }
                active_rec++;
            }
            /*
            ** Write new EOF record.
            */
            tmp_rec.gcn_tup_id = -1;
            tmp_rec.gcn_l_uid = 0;
            tmp_rec.gcn_uid[0] = '\0';
            tmp_rec.gcn_l_obj = 0;
            tmp_rec.gcn_obj[0] = '\0';
            tmp_rec.gcn_l_val = 0;
            tmp_rec.gcn_val[0] = '\0';
            tmp_rec.gcn_invalid = TRUE;
            offset = active_rec * sizeof(GCN_DB_REC0);
            status = SIfseek(dstFile, (i4)offset, SI_P_START);
            status = SIwrite(sizeof( GCN_DB_REC0 ), (PTR)&tmp_rec, 
                &count, dstFile );
        }
        else
        {
            for (q = gcn_qhead.q_prev; q != &gcn_qhead; q = q->q_prev)
            {
                gcn_q = (GCN_QUEUE *)q;
                gcn_q->buf.gcn_l_val = STlength(gcn_q->buf.gcn_val);
                if (verboseArg)
                   SIprintf("Writing %s record vnode %s val %s\n", 
                       !STcasecmp("*", gcn_q->buf.gcn_uid) ? "global" : 
                       "private", gcn_q->buf.gcn_obj, gcn_q->buf.gcn_val);
                status = SIwrite(sizeof( GCN_DB_REC0 ), (char *)&gcn_q->buf, 
                    &count, dstFile );
                if ( status != OK)
                {
                    SIprintf( "iicvtgcn: Failed to write file %s, " \
                        "status is %x\n", srcbuf, status );
                    goto cvt_exit;
                }
            }
        }  /* if (rewrite) */


        cleanup_queues();

        SIclose( srcFile );
        srcOpened = FALSE;
        SIclose( dstFile );
        dstOpened = FALSE;

    } /* for (i = 0; i < NBR_NAMED_FILES; i++ ) */

cvt_exit:

    cleanup_queues();

    if (srcOpened)
        SIclose(srcFile);
    if (dstOpened)
        SIclose(dstFile);
    PCexit( OK );
}
Exemple #8
0
/*{
** Name: main()	- collation compiler
**
** Description:
**      Top level of collation compiler.
**
** Inputs:
**	argc			argument count
**	argv			argument vector
**
** Outputs:
**	none
**
** History:
**      03-may-89 (anton)
**          Created.
**	17-Jun-89 (anton)
**	    Moved to ADU from CL
**	21-Dec-89 (anton)
**	    Fixed usage message - removed magic number - bug 9193
**    	01-jun-92 (andys)
**          Correct spelling of 'language'. [bug 44495]
**	21-jun-93 (geri)
**	    PCexit with FAIL if error encountered; added CMset_attr call
**	    to intialize CM attribute table; chaged read-in char set
**	    to use II_CHARSET symbol. These were in the 6.4 version.
**	14-mar-2001 (stephenb)
**	    Add optional unicode indicator.
**	06-sep-2002 (hanch04)
**	    The 32 and 64 bit version need to be run so call PCspawnlp64.
**	14-Jun-2004 (schka24)
**	    Use (safe) canned charmap setting routine.
**	04-Mar-2005 (hanje04)
**	    SIR 114034
**	    Add support for reverse hybrid builds, i.e. 64bit exe needs to
** 	    call 32bit version.
**	09-Mar-2007 (gupsh01)
**	    Add support for upper/lower case operations.
**	20-Jun-2009 (kschendel) SIR 122138
**	    Hybrid add-on symbol changed, fix here.
*/
main(
int	argc,
char	*argv[])
{
    ADULTABLE	*tbl;
    ADUUCETAB	*utbl;
    STATUS   	stat;
    CL_ERR_DESC cl_err;
    bool	unicode = FALSE;
#if defined(conf_BUILD_ARCH_32_64) && defined(BUILD_ARCH32)
    char        *lp64enabled;
#endif

    _VOID_ MEadvise(ME_INGRES_ALLOC);

#if defined(conf_BUILD_ARCH_32_64) && defined(BUILD_ARCH32)

    /*
    ** Try to exec the 64-bit version
    */
    NMgtAt("II_LP64_ENABLED", &lp64enabled);
    if ( (lp64enabled && *lp64enabled) &&
       ( !(STbcompare(lp64enabled, 0, "ON", 0, TRUE)) ||
         !(STbcompare(lp64enabled, 0, "TRUE", 0, TRUE))))
    {
        PCspawnlp64(argc, argv);
    }
#endif  /* hybrid */
#if defined(conf_BUILD_ARCH_64_32) && defined(BUILD_ARCH64)
    {
	char        *lp32enabled;
	/*
	** Try to exec the 32-bit version
	*/
	NMgtAt("II_LP32_ENABLED", &lp32enabled);
	if ( (lp32enabled && *lp32enabled) &&
	( !(STbcompare(lp32enabled, 0, "ON", 0, TRUE)) ||
	!(STbcompare(lp32enabled, 0, "TRUE", 0, TRUE))))
	    PCspawnlp32(argc, argv);
    }
#endif  /* reverse hybrid */

    /* Set CM character set stuff */

    stat = CMset_charset(&cl_err);
    if (stat != OK)
    {
	SIprintf("Error while processing character set attribute file.\n");
	PCexit(FAIL);
    }

    _VOID_ SIeqinit();

    if (argc != 3 && argc != 4)
    {
        SIprintf("Usage: aducompile description-file language-file [-u]\n");
        PCexit(FAIL);
    }

    if (argc == 4)
    {
	/* must be -u flag for unicode */
	if (STbcompare(argv[3], 0, "-u", 0, TRUE))
	{
	    SIprintf("Usage: aducompile description-file language-file [-u]\n");
	    PCexit(FAIL);
	}
	unicode = TRUE;
    }

    if (unicode)
    {
	utbl = makeutable(argv[1]);
	if (!utbl)
	{
	    SIprintf("aducompile: description-file syntax error\n");
	    PCexit(FAIL);
	}

	stat = dumputbl(utbl, argv[2]);
	if (stat)
	    SIprintf("aducompile: dumptbl %s failed with %x\n", argv[2], stat);
    }
    else
    {
	tbl = maketable(argv[1]);
	if (!tbl)
	{
	    SIprintf("aducompile: description-file syntax error\n");
	    PCexit(FAIL);
	}

	stat = dumptbl(tbl, argv[2]);
	if (stat)
	    SIprintf("aducompile: dumptbl %s failed with %x\n", argv[2], stat);
    }
    PCexit(stat ? FAIL : OK);
}
Exemple #9
0
i4
main( i4  argc, char **argv )
{
    STATUS	generic_status = OK;
    CL_ERR_DESC	system_status;
    EX_CONTEXT  context;
    STATUS	status;
    GCC_ERLIST	erlist;
    STATUS	(*call_list[7])();
    i4		i, call_count;
    i4		cmd_args   = 0;
    char	usage[] = { "Usage: iigcb -from <protocol>" };
    char	usage1[] = { " -to <protocol> <hostname> < listen_address>" };

#ifdef LNX
    PCsetpgrp();
#endif

    MEfill( sizeof( system_status ), 0, (PTR)&system_status );
    MEadvise( ME_INGRES_ALLOC );
    EXdeclare( GCX_exit_handler, &context );
    SIeqinit();

    /* 
    ** Parse command line. 
    */
    for( i = 1; i < argc; i++ )
	if ( ! STcompare( argv[i], "-from" ) )
	{
	    if ( ++i >= argc )
	    {
		SIfprintf( stderr, "\n%s%s\n\n", usage, usage1 );
		SIflush( stderr );
		SIstd_write(SI_STD_OUT, "\nFAIL\n");
		EXdelete();
		PCexit( FAIL );
	    }

	    STcopy( argv[i], gcb_from_addr.n_sel );
	    CVupper( gcb_from_addr.n_sel );
	    ++cmd_args;
	}
	else  if ( ! STcompare( argv[ i ], "-to" ) )
	{
	    if ( (i + 3) >= argc )
	    {
		SIfprintf( stderr, "\n%s%s\n\n", usage, usage1 );
		SIflush( stderr );
		SIstd_write(SI_STD_OUT, "\nFAIL\n");
		EXdelete();
		PCexit( FAIL );
	    }

	    STcopy( argv[ ++i ], gcb_to_addr.n_sel );
	    STcopy( argv[ ++i ], gcb_to_addr.node_id );
	    STcopy( argv[ ++i ], gcb_to_addr.port_id );
	    CVupper( gcb_to_addr.n_sel );
	    ++cmd_args;
	}

    if ( cmd_args )
	if ( cmd_args == 2 )
	    gcb_pm_reso.cmd_line = TRUE;
	else
	{
	    SIfprintf( stderr, "\n%s%s\n\n", usage, usage1 );
	    SIflush( stderr );
	    SIstd_write(SI_STD_OUT, "\nFAIL\n");
	    EXdelete();
	    PCexit( FAIL );
	}

    /*
    ** Perform general initialization.  The bridge may be run
    ** for async lines as a part of Ingres/Net.  Otherwise,
    ** Bridge authorization is required.
    */
    if ( gcb_pm_reso.cmd_line  &&
	 ! STcasecmp( gcb_from_addr.n_sel, ERx("async") ) ) 
	status = gcc_init( FALSE, CI_INGRES_NET, argc, argv,
			   &generic_status, &system_status );
    else
    {
#ifdef CI_INGRES_BRIDGE
	status = gcc_init( FALSE, CI_INGRES_BRIDGE, argc, argv,
			   &generic_status, &system_status );
#else 
	generic_status = E_GC2A0F_NO_AUTH_BRIDGE;
	status = FAIL;
#endif
    }

    if ( status != OK )
    {
	gcc_er_log( &generic_status, &system_status, NULL, NULL );
	generic_status = E_GC2A01_INIT_FAIL;
	gcc_er_log( &generic_status, NULL, NULL, NULL );
	SIstd_write(SI_STD_OUT, "\nFAIL\n");
	EXdelete();
	PCexit( FAIL );
    }

    /*
    ** Perform standalong Bridge Server initialization.
    */
    IIGCc_global->gcc_flags |= GCC_STANDALONE;
    gcb_init_mib();

    /*
    ** Initialize the protocol layers.
    */
    call_list[0] = GCcinit;
    call_list[1] = gcb_alinit;
    call_list[2] = gcc_pbinit;
    call_count   = 3;

    if ( gcc_call( &call_count, call_list, 
		   &generic_status, &system_status ) != OK )
    {
	gcc_er_log( &generic_status, &system_status, NULL, NULL );
	generic_status = E_GC2A01_INIT_FAIL;
	gcc_er_log( &generic_status, NULL, NULL, NULL );
	SIstd_write(SI_STD_OUT, "\nFAIL\n");
    }
    else
    {
	{
	    /*
	    ** Obtain and fix up the configuration name, then log it.
	    */
	    char	server_flavor[256], server_type[32];
	    char	*tmpbuf = PMgetDefault(3);

	    if (!STbcompare( tmpbuf, 0, "*", 0, TRUE ))
		STcopy("(DEFAULT)", server_flavor);
	    else
		STcopy(tmpbuf, server_flavor);

	    STcopy(PMgetDefault(2), server_type);
	    CVupper(server_type);

	    erlist.gcc_parm_cnt = 2;
	    erlist.gcc_erparm[0].value = server_flavor;
	    erlist.gcc_erparm[0].size = STlength(server_flavor);
	    erlist.gcc_erparm[1].value = server_type;
	    erlist.gcc_erparm[1].size = STlength(server_type);

	    generic_status = E_GC2A10_LOAD_CONFIG;
	    gcc_er_log( &generic_status, (CL_ERR_DESC *)NULL,
			(GCC_MDE *)NULL, &erlist);
	}

	erlist.gcc_parm_cnt 	   = 1;
	erlist.gcc_erparm[0].size  = STlength( IIGCc_rev_lvl );
	erlist.gcc_erparm[0].value = IIGCb_rev_lvl;
	generic_status 		   = E_GC2A03_STARTUP;
	gcc_er_log( &generic_status, NULL, NULL, &erlist );

	/*
	** Invoke GCexec to enter the main phase of Protocol bridge
	** execution.  GCexec does not return until bridge shutdown 
	** is initiated by invoking GCshut.
	*/
	GCexec();

	generic_status = E_GC2A04_SHUTDOWN;
	gcc_er_log( &generic_status, &system_status, NULL, NULL );
    }

    /*
    ** GCexec has returned.  Bridge shutdown is in process.
    ** Initialize the call list to specify termination rotutines.
    ** Call in reverse order of initialization but don't call 
    ** termination routines whose initialization routines were 
    ** not called (call_count has the number of successful 
    ** initialization calls).
    */
    call_list[0] = gcb_alterm;
    call_list[1] = gcc_pbterm;
    call_list[2] = GCcterm;

    if ( gcc_call( &call_count, &call_list[ 3 - call_count ], 
		   &generic_status, &system_status ) )
	gcc_er_log( &generic_status, &system_status, NULL, NULL );

    /*
    ** Do general server termination.
    */
    if ( gcc_term( &generic_status, &system_status ) != OK )
	gcc_er_log( &generic_status, &system_status, NULL, NULL );

    EXdelete();
    PCexit( OK );
} /* end main */