Ejemplo n.º 1
0
	/*****************************************************************
	 * TclSetCurrent:
	 *****************************************************************/
int TclSetCurrent()
   {
    int   sts;
    char  *experiment;
    static int   shot;
    static DESCRIPTOR_LONG(dsc_shot,&shot);
    static DYNAMIC_DESCRIPTOR(dsc_experiment);
    static DYNAMIC_DESCRIPTOR(dsc_asciiShot);

    cli_get_value("EXPERIMENT",&dsc_experiment);
    experiment = dsc_experiment.dscA_pointer;
    if (cli_present("INCREMENT") & 1)
       {
        shot = TreeGetCurrentShotId(experiment);
        shot++;
        sts = TreeSetCurrentShotId(experiment,shot);
       }
    else
       {
        cli_get_value("SHOT",&dsc_asciiShot);
#ifdef vms
        dsc_asciiShot.dscB_class = CLASS_S;	/* vms: malloc vs str$	*/
        sts = TdiExecute(&dsc_asciiShot,&dsc_shot MDS_END_ARG);
        dsc_asciiShot.dscB_class = CLASS_D;
#else
        sts = TdiExecute(&dsc_asciiShot,&dsc_shot MDS_END_ARG);
#endif
        if (sts & 1)
            sts = TreeSetCurrentShotId(experiment,shot);
       }

    if ((sts & 1) != 1)
        MdsMsg(sts,0);
    return sts;
   }
Ejemplo n.º 2
0
	/***************************************************************
	 * TclEdit:
	 * Open tree for edit
	 ***************************************************************/
int TclEdit()
   {
    int   shot;
    int   sts;
    static DYNAMIC_DESCRIPTOR(dsc_filnam);
    static DYNAMIC_DESCRIPTOR(dsc_asciiShot);

    cli_get_value("FILE",&dsc_filnam);
    cli_get_value("SHOTID",&dsc_asciiShot);
    sscanf(dsc_asciiShot.dscA_pointer,"%d",&shot);
    if (cli_present("NEW") & 1)
        sts = TreeOpenNew(dsc_filnam.dscA_pointer,shot);
    else
        sts = TreeOpenEdit(dsc_filnam.dscA_pointer,shot);
    if (sts & 1)
        TclNodeTouched(0,tree);
    else
       {
        sts = MdsMsg(sts,"Error opening tree-file %s for EDIT",
                dsc_filnam.dscA_pointer);
#ifdef vms
        lib$signal(sts,0);
#endif
       }
    return sts;
   }
Ejemplo n.º 3
0
/*
**++
**  ROUTINE:	main
**
**  FUNCTIONAL DESCRIPTION:
**
**  	Main program.  Fetches the command from the command line,
**  uses CLI$ routines to parse it, then starts the build process.
**
**  RETURNS:	cond_value, longword (unsigned), write only, by value
**
**  PROTOTYPE:
**
**  	main
**
**  IMPLICIT INPUTS:	See global definitions at module head.
**
**  IMPLICIT OUTPUTS:	See global definitions at module head.
**
**  COMPLETION CODES:
**
**  	SS$_NORMAL, MMK__ALLOK : normal successful completion.
**
**  SIDE EFFECTS:   	None.
**
**--
*/
unsigned int main (void) {

    DESCRIP cmdstr;
    char Output_File[256], tmp[256];
    $DESCRIPTOR(cmdname, "MMKC ");
    unsigned int status;
    int i;

/*
** Initialize the globals
*/
    temporary_symbols = 0;
    for (i = 0; i < MMK_K_SYMTABLE_SIZE; i++) {
    	INIT_QUEUE(global_symbols.symlist[i]);
    	INIT_QUEUE(local_symbols.symlist[i]);
    	INIT_QUEUE(cmdline_symbols.symlist[i]);
    	INIT_QUEUE(builtin_symbols.symlist[i]);
    }
    INIT_QUEUE(rules);
    INIT_QUEUE(dependencies);
    INIT_QUEUE(dep_internal);
    INIT_QUEUE(dep_deferred);
    INIT_QUEUE(suffixes);
    INIT_QUEUE(do_first);
    INIT_QUEUE(do_last);
    exit_status = SS$_NORMAL;
    ignore = override_silent = override_ignore = symbol_override = 0;
    skip_intermediates = 0;

/*
** Fetch and parse command string
*/
    INIT_DYNDESC(cmdstr);
    status = lib$get_foreign(&cmdstr);
    str$prefix(&cmdstr, &cmdname);
    status = cli$dcl_parse(&cmdstr, MMK_COMPILE_RULES_CLD,
    	    	lib$get_input, lib$get_input);
    if (!OK(status)) return (status | STS$M_INHIB_MSG);

/*
** Get the command parameters and qualifiers
*/
    Output_File[0] = '\0';
    if (cli_present("OUTPUT") == CLI$_PRESENT) {
    	cli_get_value("OUTPUT", Output_File, sizeof(Output_File));
    }

    status = cli_get_value("RULES_FILE", tmp, sizeof(tmp));
    if (!OK(status)) return status | STS$M_INHIB_MSG;

    Read_Description(tmp, "SYS$DISK:[].MMS", 1);
    if (OK(exit_status)) Generate_Structures(tmp, Output_File);

    return exit_status | STS$M_INHIB_MSG;

}
Ejemplo n.º 4
0
int   mdsdcl_set_command(		/* Return: status		*/
    struct _mdsdcl_ctrl  *ctrl		/* <m> the control structure	*/
   )
   {
    int   sts;
    void  *newTable;
    static DYNAMIC_DESCRIPTOR(dsc_table);

		/*------------------------------------------------------
		 * Get tablename and find its address in shared library ...
		 *-----------------------------------------------------*/
    sts = cli_get_value("TABLE",&dsc_table);
    if (sts & 1)
       {
        int i;
        for (i=0;i<dsc_table.dscW_length;i++)
          dsc_table.dscA_pointer[i] = _tolower(dsc_table.dscA_pointer[i]);
        if (!strstr(dsc_table.dscA_pointer,"_commands"))
          str_concat(&dsc_table,&dsc_table,"_commands",0);
        sts = LibFindImageSymbol(&dsc_table,&dsc_table,&newTable);
        if (~sts & 1)
            return(MdsMsg(sts,"Failed to open table %s",
                dsc_table.dscA_pointer));

		/*------------------------------------------------------
		 *... add newTable address to "tbladr[]" list
		 *-----------------------------------------------------*/
        for (i=0 ; i<ctrl->tables ; i++)
            if (newTable == ctrl->tbladr[i])  break;
        if (i == ctrl->tables)
           {
            if (ctrl->tables >= MAX_TABLES)
               {
                fprintf(stderr,"set_command: *WARN* Max_tables exceeded\n");
                return(0);
               }
            ctrl->tbladr[ctrl->tables++] = newTable;
           }
       }

		/*------------------------------------------------------
		 * Check for other qualifiers ...
		 *-----------------------------------------------------*/
    if (cli_present("HELPLIB") & 1)
        cli_get_value("HELPLIB",&ctrl->helplib);

    if (cli_present("PROMPT") & 1)
        cli_get_value("PROMPT",&ctrl->prompt);

    if (cli_present("DEF_FILE") & 1)
        cli_get_value("DEF_FILE",&ctrl->def_file);

    return(1);
   }
Ejemplo n.º 5
0
	/***************************************************************
	 * TclClose:
	 * Close tree file(s).
	 ***************************************************************/
int TclClose()
   {
    int sts;
    static const char  promptWritefirst[] =
            "This tree has been modified, write it before closing? [Y]: ";
    static DYNAMIC_DESCRIPTOR(exp);
    static DYNAMIC_DESCRIPTOR(dsc_shotid);
    int shotid;

    if (cli_get_value("FILE",&exp) & 1)
       {
        cli_get_value("SHOTID",&dsc_shotid);
        sscanf(dsc_shotid.dscA_pointer,"%d",&shotid);
        sts = TreeClose(exp.dscA_pointer,shotid);
       }
    else
       {
        int doall =  cli_present("ALL") & 1;
        while ((sts = TreeClose(0,0)) & 1 && doall);
        if (doall && sts == TreeNOT_OPEN)
            sts = TreeNORMAL;
       }
    if (sts == TreeWRITEFIRST)
       {
         if (cli_present("CONFIRM") == CLI_STS_NEGATED)
           sts = TreeQuitTree(0,0);
         else
	 {
	   printf(promptWritefirst);
	   if (yesno(1))
           {
            sts = TreeWriteTree(0,0);
            if (sts & 1)
               {
                TreeClose(0,0);
               }
           }
	   else
	     sts = TreeQuitTree(0,0);
	 }
       }
    if (sts & 1)
        TclNodeTouched(0,tree);
    else
        MdsMsg(sts,"TclClose: *WARN* unexpected status");
    return sts;
   }
Ejemplo n.º 6
0
	/***************************************************************
	 * TclShowAttribute:
	 ***************************************************************/
int TclShowAttribute() {
  int status;
  int nid;
  EMPTYXD(xd);
  static DYNAMIC_DESCRIPTOR(dsc_node);
  static DYNAMIC_DESCRIPTOR(dsc_attr);
  static DYNAMIC_DESCRIPTOR(dsc_string);
  cli_get_value("NODE",&dsc_node);
  status = TreeFindNode(dsc_node.dscA_pointer,&nid);
  if (status & 1) {
    status = cli_get_value("NAME",&dsc_attr);
    if (status & 1) {
      status = TreeGetXNci(nid,dsc_attr.dscA_pointer,&xd);
      if (status & 1) {
	status = TdiDecompile(&xd,&dsc_string MDS_END_ARG);
	if (status & 1) {
	  char *p = malloc(dsc_string.dscW_length+1);
	  strncpy(p,dsc_string.dscA_pointer,dsc_string.dscW_length);
	  p[dsc_string.dscW_length]='\0';
	  TclTextOut(p);
	  free(p);
	}
	StrFree1Dx(&dsc_string);
	MdsFree1Dx(&xd,0);
      }
    } else {
      if (TreeGetXNci(nid,"attributenames",&xd)&1) {
	TdiSortVal(&xd,&xd MDS_END_ARG);
	if (xd.dscA_pointer && xd.dscA_pointer->dscB_class == CLASS_A) {
	  typedef ARRAY(char) ARRAY_DSC;
	  ARRAY_DSC *array=(ARRAY_DSC *)xd.dscA_pointer;
	  char *name=array->dscA_pointer;
	  TclTextOut("Defined attributes for this node:");
	  for (name=array->dscA_pointer;name<array->dscA_pointer+array->dscL_arsize;name+=array->dscW_length) {
	    char *out=malloc(array->dscW_length+6);
	    sprintf(out,"    %.*s",array->dscW_length,name);
	    TclTextOut(out);
	    free(out);
	  }
	} else {
	  TclTextOut("No attributes defined for this node");
	}
	MdsFree1Dx(&xd,0);
      } else {
Ejemplo n.º 7
0
//-------------------------------------------------------------------------
// Delete a crate from the crate db
//-------------------------------------------------------------------------
int DelCrate()
{
	char	crateName[CRATE_NAME_SIZE + 1];
	int		index, numOfEntries;
	int		status = SUCCESS;

	static DESCRIPTOR( phy_name_p, "PHY_NAME" );
	static DYNAMIC_DESCRIPTOR( phy_name );

	// get user input
	str_free1_dx(&phy_name);				// per twf -- clear out field
	cli_get_value( &phy_name_p, &phy_name );
	str_upcase( &phy_name, &phy_name );
	// trim it...
	sprintf(crateName, "%.6s", phy_name.pointer);

	// check to see if db file memory mapped
	if( CRATEdbFileIsMapped == FALSE ) {			// is not, so try
		if( map_data_file(CRATE_DB) != SUCCESS ) {	// we're dead in the water
			status = FAILURE;		// MAP_ERROR;		[2001.07.12]
			goto DelCrate_Exit;
		}
	}

	// get number of current entries
	if( (numOfEntries = get_file_count(CRATE_DB)) == 0 ) {	// no entries in crate db file
		if( MSGLVL(IMPORTANT) )
			fprintf( stderr, "db file empty, no entries to remove\n" );

		status = FAILURE;		// DELCRATE_ERROR;		[2001.07.12]
		goto DelCrate_Exit;
	}

	// try to remove from crate.db
	if( (index = lookup_entry(CRATE_DB, crateName)) >= 0 ) {	// module does exist
		if( remove_entry(CRATE_DB, index) != SUCCESS ) {		// removal failed
			status = FAILURE;		// DELCRATE_ERROR;		[2001.07.12]
			goto DelCrate_Exit;
		}
	}
	else {		// no such module
		if( MSGLVL(IMPORTANT) )
			fprintf( stderr, "delcrate(): entry '%s' not found\n", crateName);

		status = FAILURE;		// DELCRATE_ERROR;		[2001.07.12]
		goto DelCrate_Exit;
	}

DelCrate_Exit:
	if( MSGLVL(DETAILS) ) {
		printf("DelCrate() status = %d\n", status);
	}

	return SUCCESS;
}
Ejemplo n.º 8
0
/****************************************************************
 * mdsdcl_define:
 * Define an mds macro ...
 ****************************************************************/
int   mdsdcl_define()			/* Return: status		*/
{
    int   i,k;
    int   sts;
    char  name[32];
    char  *p;
    struct _mdsdcl_macro  *m;
    static DYNAMIC_DESCRIPTOR(dsc_name);
    static DYNAMIC_DESCRIPTOR(dsc_cmd);
    static char  fmt1[] = "Macro '%s' is open -- cannot be edited";

    sts = cli_get_value("P1",&dsc_name);
    if (~sts & 1)
        return(sts);

    k = dsc_name.dscW_length;
    if (k >= sizeof(name))
        k = sizeof(name) - 1;
    l2un(name,dsc_name.dscA_pointer,k);
    name[k] = '\0';

    /*=======================================================
     * Get addr of macro struct.  Delete any existing lines ...
     *======================================================*/
    m = get_macro(name);
    if (m->isOpen)
        return(MdsMsg(MDSDCL_STS_ERROR,fmt1,m->name));

    for (i=0 ; i<m->numLines ; i++)
        free(m->lines[i]);
    m->numLines = 0;

    /*======================================================
     * Read new macro from input ...
     *=====================================================*/
    for ( ; (sts = mdsdcl_get_input_nosymbols("DEFMAC> ",&dsc_cmd)) & 1 ; )
    {
        if ((dsc_cmd.dscW_length > 0) && dsc_cmd.dscA_pointer)
            p = nonblank(dsc_cmd.dscA_pointer);
        else
            p = 0;
        if (!p || end_macro(p))
        {
            break;
        }
        if (m->numLines >= m->maxLines)
            extend_macro(m);
        m->lines[m->numLines++] = STRING_ALLOC(dsc_cmd.dscA_pointer);
    }
    return(1);
}
Ejemplo n.º 9
0
	/*****************************************************************
	 * TclAddTag:
	 * Add a tag name to a node
	 *****************************************************************/
int   TclAddTag()		/* Return: status			*/
   {
    int nid;
    int sts;
    static DYNAMIC_DESCRIPTOR(dsc_nodnam);
    static DYNAMIC_DESCRIPTOR(dsc_tagnam);

    cli_get_value("NODE",&dsc_nodnam);
    cli_get_value("TAGNAME",&dsc_tagnam);
    l2u(dsc_nodnam.dscA_pointer,0);
    l2u(dsc_tagnam.dscA_pointer,0);
    sts = TreeFindNode(dsc_nodnam.dscA_pointer,&nid);
    if (sts & 1)
        sts = TreeAddTag(nid,dsc_tagnam.dscA_pointer);
    if (!(sts & 1))
       {
        MdsMsg(sts,"Error adding tag %s",dsc_tagnam.dscA_pointer);
#ifdef vms
        lib$signal(sts,0);
#endif
       }
    return sts;
   }
Ejemplo n.º 10
0
void lke_setgdr(void)
{
	gd_region 	*r_top;
	mval		reset;
	bool		def;
	short		len;
	char		buf[256];
	int4		rundown_status = EXIT_NRM;			/* if gds_rundown went smoothly */
	static readonly char init_gdr[] = "gtmgbldir";

	gvcmy_rundown();
	gv_cur_region = gd_header->regions;
	r_top = gv_cur_region + gd_header->n_regions;
	for (gv_cur_region = gd_header->regions,
	  r_top = gv_cur_region + gd_header->n_regions;
	  gv_cur_region < r_top;
	  gv_cur_region++)
	{
		tp_change_reg();
		UNIX_ONLY(rundown_status |=) gds_rundown();
	}

	if (EXIT_NRM != rundown_status)
		rts_error(VARLSTCNT(1) ERR_NOTALLDBRNDWN);

	if (cli_present("gld"))
	{
		cli_get_value("gld", buf) ;
		def = FALSE;
		reset.mvtype = MV_STR;
		reset.str.len = STRLEN(buf);
		reset.str.addr = buf;
	}
	else
	{
		reset.mvtype = MV_STR;
		reset.str.len = SIZEOF(init_gdr) - 1;
		reset.str.addr = init_gdr;
	}

	zgbldir(&reset);
	cs_addrs = 0;
	cs_data = 0;
	region_init(FALSE) ;
#ifndef MUTEX_MSEM_WAKE
	mutex_sock_cleanup();
#endif
	gtmsecshr_sock_cleanup(CLIENT);
}
Ejemplo n.º 11
0
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
int ResetHighway()
{
	int status;

	static DESCRIPTOR( crate_p, "MODULE" );
	static DYNAMIC_DESCRIPTOR( wild );
	static DYNAMIC_DESCRIPTOR( crate );

	cli_get_value( &crate_p, &wild );

	if( MSGLVL(DETAILS) )
		printf("ResetHighway() invoked -- not implemented\n");

	return SUCCESS;
}
Ejemplo n.º 12
0
//-------------------------------------------------------------------------
// set a crate on-line or off-line
//-------------------------------------------------------------------------
int SetCrate()
{
	int status;
        char *cratename; 
        void *ctx=0;

	static DESCRIPTOR( crate_p, "CRATE" );
	static DESCRIPTOR( quietq, "QUIET" );

	static DYNAMIC_DESCRIPTOR( wild );
	static DYNAMIC_DESCRIPTOR( crate );

	static DESCRIPTOR( offq, "OFFLINE" );
	static DESCRIPTOR( onq, "ONLINE" );

	int off = cli_present(&offq) & 1;
	int on  = cli_present(&onq ) & 1;
        int quiet = cli_present(&quietq) & 1;

	cli_get_value( &crate_p, &wild );
	str_upcase( &wild, &wild );

	// check to see if db file memory mapped
	if( CRATEdbFileIsMapped == FALSE ) {			// is not, so try
		if( map_data_file(CRATE_DB) != SUCCESS ) {	// we're dead in the water
			if( MSGLVL(IMPORTANT) )
				fprintf( stderr, "error memory mapping crate db file\n" );

			status = FAILURE;		// MAP_ERROR;		[2001.07.12]
			goto SetCrate_Exit;
		}
	}
        
        while (find_crate(wild.pointer,&cratename,&ctx))
        {

	  status = turn_crate_on_off_line( cratename , (on) ? ON : OFF );
          if (!(status & 1) && !quiet)
            printf("Error turning crate %s %s\n",cratename,on ? "online" : "offline");
          free(cratename);
        }
        find_crate_end(&ctx);
SetCrate_Exit:
	return SUCCESS;
}
Ejemplo n.º 13
0
/*
 * --------------------------------------------------
 * Find the qualifier and convert it to 64 bit unsigned decimal number.
 *
 * Return:
 *	TRUE	- OK
 *	FALSE	- Could not convert to hex
 * --------------------------------------------------
 */
boolean_t cli_get_uint64(char *entry, gtm_uint64_t *dst)
{
    char	buf[MAX_LINE];
    char	local_str[MAX_LINE];

    assert(strlen(entry) > 0);
    strncpy(local_str, entry, SIZEOF(local_str) - 1);

    if ((cli_present(local_str) == CLI_PRESENT) && cli_get_value(local_str, buf))
    {
        if (!cli_str_to_uint64(buf, dst))
        {
            FPRINTF(stderr, "Error: cannot convert %s value to 64-bit unsigned decimal number.\n", buf);
            return FALSE;
        }
        return TRUE;
    }
    return FALSE;
}
Ejemplo n.º 14
0
/*****************************************************************
 * mdsdcl_show_macro:
 *****************************************************************/
int   mdsdcl_show_macro()		/* Return: status		*/
{
    int   i;
    int   full;
    int   sts;
    struct _mdsdcl_macro  *m;
    static DYNAMIC_DESCRIPTOR(dsc_name);
    struct _mdsdcl_ctrl  *ctrl = &MdsdclGetThreadStatic()->ctrl;

    sts = cli_get_value("MACRO",&dsc_name);
    if (sts & 1)
    {
        l2u(dsc_name.dscA_pointer,0);
        m = find_macro(dsc_name.dscA_pointer);
        if (!m)
        {
            fprintf(stderr,"  --> macro '%s' not defined\n\r",
                    dsc_name.dscA_pointer);
            return(1);
        }
        display_macro(m);
        return(1);
    }
    /*=======================================================
     * List all defined macros ...
     *======================================================*/
    full = cli_present("FULL") & 1;
    m = ctrl->macro.list;
    if (!m)
    {
        fprintf(stderr,"  --> No macros defined\n\n\r");
        return(1);
    }
    for (i=0 ; i<ctrl->macro.numMacros ; i++,m++)
    {
        if (full)
            display_macro(m);
        else
            printf("  %s\n\r",m->name);
    }
    return(1);
}
Ejemplo n.º 15
0
/*
 * --------------------------------------------------
 * Find the qualifier and convert it to decimal number
 * unless 0x prefix.
 *
 * Return:
 *	TRUE	- OK
 *	FALSE	- Could not convert to number
 * --------------------------------------------------
 */
boolean_t cli_get_num(char *entry, int4 *dst)
{
    char		buf[MAX_LINE];
    char		local_str[MAX_LINE];

    assert(strlen(entry) > 0);
    strncpy(local_str, entry, SIZEOF(local_str) - 1);

    if (cli_present(local_str) == CLI_PRESENT
            && cli_get_value(local_str, buf))
    {
        if (!cli_str_to_num(buf, dst))
        {
            FPRINTF(stderr, "Error: cannot convert %s string to number.\n", buf);
            return FALSE;
        }
        return TRUE;
    }
    return FALSE;
}
Ejemplo n.º 16
0
	/****************************************************************
	 * TclDirectoryTag:
	 * Perform directory of all of the tags
	 ****************************************************************/
int TclDirectoryTag()
   {
    int   sub_total;
    int   grand_total;
    char  *nodename;
    char  *tagnam;
    char  text[40];
    void  *ctx;
    static DYNAMIC_DESCRIPTOR(dsc_tagnam);
    static DYNAMIC_DESCRIPTOR(dsc_outLine);

    sub_total = grand_total = 0;
    while (cli_get_value("TAG",&dsc_tagnam) & 1)
       {
        tagnam = dsc_tagnam.dscA_pointer;
        l2u(tagnam,0);
        ctx = 0;
        sub_total = 0;
        TclTextOut(" ");
        sprintf(text,"Tag listing for %s",tagnam);
        TclTextOut(text);
        TclTextOut(" ");
        while ((nodename = TreeFindTagWild(tagnam,0,&ctx)))
           {
            TclTextOut(nodename);
            sub_total++;
           }
        TreeFindTagEnd(&ctx);
        grand_total += sub_total;
        sprintf(text,"Total of %d tags\n",sub_total);
        TclTextOut(text);
       }
    if (grand_total != sub_total)
       {
        sprintf(text,"Grand Total of %d tags\n",sub_total);
        TclTextOut(text);
       }
    return 1;
   }
Ejemplo n.º 17
0
//-------------------------------------------------------------------------
// deassign a module
//-------------------------------------------------------------------------
int Deassign()
{
	char			db_tmp[64];
	int 			i, index, modulesToDeassign, modulesDeassigned, numOfEntries, physical_name; 
	int				status = SUCCESS;
	struct Module_	Mod, *pMod;

	static DESCRIPTOR( physical, "PHYSICAL" );

	static DESCRIPTOR( modname_p, "MODULE" );
	static DYNAMIC_DESCRIPTOR( modname );

	static DYNAMIC_DESCRIPTOR( wild );

	struct descriptor pattern;

	// get user data
	cli_get_value( &modname_p, &wild );
	StrUpcase( &wild, &wild );

	physical_name = cli_present(&physical) & 1;

	if( MSGLVL(DETAILS) )
		printf("Deassign(): %s module: <%s>\n", physical_name ? "physical" : "logical", wild.pointer);

	// check to see if db file memory mapped
	if( CTSdbFileIsMapped == FALSE ) {				// is not, so try ...
		if( map_data_file(CTS_DB) != SUCCESS ) {	// we're dead in the water
			status = MAP_ERROR;						// [2002.02.21]
			goto Deassign_Exit;
		}
	}

	// get number of current entries
	if( (numOfEntries = get_file_count(CTS_DB)) == 0 ) {	// no entries in cts db file
		if( MSGLVL(IMPORTANT) )
			fprintf( stderr, "db file empty, no entries to remove\n" );

		status = DEASSIGN_ERROR;					// [2002.02.21]
		goto Deassign_Exit;
	}

	// if we get this far, then there are modules in the database
	modulesToDeassign = modulesDeassigned = 0;	// initialize counts
	pMod = &Mod;				// point to some actual storage

	// first, we need to count the number to deassign ...
	for( i = 0; i < numOfEntries; ++i ) {	// scan entire list
		// look up module name(s). NB! more than one logical name may be
		// assigned to the same, unique physical name.
		parse_cts_db( CTSdb+i, pMod );		// extract info from db

		memset(db_tmp, ' ', 32);	// clear out buffer
		db_tmp[33] = '\0';			// ensure buffer 'ends'

		if( physical_name ) 		// physical name
			sprintf( db_tmp, "GK%c%d%02d:N%d",
				pMod->adapter + 'A', 
				pMod->id, 
				pMod->crate,
				pMod->slot
				);
		else 						// logical name 
			sprintf( db_tmp, "%s", pMod->name );

		// prepare for 'wild' match
		pattern.pointer = db_tmp;
		pattern.length  = strlen(db_tmp);

		if( StrMatchWild( &pattern, &wild ) & 1 ) {
			++modulesToDeassign;	//
		}
	} // end of for() loop, all entries checked

	// now actually remove them
	while( modulesToDeassign ) {
		for( i = 0; i < get_file_count(CTS_DB); ++i ) {
			// look up module name(s). NB! more than one logical name may be
			// assigned to the same, unique physical name.
			parse_cts_db( CTSdb+i, pMod );		// extract info from db

			memset(db_tmp, ' ', 32);	// clear out buffer
			db_tmp[33] = '\0';			// ensure buffer 'ends'

			if( physical_name ) 		// physical name
				sprintf( db_tmp, "GK%c%d%02d:N%d",
					pMod->adapter + 'A', 
					pMod->id, 
					pMod->crate,
					pMod->slot
					);
			else 						// logical name 
				sprintf( db_tmp, "%s", pMod->name );

			// prepare for 'wild' match
			pattern.pointer = db_tmp;
			pattern.length  = strlen(db_tmp);

			if( StrMatchWild( &pattern, &wild ) & 1 ) {
				if( remove_entry(CTS_DB, i) != SUCCESS ) {	// removal failed
					status = DEASSIGN_ERROR;				// [2002.02.21]
					goto Deassign_Exit;
				}
				else 
					++modulesDeassigned;	// keep track of successes :)
			}
		}

		--modulesToDeassign;				// one less to remove ...
	}

Deassign_Exit:
	if( MSGLVL(DETAILS) ) {
		printf("Deassign(%d): ", modulesDeassigned); ShowStatus(status);
	}

	return status;
}  
Ejemplo n.º 18
0
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
// show crate status, using crates in 'crate.db' file
//-------------------------------------------------------------------------
int ShowCrate()
{
	char			colorENH[9], colorON[9];
	char tmp[7]; char tmp2[11];
	int				enhanced, i, j, online, moduleFound, numOfCrates, numOfModules;
	int				crateStatus;
	int				status;
	struct Crate_	Cr8, *pCr8;
	struct Module_	Mod, *pMod;

	static DESCRIPTOR( crate_p,  "MODULE" );
	static DESCRIPTOR( heading1, " CRATE   ONL LAM PRV ENH" );
	static DESCRIPTOR( heading2, "=======  === === === ===" );

	static DYNAMIC_DESCRIPTOR( wild );
	static DYNAMIC_DESCRIPTOR( crate );

	if( ScsiSystemStatus() == 0 ) {
		status = SUCCESS;			// this is the function's status
		printf("scsi system is %sdown!%s\n", RED, NORMAL);
		goto ShowCrate_Exit;
	}
	if( MSGLVL(DETAILS) ) printf("scsi system is %sup!%s\n", GREEN, NORMAL);

	// user input
	cli_get_value( &crate_p, &wild );
	str_upcase( &wild, &wild );

	// check to see if crate db file memory mapped
	if( CRATEdbFileIsMapped == FALSE ) {				// is not, so try
		if( map_data_file(CRATE_DB) != SUCCESS ) {		// we're dead in the water
			if( MSGLVL(IMPORTANT) )
				fprintf( stderr, "error memory mapping crate.db file\n" );

			status = FAILURE;		// MAP_ERROR;		[2001.07.12]
			goto ShowCrate_Exit;
		}
	}

	// check to see if module db file memory mapped
	if( CTSdbFileIsMapped == FALSE ) {					// is not, so try
		if( map_data_file(CTS_DB) != SUCCESS ) {		// we're dead in the water
			if( MSGLVL(IMPORTANT) )
				fprintf( stderr, "error memory mapping cts.db file\n" );

			status = FAILURE;		// MAP_ERROR;		[2001.07.12]
			goto ShowCrate_Exit;
		}
	}

	printf( "%s\n", heading1.pointer );					// header
	printf( "%s\n", heading2.pointer );					// header

	pCr8 = &Cr8;										// point to some actual storage
	pMod = &Mod;

	// get number of crates in db file
	if( (numOfCrates = get_file_count(CRATE_DB)) > 0 ) {	// possibly something to show
		if( (numOfModules = get_file_count(CTS_DB)) > 0 ) {	// maybe some crates controllers ..
			for( i = 0; i < numOfCrates; i++ ) {
				parse_crate_db(CRATEdb+i, pCr8);
				if(  wildcard_match( wild.pointer, pCr8->name, 0,0,0 ) ) {
				  //					moduleFound = FALSE;
				  //
				  //					for( j = 0; j < numOfModules; ++j ) {
				  //						parse_cts_db(CTSdb+j, pMod);
				  //						sprintf(tmp, "GK%c%d%02d",
				  //							pMod->adapter + 'A',
				  //							pMod->id,
				  //							pMod->crate
				  //							);
				  //
				  //						if( strcmp(tmp, pCr8->name) == EQUAL ) {
				  //							if( pMod->slot == 30 ) {	// found a crate controller
				  //								moduleFound = TRUE;
				  //								break;
				  //							}
				  //						}
				  //					} // end of for(modules) ...
				  moduleFound = TRUE;
				  if( moduleFound ) {
				    crateStatus = 0;
				    
				    if(MSGLVL(8)) 
				      printf("checking '%s'\n", pCr8->name);
				    
				    status = get_crate_status(pCr8->name, &crateStatus);
				    
				    if( MSGLVL(DETAILS) )
				      printf("gcs(%s) returned %d, crate 0x%x\n", pCr8->name, status, crateStatus);
				    
				    if( status == SUCCESS ) {
				      //							online = !(crateStatus & 0x3c00)    ? TRUE  : FALSE;				// [2002.12.09]
				      //							online = !(crateStatus & 0x1000)    ? TRUE  : FALSE;				// [2002.12.09]
				      online = ((crateStatus & 0x1000) != 0x1000)    ? TRUE  : FALSE;				// [2002.12.09]
				      if( !crateStatus || crateStatus == 0x3 )	// [2001.09.10]			// [2002.12.09]
					online = FALSE;													// [2002.12.09]
				      sprintf(colorON,  "%s", (online)    ? GREEN : RED);
				      
				      //							enhanced = (online && (crateStatus & 0x4030)) ? TRUE  : FALSE;		// [2002.12.09]
				      enhanced = (online && (crateStatus & 0x4000)) ? TRUE  : FALSE;		// [2002.12.09]
				      sprintf(colorENH, "%s", (enhanced)  ? GREEN : RED);
				      
				      printf("%s:   %s%c%s   .   .   %s%c%s",
					     pCr8->name,
					     colorON,  (online)   ? '*' : 'X', NORMAL,
					     colorENH, (enhanced) ? '*' : '-', NORMAL
					     );
				      if( MSGLVL(4) )
					printf( "  0x%04x", crateStatus );
				      printf("\n");
				    }
				  } // end of if(moduleFound) ...
				  else {
				    printf("%.6s:   .   .   .   .\n", pCr8->name);
				  }
				} // end of if(wildcard) ...
			} // end of for(crates) ...
		} // crates, but no modules (ie no controllers)
	}
	printf( "%s\n", heading2.pointer );					// header

	status = SUCCESS;		// always (???)

ShowCrate_Exit:
	return status;
}
Ejemplo n.º 19
0
	/****************************************************************
	 * TclSetNode:
	 ****************************************************************/
int TclSetNode()
   {
    int   nid;
    int   status;
    int   log;
    int   usageMask;
    void  *ctx = 0;
    char  *nodename;
    static DYNAMIC_DESCRIPTOR(dsc_nodename);
    static DYNAMIC_DESCRIPTOR(dsc_status);
    cli_get_value("NODENAME",&dsc_nodename);
    cli_get_value("STATUS",&dsc_status);
    nodename = dsc_nodename.dscA_pointer;
    l2u(nodename,0);
    log = cli_present("LOG") & 1;

    usageMask = -1;
    while ((status = TreeFindNodeWild(nodename,&nid,&ctx,usageMask)) & 1)
       {
	 if (dsc_status.dscA_pointer)
	 {
           int statval = atoi(dsc_status.dscA_pointer);
           NCI_ITM setnci[] = {{sizeof(int), NciSTATUS, 0, 0},{0,NciEND_OF_LIST,0,0}};
           setnci[0].pointer = (unsigned char *)&statval;
           TreeSetNci(nid,setnci);
         }
	 switch (cli_present("SUBTREE"))
           {
            case CLI_STS_PRESENT:
              status = TreeSetSubtree(nid);
              break;
            case CLI_STS_NEGATED:
              status = TreeSetNoSubtree(nid);
              break;
           }
        if (!(status & 1)) goto error;
        if (cli_present("ON") & 1)
           {
            status = TreeTurnOn(nid);
            if (status & 1)
                TclNodeTouched(nid,on_off);
            else
                TclErrorOut(status);
           }
        else if (cli_present("OFF") & 1)
           {
            status = TreeTurnOff(nid);
            if (status & 1)
                TclNodeTouched(nid,on_off);
            else
                TclErrorOut(status);
           }
        if (!(status & 1)) goto error;
           {
            int set_flags;
            int clear_flags;
            DYNAMIC_DESCRIPTOR(dsc_path);
            NCI_ITM get_itmlst[] =  { {0,NciPATH,(unsigned char *) &dsc_path,0}, {0,NciEND_OF_LIST}};
            NCI_ITM set_itmlst[] =  { {0,NciSET_FLAGS,(unsigned char *) &set_flags,0}, {0,NciEND_OF_LIST}};
            NCI_ITM clear_itmlst[] =  { {0,NciCLEAR_FLAGS,(unsigned char *) &clear_flags,0}, {0,NciEND_OF_LIST}};
            set_flags = 0;
            clear_flags = 0;
            switch (cli_present("WRITE_ONCE"))
               {
                case CLI_STS_PRESENT:
                  set_flags |= NciM_WRITE_ONCE;
                  break;
                case CLI_STS_NEGATED:
                  clear_flags |= NciM_WRITE_ONCE;
                  break;
               }
            switch (cli_present("CACHED"))
               {
                case CLI_STS_PRESENT:
                  set_flags |= NciM_CACHED;
                  break;
                case CLI_STS_NEGATED:
                  clear_flags |= NciM_CACHED;
                  break;
               }
            switch (cli_present("COMPRESS_ON_PUT"))
               {
                case CLI_STS_PRESENT:
                  set_flags |= NciM_COMPRESS_ON_PUT;
                  break;
                case CLI_STS_NEGATED:
                  clear_flags |= NciM_COMPRESS_ON_PUT;
                  break;
               }
            switch (cli_present("COMPRESS_SEGMENTS"))
               {
                  case CLI_STS_PRESENT:
                    set_flags |= NciM_COMPRESS_SEGMENTS;
                    break;
                  case CLI_STS_NEGATED:
                    clear_flags |= NciM_COMPRESS_SEGMENTS;
                    break;
               }
            switch (cli_present("DO_NOT_COMPRESS"))
               {
                case CLI_STS_PRESENT:
                  set_flags |= NciM_DO_NOT_COMPRESS;
                  break;
                case CLI_STS_NEGATED:
                  clear_flags |= NciM_DO_NOT_COMPRESS;
                  break;
               }
            switch (cli_present("SHOT_WRITE"))
               {
                case CLI_STS_PRESENT:
                  clear_flags |= NciM_NO_WRITE_SHOT;
                  break;
                case CLI_STS_NEGATED:
                  set_flags |= NciM_NO_WRITE_SHOT;
                  break;
               }
            switch (cli_present("MODEL_WRITE"))
               {
                case CLI_STS_PRESENT:
                  clear_flags |= NciM_NO_WRITE_MODEL;
                  break;
                case CLI_STS_NEGATED:
                  set_flags |= NciM_NO_WRITE_MODEL;
                  break;
               }
            switch (cli_present("INCLUDED"))
               {
                case CLI_STS_PRESENT:
                  set_flags |= NciM_INCLUDE_IN_PULSE;
                  break;
                case CLI_STS_NEGATED:
                  clear_flags |= NciM_INCLUDE_IN_PULSE;
                  break;
               }
            switch (cli_present("ESSENTIAL"))
               {
                case CLI_STS_PRESENT:
                  set_flags |= NciM_ESSENTIAL;
                  break;
                case CLI_STS_NEGATED:
                  clear_flags |= NciM_ESSENTIAL;
                  break;
               }
            if (set_flags) status = TreeSetNci(nid,set_itmlst);
            if (clear_flags) status = TreeSetNci(nid,clear_itmlst);
            if (status & 1)
               {
                if (log)
                   {
                    TreeGetNci(nid,get_itmlst);
                    str_concat(&dsc_path,"Node: ",&dsc_path," modified",0);
                    TclTextOut(dsc_path.dscA_pointer);
                    str_free1_dx(&dsc_path);
                   }
               }
            else
                goto error;
           }
       }
    TreeFindNodeEnd(&ctx);
    if (status == TreeNNF) goto error;
    return 1;
error:
#ifdef vms
    lib$signal(status,0);
#else
    MdsMsg(status,0);
#endif
    return status;
   }
Ejemplo n.º 20
0
bool cli_get_parm(char *entry, char val_buf[])
{
	char		*sp;
	int		ind;
	int		match_ind, res;
	char		local_str[MAX_LINE];
	int		eof;
	char		*gets_res;
	int		parm_len;
	DCL_THREADGBL_ACCESS;

	SETUP_THREADGBL_ACCESS;
	ind = 0;
	assert(0 != gpcmd_parm_vals);
	STRNCPY_STR(local_str, entry, SIZEOF(local_str) - 1);
	cli_strupper(local_str);
	match_ind = -1;
	while (0 < strlen(sp = (gpcmd_parm_vals + ind)->name)) /* implicit assignment intended */
	{
		if (0 == (res = STRNCMP_STR(sp, local_str, MAX_OPT_LEN))) /* implicit assignment intended */
		{
			if (-1 != match_ind)
				return (FALSE);
			else
				match_ind = ind;
		} else
		{
			if (0 < res)
				break;
		}
		ind++;
	}
	if (-1 != match_ind)
	{
		if (NULL == TAREF1(parm_ary, match_ind))
		{
			if (!((gpcmd_parm_vals + match_ind)->parm_required)) /* Value not required */
				return FALSE;
			/* If no value and required, prompt for it */
			PRINTF("%s", (gpcmd_parm_vals + match_ind)->prompt);
			fflush(stdout);
			gets_res = cli_fgets(local_str, MAX_LINE, stdin, FALSE);
			if (gets_res)
			{
				parm_len = STRLEN(gets_res);
				/* chop off newline */
				if (parm_len && (local_str[parm_len - 1] == '\n'))
				{
					local_str[parm_len - 1] = '\0';
					--parm_len;
				}
				TAREF1(parm_str_len, match_ind) = parm_len + 1;
				GROW_HEAP_IF_NEEDED(match_ind);
				if (parm_len)
					memcpy(TAREF1(parm_ary, match_ind), &local_str[0], parm_len);
				*(TAREF1(parm_ary, match_ind) + parm_len) = '\0';
			} else
			{	/* No string was returned so create a real ghost to point to.
				   Note that this should be revisited since this is NOT what should
				   be happening. We should be returning FALSE here but need to instead
				   return a null parm since current behaviors have a dependency on it
				   SE 10/2003
				 */
				TAREF1(parm_str_len, match_ind) = 1;
				GROW_HEAP_IF_NEEDED(match_ind);
				*TAREF1(parm_ary, match_ind) = '\0';
			}
		} else if (-1 == *TAREF1(parm_ary, match_ind) && 1 == TAREF1(parm_str_len, match_ind))
			return (FALSE);
		strcpy(val_buf, TAREF1(parm_ary, match_ind));
		if (!cli_look_next_token(&eof) || (0 == cli_gettoken(&eof)))
		{
			TAREF1(parm_str_len, match_ind) = 1;
			GROW_HEAP_IF_NEEDED(match_ind);
			*TAREF1(parm_ary, match_ind) = -1;
		} else
		{
			parm_len = STRLEN(cli_token_buf) + 1;
			if (MAX_LINE < parm_len)
			{
				PRINTF("Parameter string too long\n");
				fflush(stdout);
				return (FALSE);
			}
			TAREF1(parm_str_len, match_ind) = parm_len;
			GROW_HEAP_IF_NEEDED(match_ind);
			memcpy(TAREF1(parm_ary, match_ind), cli_token_buf, parm_len);
		}
	} else
	{
		/* -----------------
		 * check qualifiers
		 * -----------------
		 */
		if (!cli_get_value(local_str, val_buf))
			return (FALSE);
	}
	return (TRUE);
}
Ejemplo n.º 21
0
	/****************************************************************
	 * TclDoMethod:
	 ****************************************************************/
int TclDoMethod()
   {
    int   i;
    int   argc;
    int   sts;
    unsigned char  do_it;
    struct descriptor_xd xdarg[255];
    static int   nid;
    static unsigned short boolVal;
    static struct descriptor_s bool_dsc =
                    {sizeof(boolVal), DTYPE_W, CLASS_S, (char *)&boolVal};
    static struct descriptor nid_dsc = {4,DTYPE_NID,CLASS_S,(char *)&nid};
    static struct descriptor_xd empty_xd = {0,DTYPE_DSC,CLASS_XD,0,0};
    static DYNAMIC_DESCRIPTOR(arg);
    static DYNAMIC_DESCRIPTOR(if_clause);
    static DYNAMIC_DESCRIPTOR(method);
    static DYNAMIC_DESCRIPTOR(object);
    static void  *arglist[256] = {(void *)2,&nid_dsc,&method};

    cli_get_value("OBJECT",&object);
    sts = TreeFindNode(object.dscA_pointer,&nid);
    if (sts & 1)
       {
        do_it = (TreeIsOn(nid) | cli_present("OVERRIDE")) & 1;
        if (cli_present("IF") & 1)
           {
            cli_get_value("IF",&if_clause);
            sts = TdiExecute(&if_clause,&bool_dsc MDS_END_ARG);
            if (sts & 1)
                do_it = do_it && boolVal;
            else
                do_it = 0;
           }
        if (do_it)
           {
            int dometh_stat;
            DESCRIPTOR_LONG(dometh_stat_d,0);
            cli_get_value("METHOD",&method);
            argc = 0;
            if (cli_present("ARGUMENT") & 1)
               {
                while (cli_get_value("ARGUMENT",&arg) & 1)
                   {
                    xdarg[argc] = empty_xd;
                    sts = TdiCompile(&arg,&xdarg[argc] MDS_END_ARG);
                    if (sts & 1)
                       {
                        arglist[argc + 3] = xdarg[argc].dscA_pointer;
                        argc++;
                       }
                    else
                        break;
                   }
               }
            if (sts & 1)
               {
#ifdef vms
                arglist[0] = (void *)(argc + 2);
#else
                dometh_stat_d.dscA_pointer = (char *)&dometh_stat;
                arglist[argc+3] = &dometh_stat_d;
                arglist[argc+4] = MdsEND_ARG;
                arglist[0] = (argc + 4)+(char *)0;
#endif

		sts = (char *)LibCallg(arglist,TreeDoMethod)-(char *)0;
                if (sts & 1) sts = dometh_stat;
               }
            str_free1_dx(&arg);
            str_free1_dx(&method);
            for (i = 0; i < argc; i++)
                MdsFree1Dx(&xdarg[i],NULL);
           }
       }
    str_free1_dx(&object);
#ifdef vms
    if (!(sts & 1)) lib$signal(sts,0);
#else
	if (!(sts & 1))
	{
		char msg[512];
		sprintf(msg,"Error executing method - %s",MdsGetMsg(sts));
		TclTextOut(msg);
	}
#endif
    return sts;
   }
Ejemplo n.º 22
0
	/****************************************************************
	 * TclDirectory:
	 * Perform directory function
	 ****************************************************************/
int   TclDirectory()
   {
    unsigned int   usage;
    char  *tagnam;
    char  textLine[128];
    static char  fmtTotal[] = "Total of %d node%s.";
    static char  fmtGrandTotal[] = "Grand total of %d node%s.";
    static DYNAMIC_DESCRIPTOR(dsc_nodnam);
    static DYNAMIC_DESCRIPTOR(dsc_nodeList);
    static DYNAMIC_DESCRIPTOR(dsc_outline);
    char  *pathnam;

    int nid;
    int status;
    void  *ctx = 0;
    void  *ctx2 = 0;
    int   found = 0;
    int   grand_found = 0;
    int   first_tag;
    int   full;
    static int   nodnamLen;

    static int   retlen;
    int last_parent_nid = -1;
    int version;
    static int parent_nid;
    static char nodnamC[12+1];
    static int relationship;
    int previous_relationship;
    static unsigned char nodeUsage;
    static NCI_ITM general_info_list[] = {
          {4,NciPARENT,&parent_nid,0}
         ,{12,NciNODE_NAME,nodnamC,&nodnamLen}
         ,{4,NciPARENT_RELATIONSHIP,&relationship,0}
         ,{1,NciUSAGE,&nodeUsage,0}
         ,{0,NciEND_OF_LIST,0,0}
         };
    static int elmnt;
    static DYNAMIC_DESCRIPTOR(dsc_allUsage);
    static DYNAMIC_DESCRIPTOR(dsc_usageStr);
    int usageMask = -1;


    parent_nid = 0;

    full = cli_present("FULL") & 1;
    if (cli_present("USAGE") & 1)
       {
        usageMask = 0;
        str_free1_dx(&dsc_allUsage);
        while (cli_get_value("USAGE",&dsc_usageStr) & 1)
           {
            str_concat(&dsc_allUsage,&dsc_allUsage,&dsc_usageStr,",",0);

            str_concat(&dsc_usageStr,"USAGE.",&dsc_usageStr,0);
            if (cli_get_value(&dsc_usageStr,&dsc_usageStr) & 1)
               {
                sscanf(dsc_usageStr.dscA_pointer,"%d",&usage);
                usageMask = usageMask | (1 << usage);
               }
            else
                MdsMsg(0,"Error getting usage id#",0);
           }
       }
    str_free1_dx(&dsc_outline);
    while (cli_get_value("NODE",&dsc_nodeList) & 1)
       {
        l2u(dsc_nodeList.dscA_pointer,0);
        for (elmnt=0; str_element(&dsc_nodnam,elmnt,',',&dsc_nodeList) & 1; elmnt++)
           {
            while ((status = TreeFindNodeWild(dsc_nodnam.dscA_pointer,&nid,&ctx,usageMask)) & 1)
               {
                grand_found++;
                status = TreeGetNci(nid,general_info_list);
                nodnamC[nodnamLen] = '\0';
                if (parent_nid != last_parent_nid)
                   {
                    if (found)
                       {
                        if (!full && dsc_outline.dscW_length)
			{
                            TclTextOut(dsc_outline.dscA_pointer);
                            str_free1_dx(&dsc_outline);
                        }
                        TclTextOut("  ");
                        sprintf(textLine,fmtTotal,found,(found>1)?"s":"");
                        TclTextOut(textLine);
                       }
                    TclTextOut("  ");
                    pathnam = TreeGetPath(parent_nid);
                    TclTextOut(pathnam);
                    TreeFree(pathnam);		/* free the string	*/
                    TclTextOut("  ");
                    found = 0;
                    last_parent_nid = parent_nid;
                    previous_relationship = relationship;
                   }
                found++;
                if (full)
                   {
                    if (previous_relationship != relationship)
                       {
                        TclTextOut("  ");
                        previous_relationship = relationship;
                       }
                    if (relationship == NciK_IS_CHILD)
                        str_concat(&dsc_outline,"  ",nodnamC,0);
                    else
                        str_concat(&dsc_outline," :",nodnamC,0);

                    ctx2 = 0;
                    first_tag = 1;
                    while (tagnam = TreeFindNodeTags(nid,&ctx2))
                       {
                        str_concat(&dsc_outline,&dsc_outline,
                                (first_tag?" tags: \\":",\\"),tagnam,0);
                        TreeFree(tagnam);
                        first_tag = 0;
                       }
                    TclTextOut(dsc_outline.dscA_pointer);
                    str_free1_dx(&dsc_outline);
                    version=0;
                    while(doFull(nid,nodeUsage,version++)&1);
#ifdef vms
                    else
                      lib$signal(status,0);
#endif
                   }
                else
                   {
                    if (previous_relationship != relationship)
                       {
                        TclTextOut(dsc_outline.dscA_pointer);
                        str_free1_dx(&dsc_outline);
                        TclTextOut("  ");
                        previous_relationship = relationship;
                       }
                    if (relationship == NciK_IS_CHILD)
                        str_concat(&dsc_outline,
                            &dsc_outline,"  ",nodnamC,0);
                    else
                        str_concat(&dsc_outline,
                            &dsc_outline," :",nodnamC,0);
                    if (dsc_outline.dscW_length > 60)
                       {
                        TclTextOut(dsc_outline.dscA_pointer);
                        str_free1_dx(&dsc_outline);
                       }
                   }
               }
            TreeFindNodeEnd(&ctx);
           }
Ejemplo n.º 23
0
/****************************************************************
 * mdsdcl_do_macro:
 ****************************************************************/
int   mdsdcl_do_macro()		/* Return: status			*/
{
    int   i;
    int   icnt;
    int   irepeat;
    int   sts;
    char  prmName[4];
    struct _mdsdcl_io  *io;
    struct _mdsdcl_macro  *macro;
    static DYNAMIC_DESCRIPTOR(dsc_util);
    static char  fmt0[] = "Qualifier not supported:  use '@'";
    static char  fmt1[] = "No such command: '%s'";
    static char  fmt2[] = "Macro '%s' is already in use";
    static char  fmt3[] = "Exceeded MAX_DEPTH for indirect files & macros";
    struct _mdsdcl_ctrl  *ctrl = &MdsdclGetThreadStatic()->ctrl;

    sts = cli_get_value("NAME",&dsc_util);
    if (~sts & 1)
        return(MdsMsg(MDSDCL_STS_ERROR,"Error getting NAME"));

    if (cli_present("INTERACTIVE") & 1)
        return(MdsMsg(MDSDCL_STS_ERROR,fmt0,0));

    if (cli_present("INDIRECT") & 1)
    {
        sts = mdsdcl_openIndirectLevel(dsc_util.dscA_pointer);
        if (!sts & 1)
            return(MdsMsg(sts,"failed to open file %s",dsc_util.dscA_pointer));
        for ( ; sts & 1 ; )
            sts = mdsdcl_do_command(0);
        return((sts==MDSDCL_STS_INDIRECT_EOF) ? 1 : sts);
    }

    l2u(dsc_util.dscA_pointer,0);		/* convert to uc	*/
    macro = find_macro(dsc_util.dscA_pointer);
    if (!macro)
    {
        MdsMsg(0,"No such command");
        return(MDSDCL_STS_ERROR);
    }

    if (macro->isOpen)
        return(MdsMsg(MDSDCL_STS_ERROR,fmt2,dsc_util.dscA_pointer));

    /*=======================================================
     * Get repeat count ...
     *======================================================*/
    sts = cli_get_value("REPEAT",&dsc_util);
    if (sts & 1)
    {
        if (sscanf(dsc_util.dscA_pointer,"%d",&irepeat) != 1)
            irepeat = 1;
    }
    else
        irepeat = 1;

    /*========================================================
     * Create new ioLevel[] in ctrl struct ...
     *=======================================================*/
    if (ctrl->depth >= MAX_DEPTH)
        return(MdsMsg(MDSDCL_STS_INDIRECT_ERROR,fmt3,0));

    for (icnt=0 ; icnt<irepeat ; icnt++)
    {
        macro->isOpen = 1;
        io = ctrl->ioLevel + ++ctrl->depth;
        io->fp = 0;
        io->ioMacro = macro;
        io->lineno = 0;

        for (i=0 ; i<8 ; i++)
        {
            sprintf(prmName,"P%d",i+1);
            sts = cli_get_value(prmName,io->ioParameter+i);
            if (~sts & 1)
                break;
        }
        for ( ; i<8 ; i++)
            str_free1_dx(io->ioParameter+i);

        do {
            sts = mdsdcl_do_command(0);
        }  while (sts & 1);

        if (sts == MDSDCL_STS_INDIRECT_EOF)
            continue;
        else
            break;
    }

    return((sts==MDSDCL_STS_INDIRECT_EOF) ? 1 : sts);
}
Ejemplo n.º 24
0
//-------------------------------------------------------------------------
// Add a crate to the crate db
//-------------------------------------------------------------------------
int AddCrate()
{
	char	line[CRATE_ENTRY + 1];
	int		dbFileSize, fd, numOfEntries;
	int		status = SUCCESS;				// assume the best

	static DESCRIPTOR( phy_name_p, "PHY_NAME" );
	static DYNAMIC_DESCRIPTOR( phy_name );

	// get user input
	str_free1_dx(&phy_name);				// per twf -- clear out field
	cli_get_value( &phy_name_p, &phy_name );
	str_upcase( &phy_name, &phy_name );

	// [2002.01.08]
	if( CRATEdbFileIsMapped == FALSE ) {					// ... no
		if( check_for_file(CRATE_DB_FILE) != SUCCESS ) {	// ... no
			if( (fd = Creat(CRATE_DB_FILE, 0666)) == ERROR ) {	// no
				status = FAILURE;
				goto AddCrate_Exit;
			}
			else
				close(fd);										// yes
		}

		if( map_data_file(CRATE_DB) != SUCCESS ) {			// failure :(
			status = MAP_ERROR;
			goto AddCrate_Exit;
		} 													// else OK :)
	}

	// get current db file count
	if( (numOfEntries = get_file_count(CRATE_DB)) == FILE_ERROR ) {
		status = FAILURE;			// FILE_ERROR;		[2001.07.12]
		goto AddCrate_Exit;
	}

	if( numOfEntries ) {		// 1 or more
                char pname[7];
                sprintf(pname,"%.6s",phy_name.pointer);
		if( lookup_entry(CRATE_DB, pname) >= 0 ) {			// duplicate !
			if( MSGLVL(IMPORTANT) )
				fprintf( stderr, "duplicate crate name '%.6s' -- not allowed\n", phy_name.pointer );

			status = FAILURE;		// DUPLICATE;		[2001.07.12]
			goto AddCrate_Exit;
		}
	}

	// get db file size
	if( (dbFileSize = get_db_file_size(CRATE_DB_FILE)) == ERROR ) {
		status = FAILURE;			// FILE_ERROR;		[2001.07.12]
		goto AddCrate_Exit;
	}
	dbFileSize /= CRATE_ENTRY;	// .. current maximum number of possible crate entries

	// do we need to expand db file?
	if( (dbFileSize == 0) || (numOfEntries == dbFileSize) ) {				// ... yes
		if( (status = expand_db(CRATE_DB, numOfEntries)) != SUCCESS ) {		// expand
			status = FAILURE;	// EXPAND_ERROR; [2001.07.12]											// failure
			goto AddCrate_Exit;
		}
	}		// else OK

	// make an entry line, with online and enhanced set as undefined
	sprintf( line, "%-.6s:...:.:.:.\n",
		phy_name.pointer
		);

	// add it ...
	if( (status = add_entry(CRATE_DB, line)) != SUCCESS ) {
		status = FAILURE;			// ASSIGN_ERROR;		[2001.07.12]
		goto AddCrate_Exit;
	}

AddCrate_Exit:
	if( MSGLVL(DETAILS) ) {
		printf("AddCrate(): "); ShowStatus(status);
	}

	if( status == SUCCESS )			// if everything is OK ...
		Autoconfig();				// ... map crate to /dev/sg#

//ShowCrate();
	return status;
}
Ejemplo n.º 25
0
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
int ShowModule()
{
	char	db_tmp[64];		// enough space for a logical name and a cstring terminator	[2002.02.20]
	int 	i, numOfEntries, status = SUCCESS;

	static DESCRIPTOR( physical, "PHYSICAL" );
	static DESCRIPTOR( module_p, "MODULE" );
	static DESCRIPTOR( format_p, "FORMAT" );
	static DESCRIPTOR( blank, " " );

	static DESCRIPTOR( heading1, "  #  Logical Name                     Physical   Comment" );	// header
	static DESCRIPTOR( heading2, "==== ================================ ========== ========================================" );

	static DYNAMIC_DESCRIPTOR( wild );
	struct Module_	Mod, *pMod;
	
	struct descriptor pattern;

	int format = cli_present(&format_p) & 1;
	int physical_name = cli_present(&physical) & 1;	// 2002.01.16

	cli_get_value( &module_p, &wild );
	StrUpcase( &wild, &wild );						// convert to upper case

	if( MSGLVL(DETAILS) )
		printf("ShowModule(): in %s order\n", (physical_name) ? "physical" : "logical" );

	// check to see if db file memory mapped
	if( CTSdbFileIsMapped == FALSE ) {				// is not, so try
		if( map_data_file(CTS_DB) != SUCCESS ) {	// we're dead in the water
			if( MSGLVL(IMPORTANT) )
				fprintf( stderr, "error memory mapping database file\n" );

			status = FAILURE;		// MAP_ERROR;		[2001.07.12]
			goto Showmodule_Exit;
		}
	}

	// db file now mapped, continue
	pMod = &Mod;										// point to some actual storage
	if( (numOfEntries = get_file_count(CTS_DB)) > 0 ) {	// something to show
		printf( "%s\n",   heading1.pointer );
		printf( "%s%d\n", heading2.pointer, numOfEntries );
		for( i = 0; i < numOfEntries; i++ ) {
			parse_cts_db( CTSdb+i, pMod );		// extract info from db

			memset(db_tmp, ' ', 32);
			db_tmp[33] = '\0';

			if( physical_name ) 		// duh, physical name
				sprintf( db_tmp, "GK%c%d%02d:N%d", 
					pMod->adapter + 'A', pMod->id, pMod->crate, pMod->slot
					);
			else
				sprintf( db_tmp, "%s", pMod->name );

			pattern.pointer = db_tmp;
			pattern.length  = strlen(db_tmp);

			if( StrMatchWild( &pattern, &wild ) & 1 ) {
//				printf( "%s%3d: %.84s<%s\n", CYAN, i+1, (char *)CTSdb+(i * MODULE_ENTRY), NORMAL );	// fancy, with color
				printf( "%3d: %.84s<\n", i+1, (char *)CTSdb+(i * MODULE_ENTRY) );
			}

		} // end of for() loop

		printf( "%s\n", heading2.pointer );
	}
	else {
		if( MSGLVL(IMPORTANT) )
			fprintf( stderr, "db file is empty, no modules to show\n" );

		status = SUCCESS;		// Not necessarily an ERROR;	[2002.02.19]
		goto Showmodule_Exit;
	}
	
Showmodule_Exit:
	if( MSGLVL(DETAILS) ) {
		printf("ShowModule(): "); ShowStatus(status);
	}

	return status;
}
Ejemplo n.º 26
0
//-------------------------------------------------------------------------
// assign a new module to CTS database
//-------------------------------------------------------------------------
int Assign()
{
	char	line[MODULE_ENTRY+1];
	int		dbFileSize, fd, i, nullMask, numOfEntries, rc;
	int		status = SUCCESS;				// assume the best

	static DESCRIPTOR( phy_name_p, "PHY_NAME" );
	static DYNAMIC_DESCRIPTOR( phy_name );

	static DESCRIPTOR( log_name_p, "LOG_NAME" );
	static DYNAMIC_DESCRIPTOR( log_name );

	static DESCRIPTOR( comment_p, "COMMENT" );
	static DYNAMIC_DESCRIPTOR( comment );

	// get user input
	cli_get_value( &phy_name_p, &phy_name );
	str_upcase( &phy_name, &phy_name );

	cli_get_value( &log_name_p, &log_name );
	str_upcase( &log_name, &log_name );

	str_free1_dx(&comment);					// per twf -- clear out comment field
	cli_get_value( &comment_p, &comment );

	// check to see if db file exists
	if( check_for_file(CTS_DB_FILE) != SUCCESS ) {	// does not exist, yet
		// try to creat (sic) it
		if( (fd = Creat(CTS_DB_FILE, 0666)) == ERROR ) {
			status = FAILURE;				// FILE_ERROR;		[2001.07.12]
			goto Assign_Exit;				// we're done  :<
		}
		else
			close(fd);
	}

	// check to see if db file is memory mapped
	if( CTSdbFileIsMapped == FALSE ) {				// is not, so try
		if( map_data_file(CTS_DB) != SUCCESS ) {	// we're dead in the water
			status = FAILURE;		// MAP_ERROR;		[2001.07.12]
			goto Assign_Exit;
		}
	}

	// get current db file count
	if( (numOfEntries = get_file_count(CTS_DB)) < 0 ) {
		status = FAILURE;			// FILE_ERROR;		[2001.07.12]
		goto Assign_Exit;
	}

	if( numOfEntries ) {		// 1 or more
		if( lookup_entry(CTS_DB, log_name.pointer) >= 0 ) {	// duplicate !
			if( MSGLVL(IMPORTANT) )
				fprintf( stderr, "duplicate module name '%s' -- not allowed\n", log_name.pointer );

			status = FAILURE;		// DUPLICATE;		[2001.07.12]
			goto Assign_Exit;
		}
	}

	// get db file size
	if( (dbFileSize = get_db_file_size(CTS_DB_FILE)) == ERROR ) {
		status = FAILURE;			// FILE_ERROR;		[2001.07.12]
		goto Assign_Exit;
	}
	dbFileSize /= MODULE_ENTRY;	// .. current maximum number of possible module entries

	// do we need to expand db file?
	if( (dbFileSize == 0) || (numOfEntries == dbFileSize) ) {		// ... yes
		if( expand_db(CTS_DB, numOfEntries) != SUCCESS ) {			// expand ...
			status = FAILURE;		// EXPAND_ERROR; [2001.07.12]	// ... failure
			goto Assign_Exit;
		}
	}		// else OK

	// create a temporary string
	sprintf( line, "%-32s %-10s %-40s\n", 
		log_name.pointer, 								// these were entered by the user
		phy_name.pointer, 
		comment.pointer ? comment.pointer : ""
		);

	// check comment field for null string, ie "(null)"
	nullMask = (1 << strlen(nullStr)) - 1;				// set all mask bits
	for( i = COMMENT_INDEX; i < COMMENT_INDEX + strlen(nullStr); ++i )
		if( line[i] == nullStr[i - COMMENT_INDEX] )
			nullMask &= ~(1 << (i - COMMENT_INDEX));	// clear a bit in mask

	if( nullMask == 0 )									// all mask bit have been reset, ie matched
		for( i = COMMENT_INDEX; i < COMMENT_INDEX + strlen(nullStr); ++i ) 
			line[i] = ' ';								// make it spaces

	// add it ...
	if( add_entry(CTS_DB, line) != SUCCESS ) {
		status = FAILURE;		// ASSIGN_ERROR;		[2001.07.12]
		goto Assign_Exit;
	}

#if NEED_WARM_N_FUZZY
	// write to a buffer file for a warm fuzzy ...
	if( (fd = Creat("buffer.db", 0666)) == ERROR ) {
		if( MSGLVL(ALWAYS) )
			perror("creat()");

		status = FAILURE;		// FILE_ERROR;			[2001.07.12]
		goto Assign_Exit;
	}

	rc = write(fd, line, sizeof(line));
	close(fd);
	if( rc != sizeof(line) ) {
		if( MSGLVL(ALWAYS) )
			perror("write()");

		status = FAILURE;		// FILE_ERROR;			[2001.07.12]
	}
#endif

Assign_Exit:			// we're done, so out'a here!
	if( MSGLVL(DETAILS) ) {
		printf("Assign(): "); ShowStatus(status);
	}

	return status;
}