Source tree should only have Imakefiles, not Makefiles.
Added ;s to awk scripts so Emacs will indent them properly.
Removed ancient files
# Imakefile for backup directory.
#
-SRCS= dump_db.c bkup1.c bkup.c dumprest.c rest_db.c rest1.c rest.c
+SRCS= dump_db.h dump_db.c bkup1.c bkup.c dumprest.c rest_db.c rest1.c rest.c
SRCDIR=${SRCTOP}/backup
CODE= db2bkup.awk db2rest.awk dump_db.h dump_db.dc dumprest.dc \
- nightly.sh report.sh rest_db.dc esqlc_fix.pl
-BOBJS= dump_db.o bkup1.o bkupfix.o dumprest.o
+ nightly.sh report.sh rest_db.dc
+BOBJS= dump_db.o bkup1.o bkup.o dumprest.o
ROBJS= rest_db.o rest1.o rest.o dumprest.o
sqlrule()
program(mrbackup, ${BOBJS},${MR_LIBDEP}, ${CLIBS} ${SQL_LIB}, ${PROGDIR})
program(mrrestore, ${ROBJS},${MR_LIBDEP}, ${CLIBS} ${SQL_LIB}, ${PROGDIR})
-bkup.dc: ../db/schema db2bkup.awk
- cc -E ../db/schema | awk -f db2bkup.awk > bkup.dc
+bkup.dc: ../db/schema.sql db2bkup.awk
+ awk -f db2bkup.awk < ../db/schema.sql > bkup.dc
bkup1.dc: bkup.dc
-rest.dc: ../db/schema db2rest.awk
- cc -E ../db/schema | awk -f db2rest.awk > rest.dc
+rest.dc: ../db/schema.sql db2rest.awk
+ awk -f db2rest.awk < ../db/schema.sql > rest.dc
rest1.dc: rest.dc
clean::
- $(RM) bkup.dc bkup1.dc rest.dc rest1.dc bkupfix.c
+ $(RM) bkup.dc bkup1.dc rest.dc rest1.dc
sqlfile(dump_db)
sqlfile(rest_db)
sqlfile(dumprest)
sqlfile(bkup1)
sqlfile(rest)
sqlfile(rest1)
-
-bkupfix.c: bkup.c esqlc_fix.pl
- perl esqlc_fix.pl < bkup.c > bkupfix.c
+++ /dev/null
-# $Header$
-#
-# (c) Copyright 1988 by the Massachusetts Institute of Technology.
-# For copying and distribution information, please see the file
-# <mit-copyright.h>.
-
-.SUFFIXES:
-.SUFFIXES: .qc .c .o
-CFLAGS= -O
-
-SRCS = dump_db.c bkup1.c bkup.c dumprest.c rest_db.c rest1.c rest.c
-EQLIBS = /usr/rtingres/lib/libqlib /usr/rtingres/lib/compatlib
-
-.qc.c:
- /usr/rtingres/bin/eqc $*.qc
-
-all: mrbackup mrrestore
-
-mrbackup: dump_db.o bkup1.o bkup.o dumprest.o
- cc -o $@ ${CFLAGS} dump_db.o bkup1.o bkup.o dumprest.o ${EQLIBS}
-
-mrrestore: rest_db.o rest1.o rest.o dumprest.o
- cc -o $@ ${CFLAGS} rest_db.o rest1.o rest.o dumprest.o ${EQLIBS}
-
-copy_backups: copy_backups.c
- cc -o $@ ${CFLAGS} -I../include copy_backups.c \
- ../update/mr_update.o -L../lib \
- -lmoira -lgdb -lkrb -ldes -lmisc
-
-bkup.qc: ../db/newdb db2bkup.awk
- cc -E ../db/newdb | awk -f db2bkup.awk > bkup.qc
-
-bkup1.qc: bkup.qc
-
-rest.qc: ../db/newdb db2rest.awk
- cc -E ../db/newdb | awk -f db2rest.awk > rest.qc
-
-rest1.qc: rest.qc
-
-lint:
- lint -h dump_db.c bkup.c bkup1.c dumprest.c | egrep -v '^II'
- lint -h rest_db.c rest.c rest1.c dumprest.c | egrep -v '^II'
-
-clean:
- rm -f *.o mrbackup bkup.qc bkup1.qc mrrestore rest.qc rest1.qc
- rm -f core *~
- rm -f copy_backups counts
- rm -f bkup.c bkup1.c counts.c dump_db.c dumprest.c
- rm -f rest.c rest1.c rest_db.c
-
-install:
- install -c mrbackup ../bin/mrbackup
- install -c mrrestore ../bin/mrrestore
- install -c nightly.sh ../bin/nightly.sh
-
-depend: ${SRCS}
- mkdep ${CFLAGS} ${SRCS}
-
-# DO NOT DELETE THIS LINE -- mkdep uses it.
-
-dump_db.o: dump_db.c /usr/include/stdio.h /usr/include/sys/file.h
-dump_db.o: /usr/include/ctype.h /usr/include/mit-copyright.h dump_db.h
-bkup1.o: bkup1.c /usr/include/stdio.h
-bkup.o: bkup.c /usr/include/stdio.h dump_db.h
-dumprest.o: dumprest.c /usr/include/stdio.h /usr/include/sys/file.h
-dumprest.o: /usr/include/strings.h /usr/include/mit-copyright.h
-rest_db.o: rest_db.c /usr/include/sys/file.h /usr/include/stdio.h
-rest_db.o: /usr/include/ctype.h /usr/include/mit-copyright.h dump_db.h
-rest1.o: rest1.c /usr/include/stdio.h
-rest.o: rest.c /usr/include/stdio.h
+++ /dev/null
-/*
- * $Source$
- * $Author$
- * $Header$
- *
- * Copyright (C) 1987 by the Massachusetts Institute of Technology
- *
- * $Log$
- * Revision 1.1 1987-08-22 17:03:18 wesommer
- * Initial revision
- *
- */
-
-#ifndef lint
-static char *rcsid_copy_backups_c = "$Header$";
-#endif lint
-#include <stdio.h>
-#include <strings.h>
-#include <sys/types.h>
-#include "update.h"
-
-char *whoami;
-char host[BUFSIZ];
-char buf[BUFSIZ];
-
-static struct update_desc info = {
- 42, /* last_time_tried */
- 1, /* success */
- 12, /* interval */
- "backup", /* service_name */
- "ZEUS.MIT.EDU", /* host_name */
- "/tmp/frobnicate", /* target_path */
- 2, /* override */
- 1, /* enable */
- "/dev/null"
- /* instructions */
-};
-
-extern char *error_message();
-#include <sys/dir.h>
-
-main(argc,argv)
- int argc;
- char **argv;
-{
- int rc;
- DIR *pd, *sd;
- struct direct *pde, *sde;
-
- whoami = rindex(argv[0], '/');
- if (whoami)
- whoami++;
- else
- whoami = argv[0];
- whoami = argv[0];
- if (chdir ("/u3/sms_backup") < 0) {
- perror("can't change to /u3/sms_backup");
- exit(1);
- }
-
- pd = opendir(".");
- if (pd == NULL) {
- perror("can't open sms_backup directory");
- exit(1);
- }
-
- while ( (pde = readdir(pd)) != NULL ) {
- char *dir_name = pde->d_name;
- printf("Directory: %s\n", dir_name);
-
- if (dir_name[0] == '.') continue; /* ignore hidden files */
-
- if (chdir(dir_name) < 0) {
- perror(dir_name);
- continue;
- }
- sd = opendir (".");
- if (sd == NULL) {
- perror("Can't open .");
- goto dotdot;
- }
- while ( (sde = readdir(sd)) != NULL ) {
- if (sde->d_name[0] == '.') continue;
-
- sprintf(buf, "/site/sms/sms_backup/%s/%s", dir_name, sde->d_name);
- printf("Updating: %s\n", buf);
- info.target_path = buf;
- rc = sms_update_server(&info, sde->d_name);
- if (rc) printf("return code: %s\n", error_message(rc));
- }
- closedir(sd);
-
- dotdot:
- chdir("..");
- }
- closedir(pd);
-}
-
-/*
- * Local Variables:
- * mode: c
- * c-indent-level: 4
- * c-continued-statement-offset: 4
- * c-brace-offset: -4
- * c-argdecl-indent: 4
- * c-label-offset: -4
- * End:
- */
# This is not guaranteed to work for all data types; it may
# need to be extended.
-BEGIN { print "/* This file automatically generated */";
- print "/* Do not edit */";
+BEGIN {
+ print "/* This file automatically generated */";
+ print "/* Do not edit */\n";
print "#include <stdio.h>";
print "EXEC SQL INCLUDE sqlca;";
print "#include \"dump_db.h\"";
- print;
+ print "#define dump_date dump_str\n";
+
print "/* This file automatically generated */" > "bkup1.dc";
- print "/* Do not edit */" >> "bkup1.dc"
- print "#include <stdio.h>" >> "bkup1.dc"
- print "FILE *open_file();" >> "bkup1.dc"
- print "do_backups(prefix)\n\tchar *prefix;\n{" >>"bkup1.dc"
+ print "/* Do not edit */\n" >> "bkup1.dc";
+ print "#include <stdio.h>" >> "bkup1.dc";
+ print "FILE *open_file();" >> "bkup1.dc";
+ print "do_backups(prefix)\n\tchar *prefix;\n{" >> "bkup1.dc";
}
$1=="#" { next; }
-/^create/ { printf "dump_%s(f)\nFILE *f;\n{\n\tEXEC SQL BEGIN DECLARE SECTION;\n", $3;
- printf "\tdump_%s(open_file(prefix, \"%s\"));\n", $3, $3 >> "bkup1.dc"
+/^create/ {
+ printf "dump_%s(f)\nFILE *f;\n{\n\tEXEC SQL BEGIN DECLARE SECTION;\n", $3;
+ printf "\tdump_%s(open_file(prefix, \"%s\"));\n", $3, $3 >> "bkup1.dc";
+
tablename = $3;
rangename = substr(tablename, 1, 1);
count = 0;
- next;}
+ next;
+}
NF>=2 {
vname[count] = $1;
- printf "/* %s */\n", $0
+ printf "/* %s */\n", $0;
if ($2 ~ /INTEGER/ || $2 ~ /SMALLINT/ || $2 ~ /INTEGER1/) {
- printf "\tint\tt_%s;\n", vname[count]
- vtype[count]="int"
+ printf "\tint\tt_%s;\n", vname[count];
+ vtype[count]="int";
} else if ($2 ~ /CHAR\([0-9]*\)/) {
- t = split($2, temp, "(")
+ t = split($2, temp, "(");
if (t != 2) printf "Can't parse %s\n", $2;
- t = split(temp[2], temp2, ")")
+ t = split(temp[2], temp2, ")");
if (t != 2) printf "Can't parse %s\n", temp[2];
printf "\tchar\tt_%s[%d];\n", vname[count], temp2[1]+1;
if ($1 == "signature") {
- vtype[count]="bin"
+ vtype[count]="bin";
} else {
- vtype[count]="str"
+ vtype[count]="str";
}
+ vsize[count] = temp2[1]+1;
} else if ($2 ~ /DATE/) {
- printf "\tchar\tt_%s[26];\n", vname[count]
- vtype[count]="str"
+ printf "\tchar\tt_%s[26];\n", vname[count];
+ vtype[count]="date";
} else printf "Unknown data type %s\n", $2;
count++;
}
/^\);$/ {
printf "\tEXEC SQL END DECLARE SECTION;\n";
printf "\tEXEC SQL DECLARE c_%s CURSOR FOR\n", tablename;
- printf "\t\tSELECT * FROM %s;\n", tablename;
+ printf "\t\tSELECT\n";
+ for (i = 0; i < count; i++) {
+ if (i != 0) {
+ print ",";
+ }
+ if(vtype[i] ~ /date/) {
+ printf "\t\t\tTO_CHAR(%s, 'DD-mon-YYYY HH24:MI:SS')", vname[i];
+ } else printf "\t\t\t%s", vname[i];
+ }
+ printf " FROM %s;\n", tablename;
+
printf "\tEXEC SQL OPEN c_%s;\n", tablename;
- printf "\twhile(1) {\n\tEXEC SQL FETCH c_%s INTO\n", tablename;
+ printf "\twhile(1) {\n\t\tEXEC SQL FETCH c_%s INTO\n", tablename;
for (i = 0; i < count; i++) {
if (i != 0) printf ",\n";
- printf "\t\t:t_%s", vname[i];
+ printf "\t\t\t:t_%s", vname[i];
}
printf ";\n";
- printf "\tif(sqlca.sqlcode != 0) break;\n";
+ printf "\t\tif(sqlca.sqlcode != 0) break;\n";
for (i = 0; i < count; i++) {
- if (i != 0) print "\tdump_sep(f);"
- printf "\tdump_%s(f, t_%s);\n", vtype[i], vname[i];
+ if (i != 0) print "\t\tdump_sep(f);";
+ if (vtype[i] ~ /str/) {
+ printf "\t\tdump_str(f, strtrim(t_%s));\n", vname[i];
+ } else {
+ printf "\t\tdump_%s(f, t_%s);\n", vtype[i], vname[i];
+ }
}
printf "\t\tdump_nl(f);\n";
printf "\t}\n";
printf "\tEXEC SQL CLOSE c_%s;\n", tablename;
printf "\tsafe_close(f);\n";
- printf "}\n";
+ printf "}\n\n";
}
-END { print "/* All done */"
- print "}" >>"bkup1.dc"
+
+END {
+ print "/* All done */";
+ print "}" >> "bkup1.dc";
}
# This is not guaranteed to work for all data types; it may
# need to be extended.
-BEGIN { print "/* This file automatically generated */";
- print "/* Do not edit */";
+BEGIN {
+ print "/* This file automatically generated */";
+ print "/* Do not edit */\n";
print "#include <stdio.h>";
print "EXEC SQL INCLUDE sqlca;";
- print "void parse_nl(), parse_str(), parse_sep();"
+ print "void parse_nl(), parse_str(FILE *, char *, int), parse_sep();\n";
+
print "/* This file automatically generated */" > "rest1.dc";
- print "/* Do not edit */" >> "rest1.dc";
+ print "/* Do not edit */\n" >> "rest1.dc";
print "#include <stdio.h>" >> "rest1.dc";
print "FILE *open_file();" >> "rest1.dc";
- print "do_restores(prefix)\n\tchar *prefix;\n{" >>"rest1.dc";
+ print "do_restores(prefix)\n\tchar *prefix;\n{" >> "rest1.dc";
}
$1=="#" { next; }
-/^create/ { printf "restore_%s(f)\nFILE *f;\n", $3;
+/^create/ {
+ printf "restore_%s(f)\nFILE *f;\n", $3;
print "{\n\tEXEC SQL BEGIN DECLARE SECTION;";
printf "\trestore_%s(open_file(prefix, \"%s\"));\n", $3, $3 >> "rest1.dc";
+
tablename = $3;
rangename = substr(tablename, 1, 1);
count = 0;
- next; }
+ next;
+}
NF >= 2 {
vname[count] = $1;
- printf "/* %s */\n", $0
+ printf "/* %s */\n", $0;
if ($2 ~ /INTEGER/ || $2 ~ /SMALLINT/ || $2 ~ /INTEGER1/) {
- printf "\tint\tt_%s;\n", vname[count]
- vtype[count]="int"
+ printf "\tint\tt_%s;\n", vname[count];
+ vtype[count]="int";
} else if ($2 ~ /CHAR\([0-9]*\)/) {
- t = split($2, temp, "(")
+ t = split($2, temp, "(");
if (t != 2) printf "Can't parse %s\n", $2;
- t = split(temp[2], temp2, ")")
+ t = split(temp[2], temp2, ")");
if (t != 2) printf "Can't parse %s\n", temp[2];
printf "\tchar\tt_%s[%d];\n", vname[count], temp2[1]+1;
+ if ($1 == "signature") {
+ vtype[count]="bin";
+ printf "\tEXEC SQL VAR t_signature IS STRING(%d);\n", temp2[1]+1;
+ } else vtype[count]="str";
vsize[count] = temp2[1]+1;
- vtype[count]="str"
} else if ($2 ~ /DATE/) {
printf "\tchar\tt_%s[26];\n", vname[count];
- vtype[count]="str";
- vsize[count]=26;
+ vtype[count]="date";
} else printf "Unknown data type %s\n", $2;
count++;
}
/^\);$/ {
- print "\tEXEC SQL END DECLARE SECTION;\n";
- print "\twhile(!feof(f)) {"
+ printf "\tEXEC SQL END DECLARE SECTION;\n\tint count=0;\n";
+
+ print "\twhile(!feof(f)) {";
+ print "\t\tif(!(++count%100)) {\n\t\t\tEXEC SQL COMMIT;\n\t\t}\n";
+
for (i = 0; i < count; i++) {
- if (i != 0) print "\t\tparse_sep(f);"
+ if (i != 0) print "\t\tparse_sep(f);";
if (vtype[i] ~ /int/) {
printf("\t\tt_%s = parse_int(f);\n", vname[i]);
- } else printf "\t\tparse_%s(f, t_%s, %d);\n", vtype[i], vname[i], vsize[i]
- if (i == 0) print "\t\tif (feof(f)) break;"
+ } else if (vtype[i] ~ /date/) {
+ printf "\t\tparse_str(f, t_%s, 26);\n", vname[i];
+ } else {
+ printf "\t\tparse_str(f, t_%s, %d);\n", vname[i], vsize[i];
+ }
+ if (i == 0) print "\t\tif (feof(f)) break;";
}
printf "\t\tparse_nl(f);\n"
printf ")\n\t\tVALUES (\n";
for (i = 0; i < count; i++) {
if (i != 0) printf ",\n";
- printf "\t\t\t:t_%s", vname[i];
+ if (vtype[i] ~ /date/) {
+ printf "\t\t\tTO_DATE(NVL(:t_%s,TO_CHAR(SYSDATE, 'DD_mon-YYYY HH24:MI:SS')), 'DD-mon-YYYY HH24:MI:SS')", vname[i];
+ } else if(vtype[i] ~ /int/) {
+ printf "\t\t\t:t_%s", vname[i];
+ } else {
+ printf "\t\t\tNVL(:t_%s,CHR(0))", vname[i];
+ }
}
- printf ");\n\t\tif (sqlca.sqlcode != 0) {\n"
- printf "\t\t\tcom_err(\"restore\", 0, \"insert failed\");\n"
- printf "\t\t\texit(2);\n\t\t}\n\t}\n"
- printf "\t(void) fclose(f);\n"
- printf "}\n"
+ printf ");\n\t\tif (sqlca.sqlcode != 0) {\n";
+ printf "\t\t\tsqlca.sqlerrm.sqlerrmc[sqlca.sqlerrm.sqlerrml]=0;\n";
+ printf "\t\t\tprintf(\"%%s\\n\", sqlca.sqlerrm.sqlerrmc);\n";
+ printf "\t\t\tcom_err(\"restore\", 0, \"insert failed\");\n";
+ printf "\t\t\texit(2);\n\t\t}\n\t}\n";
+ printf "\t(void) fclose(f);\n";
+ printf "\tEXEC SQL COMMIT;\n";
+ printf "}\n\n";
}
-END { print "/* All done */"
- print "}" >>"rest1.dc";
+
+
+END {
+ print "/* All done */";
+ print "}" >> "rest1.dc";
}
#include <stdio.h>
#include <sys/file.h>
+#include <fcntl.h>
#include <ctype.h>
#include <mit-copyright.h>
EXEC SQL INCLUDE sqlca;
FILE *open_file();
char act[257];
+EXEC SQL BEGIN DECLARE SECTION;
+char *db="moira";
+EXEC SQL END DECLARE SECTION;
main(argc, argv)
int argc;
}
prefix = argv[1];
- bzero(act, 256);
+ memset(act, 0, 256);
for (i=0; i<' '; i++) act[i]=2;
for (i=128; i<256; i++) act[i]=2;
act['\\']=1;
act[127]=2;
- EXEC SQL CONNECT moira;
- EXEC SQL set lockmode session where level = table;
+ EXEC SQL CONNECT :db IDENTIFIED BY :db;
do_backups(prefix);
- EXEC SQL DISCONNECT;
+ EXEC SQL COMMIT;
exit(0);
}
register FILE *f;
register char *str;
{
- char *strtrim();
- register char *ibp = strtrim(str);
+ register char *ibp;
register int c; /* PCC doesn't put chars in registers.. */
register int t;
- for (; c = (unsigned char) *ibp; ibp++) {
+ for (ibp = str; c = (unsigned char) *ibp; ibp++) {
switch(act[c]) {
case 1:
if (putc1('\\', f) < 0) wpunt();
#endif lint
#include <stdio.h>
-#include <sys/file.h>
-#include <strings.h>
#include <mit-copyright.h>
punt(msg)
char *msg;
{
perror(msg);
- EXEC SQL DISCONNECT;
exit(1);
}
+++ /dev/null
-#!/usr/athena/bin/perl -i.bak
-
-# Limitations:
-# 1. Schema must have "create table tablename" all on one line
-# 2. Fields (columns) must be declared "NOT NULL WITH DEFAULT"
-# 3. C variables corresponding to database fields must use the
-# database field name with "t_" prefixed.
-# 4. Field names, table names, and C "t_" variable names are of the same case
-# 5. Only references within CURSOR loops are corrected.
-
-
-# Step 1. Read the schema, so we know the proper field lengths
-open(SCHEMA,"../db/schema") || die "Could not open schema, stopped\n";
-
-while(<SCHEMA>) {
- if(/create\s+table\s+/) {
- ($table,$ignore) = split(' ',$');
- next;
- }
- if(/\s+(\w+)\s+(VAR)?CHAR\((\d+)\)\s+NOT NULL WITH DEFAULT/) {
- $fields{$table . "." . $1} = $3;
- }
-}
-
-
-# Step 2. Read the code to be cleaned up
-
-# Pass through most lines.
-# Note the opening and closing of cursors.
-# Play with IIcsGetio. Change 4th argument if it's wrong.
-
-while(<>) {
- if(/IIwritio\(.*"select.*from\s+(\w+)"\);/) {
- $table = $1;
- next;
- }
- if(/IIcsGetio\((.*,.*,.*,(\d+),&?t_(\w+))\);/) {
- $width = $2;
- $field = $3;
-
- $tablefield = $table . "." . $field;
- $shouldbe = $fields{$tablefield};
-
- if( $shouldbe && $shouldbe != $width ) {
- s/(\(.*,.*,.*,)(\d+),/\1$shouldbe,/;
- }
- }
-} continue {
- print;
-}
-
#
#
BKUPDIRDIR=/backup
-PATH=/bin:/athena/bin:/usr/athena/bin:/usr/bin:/usr/ucb:/usr/new; export PATH
-. /usr/ingres/sqluser.profile
+PATH=/usr/athena/bin:/bin:/usr/bin:/usr/ucb; export PATH
+ORACLE_HOME=/usr/oracle; export ORACLE_HOME
+ORACLE_SID=moira; export ORACLE_SID
chdir ${BKUPDIRDIR}
-# /moira/bin/counts </dev/null
-
if [ -d in_progress ]
then
echo "Two backups running?"
if [ -d stale ]
then
- echo -n "Stale backup "
+ /usr/ucb/echo -n "Stale backup "
rm -r stale
echo "removed"
fi
-echo -n "Shifting backups "
+/usr/ucb/echo -n "Shifting backups "
mv backup_3 stale
-echo -n "3 "
+/usr/ucb/echo -n "3 "
mv backup_2 backup_3
-echo -n "2 "
+/usr/ucb/echo -n "2 "
mv backup_1 backup_2
-echo -n "1 "
+/usr/ucb/echo -n "1 "
mv in_progress backup_1
echo
-/bin/df /moira/moira.log | /usr/ucb/tail -1
+/bin/df -k /moira/moira.log | /usr/ucb/tail -1
echo
-echo -n "deleting last backup"
+echo "deleting last backup"
rm -rf stale
echo
echo "Shipping over the net"
undef %TYPES;
-open(CLUSTERS, "cluster") || die "Cannot open cluster file for input.\n";
+open(CLUSTERS, "clusters") || die "Cannot open clusters file for input.\n";
$total = 0;
#include <sys/file.h>
#include <stdio.h>
+#include <fcntl.h>
#include <ctype.h>
#include <mit-copyright.h>
EXEC SQL INCLUDE sqlca;
}
db = argv[1];
- if (!yes_or_no("Do you *REALLY* want to wipe the SMS database?")) {
+ if (!yes_or_no("Do you *REALLY* want to wipe the moira database?")) {
printf("I didn't think so\n");
exit(1);
}
printf("Opening database: ");
(void) fflush(stdout);
- EXEC SQL CONNECT :db;
+ EXEC SQL CONNECT :db IDENTIFIED BY :db;
if (sqlca.sqlcode != 0) {
com_err(argv[0], 0, "Ingres database open failed");
exit(1);
}
- EXEC SQL SET AUTOCOMMIT ON;
-
printf(" done\n");
printf("Prefix of backup to restore: ");
do_restores(prefix);
printf("Restore complete\n");
EXEC SQL COMMIT;
- EXEC SQL DISCONNECT;
exit(0);
/*NOTREACHED*/
}
return(val * sign);
}
-void parse_str(f, buf, len)
+void parse_str(f, buf, maxlen)
register FILE *f;
register char *buf;
- register int len; /* incl trailing NULL */
+ register int maxlen;
{
- register int c;
+ register int c, len=0;
- while ((c = getc(f)) != EOF && c != SEP_CHAR && c != '\n' && len > 0) {
+ while ((c = getc(f)) != EOF && c != SEP_CHAR && c != '\n' && len < maxlen) {
if (c == '\\') {
c = getc(f);
if (isdigit(c)) {
punt("Broken \\###");
/* Convert to ASCII code: */
*buf++ = (((c-'0')<<6) + ((c1-'0')<<3) + c2-'0');
+ len++;
} else if (c == '\\' || c == SEP_CHAR) {
*buf++ = c;
- --len;
+ len++;
} else punt ("Broken '\\'");
} else {
*buf++ = c;
- --len;
+ len++;
}
}
+ *buf='\0';
if (c == EOF)
return;
while ((c = getc(f)) != EOF && c != SEP_CHAR && c != '\n');
(void) ungetc(c, f);
} else {
- *buf++ = 0;
(void) ungetc(c, f);
}
}
+++ /dev/null
-#!/bin/csh
-
-set path=(. /bin /usr/bin ~rtingres/bin)
-
-if ($user != smsdba) then
- echo "This script must be run as smsdba"
- exit 1
-endif
-
-createdb smstemp
-if ($status) then
- echo "unable to create database"
- exit 2
-endif
-
-cd /mit/smsdev/backup
-
-ingres smstemp < dodbbuild
-
-smsrestore
-
-ingres smstemp < dodbopt
-
-sysmod smstemp
-
-echo "When you are satisfied that this is correct, rename the smstemp database"
-echo "to sms by renaming directories under ~rtingres/data/default, then run"
-echo "'finddbs -r' to fix the ingres database database."
-
-exit 0