/*************************************************************** * 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; }
/***************************************************************** * 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; }
void main() { MdsMsg(MDSDCL_STS_SUCCESS,0); MDSprintf("\n"); MdsMsg(CLI_STS_PRESENT,0); MDSprintf("\n"); MdsMsg(CCL_STS_SUCCESS,0); MDSprintf("\n"); MdsMsg(TCL_STS_SUCCESS,0); MDSprintf("\n"); MdsMsg(TreeNORMAL,0); MDSprintf("\n"); MdsMsg(LibNOTFOU,0); MDSprintf("\n"); MdsMsg(StrMATCH,0); MDSprintf("\n"); MdsMsg(SsINTOVF,0); MDSprintf("\n"); }
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); }
/**************************************************************** * 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); }
/*************************************************************** * 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; }
/***************************************************************** * 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; }
/**************************************************************** * 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); }
/**************************************************************** * mdsdcl_do_command: * Effectively, the main MDSDCL routine ... ****************************************************************/ int mdsdcl_do_command( void *command /* <r:opt> command -- cstring or dsc */ ) { int tblidx; int sts,stsParse; int tried_indirect = 0; struct _mdsdcl_io *io; static char doMacro[12]; static DYNAMIC_DESCRIPTOR(dsc_cmd); struct _mdsdcl_ctrl *ctrl = &MdsdclGetThreadStatic()->ctrl; #ifdef vms extern int MDSDCL$MSG_TO_RET(); extern int MDSDCL$OUT_OF_BAND_AST(); #endif /*--------------------------------------------------------------- * Executable: *--------------------------------------------------------------*/ LockMdsShrMutex(&mdsdclMutex,&mdsdclMutex_initialized); if (!ctrl->tbladr[0]) mdsdcl_initialize(ctrl); tblidx = ctrl->tables; if (!doMacro[0]) { /* first time ... */ sprintf(doMacro,"DO %cMACRO ",'/'); } io = ctrl->ioLevel + ctrl->depth; if (command) { str_trim(&io->last_command,command); str_copy_dx(&dsc_cmd,&io->last_command); mdsdcl_insert_symbols(io->ioParameter,&dsc_cmd); } else { str_free1_dx(&io->last_command); str_free1_dx(&dsc_cmd); } /*------------------------------------------------------- * Try each table in turn ... *------------------------------------------------------*/ for ( ; tblidx>0 ; tblidx--) { do { stsParse = mdsdcl_dcl_parse(&dsc_cmd,ctrl,tblidx); } while(stsParse == CLI_STS_NOCOMD); /* 25-Feb-03: ignore blank lines -- TRG */ if (~stsParse & 1) { if ((stsParse == CLI_STS_EOF) || (stsParse == CLI_STS_NOCOMD)) { UnlockMdsShrMutex(&mdsdclMutex); return(stsParse); } else if (stsParse == MDSDCL_STS_INDIRECT_EOF) { UnlockMdsShrMutex(&mdsdclMutex); return(stsParse); /*--------------------> return */ } } io = ctrl->ioLevel + ctrl->depth; if (!dsc_cmd.dscA_pointer) str_copy_dx(&dsc_cmd,&io->last_command); if (stsParse & 1) { /* Try to dispatch the routine ... */ sts = cli_dispatch(ctrl); if (sts != CLI_STS_INVROUT) { if (ctrl->verify && sts != 3) displayCmdline(dsc_cmd.dscA_pointer); if (~sts & 1) { if (dsc_cmd.dscA_pointer) MdsMsg(0,"--> failed on line '%s'", dsc_cmd.dscA_pointer); mdsdcl_close_indirect_all(); } UnlockMdsShrMutex(&mdsdclMutex); return(sts); /*--------------------> return */ } } } /*------------------------------------------------------- * Command not found in any table: try it as a macro ... *------------------------------------------------------*/ if (ctrl->verify) displayCmdline(dsc_cmd.dscA_pointer); tblidx = 1; /* i.e., the table for DO/MACRO */ str_prefix(&dsc_cmd,doMacro); sts = mdsdcl_dcl_parse(&dsc_cmd,ctrl,tblidx); if (sts & 1) { /* Try to dispatch the macro ... */ sts = cli_dispatch(ctrl); } else if (sts == CLI_STS_IVQUAL) { MdsMsg(0,"No such command"); /* CLI_STS_IVQUAL msg is suppressed * by cli_process_qualifier() */ } if (~sts & 1) mdsdcl_close_indirect_all(); UnlockMdsShrMutex(&mdsdclMutex); return(sts); /*--------------------> return */ }
/**************************************************************** * 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); }
/**************************************************************** * 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; }
/**************************************************************** * mdsdcl_dcl_parse: *****************************************************************/ int mdsdcl_dcl_parse( /* Returns CLI_STS_xxx status */ void *command /* <r:opt> command string */ ,struct _mdsdcl_ctrl *ctrl /* <m> control structure */ ,int tabidx /* <r> cmd table idx, 1-based */ ) { int indirect_flag; int nbytes; int sts; char *p; struct _mdsdcl_io *io; struct descriptor *dsc; static char *cmd; /* addr of private cmd string */ static int maxcmd; /* current length of cmd[] */ static char doIndirect[16]; static DYNAMIC_DESCRIPTOR(dsc_filename); #ifdef vms extern mdsdcl$dcl_parse_handler(); #endif #ifdef vms if (tabidx > 1) lib$establish(lib$sig_to_ret); else lib$establish(mdsdcl$dcl_parse_handler); #endif if (!doIndirect[0]) { /* first time ... */ sprintf(doIndirect,"DO %cINDIRECT",QUALIFIER_CHARACTER); } /*------------------------------------------------------- * Copy optional "command" to cmd, checking for '@' ... *------------------------------------------------------*/ if (command && (is_cdescr(command) || is_ddescr(command))) { dsc = command; p = nonblank(dsc->dscA_pointer); } else p = nonblank(command); if (!p) { /* command string is null ... */ sts = cli_dcl_parse(0,ctrl->tbladr[tabidx-1], mdsdcl_get_input,mdsdcl_get_input,&ctrl->prompt); dsc = cli_addr_cmdline_dsc(); io = ctrl->ioLevel + ctrl->depth; str_copy_dx(&io->last_command,dsc); } else { /* else, p is start of command string ... */ nbytes = 0; if (indirect_flag = (*p == '@')) { p = nonblank(p+1); /* skip the '@' */ nbytes = sizeof(doIndirect) - 1; if (!ascFilename(&p,&dsc_filename,0)) return(MdsMsg(MDSDCL_STS_INDIRECT_ERROR, "Illegal filename: %s",p?p:"")); nbytes += strlen(dsc_filename.dscA_pointer) + 3; /* 2 quotes + blank */ } nbytes += p ? strlen(p) + 1 : 0; if (nbytes > maxcmd) { /*----- allocate enough space for cmd[] ------*/ maxcmd = (nbytes>79) ? nbytes : 79; if (cmd) free(cmd); cmd = malloc(maxcmd); if (!cmd) { fprintf(stderr,"mdsdcl_dcl_parse: Out of space!\n"); exit(0); } } if (indirect_flag) sprintf(cmd,"%s \"%s\" %s", doIndirect,dsc_filename.dscA_pointer,p?p:""); else strcpy(cmd,p?p:""); sts = cli_dcl_parse(cmd,ctrl->tbladr[tabidx-1], mdsdcl_get_input,mdsdcl_get_input,&ctrl->prompt); } return(sts); }