home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / new / comm / bbs / eazybbs / source / eazy2mail_direct.c next >
C/C++ Source or Header  |  1994-09-08  |  2KB  |  96 lines

  1.  
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include <time.h>
  6. #include <proto/dos.h>
  7. #include <proto/exec.h>
  8.  
  9.  
  10.  
  11. #define VERSION "1.7"
  12. static char *version = "\0$VER: eazy2mail " VERSION " (" __AMIGADATE__ ")";
  13.  
  14.  
  15.  
  16. void space2under(char *s)
  17. {
  18.     while (s && *s) {
  19.         if (*s == ' ')
  20.             *s = '_';
  21.         s++;
  22.     }
  23. }
  24.  
  25.  
  26.  
  27. int main(int argc, char *argv[])
  28. {
  29.     if (argc == 6) {
  30.         char tmp[80];
  31.         FILE *fp;
  32.  
  33.         sprintf(tmp, "%s%ld", "MB_TMP:Eazy2Mail.tmp", (long) FindTask(NULL));
  34.  
  35.         if (fp = fopen(tmp, "w")) {
  36.             register int c = 0, last = 0;
  37.             time_t t;
  38.             struct tm *ut;
  39.             char uname[16];
  40.             char *sname = argv[2];
  41.             char *tonam = argv[4];
  42.             char *realn = argv[3];
  43.             char *sbjct = argv[5];
  44.             char exec[256];
  45.  
  46.             time(&t);
  47.             ut = gmtime(&t);
  48.  
  49.             strcpy(uname, argv[1]);
  50.             space2under(uname);
  51.  
  52.             fprintf(fp, "From: %s@%s (%s)\n", uname, sname, realn);
  53.             fprintf(fp, "To: %s\n", tonam);
  54.             fprintf(fp, "Sender: eazybbs@%s\n", sname);
  55.             fprintf(fp, "Subject: %s\n", sbjct);
  56.             fprintf(fp, "MIME-Version: 1.0\n");
  57.             fprintf(fp, "Content-Type: text/plain; charset=ISO-8859-1\n");
  58.             fprintf(fp, "Content-Transfer-Encoding: 8bit\n");
  59.             fprintf(fp, "\n");
  60.  
  61.             while ((c = getchar()) != EOF) {
  62.                 if (last == '\\') {
  63.                     switch (c) {
  64.                     case '\\':
  65.                         fputc(c, fp);
  66.                         break;
  67.                     default:
  68.                         break;
  69.                     }
  70.                     last = 0;
  71.                 }
  72.                 else if (c == '\\') {
  73.                     last = c;
  74.                 }
  75.                 else {
  76.                     fputc(c, fp);
  77.                     last = c;
  78.                 }
  79.             }
  80.             fprintf(fp, "\n");
  81.  
  82.             fclose(fp);
  83.  
  84.             sprintf(exec, "sendmail <%s", tmp);
  85.             System(exec, NULL);
  86.             DeleteFile(tmp);
  87.         }
  88.     }
  89.     else {
  90.         fprintf(stderr, "\033[1;33mEazyBBS\033[0m © 1988-1993 Andreas M. Kirchwitz\n"
  91.             "Usage: eazy2mail \033[3m<user> <site> <real> <to> <subject> \033[0m <text\n");
  92.     }
  93.  
  94.     exit(0);
  95. }
  96.