home *** CD-ROM | disk | FTP | other *** search
/ ftp.uv.es / 2014.11.ftp.uv.es.tar / ftp.uv.es / pub / unix / pine4.10.tar.gz / pine4.10.tar / pine4.10 / imap / src / ipopd / ipop2d.c next >
C/C++ Source or Header  |  1999-01-28  |  19KB  |  672 lines

  1. /*
  2.  * Program:    IPOP2D - IMAP to POP2 conversion server
  3.  *
  4.  * Author:    Mark Crispin
  5.  *        Networks and Distributed Computing
  6.  *        Computing & Communications
  7.  *        University of Washington
  8.  *        Administration Building, AG-44
  9.  *        Seattle, WA  98195
  10.  *        Internet: MRC@CAC.Washington.EDU
  11.  *
  12.  * Date:    28 October 1990
  13.  * Last Edited:    27 January 1999
  14.  *
  15.  * Copyright 1999 by the University of Washington
  16.  *
  17.  *  Permission to use, copy, modify, and distribute this software and its
  18.  * documentation for any purpose and without fee is hereby granted, provided
  19.  * that the above copyright notice appears in all copies and that both the
  20.  * above copyright notice and this permission notice appear in supporting
  21.  * documentation, and that the name of the University of Washington not be
  22.  * used in advertising or publicity pertaining to distribution of the software
  23.  * without specific, written prior permission.  This software is made
  24.  * available "as is", and
  25.  * THE UNIVERSITY OF WASHINGTON DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED,
  26.  * WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT LIMITATION ALL IMPLIED
  27.  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, AND IN
  28.  * NO EVENT SHALL THE UNIVERSITY OF WASHINGTON BE LIABLE FOR ANY SPECIAL,
  29.  * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  30.  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, TORT
  31.  * (INCLUDING NEGLIGENCE) OR STRICT LIABILITY, ARISING OUT OF OR IN CONNECTION
  32.  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  33.  *
  34.  */
  35.  
  36.  
  37. /* Parameter files */
  38.  
  39. #include "mail.h"
  40. #include "osdep.h"
  41. #include <stdio.h>
  42. #include <ctype.h>
  43. #include <errno.h>
  44. extern int errno;        /* just in case */
  45. #include <signal.h>
  46. #include "misc.h"
  47.  
  48.  
  49. /* Autologout timer */
  50. #define KODTIMEOUT 60*5
  51. #define LOGINTIMEOUT 60*3
  52. #define TIMEOUT 60*30
  53.  
  54.  
  55. /* Size of temporary buffers */
  56. #define TMPLEN 1024
  57.  
  58.  
  59. /* Server states */
  60.  
  61. #define LISN 0
  62. #define AUTH 1
  63. #define MBOX 2
  64. #define ITEM 3
  65. #define NEXT 4
  66. #define DONE 5
  67.  
  68. /* Global storage */
  69.  
  70. char *version = "4.51";        /* server version */
  71. short state = LISN;        /* server state */
  72. short critical = NIL;        /* non-zero if in critical code */
  73. MAILSTREAM *stream = NIL;    /* mailbox stream */
  74. long idletime = 0;        /* time we went idle */
  75. unsigned long nmsgs = 0;    /* number of messages */
  76. unsigned long current = 1;    /* current message number */
  77. unsigned long size = 0;        /* size of current message */
  78. char status[MAILTMPLEN];    /* space for status string */
  79. char *user = "";        /* user name */
  80. char *pass = "";        /* password */
  81. unsigned long *msg = NIL;    /* message translation vector */
  82.  
  83.  
  84. /* Function prototypes */
  85.  
  86. int main (int argc,char *argv[]);
  87. void clkint ();
  88. void kodint ();
  89. void hupint ();
  90. void trmint ();
  91. short c_helo (char *t,int argc,char *argv[]);
  92. short c_fold (char *t);
  93. short c_read (char *t);
  94. short c_retr (char *t);
  95. short c_acks (char *t);
  96. short c_ackd (char *t);
  97. short c_nack (char *t);
  98.  
  99. /* Main program */
  100.  
  101. int main (int argc,char *argv[])
  102. {
  103.   char *s,*t;
  104.   char cmdbuf[TMPLEN];
  105.                 /* initialize server */
  106.   server_init (argv[0],"pop",NIL,NIL,clkint,kodint,hupint,trmint);
  107. #include "linkage.c"
  108.   /* There are reports of POP2 clients which get upset if anything appears
  109.    * between the "+" and the "POP2" in the greeting.
  110.    */
  111.   printf ("+ POP2 %s v%s server ready\015\012",tcp_serverhost (),version);
  112.   fflush (stdout);        /* dump output buffer */
  113.   state = AUTH;            /* initial server state */
  114.   while (state != DONE) {    /* command processing loop */
  115.     idletime = time (0);    /* get a command under timeout */
  116.     alarm ((state != AUTH) ? TIMEOUT : LOGINTIMEOUT);
  117.     while (!fgets (cmdbuf,TMPLEN-1,stdin)) {
  118.       if (errno==EINTR) errno=0;/* ignore if some interrupt */
  119.       else {
  120.     char *e = errno ? strerror (errno) : "Command stream end of file";
  121.     alarm (0);        /* disable all interrupts */
  122.     server_init (NIL,NIL,NIL,NIL,SIG_IGN,SIG_IGN,SIG_IGN,SIG_IGN);
  123.     syslog (LOG_INFO,"%s while reading line user=%.80s host=%.80s",
  124.         e,user ? user : "???",tcp_clienthost ());
  125.     state = DONE;
  126.     mail_close (stream);    /* try to close the stream gracefully */
  127.     stream = NIL;
  128.     _exit (1);
  129.       }
  130.     }
  131.     alarm (0);            /* make sure timeout disabled */
  132.     idletime = 0;        /* no longer idle */
  133.                 /* find end of line */
  134.     if (!strchr (cmdbuf,'\012')) {
  135.       server_init (NIL,NIL,NIL,NIL,SIG_IGN,SIG_IGN,SIG_IGN,SIG_IGN);
  136.       fputs ("- Command line too long\015\012",stdout);
  137.       state = DONE;
  138.     }
  139.     else if (!(s = strtok (cmdbuf," \015\012"))) {
  140.       server_init (NIL,NIL,NIL,NIL,SIG_IGN,SIG_IGN,SIG_IGN,SIG_IGN);
  141.       fputs ("- Missing or null command\015\012",stdout);
  142.       state = DONE;
  143.     }
  144.     else {            /* dispatch based on command */
  145.       ucase (s);        /* canonicalize case */
  146.                 /* snarf argument */
  147.       t = strtok (NIL,"\015\012");
  148.       if ((state == AUTH) && !strcmp (s,"HELO")) state = c_helo (t,argc,argv);
  149.       else if ((state == MBOX || state == ITEM) && !strcmp (s,"FOLD"))
  150.      state = c_fold (t);
  151.       else if ((state == MBOX || state == ITEM) && !strcmp (s,"READ"))
  152.     state = c_read (t);
  153.       else if ((state == ITEM) && !strcmp (s,"RETR")) state = c_retr (t);
  154.       else if ((state == NEXT) && !strcmp (s,"ACKS")) state = c_acks (t);
  155.       else if ((state == NEXT) && !strcmp (s,"ACKD")) state = c_ackd (t);
  156.       else if ((state == NEXT) && !strcmp (s,"NACK")) state = c_nack (t);
  157.       else if ((state == AUTH || state == MBOX || state == ITEM) &&
  158.            !strcmp (s,"QUIT")) {
  159.     server_init (NIL,NIL,NIL,NIL,SIG_IGN,SIG_IGN,SIG_IGN,SIG_IGN);
  160.     state = DONE;        /* done in either case */
  161.     if (t) fputs ("- Bogus argument given to QUIT\015\012",stdout);
  162.     else {            /* expunge the stream */
  163.       if (stream && nmsgs) stream = mail_close_full (stream,CL_EXPUNGE);
  164.       stream = NIL;        /* don't repeat it */
  165.                 /* acknowledge the command */
  166.       fputs ("+ Sayonara\015\012",stdout);
  167.     }
  168.       }
  169.       else {            /* some other or inappropriate command */
  170.     server_init (NIL,NIL,NIL,NIL,SIG_IGN,SIG_IGN,SIG_IGN,SIG_IGN);
  171.     printf ("- Bogus or out of sequence command - %s\015\012",s);
  172.     state = DONE;
  173.       }
  174.     }
  175.     fflush (stdout);        /* make sure output blatted */
  176.   }
  177.                 /* clean up the stream */
  178.   if (stream) mail_close (stream);
  179.   syslog (LOG_INFO,"Logout user=%.80s host=%.80s",user ? user : "???",
  180.       tcp_clienthost ());
  181.   return 0;            /* all done */
  182. }
  183.  
  184. /* Clock interrupt
  185.  */
  186.  
  187. void clkint ()
  188. {
  189.   alarm (0);        /* disable all interrupts */
  190.   server_init (NIL,NIL,NIL,NIL,SIG_IGN,SIG_IGN,SIG_IGN,SIG_IGN);
  191.   fputs ("- Autologout; idle for too long\015\012",stdout);
  192.   syslog (LOG_INFO,"Autologout user=%.80s host=%.80s",user ? user : "???",
  193.       tcp_clienthost ());
  194.   fflush (stdout);        /* make sure output blatted */
  195.   state = DONE;            /* mark state done in either case */
  196.   if (!critical) {        /* badly host if in critical code */
  197.     if (stream && !stream->lock) mail_close (stream);
  198.     stream = NIL;
  199.     _exit (1);            /* die die die */
  200.   }
  201. }
  202.  
  203.  
  204. /* Kiss Of Death interrupt
  205.  */
  206.  
  207. void kodint ()
  208. {
  209.                 /* only if in command wait */
  210.   if (idletime && ((time (0) - idletime) > KODTIMEOUT)) {
  211.     alarm (0);        /* disable all interrupts */
  212.     server_init (NIL,NIL,NIL,NIL,SIG_IGN,SIG_IGN,SIG_IGN,SIG_IGN);
  213.     fputs ("- Received Kiss of Death\015\012",stdout);
  214.     syslog (LOG_INFO,"Killed (lost mailbox lock) user=%.80s host=%.80s",
  215.         user ? user : "???",tcp_clienthost ());
  216.     fflush (stdout);        /* make sure output blatted */
  217.     state = DONE;        /* mark state done in either case */
  218.     if (!critical) {        /* badly host if in critical code */
  219.       if (stream && !stream->lock) mail_close (stream);
  220.       stream = NIL;
  221.       _exit (1);        /* die die die */
  222.     }
  223.   }
  224. }
  225.  
  226.  
  227. /* Hangup interrupt
  228.  */
  229.  
  230. void hupint ()
  231. {
  232.   alarm (0);        /* disable all interrupts */
  233.   server_init (NIL,NIL,NIL,NIL,SIG_IGN,SIG_IGN,SIG_IGN,SIG_IGN);
  234.   syslog (LOG_INFO,"Hangup user=%.80s host=%.80s",user ? user : "???",
  235.       tcp_clienthost ());
  236.   state = DONE;            /* mark state done in either case */
  237.   if (!critical) {        /* badly host if in critical code */
  238.     if (stream && !stream->lock) mail_close (stream);
  239.     stream = NIL;
  240.     _exit (1);            /* die die die */
  241.   }
  242. }
  243.  
  244.  
  245. /* Termination interrupt
  246.  */
  247.  
  248. void trmint ()
  249. {
  250.   alarm (0);        /* disable all interrupts */
  251.   server_init (NIL,NIL,NIL,NIL,SIG_IGN,SIG_IGN,SIG_IGN,SIG_IGN);
  252.   fputs ("- Killed\015\012",stdout);
  253.   syslog (LOG_INFO,"Killed user=%.80s host=%.80s",user ? user : "???",
  254.       tcp_clienthost ());
  255.   fflush (stdout);        /* make sure output blatted */
  256.   state = DONE;            /* mark state done in either case */
  257.   if (!critical) {        /* badly host if in critical code */
  258.     if (stream && !stream->lock) mail_close (stream);
  259.     stream = NIL;
  260.     _exit (1);            /* die die die */
  261.   }
  262. }
  263.  
  264. /* Parse HELO command
  265.  * Accepts: pointer to command argument
  266.  * Returns: new state
  267.  */
  268.  
  269. short c_helo (char *t,int argc,char *argv[])
  270. {
  271.   char *s,*u,*p;
  272.   char tmp[TMPLEN];
  273.   if ((!(t && *t && (u = strtok (t," ")) && (p = strtok (NIL,"\015\012")))) ||
  274.       (strlen (p) >= TMPLEN)) {    /* get user name and password */
  275.     fputs ("- Missing user or password\015\012",stdout);
  276.     return DONE;
  277.   }
  278.                 /* copy password, handle quoting */
  279.   for (s = tmp; *p; p++) *s++ = (*p == '\\') ? *++p : *p;
  280.   *s = '\0';            /* tie off string */
  281.   pass = cpystr (tmp);
  282. #ifndef DISABLE_POP_PROXY
  283.                 /* want remote mailbox? */
  284.   if ((s = strchr (u,':')) && anonymous_login (argc,argv)) {
  285.     *s++ = '\0';        /* separate host name from user name */
  286.     user = cpystr (s);        /* note user name */
  287.     syslog (LOG_INFO,"IMAP login to host=%.80s user=%.80s host=%.80s",u,user,
  288.         tcp_clienthost ());
  289.                 /* initially remote INBOX */
  290.     sprintf (tmp,"{%.128s/user=%.128s}INBOX",u,user);
  291.                 /* disable rimap just in case */
  292.     mail_parameters (NIL,SET_RSHTIMEOUT,0);
  293.   }
  294.   else
  295. #endif
  296.   if (!s && server_login (user = cpystr (u),pass,argc,argv)) {
  297.     syslog (LOG_INFO,"Login user=%.80s host=%.80s",user,tcp_clienthost ());
  298.     strcpy (tmp,"INBOX");    /* local; attempt login, select INBOX */
  299.   }
  300.   else {
  301.     fputs ("- Bad login\015\012",stdout);
  302.     return DONE;
  303.   }
  304.   return c_fold (tmp);        /* open default mailbox */
  305. }
  306.  
  307. /* Parse FOLD command
  308.  * Accepts: pointer to command argument
  309.  * Returns: new state
  310.  */
  311.  
  312. short c_fold (char *t)
  313. {
  314.   unsigned long i,j,flags;
  315.   char *s,tmp[2*TMPLEN];
  316.   NETMBX mb;
  317.   if (!(t && *t)) {        /* make sure there's an argument */
  318.     fputs ("- Missing mailbox name\015\012",stdout);
  319.     return DONE;
  320.   }
  321.   myusername_full (&flags);    /* get user type flags */
  322.                 /* expunge old stream */
  323.   if (stream && nmsgs) mail_expunge (stream);
  324.   nmsgs = 0;            /* no more messages */
  325.   if (msg) fs_give ((void **) &msg);
  326. #ifndef DISABLE_POP_PROXY
  327.   if (flags == MU_ANONYMOUS) {    /* don't permit proxy to leave IMAP */
  328.     if (stream) {        /* not first time */
  329.       if (!(stream->mailbox && (s = strchr (stream->mailbox,'}'))))
  330.     fatal ("bad previous mailbox name");
  331.       strncpy (tmp,stream->mailbox,i = (++s - stream->mailbox));
  332.       if (i >= TMPLEN) fatal ("ridiculous network prefix");
  333.       strcpy (tmp+i,t);        /* append mailbox to initial spec */
  334.       t = tmp;
  335.     }
  336.                 /* must be net name first time */
  337.     else if (!mail_valid_net_parse (t,&mb)) fatal ("anonymous folder bogon");
  338.   }
  339. #endif
  340.                 /* open mailbox, note # of messages */
  341.   if (j = (stream = mail_open (stream,t,NIL)) ? stream->nmsgs : 0) {
  342.     sprintf (tmp,"1:%lu",j);    /* fetch fast information for all messages */
  343.     mail_fetch_fast (stream,tmp,NIL);
  344.     msg = (unsigned long *) fs_get ((stream->nmsgs + 1) *
  345.                     sizeof (unsigned long));
  346.     for (i = 1; i <= j; i++)    /* find undeleted messages, add to vector */
  347.       if (!mail_elt (stream,i)->deleted) msg[++nmsgs] = i;
  348.   }
  349. #ifndef DISABLE_POP_PROXY
  350.   if (!stream && (flags == MU_ANONYMOUS)) {
  351.     fputs ("- Bad login\015\012",stdout);
  352.     return DONE;
  353.   }
  354. #endif
  355.   printf ("#%lu messages in %s\015\012",nmsgs,stream ? stream->mailbox :
  356.       "<none>");
  357.   return MBOX;
  358. }
  359.  
  360. /* Parse READ command
  361.  * Accepts: pointer to command argument
  362.  * Returns: new state
  363.  */
  364.  
  365. short c_read (char *t)
  366. {
  367.   MESSAGECACHE *elt = NIL;
  368.   if (t && *t) {        /* have a message number argument? */
  369.                 /* validity check message number */
  370.     if (((current = strtoul (t,NIL,10)) < 1) || (current > nmsgs)) {
  371.       fputs ("- Invalid message number given to READ\015\012",stdout);
  372.       return DONE;
  373.     }
  374.   }
  375.   else if (current > nmsgs) {    /* at end of mailbox? */
  376.     fputs ("=0 No more messages\015\012",stdout);
  377.     return MBOX;
  378.   }
  379.                 /* set size if message valid and exists */
  380.   size = msg[current] ? (elt = mail_elt(stream,msg[current]))->rfc822_size : 0;
  381.   if (elt) sprintf (status,"Status: %s%s\015\012",
  382.             elt->seen ? "R" : " ",elt->recent ? " " : "O");
  383.   else status[0] = '\0';    /* no status */
  384.   size += strlen (status);    /* update size to reflect status */
  385.                 /* display results */
  386.   printf ("=%lu characters in message %lu\015\012",size + 2,current);
  387.   return ITEM;
  388. }
  389.  
  390.  
  391. /* Parse RETR command
  392.  * Accepts: pointer to command argument
  393.  * Returns: new state
  394.  */
  395.  
  396. short c_retr (char *t)
  397. {
  398.   if (t) {            /* disallow argument */
  399.     fputs ("- Bogus argument given to RETR\015\012",stdout);
  400.     return DONE;
  401.   }
  402.   if (size) {            /* message size valid? */
  403.     unsigned long i,j;
  404.     t = mail_fetch_header (stream,msg[current],NIL,NIL,&i,FT_PEEK);
  405.     if (i > 2) {        /* only if there is something */
  406.       i -= 2;            /* lop off last two octets */
  407.       while (i) {        /* blat the header */
  408.     j = fwrite (t,sizeof (char),i,stdout);
  409.     if (i -= j) t += j;    /* advance to incomplete data */
  410.       }
  411.     }
  412.     fputs (status,stdout);    /* yes, output message */
  413.     fputs ("\015\012",stdout);    /* delimit header from text */
  414.     t = mail_fetch_text (stream,msg[current],NIL,&i,NIL);
  415.     while (i) {            /* blat the text */
  416.       j = fwrite (t,sizeof (char),i,stdout);
  417.       if (i -= j) t += j;    /* advance to incomplete data */
  418.     }
  419.     fputs ("\015\012",stdout);    /* trailer to coddle PCNFS' NFSMAIL */
  420.   }
  421.   else return DONE;        /* otherwise go away */
  422.   return NEXT;
  423. }
  424.  
  425. /* Parse ACKS command
  426.  * Accepts: pointer to command argument
  427.  * Returns: new state
  428.  */
  429.  
  430. short c_acks (char *t)
  431. {
  432.   char tmp[TMPLEN];
  433.   if (t) {            /* disallow argument */
  434.     fputs ("- Bogus argument given to ACKS\015\012",stdout);
  435.     return DONE;
  436.   }
  437.                 /* mark message as seen */
  438.   sprintf (tmp,"%lu",msg[current++]);
  439.   mail_setflag (stream,tmp,"\\Seen");
  440.   return c_read (NIL);        /* end message reading transaction */
  441. }
  442.  
  443.  
  444. /* Parse ACKD command
  445.  * Accepts: pointer to command argument
  446.  * Returns: new state
  447.  */
  448.  
  449. short c_ackd (char *t)
  450. {
  451.   char tmp[TMPLEN];
  452.   if (t) {            /* disallow argument */
  453.     fputs ("- Bogus argument given to ACKD\015\012",stdout);
  454.     return DONE;
  455.   }
  456.                 /* mark message as seen and deleted */
  457.   sprintf (tmp,"%lu",msg[current]);
  458.   mail_setflag (stream,tmp,"\\Seen \\Deleted");
  459.   msg[current++] = 0;        /* mark message as deleted */
  460.   return c_read (NIL);        /* end message reading transaction */
  461. }
  462.  
  463.  
  464. /* Parse NACK command
  465.  * Accepts: pointer to command argument
  466.  * Returns: new state
  467.  */
  468.  
  469. short c_nack (char *t)
  470. {
  471.   if (t) {            /* disallow argument */
  472.     fputs ("- Bogus argument given to NACK\015\012",stdout);
  473.     return DONE;
  474.   }
  475.   return c_read (NIL);        /* end message reading transaction */
  476. }
  477.  
  478. /* Co-routines from MAIL library */
  479.  
  480.  
  481. /* Message matches a search
  482.  * Accepts: MAIL stream
  483.  *        message number
  484.  */
  485.  
  486. void mm_searched (MAILSTREAM *stream,unsigned long msgno)
  487. {
  488.   /* Never called */
  489. }
  490.  
  491.  
  492. /* Message exists (i.e. there are that many messages in the mailbox)
  493.  * Accepts: MAIL stream
  494.  *        message number
  495.  */
  496.  
  497. void mm_exists (MAILSTREAM *stream,unsigned long number)
  498. {
  499.   /* Can't use this mechanism.  POP has no means of notifying the client of
  500.      new mail during the session. */
  501. }
  502.  
  503.  
  504. /* Message expunged
  505.  * Accepts: MAIL stream
  506.  *        message number
  507.  */
  508.  
  509. void mm_expunged (MAILSTREAM *stream,unsigned long number)
  510. {
  511.   if (state != DONE) {        /* ignore if closing */
  512.                 /* this should never happen */
  513.     fputs ("- Mailbox expunged from under me!\015\012",stdout);
  514.     if (stream && !stream->lock) mail_close (stream);
  515.     stream = NIL;
  516.     _exit (1);
  517.   }
  518. }
  519.  
  520.  
  521. /* Message status changed
  522.  * Accepts: MAIL stream
  523.  *        message number
  524.  */
  525.  
  526. void mm_flags (MAILSTREAM *stream,unsigned long number)
  527. {
  528.   /* This isn't used */
  529. }
  530.  
  531.  
  532. /* Mailbox found
  533.  * Accepts: MAIL stream
  534.  *        hierarchy delimiter
  535.  *        mailbox name
  536.  *        mailbox attributes
  537.  */
  538.  
  539. void mm_list (MAILSTREAM *stream,int delimiter,char *name,long attributes)
  540. {
  541.   /* This isn't used */
  542. }
  543.  
  544.  
  545. /* Subscribe mailbox found
  546.  * Accepts: MAIL stream
  547.  *        hierarchy delimiter
  548.  *        mailbox name
  549.  *        mailbox attributes
  550.  */
  551.  
  552. void mm_lsub (MAILSTREAM *stream,int delimiter,char *name,long attributes)
  553. {
  554.   /* This isn't used */
  555. }
  556.  
  557.  
  558. /* Mailbox status
  559.  * Accepts: MAIL stream
  560.  *        mailbox name
  561.  *        mailbox status
  562.  */
  563.  
  564. void mm_status (MAILSTREAM *stream,char *mailbox,MAILSTATUS *status)
  565. {
  566.   /* This isn't used */
  567. }
  568.  
  569. /* Notification event
  570.  * Accepts: MAIL stream
  571.  *        string to log
  572.  *        error flag
  573.  */
  574.  
  575. void mm_notify (MAILSTREAM *stream,char *string,long errflg)
  576. {
  577.   mm_log (string,errflg);    /* just do mm_log action */
  578. }
  579.  
  580.  
  581. /* Log an event for the user to see
  582.  * Accepts: string to log
  583.  *        error flag
  584.  */
  585.  
  586. void mm_log (char *string,long errflg)
  587. {
  588.   /* Not doing anything here for now */
  589. }
  590.  
  591.  
  592. /* Log an event to debugging telemetry
  593.  * Accepts: string to log
  594.  */
  595.  
  596. void mm_dlog (char *string)
  597. {
  598.   /* Not doing anything here for now */
  599. }
  600.  
  601.  
  602. /* Get user name and password for this host
  603.  * Accepts: parse of network mailbox name
  604.  *        where to return user name
  605.  *        where to return password
  606.  *        trial count
  607.  */
  608.  
  609. void mm_login (NETMBX *mb,char *username,char *password,long trial)
  610. {
  611.                 /* set user name */
  612.   strncpy (username,*mb->user ? mb->user : user,NETMAXUSER-1);
  613.   strncpy (password,pass,255);    /* and password */
  614.   username[NETMAXUSER] = password[255] = '\0';
  615. }
  616.  
  617. /* About to enter critical code
  618.  * Accepts: stream
  619.  */
  620.  
  621. void mm_critical (MAILSTREAM *stream)
  622. {
  623.   critical = T;
  624. }
  625.  
  626.  
  627. /* About to exit critical code
  628.  * Accepts: stream
  629.  */
  630.  
  631. void mm_nocritical (MAILSTREAM *stream)
  632. {
  633.   critical = NIL;
  634. }
  635.  
  636.  
  637. /* Disk error found
  638.  * Accepts: stream
  639.  *        system error code
  640.  *        flag indicating that mailbox may be clobbered
  641.  * Returns: abort flag
  642.  */
  643.  
  644. long mm_diskerror (MAILSTREAM *stream,long errcode,long serious)
  645. {
  646.   if (serious) {        /* try your damnest if clobberage likely */
  647.     syslog (LOG_ALERT,
  648.         "Retrying after disk error user=%.80s host=%.80s mbx=%.80s: %.80s",
  649.         user,tcp_clienthost (),
  650.         (stream && stream->mailbox) ? stream->mailbox : "???",
  651.         strerror (errcode));
  652.     alarm (0);            /* make damn sure timeout disabled */
  653.     sleep (60);            /* give it some time to clear up */
  654.     return NIL;
  655.   }
  656.   syslog (LOG_ALERT,"Fatal disk error user=%.80s host=%.80s mbx=%.80s: %.80s",
  657.       user,tcp_clienthost (),
  658.       (stream && stream->mailbox) ? stream->mailbox : "???",
  659.       strerror (errcode));
  660.   return T;
  661. }
  662.  
  663.  
  664. /* Log a fatal error event
  665.  * Accepts: string to log
  666.  */
  667.  
  668. void mm_fatal (char *string)
  669. {
  670.   mm_log (string,ERROR);    /* shouldn't happen normally */
  671. }
  672.