--- /ligo/apps/epics-3.14.12_long/extensions/src/medm/medm/utils.c.orig 2015-01-13 18:56:44.867720104 -0800 +++ /ligo/apps/epics-3.14.12_long/extensions/src/medm/medm/utils.c 2015-01-13 22:49:56.636820963 -0800 @@ -4156,6 +4156,37 @@ timeOffset = time900101 - time700101; } +#if((2*MAX_TRACES)+2) > MAX_PENS +#define MAX_COUNT 2*MAX_TRACES+2 +#else +#define MAX_COUNT MAX_PENS +#endif +void recursivePrint(DlElement *pE, FILE *f) { + UpdateTask *pT; + Record *records[MAX_COUNT]; + int j, count; + + while (pE) { + pT = getUpdateTaskFromElement(pE); + if (pT && pT->getRecord) { + pT->getRecord(pT->clientData, records, &count); + count %= 100; /* count > 100 encodes widget columns; see getPvInfoFromDisplay() */ + if (count) { + for(j=0; j < count; j++) { + if (records[j] && records[j]->name) { + fprintf(f, "%d %s\n", pE->type, records[j]->name); + } + } + } + } + else if (pE->type == DL_Composite) { + recursivePrint(FirstDlElement((pE->structure.composite)->dlElementList), f); + } + pE = pE->next; + } +} +#undef MAX_COUNT + void parseAndExecCommand(DisplayInfo *displayInfo, char * cmd) { char *name, *title; @@ -4165,6 +4196,7 @@ int i, j, ic, len, clen, count; unsigned u = 0; DlElement *pE; + int chandump = 0; #ifdef VMS #include @@ -4184,6 +4216,10 @@ *(command+ic) = *(cmd+i); ic++; } else { switch(cmd[i+1]) { + case 'D': + chandump = 1; + i++; + break; case 'P': /* Get the names */ records = getPvInfoFromDisplay(displayInfo, &count, &pE); @@ -4291,7 +4327,23 @@ #ifndef VMS /* KE: This blocks unless the command includes & (on UNIX) */ /* It should probably be fixed for WIN32 */ - system(command); + { + if (chandump) { + FILE *f; + f = popen(command, "w"); + fprintf(f, "%s\n", displayInfo->dlFile->name); + for(i = 0; i < displayInfo->numNameValues; i++) { + if (i > 0) fprintf(f, ","); + fprintf(f, "%s=%s", displayInfo->nameValueTable[i].name, + displayInfo->nameValueTable[i].value); + } + fprintf(f, "\n"); + recursivePrint(FirstDlElement(displayInfo->dlElementList), f); + pclose(f); + } else { + system(command); + } + } #else /* ACM: This does not block the whole application, but spawns a command */ cmdDesc.dsc$w_length = strlen(command);