home *** CD-ROM | disk | FTP | other *** search
/ The Pier Shareware 6 / The_Pier_Shareware_Number_6_(The_Pier_Exchange)_(1995).iso / 024 / psi110g.zip / PUSHMAIL.C < prev    next >
C/C++ Source or Header  |  1994-04-17  |  2KB  |  55 lines

  1. /* This program allows you to push mail destined for one host
  2.  * to another (i.e. going on vacation and shutting down your
  3.  * host but want your mail delivered by your "buddy"):
  4.  */
  5. #include <dir.h>
  6. #include <dos.h>
  7. #include <fcntl.h>
  8. #include "global.h"
  9. #define MAXLINE 256
  10.   
  11. main(int argc,char *argv[])
  12. {
  13.     struct ffblk block;
  14.     int done,i;
  15.     FILE *fd,*fo;
  16.     char *j,str[MAXLINE+2],*strp;
  17.   
  18.     fprintf(stderr,"\n%s is COPYRIGHT 1989 by John D. Hays (KD7UW)\n",argv[0]);
  19.     fprintf(stderr,"Authorized for unlimited distribution for ");
  20.     fprintf(stderr,"Amateur Radio Use\n");
  21.     fprintf(stderr,"This notice must be retained.  All Rights Reserved.\n\n");
  22.     if (argc < 3)
  23.     {
  24.         fprintf(stderr,"Usage: %s oldhost forwardhost \007\n",argv[0]);
  25.         exit(0);
  26.     }
  27.   
  28.     done = findfirst("*.wrk",&block,0x3F);
  29.   
  30.     while (!done) {
  31.         if ((fd = fopen(block.ff_name,"r")) != NULL)
  32.             strp = str; /* Turbo-C is not handling fgets right ??? */
  33.         {
  34.             strp = fgets(strp,MAXLINE,fd);
  35.             j = strrchr(strp,'\n');
  36.             if (j != NULL) *j = '\0';
  37.             if (stricmp(argv[1],strp) == 0)
  38.             {
  39.                 fprintf(stderr,"Changing: %s\n",block.ff_name);
  40.                 i = unlink(block.ff_name);
  41.                 fo = fopen(block.ff_name,"w");
  42.                 fprintf(fo,"%s\n",argv[2]);
  43.                 while ((strp = fgets(strp,MAXLINE,fd)) != NULL)
  44.                 {
  45.                     fprintf(fo,"%s",strp);
  46.                 }
  47.             }
  48.             fclose(fd);
  49.             fclose(fo);
  50.         }
  51.         fprintf(stderr, "%s: Unable to open %s\n",argv[0],block.ff_name);
  52.         done = findnext(&block);
  53.     }
  54. }
  55.