Пример #1
0
str
fix_exec_path (str path, str dir)
{
  const char *prog = strrchr (path, '/');
  if (prog)
    return path;

  if (!dir)
    dir = execdir;
  path = dir << "/" << path;
  prog = strrchr (path, '/');
  if (!prog)
    panic ("No EXECDIR for unqualified path %s.\n", path.cstr ());

#ifdef MAINTAINER
  if (builddir && dir == execdir) {
    str np;
    np = builddir << prog;
    if (execok (np))
      return np;
    np = builddir << prog << prog;
    if (execok (np))
      return np;
    if (np = searchdir (builddir, prog))
      return np;
    if (np = searchdir (builddir << "/lib", prog))
      return np;
  }
#endif /* MAINTAINER */

  return path;
}
Пример #2
0
/*
 * Read indirect blocks, and pass the data blocks to be searched
 * as directories. Quit as soon as any entry is found that will
 * require the directory to be dumped.
 */
static int
dirindir(ufs1_ino_t ino, daddr_t blkno, int ind_level, long *filesize,
         long *tape_size, int nodump)
{
	int ret = 0;
	int i;
	daddr_t	idblk[MAXNINDIR];

	bread(fsbtodb(sblock, blkno), (char *)idblk, (int)sblock->fs_bsize);
	if (ind_level <= 0) {
		for (i = 0; *filesize > 0 && i < NINDIR(sblock); i++) {
			blkno = idblk[i];
			if (blkno != 0) {
				ret |= searchdir(ino, blkno, sblock->fs_bsize,
					*filesize, tape_size, nodump);
			}
			if (ret & HASDUMPEDFILE)
				*filesize = 0;
			else
				*filesize -= sblock->fs_bsize;
		}
		return (ret);
	}
	ind_level--;
	for (i = 0; *filesize > 0 && i < NINDIR(sblock); i++) {
		blkno = idblk[i];
		if (blkno != 0) {
			ret |= dirindir(ino, blkno, ind_level, filesize,
			    tape_size, nodump);
		}
	}
	return (ret);
}
Пример #3
0
__export int open_file(const char *name, int flags, struct com32_filedata *filedata)
{
    int rv;
    struct file *file;
    char mangled_name[FILENAME_MAX];

    dprintf("open_file %s\n", name);

    mangle_name(mangled_name, name);
    rv = searchdir(mangled_name, flags);

    if (rv < 0)
	return rv;

    file = handle_to_file(rv);

    if (file->inode->mode != DT_REG) {
	_close_file(file);
	return -1;
    }

    filedata->size	= file->inode->size;
    filedata->blocklg2	= SECTOR_SHIFT(file->fs);
    filedata->handle	= rv;

    return rv;
}
Пример #4
0
int chdir(const char *src)
{
    int rv;
    struct file *file;
    char cwd_buf[CURRENTDIR_MAX];

    if (this_fs->fs_ops->chdir)
	return this_fs->fs_ops->chdir(this_fs, src);

    /* Otherwise it is a "conventional filesystem" */
    rv = searchdir(src);
    if (rv < 0)
	return rv;

    file = handle_to_file(rv);
    if (file->inode->mode != DT_DIR) {
	_close_file(file);
	return -1;
    }

    put_inode(this_fs->cwd);
    this_fs->cwd = get_inode(file->inode);
    _close_file(file);

    /* Save the current working directory */
    realpath(cwd_buf, src, CURRENTDIR_MAX);

    /* Make sure the cwd_name ends in a slash, it's supposed to be a prefix */
    join_paths(this_fs->cwd_name, CURRENTDIR_MAX, cwd_buf, "/");

    return 0;
}
Пример #5
0
/*
 * Read indirect blocks, and pass the data blocks to be searched
 * as directories. Quit as soon as any entry is found that will
 * require the directory to be dumped.
 */
static int
dirindir(ino_t ino, daddr64_t blkno, int ind_level, off_t *filesize)
{
	int ret = 0;
	int i;
	char idblk[MAXBSIZE];

	bread(fsbtodb(sblock, blkno), idblk, (int)sblock->fs_bsize);
	if (ind_level <= 0) {
		for (i = 0; *filesize > 0 && i < NINDIR(sblock); i++) {
			if (sblock->fs_magic == FS_UFS1_MAGIC)
				blkno = ((int32_t *)idblk)[i];
			else
				blkno = ((int64_t *)idblk)[i];
			if (blkno != 0)
				ret |= searchdir(ino, blkno, sblock->fs_bsize,
					*filesize);
			if (ret & HASDUMPEDFILE)
				*filesize = 0;
			else
				*filesize -= sblock->fs_bsize;
		}
		return (ret);
	}
	ind_level--;
	for (i = 0; *filesize > 0 && i < NINDIR(sblock); i++) {
		if (sblock->fs_magic == FS_UFS1_MAGIC)
			blkno = ((int32_t *)idblk)[i];
		else
			blkno = ((int64_t *)idblk)[i];
		if (blkno != 0)
			ret |= dirindir(ino, blkno, ind_level, filesize);
	}
	return (ret);
}
Пример #6
0
/*
 * Dump pass 2.
 *
 * Scan each directory on the filesystem to see if it has any modified
 * files in it. If it does, and has not already been added to the dump
 * list (because it was itself modified), then add it. If a directory
 * has not been modified itself, contains no modified files and has no
 * subdirectories, then it can be deleted from the dump list and from
 * the list of directories. By deleting it from the list of directories,
 * its parent may now qualify for the same treatment on this or a later
 * pass using this algorithm.
 */
int
mapdirs(ino_t maxino, off_t *tapesize)
{
	union dinode *dp;
	int i, isdir;
	char *map;
	ino_t ino;
	union dinode di;
	off_t filesize;
	int ret, change = 0;

	isdir = 0;		/* XXX just to get gcc to shut up */
	for (map = dumpdirmap, ino = 1; ino < maxino; ino++) {
		if (((ino - 1) % NBBY) == 0)	/* map is offset by 1 */
			isdir = *map++;
		else
			isdir >>= 1;
		if ((isdir & 1) == 0 || TSTINO(ino, dumpinomap))
			continue;
		dp = getino(ino, &i);
		/*
		 * inode buf may change in searchdir().
		 */
		if (sblock->fs_magic == FS_UFS1_MAGIC)
			di.dp1 = dp->dp1;
		else
			di.dp2 = dp->dp2;
		filesize = (off_t)DIP(dp, di_size);
		for (ret = 0, i = 0; filesize > 0 && i < NDADDR; i++) {
			if (DIP(&di, di_db[i]) != 0)
				ret |= searchdir(ino, DIP(&di, di_db[i]),
				    sblksize(sblock, DIP(dp, di_size), i),
				    filesize);
			if (ret & HASDUMPEDFILE)
				filesize = 0;
			else
				filesize -= sblock->fs_bsize;
		}
		for (i = 0; filesize > 0 && i < NIADDR; i++) {
			if (DIP(&di, di_ib[i]) == 0)
				continue;
			ret |= dirindir(ino, DIP(&di, di_ib[i]), i, &filesize);
		}
		if (ret & HASDUMPEDFILE) {
			SETINO(ino, dumpinomap);
			*tapesize += blockest(dp);
			change = 1;
			continue;
		}
		if ((ret & HASSUBDIRS) == 0) {
			if (!TSTINO(ino, dumpinomap)) {
				CLRINO(ino, dumpdirmap);
				change = 1;
			}
		}
	}
	return (change);
}
Пример #7
0
char *ttyname(int fd)
{
    struct stat fdstat;
    struct devdir *ddp;
    char *rval;

    if (isatty(fd) == 0)
	return(NULL);
    if (fstat(fd, &fdstat) < 0)
	return(NULL);
    if (S_ISCHR(fdstat.st_mode) == 0)
	return(NULL);

    rval = searchdir("/dev", &fdstat);
    if (rval == NULL) {
	for (ddp = head; ddp != NULL; ddp = ddp->d_next)
	    if ((rval = searchdir(ddp->d_name, &fdstat)) != NULL)
		break;
    }
    
    cleanup();
    return(rval);
}
Пример #8
0
void pm_searchdir(com32sys_t *regs)
{
    char *name = MK_PTR(regs->ds, regs->edi.w[0]);
    int rv;

    rv = searchdir(name);
    if (rv < 0) {
	regs->esi.w[0]  = 0;
	regs->eax.l     = 0;
	regs->eflags.l |= EFLAGS_ZF;
    } else {
	regs->esi.w[0]  = rv;
	regs->eax.l     = handle_to_file(rv)->inode->size;
	regs->eflags.l &= ~EFLAGS_ZF;
    }
}
Пример #9
0
/*
 * Read indirect blocks, and pass the data blocks to be searched
 * as directories. Quit as soon as any entry is found that will
 * require the directory to be dumped.
 */
static int
dirindir(
	ino_t ino,
	ufs2_daddr_t blkno,
	int ind_level,
	long *filesize,
	long *tapesize,
	int nodump,
	ino_t maxino)
{
	union {
		ufs1_daddr_t ufs1[MAXBSIZE / sizeof(ufs1_daddr_t)];
		ufs2_daddr_t ufs2[MAXBSIZE / sizeof(ufs2_daddr_t)];
	} idblk;
	int ret = 0;
	int i;

	bread(fsbtodb(sblock, blkno), (char *)&idblk, (int)sblock->fs_bsize);
	if (ind_level <= 0) {
		for (i = 0; *filesize > 0 && i < NINDIR(sblock); i++) {
			if (sblock->fs_magic == FS_UFS1_MAGIC)
				blkno = idblk.ufs1[i];
			else
				blkno = idblk.ufs2[i];
			if (blkno != 0)
				ret |= searchdir(ino, blkno, sblock->fs_bsize,
					*filesize, tapesize, nodump, maxino);
			if (ret & HASDUMPEDFILE)
				*filesize = 0;
			else
				*filesize -= sblock->fs_bsize;
		}
		return (ret);
	}
	ind_level--;
	for (i = 0; *filesize > 0 && i < NINDIR(sblock); i++) {
		if (sblock->fs_magic == FS_UFS1_MAGIC)
			blkno = idblk.ufs1[i];
		else
			blkno = idblk.ufs2[i];
		if (blkno != 0)
			ret |= dirindir(ino, blkno, ind_level, filesize,
			    tapesize, nodump, maxino);
	}
	return (ret);
}
Пример #10
0
/* 
 * Open a directory
 */
__export DIR *opendir(const char *path)
{
    int rv;
    struct file *file;

    rv = searchdir(path, O_RDONLY|O_DIRECTORY);
    if (rv < 0)
	return NULL;

    file = handle_to_file(rv);

    if (file->inode->mode != DT_DIR) {
	_close_file(file);
	return NULL;
    }

    return (DIR *)file;
}
Пример #11
0
/*
 * Lookup a pathname which is always assumed to start from the ROOTINO.
 */
struct direct *
pathsearch(const char *pathname)
{
	ino_t ino;
	struct direct *dp;
	char *path, *name, buffer[MAXPATHLEN];

	strlcpy(buffer, pathname, sizeof buffer);
	path = buffer;
	ino = ROOTINO;
	while (*path == '/')
		path++;
	dp = NULL;
	while ((name = strsep(&path, "/")) != NULL && *name != '\0') {
		if ((dp = searchdir(ino, name)) == NULL)
			return (NULL);
		ino = dp->d_ino;
	}
	return (dp);
}
Пример #12
0
void pm_open_file(com32sys_t *regs)
{
    int rv;
    struct file *file;
    const char *name = MK_PTR(regs->es, regs->esi.w[0]);
    char mangled_name[FILENAME_MAX];

    dprintf("pm_open_file %s\n", name);

    mangle_name(mangled_name, name);
    rv = searchdir(mangled_name);
    if (rv < 0) {
	regs->eflags.l |= EFLAGS_CF;
    } else {
	file = handle_to_file(rv);
	regs->eflags.l &= ~EFLAGS_CF;
	regs->eax.l = file->inode->size;
	regs->ecx.w[0] = SECTOR_SIZE(file->fs);
	regs->esi.w[0] = rv;
    }
}
Пример #13
0
	void getSubFiles(char* pDir, CStringList& pOut, CString* search)
	{
		// Assemble the search wildcards.
		CString searchdir( pDir );
		if ( search == 0 ) searchdir << "*";
		else
		{
			searchdir << search->replaceAll( "%", "*" );
			searchdir << ".txt";
		}

		WIN32_FIND_DATA filedata;
		HANDLE hFind = FindFirstFile(searchdir.text(), &filedata);
		if(hFind!=NULL)
		{
			do
			{
				if(!(filedata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
					pOut.add(filedata.cFileName);
			} while (FindNextFile(hFind, &filedata));
		}
		FindClose(hFind);
	}
Пример #14
0
void searchdir(const char *name, int level)
{
    DIR *dir;
    struct dirent *entry;
		char *symlinkpath = (char *)name;
    if (!(dir = opendir(name)))
        return;
    if (!(entry = readdir(dir)))
        return;

    do {
        if (entry->d_type == DT_DIR)
				{
            char path[1024];
            int len = snprintf(path, sizeof(path)-1, "%s/%s", name, entry->d_name);
            path[len] = 0;
            if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0)
                continue;
            searchdir(path, level + 1);
        }
        else
				{
					//this logic sucked so 
					//buf has the full real file path
					//then i copy the systemlink part of the real file path in buff
					//then since that deletes the d_name i pin a / and the d_name to the end
					//of result so result now has full file path
						FILE *fp;
						char *ptr;
						char buf[PATH_MAX + 10]; 
						char result[1000];
						realpath(entry->d_name, buf);
							//printf("systemlinkpath %s\n",symlinkpath);
							ptr = realpath(symlinkpath,buf);
							strcpy(result,ptr);
							strcat(result,"/");
							strcat(result,entry->d_name);
    					
						//	printf("result %s\n",result);
							if(strcmp(result, "~") == 0)
							{
								continue;
							}
							else
							{
								fp = fopen(result,"r");
								//printf("opened %s\n",result);
							}						
						//if you cant read one file skip it and continue
							if(fp == NULL)
					   	{
						  	printf("ERROR: You cant open this file in this directory\n");
						  	continue;
					   	}	
							else
							{
								
								readFILE(fp);
		            fclose(fp); 
								
							}
				     
		          
				}
    } while ((entry = readdir(dir)));
    closedir(dir);
}
Пример #15
0
int main(int nargs,char *argv[])
{
	FILE *fp;
	FILE *outPut;
	struct stat fileStat;
	struct stat fileStat1;
	if(nargs != 5)
	{
		printf("ERROR:Not enough parameters. you dun goofed bro!!!!\n");
		exit(1);
	}
	else
	{	
		if(strcmp(argv[1],argv[4]) == 0)
		{
		 printf("ERROR:Can not output to input file\n");
		 exit(1);
		}
		//num of print to console
     int numPrint;
	  //num of process to fork
		 int numProc;
		if(sscanf(argv[2],"%i",&numPrint) != 1 || sscanf(argv[2],"%i",&numPrint) != 1)
		{
				printf("ERROR: parameter 2 and 3 have to be integers!\n");
					exit(1);
		}
    numPrint = atoi(argv[2]);
    numProc = atoi(argv[3]);

    if(stat(argv[1],&fileStat) < 0)
		{
			printf("ERROR:FILE OR DIRECTORY NOT EXIST\n");    
        exit(1);
		}
		if(stat(argv[4],&fileStat1) == 0)
		{
			printf("ERROR:OUTPUT FILE EXIST AND WILL BE OVER WRITTEN\n");    
        exit(1);
		}
		else
		{
			char *ftp = argv[4];
    	outPut = fopen(ftp,"w+"); 
		}

    

    if(outPut == NULL)
    {
     printf("ERROR: couldnt open file for writing\n");
     exit(1);

    }
//if command line read in a file or read in a directory
			if (S_ISREG(fileStat.st_mode) && (fileStat.st_mode & S_IRUSR))
			{
				
				       //get file size
				
          unsigned int fileSize = fileStat.st_size;
          int fd = open(argv[1],O_RDONLY);
					char *file = NULL;
					printf("FileSize: %d\n", fileSize);
				
					int i;
          fp = fopen(argv[1], "r");
						 if(fp == NULL)
					   {
						  printf("ERROR: Couldnt open file might not exist!!!!!\n");
						  exit(1);
					   }
						//mmap the file
					 	file = splitFile(fp,fileSize,numProc,fd);
						int length = fileSize/numProc;
						int j;
						//usable stuff
						int startingIndex[numProc];
						int endingIndex[numProc];
						int tempPosition = 0;

						//moving starting and ending points
						for(i = 0; i < numProc; i++)
						{
							startingIndex[i] = i * length;
							endingIndex[i] = (i * length) + length;
						}

						for(i = 1; i < numProc; i++)
						{
								while(file[startingIndex[i]] != ' ' && file[startingIndex[i]] != '\t' && file[startingIndex[i]] != '\n')
								{
									
									startingIndex[i]++;
									endingIndex[i-1]++;
								}
						}

						for(i = 0; i < numProc; i++)
						{
							printf("block number:%d\n",i);
								//call child stuff 
							for(j = startingIndex[i]; j < endingIndex[i]; j++)
							{
								//filter
								char tempAry[500];
								tempPosition = 0; 
								//cut out the white space caused by having to move the starting and ending indexs
								//printf("file[startingIndex[i]]: %c\n",file[startingIndex[i]]);
								while(file[j] != ' ' && file[j] != '\t' && file[j] != '\n' && j < endingIndex[i])
								{
											tempAry[tempPosition] = file[j];
											tempPosition++;
											j++;
												
								}
								tempAry[tempPosition] = '\0';
								
								if(strlen(tempAry) > 0)	
								{
									if(wordfilter(tempAry) == TRUE)
									{
										printf("%s ",tempAry);
								  }	
									
								}	
										
							}
							printf("\n");			
						}
					
				   readFILE(fp);
	         sortLinkedList();   			
		       printList(numPrint,outPut);
           fclose(fp);
					 freeAll();
			}
			else if (S_ISDIR(fileStat.st_mode) && (fileStat.st_mode & S_IRUSR))
			{
			//printf("This is a directory and you can read noice\n");
           searchdir(argv[1],0);
					 sortLinkedList();
					 printList(numPrint,outPut);
					 freeAll();
   		 }
			else
			{
				printf("ERROR:your input is either not a file, not a directory,or the input could not be read please check permissions on file and re-run if you believe a error has occured"); 
			}
	}
 fclose(outPut);
    
return 0;
}
Пример #16
0
/*
 * Dump pass 2.
 *
 * Scan each directory on the filesystem to see if it has any modified
 * files in it. If it does, and has not already been added to the dump
 * list (because it was itself modified), then add it. If a directory
 * has not been modified itself, contains no modified files and has no
 * subdirectories, then it can be deleted from the dump list and from
 * the list of directories. By deleting it from the list of directories,
 * its parent may now qualify for the same treatment on this or a later
 * pass using this algorithm.
 */
int
mapdirs(ino_t maxino, int64_t *tapesize)
{
	union dinode *dp;
	int i, isdir, nodump;
	char *map;
	ino_t ino;
	union dinode di;
	off_t filesize;
	int ret, change = 0;

	isdir = 0;		/* XXX just to get gcc to shut up */
	for (map = dumpdirmap, ino = 1; ino < maxino; ino++) {
		if (((ino - 1) % NBBY) == 0)	/* map is offset by 1 */
			isdir = *map++;
		else
			isdir >>= 1;
                /*
		 * If a directory has been removed from usedinomap, it
		 * either has the nodump flag set, or has inherited
		 * it.  Although a directory can't be in dumpinomap if
		 * it isn't in usedinomap, we have to go through it to
		 * propagate the nodump flag.
		 */
		nodump = !nonodump && !TSTINO(ino, usedinomap);
		if ((isdir & 1) == 0 || (TSTINO(ino, dumpinomap) && !nodump))
			continue;
		dp = getino(ino, &i);
		/*
		 * inode buf may change in searchdir().
		 */
		if (sblock->fs_magic == FS_UFS1_MAGIC)
			di.dp1 = dp->dp1;
		else
			di.dp2 = dp->dp2;
		filesize = (off_t)DIP(dp, di_size);
		for (ret = 0, i = 0; filesize > 0 && i < NDADDR; i++) {
			if (DIP(&di, di_db[i]) != 0)
				ret |= searchdir(ino, DIP(&di, di_db[i]),
				    sblksize(sblock, DIP(dp, di_size), i),
				    filesize, tapesize, nodump);
			if (ret & HASDUMPEDFILE)
				filesize = 0;
			else
				filesize -= sblock->fs_bsize;
		}
		for (i = 0; filesize > 0 && i < NIADDR; i++) {
			if (DIP(&di, di_ib[i]) == 0)
				continue;
			ret |= dirindir(ino, DIP(&di, di_ib[i]), i, &filesize,
			    tapesize, nodump);
		}
		if (ret & HASDUMPEDFILE) {
			SETINO(ino, dumpinomap);
			*tapesize += blockest(dp);
			change = 1;
			continue;
		}
                if (nodump) {
                        if (ret & HASSUBDIRS)
                                change = 1;     /* subdirs inherit nodump */
                        CLRINO(ino, dumpdirmap);
                } else if ((ret & HASSUBDIRS) == 0) {
			if (!TSTINO(ino, dumpinomap)) {
				CLRINO(ino, dumpdirmap);
				change = 1;
			}
		}
	}
	return (change);
}
Пример #17
0
/*
 * Dump pass 2.
 *
 * Scan each directory on the filesystem to see if it has any modified
 * files in it. If it does, and has not already been added to the dump
 * list (because it was itself modified), then add it. If a directory
 * has not been modified itself, contains no modified files and has no
 * subdirectories, then it can be deleted from the dump list and from
 * the list of directories. By deleting it from the list of directories,
 * its parent may now qualify for the same treatment on this or a later
 * pass using this algorithm.
 */
int
mapdirs(ufs1_ino_t maxino, long *tape_size)
{
	struct	ufs1_dinode *dp;
	int isdir, nodump;
	unsigned int i;
	char *map;
	ufs1_ino_t ino;
	struct ufs1_dinode di;
	long filesize;
	int ret, change = 0;

	isdir = 0;		/* XXX just to get gcc to shut up */
	for (map = dumpdirmap, ino = 1; ino < maxino; ino++) {
		if (((ino - 1) % NBBY) == 0)	/* map is offset by 1 */
			isdir = *map++;
		else
			isdir >>= 1;
		/*
		 * If a directory has been removed from usedinomap, it
		 * either has the nodump flag set, or has inherited
		 * it.  Although a directory can't be in dumpinomap if
		 * it isn't in usedinomap, we have to go through it to
		 * propagate the nodump flag.
		 */
		nodump = !nonodump && (TSTINO(ino, usedinomap) == 0);
		if ((isdir & 1) == 0 || (TSTINO(ino, dumpinomap) && !nodump))
			continue;
		dp = getino(ino);
		di = *dp;	/* inode buf may change in searchdir(). */
		filesize = di.di_size;
		for (ret = 0, i = 0; filesize > 0 && i < NDADDR; i++) {
			if (di.di_db[i] != 0) {
				ret |= searchdir(ino, di.di_db[i],
					(long)dblksize(sblock, &di, i),
					filesize, tape_size, nodump);
			}
			if (ret & HASDUMPEDFILE)
				filesize = 0;
			else
				filesize -= sblock->fs_bsize;
		}
		for (i = 0; filesize > 0 && i < NIADDR; i++) {
			if (di.di_ib[i] == 0)
				continue;
			ret |= dirindir(ino, di.di_ib[i], i, &filesize,
			    tape_size, nodump);
		}
		if (ret & HASDUMPEDFILE) {
			SETINO(ino, dumpinomap);
			*tape_size += blockest(&di);
			change = 1;
			continue;
		}
		if (nodump) {
			if (ret & HASSUBDIRS)
				change = 1;	/* subdirs inherit nodump */
			CLRINO(ino, dumpdirmap);
		} else if ((ret & HASSUBDIRS) == 0)
			if (!TSTINO(ino, dumpinomap)) {
				CLRINO(ino, dumpdirmap);
				change = 1;
			}
	}
	return (change);
}
Пример #18
0
/*
 * For a specified manual directory, read, store and sort section subdirs.
 * For each section specified, find and search matching subdirs.
 */
static void
mandir(char **secv, char *path, char *name, int lspec)
{
	DIR	*dp;
	char	**dirv;
	char	**dv, **pdv;
	int	len, dslen;

	if ((dp = opendir(path)) == NULL)
		return;

	if (lspec)
		DPRINTF("-- Searching mandir: %s\n", path);

	sortdir(dp, &dirv);

	/* Search in the order specified by MANSECTS */
	for (; *secv; secv++) {
		len = strlen(*secv);
		for (dv = dirv; *dv; dv++) {
			dslen = strlen(*dv + 3);
			if (dslen > len)
				len = dslen;
			if (**secv == '\\') {
				if (strcmp(*secv + 1, *dv + 3) != 0)
					continue;
			} else if (strncasecmp(*secv, *dv + 3, len) != 0) {
				if (!all &&
				    (newsection = map_section(*secv, path))
				    == NULL) {
					continue;
				}
				if (newsection == NULL)
					newsection = "";
				if (strncmp(newsection, *dv + 3, len) != 0) {
					continue;
				}
			}

			if (searchdir(path, *dv, name) == 0)
				continue;

			if (!all) {
				pdv = dirv;
				while (*pdv) {
					free(*pdv);
					pdv++;
				}
				(void) closedir(dp);
				free(dirv);
				return;
			}

			if (all && **dv == 'm' && *(dv + 1) &&
			    strcmp(*(dv + 1) + 3, *dv + 3) == 0)
					dv++;
		}
	}
	pdv = dirv;
	while (*pdv != NULL) {
		free(*pdv);
		pdv++;
	}
	free(dirv);
	(void) closedir(dp);
}
Пример #19
0
main(int ac, char* av[])
{
    searchdir(av[1], ".");
}