home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / PLIST.ZIP / PLIST.C < prev    next >
C/C++ Source or Header  |  1990-05-03  |  3KB  |  129 lines

  1. /*    PLIST.C    -    Pretty List
  2.  
  3.     A quick and dirty file list generator for maxp.  It's not fancy. but
  4.     the price is right.  It works for me.  Refer to the attached .cmd file
  5.     to see how I generate the files list for my complete system.
  6.  
  7.     Do whatever you please with this file and code.  Just dont give me
  8.     credit after you break it.
  9.  
  10.     The code was written in the wee hours of the morning, so if the logic is
  11.     broken, or doesn't work for you, dont yell, just fix it.  If there is 
  12.     anything you feel the program really needs, netmail me at 153/905.
  13.  
  14.     Planned enhancements:-
  15.  
  16.         make it use area.dat instead of systemxx.bbs.
  17.  
  18.  
  19.     Gerry Rozema
  20.  
  21. */
  22.  
  23.  
  24.  
  25.  
  26.  
  27. #define INCL_BASE
  28.  
  29. #include <stdio.h>
  30. #include <stdlib.h>
  31. #include <os2.h>
  32.  
  33. struct    _sys {
  34.     int        _scaller,            /* caller number */
  35.                 _spriv;                /* minimum privilege level */
  36.     char        _smsgpath[40],    /* path for message base */
  37.                 _sbbspath[40],    /*    for .BBS files */
  38.                 _shlppath[40],    /*    for .HLP files */
  39.                 _suppath[40],        /*    for uploads */
  40.                 _sfilepath[40];    /*    for file area */
  41.     int        _sattrib;            /* attributes */
  42.     };
  43.  
  44. typedef struct _sys    VSYS;
  45.  
  46. int main(int argc, char **argv)
  47. {
  48.  
  49.     char filename[128];
  50.     char rootname[128];
  51.     char *comment;
  52.     char text[512];
  53.     FILE *thefile;
  54.     FILE *filesbbs;
  55.     VSYS sysfile;
  56.     int x,y,rc,linesize;
  57.     HDIR hdir;
  58.     FILEFINDBUF findbuf;
  59.     USHORT usCount;
  60.     int day,month,year;
  61.     int filecount;
  62.     ULONG bytecount;
  63.  
  64.     if (argc != 2) {
  65.         printf("Pretty file lister Version 0.00 for Maximus OS/2.\n");
  66.         printf("Released to the Public Domain, May 1990 by J.G. Rozema\n");
  67.         printf("useage is Plist <area #>\n");
  68.         exit(-1);
  69.     }
  70.     //  Make the filename
  71.     sprintf(filename,"system%s.bbs",argv[1]);
  72.  
  73.     if ((thefile=fopen(filename,"r"))==NULL) {
  74.         printf("Error opening %s\n",filename);
  75.         exit(-1);
  76.         }
  77.     fread(&sysfile,sizeof(VSYS),1,thefile);
  78.     fclose(thefile);
  79.  
  80.     sprintf(filename,"%sfiles.bbs",sysfile._sfilepath);
  81.     if ((filesbbs=fopen(filename,"r"))==NULL) {
  82.         printf("Error opening %s\n",filename);
  83.         exit(-1);
  84.     }
  85.     filecount=0;
  86.     bytecount=0;
  87.     while(fgets(text,500,filesbbs)!=NULL) {
  88.         linesize=0;
  89.         for (x=0; x<500; x++) {
  90.             if (text[x]!=0) linesize++;
  91.         }
  92.         for (x=0; x<linesize; x++) {
  93.             if ((text[x]==' ')||(text[x]==0x0a)||(text[x]==0x0d)) break;
  94.         }
  95.         for (y=0; y<x; y++) {
  96.             rootname[y]=text[y];
  97.         }
  98.         rootname[y]=0;
  99.         for(x=y; x<500; x++) if (text[x]!=' ') break;
  100.         comment=&text[x];
  101.         if ((y>1) && (x>1)) {
  102.             sprintf(filename,"%s%s",sysfile._sfilepath,rootname);
  103.             hdir=HDIR_SYSTEM;
  104.             usCount=1;
  105.             rc=DosFindFirst(filename,&hdir,FILE_NORMAL,&findbuf,
  106.                 sizeof(FILEFINDBUF),&usCount,0L);
  107.             if(rc==NULL) {
  108.                 filecount++;
  109.                 bytecount+=findbuf.cbFileAlloc;
  110.                 printf("%-12s ",rootname);
  111.                 printf("%6ld ",findbuf.cbFileAlloc);
  112.                 day=findbuf.fdateLastWrite.day;
  113.                 month=findbuf.fdateLastWrite.month;
  114.                 year=findbuf.fdateLastWrite.year+80;
  115.                 printf("%02d-%02d-%02d ",year,month,day);
  116.             }
  117.         }
  118.         if (linesize > 0) {
  119.             printf("%s",comment);
  120.         }
  121.         else printf("\n");
  122.     }
  123.     printf("\n");
  124.     printf("Area %s:- %d Files processed, %ld Kilobytes\n",argv[1],filecount,bytecount/1000);
  125.     printf("\n");
  126.     printf("\n");
  127.     return (0);
  128. }
  129.