any findin (avl_any *t, any x, struct node *p)
{
    if (p==NULL)
        return 0;

    else if (LT(x,p->item))
        return findin(t, x, p->left);

    else if (LT(p->item,x))
        return findin(t, x, p->right);

    else
        return p->item;
}
Exemple #2
0
void
find(char **dirs, char *cp)
{

	while (*dirs)
		findin(*dirs++, cp);
}
Exemple #3
0
void
findv(char **dirv, int dirc, char *cp)
{

	while (dirc > 0)
		findin(*dirv++, cp), dirc--;
}
Exemple #4
0
static void
lookbin(char *cp)
{
	if (Bflag == 0) {
		findv(bindirs, ARRAY_SIZE(bindirs)-1, cp);
		while (*dirp)
			findin(*dirp++, cp);		/* look $PATH */
	 } else
		findv(Bflag, Bcnt, cp);
}
Exemple #5
0
static void
findin(char *dir, char *cp)
{
	DIR *dirp;
	struct dirent *dp;
	char *d, *dd;
	size_t l;
	char dirbuf[1024];
	struct stat statbuf;

	dd = strchr(dir, '*');
	if (!dd) {
		dirp = opendir(dir);
		if (dirp == NULL)
			return;
		while ((dp = readdir(dirp)) != NULL) {
			if (itsit(cp, dp->d_name)) {
				count++;
				if (print)
					printf(" %s/%s", dir, dp->d_name);
			}
		}
		closedir(dirp);
		return;
	}

	l = strlen(dir);
	if (l < sizeof(dirbuf)) {
		/* refuse excessively long names */
		strcpy(dirbuf, dir);
		d = strchr(dirbuf, '*');
		if (d)
			*d = 0;
		dirp = opendir(dirbuf);
		if (dirp == NULL)
			return;
		while ((dp = readdir(dirp)) != NULL) {
			if (!strcmp(dp->d_name, ".") ||
			    !strcmp(dp->d_name, ".."))
				continue;
			if (strlen(dp->d_name) + l > sizeof(dirbuf))
				continue;
			sprintf(d, "%s", dp->d_name);
			if (stat(dirbuf, &statbuf))
				continue;
			if (!S_ISDIR(statbuf.st_mode))
				continue;
			strcat(d, dd + 1);
			findin(dirbuf, cp);
		}
		closedir(dirp);
	}
	return;

}
Exemple #6
0
static NCerror
repairgrids(NCDAPCOMMON* ncc, NClist* repairlist)
{
    NCerror ncstat = NC_NOERR;
    int i;
    assert(nclistlength(repairlist) % 2 == 0);
    for(i=0;i<nclistlength(repairlist);i+=2) {
	CDFnode* node = (CDFnode*)nclistget(repairlist,i);
	CDFnode* pattern = (CDFnode*)nclistget(repairlist,i+1);
	int index = findin(node->container,node);
	int tindex = findin(pattern->container,pattern);
	ncstat = structwrap(ncc, node,node->container,index,
                             pattern->container,tindex);
#ifdef DEBUG
fprintf(stderr,"repairgrids: %s -> %s\n",
ocfqn(node->ocnode),ocfqn(pattern->ocnode));
#endif

    }
    return ncstat;
}
Exemple #7
0
static void lookup(const char *pattern, struct wh_dirlist *ls, int want)
{
	char patbuf[PATH_MAX];
	int count = 0;
	char *wait = NULL, *p;

	/* canonicalize pattern -- remove path suffix etc. */
	p = strrchr(pattern, '/');
	p = p ? p + 1 : (char *) pattern;
	strncpy(patbuf, p, PATH_MAX);
	patbuf[PATH_MAX - 1] = '\0';

	DBG(SEARCH, ul_debug("lookup dirs for '%s' (%s), want: %s %s %s",
				patbuf, pattern,
				want & BIN_DIR ? "bin" : "",
				want & MAN_DIR ? "min" : "",
				want & SRC_DIR ? "src" : ""));
	p = strrchr(patbuf, '.');
	if (p)
		*p = '\0';

	if (!uflag)
		/* if -u not specified then we always print the pattern */
		printf("%s:", patbuf);

	for (; ls; ls = ls->next) {
		if ((ls->type & want) && ls->path)
			findin(ls->path, patbuf, &count, &wait);
	}

	free(wait);

	if (!uflag || (uflag && count > 1))
		putchar('\n');
	return;
}
any avl_any_find (avl_any *t, any x)
{
    assert(t!=NULL);
    return findin (t,x,t->root);
}
Exemple #9
0
    }
    return 1; /* we matched everything at this level */
}

/* Wrap the node wrt the template grid or template struct */

static NCerror
repairgrids(NCDAPCOMMON* ncc, NClist* repairlist)
{
    NCerror ncstat = NC_NOERR;
    int i;
    assert(nclistlength(repairlist) % 2 == 0);
    for(i=0; i<nclistlength(repairlist); i+=2) {
        CDFnode* node = (CDFnode*)nclistget(repairlist,i);
        CDFnode* template = (CDFnode*)nclistget(repairlist,i+1);
        int index = findin(node->container,node);
        int tindex = findin(template->container,template);
        ncstat = structwrap(ncc, node,node->container,index,
                            template->container,tindex);
#ifdef DEBUG
        fprintf(stderr,"repairgrids: %s -> %s\n",
                ocfqn(node->ocnode),ocfqn(template->ocnode));
#endif

    }
    return ncstat;
}

static NCerror
structwrap(NCDAPCOMMON* ncc, CDFnode* node, CDFnode* parent, int parentindex,
           CDFnode* templategrid, int gridindex)
Exemple #10
0
bool Input::GetKeyUp(s32 k){
	// Get state and return if it is up and has changed this frame
	return findin(keyStates, k) == (Input::ChangedThisFrameFlag|Input::Up);
}
Exemple #11
0
bool Input::GetKeyDown(s32 k){
	// Get state and return if it is down and has changed this frame
	return findin(keyStates, k) == (Input::ChangedThisFrameFlag|Input::Down);
}
Exemple #12
0
bool Input::GetKey(s32 k){
	// Get only the raw "up or down" state
	return findin(keyStates, k) & 1;
}
Exemple #13
0
bool Input::GetButton(s32 k) {
	// Get only the raw "up or down" state
	return findin(mouseStates, k) & 1;
}