const char * mfn_links(MFUNARGS) { char buf2[BUFFER_LEN]; dbref obj; int i, cnt; obj = mesg_dbref(player, what, perms, argv[0]); if (obj == AMBIGUOUS || obj == UNKNOWN || obj == NOTHING || obj == HOME) ABORT_MPI("LINKS","Match failed"); if (obj == PERMDENIED) ABORT_MPI("LINKS",NOPERM_MESG); switch (Typeof(obj)) { case TYPE_ROOM: obj = DBFETCH(obj)->sp.room.dropto; break; case TYPE_PLAYER: obj = DBFETCH(obj)->sp.player.home; break; case TYPE_THING: obj = DBFETCH(obj)->sp.thing.home; break; case TYPE_EXIT: { dbref obj2; *buf = '\0'; cnt = DBFETCH(obj)->sp.exit.ndest; if (cnt) { for (i = 0; i < cnt; i++) { obj2 = DBFETCH(obj)->sp.exit.dest[i]; ref2str(obj2, buf2); if (strlen(buf) + strlen(buf2) + 2 < BUFFER_LEN) { if (*buf) strcat(buf, "\r"); strcat(buf, buf2); } else break; } return buf; } else { return "#-1"; } break; } case TYPE_PROGRAM: default: return "#-1"; break; } return ref2str(obj, buf); }
int lookup(int i) { if (boo[i] == false) { fprintf(stderr, "未定义变量 %s\n", ref2str(i)); exit(0); } return env[i]; }
Node * newNode(Token tok) { Node * t ; if (tok.type == NUM) t = new Node(NUM, stoi(ref2str(tok.ctx))); else if (tok.type == ID) t = new Node(ID, tok.ctx); else t = new Node(tok); return t; }
const char * mfn_muf(MFUNARGS) { char *ptr; struct inst *rv = NULL; dbref obj = mesg_dbref_raw(player, what, perms, argv[0]); if (obj == UNKNOWN) ABORT_MPI("MUF","Match failed"); if (obj <= NOTHING || Typeof(obj) != TYPE_PROGRAM) ABORT_MPI("MUF","Bad program reference"); if (!(FLAGS(obj) & LINK_OK) && !controls(perms,obj)) ABORT_MPI("MUF",NOPERM_MESG); if ((mesgtyp & (MPI_ISLISTENER | MPI_ISLOCK)) && (MLevel(obj) < LM3)) ABORT_MPI("MUF",NOPERM_MESG); if (++mpi_muf_call_levels > 18) ABORT_MPI("MUF","Too many call levels"); strcpy(match_args, argv[1]); ptr = get_mvar("how"); strcpy(match_cmdname, ptr); strcat(match_cmdname, "(MPI)"); rv = interp(player, DBFETCH(player)->location, obj, perms, PREEMPT, STD_HARDUID, 1); mpi_muf_call_levels--; if (!rv) return ""; switch(rv->type) { case PROG_STRING: if (rv->data.string) { strcpy(buf, rv->data.string->data); CLEAR(rv); return buf; } else { CLEAR(rv); return ""; } break; case PROG_INTEGER: sprintf(buf, "%d", rv->data.number); CLEAR(rv); return buf; break; case PROG_OBJECT: ptr = ref2str(rv->data.objref, buf); CLEAR(rv); return ptr; break; default: CLEAR(rv); return ""; break; } return ""; }
void dopointer (int okzero, int requiretag, FileOffset requireoffset, int contexttag, FileOffset contextoffset, char *edgelabel) { if (vmode && ((okzero==NONZERO && requireoffset <= Interrupted) || (okzero==MAYBELAMBDA && requireoffset < Lambda))) { fprintf(stderr, "bad %s pointer in %s 0x%x\n" ,ref2str(requireoffset), tag2str(contexttag), contextoffset); } if (vmode && requireoffset>DoLambda) { int t = tagat(requireoffset); if (t != requiretag) { if ((requiretag==ANYEXP) && (ExpApp<=t) && (t<=ExpDoStmt)) ; else if ((requiretag==ANYATOM) && (AtomVariable<=t) && (t<=AtomAbstract)) ; else fprintf(stderr, "tag at 0x%x is %s, not %s as %s at 0x%x implies\n" , requireoffset, tag2str(t), tag2str(requiretag) , tag2str(contexttag), contextoffset); } } if (amode) { switch(requireoffset) { case Root: case Unevaluated: case Entered: case Interrupted: case Lambda: case DoLambda: printf("(%s)",ref2str(requireoffset)); break; default: printf("(%s 0x%x)", tag2str(requiretag), requireoffset); break; } } if (gmode && requireoffset!=0 && *edgelabel != '\0') if (strcmp(edgelabel,"p")==0) printf("%d -> %d [style=dashed]\n", contextoffset, requireoffset); else printf("%d -> %d [label=\"%s\"]\n", contextoffset, requireoffset, edgelabel); }
const char * mfn_loc(MFUNARGS) { dbref obj; obj = mesg_dbref_local(descr, player, what, perms, argv[0], mesgtyp); if (obj == UNKNOWN || obj == AMBIGUOUS || obj == NOTHING || obj == HOME) ABORT_MPI("LOC", "Match failed."); if (obj == PERMDENIED) ABORT_MPI("LOC", "Permission denied."); return ref2str(getloc(obj), buf, BUFFER_LEN); }
const char * mfn_contents(MFUNARGS) { char buf2[50]; int list_limit = MAX_MFUN_LIST_LEN; dbref obj = mesg_dbref_local(player, what, perms, argv[0]); int typchk, ownroom; int outlen, nextlen; if (obj == AMBIGUOUS || obj == UNKNOWN || obj == NOTHING || obj == HOME) ABORT_MPI("CONTENTS","Match failed"); if (obj == PERMDENIED) ABORT_MPI("CONTENTS",NOPERM_MESG); typchk = NOTYPE; if (argc > 1) { if (!string_compare(argv[1], "Room")) { typchk = TYPE_ROOM; } else if (!string_compare(argv[1], "Exit")) { typchk = TYPE_EXIT; /* won't find any, though */ } else if (!string_compare(argv[1], "Player")) { typchk = TYPE_PLAYER; } else if (!string_compare(argv[1], "Program")) { typchk = TYPE_PROGRAM; } else if (!string_compare(argv[1], "Thing")) { typchk = TYPE_THING; } else { ABORT_MPI("CONTENTS","Type must be 'player', 'room', 'thing', 'program', or 'exit'. (2)"); } } strcpy(buf, ""); outlen = 0; ownroom = controls(perms, obj); obj = DBFETCH(obj)->contents; while (obj != NOTHING && list_limit) { if ((typchk == NOTYPE || Typeof(obj) == typchk) && (ownroom || controls(perms, obj) || !((FLAGS(obj) & DARK) || (FLAGS(getloc(obj)) & DARK) || (Typeof(obj) == TYPE_PROGRAM && !(FLAGS(obj) & LINK_OK)))) && !(Typeof(obj) == TYPE_ROOM && typchk != TYPE_ROOM)) { ref2str(obj, buf2); nextlen = strlen(buf2); if ((outlen + nextlen) >= (BUFFER_LEN - 3)) break; if (outlen) strcat((buf+(outlen++)), "\r"); strcat((buf + outlen), buf2); outlen += nextlen; list_limit--; } obj = DBFETCH(obj)->next; } return buf; }
const char * mfn_owner(MFUNARGS) { dbref obj; obj = mesg_dbref_raw(player, what, perms, argv[0]); if (obj == AMBIGUOUS || obj == NOTHING || obj == UNKNOWN) ABORT_MPI("OWNER","Failed match"); if (obj == PERMDENIED) ABORT_MPI("OWNER",NOPERM_MESG); if (obj == HOME) obj = DBFETCH(player)->sp.player.home; return ref2str(OWNER(obj), buf); }
const char * mfn_online(MFUNARGS) { int list_limit = MAX_MFUN_LIST_LEN; int count = pcount(); char buf2[BUFFER_LEN]; if (!(mesgtyp & MPI_ISBLESSED)) ABORT_MPI("ONLINE", "Permission denied."); *buf = '\0'; while (count && list_limit--) { if (*buf) strcatn(buf, BUFFER_LEN, "\r"); ref2str(pdbref(count), buf2, sizeof(buf2)); if ((strlen(buf) + strlen(buf2)) >= (BUFFER_LEN - 3)) break; strcatn(buf, BUFFER_LEN, buf2); count--; } return buf; }
const char * mfn_exits(MFUNARGS) { int outlen, nextlen; char buf2[50]; int list_limit = MAX_MFUN_LIST_LEN; dbref obj = mesg_dbref(player, what, perms, argv[0]); if (obj == AMBIGUOUS || obj == UNKNOWN || obj == NOTHING || obj == HOME) ABORT_MPI("EXITS","Match failed"); if (obj == PERMDENIED) ABORT_MPI("EXITS",NOPERM_MESG); switch(Typeof(obj)) { case TYPE_ROOM: case TYPE_THING: case TYPE_PLAYER: obj = DBFETCH(obj)->exits; break; default: obj = NOTHING; break; } *buf = '\0'; outlen = 0; while (obj != NOTHING && list_limit) { ref2str(obj, buf2); nextlen = strlen(buf2); if ((outlen + nextlen) >= (BUFFER_LEN - 3)) break; if (outlen) strcat((buf + (outlen++)), "\r"); strcat((buf + outlen), buf2); outlen += nextlen; list_limit--; obj = DBFETCH(obj)->next; } return buf; }