Ejemplo n.º 1
0
void
yyinit( void )
{
	char *name, *value, *map_path;

	/* zero the line counter */
	yylineno = 0;

	if( rulemap_path == NULL )
	{
		NMloc( FILES, FILENAME, ERx( "default.rfm" ), &loc );
		LOcopy( &loc, file_name, &loc );	
		LOtos( &loc, &map_path );
	}
	else
	{
		STcopy( rulemap_path, file_name );
		LOfroms( FILENAME, file_name, &loc );
		map_path = rulemap_path;
	}

	(void) PMmInit( &rulemap );
	if( PMmLoad( rulemap, &loc, PMerror ) != OK )
		PCexit( FAIL );

	/* initiate scan of rule map */
	if( PMmScan( rulemap, ERx( ".*" ), &rfm_scan, NULL, &name, &value )
		!= OK )
	{
		F_ERROR( "Rule file map %s is empty.", map_path );
	}

	/* set up LOCATION of first rule file */
	STcopy( value, file_name );
	NMloc( FILES, FILENAME, file_name, &loc );
	LOcopy( &loc, file_name, &loc );	

	/* initialize input pointer */
	yyp = &dummy;

	/* open rule file */
	if( SIfopen( &loc, ERx( "r" ), SI_TXT, SI_MAX_TXT_REC, &yyin )
		!= OK && yywrap() )
	{
		ERROR( "No configuration rule files were found." );
	}
}
Ejemplo n.º 2
0
static bool
yywrap( void )
{
	char *name, *value;

	/* initialize the line counter */
	yylineno = -1;

	while( TRUE )
	{
		/* get the name of next rule specification to be loaded */
		if( PMmScan( rulemap, NULL, &rfm_scan, NULL, &name,
			&value ) != OK )
		{
			if( yyin != (FILE *) NULL )
				(void) SIclose( yyin );
			return( TRUE ); /* no more files */
		}

		/* set up LOCATION of rule file */
		STcopy( value, file_name );
		NMloc( FILES, FILENAME, file_name, &loc );
		LOcopy( &loc, file_name, &loc );	

		if( yyin != (FILE *) NULL )
		{
			(void) SIclose( yyin );
			yyin = (FILE *) NULL;
		}

		/* try to open rule file */
		if( SIfopen( &loc, ERx( "r" ), SI_TXT, SI_MAX_TXT_REC, &yyin )
			== OK && SIgetrec( yybuf, sizeof( yybuf ), yyin )
			== OK )
		{
			break;	
		}
	}

	/* initialize input pointer */
	yyp = &dummy;

	/* another file was opened - so we're not done yet */
	return( FALSE );
}
Ejemplo n.º 3
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 */
}