void macrodump(struct macrotable *node, FILE * f) { if (!node) return; macrodump(node->left, f); putstring(f, node->name); putstring(f, node->definition); putref(f, node->implementor); macrodump(node->right, f); }
void doref(char *line1) { char buff[QLEN], dbuff[3*QLEN]; char answer[ANSLEN], temp[TLEN], line[BUFSIZ]; char *p, **sr, *flds[NFLD], *r; int nf, nr, query = 0, alph, digs; again: buff[0] = dbuff[0] = 0; if (biblio && Iline == 1 && line1[0] == '%') n_strcat(dbuff, line1, sizeof(dbuff)); while (input(line, sizeof(line))) { /* get query */ Iline++; if (prefix(line, ".]")) break; if (biblio && line[0] == '\n') break; if (biblio && line[0] == '%' && line[1] == *convert) break; if (control(line[0])) query = 1; n_strcat(query ? dbuff : buff, line, query ? sizeof(dbuff) : sizeof(buff)); if (strlen(buff) > QLEN) err("query too long (%d)", strlen(buff)); if (strlen(dbuff) > 3 * QLEN) err("record at line %d too long", Iline-1); } if (biblio && line[0] == '\n' && feof(in)) return; if (strcmp(buff, "$LIST$\n")==0) { assert (dbuff[0] == 0); dumpold(); return; } answer[0] = 0; for (p = buff; *p; p++) { if (isupper((int)*p)) *p |= 040; } alph = digs = 0; for (p = buff; *p; p++) { if (isalpha((int)*p)) alph++; else if (isdigit((int)*p)) digs++; else { *p = 0; if ((alph+digs < 3) || common(p-alph)) { r = p-alph; while (r < p) *r++ = ' '; } if (alph == 0 && digs > 0) { r = p-digs; if (digs != 4 || atoi(r)/100 != 19) { while (r < p) *r++ = ' '; } } *p = ' '; alph = digs = 0; } } one[0] = 0; if (buff[0]) { /* do not search if no query */ for (sr = rdata; sr < search; sr++) { temp[0] = 0; corout(buff, temp, "hunt", *sr, TLEN); assert(strlen(temp) < TLEN); if (strlen(temp)+strlen(answer) > BUFSIZ) err("Accumulated answers too large",0); n_strcat(answer, temp, sizeof(answer)); if (strlen(answer)>BUFSIZ) err("answer too long (%d)", strlen(answer)); if (newline(answer) > 0) break; } } assert(strlen(one) < ANSLEN); assert(strlen(answer) < ANSLEN); if (buff[0]) switch (newline(answer)) { case 0: fprintf(stderr, "No such paper: %s\n", buff); return; default: fprintf(stderr, "Too many hits: %s\n", trimnl(buff)); choices(answer); p = buff; while (*p != '\n') p++; *++p = 0; case 1: if (endpush) if ((nr = chkdup(answer))) { if (bare < 2) { nf = tabs(flds, one); nf += tabs(flds+nf, dbuff); assert(nf < NFLD); putsig(nf,flds,nr,line1,line,0); } return; } if (one[0] == 0) corout(answer, one, "deliv", dr, QLEN); break; } assert(strlen(buff) < QLEN); assert(strlen(one) < ANSLEN); nf = tabs(flds, one); nf += tabs(flds+nf, dbuff); assert(nf < NFLD); refnum++; if (sort) putkey(nf, flds, refnum, keystr); if (bare < 2) putsig(nf, flds, refnum, line1, line, 1); else flout(); putref(nf, flds); if (biblio && line[0] == '\n') goto again; if (biblio && line[0] == '%' && line[1] == *convert) fprintf(fo, "%s%c%s", convert+1, sep, line+3); }
static int db_write_object(FILE * f, dbref i, int db_format, int flags) { ATTR *a; char *got, *as; dbref aowner; int ca, aflags, save, j; BOOLEXP *tempbool; if(!(flags & V_ATRNAME)) putstring(f, Name(i)); putref(f, Location(i)); if(flags & V_ZONE) putref(f, Zone(i)); putref(f, Contents(i)); putref(f, Exits(i)); if(flags & V_LINK) putref(f, Link(i)); putref(f, Next(i)); if(!(flags & V_ATRKEY)) { got = atr_get(i, A_LOCK, &aowner, &aflags); tempbool = parse_boolexp(GOD, got, 1); free_lbuf(got); putboolexp(f, tempbool); if(tempbool) free_bool(tempbool); } putref(f, Owner(i)); if(flags & V_PARENT) putref(f, Parent(i)); if(!(flags & V_ATRMONEY)) putref(f, Pennies(i)); putref(f, Flags(i)); if(flags & V_XFLAGS) putref(f, Flags2(i)); if(flags & V_3FLAGS) putref(f, Flags3(i)); if(flags & V_POWERS) { putref(f, Powers(i)); putref(f, Powers2(i)); } /* * write the attribute list */ if((!(flags & V_GDBM)) || (mudstate.panicking == 1)) { for(ca = atr_head(i, &as); ca; ca = atr_next(&as)) { save = 0; a = atr_num(ca); if(a) j = a->number; else j = -1; if(j > 0) { switch (j) { case A_NAME: if(flags & V_ATRNAME) save = 1; break; case A_LOCK: if(flags & V_ATRKEY) save = 1; break; case A_LIST: case A_MONEY: break; default: save = 1; } } if(save) { got = atr_get_raw(i, j); fprintf(f, ">%d\n", j); putstring(f, got); } } fprintf(f, "<\n"); } return 0; }