/* Copyright (C) 1991, Andrew Molitor. All rights reserved. */ /* Heavily chopped down variation on the loaddb theme for VMS implementations. */ #include "config.h" #include <stdio.h> #include "mud.h" main(ac,av) int ac; char *av[]; { char obuf[MAXOID]; FILE *in; Obj *op; int cnt = 0; int vflg = 0; #ifdef COMPRESS_OIF int cin = 0; int cout = 0; #endif /* Simplified argument handling for now */ if(ac < 3){ exit(usage()); } while(ac-- > 1){ if(av[ac][0] != '-') continue; switch(av[ac][1]){ case 'o': dddb_setfile(av[ac+1]); break; case 'i': in = fopen(av[ac+1],"r"); if(in == (FILE *)0){ printf("Could not open file %s for input.\n", av[ac+1]); exit(1); } break; case 'v': vflg = 1; break; #ifdef COMPRESS_OIF case 'C': switch(av[ac][2]){ case 'i': cin = 1; break; case 'o': cout = 1; break; default: exit(usage()); break; } break; #endif default: exit(usage()); break; } } dddb_init(); /* Loop across the flat OIF file. */ while(1){ tmp_sync(); #ifdef COMPRESS_OIF if(cin) comp_on(1); else comp_on(0); #endif op = oiffromFILE(in,obuf); if(op == (Obj *)0) break; if(obuf[0] == '\0') { fprintf(stderr,"unnamed object in input\n"); objfree(op); obuf[0] = '\0'; continue; } #ifdef COMPRESS_OIF if(cout) comp_on(1); else comp_on(0); #endif if(dddb_put(op,obuf)) { fprintf(stderr,"cannot store object %s\n",obuf); objfree(op); obuf[0] = '\0'; continue; } else { cnt++; if(vflg) fprintf(stderr,"<+ %s\n",obuf); objfree(op); obuf[0] = '\0'; } } dddb_close(); fclose(in); printf("Stored %d objects.\n",cnt); } usage() { puts("loaddb -i <flat_oif_file> -o <output_db_name> [-Ci -Co -v]"); return(1); }