/************************************************************************* * * Name: dir_DeassignLogical * * Type pwr_tStatus * * Description: * Deassign a logical name. * * Parameters * **************************************************************************/ pwr_tStatus dir_DeassignLogical( char *name, 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}; 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; sts = lib$delete_logical( &name_desc, &table_desc); return sts; #else printf("DeassignLogical: NYI\n"); return 0; #endif }
/* 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 */ }