⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mail.c

📁 由3926个源代码
💻 C
📖 第 1 页 / 共 4 页
字号:
               } /* while */
               fputs("\n\nEnter \"help\" for additional information.\n",
                        stdout);
               break;
            } /* case */

            case M_FORWARD:
               success = ForwardItem( integer, operand);
               break;

            case M_GOTO:
               current = Position( integer, 0, current );
               break;

            case M_HEADERS:
               PrintSubject( (cmd_ptr->bits & NO_OPERANDS) ?
                                 -1 : integer, letternum );
               break;

            case M_HELP:
            {
               char filename[FILENAME_MAX];
               mkfilename(filename, E_confdir, "mail.hlp");
               Sub_Pager(filename, TRUE );
               break;
            }

            case M_INTPRINT:
               success = Pager( integer , FALSE, noreceived, first_pass);
               break;

            case M_INTTYPE:
               success = Pager( integer , FALSE, noseperator, first_pass);
               break;

            case M_INVALID:
               printf("Invalid command \"%s\".  Enter \"?\" for help.\n",
                        command);
               break;

            case M_MAIL:
               success = DeliverMail( operand , current);
               break;

            case M_NOOP:
               break;

            case M_REPLY:
               success = Reply( integer );
               break;

            case M_QUIT:
               done = TRUE;
               break;

            case M_SAVE:
               success = SaveItem( integer,
                         TRUE,         /* Do delete */
                         seperators,   /* Do save headers */
                         operand ,
                         cmd_ptr->verb );
               modified = TRUE;
               break;

            case M_SET:
               if (operand == NULL)
                  sayoptions( configFlags);
               else
                  options(operand, USER_CONFIG, configFlags, bflag);
               break;

            case M_SYSTEM:
               subshell( operand );
               break;

            case M_UNDELETE:
               letters[integer].status = M_UNREAD;
               break;

            case M_UP:
               current = Position( 0 , - integer , current );
               break;

            case M_STATUS:
               printf("%s:\t%s created %s %s running under %s %d.%02d\n",
                       compilep, compilev, compiled, compilet,

#ifdef WIN32
                     "Windows NT",
                     _winmajor,
                     _winminor);
#elif defined(__OS2__)
                    "OS/2(R)" ,
                    (int) _osmajor / 10,
                      _osminor);
#elif defined(__TURBOC__)
                    "DOS",
                    _osmajor,
                    _osminor);
#else
                    (_osmode == DOS_MODE) ? "DOS" : "OS/2(R)" ,
                    (_osmode == DOS_MODE) ? _osmajor : ((int) _osmajor / 10 ),
                     _osminor);
#endif
#ifdef _Windows
               printf("Windows version: %s\t", compilew );
#endif
               printf("Magic Word:\t%s\n","flarp");
               printf("Return address:\t\"%s\" <%s@%s>\n"
                      "Domain name:\t%s\tNodename:\t%s\n",
                        E_name, E_mailbox, E_fdomain, E_domain, E_nodename );
               printf("Current File:\t%s\tNumber of items: %d\n"
                      "File size:\t%ld bytes\tLast updated:\t%s",
                        mfilename, letternum + 1 , mboxsize ,
                        ctime( & mboxage ) );
               break;

            case M_WRITE:
               success = SaveItem( integer,
                         TRUE,      /* Do delete */
                         noheader,  /* Do not save headers */
                         operand,
                         cmd_ptr->verb );
               modified = TRUE;
         } /* switch */
         first_pass = FALSE;
      } /* while */

      success = ! first_pass; /* If first_pass not run, then
                                 Get_Operand failed                  */

      if ( crlf )
         putchar('\n');

      if ( success && !done )
      {
         if (cmd_ptr->bits & POSITION)
            current = Position( 0 , 0 , integer );

         if ( current != previous )
         {
            if ( (cmd_ptr->bits & AUTOPRINT ) &&
                  bflag[F_AUTOPRINT] &&
                  (letters[current].status != M_DELETED) )
               Pager( current , TRUE, noreceived, TRUE);
            else
               PrintSubject( current , letternum );
         } /* if */
      } /* if */
   } /* while */

/*--------------------------------------------------------------------*/
/*                       End main command loop                        */
/*--------------------------------------------------------------------*/

   if (modified)
      UpdateMailbox(letternum, postoffice);

   free(letters);

} /*Interactive_Mail*/

/*--------------------------------------------------------------------*/
/*    I n c l u d e N e w                                             */
/*                                                                    */
/*    Includes mail from the system box into the user's local         */
/*    mailbox                                                         */
/*--------------------------------------------------------------------*/

static void IncludeNew( const char *target, const char *user)
{
   long age, size;
   FILE *stream_in;
   FILE *stream_out;
   int  bytes;

   char sysbox[FILENAME_MAX];
   char buf[BUFSIZ];

   mkmailbox(sysbox, user);

/*--------------------------------------------------------------------*/
/*      Return semi-quietly if we can't open the system mailbox       */
/*--------------------------------------------------------------------*/

   stream_in   = FOPEN( sysbox, "r", BINARY_MODE);
   if ( stream_in == NULL )
   {
      if ( debuglevel > 1 )
         printerr( sysbox );
      return;
   }

/*--------------------------------------------------------------------*/
/*      Determine if we have new mail, returning quietly if not       */
/*--------------------------------------------------------------------*/

   age = stater( sysbox , &size );

   if ( age == -1)
      panic();

   printmsg( 1, "Including mail from %s through %s",
            sysbox,
            ctime(&age));

/*--------------------------------------------------------------------*/
/*                    Now open up the output file                     */
/*--------------------------------------------------------------------*/

   stream_out  = FOPEN( target, "a+", BINARY_MODE);

   if ( stream_out == NULL )
   {
      printerr( target );
      panic();
   }

/*--------------------------------------------------------------------*/
/*                       Loop to read the data                        */
/*--------------------------------------------------------------------*/

   while ((bytes = fread(buf,sizeof(char), sizeof buf, stream_in)) > 0)
   {
      if ((int) fwrite(buf, sizeof(char), bytes, stream_out) != bytes)
      {
         printmsg(0, "Error including new mail into %s", target );
         printerr( target );
         fclose( stream_in );
         fclose( stream_out );
         panic();
      }
   } /* while */

/*--------------------------------------------------------------------*/
/*                   Clean up and return to caller                    */
/*--------------------------------------------------------------------*/

   if ( ferror( stream_in ))
   {
      printerr( sysbox );
      panic();
   }

   fclose( stream_in  );
   fclose( stream_out );

   filebkup( sysbox );
   unlink(sysbox);

} /* IncludeNew */

/*--------------------------------------------------------------------*/
/*    C r e a t e B o x                                               */
/*                                                                    */
/*    Creates the temporary mailbox and related tables                */
/*--------------------------------------------------------------------*/

int CreateBox(FILE *rmailbox, FILE *fmailbox , const char *tmailbox)
{

/*--------------------------------------------------------------------*/
/*          Copy real mailbox file to temporary mailbox file          */
/*--------------------------------------------------------------------*/

   int letternum = 0;
   boolean inheader = FALSE;
   long position;
   char line[LSIZE];
   char **list;
   size_t replyprior = 0;
   size_t dateprior = 0;
   size_t subjectprior = 0;
   size_t fromprior = 0;

   struct ldesc *letter = NULL;

   while ((fgets(line, LSIZE, rmailbox) != nil(char)) ){

      if (inheader)
      {
         if (*line == '\n')
            inheader = FALSE;
      }  /* inheader */
      else {               /* Determine if starting new message   */
         if (equal(line,MESSAGESEP) ||
            (bflag[F_FROMSEP] && equaln(line, "From ", 5)))
         {
             while (equal(line,MESSAGESEP))
             if (fgets(line, LSIZE, rmailbox) == NULL)
             {
               printerr(mfilename);
               panic();
             } /* if */

/*--------------------------------------------------------------------*/
/*               Make the mailbox bigger if we need to                */
/*--------------------------------------------------------------------*/

             position = ftell(fmailbox);
             if ( (letternum+1) == maxletters )
             {
               maxletters = max((int) ((maxletters * mboxsize) / position),
                                 (letternum * 11) / 10 );
               printmsg(2,"Reallocating mailbox array from %d to %d entries",
                     letternum+1, maxletters );
               letters = realloc( letters, maxletters *  sizeof(letters[0]));
               checkref( letters );
             }

/*--------------------------------------------------------------------*/
/*             Initialize this entry in th mailbox array              */
/*--------------------------------------------------------------------*/

             letter = &letters[letternum++];

             fromprior = subjectprior = replyprior = dateprior = INT_MAX;
             letter->from = letter->subject = letter->date =
                  letter->replyto = MISSING;
             letter->adr = position;
             letter->status = M_UNREAD;
             letter->lines = 0L;
             inheader = TRUE;
             printf("Reading message %d (%d%% done)\r",letternum,
                        (int) (position * 100 / mboxsize));
         }
         else
         {
            if(letter == NULL)   /* Did we find first letter?     */
            {                    /* No --> Abort with message     */
               fprintf(stderr,"%s  %s\n\a",
                  "This mailbox is not in UUPC/extended format!",
                  bflag[F_FROMSEP] ?
                  "Messages must be seperated by From lines!" :
                  "(Try \"options=fromsep\" in your configuration file)");
               panic();
            } /* if */

            letter->lines++;
         } /* else */
      } /* else */

      if (inheader)
      {
         size_t priority = 0;

/*--------------------------------------------------------------------*/
/*              Search for the best Date: related field               */
/*--------------------------------------------------------------------*/

         while ( (dateprior > priority) && (datelist[priority] != NULL ))
         {
            if (equalni(line, datelist[priority],
                             strlen(datelist[priority]) ) )
            {
               letter->date = ftell(fmailbox);
               dateprior = priority;
            }
            priority++;
         }

/*--------------------------------------------------------------------*/
/*             Search for the best Subject: related field             */
/*--------------------------------------------------------------------*/

         priority = 0;
         while ( (subjectprior > priority) &&
                 (subjectlist[priority] != NULL ))

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -