Ejemplo n.º 1
0
/*************************************************************************
*
* Name:		dir_DefineLogical
*
* Type		pwr_tStatus
*
* Description: 
*		Define a logical name.
*
* Parameters
*
**************************************************************************/
pwr_tStatus dir_DefineLogical( 
	char	*name,
	char	*value,
	char	*table
)
{
#ifdef OS_VMS
	pwr_tStatus sts;
	struct dsc$descriptor_s name_desc = 
			{0, DSC$K_DTYPE_T, DSC$K_CLASS_S, 0};
	struct dsc$descriptor_s table_desc = 
			{0, DSC$K_DTYPE_T, DSC$K_CLASS_S, 0};
	struct dsc$descriptor_s value_desc = 
			{0, DSC$K_DTYPE_T, DSC$K_CLASS_S, 0};

	name_desc.dsc$w_length = strlen( name);
	name_desc.dsc$a_pointer = name;
	table_desc.dsc$w_length = strlen( table);
	table_desc.dsc$a_pointer = table;
	value_desc.dsc$w_length = strlen( value);
	value_desc.dsc$a_pointer = value;

	sts = lib$set_logical( &name_desc, &value_desc, &table_desc,
		NULL,NULL);
	return sts;
#else
	printf("DefineLogical: NYI\n");
	return 0;
#endif
}
Ejemplo n.º 2
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 */
}
Ejemplo n.º 3
0
int
osPutEnv(String eqn)
{
	unsigned long int status;
	String  end_buffer;
	static unsigned long int lnm_attr;
	static String equiv_buffer;	          /* xlation of logical name */
	struct dsc$descriptor_s lognam;	          /* logical name */
	$DESCRIPTOR(tabnam, "LNM$PROCESS_TABLE"); /* logical name table */

	struct item_list_3 itmlst[] = {
		{sizeof lnm_attr, LNM$_ATTRIBUTES, (String) & lnm_attr, 0},
		{0, LNM$_STRING, 0, 0},
		{0, 0, 0, 0}
	};

	for (equiv_buffer = eqn;
		*equiv_buffer && *equiv_buffer != '=';
		equiv_buffer++);

	for (end_buffer = ++equiv_buffer; *end_buffer; end_buffer++);

	lognam.dsc$a_pointer = eqn;		/* logical name string */
	lognam.dsc$w_length = (equiv_buffer - eqn) - 1;	/* string length */
	lognam.dsc$b_class = DSC$K_CLASS_S;	/* string descriptor */
	lognam.dsc$b_dtype = DSC$K_DTYPE_T;	/* ASCII string */

	lnm_attr = 0;		/* use default attributes */
	/* LNM$M_CONCEALED|LNM$M_TERMINAL */

	itmlst[1].buffer_address = equiv_buffer;
	itmlst[1].buffer_length = end_buffer - equiv_buffer;

	/*
	 * A little explanation is required here. The system service routine
	 * $CRELNM creates a new logical name and assigns it a value and
	 * miscellaneous properties. Among the properties is the access mode,
	 * which specifies whether the logical name has USER, SUPERVISOR,
	 * EXECUTIVE, or KERNEL mode. Unfortunately, it cannot define a
	 * logical name with an access mode higher than that of the process
	 * it is running in, and for USER mode processes this means that the
	 * logical name can only be defined with USER mode. This, in turn,
	 * means that the logical name will vanish when the image exits. To
	 * cirumvent this, we may use the RTL routine LIB$SET_LOGICAL, which
	 * requests the shell under which the process is running to define
	 * the logical name for it at SUPERVISOR access mode, which survives
	 * the exit of the current image.
	 */

#ifdef SUPERVISOR_LNM
	status = lib$set_logical(
		&lognam,	/* LNM to be defined */
		NULL,		/* value (specified in itmlst) */
		&tabnam,	/* LNM table to contain new name */
		NULL,		/* attr: default attributes */
		&itmlst);	/* what to do */
#else /* SUPERVISOR_LNM */
	status = sys$crelnm(
		NULL,		/* attr: default attributes */
		&tabnam,	/* LNM table to contain new name */
		&lognam,	/* LNM to be defined */
		NULL,		/* acmode: access mode of LNM */
		&itmlst);	/* what to do */
#endif /* SUPERVISOR_LNM */

	if (!(status & 1))
		lib$signal(status, NULL);	/* report unexpected errors */

	return (status & 1) ? 0 : -1;	/* UNIX-like return code */
}