dbStatic: collect promptgroup enum choices when reading dbd
This commit is contained in:
@@ -165,8 +165,9 @@ typedef struct dbBase {
|
||||
ELLLIST functionList;
|
||||
ELLLIST variableList;
|
||||
ELLLIST bptList;
|
||||
ELLLIST filterList;
|
||||
void *pathPvt;
|
||||
ELLLIST filterList;
|
||||
ELLLIST guiGroupList;
|
||||
void *pathPvt;
|
||||
struct dbPvd *ppvd;
|
||||
struct gphPvt *pgpHash;
|
||||
short ignoreMissingMenus;
|
||||
|
||||
@@ -71,6 +71,7 @@ static void dbRecordtypeEmpty(void);
|
||||
static void dbRecordtypeBody(void);
|
||||
static void dbRecordtypeFieldHead(char *name,char *type);
|
||||
static void dbRecordtypeFieldItem(char *name,char *value);
|
||||
static short findOrAddGuiGroup(const char *name);
|
||||
|
||||
static void dbDevice(char *recordtype,char *linktype,
|
||||
char *dsetname,char *choicestring);
|
||||
@@ -495,7 +496,23 @@ static void dbRecordtypeFieldHead(char *name,char *type)
|
||||
yyerrorAbort("Illegal Field Type");
|
||||
pdbFldDes->field_type = i;
|
||||
}
|
||||
|
||||
|
||||
static short findOrAddGuiGroup(const char *name)
|
||||
{
|
||||
dbGuiGroup *pdbGuiGroup;
|
||||
GPHENTRY *pgphentry;
|
||||
pgphentry = gphFind(pdbbase->pgpHash, name, &pdbbase->guiGroupList);
|
||||
if (!pgphentry) {
|
||||
pdbGuiGroup = dbCalloc(1,sizeof(dbGuiGroup));
|
||||
pdbGuiGroup->name = epicsStrDup(name);
|
||||
ellAdd(&pdbbase->guiGroupList, &pdbGuiGroup->node);
|
||||
pdbGuiGroup->key = ellCount(&pdbbase->guiGroupList);
|
||||
pgphentry = gphAdd(pdbbase->pgpHash, pdbGuiGroup->name, &pdbbase->guiGroupList);
|
||||
pgphentry->userPvt = pdbGuiGroup;
|
||||
}
|
||||
return ((dbGuiGroup *)pgphentry->userPvt)->key;
|
||||
}
|
||||
|
||||
static void dbRecordtypeFieldItem(char *name,char *value)
|
||||
{
|
||||
dbFldDes *pdbFldDes;
|
||||
@@ -517,14 +534,7 @@ static void dbRecordtypeFieldItem(char *name,char *value)
|
||||
return;
|
||||
}
|
||||
if(strcmp(name,"promptgroup")==0) {
|
||||
int i;
|
||||
for(i=0; i<GUI_NTYPES; i++) {
|
||||
if(strcmp(value,pamapguiGroup[i].strvalue)==0) {
|
||||
pdbFldDes->promptgroup = pamapguiGroup[i].value;
|
||||
return;
|
||||
}
|
||||
}
|
||||
yyerror("Illegal promptgroup. See guigroup.h for legal values");
|
||||
pdbFldDes->promptgroup = findOrAddGuiGroup(value);
|
||||
return;
|
||||
}
|
||||
if(strcmp(name,"prompt")==0) {
|
||||
|
||||
@@ -417,6 +417,7 @@ dbBase * dbAllocBase(void)
|
||||
ellInit(&pdbbase->variableList);
|
||||
ellInit(&pdbbase->bptList);
|
||||
ellInit(&pdbbase->filterList);
|
||||
ellInit(&pdbbase->guiGroupList);
|
||||
gphInitPvt(&pdbbase->pgpHash,256);
|
||||
dbPvdInitPvt(pdbbase);
|
||||
return (pdbbase);
|
||||
@@ -442,8 +443,10 @@ void dbFreeBase(dbBase *pdbbase)
|
||||
drvSup *pdrvSupNext;
|
||||
brkTable *pbrkTable;
|
||||
brkTable *pbrkTableNext;
|
||||
chFilterPlugin *pfilt;
|
||||
chFilterPlugin *pfiltNext;
|
||||
chFilterPlugin *pfilt;
|
||||
chFilterPlugin *pfiltNext;
|
||||
dbGuiGroup *pguiGroup;
|
||||
dbGuiGroup *pguiGroupNext;
|
||||
int i;
|
||||
DBENTRY dbentry;
|
||||
|
||||
@@ -584,6 +587,15 @@ void dbFreeBase(dbBase *pdbbase)
|
||||
free(pfilt);
|
||||
pfilt = pfiltNext;
|
||||
}
|
||||
pguiGroup = (dbGuiGroup *)ellFirst(&pdbbase->guiGroupList);
|
||||
while (pguiGroup) {
|
||||
pguiGroupNext = (dbGuiGroup *)ellNext(&pguiGroup->node);
|
||||
gphDelete(pdbbase->pgpHash, pguiGroup->name, &pdbbase->guiGroupList);
|
||||
ellDelete(&pdbbase->bptList, &pguiGroup->node);
|
||||
free(pguiGroup->name);
|
||||
free((void *)pguiGroup);
|
||||
pguiGroup = pguiGroupNext;
|
||||
}
|
||||
gphFreeMem(pdbbase->pgpHash);
|
||||
dbPvdFreeMem(pdbbase);
|
||||
dbFreePath(pdbbase);
|
||||
@@ -738,6 +750,31 @@ static long dbAddOnePath (DBBASE *pdbbase, const char *path, unsigned length)
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *dbGetPromptGroupNameFromKey(DBBASE *pdbbase, const short key)
|
||||
{
|
||||
dbGuiGroup *pdbGuiGroup;
|
||||
|
||||
if (!pdbbase) return NULL;
|
||||
for (pdbGuiGroup = (dbGuiGroup *)ellFirst(&pdbbase->guiGroupList);
|
||||
pdbGuiGroup; pdbGuiGroup = (dbGuiGroup *)ellNext(&pdbGuiGroup->node)) {
|
||||
if (pdbGuiGroup->key == key) return pdbGuiGroup->name;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
short dbGetPromptGroupKeyFromName(DBBASE *pdbbase, const char *name)
|
||||
{
|
||||
GPHENTRY *pgphentry;
|
||||
|
||||
if (!pdbbase) return 0;
|
||||
pgphentry = gphFind(pdbbase->pgpHash, name, &pdbbase->guiGroupList);
|
||||
if (!pgphentry) {
|
||||
return 0;
|
||||
} else {
|
||||
return ((dbGuiGroup*)pgphentry->userPvt)->key;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
long dbWriteRecord(DBBASE *ppdbbase,const char *filename,
|
||||
const char *precordTypename,int level)
|
||||
@@ -937,16 +974,11 @@ long dbWriteRecordTypeFP(
|
||||
fprintf(fp,"\t\tprompt(\"%s\")\n",pdbFldDes->prompt);
|
||||
if(pdbFldDes->initial)
|
||||
fprintf(fp,"\t\tinitial(\"%s\")\n",pdbFldDes->initial);
|
||||
if(pdbFldDes->promptgroup) {
|
||||
for(j=0; j<GUI_NTYPES; j++) {
|
||||
if(pamapguiGroup[j].value == pdbFldDes->promptgroup) {
|
||||
fprintf(fp,"\t\tpromptgroup(%s)\n",
|
||||
pamapguiGroup[j].strvalue);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(pdbFldDes->special) {
|
||||
if (pdbFldDes->promptgroup) {
|
||||
fprintf(fp,"\t\tpromptgroup(\"%s\")\n",
|
||||
dbGetPromptGroupNameFromKey(pdbbase, pdbFldDes->promptgroup));
|
||||
}
|
||||
if(pdbFldDes->special) {
|
||||
if(pdbFldDes->special >= SPC_NTYPES) {
|
||||
fprintf(fp,"\t\tspecial(%d)\n",pdbFldDes->special);
|
||||
} else for(j=0; j<SPC_NTYPES; j++) {
|
||||
@@ -3183,14 +3215,9 @@ void dbDumpField(
|
||||
if(!pdbFldDes->promptgroup) {
|
||||
printf("\t promptgroup: %d\n",pdbFldDes->promptgroup);
|
||||
} else {
|
||||
for(j=0; j<GUI_NTYPES; j++) {
|
||||
if(pamapguiGroup[j].value == pdbFldDes->promptgroup) {
|
||||
printf("\t promptgroup: %s\n",
|
||||
pamapguiGroup[j].strvalue);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
printf("\t promptgroup: %s\n",
|
||||
dbGetPromptGroupNameFromKey(pdbbase, pdbFldDes->promptgroup));
|
||||
}
|
||||
printf("\t interest: %hd\n", pdbFldDes->interest);
|
||||
printf("\t as_level: %d\n",pdbFldDes->as_level);
|
||||
printf("\t initial: %s\n",
|
||||
|
||||
@@ -81,6 +81,10 @@ epicsShareFunc long dbReadDatabaseFP(DBBASE **ppdbbase,
|
||||
FILE *fp, const char *path, const char *substitutions);
|
||||
epicsShareFunc long dbPath(DBBASE *pdbbase, const char *path);
|
||||
epicsShareFunc long dbAddPath(DBBASE *pdbbase, const char *path);
|
||||
epicsShareFunc char * dbGetPromptGroupNameFromKey(DBBASE *pdbbase,
|
||||
const short key);
|
||||
epicsShareFunc short dbGetPromptGroupKeyFromName(DBBASE *pdbbase,
|
||||
const char *name);
|
||||
epicsShareFunc long dbWriteRecord(DBBASE *ppdbbase,
|
||||
const char *filename, const char *precordTypename, int level);
|
||||
epicsShareFunc long dbWriteRecordFP(DBBASE *ppdbbase,
|
||||
|
||||
@@ -42,6 +42,13 @@ typedef struct dbPathNode {
|
||||
char *directory;
|
||||
} dbPathNode;
|
||||
|
||||
/* Element of the global gui group list */
|
||||
typedef struct dbGuiGroup {
|
||||
ELLNODE node;
|
||||
short key;
|
||||
char *name;
|
||||
} dbGuiGroup;
|
||||
|
||||
/*The following are in dbPvdLib.c*/
|
||||
/*directory*/
|
||||
typedef struct{
|
||||
|
||||
Reference in New Issue
Block a user