home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / gigop806.zip / GUUQ.CPP < prev    next >
Text File  |  1994-08-04  |  4KB  |  141 lines

  1.  
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include <ctype.h>
  6. #include <stdio.h>
  7. #include <dos.h>
  8. #include <direct.h>
  9. #include <share.h>
  10. #include <sys\types.h>
  11. #include <sys\stat.h>
  12.  
  13. int incoming=0;
  14. char sys[256]="";
  15. char ourname[256]="";
  16.  
  17.  
  18.  
  19. char           *waffle_munger(char *str, char *sys, char *ourname);
  20.  
  21. void checkcline(char *filename,char *cline)
  22. {
  23.  char tempname[256];
  24.  char namehere[256];
  25.  struct stat buf;
  26.  
  27.  if (!*filename)
  28.    return;
  29.  strcpy(tempname,filename);
  30.  strcpy(namehere,waffle_munger(tempname,sys,ourname));
  31.  if (!incoming) strcat(namehere,"at");
  32.  
  33.  printf("%-12s ",namehere);
  34.  if (stat(namehere,&buf)!=-1) 
  35.     printf("%7lu %s\n",buf.st_size,cline);
  36.   else 
  37.     printf("Error finding file (either missing or settings are wrong)\n");
  38. }
  39.  
  40. void process(char *s)
  41. {
  42.  FILE *file;
  43.  static char  line[256];
  44.  static char  cline[256]="";
  45.  static char  iline[256]="";
  46.  static char  fline[256]="";
  47.  
  48.  char *command,*parms;
  49.  int err=0;
  50.  
  51.  
  52.  file=_fsopen(s,"rt",SH_DENYRW);
  53.  if (!file) return;
  54.  while(!feof(file))
  55.   {
  56.     line[0]=0;
  57.     fgets(line,sizeof(line),file);
  58.     if (!line[0]) continue;
  59.     if (line[0]=='\n') continue;
  60.  
  61.     command=strtok(line," \n");
  62.     parms=strtok(NULL,"\n"); // remaineder
  63.  
  64.     switch(*command) {
  65.     case 'C' : if (parms) strcpy(cline,parms); break;
  66.     case 'I' : if (parms) strcpy(iline,parms); break;
  67.     case 'F' : if (parms) strcpy(fline,parms); break;
  68.     }
  69.   }
  70.  fclose(file);
  71.  
  72.  if (cline[0])
  73.    checkcline(iline[0]?iline:fline,cline);
  74.  
  75. }
  76.  
  77.  
  78. void showhelp(void)
  79. {
  80.  printf("Usage:   GUUQ [in/out] remotename ourname\n"
  81.         "         where remotename and ourname are the uucp names used for spooling\n");
  82.  if (getenv("MYSITE")) if (getenv("MYFEED")) exit(0);
  83.  
  84.  printf("\nYou may also set the following in your environment settings..\n");
  85.  if (!getenv("MYSITE"))
  86.    printf("SET MYSITE=wmeonlin  (subsitute YOUR site's UUCP name from your gateway configs\n");
  87.  if (!getenv("MYFEED"))
  88.    printf("SET MYFEED=hostname  (subsitute your FEED'S UUCP name from your gateway configs\n");
  89.  exit(0);
  90. }
  91.  
  92. int main(int argc, char *argv[])
  93. {
  94.  char *p;
  95.  sys[0]=0;
  96.  ourname[0]=0;
  97.  DIR *dirp;
  98.  struct dirent *direntp;
  99.  
  100.  if ((p=getenv("MYSITE"))!=NULL) strcpy(ourname,p);
  101.  if ((p=getenv("MYFEED"))!=NULL) strcpy(sys,p);
  102.  
  103.  if (argc>1)
  104.   {
  105.    if (stricmp(argv[1],"in")==NULL) incoming=1;
  106.    else if (stricmp(argv[1],"out")==NULL) incoming=0;
  107.    else showhelp();
  108.    }
  109.     else incoming=0;
  110.  
  111.  if (argc>2) strcpy(sys,argv[2]);
  112.  if (argc>3) strcpy(ourname,argv[3]);
  113.  
  114.  if (!ourname[0]) showhelp();
  115.  if (!sys[0]) showhelp();
  116.    fprintf(stderr,"GUUQ Copyright 1994 by Jason Fesler.  All rights reserved.\n");
  117.  
  118.       if (incoming) {
  119.          printf("Data File       Size Command                           *.X    (Inbound)\n");
  120.          printf("---------------+----+--------------------------------------------------\n");
  121.          dirp = opendir("*.X");
  122.       } else {
  123.          printf("Data File       Size Command                           *.XQT  (Outbound)\n");
  124.          printf("---------------+----+---------------------------------------------------\n");
  125.          dirp = opendir("*.XQT");
  126.       } /* endif */
  127.  
  128.       if (dirp == NULL) {
  129.          } else {
  130.           for (;;) {
  131.           direntp = readdir(dirp);
  132.           if (direntp==NULL) break;
  133.           process(direntp->d_name);
  134.          }
  135.         closedir(dirp);
  136.       } /* endif incoming */
  137.    return 0;
  138. }
  139.  
  140.  
  141.