Beispiel #1
0
int dynamic_set_attributes(dynamic_page p, page_attribute a)
{
	attribute_free(p->attr);
	if( (p->attr = attribute_dup(a)) == NULL) 
		return ENOMEM;

	return 0;
}
Beispiel #2
0
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;
}
Beispiel #3
0
dynamic_page dynamic_new(const char* uri, PAGE_FUNCTION handler, page_attribute a)
{
	dynamic_page p;

	if( (p = malloc(sizeof *p)) != NULL) {
		p->handler = handler;
		p->attr = NULL;
		if( (p->uri = cstring_dup(uri)) == NULL) {
			free(p);
			p = NULL;
		}
		else if(a != NULL && (p->attr = attribute_dup(a)) == NULL) {
			cstring_free(p->uri);
			free(p);
			p = NULL;
		}
	}

	return p;
}