Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Friday, October 16, 2026

Diff for libplaton/platon/net/pop3/pop3.c between version 1.2 and 1.3

version 1.2, 2002/10/21 17:01:25 version 1.3, 2002/10/22 13:51:24
Line 575  int pop3_getmail(int nMessageNo, int nMe
Line 575  int pop3_getmail(int nMessageNo, int nMe
 {  {
         /*static struct pop3_mail mail; *//* Our mail structure */          /*static struct pop3_mail mail; *//* Our mail structure */
         int nBytesRecv,nBytesSend;              /* Returns from send() & recv() */          int nBytesRecv,nBytesSend;              /* Returns from send() & recv() */
         int nLength;                                            /* String length */          char nRetrMsg[25];                                      /* RETR message to send */
         char* nRetrMsg;                                 /* RETR message to send */  
         char* nIntString;                                       /* MessageNo converted  
                                                                                    to char[] */  
         char nRecvBuf[3];                                       /* Return code recieve          char nRecvBuf[3];                                       /* Return code recieve
                                                                                    buffer */                                                                                     buffer */
         char *nMsgBuf,*nPartBuf;                        /* Buffer to hold the message          char *nMsgBuf, nPartBuf[2];                     /* Buffer to hold the message
                                                                                    data */                                                                                     data */
         uint nEndFound;                                 /* Indicate if the end of mail          uint nEndFound;                                 /* Indicate if the end of mail
                                                                            is reached */                                                                             is reached */
         uint nBytesDone;                                        /* Number of bytes          uint nBytesDone;                                        /* Number of bytes
                                                                                    recv()'d */                                                                                     recv()'d */
   
         /* Build the RETR string */          sprintf(nRetrMsg, "RETR %u\r\n", nMessageNo);
         nIntString=(char*)malloc(3);  
         nIntString=itoa(nMessageNo);  
   
         nLength=8;  
         nLength+=strlen(nIntString);  
         nRetrMsg=(char*)malloc(nLength);  
   
         nRetrMsg=strcpy(nRetrMsg,"RETR ");  
         nRetrMsg=strcat(nRetrMsg,nIntString);  
         nRetrMsg=strcat(nRetrMsg,"\r\n\0");  
   
 #ifdef __POP3_DEBUG  #ifdef __POP3_DEBUG
         printf("libpop3: pop3_getmail: %s",nRetrMsg);          printf("libpop3: pop3_getmail: %s", nRetrMsg);
 #endif  /* __POP3_DEBUG */  #endif  /* __POP3_DEBUG */
   
         /* Send the RETR command */          /* Send the RETR command */
Line 645  int pop3_getmail(int nMessageNo, int nMe
Line 632  int pop3_getmail(int nMessageNo, int nMe
 #endif  /* __POP3_DEBUG */  #endif  /* __POP3_DEBUG */
   
         /* Allocate buffers */          /* Allocate buffers */
         /* Note that we can only treat nMessageSize as a guide, we can realloc() if we          /* Note that we can only treat nMessageSize as a guide, we can realloc() if
            need more */             we need more */
         nMessageSize+=100;          nMessageSize+=100;
   
         nMsgBuf=(char*)malloc(nMessageSize);          nMsgBuf=(char*)malloc(nMessageSize);
         nPartBuf=(char*)malloc(2);  
   
         /* Clear the input buffers */          /* Clear the input buffers */
         nPartBuf=(char*)memset(nPartBuf,'\0',2);          memset((void *) nPartBuf,'\0',2);
         nMsgBuf=(char*)memset(nMsgBuf,'\0',nMessageSize);          memset((void *) nMsgBuf,'\0',nMessageSize);
   
         /* Reset some variables */          /* Reset some variables */
         nEndFound=0;          nEndFound=0;
Line 715  int pop3_getmail(int nMessageNo, int nMe
Line 701  int pop3_getmail(int nMessageNo, int nMe
         /* Terminate the message buffer & free the part buffer */          /* Terminate the message buffer & free the part buffer */
         nMsgBuf[nBytesDone]='\0';          nMsgBuf[nBytesDone]='\0';
   
         free(nPartBuf);  
   
         /* Process the mail */          /* Process the mail */
 #ifdef __POP3_DEBUG  #ifdef __POP3_DEBUG
         printf("libpop3: pop3_getmail: Extracting headers\n");          printf("libpop3: pop3_getmail: Extracting headers\n");
Line 838  void pop3_freemail(struct pop3_mail *mai
Line 822  void pop3_freemail(struct pop3_mail *mai
         if(mail->zInReplyTo!=0)          if(mail->zInReplyTo!=0)
                 free(mail->zInReplyTo);                  free(mail->zInReplyTo);
   
         if(mail->zHeaders!=0)          /* Not implemented?
                 free(mail->zHeaders);             if(mail->zHeaders!=0)
              free(mail->zHeaders); */
 }  }
   
 int pop3_deletemail(int nMessageNo)  int pop3_deletemail(int nMessageNo)
 {  {
         /* Delete the mail with the DELE command */          /* Delete the mail with the DELE command */
         int nBytesRecv,nBytesSend;      /* Returns from send() & recv() */          int nBytesRecv,nBytesSend;      /* Returns from send() & recv() */
         int nLength;                                    /* Length of message */  
         char nRecvBuf[3];                               /* Return code recieve buffer          char nRecvBuf[3];                               /* Return code recieve buffer
         */          */
         char* nDeleMsg;                         /* DELE message to send */          char nDeleMsg[25];                              /* DELE message to send */
         char* nIntString;                               /* Integer converted to char[]          char* nIntString;                               /* Integer converted to char[] */
         */  
   
         /* Allocate the IntegerString */          /* Allocate the IntegerString */
         nIntString=(char*)malloc(3);          nIntString=(char*)malloc(3);
Line 860  int pop3_deletemail(int nMessageNo)
Line 843  int pop3_deletemail(int nMessageNo)
         /* Build the message */          /* Build the message */
         nIntString=itoa(nMessageNo);          nIntString=itoa(nMessageNo);
   
         nLength=8;          sprintf(nDeleMsg, "DELE %u\r\n", nMessageNo);
         nLength+=strlen(nIntString);  
         nDeleMsg=(char*)malloc(nLength);  
   
         nDeleMsg=strcpy(nDeleMsg,"DELE ");  
         nDeleMsg=strcat(nDeleMsg,nIntString);  
         nDeleMsg=strcat(nDeleMsg,"\r\n\0");  
   
         /* Send the DELE command */          /* Send the DELE command */
         nBytesSend=send(__pop3GlobalSocket,nDeleMsg,strlen(nDeleMsg),0);          nBytesSend=send(__pop3GlobalSocket,nDeleMsg,strlen(nDeleMsg),0);
Line 1186  int main(int argc, char *argv[])
Line 1163  int main(int argc, char *argv[])
 {  {
         register int port = POP3_PORT;          register int port = POP3_PORT;
         char *server = "localhost";          char *server = "localhost";
           char *username = NULL;
           char *password = NULL;
   
         int nMailCount=0;               /* Number of mails on server */          int nMailCount=0;               /* Number of mails on server */
         int nMailSize=0;                /* Size of first email in bytes */          int nMailSize=0;                /* Size of first email in bytes */
   
         if (argc < 3) {          if (argc < 2) {
                 fprintf(stderr, "Usage: %s <username> <password>"                  fprintf(stderr, "Usage: %s <username[:password]>"
                                 " [ <smpt_server> [ <port> ]]\n", argv[0]);                                  " [ <smpt_server> [ <port> ]]\n", argv[0]);
                 return 1;                  return 1;
         }          }
         if (argc > 3) {          if (argc > 2) {
                 server = argv[3];                  server = argv[2];
         }          }
         if (argc > 4) {          if (argc > 3) {
                 port = atoi(argv[4]);                  port = atoi(argv[3]);
                 if (port == 0)                  if (port == 0)
                         port = POP3_PORT;                          port = POP3_PORT;
         }          }
   
         printf("Connecting to server\n");          printf("Connecting to server %s:%d\n", server, port);
   
         if (pop3_connect(server, port) != 0) {          if (pop3_connect(server, port) != 0) {
                 printf("Error: Could not connect to server\n");                  printf("Error: Could not connect to server\n");
                 return(1);                  return(1);
         }          }
   
           username = argv[1];
           if ((password = strchr(username, ':')) == NULL) {
                   password = getpass("POP3 password: ");
           } else {
                   *password = '\0';
                   password++;
           }
   
         printf("Logging in\n");          printf("Logging in\n");
   
         if (pop3_login("frodo", "gandalf") != 0) {          if (pop3_login(username, password) != 0) {
                 printf("Error: Could not login to server\n");                  printf("Error: Could not login to server\n");
                 /* Attempt to disconnect */                  /* Attempt to disconnect */
                 pop3_disconnect();                  pop3_disconnect();

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top