Changeset 3024
- Timestamp:
- 11/28/07 19:19:36
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
devel/pvanhoof/bs/libtinymail-camel/bs/bodystruct.c
r3023 r3024 10 10 11 11 #include "bodystruct.h" 12 13 #define PRINT_NULL(o) (o?o:"(null)") 12 14 13 15 #ifdef DEBUG … … 316 318 while (param) { 317 319 next = param->next; 318 debug_printf ("%s = ", param->name);319 debug_printf ("%s\n", param->value);320 debug_printf ("%s = ", PRINT_NULL (param->name)); 321 debug_printf ("%s\n", PRINT_NULL (param->value)); 320 322 param = next; 321 323 } … … 420 422 inptr = *in; 421 423 str = decode_qstring (&inptr, inend, err); 422 debug_printf ("unknown: %s\n", str);424 debug_printf ("unknown: %s\n", PRINT_NULL (str)); 423 425 g_free (str); 424 426 *in = inptr; … … 450 452 451 453 node->date = decode_qstring (&inptr, inend, err); 452 debug_printf ("env date: %s\n", node->date);454 debug_printf ("env date: %s\n", PRINT_NULL (node->date)); 453 455 node->subject = decode_qstring (&inptr, inend, err); 454 debug_printf ("env subject: %s\n", node->subject);456 debug_printf ("env subject: %s\n", PRINT_NULL (node->subject)); 455 457 456 458 node->from = decode_estring (&inptr, inend, err); 457 debug_printf ("env from: %s\n", node->from);459 debug_printf ("env from: %s\n", PRINT_NULL (node->from)); 458 460 459 461 node->sender = decode_estring (&inptr, inend, err); 460 debug_printf ("env sender: %s\n", node->sender);462 debug_printf ("env sender: %s\n", PRINT_NULL (node->sender)); 461 463 462 464 node->reply_to = decode_estring (&inptr, inend, err); 463 debug_printf ("env reply_to: %s\n", node->reply_to);465 debug_printf ("env reply_to: %s\n", PRINT_NULL (node->reply_to)); 464 466 465 467 node->to = decode_estring (&inptr, inend, err); 466 debug_printf ("env to: %s\n", node->to);468 debug_printf ("env to: %s\n", PRINT_NULL (node->to)); 467 469 468 470 node->cc = decode_estring (&inptr, inend, err); 469 debug_printf ("env cc: %s\n", node->cc);471 debug_printf ("env cc: %s\n", PRINT_NULL (node->cc)); 470 472 471 473 node->bcc = decode_estring (&inptr, inend, err); 472 debug_printf ("env bcc: %s\n", node->bcc);474 debug_printf ("env bcc: %s\n", PRINT_NULL (node->bcc)); 473 475 474 476 node->in_reply_to = decode_estring (&inptr, inend, err); 475 debug_printf ("env in_reply_to: %s\n", node->in_reply_to);477 debug_printf ("env in_reply_to: %s\n", PRINT_NULL (node->in_reply_to)); 476 478 477 479 node->message_id = decode_qstring (&inptr, inend, err); 478 debug_printf ("env message_id: %s\n", node->message_id);480 debug_printf ("env message_id: %s\n", PRINT_NULL (node->message_id)); 479 481 480 482 while (inptr < inend && *inptr == ' ') … … 517 519 /* case b */ 518 520 part->content.lang = decode_qstring (&inptr, inend, err); 519 debug_printf ("lang: %s\n", part->content.lang);521 debug_printf ("lang: %s\n", PRINT_NULL (part->content.lang)); 520 522 521 523 while (inptr < inend && *inptr == ' ') … … 536 538 /* case c */ 537 539 part->content.lang = decode_qstring (&inptr, inend, err); 538 debug_printf ("lang: %s\n", part->content.lang);540 debug_printf ("lang: %s\n", PRINT_NULL (part->content.lang)); 539 541 } else /* case a */ 540 542 inptr += 3; … … 564 566 /* cases c & b */ 565 567 disposition->type = decode_qstring (&inptr, inend, err); 566 debug_printf ("disposition.type: %s\n", disposition->type);568 debug_printf ("disposition.type: %s\n", PRINT_NULL (disposition->type)); 567 569 disposition->params = decode_params (&inptr, inend, err); 568 570 print_params (disposition->params); … … 586 588 /* case d */ 587 589 disposition->type = decode_qstring (&inptr, inend, err); 588 debug_printf ("disposition.type: %s\n", disposition->type);590 debug_printf ("disposition.type: %s\n", PRINT_NULL (disposition->type)); 589 591 disposition->params = decode_params (&inptr, inend, err); 590 592 print_params (disposition->params); … … 599 601 600 602 601 static void602 parse_something_unknown (unsigned char **in, unsigned char *inend, GError **err)603 {604 unsigned char *inptr = *in;605 606 /* a) NIL607 * b) ("INLINE" NIL)608 * c) "INLINE" NIL (never seen this one)*/609 610 while (inptr < inend && *inptr == ' ')611 inptr++;612 613 if (*inptr == '(') {614 struct _mimeparam *unknown_param;615 inptr++; /* My '(' */616 617 /* case b */618 read_unknown_qstring (&inptr, inend, err);619 unknown_param = decode_params (&inptr, inend, err);620 print_params (unknown_param);621 mimeparam_destroy (unknown_param);622 623 while (inptr < inend && *inptr == ' ')624 inptr++;625 626 if (*inptr != ')') {627 *in = inptr;628 set_error (err, in);629 return;630 }631 632 inptr++; /* My ')' */633 } else {634 if (strncmp ((const char *) inptr, "NIL", 3) != 0) {635 struct _mimeparam *unknown_param;636 /* case c */637 read_unknown_qstring (&inptr, inend, err);638 unknown_param = decode_params (&inptr, inend, err);639 print_params (unknown_param);640 mimeparam_destroy (unknown_param);641 } else /* case a */642 inptr += 3;643 }644 645 *in = inptr;646 647 return;648 }649 603 650 604 static void … … 736 690 if (*inptr != ')') { 737 691 part->content.subtype = decode_qstring (&inptr, inend, err); 738 debug_printf ("contensubtype: %s\n", part->content.subtype);692 debug_printf ("contensubtype: %s\n", PRINT_NULL (part->content.subtype)); 739 693 } 740 694 … … 765 719 if (!part->content.type) 766 720 part->content.type = g_strdup ("TEXT"); 767 debug_printf ("contentype: %s\n", part->content.type);721 debug_printf ("contentype: %s\n", PRINT_NULL (part->content.type)); 768 722 769 723 part->content.subtype = decode_qstring (&inptr, inend, err); 770 724 if (!part->content.subtype) 771 725 part->content.subtype = g_strdup ("PLAIN"); 772 debug_printf ("contensubtype: %s\n", part->content.subtype);726 debug_printf ("contensubtype: %s\n", PRINT_NULL (part->content.subtype)); 773 727 774 728 part->disposition.type = NULL; … … 788 742 if (*inptr != ')') { 789 743 part->content.cid = decode_qstring (&inptr, inend, err); 790 debug_printf ("content.cid: %s\n", part->content.cid);744 debug_printf ("content.cid: %s\n", PRINT_NULL (part->content.cid)); 791 745 } 792 746 793 747 if (*inptr != ')') { 794 748 part->description = decode_qstring (&inptr, inend, err); 795 debug_printf ("description: %s\n", part->description);749 debug_printf ("description: %s\n", PRINT_NULL (part->description)); 796 750 } 797 751 … … 800 754 if (!part->encoding) 801 755 part->encoding = g_strdup ("7BIT"); 802 debug_printf ("encoding: %s\n", part->encoding);756 debug_printf ("encoding: %s\n", PRINT_NULL (part->encoding)); 803 757 } 804 758 … … 846 800 if (*inptr != ')') { 847 801 part->content.cid = decode_qstring (&inptr, inend, err); 848 debug_printf ("content.cid: %s\n", part->content.cid);802 debug_printf ("content.cid: %s\n", PRINT_NULL (part->content.cid)); 849 803 } 850 804 851 805 if (*inptr != ')') { 852 806 part->description = decode_qstring (&inptr, inend, err); 853 debug_printf ("description: %s\n", part->description);807 debug_printf ("description: %s\n", PRINT_NULL (part->description)); 854 808 } 855 809 856 810 if (*inptr != ')') { 857 811 part->encoding = decode_qstring (&inptr, inend, err); 858 debug_printf ("encoding: %s\n", part->encoding);812 debug_printf ("encoding: %s\n", PRINT_NULL (part->encoding)); 859 813 } 860 814 … … 885 839 } 886 840 887 } else if (!strcasecmp (part->content.type, " application")||888 !strcasecmp (part->content.type, " image") ||889 !strcasecmp (part->content.type, " audio"))841 } else if (!strcasecmp (part->content.type, "APPLICATION")|| 842 !strcasecmp (part->content.type, "IMAGE") || 843 !strcasecmp (part->content.type, "AUDIO")) 890 844 { 891 845 … … 897 851 if (*inptr != ')') { 898 852 part->content.cid = decode_qstring (&inptr, inend, err); 899 debug_printf ("content.cid: %s\n", part->content.cid);853 debug_printf ("content.cid: %s\n", PRINT_NULL (part->content.cid)); 900 854 } 901 855 902 856 if (*inptr != ')') { 903 857 part->description = decode_qstring (&inptr, inend, err); 904 debug_printf ("description: %s\n", part->description);858 debug_printf ("description: %s\n", PRINT_NULL (part->description)); 905 859 } 906 860 907 861 if (*inptr != ')') { 908 862 part->encoding = decode_qstring (&inptr, inend, err); 909 debug_printf ("encoding: %s\n", part->encoding);863 debug_printf ("encoding: %s\n", PRINT_NULL (part->encoding)); 910 864 } 911 865 … … 984 938 printf (" "); 985 939 986 printf ("IMAP part specification: %s\n", part->part_spec);940 printf ("IMAP part specification: %s\n", PRINT_NULL (part->part_spec)); 987 941 988 942 for (i = 0; i < depth; i++) 989 943 printf (" "); 990 944 991 printf ("Content-Type: %s/%s", part->content.type,945 printf ("Content-Type: %s/%s", PRINT_NULL (part->content.type), 992 946 part->content.subtype); 993 947 … … 995 949 param = part->content.params; 996 950 while (param) { 997 printf ("; %s=%s", param->name, param->value); 951 printf ("; %s=%s", PRINT_NULL (param->name), 952 PRINT_NULL (param->value)); 998 953 param = param->next; 999 954 } … … 1013 968 for (i = 0; i < depth; i++) 1014 969 printf (" "); 1015 printf ( "Date: %s\n", part->envelope->date);970 printf ( "Date: %s\n", PRINT_NULL (part->envelope->date)); 1016 971 for (i = 0; i < depth; i++) 1017 972 printf (" "); 1018 printf ("Subject: %s\n", part->envelope->subject);973 printf ("Subject: %s\n", PRINT_NULL (part->envelope->subject)); 1019 974 for (i = 0; i < depth; i++) 1020 975 printf (" "); 1021 printf ("From: %s\n", part->envelope->from);976 printf ("From: %s\n", PRINT_NULL (part->envelope->from)); 1022 977 for (i = 0; i < depth; i++) 1023 978 printf (" "); 1024 printf ("Sender: %s\n", part->envelope->sender);979 printf ("Sender: %s\n", PRINT_NULL (part->envelope->sender)); 1025 980 for (i = 0; i < depth; i++) 1026 981 printf (" "); 1027 printf ("Reply-To: %s\n", part->envelope->reply_to);982 printf ("Reply-To: %s\n", PRINT_NULL (part->envelope->reply_to)); 1028 983 for (i = 0; i < depth; i++) 1029 984 printf (" "); 1030 printf ("To: %s\n", part->envelope->to);985 printf ("To: %s\n", PRINT_NULL (part->envelope->to)); 1031 986 for (i = 0; i < depth; i++) 1032 987 printf (" "); 1033 printf ("Cc: %s\n", part->envelope->cc);988 printf ("Cc: %s\n", PRINT_NULL (part->envelope->cc)); 1034 989 for (i = 0; i < depth; i++) 1035 990 printf (" "); 1036 printf ("Bcc: %s\n", part->envelope->bcc);991 printf ("Bcc: %s\n", PRINT_NULL (part->envelope->bcc)); 1037 992 for (i = 0; i < depth; i++) 1038 993 printf (" "); 1039 printf ("In-Reply-To: %s\n", part->envelope->in_reply_to);994 printf ("In-Reply-To: %s\n", PRINT_NULL (part->envelope->in_reply_to)); 1040 995 for (i = 0; i < depth; i++) 1041 996 printf (" "); 1042 printf ("Message-Id: %s\n", part->envelope->message_id);997 printf ("Message-Id: %s\n", PRINT_NULL (part->envelope->message_id)); 1043 998 bodystruct_dump_r (part->subparts, depth); 1044 999 depth--; … … 1047 1002 for (i = 0; i < depth; i++) 1048 1003 printf (" "); 1049 printf ("Content-Disposition: %s", part->disposition.type);1004 printf ("Content-Disposition: %s", PRINT_NULL (part->disposition.type)); 1050 1005 if (part->disposition.params) { 1051 1006 param = part->disposition.params; 1052 1007 while (param) { 1053 printf ("; %s=%s", param->name, param->value); 1008 printf ("; %s=%s", PRINT_NULL (param->name), 1009 PRINT_NULL (param->value)); 1054 1010 param = param->next; 1055 1011 } … … 1062 1018 for (i = 0; i < depth; i++) 1063 1019 printf (" "); 1064 printf ("Content-Transfer-Encoding: %s\n", part->encoding);1020 printf ("Content-Transfer-Encoding: %s\n", PRINT_NULL (part->encoding)); 1065 1021 } 1066 1022 … … 1068 1024 for (i = 0; i < depth; i++) 1069 1025 printf (" "); 1070 printf ("Description: %s\n", part->description);1026 printf ("Description: %s\n", PRINT_NULL (part->description)); 1071 1027 } 1072 1028 … … 1078 1034 for (i = 0; i < depth; i++) 1079 1035 printf (" "); 1080 printf ("Language: %s\n", part->content.lang);1036 printf ("Language: %s\n", PRINT_NULL (part->content.lang)); 1081 1037 } 1082 1038 … … 1084 1040 for (i = 0; i < depth; i++) 1085 1041 printf (" "); 1086 printf ("Location: %s\n", part->content.loc);1042 printf ("Location: %s\n", PRINT_NULL (part->content.loc)); 1087 1043 } 1088 1044 … … 1090 1046 for (i = 0; i < depth; i++) 1091 1047 printf (" "); 1092 printf ("Cid: %s\n", part->content.cid);1048 printf ("Cid: %s\n", PRINT_NULL (part->content.cid)); 1093 1049 } 1094 1050 … … 1096 1052 for (i = 0; i < depth; i++) 1097 1053 printf (" "); 1098 printf ("MD5: %s\n", part->content.md5); 1099 } 1100 } 1054 printf ("MD5: %s\n", PRINT_NULL (part->content.md5)); 1055 } 1056 } 1057 1101 1058 1102 1059 printf ("\n");
