home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 2 / goldfish_vol2_cd1.bin / files / comm / mail / smail / src / rcs / mail.c,v < prev    next >
Text File  |  1993-12-21  |  19KB  |  1,011 lines

  1. head    1.13;
  2. access;
  3. symbols
  4.     C_1:1.13;
  5. locks; strict;
  6. comment    @ * @;
  7.  
  8.  
  9. 1.13
  10. date    93.11.06.16.00.10;    author Aussem;    state Exp;
  11. branches;
  12. next    1.12;
  13.  
  14. 1.12
  15. date    93.11.02.20.12.42;    author Aussem;    state Exp;
  16. branches;
  17. next    1.11;
  18.  
  19. 1.11
  20. date    93.10.31.20.10.53;    author Aussem;    state Exp;
  21. branches;
  22. next    1.10;
  23.  
  24. 1.10
  25. date    93.10.23.21.22.49;    author Aussem;    state Exp;
  26. branches;
  27. next    1.9;
  28.  
  29. 1.9
  30. date    93.10.21.21.17.05;    author Aussem;    state Exp;
  31. branches;
  32. next    1.8;
  33.  
  34. 1.8
  35. date    93.10.16.14.54.51;    author Aussem;    state Exp;
  36. branches;
  37. next    1.7;
  38.  
  39. 1.7
  40. date    93.10.13.21.41.42;    author Aussem;    state Exp;
  41. branches;
  42. next    1.6;
  43.  
  44. 1.6
  45. date    93.10.02.00.14.38;    author Aussem;    state Exp;
  46. branches;
  47. next    1.5;
  48.  
  49. 1.5
  50. date    93.09.30.22.21.34;    author Aussem;    state Exp;
  51. branches;
  52. next    1.4;
  53.  
  54. 1.4
  55. date    93.09.30.21.07.03;    author Aussem;    state Exp;
  56. branches;
  57. next    1.3;
  58.  
  59. 1.3
  60. date    93.09.23.22.44.57;    author Aussem;    state Exp;
  61. branches;
  62. next    1.2;
  63.  
  64. 1.2
  65. date    93.09.18.16.47.47;    author Aussem;    state Exp;
  66. branches;
  67. next    1.1;
  68.  
  69. 1.1
  70. date    93.09.11.15.01.16;    author Aussem;    state Exp;
  71. branches;
  72. next    ;
  73.  
  74.  
  75. desc
  76. @Local mailer for smail
  77. @
  78.  
  79.  
  80. 1.13
  81. log
  82. @mail now don't stop at once if the delivering fails
  83. @
  84. text
  85. @/*
  86.  * emulation of the unix mail command
  87.  * Just append it to the mail-folder
  88.  *
  89.  *
  90.  * This program is free software; you can redistribute it and/or
  91.  * modify it under the terms of the GNU General Public License as
  92.  * published by the Free Software Foundation; either version 2 of
  93.  * the License, or (at your option) any later version.
  94.  *
  95.  * This program is distributed in the hope that it will be useful,
  96.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  97.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  98.  * General Public License for more details.
  99.  *
  100.  * You should have received a copy of the GNU General Public License
  101.  * along with this program; if not, write to the Free Software
  102.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  103.  *
  104.  * $Log: mail.c,v $
  105.  * Revision 1.12  1993/11/02  20:12:42  Aussem
  106.  * MUFS routines insert
  107.  *
  108.  * Revision 1.11  1993/10/31  20:10:53  Aussem
  109.  * submitt a bigger stack
  110.  *
  111.  * Revision 1.10  1993/10/23  21:22:49  Aussem
  112.  * mail now uses the mail folder directly (uumail:user)
  113.  *
  114.  * Revision 1.9  1993/10/21  21:17:05  Aussem
  115.  * MailReadyCmd will be started via run <nil: >nil:
  116.  * only if t:mailrdy does not exists
  117.  * if the mail folder is locked, mail will be wait until
  118.  * the mail folder is unlocked
  119.  *
  120.  * Revision 1.8  1993/10/16  14:54:51  Aussem
  121.  * cosmetic changes
  122.  *
  123.  * Revision 1.7  1993/10/13  21:41:42  Aussem
  124.  * mail supports now more than one address for each
  125.  * invocation. This is needed for Maxrmaillength!=0 !
  126.  *
  127.  * Revision 1.6  1993/10/02  00:14:38  Aussem
  128.  * MailReadyCmd keyword in uulib:condif is supported by mail and mail_axsh
  129.  *
  130.  * Revision 1.5  1993/09/30  22:21:34  Aussem
  131.  * if env:MAILTONOEXIST mail will deliver a mail although the user does not
  132.  * exists on the site.
  133.  *
  134.  * Revision 1.4  1993/09/30  21:07:03  Aussem
  135.  * mail wait now 6 minutes to open uumail:<mail-folder>
  136.  *
  137.  * Revision 1.3  1993/09/23  22:44:57  Aussem
  138.  * removes uumail:<file>.o before backup uumail:<file>
  139.  *
  140.  * Revision 1.2  1993/09/18  16:47:47  Aussem
  141.  * put the "normal" and axsh version in this file (set define AXSH
  142.  * for the AXSh Version)
  143.  *
  144.  * Revision 1.1  1993/09/11  15:01:16  Aussem
  145.  * Initial revision
  146.  *
  147.  *
  148.  */
  149.  
  150. static char     *rcsid="$Id: mail.c,v 1.12 1993/11/02 20:12:42 Aussem Exp Aussem $";
  151.  
  152. #include <stdio.h>
  153. #include <string.h>
  154. #include <stdlib.h>
  155. #include <dos.h>
  156. #include <proto/dos.h>
  157. #include <pragmas/dos_pragmas.h>
  158. #include <proto/exec.h>
  159. #include <pragmas/exec_pragmas.h>
  160.  
  161. #ifdef AXSH
  162. #include "axsh/iomodes.h"
  163. #include "axsh/misc.h"
  164. #include "axsh/users.h"
  165. static struct User usr;
  166. #endif
  167.  
  168.  
  169. extern struct DosLibrary *DOSBase;
  170.  
  171. /* should be large enough */
  172. long __stack=20000L;
  173.  
  174. /* global Vars for this modul */
  175. static const char *uumail = "UUMAIL:";
  176. static const char *version = "$VER: mail V1.4 © 1993 by Ralph-Thomas Aussem ("__DATE__","__TIME__")";
  177. static const int maxretry = 30;
  178. static const int retrysecs = 20;
  179. static char *argv0 = "mail";
  180.  
  181. /* prototypes */
  182. static char *readfile (char *);
  183. static long filelength (char *);
  184. static void sleep (unsigned long time);
  185. char * findconfig(char *);
  186.  
  187. #ifdef AXSH
  188. int
  189. getuid (char *name)
  190. {
  191.   if (search_userdata ("AXsh:etc/passwd", &usr, 0, name) == -1)        /* if user not found */
  192.         return(0);
  193. return(1);
  194. }
  195. #endif
  196.  
  197. #ifdef MUFS
  198. #include <proto/multiuser.h>
  199. #include <pragmas/multiuser_pragmas.h>
  200. #include <libraries/multiuser.h>
  201.  
  202. struct muBase *muBase=NULL;
  203. struct muUserInfo *ui=NULL;
  204.  
  205. int setup_mufs(void);
  206. void kill_mufs(void);
  207.  
  208. int getuid(char *name)
  209. {
  210. if(!setup_mufs())
  211.     return(0);
  212.  
  213. strcpy(ui->UserID,name);
  214. if(muGetUserInfo(ui,muKeyType_UserID)==NULL)
  215.     {
  216.     return(0);
  217.     }
  218. return(1);
  219. }
  220.  
  221. int setup_mufs(void)
  222. {
  223. if(!muBase)
  224.     {
  225.     muBase=(struct muBase *)OpenLibrary(MULTIUSERNAME,MULTIUSERVERSION);
  226.     if(!muBase)
  227.         {
  228. #ifdef DEBUG
  229.         printf("%s: unable to open %s Version >= %d\n",argv0,MULTIUSERNAME,MULTIUSERVERSION);
  230. #endif
  231.         return(0);
  232.        }
  233.    }
  234.  
  235. if(!ui)
  236.     {
  237.     ui=muAllocUserInfo();
  238.     if(!ui)
  239.         {
  240.         kill_mufs();
  241. #ifdef DEBUG
  242.         printf("%s: unable to alloc mem\n");
  243. #endif
  244.         return(NULL);
  245.         }
  246.     }
  247. return(1);
  248. }
  249.  
  250. void kill_mufs(void)
  251. {
  252. if(ui)
  253.     muFreeUserInfo(ui);
  254. if(muBase)
  255.     CloseLibrary((struct Library *)muBase);
  256. }
  257. #endif /* MUFS */
  258.  
  259. /*
  260.  * sleep():
  261.  * wait <time> seconds
  262.  */
  263. static void
  264. sleep (unsigned long time)
  265. {
  266.   Delay (50L * time);
  267. }
  268.  
  269. /*
  270.  * filelength():
  271.  * returns the length of file <fname>
  272.  * it returns -1 if the file does not exists or locked 
  273.  * by someone else
  274.  */
  275. static
  276. long
  277. filelength (char *fname)
  278. {
  279.   struct FileInfoBlock __aligned fileinfo;
  280.   long groesse;
  281.   BPTR fp;
  282.  
  283.   fp=Open(fname,MODE_OLDFILE);
  284.   if(!fp)
  285.       {
  286.       LONG error=IoErr();
  287.  
  288.    if(error == ERROR_OBJECT_IN_USE)
  289.        return(-2);
  290.    if(error == ERROR_OBJECT_NOT_FOUND)
  291.        return(-1);
  292.    }
  293.   ExamineFH (fp, &fileinfo);
  294.   groesse = (long) fileinfo.fib_Size;
  295.   Close (fp);
  296.   return (groesse);
  297. }
  298.  
  299. long getpid(void)
  300. {
  301. struct Process *proc;
  302.  
  303. Forbid();
  304. proc=(struct Process *)FindTask(NULL);
  305. Permit();
  306. if(proc)return(proc->pr_TaskNum);
  307. return(0);
  308. }
  309.  
  310. int lock_with_file(char *lockfilename)
  311. {
  312.     FILE *file;
  313.     char buf[BUFSIZ];
  314.  
  315.     while( ( file = fopen( lockfilename, "r" ) ) != NULL )
  316.     {
  317.         fgets( buf, sizeof(buf), file );
  318.         fclose( file );
  319. #ifdef DEBUG
  320.         printf( "Mail locked by proc '%s'. Waiting 10 secs\n", buf);
  321. #endif
  322.         sleep( 10 );
  323.     }
  324.  
  325. #ifdef DEBUG
  326.     printf("locking Mail.\n");
  327. #endif
  328.     if( ( file = fopen( lockfilename, "w" ) ) == NULL ) return -1;
  329.     fprintf( file, "%d\n", getpid() );
  330.     fclose( file );
  331.     return 0;
  332. }
  333.  
  334. int unlock_with_file( char *lockfilename )
  335. {
  336. #ifdef DEBUG
  337.     printf("unlock Mail.\n");
  338. #endif
  339.     return remove( lockfilename );
  340. }
  341.  
  342. /*
  343.  * readfile():
  344.  * read file <filename> and returns the buffer
  345.  *
  346.  */
  347. static
  348. char *
  349. readfile (char *filename)
  350. {
  351.   char *puf;
  352.   size_t len, read;
  353.   FILE *fp;
  354.  
  355. #ifdef DEBUG
  356.     printf("Reading %s.\n",filename);
  357. #endif
  358.  
  359.   if (!filename)
  360.     return (NULL);
  361.  
  362.   len = filelength (filename);
  363.   if (len < 1)
  364.     {
  365.       printf ("\n%s: unable to open file %s", argv0, filename);
  366.       return (NULL);
  367.     }
  368.  
  369.   puf = malloc ((len + 1) * sizeof (char));
  370.   if (!puf)
  371.     {
  372.       printf ("\n%s: unable to allocate %d Bytes", argv0, (len + 1) * sizeof (char));
  373.       free (puf);
  374.       return (NULL);
  375.     }
  376.  
  377.   fp = fopen (filename, "r");
  378.   if (!fp)
  379.     {
  380.       printf ("\n%s: unable to open file %s", argv0, filename);
  381.       free (puf);
  382.       return (NULL);
  383.     }
  384.  
  385.   read = fread (puf, len, 1, fp) * len;
  386.   if (read != len)
  387.     {
  388.       printf ("\n%s: unable to read from %s %d (%d) bytes", argv0, filename, len, read);
  389.       free (puf);
  390.       fclose (fp);
  391.       return (NULL);
  392.     }
  393.   puf[len]='\0';
  394.   fclose (fp);
  395.   return (puf);
  396. }
  397.  
  398. #define CTLZ    ('z'&0x1F)
  399. static char *ConfBuf = NULL;
  400.  
  401. char *
  402. findconfig(field)
  403. char *field;
  404. {
  405.     char *str;
  406.     short flen = strlen(field);
  407.  
  408.     /*
  409.      *    load config file if not already loaded
  410.      */
  411.  
  412.     if (ConfBuf == NULL) {
  413.     FILE *fi;
  414.     fi = fopen("S:UUConfig", "r");
  415.     if (fi == NULL)
  416.         fi = fopen("UULIB:Config", "r");
  417.     if (fi) {
  418.         long buflen;
  419.         fseek(fi, 0L, 2);
  420.         buflen = ftell(fi);
  421.         fseek(fi, 0L, 0);
  422.         if (buflen > 0 && (ConfBuf = malloc(buflen + 1))) {
  423.         fread(ConfBuf, buflen, 1, fi);
  424.         ConfBuf[buflen] = CTLZ;     /*    can't use \0 */
  425.         for (str = ConfBuf; *str && *str != CTLZ; ++str) {
  426.             char *bup;
  427.             if (*str == '\n') {     /*  make separate strs */
  428.             *str = 0;
  429.                         /*    remove white space at end */
  430.             for (bup = str - 1; bup >= ConfBuf && (*bup == ' ' || *bup == 9); --bup)
  431.                 *bup = 0;
  432.             }
  433.         }
  434.         } else {
  435.         ConfBuf = NULL;
  436.         }
  437.         fclose(fi);
  438.     }
  439.     }
  440.     if (ConfBuf == NULL)
  441.     return(NULL);
  442.  
  443.     /*
  444.      *    Search ConfBuf for Field<space/tab>
  445.      */
  446.  
  447.     for (str = ConfBuf; *str != CTLZ; str += strlen(str) + 1) {
  448.     if (*str == 0 || *str == '#')
  449.         continue;
  450.     if (strnicmp(str, field, flen) == 0 && (str[flen] == ' ' || str[flen] == '\t')) {
  451.         str += flen;
  452.         while (*str == ' ' || *str == 9)
  453.         ++str;
  454.         return(str);
  455.     }
  456.     }
  457.     return(NULL);
  458. }
  459.  
  460. /*
  461.  * MAIN
  462.  */
  463. int
  464. main (int argc, char *argv[])
  465. {
  466.   FILE *fp;
  467.   char file[128],lockfile[128], puf[128], *text, *cmd,*address;
  468.   long len;
  469.   int retry,i,fail=0;
  470.  
  471.   argv0 = argv[0];
  472.  
  473.   if (argc < 3)
  474.     {
  475.       printf ("usage %s mail-file address0 .. addressn\n", argv0);
  476.       exit (10);
  477.     }
  478.  
  479.   text = readfile (argv[1]);
  480.   if (!text)
  481.       {
  482.       /* error messages are generated by readfile() */
  483.       remove (file);
  484.         unlock_with_file(lockfile);
  485.       exit (10);
  486.       }
  487.  
  488.  
  489.   for(i=2;i<argc;i++)
  490.   {
  491.   address=argv[i];
  492.   retry=0;
  493.   printf("sending mail to '%s'...",address);
  494.  
  495.   strcpy (file, uumail);
  496.   strcat (file, address);
  497.   len=filelength(file);
  498.  
  499.   while(len==-2)
  500.     {
  501.        len=filelength(file);
  502.       retry++;
  503.       printf ("\n%s: unable to open %s (%d retries done), waiting %d secs", argv0, file, retry-1,retrysecs);
  504.       sleep (retrysecs);
  505.    }
  506.  
  507. #if defined(AXSH) || defined(MUFS)
  508.   if(!getuid(address))
  509.     {
  510.       if(getenv("MAILTONOEXIST")==NULL)
  511.           {
  512.           printf (" No user '%s' exists\n",address);
  513.           fail=1;
  514.          continue;
  515.           }
  516.     }
  517.  
  518. #else
  519.   if(len==-1)
  520.     {
  521.       if(getenv("MAILTONOEXIST")==NULL)
  522.           {
  523.           printf (" No mail-folder for user '%s'\n",address);
  524.           fail=1;
  525.          continue;
  526.           }
  527.     }
  528. #endif
  529.  
  530.   strcpy (lockfile, "T:");
  531.   strcat (lockfile, address);
  532.   strcat (lockfile,".lck");
  533.   lock_with_file(lockfile);
  534.  
  535.   fp = fopen (file, "a");
  536.   if (!fp)
  537.     {
  538.       printf ("\n%s: Unable to open the backup mail-folder for %s (%s)", argv0, address, file);
  539.       remove (file);
  540.         unlock_with_file(lockfile);
  541.       exit (10);
  542.     }
  543.  
  544.   len = strlen (text);
  545.   if ((fwrite (text, len, 1, fp) * len) != len)
  546.     {
  547.       printf ("\n%s: Error appending mail to mail-folder %s", argv0, file);
  548.       fclose (fp);
  549.       remove (file);
  550.         unlock_with_file(lockfile);
  551.       exit (10);
  552.     }
  553.  
  554.   fclose (fp);
  555.   unlock_with_file(lockfile);
  556.  
  557.   cmd=findconfig("MailReadyCmd");
  558.   if(cmd)
  559.       {
  560.       if(filelength("T:MailRdy")==-1)
  561.           {
  562.             strcpy(puf,"echo >T:MailRdy");
  563.             system(puf);
  564.             strcpy(puf,"run <nil: >nil: ");
  565.               strcat(puf,cmd);
  566.               system(puf);
  567.        }
  568.       }
  569.   putchar('\n');
  570.   }
  571.  
  572.   if(text)
  573.       free (text);
  574. #ifdef MUFS
  575.   kill_mufs();
  576. #endif
  577.   if(fail)
  578.       exit (5);
  579.   exit(0);
  580. }
  581. @
  582.  
  583.  
  584. 1.12
  585. log
  586. @MUFS routines insert
  587. @
  588. text
  589. @d21 3
  590. d66 1
  591. a66 1
  592. static char     *rcsid="$Id: mail.c,v 1.11 1993/10/31 20:10:53 Aussem Exp Aussem $";
  593. d385 1
  594. a385 1
  595.   int retry,i;
  596. d429 2
  597. a430 1
  598.           exit (20);
  599. d440 2
  600. a441 1
  601.           exit (20);
  602. d493 3
  603. a495 1
  604.   exit (0);
  605. @
  606.  
  607.  
  608. 1.11
  609. log
  610. @submitt a bigger stack
  611. @
  612. text
  613. @d21 3
  614. d63 1
  615. a63 1
  616. static char     *rcsid="$Id: mail.c,v 1.10 1993/10/23 21:22:49 Aussem Exp Aussem $";
  617. d110 62
  618. d420 1
  619. a420 1
  620. #ifdef AXSH
  621. d485 3
  622. @
  623.  
  624.  
  625. 1.10
  626. log
  627. @mail now uses the mail folder directly (uumail:user)
  628. @
  629. text
  630. @d21 3
  631. d60 1
  632. a60 1
  633. static char     *rcsid="$Id: mail.c,v 1.9 1993/10/21 21:17:05 Aussem Exp Aussem $";
  634. d81 3
  635. d86 1
  636. a86 1
  637. static const char *version = "$VER: mail V1.3 © 1993 by Ralph-Thomas Aussem ("__DATE__","__TIME__")";
  638. @
  639.  
  640.  
  641. 1.9
  642. log
  643. @MailReadyCmd will be started via run <nil: >nil:
  644. only if t:mailrdy does not exists
  645. if the mail folder is locked, mail will be wait until
  646. the mail folder is unlocked
  647. @
  648. text
  649. @d21 6
  650. d57 1
  651. a57 1
  652. static char     *rcsid="$Id: mail.c,v 1.8 1993/10/16 14:54:51 Aussem Exp Aussem $";
  653. d311 1
  654. a311 1
  655.   int rc, retry,i;
  656. a374 23
  657.  
  658.   /* remove uumail:<file>.o */
  659.   strcpy (puf, file);
  660.   strcat (puf, ".o");
  661.   remove(puf);
  662.  
  663.   if(len>0)
  664.       {
  665.       strcpy (puf, "copy ");
  666.       strcat (puf, file);
  667.       strcat (puf, " to ");
  668.       strcat (puf, file);
  669.       strcat (puf, ".o");
  670.       rc = system (puf);
  671.       if (rc)
  672.         {
  673.           printf ("\n%s: Unable to create backup file (%s)", argv0, puf);
  674.             unlock_with_file(lockfile);
  675.           exit (10);
  676.         }
  677.    }
  678.   strcat (file, ".o");
  679.  
  680. d393 1
  681. a394 18
  682.  
  683.   strcpy (puf, "copy ");
  684.   strcat (puf, file);
  685.   strcat (puf, " to ");
  686.   strcat (puf, file);
  687.   len = strlen (puf);
  688.   if (len >= 2)
  689.     puf[len - 2] = '\0';
  690.   rc = system (puf);
  691.   if (rc)
  692.     {
  693.       printf ("\n%s: Unable to rename backup file (%s)", argv0, puf);
  694.       remove (file);
  695.         unlock_with_file(lockfile);
  696.       exit (10);
  697.     }
  698.  
  699.   remove (file);
  700. d409 1
  701. a409 1
  702.   putc('\n',fp);
  703. @
  704.  
  705.  
  706. 1.8
  707. log
  708. @cosmetic changes
  709. @
  710. text
  711. @d21 3
  712. d51 1
  713. a51 1
  714. static char     *rcsid="$Id: mail.c,v 1.7 1993/10/13 21:41:42 Aussem Exp Aussem $";
  715. d74 1
  716. a74 1
  717. static const char *version = "$VER: mail V1.2 © 1993 by Ralph-Thomas Aussem ("__DATE__","__TIME__")";
  718. a115 1
  719.   struct FileLock *lock;
  720. d117 6
  721. d124 6
  722. a129 3
  723.   if (!(lock = (struct FileLock *) Lock (fname, ACCESS_READ)))
  724.     return (-1);
  725.   Examine ((BPTR) lock, &fileinfo);
  726. d131 1
  727. a131 1
  728.   UnLock ((BPTR) lock);
  729. d201 1
  730. a201 1
  731.       printf ("%s: unable to open file %s\n", argv0, filename);
  732. d208 1
  733. a208 1
  734.       printf ("%s: unable to allocate %d Bytes\n", argv0, (len + 1) * sizeof (char));
  735. d216 1
  736. a216 1
  737.       printf ("%s: unable to open file %s\n", argv0, filename);
  738. d224 1
  739. a224 1
  740.       printf ("%s: unable to read from %s %d (%d) bytes\n", argv0, filename, len, read);
  741. d315 10
  742. a330 5
  743.   strcpy (lockfile, "T:");
  744.   strcat (lockfile, address);
  745.   strcat (lockfile,".lck");
  746.   lock_with_file(lockfile);
  747.  
  748. d333 1
  749. d335 7
  750. a341 1
  751.   len=filelength(file);
  752. a348 1
  753.             unlock_with_file(lockfile);
  754. a358 1
  755.             unlock_with_file(lockfile);
  756. d363 7
  757. a376 1
  758.  
  759. d385 1
  760. a385 1
  761.           printf ("%s: Unable to create backup file (%s)\n", argv0, puf);
  762. d392 1
  763. a392 20
  764.   text = readfile (argv[1]);
  765.   if (!text)
  766.     {
  767.       /* error messages are generated by readfile() */
  768.       remove (file);
  769.         unlock_with_file(lockfile);
  770.       exit (10);
  771.     }
  772.  
  773.   do
  774.     {
  775.       retry++;
  776.       fp = fopen (file, "a");
  777.       if (fp)
  778.             break;
  779.       printf ("%s: unable to open %s, waiting %d secs\n", argv0, file, retrysecs);
  780.       sleep (retrysecs);
  781.     }
  782.   while (retry < maxretry);
  783.  
  784. d395 1
  785. a395 1
  786.       printf ("%s: Unable to open the backup mail-folder for %s (%s)\n", argv0, address, file);
  787. a396 2
  788.       if (text)
  789.             free (text);
  790. d404 1
  791. a404 1
  792.       printf ("%s: Error appending mail to mail-folder %s\n", argv0, file);
  793. a405 2
  794.       if (text)
  795.             free (text);
  796. a410 2
  797.   if (text)
  798.     free (text);
  799. d422 1
  800. a422 1
  801.       printf ("%s: Unable to rename backup file (%s)\n", argv0, puf);
  802. d430 1
  803. d433 11
  804. a443 1
  805.       system(cmd);
  806. d445 3
  807. @
  808.  
  809.  
  810. 1.7
  811. log
  812. @mail supports now more than one address for each
  813. invocation. This is needed for Maxrmaillength!=0 !
  814. @
  815. text
  816. @d21 4
  817. d48 1
  818. a48 1
  819. static char     *rcsid="$Id: mail.c,v 1.6 1993/10/02 00:14:38 Aussem Exp Aussem $";
  820. d71 1
  821. a71 1
  822. static const char *version = "$VER: mail V1.1 © 1993 by Ralph-Thomas Aussem ("__DATE__","__TIME__")";
  823. d368 1
  824. d379 1
  825. a379 1
  826.     break;
  827. @
  828.  
  829.  
  830. 1.6
  831. log
  832. @MailReadyCmd keyword in uulib:condif is supported by mail and mail_axsh
  833. @
  834. text
  835. @d21 3
  836. d44 1
  837. a44 1
  838. static char     *rcsid="$Id: mail.c,v 1.5 1993/09/30 22:21:34 Aussem Exp Aussem $";
  839. d288 1
  840. a288 1
  841.   char file[128],lockfile[128]="T:", puf[128], *text, *cmd;
  842. d290 1
  843. a290 1
  844.   int rc, retry = 0;
  845. d294 1
  846. a294 1
  847.   if (argc == 4)
  848. d296 1
  849. a296 1
  850.       printf ("%s: only mail to local host possible\nPlease use your sendmail program !\n", argv0);
  851. d299 6
  852. a304 5
  853.   if (argc != 3)
  854.     {
  855.       printf ("usage %s mail-file address\n", argv0);
  856.       exit (10);
  857.     }
  858. d306 2
  859. a307 1
  860.   strcat (lockfile, argv[2]);
  861. d312 1
  862. a312 1
  863.   strcat (file, argv[2]);
  864. d317 1
  865. a317 1
  866.   if(!getuid(argv[2]))
  867. d321 1
  868. a321 1
  869.           printf (" No user '%s' exists\n",argv[2]);
  870. d332 1
  871. a332 1
  872.           printf (" No mail-folder for user '%s'\n",argv[2]);
  873. d382 1
  874. a382 1
  875.       printf ("%s: Unable to open the backup mail-folder for %s (%s)\n", argv0, argv[2], file);
  876. d426 1
  877. @
  878.  
  879.  
  880. 1.5
  881. log
  882. @if env:MAILTONOEXIST mail will deliver a mail although the user does not
  883. exists on the site.
  884. @
  885. text
  886. @d21 4
  887. d41 1
  888. a41 1
  889. static char     *rcsid="$Id: mail.c,v 1.4 1993/09/30 21:07:03 Aussem Exp Aussem $";
  890. d73 1
  891. d216 62
  892. d285 1
  893. a285 1
  894.   char file[128],lockfile[128]="T:", puf[128], *text;
  895. d418 3
  896. @
  897.  
  898.  
  899. 1.4
  900. log
  901. @mail wait now 6 minutes to open uumail:<mail-folder>
  902. @
  903. text
  904. @d21 3
  905. d37 1
  906. a37 1
  907. static char     *rcsid="$Id: mail.c,v 1.3 1993/09/23 22:44:57 Aussem Exp Aussem $";
  908. d247 6
  909. a252 3
  910.       printf (" No user '%s' exists\n",argv[2]);
  911.         unlock_with_file(lockfile);
  912.       exit (20);
  913. d258 6
  914. a263 3
  915.       printf (" No mail-folder for user '%s'\n",argv[2]);
  916.         unlock_with_file(lockfile);
  917.       exit (20);
  918. @
  919.  
  920.  
  921. 1.3
  922. log
  923. @removes uumail:<file>.o before backup uumail:<file>
  924. @
  925. text
  926. @d21 3
  927. d34 1
  928. a34 1
  929. static char     *rcsid="$Id: mail.c,v 1.2 1993/09/18 16:47:47 Aussem Exp Aussem $";
  930. d57 3
  931. a59 2
  932. static const char *version = "$VER: mail V1.0 © 1993 by Ralph-Thomas Aussem ("__DATE__","__TIME__")";
  933. static const int maxretry = 10;
  934. d294 2
  935. a295 2
  936.       printf ("%s: unable to open %s, waiting %d secs\n", argv0, file, retry);
  937.       sleep (retry);
  938. @
  939.  
  940.  
  941. 1.2
  942. log
  943. @put the "normal" and axsh version in this file (set define AXSH
  944. for the AXSh Version)
  945. @
  946. text
  947. @d21 4
  948. d31 1
  949. a31 1
  950. static char     *rcsid="$Id: mail.c,v 1.1 1993/09/11 15:01:16 Aussem Exp Aussem $";
  951. d253 5
  952. d260 1
  953. @
  954.  
  955.  
  956. 1.1
  957. log
  958. @Initial revision
  959. @
  960. text
  961. @d5 19
  962. a23 9
  963.  * Copyright:
  964.  * This package is freeware.  This means you can copy it freely
  965.  * as  long as you don't ask any money for it, except perhaps a
  966.  * nominal fee for copying.  The package is however Copyright ©
  967.  * Ralph-Thomas   Aussem,  All  Rights  Reserved.   The  author
  968.  * reservers  the  right  to  change the status of this package
  969.  * whenever he may find it appropriate.
  970.  
  971.  * $Log$
  972. d27 1
  973. a27 1
  974. static char     *rcsid="$Id$";
  975. d38 8
  976. d59 10
  977. d101 43
  978. d157 4
  979. d207 1
  980. a207 1
  981.   char file[128], puf[128], *text;
  982. d224 4
  983. d231 4
  984. a234 1
  985.   if(filelength(file)==-1)
  986. d236 2
  987. a237 1
  988.       printf (" No mail-folder for user >>%s<< exists\n",argv[2]);
  989. d240 3
  990. a242 7
  991.   strcpy (puf, "copy ");
  992.   strcat (puf, file);
  993.   strcat (puf, " to ");
  994.   strcat (puf, file);
  995.   strcat (puf, ".o");
  996.   rc = system (puf);
  997.   if (rc)
  998. d244 3
  999. a246 2
  1000.       printf ("%s: Unable to create backup file (%s)\n", argv0, puf);
  1001.       exit (10);
  1002. d248 16
  1003. a263 1
  1004.  
  1005. d270 1
  1006. d291 1
  1007. d303 1
  1008. d322 1
  1009. d327 1
  1010. @
  1011.