示例#1
0
int main(int argc, char * argv[]) {

  Tinit();
  ReferentialAlgebra_init();

  recordid rootEntry;
  recordid hash;
  int xid = Tbegin();
  if(TrecordType(xid, ROOT_RECORD) == INVALID_SLOT) {
    printf("Creating new store\n");

    rootEntry = Talloc(xid, sizeof(recordid));
    assert(rootEntry.page == ROOT_RECORD.page);
    assert(rootEntry.slot == ROOT_RECORD.slot);

    hash = ReferentialAlgebra_allocContext(xid);

    Tset(xid, rootEntry, &hash);

  } else {
    printf("Opened existing store\n");
    rootEntry.page = ROOT_RECORD.page;
    rootEntry.slot = ROOT_RECORD.slot;
    rootEntry.size = sizeof(recordid);

    Tread(xid, rootEntry, &hash);

  }

  context = ReferentialAlgebra_openContext(xid,hash);

  Tcommit(xid);

  FILE * in;
  if(argc == 3) { // listen on socket
    if(strcmp("--socket", argv[1])) {
      printf("usage:\n\n%s\n%s <filename>\n%s --socket addr:port\n",
	     argv[0],argv[0],argv[0]);
    } else {
      startServer(argv[2], hash);
    }

    printf("Shutting down...\n");
  } else {
    if(argc == 2) {
      in = fopen(argv[1], "r");
      if(!in) {
	printf("Couldn't open input file.\n");
	return 1;
      }
    } else {
      in = stdin;
    }
    openInterpreter(in, stdout, hash);
  }
  Tdeinit();
}
示例#2
0
JNIEXPORT jlong JNICALL Java_stasis_jni_Stasis_record_1type
  (JNIEnv *e, jclass c, jlong xid, jlongArray jlaRid) {
  recordid rid = recordid_jlongArray(e, jlaRid);
  if((*e)->ExceptionOccurred(e)) return 0;
  return (jlong)TrecordType(xid, rid);
}