int main(void) { page_attribute a, b; size_t i, niter = 10000; const char* media_type = "text/html"; const char* language = "en_uk"; const char* charset = "iso8859-1"; const char* encoding = "gzip"; for (i = 0; i < niter; i++) { if ((a = attribute_new()) == NULL) return 77; if (!attribute_set_media_type(a, media_type)) return 77; if (!attribute_set_language(a, language)) return 77; if (!attribute_set_charset(a, charset)) return 77; if (!attribute_set_encoding(a, encoding)) return 77; if (strcmp(attribute_get_media_type(a), media_type) != 0) return 77; if (strcmp(attribute_get_language(a), language) != 0) return 77; if (strcmp(attribute_get_charset(a), charset) != 0) return 77; if (strcmp(attribute_get_encoding(a), encoding) != 0) return 77; if ((b = attribute_dup(a)) == NULL) return 77; if (strcmp(attribute_get_media_type(b), media_type) != 0) return 77; if (strcmp(attribute_get_language(b), language) != 0) return 77; if (strcmp(attribute_get_charset(b), charset) != 0) return 77; if (strcmp(attribute_get_encoding(b), encoding) != 0) return 77; attribute_free(a); attribute_free(b); } return 0; }
static int check_attributes(http_request request, page_attribute a) { const char* page_val; assert(request != NULL); assert(a != NULL); /* See if the client understands us */ page_val = attribute_get_media_type(a); if(page_val && !request_accepts_media_type(request, page_val)) return 0; return 1; }