]> andersk Git - moira.git/blobdiff - backup/dump_db.pc
Command line printer manipulation client, and build goo.
[moira.git] / backup / dump_db.pc
index c1258bbcbb5ea1fdad22ed86167dcd5a85d2b44d..850d01346aa151d05f32f500d248834ef8de5dcc 100644 (file)
@@ -1,36 +1,25 @@
-/*
- *     $Source$
- *     $Author$
- *     $Header$
- *
- *     (c) Copyright 1988 by the Massachusetts Institute of Technology.
- *     For copying and distribution information, please see the file
- *     <mit-copyright.h>.
+/* $Id$
  *
  *     This program dumps the Moira database to a series of output files
  * which can be later read back into Moira in the event of a crash.
  *
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#ifndef lint
-static char *rcsid_dump_db_c = "$Header$";
-#endif lint
-
-#include <stdio.h>
-#include <sys/file.h>
-#include <fcntl.h>
-#include <ctype.h>
 #include <mit-copyright.h>
-EXEC SQL INCLUDE sqlca;
+#include <moira.h>
 #include "dump_db.h"
 
-/* putc without the line buffer hair */
+#include <fcntl.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
 
-#define putc1(x, p)    (--(p)->_cnt >= 0 ?\
-       (int)(*(unsigned char *)(p)->_ptr++ = (x)) :\
-               _flsbuf((unsigned char)(x), p))
+EXEC SQL INCLUDE sqlca;
 
-FILE *open_file();
+RCSID("$Header$");
 
 EXEC SQL BEGIN DECLARE SECTION;
 char *db = "moira";
@@ -39,7 +28,6 @@ EXEC SQL END DECLARE SECTION;
 int main(int argc, char **argv)
 {
   char *prefix;
-  int i;
 
   if (argc != 2)
     {
@@ -56,48 +44,48 @@ int main(int argc, char **argv)
   exit(0);
 }
 
-int dump_int(FILE *f, int n)
+void dump_int(FILE *f, int n)
 {
   char buf[1024];
   sprintf(buf, "%d", n);
   dump_str(f, buf);
 }
 
-int wpunt(void)
+void wpunt(void)
 {
   punt("can't write backup file");
 }
 
-int dump_str(FILE *f, char *str)
+void dump_str(FILE *f, char *str)
 {
-  char *ibp, c;
+  unsigned char *ibp, c;
   int t;
 
-  for (ibp = str; c = (unsigned char) *ibp; ibp++)
+  for (ibp = str; (c = *ibp); ibp++)
     {
       if (c < 32 || c > 126 || c == SEP_CHAR || c == '\\')
        {
-         if (putc1('\\', f) < 0)
+         if (putc('\\', f) < 0)
            wpunt();
          t = ((c >> 6) & 7) + '0';
-         if (putc1(t, f) < 0)
+         if (putc(t, f) < 0)
            wpunt();
          t = ((c >> 3) & 7) + '0';
-         if (putc1(t, f) < 0)
+         if (putc(t, f) < 0)
            wpunt();
          t = (c & 7) + '0';
-         if (putc1(t, f) < 0)
+         if (putc(t, f) < 0)
            wpunt();
        }
       else
        {
-         if (putc1(c, f) < 0)
+         if (putc(c, f) < 0)
            wpunt();
        }
     }
 }
 
-int safe_close(FILE *stream)
+void safe_close(FILE *stream)
 {
   if (fflush(stream) == EOF)
     punt("Unable to fflush");
@@ -128,24 +116,14 @@ FILE *open_file(char *prefix, char *suffix)
   return f;
 }
 
-
 /*
- * Trim whitespace off both ends of a string.
+ * Trim whitespace off the tail end of a string
  */
-char *strtrim(char *save)
+char *endtrim(char *save)
 {
   char *t, *s;
 
   s = save;
-  while (isspace(*s))
-    s++;
-  /* skip to end of string */
-  if (*s == '\0')
-    {
-      *save = '\0';
-      return save;
-    }
-
   for (t = s; *t; t++)
     continue;
   while (t > s)
@@ -157,6 +135,7 @@ char *strtrim(char *save)
          break;
        }
     }
-  *t = '\0';
+  if (*t)
+    *t = '\0';
   return s;
 }
This page took 0.038731 seconds and 4 git commands to generate.