Merged Dirk Zimoch's info_fields branch into 3.16
Used --squash to drop noisy history. Modified the dbli output format slightly.
This commit is contained in:
@@ -19,6 +19,14 @@
|
||||
|
||||
-->
|
||||
|
||||
<h3>Finding info fields</h3>
|
||||
|
||||
<p>A new iocsh command <code>dbli</code> lists the info fields defined in the
|
||||
database, and can take a glob pattern to limit output to specific info names.
|
||||
The newly added dbStaticLib function <code>dbNextMatchingInfo()</code> iterates
|
||||
through the info fields defined in the current record, and is used to implement
|
||||
the new command.</p>
|
||||
|
||||
<h3>Output from <tt>dbpr</tt> command enhanced</h3>
|
||||
|
||||
<p>The "DataBase Print Record" command <tt>dbpr</tt> now generates slightly
|
||||
|
||||
@@ -152,6 +152,12 @@ static const iocshArg * const dbnrArgs[1] = {&dbnrArg0};
|
||||
static const iocshFuncDef dbnrFuncDef = {"dbnr",1,dbnrArgs};
|
||||
static void dbnrCallFunc(const iocshArgBuf *args) { dbnr(args[0].ival);}
|
||||
|
||||
/* dbli */
|
||||
static const iocshArg dbliArg0 = { "pattern",iocshArgString};
|
||||
static const iocshArg * const dbliArgs[1] = {&dbliArg0};
|
||||
static const iocshFuncDef dbliFuncDef = {"dbli",1,dbliArgs};
|
||||
static void dbliCallFunc(const iocshArgBuf *args) { dbli(args[0].sval);}
|
||||
|
||||
/* dbla */
|
||||
static const iocshArg dblaArg0 = { "pattern",iocshArgString};
|
||||
static const iocshArg * const dblaArgs[1] = {&dblaArg0};
|
||||
@@ -415,6 +421,7 @@ void dbIocRegister(void)
|
||||
iocshRegister(&dblFuncDef,dblCallFunc);
|
||||
iocshRegister(&dbnrFuncDef,dbnrCallFunc);
|
||||
iocshRegister(&dblaFuncDef,dblaCallFunc);
|
||||
iocshRegister(&dbliFuncDef,dbliCallFunc);
|
||||
iocshRegister(&dbgrepFuncDef,dbgrepCallFunc);
|
||||
iocshRegister(&dbgfFuncDef,dbgfCallFunc);
|
||||
iocshRegister(&dbpfFuncDef,dbpfCallFunc);
|
||||
|
||||
@@ -258,7 +258,30 @@ long dbla(const char *pmask)
|
||||
dbFinishEntry(pdbentry);
|
||||
return 0;
|
||||
}
|
||||
|
||||
long dbli(const char *pattern)
|
||||
{
|
||||
DBENTRY dbentry;
|
||||
void* ptr;
|
||||
|
||||
if (!pdbbase) {
|
||||
printf("No database loaded\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
dbInitEntry(pdbbase, &dbentry);
|
||||
while (dbNextMatchingInfo(&dbentry, pattern) == 0)
|
||||
{
|
||||
printf("%s info(%s, \"%s\"", dbGetRecordName(&dbentry),
|
||||
dbGetInfoName(&dbentry), dbGetInfoString(&dbentry));
|
||||
if ((ptr = dbGetInfoPointer(&dbentry)) != NULL)
|
||||
printf(", %p", ptr);
|
||||
printf(")\n");
|
||||
}
|
||||
dbFinishEntry(&dbentry);
|
||||
return 0;
|
||||
}
|
||||
|
||||
long dbgrep(const char *pmask)
|
||||
{
|
||||
DBENTRY dbentry;
|
||||
|
||||
@@ -25,6 +25,8 @@ epicsShareFunc long dbl(
|
||||
epicsShareFunc long dbnr(int verbose);
|
||||
/* list aliases */
|
||||
epicsShareFunc long dbla(const char *pmask);
|
||||
/* list infos */
|
||||
epicsShareFunc long dbli(const char *patern);
|
||||
/*list records with mask*/
|
||||
epicsShareFunc long dbgrep(const char *pmask);
|
||||
/*get field value*/
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
record(x, "testrec") {
|
||||
info("A", "B")
|
||||
alias("testalias")
|
||||
info("A", "B")
|
||||
}
|
||||
|
||||
alias("testrec", "testalias2")
|
||||
|
||||
@@ -2716,6 +2716,32 @@ long dbNextInfo(DBENTRY *pdbentry)
|
||||
return (pinfo ? 0 : S_dbLib_infoNotFound);
|
||||
}
|
||||
|
||||
long dbNextMatchingInfo(DBENTRY *pdbentry, const char *pattern)
|
||||
{
|
||||
long status;
|
||||
|
||||
if (!pdbentry->precordType)
|
||||
{
|
||||
status = dbFirstRecordType(pdbentry);
|
||||
goto first;
|
||||
}
|
||||
while(1) {
|
||||
status = dbNextInfo(pdbentry);
|
||||
while (status) {
|
||||
status = dbNextRecord(pdbentry);
|
||||
while (status) {
|
||||
status = dbNextRecordType(pdbentry);
|
||||
first:
|
||||
if (status) return status;
|
||||
status = dbFirstRecord(pdbentry);
|
||||
}
|
||||
status = dbFirstInfo(pdbentry);
|
||||
}
|
||||
if (!pattern || !*pattern) return 0;
|
||||
if (epicsStrGlobMatch(dbGetInfoName(pdbentry), pattern)) return 0;
|
||||
}
|
||||
}
|
||||
|
||||
long dbFindInfo(DBENTRY *pdbentry,const char *name)
|
||||
{
|
||||
dbRecordNode *precnode = pdbentry->precnode;
|
||||
|
||||
@@ -188,6 +188,8 @@ epicsShareFunc long dbFirstInfo(DBENTRY *pdbentry);
|
||||
epicsShareFunc long dbNextInfo(DBENTRY *pdbentry);
|
||||
epicsShareFunc long dbFindInfo(DBENTRY *pdbentry,
|
||||
const char *name);
|
||||
epicsShareFunc long dbNextMatchingInfo(DBENTRY *pdbentry,
|
||||
const char *pattern);
|
||||
epicsShareFunc long dbDeleteInfo(DBENTRY *pdbentry);
|
||||
epicsShareFunc const char * dbGetInfoName(DBENTRY *pdbentry);
|
||||
epicsShareFunc const char * dbGetInfoString(DBENTRY *pdbentry);
|
||||
|
||||
Reference in New Issue
Block a user