コード例 #1
0
ファイル: msgparse.c プロジェクト: PyroMuddypaw/fuzzball
int
get_list_count(dbref player, dbref obj, dbref perms, char *listname, int mesgtyp, int* blessed)
{
	char buf[BUFFER_LEN];
	const char *ptr;
	int i, len = strlen(listname);

	if (listname[len-1] == NUMBER_TOKEN) listname[len-1] = 0;

	snprintf(buf, sizeof(buf), "%.512s#", listname);
	ptr = safegetprop(player, obj, perms, buf, mesgtyp, blessed);
	if (ptr && *ptr)
		return (atoi(ptr));

	snprintf(buf, sizeof(buf), "%.512s/#", listname);
	ptr = safegetprop(player, obj, perms, buf, mesgtyp, blessed);
	if (ptr && *ptr)
		return (atoi(ptr));

	for (i = 1; i < MAX_MFUN_LIST_LEN; i++) {
		ptr = get_list_item(player, obj, perms, listname, i, mesgtyp, blessed);
		if (!ptr)
			return 0;
		if (!*ptr)
			break;
	}
	if (i-- < MAX_MFUN_LIST_LEN)
		return i;
	return MAX_MFUN_LIST_LEN;
}
コード例 #2
0
ファイル: mfuns.c プロジェクト: rhencke/fuzzball
const char *
mfn_exec(MFUNARGS)
{
	dbref trg, obj = what;
	const char *ptr, *pname;
	int blessed = 0;

	pname = argv[0];
	if (argc == 2) {
		obj = mesg_dbref(descr, player, what, perms, argv[1], mesgtyp);
	}
	if (obj == UNKNOWN || obj == AMBIGUOUS || obj == NOTHING || obj == HOME)
		ABORT_MPI("EXEC", "Match failed.");
	if (obj == PERMDENIED)
		ABORT_MPI("EXEC", "Permission denied.");
	while (*pname == PROPDIR_DELIMITER)
		pname++;
	ptr = safegetprop(player, obj, perms, pname, mesgtyp, &blessed);
	if (!ptr)
		ABORT_MPI("EXEC", "Failed read.");
	trg = what;
	if (blessed) {
		mesgtyp |= MPI_ISBLESSED;
	} else {
		mesgtyp &= ~MPI_ISBLESSED;
	}
	if (Prop_ReadOnly(pname) || Prop_Private(pname) || Prop_SeeOnly(pname) || Prop_Hidden(pname))
		trg = obj;
	ptr = mesg_parse(descr, player, obj, trg, ptr, buf, BUFFER_LEN, mesgtyp);
	CHECKRETURN(ptr, "EXEC", "propval");
	return ptr;
}
コード例 #3
0
ファイル: msgparse.c プロジェクト: CyberLeo/protomuck
int
msg_is_macro(dbref player, dbref what, dbref perms, const char *name)
{
    const char   *ptr;
    char    buf2[BUFFER_LEN];
    dbref   obj;

    if (!*name) return 0;
    sprintf(buf2, "_msgmacs/%s", name);
    obj = what;
    ptr = get_mfunc(name);
    if (!ptr || !*ptr) ptr = safegetprop(player, OWNER(obj), perms, buf2);
    if (!ptr || !*ptr) ptr = safegetprop(player, obj, perms, buf2);
    if (!ptr || !*ptr) return 0;
    return 1;
}
コード例 #4
0
const char *
get_list_item(dbref player, dbref what, dbref perms, const char *listname, int itemnum)
{
    char    buf[BUFFER_LEN];
    const char *ptr;

    sprintf(buf, "%.512s#/%d", listname, itemnum);
    ptr = safegetprop(player, what, perms, buf);
    if (!ptr || *ptr) return ptr;

    sprintf(buf, "%.512s/%d", listname, itemnum);
    ptr = safegetprop(player, what, perms, buf);
    if (!ptr || *ptr) return ptr;

    sprintf(buf, "%.512s%d", listname, itemnum);
    return (safegetprop(player, what, perms, buf));
}
コード例 #5
0
ファイル: msgparse.c プロジェクト: CyberLeo/protomuck
void
msg_unparse_macro(dbref player, dbref what, dbref perms, char *name, int argc, argv_typ argv, char *rest, int maxchars)
{
    const char   *ptr;
    char *ptr2;
    char    buf[BUFFER_LEN];
    char    buf2[BUFFER_LEN];
    dbref   obj;
    int     i, p = 0;

    strcpy(buf, rest);
    sprintf(buf2, "_msgmacs/%s", name);
    obj = what;
    ptr = get_mfunc(name);
    if (!ptr || !*ptr) ptr = safegetprop_strict(player, OWNER(obj), perms, buf2);
    if (!ptr || !*ptr) ptr = safegetprop(player, obj, perms, buf2);
    while (ptr && *ptr && p < (maxchars - 1)) {
        if (*ptr == '\\') {
            if (*(ptr+1) == 'r') {
                rest[p++] = '\r';
		ptr++; ptr++;
            } else {
                rest[p++] = *(ptr++);
                rest[p++] = *(ptr++);
            }
        } else if (*ptr == MFUN_LEADCHAR) {
            if (*(ptr+1) == MFUN_ARGSTART && isdigit(*(ptr + 2)) &&
                    *(ptr + 3) == MFUN_ARGEND) {
                ptr++; ptr++;
                i = *(ptr++) - '1';
                ptr++;
                if (i >= argc || i < 0) {
                    ptr2 = NULL;
                } else {
                    ptr2 = argv[i];
                }
                while (ptr2 && *ptr2 && p < (maxchars - 1)) {
                    rest[p++] = *(ptr2++);
                }
            } else {
                rest[p++] = *(ptr++);
            }
        } else {
            rest[p++] = *(ptr++);
        }
    }
    ptr2 = buf;
    while (ptr2 && *ptr2 && p < (maxchars - 1)) {
        rest[p++] = *(ptr2++);
    }
    rest[p] = '\0';
}
コード例 #6
0
ファイル: msgparse.c プロジェクト: PyroMuddypaw/fuzzball
const char *
get_list_item(dbref player, dbref what, dbref perms, char *listname, int itemnum, int mesgtyp, int* blessed)
{
	char buf[BUFFER_LEN];
	const char *ptr;
	int len = strlen(listname);

	if (listname[len-1] == NUMBER_TOKEN) listname[len-1] = 0;

	snprintf(buf, sizeof(buf), "%.512s#/%d", listname, itemnum);
	ptr = safegetprop(player, what, perms, buf, mesgtyp, blessed);
	if (!ptr || *ptr)
		return ptr;

	snprintf(buf, sizeof(buf), "%.512s/%d", listname, itemnum);
	ptr = safegetprop(player, what, perms, buf, mesgtyp, blessed);
	if (!ptr || *ptr)
		return ptr;

	snprintf(buf, sizeof(buf), "%.512s%d", listname, itemnum);
	return (safegetprop(player, what, perms, buf, mesgtyp, blessed));
}
コード例 #7
0
ファイル: mfuns.c プロジェクト: rhencke/fuzzball
const char *
mfn_index(MFUNARGS)
{
	dbref trg = (dbref) 0, obj = what;
	dbref tmpobj = (dbref) 0;
	const char *pname, *ptr;
	int blessed = 0;

	pname = argv[0];
	if (argc == 2) {
		obj = mesg_dbref(descr, player, what, perms, argv[1], mesgtyp);
	}
	if (obj == UNKNOWN || obj == AMBIGUOUS || obj == NOTHING || obj == HOME)
		ABORT_MPI("INDEX", "Match failed.");
	if (obj == PERMDENIED)
		ABORT_MPI("INDEX", "Permission denied.");
	tmpobj = obj;
	ptr = safegetprop(player, obj, perms, pname, mesgtyp, &blessed);
	if (!ptr)
		ABORT_MPI("INDEX", "Failed read.");
	if (!*ptr)
		return "";
	obj = tmpobj;
	ptr = safegetprop(player, obj, perms, ptr, mesgtyp, &blessed);
	if (!ptr)
		ABORT_MPI("INDEX", "Failed read.");
	trg = what;
	if (blessed) {
		mesgtyp |= MPI_ISBLESSED;
	} else {
		mesgtyp &= ~MPI_ISBLESSED;
	}
	if (Prop_ReadOnly(ptr) || Prop_Private(ptr) || Prop_SeeOnly(ptr) || Prop_Hidden(ptr))
		trg = obj;
	ptr = mesg_parse(descr, player, obj, trg, ptr, buf, BUFFER_LEN, mesgtyp);
	CHECKRETURN(ptr, "INDEX", "listval");
	return ptr;
}
コード例 #8
0
int
get_list_count(dbref player, dbref obj, dbref perms, const char *listname)
{
    char    buf[BUFFER_LEN];
    const char *ptr;
    int i;

    sprintf(buf, "%.512s#", listname);
    ptr = safegetprop(player, obj, perms, buf);
    if (ptr && *ptr) return (atoi(ptr));

    sprintf(buf, "%.512s/#", listname);
    ptr = safegetprop(player, obj, perms, buf);
    if (ptr && *ptr) return (atoi(ptr));

    for (i = 1; i < MAX_MFUN_LIST_LEN; i++) {
	ptr = get_list_item(player, obj, perms, listname, i);
        if (!ptr) return 0;
        if (!*ptr) break;
    }
    if (i-- < MAX_MFUN_LIST_LEN) return i;
    return MAX_MFUN_LIST_LEN;
}
コード例 #9
0
ファイル: mfuns.c プロジェクト: rhencke/fuzzball
const char *
mfn_prop(MFUNARGS)
{
	dbref obj = what;
	const char *ptr, *pname;
	int blessed = 0;

	pname = argv[0];
	if (argc == 2) {
		obj = mesg_dbref(descr, player, what, perms, argv[1], mesgtyp);
	}
	if (obj == UNKNOWN || obj == AMBIGUOUS || obj == NOTHING || obj == HOME)
		ABORT_MPI("PROP", "Match failed.");
	if (obj == PERMDENIED)
		ABORT_MPI("PROP", "Permission denied.");
	ptr = safegetprop(player, obj, perms, pname, mesgtyp, &blessed);
	if (!ptr)
		ABORT_MPI("PROP", "Failed read.");
	return ptr;
}