X-Git-Url: http://andersk.mit.edu/gitweb/moira.git/blobdiff_plain/5eaef52092da48d922a6b37cf48bb7c5104d0841..7e38e77c605ee3e0b3ea3fa2d7e9bf9e9730d3b5:/backup/db2rest.awk diff --git a/backup/db2rest.awk b/backup/db2rest.awk index 269cad43..07e637e9 100644 --- a/backup/db2rest.awk +++ b/backup/db2rest.awk @@ -1,5 +1,4 @@ -# $Source$ -# $Header$ +# $Id$ # # This converts the file used to originally create the database # into a program to restore it from a backup. @@ -9,24 +8,29 @@ BEGIN { print "/* This file automatically generated */"; print "/* Do not edit */\n"; - print "#include "; print "EXEC SQL INCLUDE sqlca;"; print "EXEC SQL WHENEVER SQLERROR DO dbmserr();"; - print "void parse_nl(FILE *), parse_str(FILE *, char *, int), parse_sep(FILE *);\n"; + print "#include "; + print "#include \"dump_db.h\""; + print "#include \"rest.h\""; print "/* This file automatically generated */" > "rest1.pc"; print "/* Do not edit */\n" >> "rest1.pc"; - print "#include " >> "rest1.pc"; - print "FILE *open_file(char *prefix, char *suffix);\n" >> "rest1.pc"; - print "int do_restores(char *prefix)\n{" >> "rest1.pc"; + print "#include \"dump_db.h\"" >> "rest1.pc"; + print "#include \"rest.h\"" >> "rest1.pc"; + print "void do_restores(char *prefix)\n{" >> "rest1.pc"; + + print "/* This file automatically generated */" > "bkup.h"; + print "/* Do not edit */\n" >> "bkup.h"; } $1=="#" { next; } /^create/ { - printf "int restore_%s(FILE *f)\n", $3; + printf "void restore_%s(FILE *f)\n", $3; print "{\n EXEC SQL BEGIN DECLARE SECTION;"; printf " restore_%s(open_file(prefix, \"%s\"));\n", $3, $3 >> "rest1.pc"; + printf "void restore_%s(FILE *f);\n", $3 >> "rest.h"; tablename = $3; rangename = substr(tablename, 1, 1); @@ -46,9 +50,9 @@ NF >= 2 { t = split(temp[2], temp2, ")"); if (t != 2) printf "Can't parse %s\n", temp[2]; printf " char\tt_%s[%d];\n", vname[count], temp2[1]+1; - if ($1 == "signature") { + if ($1 == "signature" || $1 == "sid") { vtype[count]="bin"; - printf " EXEC SQL VAR t_signature IS STRING(%d);\n", temp2[1]+1; + printf " EXEC SQL VAR t_%s IS STRING(%d);\n", vname[count], temp2[1]+1; } else vtype[count]="str"; vsize[count] = temp2[1]+1; } else if ($2 ~ /DATE/) {