home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
OS9
/
OSK
/
MISC
/
howfrag.lzh
/
HOWFRAG.C
next >
Wrap
C/C++ Source or Header
|
1991-11-09
|
942b
|
51 lines
#include <modes.h>
#include <stdio.h>
#include <strings.h>
#include <direct.h>
#include <errno.h>
main (argc,argv)
int argc;
char **argv;
{
int i,j,path,segs;
struct fildes filbuf;
if (argc <2 || (strcmp (argv[1],"-?")==0))
{
fprintf(stderr,"Syntax: %s <filename> [<filenames> ... ]\n",argv[0]);
fprintf(stderr,"Function: determine number of fragments in a file.\n");
exit(0);
}
for (i=1; i<argc; i++)
{
path=open(argv[i],S_IREAD);
if (path==-1)
{
fprintf(stderr,"%s: error opening %s\n",argv[0],argv[i]);
exit(errno);
}
if((_gs_gfd(path,&filbuf,sizeof(filbuf)))==-1)
{
fprintf(stderr,"%s: Error #%3d\n",argv[i],errno);
}
else
{
segs=0;
for (j=0; j<48; j++)
{
if (filbuf.fdseg[j].addr[0]!='\0' ||
filbuf.fdseg[j].addr[1]!='\0' ||
filbuf.fdseg[j].addr[2]!='\0')
{
segs++;
}
}
printf("%s: %d segments, 48 max\n",argv[i],segs);
}
close(path);
}
}