Add dbServer files.
This commit is contained in:
@@ -26,6 +26,7 @@ INC += dbLink.h
|
||||
INC += dbLock.h
|
||||
INC += dbNotify.h
|
||||
INC += dbScan.h
|
||||
INC += dbServer.h
|
||||
INC += dbTest.h
|
||||
INC += dbCaTest.h
|
||||
INC += db_test.h
|
||||
@@ -86,4 +87,5 @@ dbCore_SRCS += templateInstances.cpp
|
||||
dbCore_SRCS += dbIocRegister.c
|
||||
dbCore_SRCS += chfPlugin.c
|
||||
dbCore_SRCS += dbState.c
|
||||
dbCore_SRCS += dbServer.c
|
||||
|
||||
|
||||
58
src/ioc/db/dbServer.c
Normal file
58
src/ioc/db/dbServer.c
Normal file
@@ -0,0 +1,58 @@
|
||||
/*************************************************************************\
|
||||
* Copyright (c) 2014 UChicago Argonne LLC, as Operator of Argonne
|
||||
* National Laboratory.
|
||||
* EPICS BASE is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
\*************************************************************************/
|
||||
|
||||
/*
|
||||
* Author: Andrew Johnson <anj@aps.anl.gov>
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "ellLib.h"
|
||||
#include "epicsStdio.h"
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include "dbServer.h"
|
||||
|
||||
static ELLLIST serverList = ELLLIST_INIT;
|
||||
|
||||
|
||||
void dbRegisterServer(dbServer *psrv)
|
||||
{
|
||||
if (ellNext(&psrv->node)) {
|
||||
fprintf(stderr, "dbRegisterServer: '%s' registered twice?\n",
|
||||
psrv->name);
|
||||
return;
|
||||
}
|
||||
|
||||
ellAdd(&serverList, &psrv->node);
|
||||
}
|
||||
|
||||
void dbsr(unsigned level)
|
||||
{
|
||||
dbServer *psrv = (dbServer *)ellFirst(&serverList);
|
||||
|
||||
while (psrv) {
|
||||
printf("Server '%s':\n", psrv->name);
|
||||
if (psrv->report)
|
||||
psrv->report(level);
|
||||
psrv = (dbServer *)ellNext(&psrv->node);
|
||||
}
|
||||
}
|
||||
|
||||
int dbServerClient(char *pBuf, size_t bufSize)
|
||||
{
|
||||
dbServer *psrv = (dbServer *)ellFirst(&serverList);
|
||||
|
||||
while (psrv) {
|
||||
if (psrv->client &&
|
||||
psrv->client(pBuf, bufSize) == 0)
|
||||
return 0;
|
||||
psrv = (dbServer *)ellNext(&psrv->node);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
58
src/ioc/db/dbServer.h
Normal file
58
src/ioc/db/dbServer.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/*************************************************************************\
|
||||
* Copyright (c) 2014 UChicago Argonne LLC, as Operator of Argonne
|
||||
* National Laboratory.
|
||||
* EPICS BASE is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
\*************************************************************************/
|
||||
|
||||
/*
|
||||
* Author: Andrew Johnson <anj@aps.anl.gov>
|
||||
*/
|
||||
|
||||
#ifndef INC_dbServer_H
|
||||
#define INC_dbServer_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "ellLib.h"
|
||||
#include "shareLib.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Server information structure */
|
||||
|
||||
typedef struct dbServer {
|
||||
ELLNODE node;
|
||||
const char *name;
|
||||
|
||||
/* Print level-dependent status report to stdout */
|
||||
void (* report) (unsigned level);
|
||||
|
||||
/* Get number of channels and clients connected */
|
||||
void (* stats) (unsigned *channels, unsigned *clients);
|
||||
|
||||
/* Get identity of client initiating the calling thread */
|
||||
/* Must return 0 (OK), or -1 (ERROR) from unknown threads */
|
||||
int (* client) (char *pBuf, size_t bufSize);
|
||||
} dbServer;
|
||||
|
||||
|
||||
epicsShareFunc void dbRegisterServer(dbServer *psrv);
|
||||
|
||||
/* Extra routines could be added if/when needed:
|
||||
*
|
||||
* epicsShareFunc const dbServer* dbFindServer(const char *name);
|
||||
* epicsShareFunc void dbIterateServers(srvIterFunc func, void *user);
|
||||
*/
|
||||
|
||||
epicsShareFunc void dbsr(unsigned level);
|
||||
|
||||
epicsShareFunc int dbServerClient(char *pBuf, size_t bufSize);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* INC_dbServer_H */
|
||||
Reference in New Issue
Block a user