Changeset 5f40da7 for lib/misc.c
- Timestamp:
- 2011-12-26T10:51:19Z (13 years ago)
- Branches:
- master
- Children:
- 199fea6
- Parents:
- 96f954d (diff), 644b808 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/misc.c
r96f954d r5f40da7 729 729 return cmd; 730 730 } 731 732 char *get_rfc822_header( char *text, char *header, int len ) 733 { 734 int hlen = strlen( header ), i; 735 char *ret; 736 737 if( text == NULL ) 738 return NULL; 739 740 if( len == 0 ) 741 len = strlen( text ); 742 743 i = 0; 744 while( ( i + hlen ) < len ) 745 { 746 /* Maybe this is a bit over-commented, but I just hate this part... */ 747 if( g_strncasecmp( text + i, header, hlen ) == 0 ) 748 { 749 /* Skip to the (probable) end of the header */ 750 i += hlen; 751 752 /* Find the first non-[: \t] character */ 753 while( i < len && ( text[i] == ':' || text[i] == ' ' || text[i] == '\t' ) ) i ++; 754 755 /* Make sure we're still inside the string */ 756 if( i >= len ) return( NULL ); 757 758 /* Save the position */ 759 ret = text + i; 760 761 /* Search for the end of this line */ 762 while( i < len && text[i] != '\r' && text[i] != '\n' ) i ++; 763 764 /* Make sure we're still inside the string */ 765 if( i >= len ) return( NULL ); 766 767 /* Copy the found data */ 768 return( g_strndup( ret, text + i - ret ) ); 769 } 770 771 /* This wasn't the header we were looking for, skip to the next line. */ 772 while( i < len && ( text[i] != '\r' && text[i] != '\n' ) ) i ++; 773 while( i < len && ( text[i] == '\r' || text[i] == '\n' ) ) i ++; 774 775 /* End of headers? */ 776 if( ( i >= 4 && strncmp( text + i - 4, "\r\n\r\n", 4 ) == 0 ) || 777 ( i >= 2 && ( strncmp( text + i - 2, "\n\n", 2 ) == 0 || 778 strncmp( text + i - 2, "\r\r", 2 ) == 0 ) ) ) 779 { 780 break; 781 } 782 } 783 784 return NULL; 785 }
Note: See TracChangeset
for help on using the changeset viewer.