- Timestamp:
- 2011-12-19T00:00:31Z (13 years ago)
- Branches:
- master
- Children:
- bf57cd1
- Parents:
- 64b6635
- Location:
- lib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/misc.c
r64b6635 r9b0ad7e 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( len == 0 ) 738 len = strlen( text ); 739 740 i = 0; 741 while( ( i + hlen ) < len ) 742 { 743 /* Maybe this is a bit over-commented, but I just hate this part... */ 744 if( g_strncasecmp( text + i, header, hlen ) == 0 ) 745 { 746 /* Skip to the (probable) end of the header */ 747 i += hlen; 748 749 /* Find the first non-[: \t] character */ 750 while( i < len && ( text[i] == ':' || text[i] == ' ' || text[i] == '\t' ) ) i ++; 751 752 /* Make sure we're still inside the string */ 753 if( i >= len ) return( NULL ); 754 755 /* Save the position */ 756 ret = text + i; 757 758 /* Search for the end of this line */ 759 while( i < len && text[i] != '\r' && text[i] != '\n' ) i ++; 760 761 /* Make sure we're still inside the string */ 762 if( i >= len ) return( NULL ); 763 764 /* Copy the found data */ 765 return( g_strndup( ret, text + i - ret ) ); 766 } 767 768 /* This wasn't the header we were looking for, skip to the next line. */ 769 while( i < len && ( text[i] != '\r' && text[i] != '\n' ) ) i ++; 770 while( i < len && ( text[i] == '\r' || text[i] == '\n' ) ) i ++; 771 772 /* End of headers? */ 773 if( ( i >= 4 && strncmp( text + i - 4, "\r\n\r\n", 4 ) == 0 ) || 774 ( i >= 2 && ( strncmp( text + i - 2, "\n\n", 2 ) == 0 || 775 strncmp( text + i - 2, "\r\r", 2 ) == 0 ) ) ) 776 { 777 break; 778 } 779 } 780 781 return( NULL ); 782 } -
lib/misc.h
r64b6635 r9b0ad7e 65 65 66 66 G_MODULE_EXPORT char *word_wrap( const char *msg, int line_len ); 67 68 67 G_MODULE_EXPORT gboolean ssl_sockerr_again( void *ssl ); 69 70 68 G_MODULE_EXPORT int md5_verify_password( char *password, char *hash ); 71 72 69 G_MODULE_EXPORT char **split_command_parts( char *command ); 70 G_MODULE_EXPORT char *get_rfc822_header( char *text, char *header, int len ); 73 71 74 72 #endif
Note: See TracChangeset
for help on using the changeset viewer.