Commit 673141ed authored by Pekka Pessi's avatar Pekka Pessi

Made headers C++-safe (bug #1376379).

darcs-hash:20060103204348-65a35-293d8b6f87eb77457887e8ce70289db22e8d7690.gz
parent d97905d8
......@@ -35,6 +35,8 @@
*
*/
#include <string.h>
/* Parsing tokens */
/** Control characters. */
#define CTL "\001\002\003\004\005\006\007" \
......@@ -153,9 +155,13 @@ enum {
#define BNF_DLL __declspec(dllimport)
#endif
#endif
BNF_DLL
BNF_DLL extern
#ifdef __cplusplus
"C"
#endif
/** Table for determining class of a character */
extern unsigned char const _bnf_table[256];
unsigned char const _bnf_table[256];
/** Get number of characters before CRLF */
#define span_non_crlf(s) strcspn(s, CR LF)
......
......@@ -38,6 +38,10 @@
/** Define as current Sofia name and version */
#define SOFIA_SIP_NAME_VERSION "@PACKAGE_NAME@-@PACKAGE_VERSION@"
#ifdef __cplusplus
extern "C" {
#endif
extern char const * const sofia_sip_name_version;
extern char const * const sofia_sip_has_smime;
extern char const * const sofia_sip_has_tls;
......@@ -51,4 +55,8 @@ extern char const * const sofia_sip_has_upnp;
extern char const * const sofia_sip_has_sctp;
extern char const * const sofia_sip_has_ipv6;
#ifdef __cplusplus
}
#endif
#endif
......@@ -46,6 +46,8 @@
#include <msg_mime.h>
#endif
SOFIA_BEGIN_DECLS
/* ----------------------------------------------------------------------
* 1) Constants
*/
......@@ -475,4 +477,6 @@ union http_header_u {
#include <http_dll.h>
SOFIA_END_DECLS
#endif /* !defined(HTTP_H) */
......@@ -36,6 +36,8 @@
#include <msg_types.h>
#endif
SOFIA_BEGIN_DECLS
/* Use directly these header classes */
#define http_accept_class msg_accept_class
......@@ -62,4 +64,6 @@
#undef HTTP_HCLASSES_ONLY
#endif
SOFIA_END_DECLS
#endif /* !defined HTTP_HCLASSES_H */
......@@ -50,6 +50,8 @@
#include <msg_header.h>
#endif
SOFIA_BEGIN_DECLS
/* ----------------------------------------------------------------------
* 1) Macros
*/
......@@ -252,4 +254,6 @@ int http_query_parse(char *query,
#include <http_protos.h>
#endif
SOFIA_END_DECLS
#endif /* !defined(HTTP_HEADER_H) */
......@@ -24,8 +24,6 @@
#ifndef HTTP_PARSER_H /**Defined when http_parser.h has been included.*/
#define HTTP_PARSER_H
/**@file http_parser.h
* @brief Typedefs and prototypes used by HTTP parser.
*
......@@ -58,6 +56,8 @@
#include <http_header.h>
#endif
SOFIA_BEGIN_DECLS
/* ---------------------------------------------------------------------------
* 1) Macros for defining boilerplate functions and structures for each header
*/
......@@ -66,8 +66,6 @@
#define HTTP_HCLASS_TEST(x) ((x) && (x)->hc_tag == HTTP_PROTOCOL_TAG)
#define HTTP_HDR_TEST(x) ((x)->sh_class && HTTP_HCLASS_TEST((x)->sh_class))
#define http_no_update NULL
/** Define a header class for a HTTP header. */
#define HTTP_HEADER_CLASS(c, l, params, kind, dup) \
MSG_HEADER_CLASS(http_, c, l, "", params, kind, http_ ## dup, http_no)
......@@ -111,5 +109,8 @@ int http_extract_body(msg_t *msg, http_t *http, char b[], int bsiz, int eos);
#define http_default_dup_xtra msg_default_dup_xtra
#define http_default_dup_one msg_default_dup_one
#endif /* !defined(HTTP_PARSER_H) */
#define http_no_update NULL
SOFIA_END_DECLS
#endif /* !defined(HTTP_PARSER_H) */
......@@ -52,7 +52,7 @@
((http_header_t *)msg_header_make((h), (c), (s)))
#define http_header_vformat(h, c, f, a) \
((http_header_t *)msg_header_vformat((h), (c), (f), (a)))
SOFIA_BEGIN_DECLS
/* Declare internal prototypes for #xxxxxxx_xxxxxxx# */
......@@ -304,5 +304,5 @@ http_#xxxxxx#_t *http_#xxxxxx#_make(su_home_t *home, char const *s)
/** @} */
SOFIA_END_DECLS
#endif /* !defined(HTTP_PROTOS_H) */
......@@ -34,8 +34,11 @@
* @date Created: Tue Sep 18 18:55:09 2001 ppessi
*/
#include <su_config.h>
#include <http_dll.h>
SOFIA_BEGIN_DECLS
char const *http_status_phrase(int status);
#define HTTP_100_CONTINUE 100, http_100_continue
......@@ -122,4 +125,6 @@ HTTP_DLL extern char const http_503_no_service[];
HTTP_DLL extern char const http_504_gateway_timeout[];
HTTP_DLL extern char const http_505_http_version[];
SOFIA_END_DECLS
#endif /* HTTP_STATUS_H */
......@@ -55,6 +55,8 @@
#include <http.h>
#endif
SOFIA_BEGIN_DECLS
#define HTTPTAG(c, x) httptag_##c, httptag_##c##_v(x)
#define HTTPTAG_REF(c, x) httptag_##c##_ref, httptag_##c##_vr(&(x))
#define HTTPTAG_STR(c, s) httptag_##c##_str, tag_str_v(s)
......@@ -225,5 +227,5 @@ httptag_#xxxxxx#_vr(http_#xxxxxx#_t const **vp)
#define httptag_#xxxxxx#_vr(vp) (tag_value_t)(vp)
#endif
SOFIA_END_DECLS
#endif /* !defined(HTTP_TAG_H) */
......@@ -42,6 +42,8 @@
#include <msg_tag_class.h>
#endif
SOFIA_BEGIN_DECLS
/** Define a named tag type for HTTP header @a t. */
#define HTTPHDRTAG_NAMED_TYPEDEF(n, t) \
{{ TAG_NAMESPACE, #n, httphdrtag_class, \
......@@ -66,4 +68,6 @@ tagi_t *httptag_filter(tagi_t *dst, tagi_t const f[], tagi_t const *src,
#endif /* !defined(HTTP_TAG_CLASS_H) */
SOFIA_END_DECLS
......@@ -43,6 +43,10 @@
* @author Pekka Pessi <Pekka.Pessi@nokia.com>
*/
#include <su_config.h>
SOFIA_BEGIN_DECLS
/** Decode a BASE64-encoded string. */
int base64_d(char buf[], int bsiz, char const *b64s);
/** Encode data with BASE64. */
......@@ -51,4 +55,6 @@ int base64_e(char buf[], int bsiz, void *data, int dsiz);
/** Calculate size of n bytes encoded in base64 */
#define BASE64_SIZE(n) ((((n) + 2) / 3) * 4)
SOFIA_END_DECLS
#endif /* !BASE_64 */
......@@ -26,13 +26,17 @@
#define RC4_H
/**@file rc4.h
* @brief
* @brief Arcfour random number generator.
*
* @author Pekka Pessi <Pekka.Pessi@nokia.com>
*
* @date Created: Sun Jun 9 14:32:58 1996 ppessi
*/
#if defined(__cplusplus)
extern "C" {
#endif
/** Byte. */
typedef unsigned char rc4_u8;
......@@ -53,4 +57,8 @@ void rc4_init(const void *seed, int seed_len, rc4_t *state);
/** Generate RC4 stream. */
void rc4(void *buffer, int len, rc4_t *state);
#if defined(__cplusplus)
}
#endif
#endif /* !defined RC4_H */
......@@ -60,16 +60,8 @@
#ifndef _SHA1_H_
#define _SHA1_H_
#if HAVE_STDINT_H
#include <stdint.h>
#elif HAVE_INTTYPES_H
#include <inttypes.h>
#else
/* Define HAVE_STDINT_H as 1 if you have <stdint.h>,
or HAVE_INTTYPES_H if you have <inttypes.h> */
typedef unsigned int uint32_t;
typedef short int int_least16_t;
typedef unsigned char uint8_t;
#ifndef SU_TYPES_H
#include <su_types.h>
#endif
/*
......
......@@ -34,10 +34,14 @@
*
*/
#ifndef SU_CONFIG_H
#include <su_config.h>
#endif
#include <string.h>
SOFIA_BEGIN_DECLS
#if SU_HAVE_INLINE
su_inline
#endif
......@@ -148,4 +152,6 @@ size_t strncspn(char const *s, size_t ssize, char const *reject)
#endif
SOFIA_END_DECLS
#endif /* !STRING0_H */
......@@ -35,9 +35,15 @@
*
*/
#include <su_config.h>
SOFIA_BEGIN_DECLS
int token64_e(char b[], int bsiz, void const *data, int dlen);
/** Calculate size of n bytes encoded in token-64 */
#define TOKEN64_SIZE(n) (((n + 2) / 3) * 4)
SOFIA_END_DECLS
#endif /* !TOKEN64_H */
......@@ -22,6 +22,9 @@
*
*/
#ifndef UNIQUEID_H /** Defined when <uniqueid.h> has been included. */
#define UNIQUEID_H
/**@file uniqueid.h
*
* Compatibility functions to handle GloballyUniqueID.
......@@ -33,10 +36,6 @@
* @date Created: Tue Apr 15 06:31:41 1997 pessi
*/
#ifndef UNIQUEID_H /** Defined when <uniqueid.h> has been included. */
#define UNIQUEID_H
/* Compatibility functionality */
#define guid_t su_guid_t
#define guid_generate su_guid_generate
......
......@@ -41,16 +41,11 @@
#ifndef UTF8_H /** Defined when <utf8.h> has been included */
#define UTF8_H
#ifdef __cplusplus
extern "C" {
#endif
#if 0
}
#ifndef SU_TYPES_H
#include <su_types.h>
#endif
#ifndef _SIZE_T
#include <stddef.h>
#endif
SOFIA_BEGIN_DECLS
typedef unsigned char utf8;
typedef unsigned short utf16;
......@@ -184,8 +179,6 @@ int ucs4ncmp(ucs4 const *s1, ucs4 const *s2, size_t n);
(s)[4]=((c>>6)&63)|128,\
(s)[5]=((c)&63)|128)
#ifdef __cplusplus
}
#endif
SOFIA_END_DECLS
#endif /* UTF8_H */
......@@ -44,6 +44,8 @@
#include <url.h>
#endif
SOFIA_BEGIN_DECLS
/** Authenticator object. */
typedef struct auth_client_s auth_client_t;
......@@ -79,4 +81,6 @@ struct sip_s;
int auc_with_uicc(auth_client_t **auc, su_home_t *home, struct uicc_s *uicc);
int auc_authorize(auth_client_t **auc, msg_t *msg, struct sip_s *sip);
SOFIA_END_DECLS
#endif
......@@ -25,7 +25,6 @@
#ifndef AUTH_DIGEST_H /** Defined when <auth_digest.h> has been included. */
#define AUTH_DIGEST_H
/**@file auth_digest.h
* Datatypes and functions for Digest authentication.
*
......@@ -49,6 +48,8 @@
#include <su_alloc.h>
#endif
SOFIA_BEGIN_DECLS
/** Parameters for digest-challenge.
*
* The digest-challenge is sent by server or proxy to client. It can be
......@@ -153,4 +154,6 @@ int auth_digest_response(auth_response_t *, auth_hexmd5_t response,
auth_hexmd5_t const ha1,
char const *method_name, void const *data, int dlen);
SOFIA_END_DECLS
#endif
......@@ -22,10 +22,8 @@
*
*/
#ifndef AUTH_MODULE_H
/** Defined when <auth_module.h> has been included. @HI */
#ifndef AUTH_MODULE_H /** Defined when auth_module.h has been included. */
#define AUTH_MODULE_H
/**@file auth_module.h
* @brief Authentication verification interface for NTA network elements.
......@@ -54,6 +52,8 @@
#include <url_tag.h>
#endif
SOFIA_BEGIN_DECLS
typedef struct auth_mod_t auth_mod_t;
/** Authentication operation. */
typedef struct auth_status_t auth_status_t;
......@@ -65,7 +65,7 @@ typedef void auth_magic_t;
#endif
/** Virtual table for authentication plugin. */
typedef struct auth_scheme_t const auth_scheme_t;
typedef struct auth_scheme const auth_scheme_t;
/** Opaque data used by authentication plugin module. */
typedef struct auth_plugin_t auth_plugin_t;
......@@ -354,4 +354,6 @@ AUTH_DLL extern tag_typedef_t authtag_cache_errors;
#define AUTHTAG_CACHE_ERRORS_REF(x) authtag_cache_errors_ref, tag_uint_vr((&x))
AUTH_DLL extern tag_typedef_t authtag_cache_errors_ref;
SOFIA_END_DECLS
#endif
......@@ -52,11 +52,13 @@
#include <htable.h>
SOFIA_BEGIN_DECLS
/* ====================================================================== */
/* Plugin interface for authentication */
/** Authentication scheme */
struct auth_scheme_t
struct auth_scheme
{
/** Name */
char const *asch_method;
......@@ -244,4 +246,6 @@ void auth_md5_hmac_init(auth_mod_t *am, su_md5_t *md5);
void auth_md5_hmac_digest(auth_mod_t *am, su_md5_t *md5,
void *hmac, size_t size);
SOFIA_END_DECLS
#endif /* !defined AUTH_PLUGIN_H */
......@@ -35,9 +35,13 @@
#include <su_log.h>
SOFIA_BEGIN_DECLS
/** Common log for application and srvlib components. */
extern su_log_t iptsec_log[];
SOFIA_END_DECLS
#define SU_LOG (iptsec_log)
#include <su_debug.h>
......
......@@ -36,6 +36,8 @@
#include <msg_dll.h>
#include <msg_types.h>
SOFIA_BEGIN_DECLS
msg_t *msg_create(msg_mclass_t const *mc, int flags);
void msg_destroy(msg_t *);
......@@ -157,4 +159,6 @@ enum msg_flg_parser {
#define MSG_IS_COMPLETE(mo) (((mo)->msg_flags & MSG_FLG_COMPLETE) != 0)
SOFIA_END_DECLS
#endif /* MSG_H */
......@@ -41,6 +41,8 @@
#include <su.h>
#endif
SOFIA_BEGIN_DECLS
void msg_addr_zero(msg_t *msg);
su_addrinfo_t *msg_addrinfo(msg_t *msg);
su_sockaddr_t *msg_addr(msg_t *msg);
......@@ -82,4 +84,6 @@ int msg_buf_external(msg_t *msg,
unsigned blocksize);
SOFIA_END_DECLS
#endif /* !defined(MSG_ADDR_H) */
......@@ -34,6 +34,12 @@
*
*/
#ifndef MSG_TYPES_H
#include <msg_types.h>
#endif
SOFIA_BEGIN_DECLS
void *msg_buf_alloc(msg_t *msg, unsigned size);
void *msg_buf_exact(msg_t *msg, unsigned size);
unsigned msg_buf_commit(msg_t *msg, unsigned size, int eos);
......@@ -45,4 +51,6 @@ void *msg_buf_move(msg_t *dst, msg_t const *src);
void msg_buf_set(msg_t *msg, void *b, unsigned size);
SOFIA_END_DECLS
#endif /* !defined MSG_BUFFER_H */
......@@ -25,7 +25,6 @@
#ifndef MSG_DATE_H /** Defined when msg_date.h has been included. */
#define MSG_DATE_H
/**@ingroup msg_parser
* @file msg_date.h
* @brief Types and functions for handling dates and times.
......@@ -36,6 +35,12 @@
*
*/
#ifndef SU_CONFIG_H
#include <su_config.h>
#endif
SOFIA_BEGIN_DECLS
#ifndef MSG_TIME_T_DEFINED
#define MSG_TIME_T_DEFINED
/** Time in seconds since epoch (1900-Jan-01 00:00:00). */
......@@ -63,4 +68,6 @@ int msg_date_e(char b[], int bsiz, msg_time_t date);
enum { msg_date_string_size = 29 };
SOFIA_END_DECLS
#endif /* !defined(MSG_DATE_H) */
......@@ -38,16 +38,17 @@
#include <stdarg.h>
#include <string.h>
#ifndef MSG_H
#include <msg.h>
#endif
#ifndef SU_TYPES_H
#include <su_types.h>
#endif
#ifndef SU_ALLOC_H
#include <su_alloc.h>
#endif
#ifndef MSG_H
#include <msg.h>
#endif
/* These headers are critical for understanding the message */
#define msg_kind_single_critical msg_kind_single, 1
#define msg_kind_list_critical msg_kind_list, 1
SOFIA_BEGIN_DECLS
msg_header_t *msg_header_alloc(su_home_t *, msg_hclass_t *hc, int extra)
__attribute__((__malloc__));
......@@ -232,4 +233,6 @@ enum {
#include <msg_protos.h>
#endif
SOFIA_END_DECLS
#endif /** !defined(MSG_HEADER_H) */
......@@ -25,7 +25,6 @@
#ifndef MSG_INTERNAL_H /** Defined when msg_internal.h has been included. */
#define MSG_INTERNAL_H
/**@IFILE msg_internal.h
* @brief Abstract messages - internal interface
*
......@@ -47,6 +46,8 @@
#include <su_alloc.h>
#endif
SOFIA_BEGIN_DECLS
struct msg_s {
su_home_t m_home[1]; /**< Memory home */
......@@ -121,4 +122,6 @@ static inline int msg_is_special(msg_header_t const *h)
return h->sh_class->hc_hash < 0;
}
SOFIA_END_DECLS
#endif /* MSG_INTERNAL_H */
......@@ -38,6 +38,8 @@
#include <msg_header.h>
#endif
SOFIA_BEGIN_DECLS
enum {
/** Default size of hash table */
MC_HASH_SIZE = 127,
......@@ -131,4 +133,6 @@ msg_href_t const *msg_find_hclass(msg_mclass_t const *, char const *, int *);
msg_mclass_t const *msg_mclass(msg_t const *);
SOFIA_END_DECLS
#endif /* !defined(MSG_MCLASS_H) */
......@@ -37,10 +37,14 @@
*
*/
#include <su_config.h>
#ifndef BNF_H
#include <bnf.h>
#endif
SOFIA_BEGIN_DECLS
/** Hash the header name */
#define MC_HASH(s, n) (msg_header_name_hash(s, NULL) % (unsigned)(n))
......@@ -68,4 +72,6 @@ unsigned short msg_header_name_hash(char const *s, int *llen)
return hash;
}
SOFIA_END_DECLS
#endif /** MSG_MCLASS_HASH_H */
......@@ -47,6 +47,8 @@
#include <su_types.h>
#endif
SOFIA_BEGIN_DECLS
typedef struct msg_accept_any_s msg_accept_any_t;
typedef struct msg_accept_s msg_accept_t;
......@@ -229,4 +231,6 @@ extern char const msg_mime_version_1_0[];
/** MIME multipart parser table identifier. @HIDE */
#define MSG_MULTIPART_PROTOCOL_TAG ((void *)0x4d494d45) /* 'MIME' */
SOFIA_END_DECLS
#endif /** MSG_MIME_H */
......@@ -54,6 +54,8 @@
#include <msg_mclass.h>
#endif
SOFIA_BEGIN_DECLS
MSG_DLL extern msg_mclass_t const msg_multipart_mclass[1];
#define msg_multipart_class ((msg_hclass_t *)msg_multipart_mclass)
......@@ -315,4 +317,6 @@ MSG_DLL msg_update_f msg_accept_update;
MSG_DLL msg_update_f msg_accept_any_update;
MSG_DLL msg_update_f msg_content_disposition_update;
SOFIA_END_DECLS
#endif /** !defined(MSG_MIME_PROTOS_H) */
......@@ -39,23 +39,18 @@
#ifndef SU_ALLOC_H
#include <su_alloc.h>
#endif
#ifndef MSG_H
#include <msg.h>
#endif
#ifndef MSG_HEADER_H
#include <msg_header.h>
#endif
#ifndef BNF_H
#include <bnf.h>
#endif
#ifndef URL_H
#include <url.h>
#endif
SOFIA_BEGIN_DECLS
/* ---------------------------------------------------------------------------
* 1) Header class definitions.
*/
......@@ -95,6 +90,10 @@
}}
#endif
/* Mark headers critical for understanding the message */
#define msg_kind_single_critical msg_kind_single, 1
#define msg_kind_list_critical msg_kind_list, 1
int msg_extract_header(msg_t *msg, msg_pub_t *mo, char b[], int bsiz, int eos);
int msg_extract_separator(msg_t *msg, msg_pub_t *mo, char b[], int bsiz, int eos);
int msg_extract_payload(msg_t *msg, msg_pub_t *mo,
......@@ -311,4 +310,6 @@ static inline void *msg_header_data(msg_frg_t *h)
return NULL;
}
SOFIA_END_DECLS
#endif /** MSG_PARSER_H */
......@@ -43,13 +43,12 @@
* @date Created: Fri Aug 16 19:18:26 EEST 2002 ppessi
*/
#ifndef MSG_DLL_H
#include <msg_dll.h>
#endif
#ifndef MSG_TYPES_H
#include <msg_types.h>
#ifndef MSG_HEADER_H
#include <msg_header.h>
#endif
SOFIA_BEGIN_DECLS
enum {
msg_request_hash = -1,
msg_status_hash = -2
......@@ -306,4 +305,6 @@ su_inline msg_#xxxxxx#_t *msg_#xxxxxx#_format(su_home_t *home, char const *fmt,
/** @} */