6 * Copyright (C) 1987 by the Massachusetts Institute of Technology
9 * Revision 1.1 1987-07-13 03:50:02 wesommer
15 static char *rcsid_rest_db_qc = "$Header$";
30 if (!yes_or_no("Do you *REALLY* want to wipe the SMS database?")) {
31 printf("I didn't think so\n");
34 if (!yes_or_no("Have you initialized an empty database named smstemp?")) {
35 printf("You should have\n");
39 printf("Opening database: ");
40 (void) fflush(stdout);
45 printf("Prefix of backup to restore: ");
46 (void) fflush(stdout);
47 if (gets(buf) == NULL) {
52 if (!yes_or_no("Are you SURE?")) {
53 printf("I didn't think so\n");
57 printf("Restore complete\n");
69 int tt = open("/dev/tty", O_RDWR, 0);
76 (void) fflush(stdout);
77 (void) fflush(stderr);
78 o = fdopen(dup(tt), "w");
79 i = fdopen(dup(tt), "r");
83 fprintf(o, "%s (yes or no): ", prompt);
85 if (fgets(buf, BUFSIZ, i) == NULL) goto err;
86 for (cp = buf; *cp; cp++) {
87 if (isupper(*cp)) *cp=tolower(*cp);
89 if (strcmp(buf, "yes\n") == 0) {
92 if (strcmp(buf, "no\n") == 0) {
110 register int val = 0;
111 register int sign = 1;
112 while ((c = getc(f)) != EOF && c != ':' && c != '\n') {
113 if (c == '-') sign = -1;
114 else if (isdigit(c)) {
117 } else (void) fprintf(stderr,"non-digit in numeric field\n");
123 void parse_str(f, buf, len)
126 register int len; /* incl trailing NULL */
130 while ((c = getc(f)) != EOF && c != ':' && c != '\n' && len > 0) {
134 /* Expect three-digit octal number.. */
138 if (!isdigit(c1) || !isdigit(c2))
139 punt("Broken \\###");
140 /* Convert to ASCII code: */
141 *buf++ = (((c-'0')<<6) + ((c1-'0')<<3) + c2-'0');
142 } else if (c == '\\' || c == ':') {
145 } else punt ("Broken '\\'");
154 if (c != EOF && c != ':' && c != '\n')
155 fprintf(stderr, "Field too wide, truncated\n");
165 if (getc(f) != ':') punt("Expected colon");
170 if (getc(f) != '\n') punt("Expected newline");
174 FILE *open_file(prefix, suffix)
175 char *prefix, *suffix;
181 (void) strcpy(name, prefix);
182 (void) strcat(name, suffix);
184 fd = open(name, O_RDONLY, 0);
190 fprintf(stderr, "fdopen of ");
193 fprintf(stderr, "Working on %s\n", name);
201 * c-continued-statement-offset: 4
203 * c-argdecl-indent: 4