home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FreeWare Collection 2
/
FreeSoftwareCollection2pd199x-jp.img
/
ms_dos
/
update
/
exargs.c
next >
Wrap
Text File
|
1990-06-14
|
1KB
|
66 lines
/*
* exargs.c
* to extend wild cards in arguments
* for Turbo C
* 1988/4/10 Sey
*/
#include <dir.h>
#include <dos.h>
#define _SUBLVLMAX_ 1
#include <gosub.h>
#include <string.h>
#include <stdlib.h>
int
exargs(int argc,char *argv[],char *xargv[],int maxarg)
{
struct ffblk ffblk;
int n,done,flags;
char drive[MAXDRIVE],dir[MAXDIR],name[MAXFILE],ext[MAXEXT];
static int nx = 0;
for(n = 1 ;n < argc ;n++ )
{
jfnsplit(argv[n],drive,dir,name,ext);
if(done = findfirst(argv[n],&ffblk,0))
gosub(appendargv);
while(!done)
{
gosub(appendfound);
done = findnext(&ffblk);
}
}
return(nx);
appendfound:
{
char *p;
if( nx >= maxarg )
fatal("too many files");
if( (p = (char *)malloc(strlen(drive)+strlen(dir)+
strlen(ffblk.ff_name)+1 )) == NULL)
fatal("out of memory");
strcpy(p,drive);
strcat(p,dir);
strcat(p,ffblk.ff_name);
xargv[nx] = p;
nx++;
retsub;
}
appendargv:
{
char *p;
if( nx >= maxarg )
fatal("too many matched files");
if( (p = (char *)malloc(strlen(argv[n])+1)) == NULL)
fatal("out of memory");
strcpy(p,argv[n]);
xargv[nx] = p;
nx++;
retsub;
}
}
/* end exargs */