make function available on softioc

This commit is contained in:
zimoch
2011-08-29 15:13:58 +00:00
parent 7bda130084
commit 23eaf2f57e
4 changed files with 100 additions and 41 deletions
+62 -35
View File
@@ -1,53 +1,80 @@
/* listRecords is a wrapper function for dbl
it is required because of the changed syntax of dbl in R3.14.
*/
/* listRecords.c
*
* listRecords is a wrapper function for dbl
* it hides the changed syntax of dbl in R3.14.
*
* $Author: zimoch $
*
* $Source: /cvs/G/DRV/misc/listRecords.c,v $
*
*/
#include <epicsVersion.h>
#include <stddef.h>
#include <errno.h>
#include <epicsVersion.h>
#ifdef BASE_VERSION
/* This is R3.13 */
#define EPICS_3_13
#include <stdio.h>
long dbl(char *precordTypename, char *filename, char *fields);
#else
/* This is R3.14 */
#define EPICS_3_14
#include <string.h>
#include <dbTest.h>
#include <epicsStdio.h>
#include <iocsh.h>
#include <epicsExport.h>
#endif
int listRecords(char* file, char* fields)
int listRecords(char* filename, char* fields)
{
#ifndef BASE_VERSION
/* This is R3.14 */
FILE* oldStdout;
FILE* newStdout;
#endif
if (!file)
{
printf ("usage: listRecords \"filename\", \"field field ...\"\n");
return -1;
}
#ifdef BASE_VERSION
/* This is R3.13 */
return dbl(0L, file, fields);
#ifdef EPICS_3_13
return dbl(NULL, filename, fields);
#else
/* This is R3.14 */
newStdout = fopen(file, "w");
if (!newStdout)
{
fprintf (stderr, "Can't open %s for writing: %s\n",
file, strerror(errno));
return errno;
FILE* oldStdout = NULL;
FILE* newStdout = NULL;
if (filename && *filename)
{
newStdout = fopen(filename, "w");
if (!newStdout)
{
fprintf (stderr, "Can't open %s for writing: %s\n",
filename, strerror(errno));
return errno;
}
oldStdout = epicsGetThreadStdout();
epicsSetThreadStdout(newStdout);
}
dbl(0L, fields);
if (newStdout)
{
fclose(newStdout);
epicsSetThreadStdout(oldStdout);
}
return 0;
}
oldStdout = epicsGetThreadStdout();
epicsSetThreadStdout(newStdout);
dbl(0L, fields);
fclose(newStdout);
epicsSetThreadStdout(oldStdout);
return 0;
#endif
}
#ifdef EPICS_3_14
static const iocshArg listRecordsArg0 = { "filename", iocshArgString };
static const iocshArg listRecordsArg1 = { "fields", iocshArgString };
static const iocshArg * const listRecordsArgs[2] = { &listRecordsArg0, &listRecordsArg1 };
static const iocshFuncDef listRecordsDef = { "listRecords", 2, listRecordsArgs };
static void listRecordsFunc (const iocshArgBuf *args)
{
listRecords(args[0].sval, args[1].sval);
}
static void listRecordsRegister(void)
{
static int firstTime = 1;
if (firstTime) {
iocshRegister (&listRecordsDef, listRecordsFunc);
firstTime = 0;
}
}
epicsExportRegistrar(listRecordsRegister);
#endif
+1
View File
@@ -0,0 +1 @@
registrar(listRecordsRegister)
+36 -6
View File
@@ -5,18 +5,25 @@
*
* $Author: zimoch $
*
* $Log: updateMenuConvert.c,v $
* Revision 1.1 2005/04/14 11:25:49 zimoch
* add breakpoint tabled to menu convert
* $Source: /cvs/G/DRV/misc/updateMenuConvert.c,v $
*
*/
#include <dbStaticLib.h>
#include <string.h>
#include <ellLib.h>
#include <stdlib.h>
#include <dbScan.h>
#include <dbStaticLib.h>
#include <dbAccess.h>
#include <epicsVersion.h>
#ifdef BASE_VERSION
#define EPICS_3_13
extern DBBASE *pdbbase;
#else
#define EPICS_3_14
#include <iocsh.h>
#include <epicsExport.h>
#endif
typedef struct node {
ELLNODE node;
@@ -24,7 +31,7 @@ typedef struct node {
char *value;
} node;
int epicsShareAPI updateMenuConvert ()
int updateMenuConvert ()
{
brkTable *pbrkTable;
dbMenu *menuConvert;
@@ -34,6 +41,11 @@ int epicsShareAPI updateMenuConvert ()
char **papChoiceName;
char **papChoiceValue;
if (interruptAccept)
{
fprintf(stderr, "updateMenuConvert: Can update menuConvert only before iocInit!\n");
return -1;
}
menuConvert = dbFindMenu(pdbbase,"menuConvert");
ellInit(&missing);
for(pbrkTable = (brkTable *)ellFirst(&pdbbase->bptList);
@@ -87,3 +99,21 @@ int epicsShareAPI updateMenuConvert ()
}
return 0;
}
#ifdef EPICS_3_14
static const iocshFuncDef updateMenuConvertDef = { "updateMenuConvert", 0, NULL };
static void updateMenuConvertFunc (const iocshArgBuf *args)
{
updateMenuConvert();
}
static void updateMenuConvertRegister(void)
{
static int firstTime = 1;
if (firstTime) {
iocshRegister (&updateMenuConvertDef, updateMenuConvertFunc);
firstTime = 0;
}
}
epicsExportRegistrar(updateMenuConvertRegister);
#endif
+1
View File
@@ -0,0 +1 @@
registrar(updateMenuConvertRegister)