%{ /************************************************************************** * * 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 #include #include #include "macLib.h" #include "dbmf.h" #include "epicsVersion.h" static int line_num; static int yyerror(); int dbLoadTemplate(char* sub_file); #ifdef SUB_TOOL static int sub_it(); #else int dbLoadRecords(char* pfilename, char* pattern); #endif #ifdef vxWorks #define VAR_MAX_VAR_STRING 1500 #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; static char** vars = NULL; static char* db_file_name = NULL; static int var_count,sub_count; %} %start template %token WORD QUOTE %token DBFILE %token PATTERN %token EQUALS %left O_PAREN C_PAREN %left O_BRACE C_BRACE %union { int Int; char Char; char *Str; double Real; } %% template: templs | subst ; templs: templs templ | templ ; templ: templ_head O_BRACE subst C_BRACE | templ_head { #ifndef SUB_TOOL if(db_file_name) dbLoadRecords(db_file_name,NULL); else fprintf(stderr,"Error: no db file name given\n"); #else sub_it(); #endif } ; templ_head: DBFILE WORD { var_count=0; if(db_file_name) dbmfFree(db_file_name); db_file_name = dbmfMalloc(strlen($2)+1); strcpy(db_file_name,$2); dbmfFree($2); } ; subst: PATTERN pattern subs | var_subs ; pattern: O_BRACE vars C_BRACE { #ifdef ERROR_STUFF int i; for(i=0;i=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); } #endif #endif