Esempio n. 1
0
static size_t 
raptor_www_curl_header_callback(void* ptr,  size_t  size, size_t nmemb,
                                void *userdata) 
{
  raptor_www* www = (raptor_www*)userdata;
  size_t bytes = size * nmemb;
  int c;

  /* If WWW has been aborted, return nothing so that
   * libcurl will abort the transfer
   */
  if(www->failed)
    return 0;
  
#define CONTENT_TYPE_LEN 14
  if(!raptor_strncasecmp((char*)ptr, "Content-Type: ", CONTENT_TYPE_LEN)) {
    size_t len = bytes - CONTENT_TYPE_LEN - 2; /* for \r\n */
    char *type_buffer = RAPTOR_MALLOC(char*, len + 1);
    memcpy(type_buffer, (char*)ptr + 14, len);
    type_buffer[len]='\0';
    if(www->type)
      RAPTOR_FREE(char*, www->type);
    www->type = type_buffer;
    www->free_type = 1;

#if defined(RAPTOR_DEBUG) && RAPTOR_DEBUG > 2
    RAPTOR_DEBUG3("Got content type header '%s' (%d bytes)\n", type_buffer, len);
#endif
    if(www->content_type)
      www->content_type(www, www->content_type_userdata, www->type);
  }
Esempio n. 2
0
/**
 * raptor_uri_uri_string_is_file_uri:
 * @uri_string: The URI string to check
 *
 * Check if a URI string is a file: URI.
 * 
 * Return value: Non zero if URI string is a file: URI
 **/
int
raptor_uri_uri_string_is_file_uri(const unsigned char* uri_string) {
  if(!uri_string || !*uri_string)
    return 1;

  return raptor_strncasecmp((const char*)uri_string, "file:", 5)==0;
}
Esempio n. 3
0
static int
assert_strncasecmp (const char *s1, const char *s2, size_t size, int expected)
{
  int result = raptor_strncasecmp(s1, s2, size);
  result = (result > 0) ? 1 : ((result <0) ? -1 : 0);

  if(result != expected)
    {
      fprintf(stderr, "FAIL strncasecmp (%s, %s, %d) gave %d != %d\n",
              s1, s2, (unsigned int)size, result, expected);
      return 1;
    }
  return 0;
}
Esempio n. 4
0
/**
 * raptor_uri_is_file_uri - Check if a URI string is a a file: URI
 * @uri_string: The URI string to check
 * 
 * Return value: Non zero if URI string is a file: URI
 **/
int
raptor_uri_is_file_uri(const unsigned char* uri_string) {
  return raptor_strncasecmp((const char*)uri_string, "file:", 5)==0;
}