+dump_int(f, n)
+ FILE *f;
+ int n;
+{
+ char buf[1024];
+ (void) sprintf(buf, "%d", n);
+ dump_str(f, buf);
+}
+
+wpunt()
+{
+ punt("can't write backup file");
+}
+
+dump_str(f, str)
+ register FILE *f;
+ register char *str;
+{
+ char *strtrim();
+ register char *ibp = strtrim(str);
+ register int c; /* PCC doesn't put chars in registers.. */
+ for (; c = *ibp; ibp++) {
+ c = toascii(c); /* punt 8th bit */
+ switch(act[c]) {
+ register int t;
+ case 1:
+ if (putc1('\\', f) < 0) wpunt();
+ /* fall thru.. */
+ case 0:
+ if (putc1(c, f) < 0) wpunt();
+
+ break;
+ case 2:
+ if (putc1('\\', f) < 0) wpunt();
+ t = ((c>>6)&7) + '0';
+ if (putc1(t,f) < 0) wpunt();
+ t = ((c>>3)&7) + '0';
+ if (putc1(t,f) < 0) wpunt();
+ t = (c&7) + '0';
+ if (putc1(t,f) < 0) wpunt();
+ break;
+
+ default:
+ punt("Can't get here");
+ }
+ }
+}
+
+safe_close(stream)
+ FILE *stream;
+{
+ if (fflush(stream) == EOF)
+ punt("Unable to fflush");
+ if (fsync(fileno(stream)) != 0)
+ punt("Unable to fsync");
+ (void) fclose(stream);
+}
+