Skip to content
Snippets Groups Projects
Commit dde8c61a authored by Andrew Johnson's avatar Andrew Johnson
Browse files

registry: Cleanup

Delete spurious global symbols
Remove unnecessary casts
Fix (c) headers
Added missing #include guard
Remove unnecessary #includes
Prettified.
parent 0a0302da
No related branches found
No related tags found
No related merge requests found
...@@ -13,8 +13,6 @@ ...@@ -13,8 +13,6 @@
* Date: 2004-03-19 * Date: 2004-03-19
*/ */
#include "dbBase.h"
#include "shareLib.h"
#include "errlog.h" #include "errlog.h"
#define epicsExportSharedSymbols #define epicsExportSharedSymbols
...@@ -24,16 +22,16 @@ ...@@ -24,16 +22,16 @@
void epicsShareAPI registerRecordTypes(DBBASE *pbase, int nRecordTypes, void epicsShareAPI registerRecordTypes(DBBASE *pbase, int nRecordTypes,
const char* const* recordTypeNames, const recordTypeLocation *rtl) const char * const *recordTypeNames, const recordTypeLocation *rtl)
{ {
int i; int i;
for(i=0; i< nRecordTypes; i++) { for (i = 0; i < nRecordTypes; i++) {
recordTypeLocation *precordTypeLocation; recordTypeLocation *precordTypeLocation;
computeSizeOffset sizeOffset; computeSizeOffset sizeOffset;
DBENTRY dbEntry; DBENTRY dbEntry;
if(registryRecordTypeFind(recordTypeNames[i])) continue; if (registryRecordTypeFind(recordTypeNames[i])) continue;
if(!registryRecordTypeAdd(recordTypeNames[i],&rtl[i])) { if (!registryRecordTypeAdd(recordTypeNames[i], &rtl[i])) {
errlogPrintf("registryRecordTypeAdd failed %s\n", errlogPrintf("registryRecordTypeAdd failed %s\n",
recordTypeNames[i]); recordTypeNames[i]);
continue; continue;
...@@ -41,7 +39,7 @@ void epicsShareAPI registerRecordTypes(DBBASE *pbase, int nRecordTypes, ...@@ -41,7 +39,7 @@ void epicsShareAPI registerRecordTypes(DBBASE *pbase, int nRecordTypes,
dbInitEntry(pbase,&dbEntry); dbInitEntry(pbase,&dbEntry);
precordTypeLocation = registryRecordTypeFind(recordTypeNames[i]); precordTypeLocation = registryRecordTypeFind(recordTypeNames[i]);
sizeOffset = precordTypeLocation->sizeOffset; sizeOffset = precordTypeLocation->sizeOffset;
if(dbFindRecordType(&dbEntry,recordTypeNames[i])) { if (dbFindRecordType(&dbEntry, recordTypeNames[i])) {
errlogPrintf("registerRecordDeviceDriver failed %s\n", errlogPrintf("registerRecordDeviceDriver failed %s\n",
recordTypeNames[i]); recordTypeNames[i]);
} else { } else {
...@@ -51,12 +49,12 @@ void epicsShareAPI registerRecordTypes(DBBASE *pbase, int nRecordTypes, ...@@ -51,12 +49,12 @@ void epicsShareAPI registerRecordTypes(DBBASE *pbase, int nRecordTypes,
} }
void epicsShareAPI registerDevices(DBBASE *pbase, int nDevices, void epicsShareAPI registerDevices(DBBASE *pbase, int nDevices,
const char* const* deviceSupportNames, const dset* const* devsl) const char * const *deviceSupportNames, const dset * const *devsl)
{ {
int i; int i;
for(i=0; i< nDevices; i++) { for (i = 0; i < nDevices; i++) {
if(registryDeviceSupportFind(deviceSupportNames[i])) continue; if (registryDeviceSupportFind(deviceSupportNames[i])) continue;
if(!registryDeviceSupportAdd(deviceSupportNames[i],devsl[i])) { if (!registryDeviceSupportAdd(deviceSupportNames[i], devsl[i])) {
errlogPrintf("registryDeviceSupportAdd failed %s\n", errlogPrintf("registryDeviceSupportAdd failed %s\n",
deviceSupportNames[i]); deviceSupportNames[i]);
continue; continue;
...@@ -65,12 +63,12 @@ void epicsShareAPI registerDevices(DBBASE *pbase, int nDevices, ...@@ -65,12 +63,12 @@ void epicsShareAPI registerDevices(DBBASE *pbase, int nDevices,
} }
void epicsShareAPI registerDrivers(DBBASE *pbase, int nDrivers, void epicsShareAPI registerDrivers(DBBASE *pbase, int nDrivers,
const char* const* driverSupportNames, struct drvet* const* drvsl) const char * const * driverSupportNames, struct drvet * const *drvsl)
{ {
int i; int i;
for(i=0; i< nDrivers; i++) { for (i = 0; i < nDrivers; i++) {
if(registryDriverSupportFind(driverSupportNames[i])) continue; if (registryDriverSupportFind(driverSupportNames[i])) continue;
if(!registryDriverSupportAdd(driverSupportNames[i], drvsl[i])) { if (!registryDriverSupportAdd(driverSupportNames[i], drvsl[i])) {
errlogPrintf("registryDriverSupportAdd failed %s\n", errlogPrintf("registryDriverSupportAdd failed %s\n",
driverSupportNames[i]); driverSupportNames[i]);
continue; continue;
......
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
* in file LICENSE that is included with this distribution. * in file LICENSE that is included with this distribution.
\*************************************************************************/ \*************************************************************************/
/* registryCommon.h */ #ifndef INC_registryCommon_H
#define INC_registryCommon_H
#include "dbStaticLib.h" #include "dbStaticLib.h"
#include "registryRecordType.h" #include "registryRecordType.h"
...@@ -19,14 +20,16 @@ extern "C" { ...@@ -19,14 +20,16 @@ extern "C" {
epicsShareFunc void epicsShareAPI registerRecordTypes( epicsShareFunc void epicsShareAPI registerRecordTypes(
DBBASE *pbase, int nRecordTypes, DBBASE *pbase, int nRecordTypes,
const char* const* recordTypeNames, const recordTypeLocation *rtl); const char * const *recordTypeNames, const recordTypeLocation *rtl);
epicsShareFunc void epicsShareAPI registerDevices( epicsShareFunc void epicsShareAPI registerDevices(
DBBASE *pbase, int nDevices, DBBASE *pbase, int nDevices,
const char* const* deviceSupportNames, const dset* const* devsl); const char * const *deviceSupportNames, const dset * const *devsl);
epicsShareFunc void epicsShareAPI registerDrivers( epicsShareFunc void epicsShareAPI registerDrivers(
DBBASE *pbase, int nDrivers, DBBASE *pbase, int nDrivers,
const char* const* driverSupportNames, struct drvet* const* drvsl); const char * const *driverSupportNames, struct drvet * const *drvsl);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* INC_registryCommon_H */
/*************************************************************************\ /*************************************************************************\
* Copyright (c) 2002 The University of Chicago, as Operator of Argonne * Copyright (c) 2012 UChicago Argonne LLC, as Operator of Argonne
* National Laboratory. * National Laboratory.
* Copyright (c) 2002 The Regents of the University of California, as * Copyright (c) 2002 The Regents of the University of California, as
* Operator of Los Alamos National Laboratory. * Operator of Los Alamos National Laboratory.
* EPICS BASE Versions 3.13.7 * EPICS BASE is distributed subject to a Software License Agreement found
* and higher are distributed subject to a Software License Agreement found * in file LICENSE that is included with this distribution.
* in file LICENSE that is included with this distribution.
\*************************************************************************/ \*************************************************************************/
/* registryDeviceSupport.c */ /* registryDeviceSupport.c */
/* Author: Marty Kraimer Date: 08JUN99 */ /* Author: Marty Kraimer Date: 08JUN99 */
#include <stddef.h>
#include <stdlib.h>
#include <stddef.h>
#include "dbBase.h"
#include "devSup.h"
#define epicsExportSharedSymbols #define epicsExportSharedSymbols
#include "registry.h" #include "registry.h"
#include "registryDeviceSupport.h" #include "registryDeviceSupport.h"
const char *deviceSupport = "device support"; static void *registryID = "device support";
static void *registryID = (void *)&deviceSupport;
epicsShareFunc int epicsShareAPI registryDeviceSupportAdd( epicsShareFunc int epicsShareAPI registryDeviceSupportAdd(
const char *name,const struct dset *pdset) const char *name, const struct dset *pdset)
{ {
return(registryAdd(registryID,name,(void *)pdset)); return registryAdd(registryID, name, (void *)pdset);
} }
epicsShareFunc struct dset * epicsShareAPI registryDeviceSupportFind( epicsShareFunc struct dset * epicsShareAPI registryDeviceSupportFind(
const char *name) const char *name)
{ {
return((struct dset *)registryFind(registryID,name)); return registryFind(registryID, name);
} }
...@@ -7,18 +7,18 @@ ...@@ -7,18 +7,18 @@
* in file LICENSE that is included with this distribution. * in file LICENSE that is included with this distribution.
\*************************************************************************/ \*************************************************************************/
#ifndef INCregistryDeviceSupporth #ifndef INC_registryDeviceSupport_H
#define INCregistryDeviceSupporth #define INC_registryDeviceSupport_H
#include "shareLib.h"
#include "devSup.h" #include "devSup.h"
#include "shareLib.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
epicsShareFunc int epicsShareAPI registryDeviceSupportAdd( epicsShareFunc int epicsShareAPI registryDeviceSupportAdd(
const char *name,const struct dset *pdset); const char *name, const struct dset *pdset);
epicsShareFunc struct dset * epicsShareAPI registryDeviceSupportFind( epicsShareFunc struct dset * epicsShareAPI registryDeviceSupportFind(
const char *name); const char *name);
...@@ -27,4 +27,4 @@ epicsShareFunc struct dset * epicsShareAPI registryDeviceSupportFind( ...@@ -27,4 +27,4 @@ epicsShareFunc struct dset * epicsShareAPI registryDeviceSupportFind(
#endif #endif
#endif /* INCregistryDeviceSupporth */ #endif /* INC_registryDeviceSupport_H */
/*************************************************************************\ /*************************************************************************\
* Copyright (c) 2002 The University of Chicago, as Operator of Argonne * Copyright (c) 2012 UChicago Argonne LLC, as Operator of Argonne
* National Laboratory. * National Laboratory.
* Copyright (c) 2002 The Regents of the University of California, as * Copyright (c) 2002 The Regents of the University of California, as
* Operator of Los Alamos National Laboratory. * Operator of Los Alamos National Laboratory.
* EPICS BASE Versions 3.13.7 * EPICS BASE is distributed subject to a Software License Agreement found
* and higher are distributed subject to a Software License Agreement found * in file LICENSE that is included with this distribution.
* in file LICENSE that is included with this distribution.
\*************************************************************************/ \*************************************************************************/
/* registryDriverSupport.c */ /* registryDriverSupport.c */
/* Author: Marty Kraimer Date: 08JUN99 */ /* Author: Marty Kraimer Date: 08JUN99 */
#include <stddef.h>
#include <stdlib.h>
#include <stddef.h>
#include "dbBase.h"
#include "drvSup.h"
#define epicsExportSharedSymbols #define epicsExportSharedSymbols
#include "registry.h" #include "registry.h"
#include "registryDriverSupport.h" #include "registryDriverSupport.h"
const char *driverSupport = "driver support"; static void *registryID = "driver support";
static void *registryID = (void *)&driverSupport;
epicsShareFunc int epicsShareAPI registryDriverSupportAdd( epicsShareFunc int epicsShareAPI registryDriverSupportAdd(
const char *name,struct drvet *pdrvet) const char *name, struct drvet *pdrvet)
{ {
return(registryAdd(registryID,name,(void *)pdrvet)); return registryAdd(registryID, name, pdrvet);
} }
epicsShareFunc struct drvet * epicsShareAPI registryDriverSupportFind( epicsShareFunc struct drvet * epicsShareAPI registryDriverSupportFind(
const char *name) const char *name)
{ {
return((struct drvet *)registryFind(registryID,name)); return registryFind(registryID, name);
} }
...@@ -7,19 +7,18 @@ ...@@ -7,19 +7,18 @@
* in file LICENSE that is included with this distribution. * in file LICENSE that is included with this distribution.
\*************************************************************************/ \*************************************************************************/
#ifndef INCregistryDriverSupporth #ifndef INC_registryDriverSupport_H
#define INCregistryDriverSupporth #define INC_registryDriverSupport_H
#include "shareLib.h"
#include "drvSup.h" #include "drvSup.h"
#include "shareLib.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/* c interface definitions */
epicsShareFunc int epicsShareAPI registryDriverSupportAdd( epicsShareFunc int epicsShareAPI registryDriverSupportAdd(
const char *name,struct drvet *pdrvet); const char *name, struct drvet *pdrvet);
epicsShareFunc struct drvet * epicsShareAPI registryDriverSupportFind( epicsShareFunc struct drvet * epicsShareAPI registryDriverSupportFind(
const char *name); const char *name);
...@@ -28,4 +27,4 @@ epicsShareFunc struct drvet * epicsShareAPI registryDriverSupportFind( ...@@ -28,4 +27,4 @@ epicsShareFunc struct drvet * epicsShareAPI registryDriverSupportFind(
#endif #endif
#endif /* INCregistryDriverSupporth */ #endif /* INC_registryDriverSupport_H */
/*************************************************************************\ /*************************************************************************\
* Copyright (c) 2002 The University of Chicago, as Operator of Argonne * Copyright (c) 2012 UChicago Argonne LLC, as Operator of Argonne
* National Laboratory. * National Laboratory.
* Copyright (c) 2002 The Regents of the University of California, as * Copyright (c) 2002 The Regents of the University of California, as
* Operator of Los Alamos National Laboratory. * Operator of Los Alamos National Laboratory.
* EPICS BASE Versions 3.13.7 * EPICS BASE is distributed subject to a Software License Agreement found
* and higher are distributed subject to a Software License Agreement found * in file LICENSE that is included with this distribution.
* in file LICENSE that is included with this distribution.
\*************************************************************************/ \*************************************************************************/
/* registryFunction.c */ /* registryFunction.c */
/* Author: Marty Kraimer Date: 01MAY2000 */ /* Author: Marty Kraimer Date: 01MAY2000 */
#include <stddef.h>
#include <stdlib.h>
#include <stddef.h>
#include <stdio.h> #include <stdio.h>
#define epicsExportSharedSymbols #define epicsExportSharedSymbols
#include "registry.h" #include "registry.h"
#include "registryFunction.h" #include "registryFunction.h"
const char *function = "function"; static void * const registryID = "function";
static void *registryID = (void *)&function;
epicsShareFunc int epicsShareAPI registryFunctionAdd( epicsShareFunc int epicsShareAPI registryFunctionAdd(
const char *name,REGISTRYFUNCTION func) const char *name, REGISTRYFUNCTION func)
{ {
return(registryAdd(registryID,name,(void *)func)); return registryAdd(registryID, name, func);
} }
epicsShareFunc REGISTRYFUNCTION epicsShareAPI registryFunctionFind( epicsShareFunc REGISTRYFUNCTION epicsShareAPI registryFunctionFind(
const char *name) const char *name)
{ {
REGISTRYFUNCTION func; REGISTRYFUNCTION func = registryFind(registryID, name);
func = (REGISTRYFUNCTION)registryFind(registryID,name);
if(!func) { if (!func) {
func = (REGISTRYFUNCTION)registryFind(0,name); func = registryFind(0, name);
if(func)registryFunctionAdd(name,func); if (func) registryFunctionAdd(name, func);
} }
return(func); return func;
} }
epicsShareFunc int epicsShareAPI registryFunctionRefAdd( epicsShareFunc int epicsShareAPI registryFunctionRefAdd(
registryFunctionRef ref[],int nfunctions) registryFunctionRef ref[], int nfunctions)
{ {
int ind; int i;
for(ind=0; ind<nfunctions; ind++) { for (i = 0; i < nfunctions; i++) {
if(!registryFunctionAdd(ref[ind].name,ref[ind].addr)) { if (!registryFunctionAdd(ref[i].name, ref[i].addr)) {
printf("registryFunctionRefAdd: could not register %s\n", printf("registryFunctionRefAdd: could not register %s\n",
ref[ind].name); ref[i].name);
return(0); return 0;
} }
} }
return(1); return 1;
} }
/*************************************************************************\ /*************************************************************************\
* Copyright (c) 2002 The University of Chicago, as Operator of Argonne * Copyright (c) 2007 UChicago Argonne LLC, as Operator of Argonne
* National Laboratory. * National Laboratory.
* Copyright (c) 2002 The Regents of the University of California, as * Copyright (c) 2002 The Regents of the University of California, as
* Operator of Los Alamos National Laboratory. * Operator of Los Alamos National Laboratory.
* EPICS BASE Versions 3.13.7 * EPICS BASE is distributed subject to a Software License Agreement found
* and higher are distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution. * in file LICENSE that is included with this distribution.
\*************************************************************************/ \*************************************************************************/
#ifndef INCregistryFunctionh
#define INCregistryFunctionh #ifndef INC_registryFunction_H
#define INC_registryFunction_H
#include "shareLib.h" #include "shareLib.h"
...@@ -19,21 +19,21 @@ extern "C" { ...@@ -19,21 +19,21 @@ extern "C" {
typedef void (*REGISTRYFUNCTION)(void); typedef void (*REGISTRYFUNCTION)(void);
typedef struct registryFunctionRef { typedef struct registryFunctionRef {
const char *name; const char * name;
REGISTRYFUNCTION addr; REGISTRYFUNCTION addr;
}registryFunctionRef; } registryFunctionRef;
/* c interface definitions */
epicsShareFunc int epicsShareAPI registryFunctionAdd( epicsShareFunc int epicsShareAPI registryFunctionAdd(
const char *name,REGISTRYFUNCTION func); const char *name, REGISTRYFUNCTION func);
epicsShareFunc REGISTRYFUNCTION epicsShareAPI registryFunctionFind( epicsShareFunc REGISTRYFUNCTION epicsShareAPI registryFunctionFind(
const char *name); const char *name);
epicsShareFunc int epicsShareAPI registryFunctionRefAdd( epicsShareFunc int epicsShareAPI registryFunctionRefAdd(
registryFunctionRef ref[],int nfunctions); registryFunctionRef ref[], int nfunctions);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* INCregistryFunctionh */ #endif /* INC_registryFunction_H */
/*************************************************************************\ /*************************************************************************\
* Copyright (c) 2002 The University of Chicago, as Operator of Argonne * Copyright (c) 2012 UChicago Argonne LLC, as Operator of Argonne
* National Laboratory. * National Laboratory.
* Copyright (c) 2002 The Regents of the University of California, as * Copyright (c) 2002 The Regents of the University of California, as
* Operator of Los Alamos National Laboratory. * Operator of Los Alamos National Laboratory.
* EPICS BASE Versions 3.13.7 * EPICS BASE is distributed subject to a Software License Agreement found
* and higher are distributed subject to a Software License Agreement found * in file LICENSE that is included with this distribution.
* in file LICENSE that is included with this distribution.
\*************************************************************************/ \*************************************************************************/
/* registryRecordType.c */ /* registryRecordType.c */
/* Author: Marty Kraimer Date: 08JUN99 */ /* Author: Marty Kraimer Date: 08JUN99 */
#include <stddef.h>
#include <stdlib.h>
#include <stddef.h>
#include "dbBase.h"
#define epicsExportSharedSymbols #define epicsExportSharedSymbols
#include "registry.h" #include "registry.h"
#include "registryRecordType.h" #include "registryRecordType.h"
const char *recordType = "record type"; static void * const registryID = "record type";
static void *registryID = (void *)&recordType;
epicsShareFunc int epicsShareAPI registryRecordTypeAdd( epicsShareFunc int epicsShareAPI registryRecordTypeAdd(
const char *name,const recordTypeLocation *prtl) const char *name, const recordTypeLocation *prtl)
{ {
return(registryAdd(registryID,name,(void *)prtl)); return registryAdd(registryID, name, (void *)prtl);
} }
epicsShareFunc recordTypeLocation * epicsShareAPI registryRecordTypeFind( epicsShareFunc recordTypeLocation * epicsShareAPI registryRecordTypeFind(
const char *name) const char *name)
{ {
return((recordTypeLocation *)registryFind(registryID,name)); return registryFind(registryID, name);
} }
/*************************************************************************\ /*************************************************************************\
* Copyright (c) 2002 The University of Chicago, as Operator of Argonne * Copyright (c) 2007 UChicago Argonne LLC, as Operator of Argonne
* National Laboratory. * National Laboratory.
* Copyright (c) 2002 The Regents of the University of California, as * Copyright (c) 2002 The Regents of the University of California, as
* Operator of Los Alamos National Laboratory. * Operator of Los Alamos National Laboratory.
* EPICS BASE Versions 3.13.7 * EPICS BASE is distributed subject to a Software License Agreement found
* and higher are distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution. * in file LICENSE that is included with this distribution.
\*************************************************************************/ \*************************************************************************/
#ifndef INCregistryRecordTypeh
#define INCregistryRecordTypeh #ifndef INC_registryRecordType_H
#define INC_registryRecordType_H
#include "recSup.h" #include "recSup.h"
#include "shareLib.h" #include "shareLib.h"
...@@ -27,10 +27,9 @@ typedef struct recordTypeLocation { ...@@ -27,10 +27,9 @@ typedef struct recordTypeLocation {
struct rset *prset; struct rset *prset;
computeSizeOffset sizeOffset; computeSizeOffset sizeOffset;
}recordTypeLocation; }recordTypeLocation;
epicsShareFunc int epicsShareAPI registryRecordTypeAdd( epicsShareFunc int epicsShareAPI registryRecordTypeAdd(
const char *name,const recordTypeLocation *prtl); const char *name, const recordTypeLocation *prtl);
epicsShareFunc recordTypeLocation * epicsShareAPI registryRecordTypeFind( epicsShareFunc recordTypeLocation * epicsShareAPI registryRecordTypeFind(
const char *name); const char *name);
...@@ -41,4 +40,4 @@ int registerRecordDeviceDriver(struct dbBase *pdbbase); ...@@ -41,4 +40,4 @@ int registerRecordDeviceDriver(struct dbBase *pdbbase);
#endif #endif
#endif /* INCregistryRecordTypeh */ #endif /* INC_registryRecordType_H */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment