int safeblessprop(dbref obj, dbref perms, char *buf, int mesgtyp, int set_p) { char *ptr; if (!buf) return 0; while (*buf == PROPDIR_DELIMITER) buf++; if (!*buf) return 0; /* disallow CR's and :'s in prop names. */ for (ptr = buf; *ptr; ptr++) if (*ptr == '\r' || *ptr == PROP_DELIMITER) return 0; if (!(mesgtyp & MPI_ISBLESSED)) { return 0; } if (set_p) { set_property_flags(obj, buf, PROP_BLESSED); } else { clear_property_flags(obj, buf, PROP_BLESSED); } return 1; }
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 prim_blessprop(PRIM_PROTOTYPE) { CHECKOP(2); oper2 = POP(); oper1 = POP(); if (oper2->type != PROG_STRING) abort_interp("Non-string argument (2)"); if (!oper2->data.string) abort_interp("Empty string argument (2)"); if (!valid_object(oper1)) abort_interp("Non-object argument (1)"); CHECKREMOTE(oper1->data.objref); if (mlev < 4) abort_interp("Permission denied."); { char *tmpe; char tname[BUFFER_LEN]; int len = oper2->data.string->length; tmpe = oper2->data.string->data; while (*tmpe && *tmpe != '\r' && *tmpe != ':') tmpe++; if (*tmpe) abort_interp("Illegal propname"); strcpyn(tname, sizeof(tname), oper2->data.string->data); while (len-- > 0 && tname[len] == PROPDIR_DELIMITER) { tname[len] = '\0'; } set_property_flags(oper1->data.objref, tname, PROP_BLESSED); #ifdef LOG_PROPS log2file("props.log", "#%d (%d) BLESSPROP: o=%d n=\"%s\"", program, pc->line, oper1->data.objref, tname); #endif ts_modifyobject(oper1->data.objref); } CLEAR(oper1); CLEAR(oper2); }