]> andersk Git - moira.git/blobdiff - backup/db2rest.awk
Back up sids the same way we back up gdss signatures.
[moira.git] / backup / db2rest.awk
index 269cad436b54a80786ff03df1e583e032c079f86..07e637e9e17a1041f41ee5d05952132e3ffacd4d 100644 (file)
@@ -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 <stdio.h>";
        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 <com_err.h>";
+       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 <stdio.h>" >> "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/) {
This page took 0.795896 seconds and 4 git commands to generate.