NetSurf
www-authenticate.c
Go to the documentation of this file.
1/*
2 * Copyright 2010 John-Mark Bell <jmb@netsurf-browser.org>
3 *
4 * This file is part of NetSurf, http://www.netsurf-browser.org/
5 *
6 * NetSurf is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * NetSurf is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#include <stdlib.h>
20
22#include "utils/http/generics.h"
26
27/* See www-authenticate.h for documentation */
28nserror http_parse_www_authenticate(const char *header_value,
30{
31 const char *pos = header_value;
32 http_challenge *first = NULL;
33 http_challenge *list = NULL;
35 nserror error;
36
37 /* 1#challenge */
38
39 http__skip_LWS(&pos);
40
41 error = http__parse_challenge(&pos, &first);
42 if (error != NSERROR_OK)
43 return error;
44
45 http__skip_LWS(&pos);
46
47 if (*pos == ',') {
48 error = http__item_list_parse(&pos,
49 http__parse_challenge, first, &list);
50 if (error != NSERROR_OK && error != NSERROR_NOT_FOUND)
51 return error;
52 } else {
53 list = first;
54 }
55
56 wa = malloc(sizeof(*wa));
57 if (wa == NULL) {
59 return NSERROR_NOMEM;
60 }
61
62 wa->challenges = list;
63
64 *result = wa;
65
66 return NSERROR_OK;
67}
68
69/* See www-authenticate.h for documentation */
71{
73 free(victim);
74}
75
STATIC char result[100]
Definition: arexx.c:77
nserror http__parse_challenge(const char **input, http_challenge **challenge)
Parse an HTTP challenge.
Definition: challenge.c:61
void http_challenge_list_destroy(http_challenge *list)
Destroy a list of HTTP challenges.
Definition: challenge.c:136
nserror
Enumeration of error codes.
Definition: errors.h:29
@ NSERROR_NOT_FOUND
Requested item not found.
Definition: errors.h:34
@ NSERROR_NOMEM
Memory exhaustion.
Definition: errors.h:32
@ NSERROR_OK
No error.
Definition: errors.h:30
#define http__item_list_parse(i, p, f, r)
Definition: generics.h:52
void http__skip_LWS(const char **input)
Skip past linear whitespace in input.
Definition: primitives.c:31
Representation of an HTTP challenge.
Definition: challenge.c:31
http_challenge * challenges
nserror http_parse_www_authenticate(const char *header_value, http_www_authenticate **result)
Parse an HTTP WWW-Authenticate header value.
void http_www_authenticate_destroy(http_www_authenticate *victim)
Destroy a www authenticate object.