changes so that db doesnt depend on as; as on rec

This commit is contained in:
Marty Kraimer
2000-02-24 19:45:20 +00:00
parent b0cd1f2103
commit 59a559055e
4 changed files with 251 additions and 48 deletions

View File

@@ -1,6 +1,9 @@
TOP=../..
include $(TOP)/configure/CONFIG
INC += asDbLib.h
INC += asLib.h
LIBSRCS += asLib.c
asIoc_SRCS += asDbLib.c

View File

@@ -37,7 +37,6 @@ of this distribution.
#include "asDbLib.h"
#include "dbCommon.h"
#include "recSup.h"
#include "subRecord.h"
extern struct dbBase *pdbbase;
@@ -104,6 +103,11 @@ int asSetSubstitutions(char *substitutions)
return(0);
}
static void asSpcAsCallback(struct dbCommon *precord)
{
asChangeGroup((ASMEMBERPVT *)&precord->asp,precord->asg);
}
static long asInitCommon(void)
{
long status;
@@ -126,7 +130,10 @@ static long asInitCommon(void)
}
status = asInitFile(pacf,psubstitutions);
if(asActive) {
if(!asWasActive) asDbAddRecords();
if(!asWasActive) {
dbSpcAsRegisterCallback(asSpcAsCallback);
asDbAddRecords();
}
asCaStart();
}
return(status);
@@ -183,52 +190,6 @@ int asInitAsyn(ASDBCALLBACK *pcallback)
return(0);
}
/*Interface to subroutine record*/
static void myCallback(CALLBACK *pcallback)
{
ASDBCALLBACK *pasdbcallback = (ASDBCALLBACK *)pcallback;
subRecord *precord;
struct rset *prset;
callbackGetUser(precord,pcallback);
prset=(struct rset *)(precord->rset);
precord->val = 0.0;
if(pasdbcallback->status) {
recGblSetSevr(precord,READ_ALARM,precord->brsv);
recGblRecordError(pasdbcallback->status,precord,"asInit Failed");
}
dbScanLock((dbCommon *)precord);
(*prset->process)((dbCommon *)precord);
dbScanUnlock((dbCommon *)precord);
}
long asSubInit(subRecord *precord,int pass)
{
ASDBCALLBACK *pcallback;
pcallback = (ASDBCALLBACK *)callocMustSucceed(
1,sizeof(ASDBCALLBACK),"asSubInit");
precord->dpvt = (void *)pcallback;
callbackSetCallback(myCallback,&pcallback->callback);
callbackSetUser(precord,&pcallback->callback);
return(0);
}
long asSubProcess(subRecord *precord)
{
ASDBCALLBACK *pcallback = (ASDBCALLBACK *)precord->dpvt;
if(!precord->pact && precord->val==1.0) {
db_post_events(precord,&precord->val,DBE_VALUE);
callbackSetPriority(precord->prio,&pcallback->callback);
asInitAsyn(pcallback);
precord->pact=TRUE;
return(1);
}
db_post_events(precord,&precord->val,DBE_VALUE);
return(0);
}
int asDbGetAsl(void *paddress)
{
DBADDR *paddr = paddress;

44
src/as/asDbLib.h Normal file
View File

@@ -0,0 +1,44 @@
/* share/epicsH/dbAsLib.h */
/* $Id$ */
/* Author: Marty Kraimer Date: 02-23-94*/
/*****************************************************************
COPYRIGHT NOTIFICATION
*****************************************************************
(C) COPYRIGHT 1993 UNIVERSITY OF CHICAGO
This software was developed under a United States Government license
described on the COPYRIGHT_UniversityOfChicago file included as part
of this distribution.
**********************************************************************/
/*
* Modification Log:
* -----------------
* .01 02-23-94 mrk Initial Implementation
*/
#ifndef INCdbAsLibh
#define INCdbAsLibh
#include <asLib.h>
#include <callback.h>
typedef struct {
CALLBACK callback;
long status;
} ASDBCALLBACK;
int asSetFilename(char *acf);
int asSetSubstitutions(char *substitutions);
int asInitAsyn(ASDBCALLBACK *pcallback);
int asDbGetAsl( void *paddr);
ASMEMBERPVT asDbGetMemberPvt( void *paddr);
int asdbdump( void);
int aspuag(char *uagname);
int asphag(char *hagname);
int asprules(char *asgname);
int aspmem(char *asgname,int clients);
void asCaStart(void);
void asCaStop(void);
#endif /*INCdbAsLibh*/

195
src/as/asLib.h Normal file
View File

@@ -0,0 +1,195 @@
/* $Id$ */
/* Author: Marty Kraimer Date: 09-27-93*/
/*****************************************************************
COPYRIGHT NOTIFICATION
*****************************************************************
(C) COPYRIGHT 1993 UNIVERSITY OF CHICAGO
This software was developed under a United States Government license
described on the COPYRIGHT_UniversityOfChicago file included as part
of this distribution.
**********************************************************************/
/*
* Modification Log:
* -----------------
* .01 09-27-93 mrk Initial Implementation
*/
#ifndef INCasLibh
#define INCasLibh
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <errMdef.h>
#include <ellLib.h>
typedef struct asgMember *ASMEMBERPVT;
typedef struct asgClient *ASCLIENTPVT;
typedef int (*ASINPUTFUNCPTR)(char *buf,int max_size);
typedef enum{
asClientCOAR /*Change of access rights*/
/*For now this is all*/
} asClientStatus;
typedef void (*ASCLIENTCALLBACK) (ASCLIENTPVT,asClientStatus);
/* The following routines are macros with the following syntax
long asCheckGet(ASCLIENTPVT asClientPvt);
long asCheckPut(ASCLIENTPVT asClientPvt);
*/
#define asCheckGet(asClientPvt)\
(asActive ?\
((asClientPvt)->access>=asREAD ? TRUE : FALSE)\
: TRUE)
#define asCheckPut(asClientPvt)\
(asActive ?\
((asClientPvt)->access>=asWRITE ? TRUE : FALSE)\
: TRUE)
epicsShareFunc int epicsShareAPI asInit(void);
epicsShareFunc long epicsShareAPI asInitialize(ASINPUTFUNCPTR inputfunction);
epicsShareFunc long epicsShareAPI asInitFile(const char *filename,const char *substitutions);
epicsShareFunc long epicsShareAPI asInitFP(FILE *fp,const char *substitutions);
/*caller must provide permanent storage for asgName*/
epicsShareFunc long epicsShareAPI asAddMember(ASMEMBERPVT *asMemberPvt,char *asgName);
epicsShareFunc long epicsShareAPI asRemoveMember(ASMEMBERPVT *asMemberPvt);
/*caller must provide permanent storage for newAsgName*/
epicsShareFunc long epicsShareAPI asChangeGroup(ASMEMBERPVT *asMemberPvt,char *newAsgName);
epicsShareFunc void * epicsShareAPI asGetMemberPvt(ASMEMBERPVT asMemberPvt);
epicsShareFunc void epicsShareAPI asPutMemberPvt(ASMEMBERPVT asMemberPvt,void *userPvt);
/*client must provide permanent storage for user and host*/
epicsShareFunc long epicsShareAPI asAddClient(ASCLIENTPVT *asClientPvt,ASMEMBERPVT asMemberPvt,
int asl,char *user,char *host);
/*client must provide permanent storage for user and host*/
epicsShareFunc long epicsShareAPI asChangeClient(ASCLIENTPVT asClientPvt,int asl,char *user,char *host);
epicsShareFunc long epicsShareAPI asRemoveClient(ASCLIENTPVT *asClientPvt);
epicsShareFunc void * epicsShareAPI asGetClientPvt(ASCLIENTPVT asClientPvt);
epicsShareFunc void epicsShareAPI asPutClientPvt(ASCLIENTPVT asClientPvt,void *userPvt);
epicsShareFunc long epicsShareAPI asRegisterClientCallback(ASCLIENTPVT asClientPvt,
ASCLIENTCALLBACK pcallback);
epicsShareFunc long epicsShareAPI asComputeAllAsg(void);
/* following declared below after ASG is declared
epicsShareFunc long epicsShareAPI asComputeAsg(ASG *pasg);
*/
epicsShareFunc long epicsShareAPI asCompute(ASCLIENTPVT asClientPvt);
epicsShareFunc int epicsShareAPI asDump(void (*memcallback)(ASMEMBERPVT),
void (*clientcallback)(ASCLIENTPVT),int verbose);
epicsShareFunc int epicsShareAPI asDumpUag(char *uagname);
epicsShareFunc int epicsShareAPI asDumpHag(char *hagname);
epicsShareFunc int epicsShareAPI asDumpRules(char *asgname);
epicsShareFunc int epicsShareAPI asDumpMem(char *asgname,void (*memcallback)(ASMEMBERPVT),int clients);
epicsShareFunc int epicsShareAPI asDumpHash(void);
#define S_asLib_clientsExist (M_asLib| 1) /*Client Exists*/
#define S_asLib_noUag (M_asLib| 2) /*User Access Group does not exist*/
#define S_asLib_noHag (M_asLib| 3) /*Host Access Group does not exist*/
#define S_asLib_noAccess (M_asLib| 4) /*access security: no access allowed*/
#define S_asLib_noModify (M_asLib| 5) /*access security: no modification allowed*/
#define S_asLib_badConfig (M_asLib| 6) /*access security: bad configuration file*/
#define S_asLib_badCalc (M_asLib| 7) /*access security: bad calculation espression*/
#define S_asLib_dupAsg (M_asLib| 8) /*Duplicate Access Security Group */
#define S_asLib_InitFailed (M_asLib| 9) /*access security: Init failed*/
#define S_asLib_asNotActive (M_asLib|10) /*access security is not active*/
#define S_asLib_badMember (M_asLib|11) /*access security: bad ASMEMBERPVT*/
#define S_asLib_badClient (M_asLib|12) /*access security: bad ASCLIENTPVT*/
#define S_asLib_badAsg (M_asLib|13) /*access security: bad ASG*/
#define S_asLib_noMemory (M_asLib|14) /*access security: no Memory */
/*Private declarations */
#define ASMAXINP 12
epicsShareExtern int asActive;
/* definition of access rights*/
typedef enum{asNOACCESS,asREAD,asWRITE} asAccessRights;
/*Base pointers for access security*/
typedef struct asBase{
ELLLIST uagList;
ELLLIST hagList;
ELLLIST asgList;
void *phash;
} ASBASE;
epicsShareExtern volatile ASBASE *pasbase;
/*Defs for User Access Groups*/
typedef struct{
ELLNODE node;
char *user;
} UAGNAME;
typedef struct uag{
ELLNODE node;
char *name;
ELLLIST list; /*list of UAGNAME*/
} UAG;
/*Defs for Host Access Groups*/
typedef struct{
ELLNODE node;
char *host;
} HAGNAME;
typedef struct hag{
ELLNODE node;
char *name;
ELLLIST list; /*list of HAGNAME*/
} HAG;
/*Defs for Access SecurityGroups*/
typedef struct {
ELLNODE node;
UAG *puag;
}ASGUAG;
typedef struct {
ELLNODE node;
HAG *phag;
}ASGHAG;
typedef struct{
ELLNODE node;
asAccessRights access;
int level;
int inpUsed; /*mask for which inputs are used*/
int result; /*Result of calc converted to TRUE/FALSE*/
char *calc;
void *rpcl;
ELLLIST uagList; /*List of ASGUAG*/
ELLLIST hagList; /*List of ASGHAG*/
} ASGRULE;
typedef struct{
ELLNODE node;
char *inp;
void *capvt;
struct asg *pasg;
int inpIndex;
}ASGINP;
typedef struct asg{
ELLNODE node;
char *name;
ELLLIST inpList;
ELLLIST ruleList;
ELLLIST memberList;
double *pavalue; /*pointer to array of input values*/
int inpBad; /*mask for which inputs are bad*/
int inpChanged; /*mask showing inputs that have changed*/
} ASG;
typedef struct asgMember {
ELLNODE node;
ASG *pasg;
ELLLIST clientList;
char *asgName;
void *userPvt;
} ASGMEMBER;
typedef struct asgClient {
ELLNODE node;
ASGMEMBER *pasgMember;
char *user;
char *host;
void *userPvt;
ASCLIENTCALLBACK pcallback;
int level;
asAccessRights access;
} ASGCLIENT;
epicsShareFunc long epicsShareAPI asComputeAsg(ASG *pasg);
/*following is "friend" function*/
epicsShareFunc void * epicsShareAPI asCalloc(size_t nobj,size_t size);
#endif /*INCasLibh*/