Moved sf2db to here
This commit is contained in:
@@ -5,12 +5,14 @@ include $(EPICS)/config/CONFIG_BASE
|
||||
USR_LDLIBS = -lCom
|
||||
USR_LDFLAGS = -L.
|
||||
|
||||
|
||||
DEPLIBS_BASE = $(EPICS_BASE_LIB)
|
||||
|
||||
DEPLIBS = \
|
||||
$(DEPLIBS_BASE)/libCom.a
|
||||
|
||||
SRCS.c = \
|
||||
sf2dbYacc.c\
|
||||
../sdr2gblmenu.c\
|
||||
../sdr2driver.c\
|
||||
../sdr2device.c\
|
||||
@@ -24,7 +26,9 @@ OBJS = \
|
||||
sdr2recordtype.o \
|
||||
dbStaticLib.o
|
||||
|
||||
TARGETS = sdr2gblmenu sdr2driver sdr2device sdr2recordtype
|
||||
MAN1 = sf2db.1
|
||||
|
||||
PROD = sf2db sdr2gblmenu sdr2driver sdr2device sdr2recordtype
|
||||
|
||||
include $(EPICS)/config/RULES.Unix
|
||||
|
||||
@@ -39,3 +43,12 @@ sdr2device: sdr2device.o dbStaticLib.o
|
||||
|
||||
sdr2recordtype: sdr2recordtype.o dbStaticLib.o
|
||||
$(LINK.c) -o $@ sdr2recordtype.o dbStaticLib.o $(LDLIBS)
|
||||
|
||||
sf2db: sf2dbYacc.o
|
||||
$(LINK.c) -o $@ sf2dbYacc.o
|
||||
|
||||
sf2dbYacc.o: sf2dbLex.c
|
||||
|
||||
clean::
|
||||
/bin/rm -f sf2dbYacc.c sf2dbLex.c
|
||||
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
.\" @(#)
|
||||
.TH SF2DB 1 "04 Nov 1993"
|
||||
.SH NAME
|
||||
sf2db \- make a new ascii database ".db" file from an old dct short form report
|
||||
.SH SYNOPSIS
|
||||
.B sf2db
|
||||
.B name
|
||||
<
|
||||
.B short_form_rpt
|
||||
>
|
||||
.B db_file
|
||||
.SH AVAILABILITY
|
||||
The tool in available under Unix from the EPICS add_on directory.
|
||||
.SH DESCRIPTION
|
||||
.LP
|
||||
This tool reads a dct short form report file from standard in and
|
||||
writes a ".db" (new ascii database format) file to standard out. A
|
||||
.B name
|
||||
must be given for the database. The name specified is used to name
|
||||
the ".database" file when the ".db" file is converted to a binary ".database".
|
||||
.sp
|
||||
The output of this tool can be imported to gdct(1) for editting.
|
||||
.SH "EXAMPLE USAGE"
|
||||
.LP
|
||||
sf2db test < old.short.form > new.db
|
||||
.sp
|
||||
This command will read old.short.form and produce the file new.db. When
|
||||
new.db is fed into db2database(1), a binary database file will be created
|
||||
named test.database.
|
||||
.SH "SEE ALSO"
|
||||
.BR gdct(1),
|
||||
.BR db2database(1),
|
||||
.BR dbLoadRecords(3),
|
||||
.BR dbfile(5),
|
||||
.sp
|
||||
.B "GDCT User's Manual"
|
||||
Executable
+26
@@ -0,0 +1,26 @@
|
||||
b [a-zA-Z0-9_]
|
||||
a [ \t]
|
||||
d [a-zA-Z0-9_\,\./\*#\{\}\[\]%:;!|\'\-&\(\)@\?\+<>=$\^\~]
|
||||
|
||||
%{
|
||||
%}
|
||||
|
||||
%%
|
||||
|
||||
^[A-Z0-9_]+ { yylval.Str=(char *)malloc(strlen(yytext)+1);
|
||||
strcpy(yylval.Str,yytext);
|
||||
return(FIELD); }
|
||||
|
||||
^"PV:" { return(PV); }
|
||||
"Type:" { return(TYPE); }
|
||||
"" { return(CLOSE); }
|
||||
"$$end" { return(CLOSE); }
|
||||
|
||||
{d}+ { yylval.Str=(char *)malloc(strlen(yytext)+1);
|
||||
strcpy(yylval.Str,yytext);
|
||||
return(WORD); }
|
||||
|
||||
. ;
|
||||
\n { line_num++; }
|
||||
|
||||
%%
|
||||
Executable
+151
@@ -0,0 +1,151 @@
|
||||
%{
|
||||
#include <stdio.h>
|
||||
#include <memory.h>
|
||||
#include <string.h>
|
||||
#include <epicsVersion.h>
|
||||
|
||||
#undef PUKE_FACE
|
||||
#if EPICS_VERSION<4
|
||||
#if EPICS_REVISION<13
|
||||
#if EPICS_MODIFICATION<1 && EPICS_UPDATE_LEVEL<12
|
||||
#define PUKE_FACE
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* kludge for buggy sun lex/yacc. exploits the fact that we know the union */
|
||||
/* below will be given the name YYSTYPE. done so that ifndef YYSTYPE */
|
||||
/* (as it appears in pdb.c) fails */
|
||||
/* #define YYSTYPE OUR_YYSTYPE */
|
||||
|
||||
int line_num;
|
||||
char Field_val[1000];
|
||||
|
||||
%}
|
||||
|
||||
%start sf2db
|
||||
|
||||
%token <Str> WORD
|
||||
%token <Str> FIELD
|
||||
%token <Str> TYPE
|
||||
%token <Str> PV CLOSE
|
||||
|
||||
%union
|
||||
{
|
||||
int Int;
|
||||
char Char;
|
||||
char *Str;
|
||||
double Real;
|
||||
}
|
||||
|
||||
%%
|
||||
|
||||
sf2db: crap_head records closer
|
||||
{ printf("\n"); }
|
||||
;
|
||||
|
||||
closer:
|
||||
| CLOSE
|
||||
;
|
||||
|
||||
crap_head:
|
||||
| crap_header CLOSE
|
||||
| CLOSE
|
||||
| crap_header
|
||||
;
|
||||
|
||||
crap_header: crap_header WORD
|
||||
| WORD
|
||||
;
|
||||
|
||||
records: records record
|
||||
| record
|
||||
;
|
||||
|
||||
record: header fields CLOSE
|
||||
{ printf("\t}\n"); }
|
||||
;
|
||||
|
||||
header: PV WORD TYPE WORD WORD
|
||||
{ printf("\trecord(%s,\"%s\") {\n",$4,$2); }
|
||||
| PV WORD TYPE WORD
|
||||
{ printf("\trecord(%s,\"%s\") {\n",$4,$2); }
|
||||
|
||||
fields: field
|
||||
| fields field
|
||||
;
|
||||
|
||||
field: a_field words
|
||||
{
|
||||
printf("\t\tfield(%s,\"%s\")\n",$<Str>1,Field_val);
|
||||
}
|
||||
;
|
||||
|
||||
a_field: FIELD
|
||||
{
|
||||
Field_val[0]='\0';
|
||||
$<Str>$ = $1;
|
||||
}
|
||||
;
|
||||
|
||||
words:
|
||||
| words a_word
|
||||
;
|
||||
|
||||
a_word: WORD
|
||||
{
|
||||
char *p;
|
||||
|
||||
if((p=strstr($1,".PP.MS"))) {p[0]=' ';p[3]=' '; }
|
||||
else if((p=strstr($1,".PP.NMS"))) {p[0]=' ';p[3]=' ';}
|
||||
else if((p=strstr($1,".NPP.MS"))) {p[0]=' ';p[4]=' ';}
|
||||
else if((p=strstr($1,".NPP.NMS"))) {p[0]=' ';p[4]=' ';}
|
||||
else { if(strlen(Field_val)>0) strcat(Field_val," "); }
|
||||
|
||||
strcat(Field_val,$1);
|
||||
}
|
||||
;
|
||||
|
||||
%%
|
||||
|
||||
#include "sf2dbLex.c"
|
||||
|
||||
yyerror(str)
|
||||
char *str;
|
||||
{ fprintf(stderr,"Error line %d : %s\n",line_num, yytext); }
|
||||
|
||||
/*-----------------------main routine-----------------------*/
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
FILE *fdin;
|
||||
|
||||
/* remember that the database name is not retrieved from the .report
|
||||
file, it is specified as a command line argument */
|
||||
|
||||
if( argc < 2 )
|
||||
{
|
||||
printf("Usage: %s database_name < dct_report_file > new_gdct_db_file.db\n",
|
||||
argv[0]);
|
||||
printf("\n\twhere\n\tdatabase_name: the name you wish to give the .database file\n");
|
||||
printf("\tdct_report_file: the old dct short form report file\n");
|
||||
printf("\tnew_gdct_db_file.db: the new gdct db file name, this file is used as \n\t\tinput to the gdct.\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
#ifdef PUKE_HEAD
|
||||
printf("database(x) { nowhere() {\n");
|
||||
#endif
|
||||
/* yyreset(); */
|
||||
yyparse();
|
||||
#ifdef PUKE_HEAD
|
||||
printf("}}\n");
|
||||
#endif
|
||||
|
||||
|
||||
/* fdin = freopen("tester.report", "r+", stdin);
|
||||
yyreset();
|
||||
yyparse(); */
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user