home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 2 BBS
/
02-BBS.zip
/
PLIST.ZIP
/
PLIST.C
< prev
next >
Wrap
C/C++ Source or Header
|
1990-05-03
|
3KB
|
129 lines
/* PLIST.C - Pretty List
A quick and dirty file list generator for maxp. It's not fancy. but
the price is right. It works for me. Refer to the attached .cmd file
to see how I generate the files list for my complete system.
Do whatever you please with this file and code. Just dont give me
credit after you break it.
The code was written in the wee hours of the morning, so if the logic is
broken, or doesn't work for you, dont yell, just fix it. If there is
anything you feel the program really needs, netmail me at 153/905.
Planned enhancements:-
make it use area.dat instead of systemxx.bbs.
Gerry Rozema
*/
#define INCL_BASE
#include <stdio.h>
#include <stdlib.h>
#include <os2.h>
struct _sys {
int _scaller, /* caller number */
_spriv; /* minimum privilege level */
char _smsgpath[40], /* path for message base */
_sbbspath[40], /* for .BBS files */
_shlppath[40], /* for .HLP files */
_suppath[40], /* for uploads */
_sfilepath[40]; /* for file area */
int _sattrib; /* attributes */
};
typedef struct _sys VSYS;
int main(int argc, char **argv)
{
char filename[128];
char rootname[128];
char *comment;
char text[512];
FILE *thefile;
FILE *filesbbs;
VSYS sysfile;
int x,y,rc,linesize;
HDIR hdir;
FILEFINDBUF findbuf;
USHORT usCount;
int day,month,year;
int filecount;
ULONG bytecount;
if (argc != 2) {
printf("Pretty file lister Version 0.00 for Maximus OS/2.\n");
printf("Released to the Public Domain, May 1990 by J.G. Rozema\n");
printf("useage is Plist <area #>\n");
exit(-1);
}
// Make the filename
sprintf(filename,"system%s.bbs",argv[1]);
if ((thefile=fopen(filename,"r"))==NULL) {
printf("Error opening %s\n",filename);
exit(-1);
}
fread(&sysfile,sizeof(VSYS),1,thefile);
fclose(thefile);
sprintf(filename,"%sfiles.bbs",sysfile._sfilepath);
if ((filesbbs=fopen(filename,"r"))==NULL) {
printf("Error opening %s\n",filename);
exit(-1);
}
filecount=0;
bytecount=0;
while(fgets(text,500,filesbbs)!=NULL) {
linesize=0;
for (x=0; x<500; x++) {
if (text[x]!=0) linesize++;
}
for (x=0; x<linesize; x++) {
if ((text[x]==' ')||(text[x]==0x0a)||(text[x]==0x0d)) break;
}
for (y=0; y<x; y++) {
rootname[y]=text[y];
}
rootname[y]=0;
for(x=y; x<500; x++) if (text[x]!=' ') break;
comment=&text[x];
if ((y>1) && (x>1)) {
sprintf(filename,"%s%s",sysfile._sfilepath,rootname);
hdir=HDIR_SYSTEM;
usCount=1;
rc=DosFindFirst(filename,&hdir,FILE_NORMAL,&findbuf,
sizeof(FILEFINDBUF),&usCount,0L);
if(rc==NULL) {
filecount++;
bytecount+=findbuf.cbFileAlloc;
printf("%-12s ",rootname);
printf("%6ld ",findbuf.cbFileAlloc);
day=findbuf.fdateLastWrite.day;
month=findbuf.fdateLastWrite.month;
year=findbuf.fdateLastWrite.year+80;
printf("%02d-%02d-%02d ",year,month,day);
}
}
if (linesize > 0) {
printf("%s",comment);
}
else printf("\n");
}
printf("\n");
printf("Area %s:- %d Files processed, %ld Kilobytes\n",argv[1],filecount,bytecount/1000);
printf("\n");
printf("\n");
return (0);
}