ext/iodine/http_mime_parser.h
/** takes the HTTP Content-Type header and initializes the parser data. */
takes the HTTP Content-Type header and initializes the parser data.
takes the HTTP Content - Type header and initializes the parser data .
static int http_mime_parser_init(http_mime_parser_s *parser, char *content_type,
                                 size_t len) {
  *parser = (http_mime_parser_s){.done = 0};
  if (len < 14 || strncasecmp("multipart/form", content_type, 14))
    return -1;
  char *cut = memchr(content_type, ';', len);
  while (cut) {
    ++cut;
    len -= (size_t)(cut - content_type);
    while (len && cut[0] == ' ') {
      --len;
      ++cut;
    }
    if (len <= 9)
      return -1;
    if (strncasecmp("boundary=", cut, 9)) {
      content_type = cut;
      cut = memchr(cut, ';', len);
      continue;
    }
    cut += 9;
    len -= 9;
    content_type = cut;
    parser->boundary = content_type;
    if ((cut = memchr(content_type, ';', len)))
      parser->boundary_len = (size_t)(cut - content_type);
    else
      parser->boundary_len = len;
    return 0;
  }
  return -1;
}
static int http_mime_parser_init ( http_mime_parser_s * parser , char * content_type , size_t len ) { * parser = ( http_mime_parser_s ) { . done = 0 } ; if ( len < 14 || strncasecmp ( " " , content_type , 14 ) ) return -1 ; char * cut = memchr ( content_type , ' ' , len ) ; while ( cut ) { ++ cut ; len -= ( size_t ) ( cut - content_type ) ; while ( len && cut [ 0 ] == ' ' ) { -- len ; ++ cut ; } if ( len <= 9 ) return -1 ; if ( strncasecmp ( " " , cut , 9 ) ) { content_type = cut ; cut = memchr ( cut , ' ' , len ) ; continue ; } cut += 9 ; len -= 9 ; content_type = cut ; parser -> boundary = content_type ; if ( ( cut = memchr ( content_type , ' ' , len ) ) ) parser -> boundary_len = ( size_t ) ( cut - content_type ) ; else parser -> boundary_len = len ; return 0 ; } return -1 ; }
takes the HTTP Content-Type header and initializes the parser data.
takes the HTTP Content - Type header and initializes the parser data .