void dbio_write_var(Var v) { int i; dbio_write_num((int) v.type & TYPE_DB_MASK); switch ((int) v.type) { case TYPE_CLEAR: case TYPE_NONE: break; case TYPE_STR: dbio_write_string(v.v.str); break; case TYPE_OBJ: case TYPE_ERR: case TYPE_INT: case TYPE_CATCH: case TYPE_FINALLY: dbio_write_num(v.v.num); break; case TYPE_FLOAT: dbio_write_float(*v.v.fnum); break; case TYPE_LIST: dbio_write_num(v.v.list[0].v.num); for (i = 0; i < v.v.list[0].v.num; i++) dbio_write_var(v.v.list[i + 1]); break; } }
static void write_verbdef(Verbdef * v) { dbio_write_string(v->name); dbio_write_objid(v->owner); dbio_write_num(v->perms); dbio_write_num(v->prep); }
static void write_propval(Pval * p) { dbio_write_var(p->var); dbio_write_objid(p->owner); dbio_write_num(p->perms); }
static void write_object(Objid oid) { Object *o; Verbdef *v; int i; int nverbdefs, nprops; if (!valid(oid)) { dbio_printf("#%d recycled\n", oid); return; } o = dbpriv_find_object(oid); dbio_printf("#%d\n", oid); dbio_write_string(o->name); dbio_write_string(""); /* placeholder for old handles string */ dbio_write_num(o->flags); dbio_write_objid(o->owner); dbio_write_objid(o->location); dbio_write_objid(o->contents); dbio_write_objid(o->next); dbio_write_objid(o->parent); dbio_write_objid(o->child); dbio_write_objid(o->sibling); for (v = o->verbdefs, nverbdefs = 0; v; v = v->next) nverbdefs++; dbio_write_num(nverbdefs); for (v = o->verbdefs; v; v = v->next) write_verbdef(v); dbio_write_num(o->propdefs.cur_length); for (i = 0; i < o->propdefs.cur_length; i++) write_propdef(&o->propdefs.l[i]); nprops = dbpriv_count_properties(oid); dbio_write_num(nprops); for (i = 0; i < nprops; i++) write_propval(o->propval + i); }
void dbio_write_objid(Objid oid) { dbio_write_num(oid); }