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

📄 ipop2d.c

📁 广泛使用的邮件服务器!同时
💻 C
📖 第 1 页 / 共 2 页
字号:
				/* open mailbox, note # of messages */  if (j = (stream = mail_open (stream,t,NIL)) ? stream->nmsgs : 0) {    sprintf (tmp,"1:%lu",j);	/* fetch fast information for all messages */    mail_fetch_fast (stream,tmp,NIL);    msg = (unsigned long *) fs_get ((stream->nmsgs + 1) *				    sizeof (unsigned long));    for (i = 1; i <= j; i++)	/* find undeleted messages, add to vector */      if (!mail_elt (stream,i)->deleted) msg[++nmsgs] = i;  }#ifndef DISABLE_POP_PROXY  if (!stream && (flags == MU_ANONYMOUS)) {    fputs ("- Bad login\015\012",stdout);    return DONE;  }#endif  printf ("#%lu messages in %s\015\012",nmsgs,stream ? stream->mailbox :	  "<none>");  return MBOX;}/* Parse READ command * Accepts: pointer to command argument * Returns: new state */short c_read (char *t){  MESSAGECACHE *elt = NIL;  if (t && *t) {		/* have a message number argument? */				/* validity check message number */    if (((current = strtoul (t,NIL,10)) < 1) || (current > nmsgs)) {      fputs ("- Invalid message number given to READ\015\012",stdout);      return DONE;    }  }  else if (current > nmsgs) {	/* at end of mailbox? */    fputs ("=0 No more messages\015\012",stdout);    return MBOX;  }				/* set size if message valid and exists */  size = msg[current] ? (elt = mail_elt(stream,msg[current]))->rfc822_size : 0;  if (elt) sprintf (status,"Status: %s%s\015\012",		    elt->seen ? "R" : " ",elt->recent ? " " : "O");  else status[0] = '\0';	/* no status */  size += strlen (status);	/* update size to reflect status */				/* display results */  printf ("=%lu characters in message %lu\015\012",size + 2,current);  return ITEM;}/* Parse RETR command * Accepts: pointer to command argument * Returns: new state */short c_retr (char *t){  unsigned long i,j;  STRING *bs;  if (t) {			/* disallow argument */    fputs ("- Bogus argument given to RETR\015\012",stdout);    return DONE;  }  if (size) {			/* message size valid? */    t = mail_fetch_header (stream,msg[current],NIL,NIL,&i,FT_PEEK);    if (i > 2) {		/* only if there is something */      i -= 2;			/* lop off last two octets */      while (i) {		/* blat the header */	if (!(j = fwrite (t,sizeof (char),i,stdout))) return DONE;	if (i -= j) t += j;	/* advance to incomplete data */      }    }    fputs (status,stdout);	/* yes, output message */    fputs ("\015\012",stdout);	/* delimit header from text */    if (t = mail_fetch_text (stream,msg[current],NIL,&i,FT_RETURNSTRINGSTRUCT))      while (i) {		/* blat the text */	if (!(j = fwrite (t,sizeof (char),i,stdout))) return DONE;	if (i -= j) t += j;	/* advance to incomplete data */      }    else for (bs = &stream->private.string; i--; )      if (putc (SNX (bs),stdout) == EOF) return DONE;    fputs ("\015\012",stdout);	/* trailer to coddle PCNFS' NFSMAIL */  }  else return DONE;		/* otherwise go away */  return NEXT;}/* Parse ACKS command * Accepts: pointer to command argument * Returns: new state */short c_acks (char *t){  char tmp[TMPLEN];  if (t) {			/* disallow argument */    fputs ("- Bogus argument given to ACKS\015\012",stdout);    return DONE;  }				/* mark message as seen */  sprintf (tmp,"%lu",msg[current++]);  mail_setflag (stream,tmp,"\\Seen");  return c_read (NIL);		/* end message reading transaction */}/* Parse ACKD command * Accepts: pointer to command argument * Returns: new state */short c_ackd (char *t){  char tmp[TMPLEN];  if (t) {			/* disallow argument */    fputs ("- Bogus argument given to ACKD\015\012",stdout);    return DONE;  }				/* mark message as seen and deleted */  sprintf (tmp,"%lu",msg[current]);  mail_setflag (stream,tmp,"\\Seen \\Deleted");  msg[current++] = 0;		/* mark message as deleted */  return c_read (NIL);		/* end message reading transaction */}/* Parse NACK command * Accepts: pointer to command argument * Returns: new state */short c_nack (char *t){  if (t) {			/* disallow argument */    fputs ("- Bogus argument given to NACK\015\012",stdout);    return DONE;  }  return c_read (NIL);		/* end message reading transaction */}/* Co-routines from MAIL library *//* Message matches a search * Accepts: MAIL stream *	    message number */void mm_searched (MAILSTREAM *stream,unsigned long msgno){  /* Never called */}/* Message exists (i.e. there are that many messages in the mailbox) * Accepts: MAIL stream *	    message number */void mm_exists (MAILSTREAM *stream,unsigned long number){  /* Can't use this mechanism.  POP has no means of notifying the client of     new mail during the session. */}/* Message expunged * Accepts: MAIL stream *	    message number */void mm_expunged (MAILSTREAM *stream,unsigned long number){  if (state != DONE) {		/* ignore if closing */				/* someone else screwed us */    goodbye = "- Mailbox expunged from under me!\015\012";    if (stream && !stream->lock) mail_close (stream);    stream = NIL;    sayonara (1);  }}/* Message status changed * Accepts: MAIL stream *	    message number */void mm_flags (MAILSTREAM *stream,unsigned long number){  /* This isn't used */}/* Mailbox found * Accepts: MAIL stream *	    hierarchy delimiter *	    mailbox name *	    mailbox attributes */void mm_list (MAILSTREAM *stream,int delimiter,char *name,long attributes){  /* This isn't used */}/* Subscribe mailbox found * Accepts: MAIL stream *	    hierarchy delimiter *	    mailbox name *	    mailbox attributes */void mm_lsub (MAILSTREAM *stream,int delimiter,char *name,long attributes){  /* This isn't used */}/* Mailbox status * Accepts: MAIL stream *	    mailbox name *	    mailbox status */void mm_status (MAILSTREAM *stream,char *mailbox,MAILSTATUS *status){  /* This isn't used */}/* Notification event * Accepts: MAIL stream *	    string to log *	    error flag */void mm_notify (MAILSTREAM *stream,char *string,long errflg){  mm_log (string,errflg);	/* just do mm_log action */}/* Log an event for the user to see * Accepts: string to log *	    error flag */void mm_log (char *string,long errflg){  switch (errflg) {  case NIL:			/* information message */  case PARSE:			/* parse glitch */    break;			/* too many of these to log */  case WARN:			/* warning */    syslog (LOG_DEBUG,"%s",string);    break;  case BYE:			/* driver broke connection */    if (state != DONE) {      char tmp[MAILTMPLEN];      alarm (0);		/* disable all interrupts */      server_init (NIL,NIL,NIL,SIG_IGN,SIG_IGN,SIG_IGN,SIG_IGN,SIG_IGN);      sprintf (logout = tmp,"Mailbox closed (%.80s)",string);      sayonara (1);    }    break;  case ERROR:			/* error that broke command */  default:			/* default should never happen */    syslog (LOG_NOTICE,"%s",string);    break;  }}/* Log an event to debugging telemetry * Accepts: string to log */void mm_dlog (char *string){  /* Not doing anything here for now */}/* Get user name and password for this host * Accepts: parse of network mailbox name *	    where to return user name *	    where to return password *	    trial count */void mm_login (NETMBX *mb,char *username,char *password,long trial){				/* set user name */  strncpy (username,*mb->user ? mb->user : user,NETMAXUSER-1);  strncpy (password,pass,255);	/* and password */  username[NETMAXUSER] = password[255] = '\0';}/* About to enter critical code * Accepts: stream */void mm_critical (MAILSTREAM *stream){  ++critical;}/* About to exit critical code * Accepts: stream */void mm_nocritical (MAILSTREAM *stream){  --critical;}/* Disk error found * Accepts: stream *	    system error code *	    flag indicating that mailbox may be clobbered * Returns: abort flag */long mm_diskerror (MAILSTREAM *stream,long errcode,long serious){  if (serious) {		/* try your damnest if clobberage likely */    syslog (LOG_ALERT,	    "Retrying after disk error user=%.80s host=%.80s mbx=%.80s: %.80s",	    user,tcp_clienthost (),	    (stream && stream->mailbox) ? stream->mailbox : "???",	    strerror (errcode));    alarm (0);			/* make damn sure timeout disabled */    sleep (60);			/* give it some time to clear up */    return NIL;  }  syslog (LOG_ALERT,"Fatal disk error user=%.80s host=%.80s mbx=%.80s: %.80s",	  user,tcp_clienthost (),	  (stream && stream->mailbox) ? stream->mailbox : "???",	  strerror (errcode));  return T;}/* Log a fatal error event * Accepts: string to log */void mm_fatal (char *string){  mm_log (string,ERROR);	/* shouldn't happen normally */}

⌨️ 快捷键说明

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