int ok_player_name(const char *name) { const char *scan; if (!ok_name(name) || strlen(name) > PLAYER_NAME_LIMIT) return 0; for (scan = name; *scan; scan++) { if (!(isprint(*scan) && !isspace(*scan)) && *scan != '(' && *scan != ')' && *scan != '\'' && *scan != ',') { /* was isgraph(*scan) */ return 0; } } /* Check the name isn't reserved */ if (*tp_reserved_player_names && equalstr((char*)tp_reserved_player_names, (char*)name)) return 0; /* lookup name to avoid conflicts */ return (lookup_player(name) == NOTHING); }
/* checks if object has property, returns 1 if it has the property */ int has_property_strict(int descr, dbref player, dbref what, const char *type, const char *pclass, int value) { PropPtr p; const char *str; char *ptr; char buf[BUFFER_LEN]; p = get_property(what, type); if (p) { #ifdef DISKBASE propfetch(what, p); #endif if (PropType(p) == PROP_STRTYP) { str = DoNull(PropDataUNCStr(p)); ptr = do_parse_mesg(descr, player, what, str, "(Lock)", buf, (MPI_ISPRIVATE | MPI_ISLOCK)); return (equalstr((char *) pclass, ptr)); } else if (PropType(p) == PROP_INTTYP) { return (value == PropDataVal(p)); } else { return 0; } } return 0; }
const char * mfn_smatch(MFUNARGS) { if (equalstr(argv[1], argv[0])) { return "1"; } else { return "0"; } }
int blessprops_wildcard(dbref player, dbref thing, const char *dir, const char *wild, int blessp) { char propname[BUFFER_LEN]; char wld[BUFFER_LEN]; char buf[BUFFER_LEN]; char buf2[BUFFER_LEN]; char *ptr, *wldcrd = wld; PropPtr propadr, pptr; int i, cnt = 0; int recurse = 0; #ifdef GOD_PRIV if(tp_strict_god_priv && !God(player) && God(OWNER(thing))) { notify(player,"Only God may touch what is God's."); return 0; } #endif strcpyn(wld, sizeof(wld), wild); i = strlen(wld); if (i && wld[i - 1] == PROPDIR_DELIMITER) strcatn(wld, sizeof(wld), "*"); for (wldcrd = wld; *wldcrd == PROPDIR_DELIMITER; wldcrd++) ; if (!strcmp(wldcrd, "**")) recurse = 1; for (ptr = wldcrd; *ptr && *ptr != PROPDIR_DELIMITER; ptr++) ; if (*ptr) *ptr++ = '\0'; propadr = first_prop(thing, (char *) dir, &pptr, propname, sizeof(propname)); while (propadr) { if (equalstr(wldcrd, propname)) { snprintf(buf, sizeof(buf), "%s%c%s", dir, PROPDIR_DELIMITER, propname); if (!Prop_System(buf) && ((!Prop_Hidden(buf) && !(PropFlags(propadr) & PROP_SYSPERMS)) || Wizard(OWNER(player)))) { if (!*ptr || recurse) { cnt++; if (blessp) { set_property_flags(thing, buf, PROP_BLESSED); snprintf(buf2, sizeof(buf2), "Blessed %s", buf); } else { clear_property_flags(thing, buf, PROP_BLESSED); snprintf(buf2, sizeof(buf2), "Unblessed %s", buf); } notify(player, buf2); } if (recurse) ptr = "**"; cnt += blessprops_wildcard(player, thing, buf, ptr, blessp); } } propadr = next_prop(pptr, propadr, propname, sizeof(propname)); } return cnt; }
void list_program_functions(dbref player, dbref program, char *arg) { struct inst *ptr; int count; ptr = DBFETCH(program)->sp.program.code; count = DBFETCH(program)->sp.program.siz; anotify_nolisten(player, CINFO "*function words*", 1); while (count-- > 0) { if (ptr->type == PROG_FUNCTION) { if (ptr->data.string) { if (!*arg || equalstr(arg, ptr->data.string->data)) { notify_nolisten(player, ptr->data.string->data, 1); } } } ptr++; } anotify_nolisten(player, CINFO "Done.", 1); }
int ok_name(const char *name) { return (name && *name && *name != LOOKUP_TOKEN && *name != REGISTERED_TOKEN && *name != NUMBER_TOKEN && !index(name, ARG_DELIMITER) && !index(name, AND_TOKEN) && !index(name, OR_TOKEN) && !index(name, '\r') && !index(name, ESCAPE_CHAR) && !word_start(name, NOT_TOKEN) && string_compare(name, "me") && string_compare(name, "home") && string_compare(name, "here") && ( !*tp_reserved_names || !equalstr((char*)tp_reserved_names, (char*)name) )); }
/** * List the functions in a program * * Optionally provide a filter string that will match functions using * equalstr * * @see equalstr * * You cannot pass NULL into arg, you can pass empty string if you wish to * show all functions. * * @private * @param player the person to show the list of functions to * @param program the program to list functions from * @param arg a filter string or "" */ static void list_program_functions(dbref player, dbref program, char *arg) { struct inst *ptr; int count; ptr = PROGRAM_CODE(program); count = PROGRAM_SIZ(program); notify_nolisten(player, "*function words*", 1); while (count-- > 0) { if (ptr->type == PROG_FUNCTION) { if (ptr->data.mufproc) { if (!*arg || equalstr(arg, ptr->data.mufproc->procname)) { notify_nolisten(player, ptr->data.mufproc->procname, 1); } } } ptr++; } notify_nolisten(player, "*done*", 1); }
const char * mfn_listprops(MFUNARGS) { dbref obj = what; char *ptr, *pname; char *endbuf, *pattern; char tmpbuf[BUFFER_LEN]; char patbuf[BUFFER_LEN]; char pnamebuf[BUFFER_LEN]; int flag; strcpyn(pnamebuf, sizeof(pnamebuf), argv[0]); pname = pnamebuf; if (argc > 1) { obj = mesg_dbref(descr, player, what, perms, argv[1], mesgtyp); } if (obj == UNKNOWN || obj == AMBIGUOUS || obj == NOTHING || obj == HOME) ABORT_MPI("LISTPROPS", "Match failed."); if (obj == PERMDENIED) ABORT_MPI("LISTPROPS", "Permission denied."); if (argc > 2) { pattern = argv[2]; } else { pattern = NULL; } endbuf = pname + strlen(pname); if (endbuf != pname) { endbuf--; } if (*endbuf != PROPDIR_DELIMITER && (endbuf - pname) < (BUFFER_LEN - 2)) { if (*endbuf != '\0') endbuf++; *endbuf++ = PROPDIR_DELIMITER; *endbuf++ = '\0'; } *buf = '\0'; endbuf = buf; do { ptr = next_prop_name(obj, tmpbuf, (int) sizeof(tmpbuf), pname); if (ptr && *ptr) { flag = 1; if (Prop_System(ptr)) { flag = 0; } else if (!(mesgtyp & MPI_ISBLESSED)) { if (Prop_Hidden(ptr)) { flag = 0; } if (Prop_Private(ptr) && OWNER(what) != OWNER(obj)) { flag = 0; } if (obj != player && OWNER(obj) != OWNER(what)) { flag = 0; } } if ((flag != 0) && (pattern != NULL)) { char *nptr; nptr = rindex(ptr, PROPDIR_DELIMITER); if (nptr && *nptr) { strcpyn(patbuf, sizeof(patbuf), ++nptr); if (!equalstr(pattern, patbuf)) { flag = 0; } } } if (flag) { int entrylen = strlen(ptr); if ((endbuf - buf) + entrylen + 2 < BUFFER_LEN) { if (*buf != '\0') { *endbuf++ = '\r'; } strcpyn(endbuf, BUFFER_LEN - (endbuf - buf), ptr); endbuf += entrylen; } } } pname = ptr; } while (ptr && *ptr); return buf; }
void tune_display_parms(dbref player, char *name) { int total = 0; const char *lastname = NULL; char buf[BUFFER_LEN + 50], tbuf[BUFFER_LEN]; struct tune_str_entry *tstr = tune_str_list; struct tune_time_entry *ttim = tune_time_list; struct tune_val_entry *tval = tune_val_list; struct tune_ref_entry *tref = tune_ref_list; struct tune_bool_entry *tbool = tune_bool_list; while (tstr->name) { strcpy(buf, tstr->name); if ((MLevel(OWNER(player)) >= tstr->readmlev) && (!*name || equalstr(name, buf))) { sprintf(buf, SYSCYAN "(str) " SYSRED "%c" SYSGREEN "%-24s" SYSRED " = " SYSCYAN "%.4096s", (WLevel(OWNER(player)) >= tstr->writemlev) ? ' ' : '-', tstr->name, tct(*tstr->str, tbuf)); lastname = tstr->name; anotify_nolisten2(player, buf); total++; } tstr++; } while (ttim->name) { strcpy(buf, ttim->name); if ((MLevel(OWNER(player)) >= ttim->readmlev) && (!*name || equalstr(name, buf))) { sprintf(buf, SYSPURPLE "(time) " SYSRED "%c" SYSGREEN "%-24s" SYSRED " = " SYSPURPLE "%s", (WLevel(OWNER(player)) >= ttim->writemlev) ? ' ' : '-', ttim->name, timestr_full(*ttim->tim)); lastname = ttim->name; anotify_nolisten2(player, buf); total++; } ttim++; } while (tval->name) { strcpy(buf, tval->name); if ((MLevel(OWNER(player)) >= tval->readmlev) && (!*name || equalstr(name, buf))) { sprintf(buf, SYSGREEN "(int) " SYSRED "%c" SYSGREEN "%-24s" SYSRED " = " SYSYELLOW "%d", (WLevel(OWNER(player)) >= tval->writemlev) ? ' ' : '-', tval->name, *tval->val); lastname = tval->name; anotify_nolisten2(player, buf); total++; } tval++; } while (tref->name) { strcpy(buf, tref->name); if ((MLevel(OWNER(player)) >= tref->readmlev) && (!*name || equalstr(name, buf))) { sprintf(buf, SYSYELLOW "(ref) " SYSRED "%c" SYSGREEN "%-24s" SYSRED " = %s", (WLevel(OWNER(player)) >= tref->writemlev) ? ' ' : '-', tref->name, ansi_unparse_object(player, *tref->ref)); lastname = tref->name; anotify_nolisten2(player, buf); total++; } tref++; } while (tbool->name) { strcpy(buf, tbool->name); if ((MLevel(OWNER(player)) >= tbool->readmlev) && (!*name || equalstr(name, buf))) { sprintf(buf, SYSWHITE "(bool) " SYSRED "%c" SYSGREEN "%-24s" SYSRED " = " SYSBLUE "%s", (WLevel(OWNER(player)) >= tbool->writemlev) ? ' ' : '-', tbool->name, ((*tbool->boolv) ? "yes" : "no")); lastname = tbool->name; anotify_nolisten2(player, buf); total++; } tbool++; } if ((total == 1) && lastname && *lastname) { do_sysparm(player, lastname); } else { anotify_fmt(player, CINFO "%d sysparm%s listed.", total, (total == 1) ? "" : "s"); anotify(player, SYSYELLOW "@tune str, time, int, ref, or bool to list by data types."); } }
stk_array * tune_parms_array(const char *pattern, int mlev) { struct tune_str_entry *tstr = tune_str_list; struct tune_time_entry *ttim = tune_time_list; struct tune_val_entry *tval = tune_val_list; struct tune_ref_entry *tref = tune_ref_list; struct tune_bool_entry *tbool = tune_bool_list; stk_array *nu = new_array_packed(0); struct inst temp1; char pat[BUFFER_LEN]; char buf[BUFFER_LEN]; int i = 0; strcpy(pat, pattern); while (tbool->name) { if (tbool->readmlev <= mlev) { strcpy(buf, tbool->name); if (!*pattern || equalstr(pat, buf)) { stk_array *item = new_array_dictionary(); array_set_strkey_strval(&item, "type", "boolean"); array_set_strkey_strval(&item, "group", tbool->group); array_set_strkey_strval(&item, "name", tbool->name); array_set_strkey_intval(&item, "value", *tbool->boolv ? 1 : 0); array_set_strkey_intval(&item, "readmlev", tbool->readmlev); array_set_strkey_intval(&item, "writemlev", tbool->writemlev); temp1.type = PROG_ARRAY; temp1.data.array = item; array_set_intkey(&nu, i++, &temp1); CLEAR(&temp1); } } tbool++; } while (ttim->name) { if (ttim->readmlev <= mlev) { strcpy(buf, ttim->name); if (!*pattern || equalstr(pat, buf)) { stk_array *item = new_array_dictionary(); array_set_strkey_strval(&item, "type", "timespan"); array_set_strkey_strval(&item, "group", ttim->group); array_set_strkey_strval(&item, "name", ttim->name); array_set_strkey_intval(&item, "value", *ttim->tim); array_set_strkey_intval(&item, "readmlev", ttim->readmlev); array_set_strkey_intval(&item, "writemlev", ttim->writemlev); temp1.type = PROG_ARRAY; temp1.data.array = item; array_set_intkey(&nu, i++, &temp1); CLEAR(&temp1); } } ttim++; } while (tval->name) { if (tval->readmlev <= mlev) { strcpy(buf, tval->name); if (!*pattern || equalstr(pat, buf)) { stk_array *item = new_array_dictionary(); array_set_strkey_strval(&item, "type", "integer"); array_set_strkey_strval(&item, "group", tval->group); array_set_strkey_strval(&item, "name", tval->name); array_set_strkey_intval(&item, "value", *tval->val); array_set_strkey_intval(&item, "readmlev", tval->readmlev); array_set_strkey_intval(&item, "writemlev", tval->writemlev); temp1.type = PROG_ARRAY; temp1.data.array = item; array_set_intkey(&nu, i++, &temp1); CLEAR(&temp1); } } tval++; } while (tref->name) { if (tref->readmlev <= mlev) { strcpy(buf, tref->name); if (!*pattern || equalstr(pat, buf)) { stk_array *item = new_array_dictionary(); array_set_strkey_strval(&item, "type", "dbref"); array_set_strkey_strval(&item, "group", tref->group); array_set_strkey_strval(&item, "name", tref->name); array_set_strkey_refval(&item, "value", *tref->ref); array_set_strkey_intval(&item, "readmlev", tref->readmlev); array_set_strkey_intval(&item, "writemlev", tref->writemlev); switch (tref->typ) { case NOTYPE: array_set_strkey_strval(&item, "objtype", "any"); break; case TYPE_PLAYER: array_set_strkey_strval(&item, "objtype", "player"); break; case TYPE_THING: array_set_strkey_strval(&item, "objtype", "thing"); break; case TYPE_ROOM: array_set_strkey_strval(&item, "objtype", "room"); break; case TYPE_EXIT: array_set_strkey_strval(&item, "objtype", "exit"); break; case TYPE_PROGRAM: array_set_strkey_strval(&item, "objtype", "program"); break; case TYPE_GARBAGE: array_set_strkey_strval(&item, "objtype", "garbage"); break; default: array_set_strkey_strval(&item, "objtype", "unknown"); break; } temp1.type = PROG_ARRAY; temp1.data.array = item; array_set_intkey(&nu, i++, &temp1); CLEAR(&temp1); } } tref++; } while (tstr->name) { if (tstr->readmlev <= mlev) { strcpy(buf, tstr->name); if (!*pattern || equalstr(pat, buf)) { stk_array *item = new_array_dictionary(); array_set_strkey_strval(&item, "type", "string"); array_set_strkey_strval(&item, "group", tstr->group); array_set_strkey_strval(&item, "name", tstr->name); array_set_strkey_strval(&item, "value", *tstr->str); array_set_strkey_intval(&item, "readmlev", tstr->readmlev); array_set_strkey_intval(&item, "writemlev", tstr->writemlev); temp1.type = PROG_ARRAY; temp1.data.array = item; array_set_intkey(&nu, i++, &temp1); CLEAR(&temp1); } } tstr++; } return nu; }
void listenqueue(int descr, dbref player, dbref where, dbref trigger, dbref what, dbref xclude, const char *propname, const char *toparg, int mlev, int mt, int mpi_p) { const char *tmpchar; const char *pname, *sep, *ptr; dbref the_prog = NOTHING; char buf[BUFFER_LEN]; char exbuf[BUFFER_LEN]; char *ptr2; if (!(FLAGS(what) & LISTENER) && !(FLAGS(OWNER(what)) & ZOMBIE)) return; the_prog = NOTHING; tmpchar = NULL; /* queue up program referred to by the given property */ if (((the_prog = get_property_dbref(what, propname)) != NOTHING) || (tmpchar = get_property_class(what, propname))) { if (tmpchar) { sep = tmpchar; while (*sep) { if (*sep == '\\') { sep++; } else if (*sep == '=') { break; } if (*sep) sep++; } if (*sep == '=') { for (ptr = tmpchar, ptr2 = buf; ptr < sep; *ptr2++ = *ptr++) ; *ptr2 = '\0'; strcpyn(exbuf, sizeof(exbuf), toparg); if (!equalstr(buf, exbuf)) { tmpchar = NULL; } else { tmpchar = ++sep; } } } if ((tmpchar && *tmpchar) || the_prog != NOTHING) { if (tmpchar) { if (*tmpchar == '&') { the_prog = AMBIGUOUS; } else if (*tmpchar == NUMBER_TOKEN && number(tmpchar + 1)) { the_prog = (dbref) atoi(++tmpchar); } else if (*tmpchar == REGISTERED_TOKEN) { the_prog = find_registered_obj(what, tmpchar); } else if (number(tmpchar)) { the_prog = (dbref) atoi(tmpchar); } else { the_prog = NOTHING; } } else { if (the_prog == AMBIGUOUS) the_prog = NOTHING; } if (the_prog != AMBIGUOUS) { if (the_prog < 0 || the_prog >= db_top) { the_prog = NOTHING; } else if (Typeof(the_prog) != TYPE_PROGRAM) { the_prog = NOTHING; } else if (OWNER(the_prog) != OWNER(player) && !(FLAGS(the_prog) & LINK_OK)) { the_prog = NOTHING; } else if (MLevel(the_prog) < mlev) { the_prog = NOTHING; } else if (MLevel(OWNER(the_prog)) < mlev) { the_prog = NOTHING; } else if (the_prog == xclude) { the_prog = NOTHING; } } if (the_prog == AMBIGUOUS) { if (mpi_p) { add_mpi_event(1, descr, player, where, trigger, tmpchar + 1, (mt ? "Listen" : "Olisten"), toparg, 1, (mt == 0), Prop_Blessed(what, propname)); } } else if (the_prog != NOTHING) { add_muf_queue_event(descr, player, where, trigger, the_prog, toparg, "(_Listen)", 1); } } } strcpyn(buf, sizeof(buf), propname); if (is_propdir(what, buf)) { strcatn(buf, sizeof(buf), "/"); while ((pname = next_prop_name(what, exbuf, sizeof(exbuf), buf))) { *buf = '\0'; strcatn(buf, sizeof(buf), pname); listenqueue(descr, player, where, trigger, what, xclude, buf, toparg, mlev, mt, mpi_p); } } }
void prim_array_filter_prop(PRIM_PROTOTYPE) { char pattern[BUFFER_LEN]; char tname[BUFFER_LEN]; struct inst *in; struct inst temp1; stk_array *arr; stk_array *nu; char* prop; int len; CHECKOP(3); oper3 = POP(); /* str pattern */ oper2 = POP(); /* str propname */ oper1 = POP(); /* refarr Array */ if (oper1->type != PROG_ARRAY) abort_interp("Argument not an array. (1)"); if (!array_is_homogenous(oper1->data.array, PROG_OBJECT)) abort_interp("Argument not an array of dbrefs. (1)"); if (oper2->type != PROG_STRING || !oper2->data.string) abort_interp("Argument not a non-null string. (2)"); if (oper3->type != PROG_STRING) abort_interp("Argument not a string pattern. (3)"); len = oper2->data.string ? oper2->data.string->length : 0; strcpyn(tname, sizeof(tname), DoNullInd(oper2->data.string)); while (len-- > 0 && tname[len] == PROPDIR_DELIMITER) { tname[len] = '\0'; } nu = new_array_packed(0); arr = oper1->data.array; prop = tname; strcpyn(pattern, sizeof(pattern), DoNullInd(oper3->data.string)); if (array_first(arr, &temp1)) { do { in = array_getitem(arr, &temp1); if (valid_object(in)) { ref = in->data.objref; CHECKREMOTE(ref); if (prop_read_perms(ProgUID, ref, prop, mlev)) { PropPtr pptr = get_property(ref, prop); if (pptr) { switch(PropType(pptr)) { case PROP_STRTYP: strncpy(buf, PropDataStr(pptr), BUFFER_LEN); break; case PROP_LOKTYP: if (PropFlags(pptr) & PROP_ISUNLOADED) { strncpy(buf, "*UNLOCKED*", BUFFER_LEN); } else { strncpy(buf, unparse_boolexp(ProgUID, PropDataLok(pptr), 0), BUFFER_LEN); } break; case PROP_REFTYP: snprintf(buf, BUFFER_LEN, "#%i", PropDataRef(pptr)); break; case PROP_INTTYP: snprintf(buf, BUFFER_LEN, "%i", PropDataVal(pptr)); break; case PROP_FLTTYP: snprintf(buf, BUFFER_LEN, "%g", PropDataFVal(pptr)); break; default: strncpy(buf, "", BUFFER_LEN); break; } } else strncpy(buf, "", BUFFER_LEN); if (equalstr(pattern, buf)) { array_appenditem(&nu, in); } } } } while (array_next(arr, &temp1)); } CLEAR(oper3); CLEAR(oper2); CLEAR(oper1); PushArrayRaw(nu); }