--- /dev/null
+/* $Header$ */
+
+/* (c) Copyright 1988 by the Massachusetts Institute of Technology. */
+/* For copying and distribution information, please see the file */
+/* <mit-copyright.h>. */
+
+
+#include <mit-copyright.h>
+#include <stdio.h>
+#include <sys/file.h>
+#include <ctype.h>
+
+char prefix[256];
+
+main(argc, argv)
+int argc;
+char **argv;
+{
+## char *db;
+
+ if (argc == 2)
+ db = argv[1];
+ else
+ db = "sms";
+
+ printf("Prefix of backup to restore: ");
+ fflush(stdout);
+ if (gets(prefix) == NULL) {
+ return 1;
+ }
+
+ printf("Opening database...");
+ fflush(stdout);
+## ingres db
+ printf("done\n");
+
+ do_users();
+ do_finger();
+ do_mach();
+ do_clu();
+ do_mcm();
+ do_cld();
+ do_servers();
+ do_serverhosts();
+ do_list();
+ do_maillists();
+ do_groups();
+ do_members();
+ do_strings();
+ do_pobox();
+ do_nfsphys();
+ do_filesys();
+ do_nfsquota();
+ do_services();
+ do_printcap();
+ do_alias();
+ do_values();
+
+ printf("All done.\n");
+## exit
+}
+
+char field_chars[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, /* ^@ - ^O */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* ^P - ^_ */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* SP - / */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, /* 0 - ? */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* @ - O */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* P - _ */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* ` - o */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* p - ^? */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+};
+
+
+int parse_int(f)
+ register FILE *f;
+{
+ register int c;
+ register int val = 0;
+ register int sign = 1;
+ while ((c = getc(f)) != EOF && field_chars[c] == 0) {
+ if (c == '-') sign = -1;
+ else if (isdigit(c)) {
+ val *= 10;
+ val += (c - '0');
+ } else (void) fprintf(stderr,"non-digit in numeric field\n");
+ }
+ (void) ungetc(c, f);
+ return(val * sign);
+}
+
+void parse_str(f, buf, len)
+ register FILE *f;
+ register char *buf;
+ register int len; /* incl trailing NULL */
+{
+ register int c;
+
+ while ((c = getc(f)) != EOF && field_chars[c] == 0 && len > 0) {
+ if (c == '\\') {
+ c = getc(f);
+ if (isdigit(c)) {
+ /* Expect three-digit octal number.. */
+ register int c1, c2;
+ c1 = getc(f);
+ c2 = getc(f);
+ if (!isdigit(c1) || !isdigit(c2))
+ punt("Broken \\###");
+ /* Convert to ASCII code: */
+ *buf++ = (((c-'0')<<6) + ((c1-'0')<<3) + c2-'0');
+ } else if (c == '\\' || c == ':') {
+ *buf++ = c;
+ --len;
+ } else punt ("Broken '\\'");
+ } else {
+ *buf++ = c;
+ --len;
+ }
+ }
+ if (c == EOF)
+ return;
+
+ if (c != EOF && c != ':' && c != '\n') {
+ fprintf(stderr, "Field too wide, truncated\n");
+ while ((c = getc(f)) != EOF && c != ':' && c != '\n');
+ (void) ungetc(c, f);
+ } else {
+ *buf++ = 0;
+ (void) ungetc(c, f);
+ }
+}
+
+void parse_sep(f)
+ FILE *f;
+{
+ if (getc(f) != ':') punt("Expected colon");
+}
+void parse_nl(f)
+ FILE *f;
+{
+ if (getc(f) != '\n') punt("Expected newline");
+}
+
+
+FILE *open_file(suffix)
+ char *suffix;
+{
+ char name[BUFSIZ];
+ int fd;
+ FILE *f;
+
+ sprintf(name, "%s/%s", prefix, suffix);
+
+ fd = open(name, O_RDONLY, 0);
+ if (fd < 0) {
+ punt(name);
+ }
+ f = fdopen(fd, "r");
+ if (f == NULL) {
+ fprintf(stderr, "fdopen of ");
+ punt(name);
+ }
+ fprintf(stderr, "Working on %s\n", name);
+ return(f);
+}
+
+punt(s)
+char *s;
+{
+ printf("exiting: %s\n", s);
+ exit(1);
+}
+
+static int count;
+static int interval;
+
+start_counter(x)
+int x;
+{
+ count = 0;
+ interval = x;
+}
+
+inc_count()
+{
+ if (count++ % interval == 0) {
+ printf("\r%d...", count - 1);
+ fflush(stdout);
+ }
+}
+
+end_counter()
+{
+ printf("\r%d items processed.\n", count);
+}
--- /dev/null
+modify users to cbtree unique on users_id
+index on users is i_usr_login (login)
+modify i_usr_login to btree
+index on users is i_usr_name (first, last)
+modify i_usr_name to cbtree on first, last
+index on users is i_usr_last (last, first)
+modify i_usr_name to cbtree on last, first
+index on users is i_usr_uid (uid)
+modify i_usr_uid to btree
+index on users is i_usr_pop (pop_id)
+modify i_usr_pop to btree
+
+modify machine to cbtree unique on mach_id
+index on machine is i_mac_name (name)
+modify i_mac_name to btree
+
+modify cluster to cbtree unique on clu_id
+index on cluster is i_clu_name (name)
+modify i_clu_name to btree
+
+modify mcmap to cbtree on clu_id
+index on mcmap is i_mcm_mach (mach_id)
+modify i_mcm_mach to cbtree
+
+modify svc to cbtree on clu_id
+
+modify servers to btree on name
+
+modify serverhosts to btree on service
+index on serverhosts is i_sho_mach (mach_id)
+modify i_sho_mach to cbtree
+
+modify list to cbtree unique on list_id
+index on list is i_lis_name (name)
+modify i_lis_name to btree
+index on list is i_lis_mail (maillist)
+index on list is i_lis_group (group)
+index on list is i_lis_gid (gid)
+modify i_lis_gid to btree
+
+modify members to cbtree on member_id, member_type
+index on members is i_mem_list (list_id)
+modify i_mem_list to hash
+
+modify strings to cbtree unique on string_id
+index on strings is i_str_name (string)
+modify i_str_name to hash
+
+modify nfsphys to cbtree unique on nfsphys_id
+index on nfsphys is i_nfs_mach (mach_id)
+modify i_nfs_mach to btree
+
+modify filesys to cbtree unique on filsys_id
+index on filesys is i_fil_name (label)
+modify i_fil_name to cbtree
+index on filesys is i_fil_mach (mach_id)
+modify i_fil_mach to btree
+index on filesys is i_fil_phys (phys_id)
+modify i_fil_phys to cbtree
+index on filesys is i_fil_grp (owners)
+modify i_fil_grp to btree
+
+modify nfsquota to cbtree on users_id
+index on nfsquota is i_nfq_fil (filsys_id)
+modify i_nfq_fil to cbtree
+index on nfsquota is i_nfq_phys (phys_id)
+modify i_nfq_phys to cbtree
+
+modify zephyr to cbtree unique on class
+
+modify hostaccess to cbtree unique on mach_id
+
+modify printcap to cbtree on name
+index on printcap is i_pcp_mach (mach_id)
+modify i_pcp_mach to btree
+
+modify capacls to cbtree on tag
--- /dev/null
+/* (c) Copyright 1988 by the Massachusetts Institute of Technology. */
+/* For copying and distribution information, please see the file */
+/* <mit-copyright.h>. */
+
+#include <mit-copyright.h>
+#include <stdio.h>
+
+char *malloc(), *strsave();
+
+struct np {
+ struct np *next; /* this must be the first field */
+ int id;
+ char *dir;
+};
+struct np **nfsphys = NULL;
+
+int match_phys(mach, directory)
+int mach;
+char *directory;
+{
+ struct np *p, *n;
+
+ if (nfsphys == NULL)
+## {
+## int id, maxmach, mid;
+## char dir[65];
+
+ printf("Building NFSphys table\n");
+## range of n is nfsphys
+## retrieve (maxmach = max(machine.mach_id))
+ maxmach++;
+ nfsphys = (struct np **) malloc(maxmach * sizeof(struct np *));
+ bzero(nfsphys, maxmach * sizeof(struct np *));
+## retrieve (id = n.nfsphys_id, mid = n.mach_id, dir = n.#dir)
+## sort by #dir:d {
+ n = (struct np *) malloc(sizeof(struct np));
+ n->next = NULL;
+ n->id = id;
+ n->dir = strsave(strtrim(dir));
+ p = (struct np *)&nfsphys[mid];
+ while (p->next)
+ p = p->next;
+ p->next = n;
+## }
+## }
+
+ if ((n = nfsphys[mach]) == NULL)
+ return(0);
+ while (n) {
+ if (!strncmp(directory, n->dir, strlen(n->dir)))
+ return(n->id);
+ n = n->next;
+ }
+ return(0);
+}
+
+
+##int match_filsys(mach, device, user)
+##int mach;
+##char *device;
+##int user;
+##{
+## int mid, fid;
+## char dev[33];
+
+## repeat retrieve (fid = f.filsys_id, mid = f.mach_id, dev = n.#device)
+## where f.label = u.login and n.nfsphys_id = f.phys_id and
+## u.users_id = @user
+ if (mid == mach && !strcmp(device, strtrim(dev)))
+ return(fid);
+ fid = 0;
+## repeat retrieve unique (fid = f.filsys_id) where f.mach_id = @mach and
+## f.name = @device
+ if (fid == 0) {
+## repeat retrieve unique (fid = f.filsys_id) where f.mach_id = @mach and
+## f.phys_id = n.nfsphys_id and n.#device = @device
+ }
+ return(fid);
+##}