Example #1
0
/* path is the name of the property to find */
PropPtr
propdir_get_elem(PropPtr root, char *path)
{
	PropPtr p;
	char *n;

	if (!root)
		return (NULL);
	while (*path && *path == PROPDIR_DELIMITER)
		path++;
	if (!*path)
		return (NULL);
	n = index(path, PROPDIR_DELIMITER);
	while (n && *n == PROPDIR_DELIMITER)
		*(n++) = '\0';
	if (n && *n) {
		/* just another propdir in the path */
		p = locate_prop(root, path);
		if (p && PropDir(p)) {
			/* yup, found the propdir */
			return (propdir_get_elem(PropDir(p), n));
		}
		return (NULL);
	} else {
		/* aha, we are finally to the property subname itself. */
		if ((p = locate_prop(root, path))) {
			/* found the property! */
			return (p);
		}
		return (NULL);			/* nope, doesn't exist */
	}
}
Example #2
0
/* return true if a property contains a propdir */
int
propdir_check(PropPtr root, char *path)
{
	PropPtr p;

	if ((p = propdir_get_elem(root, path)))
		return (PropDir(p) != NULL);
	return (0);
}
Example #3
0
/* return true if a property contains a propdir */
int
is_propdir_nofetch(dbref player, const char *type)
{
    PropPtr p;
    char w[BUFFER_LEN];

    strcpy(w, type);
    p = propdir_get_elem(DBFETCH(player)->properties, w);
    if (!p)
        return 0;
    return (PropDir(p) != (PropPtr) NULL);
}
Example #4
0
/* path is the name of the propdir to find the first node of */
PropPtr
propdir_first_elem(PropPtr root, char *path)
{
	PropPtr p;

	while (*path && *path == PROPDIR_DELIMITER)
		path++;
	if (!*path)
		return (first_node(root));
	p = propdir_get_elem(root, path);
	if (p && PropDir(p)) {
		return (first_node(PropDir(p)));	/* found the property! */
	}
	return (NULL);				/* nope, doesn't exist */
}
Example #5
0
PropPtr
get_property(dbref player, const char *type)
{
    PropPtr p;
    char buf[BUFFER_LEN];
    char *w;

#ifdef DISKBASE
    fetchprops(player);
#endif

    w = strcpy(buf, type);

    p = propdir_get_elem(DBFETCH(player)->properties, w);
    return (p);
}
Example #6
0
/* return a pointer to the first property in a propdir and duplicates the
   property name into 'name'.  returns 0 if the property list is empty
   or does not exist. */
PropPtr
first_prop_nofetch(dbref player, const char *dir, PropPtr *list, char *name)
{
    char buf[BUFFER_LEN];
    PropPtr p;

    if (dir) {
        while (*dir && *dir == PROPDIR_DELIMITER) {
            dir++;
        }
    }
    if (!dir || !*dir) {
        *list = DBFETCH(player)->properties;
        p = first_node(*list);
        if (p) {
            strcpy(name, PropName(p));
        } else {
            *name = '\0';
        }
        return (p);
    }

    strcpy(buf, dir);
    *list = p = propdir_get_elem(DBFETCH(player)->properties, buf);
    if (!p) {
        *name = '\0';
        return NULL;
    }
    *list = PropDir(p);
    p = first_node(*list);
    if (p) {
        strcpy(name, PropName(p));
    } else {
        *name = '\0';
    }

    return (p);
}