changes for 3.14
This commit is contained in:
@@ -1,7 +1,24 @@
|
||||
|
||||
TOP=../..
|
||||
|
||||
include $(TOP)/config/CONFIG_BASE
|
||||
include $(TOP)/configure/CONFIG
|
||||
|
||||
include $(TOP)/config/RULES_ARCHS
|
||||
YACCOPT := -l
|
||||
LEXOPT := -L
|
||||
|
||||
#dbSubs_SRCS = dbLoadTemplate_lex.c
|
||||
dbSubs_SRCS += dbLoadTemplate.c
|
||||
|
||||
IOC_LIBRARY_vxWorks = dbSubs
|
||||
|
||||
include $(TOP)/configure/RULES_BUILD
|
||||
|
||||
#
|
||||
# These lex sources are included in some C sources,
|
||||
# so they have to be created in time:
|
||||
#
|
||||
dbLoadTemplate$(OBJ): dbLoadTemplate_lex.c
|
||||
|
||||
clean::
|
||||
@$(RM) dbLoadTemplate_lex.c dbLoadTemplate.c
|
||||
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
# base/src/dbtools/Makefile.Host
|
||||
#
|
||||
|
||||
TOP = ../../..
|
||||
include $(TOP)/config/CONFIG_BASE
|
||||
|
||||
YACCOPT := -l
|
||||
LEXOPT := -L
|
||||
|
||||
|
||||
# includes and manual pages to install:
|
||||
#
|
||||
MAN1 := dbLoadTemplate.1
|
||||
MAN3 := dbLoadRecords.3 dbLoadTemplate.3
|
||||
MAN5 := templatefile.5 dbfile.5
|
||||
|
||||
|
||||
# uses getopt, optind, optarg from lib Com:
|
||||
PROD_LIBS := Db Com
|
||||
PROD := dbLoadTemplate
|
||||
|
||||
# hard-coded dependencies and rules,
|
||||
# hopefully system-independent
|
||||
|
||||
# SRCS for and dbLoadTemplate
|
||||
#
|
||||
SRCS = dbLoadTemplate.c dbLoadRecords.c
|
||||
|
||||
|
||||
include $(TOP)/config/RULES.Host
|
||||
|
||||
#
|
||||
# These lex sources are included in some C sources,
|
||||
# so they have to be created in time:
|
||||
#
|
||||
dbLoadTemplate$(OBJ): dbLoadTemplate_lex.c
|
||||
dbLoadRecords$(OBJ): dbLoadRecords_lex.c
|
||||
|
||||
clean::
|
||||
@$(RM) dbLoadTemplate_lex.c dbLoadTemplate.c dbLoadRecords_lex.c \
|
||||
dbLoadRecords.c
|
||||
|
||||
# EOF base/src/dbtools/Makefile.Host
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
TOP = ../../..
|
||||
include $(TOP)/config/CONFIG_BASE
|
||||
|
||||
YACCOPT = -l
|
||||
LEXOPT = -L
|
||||
|
||||
SRCS.c = dbLoadTemplate_lex.c
|
||||
SRCS.c += dbLoadTemplate.c
|
||||
SRCS.c += dbLoadRecords_lex.c
|
||||
SRCS.c += dbLoadRecords.c
|
||||
|
||||
LIBOBJS = dbLoadTemplate.o
|
||||
LIBOBJS += dbLoadRecords.o
|
||||
|
||||
LIBNAME = dbSubs
|
||||
|
||||
include $(TOP)/config/RULES.Vx
|
||||
|
||||
#USR_CFLAGS = -I../../rsrv -I../../ca
|
||||
|
||||
dbLoadTemplate.o: dbLoadTemplate_lex.c
|
||||
dbLoadRecords.o: dbLoadRecords_lex.c
|
||||
|
||||
clean::
|
||||
@$(RM) dbLoadTemplate_lex.c dbLoadTemplate.c dbLoadRecords_lex.c \
|
||||
dbLoadRecords.c
|
||||
|
||||
|
||||
@@ -1,116 +0,0 @@
|
||||
.\" @(#)dbLoadRecords.3 1 93/11/04 SMI;
|
||||
.TH DBLOADRECORDS 3 "11 Nov 1993"
|
||||
.SH NAME
|
||||
dbLoadRecords, dbLoadTemplate \- load ascii database records into an IOC
|
||||
.SH SYNOPSIS
|
||||
.LP
|
||||
dbLoadRecords(char* db_file, char* substitutions)
|
||||
.LP
|
||||
dbLoadTemplate(char* template_file)
|
||||
.SH DESCRIPTION
|
||||
.LP
|
||||
These routines are available from IOC core on the vxWorks command line.
|
||||
Both provide a way to load ascii ".db" files (usually created by
|
||||
.B gdct(1)
|
||||
) into the IOC. The ".db" files contain ascii versions of record instances
|
||||
and are described in more detail in dbfile(5). In addition to
|
||||
loading the ".db" ascii files into the IOC, both routines provide a method
|
||||
of performing variable substitution on record names and field values.
|
||||
.sp
|
||||
.B dbLoadRecords()
|
||||
reads the ".db" file
|
||||
.I db_file
|
||||
performing substitutions specified in string
|
||||
.I substitutions.
|
||||
The substitution must be a string specified as follows:
|
||||
.sp
|
||||
.nf
|
||||
"var1=sub1,var2=sub3,..."
|
||||
.fi
|
||||
.sp
|
||||
Variables are specified in the ".db" file as $(variable_name). If the
|
||||
substitution string "a=1,b=2,c=\\"this is a test\\"" were used, any
|
||||
variables $(a), $(b), or $(c) would be substituted with the appropriate data.
|
||||
See the
|
||||
.B EXAMPLES
|
||||
section for more details.
|
||||
.sp
|
||||
.B dbLoadTemplate()
|
||||
will read a
|
||||
.I template_file.
|
||||
The
|
||||
.I template_file
|
||||
resides in the your IOC boot directory and
|
||||
contains rules about loading ".db" files and performing substitutions.
|
||||
The template_file must be in the form used by an IOC and is described in
|
||||
templatefile(5). The
|
||||
.B EXAMPLES
|
||||
section descibes how it can be used.
|
||||
.SH EXAMPLES
|
||||
The next two examples of dbLoadRecords() and dbLoadTemplate() will
|
||||
use the following ".db" file named
|
||||
.I test.db
|
||||
:
|
||||
.sp
|
||||
.nf
|
||||
database(test)
|
||||
{
|
||||
record(ai,"$(pre)testrec1")
|
||||
record(ai,"$(pre)testrec2")
|
||||
record(stringout,"$(pre)testrec3")
|
||||
{
|
||||
field(VAL,"$(STRING)")
|
||||
field(SCAN,"$(SCAN)")
|
||||
}
|
||||
}
|
||||
.fi
|
||||
.sp
|
||||
Running
|
||||
.B dbLoadRecords
|
||||
("test.db","pre=TEST,STRING=\\"this is a test\\",SCAN=Passive")
|
||||
will produce the following records in the IOC's database:
|
||||
.sp
|
||||
.nf
|
||||
TESTtestrec1
|
||||
TESTtestrec2
|
||||
TESTtestrec3
|
||||
.fi
|
||||
.sp
|
||||
The third record will have VAL set to "this is a test" and SCAN set to
|
||||
"Passive".
|
||||
.sp
|
||||
Running
|
||||
.B dbLoadTemplate
|
||||
("test.template") with test.template containing:
|
||||
.nf
|
||||
file test.db
|
||||
{
|
||||
{pre=TEST1, STRING = "this is a test two", SCAN="1 Second" }
|
||||
{pre=TEST2, STRING = "this is a test one", SCAN=Passive }
|
||||
{pre=TEST3, STRING = "this is a test three", SCAN=Passive }
|
||||
}
|
||||
.fi
|
||||
will produce a total of nine records in the IOC's database:
|
||||
.nf
|
||||
TEST1testrec1
|
||||
TEST1testrec2
|
||||
TEST1testrec3 - (VAL="this is a test two", SCAN="1 Second")
|
||||
TEST2testrec1
|
||||
TEST2testrec2
|
||||
TEST2testrec3 - (VAL="this is a test one", SCAN="Passive")
|
||||
TEST3testrec1
|
||||
TEST3testrec2
|
||||
TEST3testrec3 - (VAL="this is a test three", SCAN="Passive")
|
||||
.fi
|
||||
.SH NOTES
|
||||
The binary file
|
||||
.IR "default.dctsdr"
|
||||
must be loaded prior to running either of these routines. This file
|
||||
contains the rules on how to construct records and change field values.
|
||||
.sp
|
||||
After the default.dctsdr file is loaded, these routines can be run as
|
||||
many times as desired until iocInit is run.
|
||||
.SH "SEE ALSO"
|
||||
.BR gdct(1),
|
||||
.BR templatefile(5),
|
||||
.BR dbfile(5)
|
||||
@@ -1,368 +0,0 @@
|
||||
%{
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* Author: Jim Kowalkowski
|
||||
*
|
||||
* Experimental Physics and Industrial Control System (EPICS)
|
||||
*
|
||||
* Copyright 1991, the Regents of the University of California,
|
||||
* and the University of Chicago Board of Governors.
|
||||
*
|
||||
* This software was produced under U.S. Government contracts:
|
||||
* (W-7405-ENG-36) at the Los Alamos National Laboratory,
|
||||
* and (W-31-109-ENG-38) at Argonne National Laboratory.
|
||||
*
|
||||
* Initial development by:
|
||||
* The Controls and Automation Group (AT-8)
|
||||
* Ground Test Accelerator
|
||||
* Accelerator Technology Division
|
||||
* Los Alamos National Laboratory
|
||||
*
|
||||
* Co-developed with
|
||||
* The Controls and Computing Group
|
||||
* Accelerator Systems Division
|
||||
* Advanced Photon Source
|
||||
* Argonne National Laboratory
|
||||
*
|
||||
* Modification Log:
|
||||
* -----------------
|
||||
* .01 10-29-93 jbk initial version
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "macLib.h"
|
||||
#include "dbStaticLib.h"
|
||||
#include "dbmf.h"
|
||||
#include "epicsVersion.h"
|
||||
|
||||
#define VAR_MAX_SUB_SIZE 300
|
||||
static char *subst_buffer= NULL;
|
||||
static int subst_used;
|
||||
static int line_num;
|
||||
static MAC_HANDLE *macHandle = NULL;
|
||||
|
||||
struct db_app_node
|
||||
{
|
||||
char* name;
|
||||
struct db_app_node* next;
|
||||
};
|
||||
typedef struct db_app_node DB_APP_NODE;
|
||||
|
||||
DB_APP_NODE* DbApplList=(DB_APP_NODE*)NULL;
|
||||
static DB_APP_NODE* DbCurrentListHead=(DB_APP_NODE*)NULL;
|
||||
static DB_APP_NODE* DbCurrentListTail=(DB_APP_NODE*)NULL;
|
||||
|
||||
static int yyerror();
|
||||
static void sub_pvname(char*,char*);
|
||||
|
||||
#ifdef vxWorks
|
||||
static DBENTRY* pdbentry;
|
||||
extern struct dbBase *pdbbase;
|
||||
#endif
|
||||
|
||||
static char* strduplicate(char* x)
|
||||
{
|
||||
char* c;
|
||||
c=(char*)malloc(strlen(x)+1);
|
||||
strcpy(c,x);
|
||||
return c;
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
%start database
|
||||
|
||||
%token <Str> COMMA
|
||||
%token <Str> WORD VALUE
|
||||
%token <Str> FIELD
|
||||
%left O_BRACE C_BRACE O_PAREN C_PAREN
|
||||
%left DATABASE RECORD
|
||||
%left NOWHERE
|
||||
%token APPL
|
||||
|
||||
%union
|
||||
{
|
||||
int Int;
|
||||
char Char;
|
||||
char *Str;
|
||||
double Real;
|
||||
}
|
||||
|
||||
%%
|
||||
|
||||
database: DATABASE d_head d_body
|
||||
| DATABASE d_head /* jbk added for graphical thing */
|
||||
| db_components
|
||||
;
|
||||
|
||||
d_head: O_PAREN WORD C_PAREN
|
||||
{ dbmfFree($2); }
|
||||
| O_PAREN WORD COMMA VALUE C_PAREN
|
||||
{ dbmfFree($2); dbmfFree($4); }
|
||||
;
|
||||
|
||||
d_body: O_BRACE nowhere_records db_components C_BRACE
|
||||
;
|
||||
|
||||
/* nowhere is here for back compatability */
|
||||
|
||||
nowhere_records: /* null */
|
||||
| NOWHERE n_head n_body
|
||||
;
|
||||
|
||||
n_head: O_PAREN C_PAREN
|
||||
;
|
||||
|
||||
n_body: O_BRACE records C_BRACE
|
||||
;
|
||||
|
||||
db_components: /* null */
|
||||
| db_components applic
|
||||
| db_components record
|
||||
;
|
||||
|
||||
applic: APPL O_PAREN VALUE C_PAREN
|
||||
{
|
||||
DB_APP_NODE* an=(DB_APP_NODE*)malloc(sizeof(DB_APP_NODE*));
|
||||
|
||||
if(subst_used)
|
||||
{
|
||||
int n;
|
||||
|
||||
n = macExpandString(macHandle,$<Str>3,subst_buffer,
|
||||
VAR_MAX_SUB_SIZE-1);
|
||||
if(n<0) fprintf(stderr,"macExpandString failed\n");
|
||||
#ifdef vxWorks
|
||||
an->name=strduplicate(subst_buffer);
|
||||
dbmfFree($3);
|
||||
#else
|
||||
printf("\napplication(\"%s\")\n",subst_buffer);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef vxWorks
|
||||
an->name=strduplicate($<Str>3);
|
||||
dbmfFree($3);
|
||||
#else
|
||||
printf("\napplication(\"%s\")\n",$<Str>3);
|
||||
#endif
|
||||
}
|
||||
if(DbCurrentListHead==(DB_APP_NODE*)NULL) DbCurrentListTail=an;
|
||||
|
||||
an->next=DbCurrentListHead;
|
||||
DbCurrentListHead=an;
|
||||
}
|
||||
;
|
||||
|
||||
records: /* null */
|
||||
| records record
|
||||
;
|
||||
|
||||
record: RECORD r_head r_body
|
||||
{
|
||||
#ifndef vxWorks
|
||||
printf("}\n");
|
||||
#endif
|
||||
}
|
||||
;
|
||||
|
||||
r_head: O_PAREN WORD COMMA WORD C_PAREN
|
||||
{
|
||||
sub_pvname($2,$4);
|
||||
dbmfFree($2); dbmfFree($4);
|
||||
}
|
||||
| O_PAREN WORD COMMA VALUE C_PAREN
|
||||
{
|
||||
sub_pvname($2,$4);
|
||||
dbmfFree($2); dbmfFree($4);
|
||||
}
|
||||
;
|
||||
|
||||
r_body: /* null */
|
||||
| O_BRACE fields C_BRACE
|
||||
;
|
||||
|
||||
fields: /* null */
|
||||
| fields field
|
||||
;
|
||||
|
||||
field: FIELD O_PAREN WORD COMMA VALUE C_PAREN
|
||||
{
|
||||
#ifdef vxWorks
|
||||
if( dbFindField(pdbentry,$<Str>3) )
|
||||
fprintf(stderr,"Cannot find field %s\n",$<Str>3);
|
||||
#endif
|
||||
if(subst_used)
|
||||
{
|
||||
int n;
|
||||
|
||||
n = macExpandString(macHandle,$<Str>5,subst_buffer,
|
||||
VAR_MAX_SUB_SIZE-1);
|
||||
if(n<0) fprintf(stderr,"macExpandString failed\n");
|
||||
#ifdef vxWorks
|
||||
if( dbPutString(pdbentry, subst_buffer) )
|
||||
fprintf(stderr,"Cannot set field %s to %s\n",
|
||||
$<Str>3,subst_buffer);
|
||||
#else
|
||||
printf("\n\t\tfield(%s, \"%s\")",$<Str>3,subst_buffer);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef vxWorks
|
||||
if( dbPutString(pdbentry, $<Str>5) )
|
||||
fprintf(stderr,"Cannot set field %s to %s\n",$<Str>3,$<Str>5);
|
||||
#else
|
||||
printf("\n\t\tfield(%s, \"%s\")",$<Str>3,$<Str>5);
|
||||
#endif
|
||||
}
|
||||
dbmfFree($3); dbmfFree($5);
|
||||
}
|
||||
;
|
||||
|
||||
%%
|
||||
|
||||
#include "dbLoadRecords_lex.c"
|
||||
|
||||
static int yyerror(str)
|
||||
char *str;
|
||||
{
|
||||
fprintf(stderr,"db file parse, Error line %d : %s\n",line_num, yytext);
|
||||
return(0);
|
||||
}
|
||||
|
||||
static int is_not_inited = 1;
|
||||
|
||||
int dbLoadRecords(char* pfilename, char* pattern)
|
||||
{
|
||||
FILE* fp;
|
||||
char **macPairs;
|
||||
|
||||
line_num=0;
|
||||
|
||||
#ifdef vxWorks
|
||||
if(pdbbase==NULL)
|
||||
{
|
||||
fprintf(stderr,"dbLoadRecords: dbLoadDatabase not called\n");
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if( pattern && *pattern )
|
||||
{
|
||||
subst_buffer = malloc(VAR_MAX_SUB_SIZE);
|
||||
subst_used = 1;
|
||||
if(macCreateHandle(&macHandle,NULL)) {
|
||||
fprintf(stderr,"dbLoadRecords macCreateHandle error\n");
|
||||
return -1;
|
||||
}
|
||||
macParseDefns(macHandle,pattern,&macPairs);
|
||||
if(macPairs == NULL) {
|
||||
macDeleteHandle(macHandle);
|
||||
macHandle = NULL;
|
||||
} else {
|
||||
macInstallMacros(macHandle,macPairs);
|
||||
free((void *)macPairs);
|
||||
}
|
||||
}
|
||||
else
|
||||
subst_used = 0;
|
||||
if( !(fp=fopen(pfilename,"r")) )
|
||||
{
|
||||
fprintf(stderr,"dbLoadRecords: error opening file\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(is_not_inited)
|
||||
{
|
||||
yyin=fp;
|
||||
is_not_inited=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
yyrestart(fp);
|
||||
}
|
||||
|
||||
#ifdef vxWorks
|
||||
pdbentry=dbAllocEntry(pdbbase);
|
||||
#endif
|
||||
|
||||
yyparse();
|
||||
|
||||
#ifdef vxWorks
|
||||
dbFreeEntry(pdbentry);
|
||||
#endif
|
||||
|
||||
if(subst_used) {
|
||||
macDeleteHandle(macHandle);
|
||||
macHandle = NULL;
|
||||
free((void *)subst_buffer);
|
||||
subst_buffer = NULL;
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
|
||||
if(DbCurrentListHead==(DB_APP_NODE*)NULL)
|
||||
{
|
||||
/* set up a default list to put on the master application list */
|
||||
DbCurrentListHead=(DB_APP_NODE*)malloc(sizeof(DB_APP_NODE));
|
||||
DbCurrentListTail=DbCurrentListHead;
|
||||
DbCurrentListHead->name=strduplicate(pfilename);
|
||||
DbCurrentListHead->next=(DB_APP_NODE*)NULL;
|
||||
}
|
||||
|
||||
DbCurrentListTail->next=DbApplList;
|
||||
DbApplList=DbCurrentListHead;
|
||||
DbCurrentListHead=(DB_APP_NODE*)NULL;
|
||||
DbCurrentListTail=(DB_APP_NODE*)NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void sub_pvname(char* type, char* name)
|
||||
{
|
||||
#ifdef vxWorks
|
||||
if( dbFindRecordType(pdbentry,type) )
|
||||
fprintf(stderr,"Cannot find record type %s\n",type);
|
||||
#endif
|
||||
|
||||
if(subst_used)
|
||||
{
|
||||
int n;
|
||||
|
||||
n = macExpandString(macHandle,name,subst_buffer,
|
||||
VAR_MAX_SUB_SIZE-1);
|
||||
if(n<0) fprintf(stderr,"macExpandString failed\n");
|
||||
#ifdef vxWorks
|
||||
dbCreateRecord(pdbentry,subst_buffer);
|
||||
#else
|
||||
printf("record(%s,\"%s\") {",type,subst_buffer);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef vxWorks
|
||||
dbCreateRecord(pdbentry,name);
|
||||
#else
|
||||
printf("record(%s,\"%s\") {",type,name);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef vxWorks
|
||||
int dbAppList()
|
||||
{
|
||||
DB_APP_NODE* an;
|
||||
|
||||
for(an=DbApplList;an;an=an->next)
|
||||
printf("%s\n",an->name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
@@ -1,42 +0,0 @@
|
||||
|
||||
pvname [a-zA-Z0-9_~\-:\.\[\]<>;]
|
||||
notquote [^\"]
|
||||
escapequote \\\"
|
||||
value {notquote}|{escapequote}
|
||||
|
||||
%{
|
||||
%}
|
||||
|
||||
%%
|
||||
|
||||
\#.*\n ;
|
||||
|
||||
"field" { return(FIELD); }
|
||||
"grecord" { return(RECORD); }
|
||||
"record" { return(RECORD); }
|
||||
"database" { return(DATABASE); }
|
||||
"nowhere" { return(NOWHERE); }
|
||||
"application" { return(APPL); }
|
||||
|
||||
|
||||
{pvname}+ { yylval.Str=(char *)dbmfMalloc(strlen(yytext)+1);
|
||||
strcpy(yylval.Str,yytext);
|
||||
return(WORD);
|
||||
}
|
||||
|
||||
\"{value}*\" { yylval.Str=(char *)dbmfMalloc(strlen(yytext)+1);
|
||||
yytext[strlen(yytext)-1] = '\0';
|
||||
strcpy(yylval.Str,yytext+1);
|
||||
return(VALUE);
|
||||
}
|
||||
|
||||
"{" { return(O_BRACE); }
|
||||
"}" { return(C_BRACE); }
|
||||
"(" { return(O_PAREN); }
|
||||
")" { return(C_PAREN); }
|
||||
"," { return(COMMA); }
|
||||
|
||||
. ;
|
||||
\n { line_num ++;}
|
||||
|
||||
%%
|
||||
@@ -49,13 +49,8 @@ int dbLoadTemplate(char* sub_file);
|
||||
|
||||
int dbLoadRecords(char* pfilename, char* pattern);
|
||||
|
||||
#ifdef vxWorks
|
||||
#define VAR_MAX_VAR_STRING 5000
|
||||
#define VAR_MAX_VARS 100
|
||||
#else
|
||||
#define VAR_MAX_VAR_STRING 50000
|
||||
#define VAR_MAX_VARS 700
|
||||
#endif
|
||||
|
||||
static char *sub_collect = NULL;
|
||||
static MAC_HANDLE *macHandle = NULL;
|
||||
@@ -320,45 +315,3 @@ int dbLoadTemplate(char* sub_file)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef vxWorks
|
||||
/* this is template loader similar to vxWorks one for .db files */
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
extern char* optarg;
|
||||
extern int optind;
|
||||
char* name = (char*)NULL;
|
||||
int no_error = 1;
|
||||
int c;
|
||||
|
||||
while(no_error && (c=getopt(argc,argv,"s:"))!=-1)
|
||||
{
|
||||
switch(c)
|
||||
{
|
||||
case 's':
|
||||
if(name) dbmfFree(name);
|
||||
name = dbmfMalloc(strlen(optarg));
|
||||
strcpy(name,optarg);
|
||||
break;
|
||||
default: no_error=0; break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!no_error || optind>=argc)
|
||||
{
|
||||
fprintf(stderr,"Usage: %s <-s name> sub_file\n",argv[0]);
|
||||
fprintf(stderr,"\n\twhere name is the output database name and\n");
|
||||
fprintf(stderr,"\tsub_file in the variable substitution file\n");
|
||||
fprintf(stderr,"\n\tThis program used the sub_file to produce a\n");
|
||||
fprintf(stderr,"\tdatabase of name name to standard out.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if(!name) {
|
||||
name = dbmfMalloc(strlen("Composite") + 1);
|
||||
strcpy(name,"Composite");
|
||||
}
|
||||
dbLoadTemplate(argv[1]);
|
||||
dbmfFree((void *)name);
|
||||
return(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
.\" @(#)dbfile.5 1 93/11/04 SMI;
|
||||
.TH DBFILE 5 "04 Nov 1993"
|
||||
.SH NAME
|
||||
".db" \- File containing textual EPICS database records and field values
|
||||
.SH SYNOPSIS
|
||||
.B file_name.db
|
||||
.SH DESCRIPTION
|
||||
.LP
|
||||
This is a file which holds EPICS database record instances in a human
|
||||
readable format. It is a replacement for the old dct short form report.
|
||||
The general format is as follows:
|
||||
.sp
|
||||
.nf
|
||||
database(database_name,"epics_release")
|
||||
{
|
||||
record( rec_type, "record_name-1" )
|
||||
{
|
||||
field( field_name-1, "field_value-1" )
|
||||
field( field_name-2, "field_value-2" )
|
||||
field( field_name-3, "field_value-3" )
|
||||
.
|
||||
.
|
||||
.
|
||||
}
|
||||
record( rec_type, "record_name-2" )
|
||||
{
|
||||
field( field_name-1, "field_value-1" )
|
||||
field( field_name-2, "field_value-2" )
|
||||
field( field_name-3, "field_value-3" )
|
||||
.
|
||||
.
|
||||
.
|
||||
}
|
||||
.
|
||||
.
|
||||
.
|
||||
}
|
||||
.fi
|
||||
.sp
|
||||
The database_name is a name used to generate a binary ".database" file
|
||||
with (do not use the extension ".database").
|
||||
The epics_release will probably be the 3.11 or greater. The rec_type
|
||||
is any valid record type defined in a default.dctsdr file. The record_name
|
||||
can be any string up to 29 characters in length. The field_name is any
|
||||
valid field name for the record type, always four or less alphanumeric
|
||||
characters. The field_value is any string that is valid
|
||||
input for the field_name.
|
||||
.SH EXAMPLES
|
||||
The following is an example of a database with three records. The first
|
||||
two records use all default values, the third replaces the SCAN field and
|
||||
VAL field.
|
||||
.sp
|
||||
.nf
|
||||
database(test)
|
||||
{
|
||||
record(ai,"ai_record")
|
||||
record(bo,"bo_record")
|
||||
record(stringout,"sout_record")
|
||||
{
|
||||
field(SCAN,"1 second")
|
||||
field(VAL,"This is a string")
|
||||
}
|
||||
}
|
||||
.fi
|
||||
.SH "SEE ALSO"
|
||||
.BR gdct(1),
|
||||
.BR db2database(1),
|
||||
.BR dbLoadRecords(3),
|
||||
.BR sf2db(1)
|
||||
@@ -1,76 +0,0 @@
|
||||
.\" @(#)templatefile.5 1 93/11/04 SMI;
|
||||
.TH TEMPLATEFILE 5 "04 Nov 1993"
|
||||
.SH NAME
|
||||
templatefile \- The file containing rules for substitutions.
|
||||
.SH DESCRIPTION
|
||||
.LP
|
||||
This file contains the rules for performing substitutions on ".db" files.
|
||||
.sp
|
||||
The purpose of this file is to specify a set of substitutions to be
|
||||
performed on a file. Substitutions can be defined in one of two ways.
|
||||
The general format for substitution
|
||||
sets is defined as follows:
|
||||
.nf
|
||||
.sp
|
||||
.B *Version-1*
|
||||
file name.db {
|
||||
{ set1var1=sub1, set1var2=sub2,...... }
|
||||
{ set2var1=sub1, set2var2=sub2,...... }
|
||||
{ set3var1=sub1, set3var2=sub2,...... }
|
||||
}
|
||||
\.
|
||||
\.
|
||||
\.
|
||||
|
||||
- or -
|
||||
|
||||
.B *Version-2*
|
||||
file name.db {
|
||||
pattern{ var1,var2,var3,....... }
|
||||
{ sub1_for_set1, sub2_for_set1, sub3_for_set1, ... }
|
||||
{ sub1_for_set2, sub2_for_set2, sub3_for_set2, ... }
|
||||
{ sub1_for_set3, sub2_for_set3, sub3_for_set3, ... }
|
||||
}
|
||||
\.
|
||||
\.
|
||||
\.
|
||||
.fi
|
||||
.sp
|
||||
Each braced line represents an entire variable substitution for the input
|
||||
file. The input file will have each set applied to it to produce
|
||||
one composite file with all the completed substitutions in it.
|
||||
Interpreting version 1 should be obvious, for version 2, the variables
|
||||
are listed in the "pattern{}" line, which must precede the braced
|
||||
substitution lines. The braced substitution lines contains set which
|
||||
match up with the pattern{} line. An example will be given later.
|
||||
.sp
|
||||
The keyword file identifies a
|
||||
.B dbfile(5)
|
||||
to perform the substitutions on, in this case "name.db".
|
||||
.SH EXAMPLES
|
||||
Four simple template file examples are listed here, the first two are
|
||||
IOC db specific, the last two are general ones. All the examples
|
||||
specify the same substitutions to perform: this=sub1 and that=sub2 for a
|
||||
first set, and this=sub3 and that=sub4 for a second set.
|
||||
.nf
|
||||
|
||||
1) file test.db { { this=sub1,that=sub2 } { this=sub3,that=sub4 } }
|
||||
2) file test.db { pattern{this,that} {sub1,sub2} {sub3,sub4 } }
|
||||
|
||||
input file for 1 and 2 (see dbfile(5) for examplanation of file):
|
||||
|
||||
database(test)
|
||||
{
|
||||
record(ai,"$(this)record") { field(DESC,"this = $(this)") }
|
||||
record(ai,"$(that)record") { field(DESC,"this = $(that)") }
|
||||
}
|
||||
|
||||
.fi
|
||||
When 1 and 2 are applied to their corresponding file, two sets of the
|
||||
record() lines will be produced: (sub1record,sub2record) and (sub3record,
|
||||
sub4record), see dbLoadTemplate(1) for a more thorough explanation.
|
||||
.SH NOTES
|
||||
No special spacing or carriage returns are required in this file.
|
||||
.SH "SEE ALSO"
|
||||
.BR dbLoadTemplate(1),
|
||||
.BR dbLoadTemplate(3),
|
||||
Reference in New Issue
Block a user