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

📄 main.lst

📁 TINI的pop3的c代码
💻 LST
📖 第 1 页 / 共 2 页
字号:
 189   1              {
 190   2                      printf("\n the number of mails in mailbox : %d", ml->numberofmails);
 191   2                      for(count=0;count<ml->numberofmails;count++)
 192   2                      {
 193   3                              printf("\n mailnumber: %d, size: %d",ml->mailnumberlist[count],ml->mailsizelist[count]);
 194   3                      }
 195   2              }
 196   1          else
 197   1                      printf("\n pop3_getmaillist failed, the returned status value is : %d",status);
 198   1      
 199   1              
 200   1              printf("\nEnter mail number to readmail:");
 201   1              scanf("%d",&count);
 202   1              readmail=pop3_receivemail(count,&status);
 203   1              
 204   1              if(readmail==0)
 205   1                      printf("\n receivemail failed, the returned status value is : %d",status);
 206   1              else
 207   1              {
 208   2                      printf("\nthe received mail content:");
 209   2                      print_mailnode(readmail);
 210   2              }
 211   1      
 212   1              //logout from pop3 server
 213   1              status=pop3_logout();
 214   1              printf("\n status of of pop3_logout is : %d",status);
 215   1      
 216   1              //register ntlmauthentication callback function
 217   1              pop3_registerauthcallback(&ntlm_authentication);
 218   1      
 219   1              //login to pop3 server
 220   1              status=pop3_login(pop3_ip,user,pass);
 221   1              printf("\nthe return value of pop3_login after registering ntlm auth callback function :%d",status);
 222   1              
 223   1              //logout from pop3 server
 224   1              status=pop3_logout();
 225   1              printf("\n status of of pop3_logout is : %d",status);
 226   1      
 227   1              while(1)
 228   1              {
 229   2              }
 230   1      }
*** WARNING C280 IN LINE 142 OF C:\KEIL\PROJECTS\LIBRARIES_SAMPLES\POP3\MAIN.C: 'file': unreferenced local variable
*** WARNING C280 IN LINE 146 OF C:\KEIL\PROJECTS\LIBRARIES_SAMPLES\POP3\MAIN.C: 'u_hdr': unreferenced local variable
 231          
 232          
 233          /*****************************************************************************************
C51 COMPILER V7.07   MAIN                                                                  06/25/2004 10:50:46 PAGE 5   

 234          *   Function Name : print_mailnode
 235          *     Description : this function displays content of mailnode structure object
 236          *        Input(s) : newmailnode
 237          *       Output(s) : nothing
 238          *         Return value: nothing
 239          *               Notes :
 240          *****************************************************************************************/
 241          void print_mailnode(struct _mail *newmailnode)
 242          {
 243   1              int count;
 244   1              printf("\nfrom id : %s",newmailnode->mailhdr.from_id);
 245   1              printf("\nsender name : %s",newmailnode->mailhdr.sendername);
 246   1              printf("\nto id : %s",newmailnode->mailhdr.to_id);
 247   1              printf("\nrecipient name : %s",newmailnode->mailhdr.recipientname);
 248   1              printf("\nsubject : %s",newmailnode->mailhdr.subject);
 249   1              printf("\nreply_to_id : %s",newmailnode->mailhdr.reply_to_id);
 250   1              printf("\ncc id : %s",newmailnode->mailhdr.cc_id);
 251   1              printf("\nbcc id : %s",newmailnode->mailhdr.bcc_id);
 252   1              printf("\nerrors to id : %s",newmailnode->mailhdr.errors_to_id);
 253   1              printf("\ndate : %s",newmailnode->mailhdr.date);
 254   1      
 255   1              count=0;
 256   1              while(newmailnode->userhdr.headernamelist[count]!=0)
 257   1              {
 258   2                      printf("\nuser header name  : %s",newmailnode->userhdr.headernamelist[count]);
 259   2                      printf("\nuser header value : %s",newmailnode->userhdr.headervaluelist[count]);
 260   2                      count++;
 261   2              }
 262   1      
 263   1              printf("\nmessage : %s",newmailnode->msg);
 264   1      
 265   1              count=0;
 266   1              while(newmailnode->attachmentlist[count]!=0)
 267   1              {
 268   2                      printf("\nattachment file names  : %s",newmailnode->attachmentlist[count]);
 269   2                      printfile(newmailnode->attachmentlist[count]);
 270   2                      count++;
 271   2              }
 272   1              return ; 
 273   1      }
 274          
 275          //print file content
 276          void printfile(char *filename)
 277          {
 278   1      
 279   1          int temp;
 280   1              FILE *file;
 281   1              file = fopen(filename, "r");
 282   1      
 283   1              if (file==NULL)
 284   1              {
 285   2                      printf("\n file not found");
 286   2                      return;
 287   2              }
 288   1              printf("\nfile content:");
 289   1      
 290   1          temp = fgetc(file);
 291   1      
 292   1          while (temp != -1)
 293   1          {
 294   2              printf("%c", (char)temp);
 295   2              temp = fgetc(file);
C51 COMPILER V7.07   MAIN                                                                  06/25/2004 10:50:46 PAGE 6   

 296   2          }
 297   1              printf("\r\n");
 298   1              fclose(file);
 299   1      }
 300          
 301          
 302          int ntlm_authentication(pop3_session *pop3_handle)
 303          {
 304   1              char buf[MAX_LINE_SIZE];
 305   1              char *mimebuf;
 306   1              int size;
 307   1      
 308   1          sprintf(buf, "AUTH NTLM\r\n");
 309   1      
 310   1              if(send(pop3_handle->handle, buf, strlen(buf),0)!=0) 
 311   1              {
 312   2                      return POP3_SOCKET_ERROR;
 313   2              }
 314   1      
 315   1              if((size=recv(pop3_handle->handle,buf,MAX_LINE_SIZE,0))==0x0FFFF)
 316   1              {
 317   2                      return POP3_SOCKET_ERROR;
 318   2              }
 319   1      
 320   1              buf[size]='\0';
 321   1      
 322   1              if(strncmp(buf,"+",1)!=0)
 323   1              {
 324   2                      return POP3_RECEIVEMAIL_ERROR;
 325   2              }
 326   1      
 327   1              //generate type1 ntlm message
 328   1              generate_type1_msg(&t1_msg, pop3_handle->user);
 329   1              mimebuf=mime_encode((unsigned char *)&t1_msg,(sizeof(type1msghdr)+t1_msg.buf_index), BASE64);
 330   1              strcpy(buf,mimebuf);
 331   1              strcat(buf,"\r\n");
 332   1      
 333   1              if(send(pop3_handle->handle, buf, strlen(buf),0)!=0)
 334   1                      return POP3_SOCKET_ERROR;
 335   1      
 336   1              //receive server response
 337   1              if((size=recv(pop3_handle->handle,buf,MAX_LINE_SIZE,0))==0x0FFFF)
 338   1                      return POP3_SOCKET_ERROR;
 339   1      
 340   1              //ignore server response status mark
 341   1              if(buf[0]=='+' && buf[1] == ' ')
 342   1                      mimebuf=mime_decode(buf+2, BASE64);
 343   1              else
 344   1                      mimebuf=mime_decode(buf, BASE64);
 345   1      
 346   1              memcpy((char *)&t2_msg,mimebuf,mem_sizeof(mimebuf));
 347   1      
 348   1              //generate type3 ntlm message
 349   1          generate_type3_msg(&t2_msg, &t3_msg, pop3_handle->user,pop3_handle->pass);
 350   1      
 351   1              mimebuf=mime_encode((unsigned char *)&t3_msg,(sizeof(type3msghdr)+t3_msg.buf_index), BASE64);
 352   1      
 353   1              strcpy(buf,mimebuf);
 354   1              strcat(buf,"\r\n");
 355   1      
 356   1              if(send(pop3_handle->handle, buf, strlen(buf),0)!=0) 
 357   1                      return POP3_SOCKET_ERROR;
C51 COMPILER V7.07   MAIN                                                                  06/25/2004 10:50:46 PAGE 7   

 358   1      
 359   1              if((size=recv(pop3_handle->handle,buf,MAX_LINE_SIZE,0))==0x0FFFF)
 360   1                      return POP3_SOCKET_ERROR;
 361   1      
 362   1              buf[size]='\0';
 363   1      
 364   1              if(strncmp(buf,"+",1)!=0)
 365   1              {
 366   2                      return POP3_INVALID_USER_PASSWORD;
 367   2              }
 368   1          return POP3_STATUS_SUCCESS;
 369   1      }
 370          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   2114    ----
   CONSTANT SIZE    =    825    ----
   XDATA SIZE       =   3222    1295
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
   EDATA SIZE       =   ----    ----
   HDATA SIZE       =   ----    ----
   XDATA CONST SIZE =   ----    ----
   FAR CONST SIZE   =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  5 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

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