3 /* (c) Copyright 1988 by the Massachusetts Institute of Technology. */
4 /* For copying and distribution information, please see the file */
5 /* <mit-copyright.h>. */
8 #include <mit-copyright.h>
26 printf("Prefix of backup to restore: ");
28 if (gets(prefix) == NULL) {
32 printf("Opening database...");
59 printf("All done.\n");
63 char field_chars[] = {
64 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, /* ^@ - ^O */
65 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* ^P - ^_ */
66 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* SP - / */
67 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, /* 0 - ? */
68 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* @ - O */
69 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* P - _ */
70 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* ` - o */
71 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* p - ^? */
72 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
73 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
74 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
75 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
76 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
77 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
78 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
79 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
88 register int sign = 1;
89 while ((c = getc(f)) != EOF && field_chars[c] == 0) {
90 if (c == '-') sign = -1;
91 else if (isdigit(c)) {
94 } else (void) fprintf(stderr,"non-digit in numeric field\n");
100 void parse_str(f, buf, len)
103 register int len; /* incl trailing NULL */
107 while ((c = getc(f)) != EOF && field_chars[c] == 0 && len > 0) {
111 /* Expect three-digit octal number.. */
115 if (!isdigit(c1) || !isdigit(c2))
116 punt("Broken \\###");
117 /* Convert to ASCII code: */
118 *buf++ = (((c-'0')<<6) + ((c1-'0')<<3) + c2-'0');
119 } else if (c == '\\' || c == ':') {
122 } else punt ("Broken '\\'");
131 if (c != EOF && c != ':' && c != '\n') {
132 fprintf(stderr, "Field too wide, truncated\n");
133 while ((c = getc(f)) != EOF && c != ':' && c != '\n');
144 if (getc(f) != ':') punt("Expected colon");
149 if (getc(f) != '\n') punt("Expected newline");
153 FILE *open_file(suffix)
160 sprintf(name, "%s/%s", prefix, suffix);
162 fd = open(name, O_RDONLY, 0);
168 fprintf(stderr, "fdopen of ");
171 fprintf(stderr, "Working on %s\n", name);
178 printf("exiting: %s\n", s);
194 if (count++ % interval == 0) {
195 printf("\r%d...", count - 1);
202 printf("\r%d items processed.\n", count);