/* Copyright 1989, 1990 by James Aspnes, David Applegate, and Bennet Yee */ /* See the file COPYING for distribution information */ #include <stdio.h> #include <ctype.h> #include "db.h" #include "globals.h" #include "bytecode.h" extern byte *compile(const char *); datum me; datum you; datum text; datum mtext; int please_gc = 0; int please_checkpoint = 0; int shutdown_flag = 0; void main(int argc, char **argv) { FILE *f; char buf[2048]; if(argc < 2) { fprintf(stderr, "Usage: %s db-file\n", argv[0]); exit(1); } if((f = fopen(argv[1], "r")) == NULL) { perror(f); exit(2); } if(db_read(f) < 0) { fprintf(stderr, "Couldn't read database from %s\n", argv[1]); exit(3); } else { fclose(f); } while(!shutdown_flag && gets(buf)) { parse_command(1, buf); if(please_gc) { full_gc(); please_gc = 0; } else { incremental_gc(); } } db_write(stdout); } void notify(datum victim, const char *buf) { printf("%d: %s\n", victim, buf); }