Files
pcas/src/registry/registry.c
2002-07-12 21:35:43 +00:00

81 lines
2.1 KiB
C
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*************************************************************************\
* Copyright (c) 2002 The University of Chicago, as Operator of Argonne
* National Laboratory.
* Copyright (c) 2002 The Regents of the University of California, as
* Operator of Los Alamos National Laboratory.
* EPICS BASE Versions 3.13.7
* and higher are distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
\*************************************************************************/
/*registry.c */
/* Author: Marty Kraimer Date: 08JUN99 */
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <stdio.h>
#include "dbDefs.h"
#include "cantProceed.h"
#include "epicsFindSymbol.h"
#include "gpHash.h"
#define epicsExportSharedSymbols
#include "registry.h"
static void *gphPvt = 0;
static void registryInit(int tableSize)
{
if(tableSize==0) tableSize = DEFAULT_TABLE_SIZE;
gphInitPvt(&gphPvt,tableSize);
if(!gphPvt) cantProceed("registry why did gphInitPvt fail\n");
}
epicsShareFunc int epicsShareAPI registrySetTableSize(int size)
{
if(gphPvt) {
printf("registryInit already called\n");
return(-1);
}
registryInit(size);
return(0);
}
epicsShareFunc int epicsShareAPI registryAdd(
void *registryID,const char *name,void *data)
{
GPHENTRY *pentry;
if(!gphPvt) registryInit(0);
pentry = gphAdd(gphPvt,name,registryID);
if(!pentry) return(FALSE);
pentry->userPvt = (void *)data;
return(TRUE);
}
epicsShareFunc void * epicsShareAPI registryFind(
void *registryID,const char *name)
{
GPHENTRY *pentry;
if(name==0) return(0);
if(registryID==0) return(epicsFindSymbol(name));
if(!gphPvt) registryInit(0);
pentry = gphFind(gphPvt,(char *)name,registryID);
if(!pentry) return(0);
return(pentry->userPvt);
}
epicsShareFunc void epicsShareAPI registryFree()
{
if(!gphPvt) return;
gphFreeMem(gphPvt);
}
epicsShareFunc int epicsShareAPI registryDump(void)
{
if(!gphPvt) return(0);
gphDump(gphPvt);
return(0);
}