jba 4/18/91

This commit is contained in:
Janet B. Anderson
1991-04-18 15:18:40 +00:00
parent 030dc689a5
commit ffc67e2414
7 changed files with 54 additions and 39 deletions

View File

@@ -1,6 +1,7 @@
/* dbAccess.c */
/* share/src/db $Id$ */
/* share/src/db $Id$ */
/*dbAccess.c
@@ -287,8 +288,9 @@ long dbNameToAddr(pname,paddr)
char *pname;
struct dbAddr *paddr;
{
char *pbuffer;
char buffer[PVNAME_SZ+FLDNAME_SZ+2];
char *precName;
char recName[PVNAME_SZ+1];
char *pfieldName;
short field_offset;
short record_number;
short n;
@@ -299,24 +301,29 @@ struct dbAddr *paddr;
struct fldDes *pfldDes;
/* convert the record name */
pbuffer = &buffer[0];
precName = &recName[0];
n=0;
while(*pname && (*pname != '.') && n<sizeof(buffer) ){
*pbuffer = *pname;
while(*pname && (*pname != '.') && (n<PVNAME_SZ) ){
*precName = *pname;
pname++;
pbuffer++;
precName++;
n++;
}
*pbuffer = 0;
if (pvdGetRec(&buffer[0],&(paddr->record_type),&record_number) < 0){
*precName = 0;
if (pvdGetRec(&recName[0],&(paddr->record_type),&record_number) < 0){
(long)(paddr->precord) = -1;
paddr->record_type = -1;
return(S_db_notFound);
}
/* convert the field name */
if (*pname) pname++;
if (!(pfldDes=pvdGetFld(paddr->record_type,pname))){
if(*pname=='.') pfieldName = pname +1;
else if(n==PVNAME_SZ && *(pname+1)=='.') pfieldName = pname+2;
else {/*Field name was not given. Use recName as a work area*/
recName[0] = 0;
pfieldName = &recName[0];
}
if (!(pfldDes=pvdGetFld(paddr->record_type,pfieldName))){
paddr->field_type = -1;
(long)(paddr->pfield) = -1;
paddr->field_size = -1;
@@ -753,13 +760,18 @@ long offset;
char *psrc=paddr->pfield;
short size=paddr->field_size;
/* always force result string to be null terminated*/
if(size>=MAX_STRING_SIZE) size = MAX_STRING_SIZE-1;
if(nRequest==1 && offset==0) {
strncpy(pbuffer,psrc,size);
*(pbuffer+size) = 0;
return(0);
}
psrc+= (size*offset);
while (nRequest) {
strncpy(pbuffer,psrc,size);
*(pbuffer+size) = 0;
pbuffer += MAX_STRING_SIZE;
if(++offset==no_elements)
psrc=paddr->pfield;
@@ -3178,11 +3190,12 @@ choice_common:
pdbr_enumStrs->no_str = no_str;
ptemp = &(pdbr_enumStrs->strs[0][0]);
for (i=0; i<no_str; i++) {
if(pchoiceSet->papChoice[i]==NULL)
*ptemp=0;
else
strncpy(ptemp,pchoiceSet->papChoice[i],26);
ptemp += 26;
if(pchoiceSet->papChoice[i]==NULL) *ptemp=0;
else {
strncpy(ptemp,pchoiceSet->papChoice[i],sizeof(pdbr_enumStrs->strs[0]));
*(ptemp+sizeof(pdbr_enumStrs->strs[0])-1) = 0;
}
ptemp += sizeof(pdbr_enumStrs->strs[0]);
}
break;
case DBF_DEVCHOICE:
@@ -3200,9 +3213,11 @@ choice_common:
pdevChoice=GET_DEV_CHOICE(pdevChoiceSet,i);
if(pdevChoice==NULL || pdevChoice->pchoice==NULL)
*ptemp=0;
else
strncpy(ptemp,pdevChoice->pchoice,26);
ptemp += 26;
else {
strncpy(ptemp,pdevChoice->pchoice,sizeof(pdbr_enumStrs->strs[0]));
*(ptemp+sizeof(pdbr_enumStrs->strs[0])-1) = 0;
}
ptemp += sizeof(pdbr_enumStrs->strs[0]);
}
break;
default:
@@ -3363,11 +3378,13 @@ long offset;
if(nRequest==1 && offset==0) {
strncpy(pdest,pbuffer,size);
*(pdest+size-1) = 0;
return(0);
}
pdest+= (size*offset);
while (nRequest) {
strncpy(pdest,pbuffer,size);
*(pdest+size-1) = 0;
pbuffer += MAX_STRING_SIZE;
if(++offset==no_elements)
pdest=paddr->pfield;

View File

@@ -988,7 +988,7 @@ static int dbpr_report(pname, paddr, interest_level, pMsgBuff, tab_size)
pRecordName = &RecordName[0];
pName = pname;
n = 0;
while (*pName && (*pName != '.') && n < sizeof(RecordName)) {
while (*pName && (*pName != '.') && (n < PVNAME_SZ)) {
*pRecordName = *pName;
pName++;
pRecordName++;
@@ -1418,6 +1418,7 @@ static int dbprReportGblChoice(pMsgBuff,precord,pfield_name,choice_value, tab_si
char *pmsg = pMsgBuff->message;
strncpy(name,precord->name,PVNAME_SZ);
name[PVNAME_SZ]=0;
strcat(name,".");
strncat(name,pfield_name,FLDNAME_SZ);
if(dbNameToAddr(name,&dbAddr)) {
@@ -1452,6 +1453,7 @@ static void dbprReportRecChoice(pMsgBuff,precord,pfield_name,choice_value,tab_si
char *pmsg = pMsgBuff->message;
strncpy(name,precord->name,PVNAME_SZ);
name[PVNAME_SZ]=0;
strcat(name,".");
strncat(name,pfield_name,FLDNAME_SZ);
if(dbNameToAddr(name,&dbAddr)) {
@@ -1499,7 +1501,8 @@ static void dbprReportDevChoice(pMsgBuff,paddr,pfield_name, tab_size)
return;
}
strncpy(buff,pdevChoice->pchoice,MAX_STRING_SIZE);
sprintf(pmsg,"%4s: %s",
buff[MAX_STRING_SIZE] = 0;
sprintf(pmsg,"%4s: %s",
pfield_name,
buff);
dbpr_msgOut(pMsgBuff,tab_size);

View File

@@ -519,7 +519,7 @@ new_alarm(){
/*
* DB_NAME_TO_ADDR
*/
static short mapNewToOld[]={0,1,1,1,1,5,5,2,6,3,7};
static short mapNewToOld[]={0,4,4,1,1,5,5,2,6,3};
db_name_to_addr(pname,paddr)
char *pname;
@@ -531,11 +531,11 @@ db_name_to_addr(pname,paddr)
status=dbNameToAddr(pname,paddr);
if(RTN_SUCCESS(status)) {
ftype = paddr->dbr_field_type;
if(ftype<0 || ftype> (sizeof(mapNewToOld)/sizeof(short))) {
printf("db_name_to_addr: Illegal dbr_field_type\n");
exit(-1);
if(INVALID_DB_REQ(ftype)) {
recGblDbaddrError(S_db_badDbrtype,paddr,"db_name_to_addr error");
return(-2);
}
paddr->dbr_field_type = mapNewToOld[paddr->dbr_field_type];
paddr->dbr_field_type = mapNewToOld[ftype];
return(0);
}
else

View File

@@ -1,5 +1,6 @@
/* iocInit.c ioc initialization */
/* share/src/db @(#)iocInit.c 1.7 3/6/91 */
/* share/src/db $Id$ */
#include <vxWorks.h>
#include <types.h>
@@ -64,13 +65,10 @@ char * pfilename;
if(initDrvSup()==0) logMsg("Drivers Initialized\n");
if(initRecSup()==0) logMsg("Record Support Initialized\n");
if(initDevSup()==0) logMsg("Device Support Initialized\n");
ts_init(); logMsg("Time Stamp Driver Initialized\n");
if(initDatabase()==0) logMsg("Database Initialized\n");
scan_init();
logMsg("Scanners Initialized\n");
rsrv_init();
logMsg("Channel Access Servers Initialized\n");
ts_init();
logMsg("Time Stamp Driver Initialized\n");
scan_init(); logMsg("Scanners Initialized\n");
rsrv_init(); logMsg("Channel Access Servers Initialized\n");
logMsg("iocInit: All initialization complete\n");
return(0);
@@ -275,6 +273,7 @@ long initDatabase()
plink = (struct link *)((char *)precord + pfldDes->offset);
if(plink->type == PV_LINK) {
strncpy(name,plink->value.pv_link.pvname,PVNAME_SZ);
name[PVNAME_SZ]=0;
strcat(name,".");
strncat(name,plink->value.pv_link.fldname,FLDNAME_SZ);
if(dbNameToAddr(name,&dbAddr) == 0) {
@@ -289,6 +288,7 @@ long initDatabase()
else {
/*This will be replaced by channel access call*/
strncpy(message,precord->name,PVNAME_SZ);
message[PVNAME_SZ]=0;
strcat(message,".");
strncat(message,pfldDes->fldname,FLDNAME_SZ);
strcat(message,": link process variable =");

View File

@@ -82,7 +82,6 @@ static long read_bi(pbi)
pbi->nsev = VALID_ALARM;
pbi->nsta = LINK_ALARM;
}
return(2);
}
break;
case (CA_LINK) :

View File

@@ -82,7 +82,6 @@ static long read_bi(pbi)
pbi->nsev = VALID_ALARM;
pbi->nsta = LINK_ALARM;
}
return(2);
}
break;
case (CA_LINK) :
@@ -98,5 +97,5 @@ static long read_bi(pbi)
}
}
}
return(2);
return(0);
}

View File

@@ -71,7 +71,6 @@ static long read_mbbi(pmbbi)
/* mbbi.inp must be a CONSTANT or a DB_LINK or a CA_LINK*/
switch (pmbbi->inp.type) {
case (CONSTANT) :
return(2);
break;
case (DB_LINK) :
options=0;
@@ -83,7 +82,6 @@ static long read_mbbi(pmbbi)
pmbbi->nsev = VALID_ALARM;
pmbbi->nsta = LINK_ALARM;
}
return(2);
}
break;
case (CA_LINK) :
@@ -98,7 +96,6 @@ static long read_mbbi(pmbbi)
errMessage(S_db_badField,message);
}
}
return(2);
}
return(0);
}