Commit 78627370 authored by Pekka Pessi's avatar Pekka Pessi

http: using isize_t, usize_t, issize_t in API.

Internally using size_t/ssize_t.

darcs-hash:20060906215233-65a35-390752eece82f1ef5d1c2699849258a5575fd7fd.gz
parent 9b6b3ecb
This diff is collapsed.
......@@ -131,10 +131,10 @@ void http_cookie_update(http_cookie_t *c)
}
/* Scan a cookie parameter */
static int cookie_scanner(char *s)
static issize_t cookie_scanner(char *s)
{
char *p = s;
unsigned tlen;
size_t tlen;
skip_token(&s);
......@@ -178,7 +178,7 @@ static int cookie_scanner(char *s)
}
/** Decode (parse) a Cookie header */
int http_cookie_d(su_home_t *home, msg_header_t *h, char *s, int slen)
issize_t http_cookie_d(su_home_t *home, msg_header_t *h, char *s, isize_t slen)
{
http_cookie_t *c = (http_cookie_t *)h;
......@@ -205,7 +205,7 @@ int http_cookie_d(su_home_t *home, msg_header_t *h, char *s, int slen)
}
/** Encode (print) a Cookie header */
int http_cookie_e(char b[], int bsiz, msg_header_t const *h, int flags)
issize_t http_cookie_e(char b[], isize_t bsiz, msg_header_t const *h, int flags)
{
char *b0 = b, *end = b + bsiz;
http_cookie_t const *c = (http_cookie_t *)h;
......@@ -224,7 +224,7 @@ int http_cookie_e(char b[], int bsiz, msg_header_t const *h, int flags)
}
/** Calculate extra storage used by Cookie header field */
int http_cookie_dup_xtra(msg_header_t const *h, int offset)
isize_t http_cookie_dup_xtra(msg_header_t const *h, isize_t offset)
{
int rv = offset;
http_cookie_t const *c = (http_cookie_t *)h;
......@@ -236,7 +236,7 @@ int http_cookie_dup_xtra(msg_header_t const *h, int offset)
/** Duplicate a Cookie header field */
char *http_cookie_dup_one(msg_header_t *dst, msg_header_t const *src,
char *b, int xtra)
char *b, isize_t xtra)
{
http_cookie_t *c = (http_cookie_t *)dst;
http_cookie_t const *o = (http_cookie_t const *)src;
......@@ -343,7 +343,7 @@ void http_set_cookie_update(http_set_cookie_t *sc)
#include <sofia-sip/msg_date.h>
/* Scan a cookie parameter */
static int set_cookie_scanner(char *s)
static issize_t set_cookie_scanner(char *s)
{
char *rest;
......@@ -374,7 +374,7 @@ static int set_cookie_scanner(char *s)
}
/** Decode (parse) Set-Cookie header */
int http_set_cookie_d(su_home_t *home, msg_header_t *h, char *s, int slen)
issize_t http_set_cookie_d(su_home_t *home, msg_header_t *h, char *s, isize_t slen)
{
msg_header_t **hh = &h->sh_succ, *h0 = h;
http_set_cookie_t *sc = (http_set_cookie_t *)h;
......@@ -422,7 +422,7 @@ int http_set_cookie_d(su_home_t *home, msg_header_t *h, char *s, int slen)
}
/** Encode (print) Set-Cookie header */
int http_set_cookie_e(char b[], int bsiz, msg_header_t const *h, int flags)
issize_t http_set_cookie_e(char b[], isize_t bsiz, msg_header_t const *h, int flags)
{
char *b0 = b, *end = b + bsiz;
http_set_cookie_t const *sc = (http_set_cookie_t *)h;
......@@ -441,7 +441,7 @@ int http_set_cookie_e(char b[], int bsiz, msg_header_t const *h, int flags)
}
/** Calculate extra storage used by Set-Cookie header field */
int http_set_cookie_dup_xtra(msg_header_t const *h, int offset)
isize_t http_set_cookie_dup_xtra(msg_header_t const *h, isize_t offset)
{
int rv = offset;
http_set_cookie_t const *sc = (http_set_cookie_t *)h;
......@@ -453,7 +453,7 @@ int http_set_cookie_dup_xtra(msg_header_t const *h, int offset)
/** Duplicate a Set-Cookie header field */
char *http_set_cookie_dup_one(msg_header_t *dst, msg_header_t const *src,
char *b, int xtra)
char *b, isize_t xtra)
{
http_set_cookie_t *sc = (http_set_cookie_t *)dst;
http_set_cookie_t const *o = (http_set_cookie_t const *)src;
......
......@@ -57,7 +57,7 @@
/** Complete a HTTP request. */
int http_request_complete(msg_t *msg)
{
size_t len;
unsigned len;
http_t *http = http_object(msg);
su_home_t *home = msg_home(msg);
......
......@@ -68,8 +68,8 @@ msg_mclass_t *http_default_mclass(void)
return http_mclass;
}
static int
http_extract_chunk(msg_t *msg, http_t *http, char b[], int bsiz, int eos);
static
issize_t http_extract_chunk(msg_t *, http_t *, char b[], isize_t bsiz, int eos);
/** Calculate length of line ending (0, 1 or 2) */
#define CRLF_TEST(s) \
......@@ -81,9 +81,9 @@ http_extract_chunk(msg_t *msg, http_t *http, char b[], int bsiz, int eos);
* @retval 0 cannot proceed
* @retval other number of bytes extracted
*/
int http_extract_body(msg_t *msg, http_t *http, char b[], int bsiz, int eos)
issize_t http_extract_body(msg_t *msg, http_t *http, char b[], isize_t bsiz, int eos)
{
int m = 0;
issize_t m = 0;
unsigned body_len;
int flags = http->http_flags;
......@@ -204,16 +204,16 @@ int http_extract_body(msg_t *msg, http_t *http, char b[], int bsiz, int eos)
* @retval 0 cannot proceed
* @retval other number of bytes extracted
*/
int http_extract_chunk(msg_t *msg, http_t *http, char b[], int bsiz, int eos)
issize_t http_extract_chunk(msg_t *msg, http_t *http, char b[], isize_t bsiz, int eos)
{
int crlf, n;
unsigned chunk_len;
size_t n;
unsigned crlf, chunk_len;
char *b0 = b, *s;
int bsiz0 = bsiz;
union {
msg_header_t *header;
msg_payload_t *chunk;
} h = { NULL };
size_t bsiz0 = bsiz;
if (bsiz == 0)
return 0;
......@@ -279,21 +279,24 @@ int http_extract_chunk(msg_t *msg, http_t *http, char b[], int bsiz, int eos)
return b - b0;
}
else {
issize_t chunk;
b += n + crlf, bsiz -= n + crlf;
b += n + crlf, bsiz -= n + crlf;
/* Extract chunk */
bsiz = msg_extract_payload(msg, http,
&h.header, chunk_len + (b - b0),
b0, bsiz0, eos);
/* Extract chunk */
chunk = msg_extract_payload(msg, http,
&h.header, chunk_len + (b - b0),
b0, bsiz0, eos);
if (bsiz != -1 && h.header) {
assert(h.chunk->pl_data);
h.chunk->pl_data += (b - b0);
h.chunk->pl_len -= (b - b0);
}
if (chunk != -1 && h.header) {
assert(h.chunk->pl_data);
h.chunk->pl_data += (b - b0);
h.chunk->pl_len -= (b - b0);
}
return bsiz;
return chunk;
}
}
/** Parse HTTP version.
......@@ -366,7 +369,7 @@ int http_version_d(char **ss, char const **ver)
}
/** Calculate extra space required by version string */
int http_version_xtra(char const *version)
isize_t http_version_xtra(char const *version)
{
if (version == http_version_1_1)
return 0;
......@@ -447,7 +450,7 @@ http_method_t http_method_d(char **ss, char const **nname)
char *s = *ss, c = *s;
char const *name;
int code = http_method_unknown;
int n = 0;
size_t n = 0;
#define MATCH(s, m) (strncasecmp(s, m, n = sizeof(m) - 1) == 0)
......@@ -515,15 +518,16 @@ http_method_t http_method_code(char const *name)
* The function http_query_parse() returns number keys that matched within
* the @a query string.
*/
int http_query_parse(char *query,
/* char const *key, char **return_value, */
...)
issize_t http_query_parse(char *query,
/* char const *key, char **return_value, */
...)
{
va_list ap;
char *q, *q_next;
char *name, *value, **return_value;
char const *key;
size_t namelen, valuelen, keylen, N;
size_t namelen, valuelen, keylen;
isize_t N;
int has_value;
if (!query)
......
......@@ -121,8 +121,8 @@ tagi_t *httptag_filter(tagi_t *dst,
hh = (void *)msg_hclass_offset(mc, http, hc);
if (http == NULL ||
hh >= (http_header_t const **)((char *)http + http->http_size) ||
hh < (http_header_t const **)&http->http_request)
(char *)hh >= ((char *)http + http->http_size) ||
(char *)hh < (char *)&http->http_request)
return dst;
h = *hh;
......@@ -131,7 +131,7 @@ tagi_t *httptag_filter(tagi_t *dst,
return dst;
stub[0].t_tag = tt;
stub[0].t_value = (long)h;
stub[0].t_value = (tag_value_t)h;
src = stub; sctt = tt;
}
......
......@@ -140,7 +140,7 @@ SOFIAPUBFUN void *http_header_data(http_header_t *h);
SOFIAPUBFUN http_content_length_t *http_content_length_create(su_home_t *home,
uint32_t n);
SOFIAPUBFUN http_payload_t *http_payload_create(su_home_t *home,
void const *data, int len);
void const *data, usize_t len);
SOFIAPUBFUN http_separator_t *http_separator_create(su_home_t *home);
#endif
......@@ -177,9 +177,9 @@ SOFIAPUBFUN http_expires_t *http_expires_create(su_home_t *home,
SOFIAPUBFUN int http_url_cmp(url_t const *a, url_t const *b);
/** Parse query part in HTTP URL. */
SOFIAPUBFUN int http_query_parse(char *query,
/* char const *key, char **return_value, */
...);
SOFIAPUBFUN issize_t http_query_parse(char *query,
/* char const *key, char **return_value, */
...);
/* ----------------------------------------------------------------------
* 4) Inlined functions
......@@ -248,7 +248,7 @@ http_content_length_t *http_content_length_create(su_home_t *home, uint32_t n)
}
su_inline
http_payload_t *http_payload_create(su_home_t *home, void const *data, int len)
http_payload_t *http_payload_create(su_home_t *home, void const *data, isize_t len)
{
return msg_payload_create(home, data, len);
}
......
......@@ -93,7 +93,7 @@ SOFIA_BEGIN_DECLS
/* Version strings */
SOFIAPUBFUN int http_version_d(char **ss, char const **ver);
SOFIAPUBFUN int http_version_xtra(char const *version);
SOFIAPUBFUN isize_t http_version_xtra(char const *version);
SOFIAPUBFUN void http_version_dup(char **pp, char const **dd, char const *s);
/* Method */
......@@ -102,8 +102,8 @@ SOFIAPUBFUN char const *http_method_name(http_method_t method,
char const *name);
/** Extract HTTP message body */
SOFIAPUBFUN int http_extract_body(msg_t *, http_t *,
char b[], int bsiz, int eos);
SOFIAPUBFUN issize_t http_extract_body(msg_t *, http_t *,
char b[], isize_t bsiz, int eos);
SOFIA_END_DECLS
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment