2006-12-21 06:30:28 +00:00
|
|
|
|
/**@ingroup msg -*- c -*-
|
|
|
|
|
* @file sofia-sip/msg_mime_protos.h.in
|
|
|
|
|
*
|
|
|
|
|
* Template for <msg_mime_protos.h>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* This file is part of the Sofia-SIP package
|
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2005 Nokia Corporation.
|
|
|
|
|
*
|
|
|
|
|
* Contact: Pekka Pessi <pekka.pessi@nokia.com>
|
|
|
|
|
*
|
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU Lesser General Public License
|
|
|
|
|
* as published by the Free Software Foundation; either version 2.1 of
|
|
|
|
|
* the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This library is distributed in the hope that it will be useful, but
|
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
|
|
|
|
* 02110-1301 USA
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef MSG_MIME_PROTOS_H
|
|
|
|
|
/** Defined when <sofia-sip/msg_mime_protos.h> has been included. */
|
2008-12-16 18:05:22 +00:00
|
|
|
|
#define MSG_MIME_PROTOS_H
|
2006-12-21 06:30:28 +00:00
|
|
|
|
|
|
|
|
|
/**@ingroup msg_mime
|
|
|
|
|
* @file sofia-sip/msg_mime_protos.h
|
|
|
|
|
*
|
|
|
|
|
* Prototypes for MIME headers (@RFC2045).
|
|
|
|
|
*
|
|
|
|
|
* #AUTO#
|
|
|
|
|
*
|
|
|
|
|
* @author Pekka Pessi <Pekka.Pessi@nokia.com>
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef MSG_PARSER_H
|
|
|
|
|
#include <sofia-sip/msg_parser.h>
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef MSG_MIME_H
|
|
|
|
|
#include <sofia-sip/msg_mime.h>
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef MSG_MCLASS_H
|
|
|
|
|
#include <sofia-sip/msg_mclass.h>
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef MSG_MCLASS_H
|
|
|
|
|
#include <sofia-sip/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)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Declare internal prototypes for #xxxxxxx_xxxxxxx# */
|
|
|
|
|
|
2008-12-16 18:05:22 +00:00
|
|
|
|
/**@addtogroup msg_#xxxxxx#
|
|
|
|
|
* @{
|
2006-12-21 06:30:28 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2008-12-16 18:05:22 +00:00
|
|
|
|
enum {
|
2006-12-21 06:30:28 +00:00
|
|
|
|
/** Hash of #xxxxxxx_xxxxxxx#. @internal */
|
2008-12-16 18:05:22 +00:00
|
|
|
|
msg_#xxxxxx#_hash = #hash#
|
2006-12-21 06:30:28 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** Parse a #xxxxxxx_xxxxxxx#. @internal */
|
|
|
|
|
MSG_DLL msg_parse_f msg_#xxxxxx#_d;
|
|
|
|
|
|
|
|
|
|
/** Print a #xxxxxxx_xxxxxxx#. @internal */
|
|
|
|
|
MSG_DLL msg_print_f msg_#xxxxxx#_e;
|
|
|
|
|
|
|
|
|
|
MSG_DLL msg_xtra_f msg_#xxxxxx#_dup_xtra;
|
|
|
|
|
MSG_DLL msg_dup_f msg_#xxxxxx#_dup_one;
|
|
|
|
|
|
|
|
|
|
/**Header class for #xxxxxxx_xxxxxxx#.
|
2008-12-16 18:05:22 +00:00
|
|
|
|
*
|
|
|
|
|
* The header class msg_#xxxxxx#_class defines how a
|
2006-12-21 06:30:28 +00:00
|
|
|
|
* #xxxxxxx_xxxxxxx# header is parsed and printed. It also
|
|
|
|
|
* contains methods used by message parser and other functions
|
|
|
|
|
* to manipulate the #msg_#xxxxxx#_t header structure.
|
2008-12-16 18:05:22 +00:00
|
|
|
|
*
|
2006-12-21 06:30:28 +00:00
|
|
|
|
*/
|
|
|
|
|
#ifndef msg_#xxxxxx#_class
|
|
|
|
|
MSG_DLL extern msg_hclass_t msg_#xxxxxx#_class[];
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/**Initializer for an #msg_#xxxxxx#_t structure.
|
2008-12-16 18:05:22 +00:00
|
|
|
|
*
|
2006-12-21 06:30:28 +00:00
|
|
|
|
* A static msg_#xxxxxx#_t structure must be initialized
|
|
|
|
|
* with the MSG_#XXXXXX#_INIT() macro. For instance,
|
2008-12-16 18:05:22 +00:00
|
|
|
|
* @code
|
|
|
|
|
*
|
2006-12-21 06:30:28 +00:00
|
|
|
|
* msg_#xxxxxx#_t msg_#xxxxxx# = MSG_#XXXXXX#_INIT;
|
2008-12-16 18:05:22 +00:00
|
|
|
|
*
|
2006-12-21 06:30:28 +00:00
|
|
|
|
* @endcode
|
|
|
|
|
* @HI
|
|
|
|
|
*/
|
|
|
|
|
#define MSG_#XXXXXX#_INIT() MSG_HDR_INIT(#xxxxxx#)
|
|
|
|
|
|
|
|
|
|
/**Initialize an #msg_#xxxxxx#_t structure.
|
2008-12-16 18:05:22 +00:00
|
|
|
|
*
|
2006-12-21 06:30:28 +00:00
|
|
|
|
* An #msg_#xxxxxx#_t structure can be initialized with the
|
|
|
|
|
* msg_#xxxxxx#_init() function/macro. For instance,
|
|
|
|
|
* @code
|
2008-12-16 18:05:22 +00:00
|
|
|
|
*
|
2006-12-21 06:30:28 +00:00
|
|
|
|
* msg_#xxxxxx#_t msg_#xxxxxx#;
|
2008-12-16 18:05:22 +00:00
|
|
|
|
*
|
2006-12-21 06:30:28 +00:00
|
|
|
|
* msg_#xxxxxx#_init(&msg_#xxxxxx#);
|
2008-12-16 18:05:22 +00:00
|
|
|
|
*
|
2006-12-21 06:30:28 +00:00
|
|
|
|
* @endcode
|
2008-12-16 18:05:22 +00:00
|
|
|
|
*
|
|
|
|
|
* @param x pointer to #msg_#xxxxxx#_t structure
|
2006-12-21 06:30:28 +00:00
|
|
|
|
*/
|
|
|
|
|
#if SU_HAVE_INLINE
|
|
|
|
|
su_inline msg_#xxxxxx#_t *msg_#xxxxxx#_init(msg_#xxxxxx#_t x[1])
|
|
|
|
|
{
|
|
|
|
|
return MSG_HEADER_INIT(x, msg_#xxxxxx#_class, sizeof(msg_#xxxxxx#_t));
|
|
|
|
|
}
|
|
|
|
|
#else
|
|
|
|
|
#define msg_#xxxxxx#_init(x) \
|
|
|
|
|
MSG_HEADER_INIT(x, msg_#xxxxxx#_class, sizeof(msg_#xxxxxx#_t))
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/**Test if header object is an instance of #msg_#xxxxxx#_t.
|
2008-12-16 18:05:22 +00:00
|
|
|
|
*
|
2006-12-21 06:30:28 +00:00
|
|
|
|
* The function msg_is_#xxxxxx#() returns true (nonzero) if
|
|
|
|
|
* the header class is an instance of #xxxxxxx_xxxxxxx#
|
|
|
|
|
* object and false (zero) otherwise.
|
2008-12-16 18:05:22 +00:00
|
|
|
|
*
|
2006-12-21 06:30:28 +00:00
|
|
|
|
* @param header pointer to the header structure to be tested
|
2008-12-16 18:05:22 +00:00
|
|
|
|
*
|
2006-12-21 06:30:28 +00:00
|
|
|
|
* @return The function msg_is_#xxxxxx#() returns true (nonzero) if the
|
|
|
|
|
* header object is an instance of header #xxxxxxx_xxxxxxx# and false (zero)
|
|
|
|
|
* otherwise.
|
|
|
|
|
*/
|
|
|
|
|
#if SU_HAVE_INLINE
|
|
|
|
|
su_inline int msg_is_#xxxxxx#(msg_header_t const *header)
|
|
|
|
|
{
|
|
|
|
|
return header && header->sh_class->hc_hash == msg_#xxxxxx#_hash;
|
|
|
|
|
}
|
|
|
|
|
#else
|
|
|
|
|
int msg_is_#xxxxxx#(msg_header_t const *header);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#define msg_#xxxxxx#_p(h) msg_is_#xxxxxx#((h))
|
|
|
|
|
|
|
|
|
|
/**Duplicate (deep copy) #msg_#xxxxxx#_t.
|
2008-12-16 18:05:22 +00:00
|
|
|
|
*
|
2006-12-21 06:30:28 +00:00
|
|
|
|
* The function msg_#xxxxxx#_dup() duplicates a header structure @a
|
|
|
|
|
* header. If the header structure @a header contains a reference
|
|
|
|
|
* (@c header->x_next) to a list of headers, all the headers in the
|
|
|
|
|
* list are duplicated, too.
|
2008-12-16 18:05:22 +00:00
|
|
|
|
*
|
2006-12-21 06:30:28 +00:00
|
|
|
|
* @param home memory home used to allocate new structure
|
|
|
|
|
* @param header header structure to be duplicated
|
2008-12-16 18:05:22 +00:00
|
|
|
|
*
|
2006-12-21 06:30:28 +00:00
|
|
|
|
* When duplicating, all parameter lists and non-constant strings
|
|
|
|
|
* attached to the header are copied, too. The function uses given
|
|
|
|
|
* memory @a home to allocate all the memory areas used to copy the
|
|
|
|
|
* header.
|
2008-12-16 18:05:22 +00:00
|
|
|
|
*
|
2006-12-21 06:30:28 +00:00
|
|
|
|
* @par Example
|
|
|
|
|
* @code
|
2008-12-16 18:05:22 +00:00
|
|
|
|
*
|
2006-12-21 06:30:28 +00:00
|
|
|
|
* #xxxxxx# = msg_#xxxxxx#_dup(home, msg->msg_#xxxxxx#);
|
2008-12-16 18:05:22 +00:00
|
|
|
|
*
|
2006-12-21 06:30:28 +00:00
|
|
|
|
* @endcode
|
2008-12-16 18:05:22 +00:00
|
|
|
|
*
|
2006-12-21 06:30:28 +00:00
|
|
|
|
* @return
|
|
|
|
|
* The function msg_#xxxxxx#_dup() returns a pointer to the
|
|
|
|
|
* newly duplicated #msg_#xxxxxx#_t header structure, or NULL
|
|
|
|
|
* upon an error.
|
|
|
|
|
*/
|
|
|
|
|
#if SU_HAVE_INLINE
|
|
|
|
|
su_inline
|
|
|
|
|
#endif
|
2008-12-16 18:05:22 +00:00
|
|
|
|
msg_#xxxxxx#_t *msg_#xxxxxx#_dup(su_home_t *home,
|
2006-12-21 06:30:28 +00:00
|
|
|
|
msg_#xxxxxx#_t const *header);
|
|
|
|
|
|
|
|
|
|
#if SU_HAVE_INLINE
|
|
|
|
|
su_inline
|
2008-12-16 18:05:22 +00:00
|
|
|
|
msg_#xxxxxx#_t *msg_#xxxxxx#_dup(su_home_t *home,
|
2006-12-21 06:30:28 +00:00
|
|
|
|
msg_#xxxxxx#_t const *header)
|
|
|
|
|
{
|
|
|
|
|
return (msg_#xxxxxx#_t *)
|
2008-12-16 18:05:22 +00:00
|
|
|
|
msg_header_dup_as(home, msg_#xxxxxx#_class, (msg_header_t const *)header);
|
2006-12-21 06:30:28 +00:00
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**Copy an #msg_#xxxxxx#_t header structure.
|
2008-12-16 18:05:22 +00:00
|
|
|
|
*
|
2006-12-21 06:30:28 +00:00
|
|
|
|
* The function msg_#xxxxxx#_copy() copies a header structure @a
|
|
|
|
|
* header. If the header structure @a header contains a reference
|
|
|
|
|
* (@c header->h_next) to a list of headers, all the headers in that
|
|
|
|
|
* list are copied, too. The function uses given memory @a home to
|
|
|
|
|
* allocate all the memory areas used to copy the header structure
|
|
|
|
|
* @a header.
|
2008-12-16 18:05:22 +00:00
|
|
|
|
*
|
2006-12-21 06:30:28 +00:00
|
|
|
|
* @param home memory home used to allocate new structure
|
|
|
|
|
* @param header pointer to the header structure to be duplicated
|
2008-12-16 18:05:22 +00:00
|
|
|
|
*
|
2006-12-21 06:30:28 +00:00
|
|
|
|
* When copying, only the header structure and parameter lists
|
|
|
|
|
* attached to it are duplicated. The new header structure retains
|
|
|
|
|
* all the references to the strings within the old @a header,
|
|
|
|
|
* including the encoding of the old header, if present.
|
2008-12-16 18:05:22 +00:00
|
|
|
|
*
|
2006-12-21 06:30:28 +00:00
|
|
|
|
* @par Example
|
|
|
|
|
* @code
|
2008-12-16 18:05:22 +00:00
|
|
|
|
*
|
2006-12-21 06:30:28 +00:00
|
|
|
|
* #xxxxxx# = msg_#xxxxxx#_copy(home, msg->msg_#xxxxxx#);
|
2008-12-16 18:05:22 +00:00
|
|
|
|
*
|
2006-12-21 06:30:28 +00:00
|
|
|
|
* @endcode
|
2008-12-16 18:05:22 +00:00
|
|
|
|
*
|
2006-12-21 06:30:28 +00:00
|
|
|
|
* @return
|
|
|
|
|
* The function msg_#xxxxxx#_copy() returns a pointer to
|
|
|
|
|
* newly copied header structure, or NULL upon an error.
|
|
|
|
|
*/
|
|
|
|
|
#if SU_HAVE_INLINE
|
|
|
|
|
su_inline
|
|
|
|
|
#endif
|
2008-12-16 18:05:22 +00:00
|
|
|
|
msg_#xxxxxx#_t *msg_#xxxxxx#_copy(su_home_t *home,
|
2006-12-21 06:30:28 +00:00
|
|
|
|
msg_#xxxxxx#_t const *header);
|
|
|
|
|
|
|
|
|
|
#if SU_HAVE_INLINE
|
|
|
|
|
su_inline
|
2008-12-16 18:05:22 +00:00
|
|
|
|
msg_#xxxxxx#_t *msg_#xxxxxx#_copy(su_home_t *home,
|
2006-12-21 06:30:28 +00:00
|
|
|
|
msg_#xxxxxx#_t const *header)
|
|
|
|
|
{
|
|
|
|
|
return (msg_#xxxxxx#_t *)
|
2008-12-16 18:05:22 +00:00
|
|
|
|
msg_header_copy_as(home, msg_#xxxxxx#_class, (msg_header_t const *)header);
|
2006-12-21 06:30:28 +00:00
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**Make a header structure #msg_#xxxxxx#_t.
|
2008-12-16 18:05:22 +00:00
|
|
|
|
*
|
2006-12-21 06:30:28 +00:00
|
|
|
|
* The function msg_#xxxxxx#_make() makes a new #msg_#xxxxxx#_t header
|
|
|
|
|
* structure. It allocates a new header structure, and decodes the string @a
|
|
|
|
|
* s as the value of the structure.
|
2008-12-16 18:05:22 +00:00
|
|
|
|
*
|
2006-12-21 06:30:28 +00:00
|
|
|
|
* @param home memory home used to allocate new header structure.
|
|
|
|
|
* @param s string to be decoded as value of the new header structure
|
2008-12-16 18:05:22 +00:00
|
|
|
|
*
|
2006-12-21 06:30:28 +00:00
|
|
|
|
* @note This function may be implemented as a macro calling
|
|
|
|
|
* msg_header_make().
|
2008-12-16 18:05:22 +00:00
|
|
|
|
*
|
2006-12-21 06:30:28 +00:00
|
|
|
|
* @return
|
|
|
|
|
* The function msg_#xxxxxx#_make() returns a pointer to newly maked
|
|
|
|
|
* #msg_#xxxxxx#_t header structure, or NULL upon an error.
|
|
|
|
|
*/
|
|
|
|
|
#if SU_HAVE_INLINE
|
|
|
|
|
su_inline msg_#xxxxxx#_t *msg_#xxxxxx#_make(su_home_t *home, char const *s)
|
|
|
|
|
{
|
|
|
|
|
return (msg_#xxxxxx#_t*)msg_header_make(home, msg_#xxxxxx#_class, s);
|
|
|
|
|
}
|
|
|
|
|
#else
|
|
|
|
|
msg_#xxxxxx#_t *msg_#xxxxxx#_make(su_home_t *home, char const *s);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**Make a #xxxxxxx_xxxxxxx# from formatting result.
|
2008-12-16 18:05:22 +00:00
|
|
|
|
*
|
2006-12-21 06:30:28 +00:00
|
|
|
|
* The function msg_#xxxxxx#_format() makes a new #xxxxxxx_xxxxxxx# object
|
|
|
|
|
* using snprintf-formatted result as its value. The function first
|
|
|
|
|
* prints the arguments according to the format @a fmt specified. Then it
|
|
|
|
|
* allocates a new header structure, and uses the formatting result as the
|
|
|
|
|
* header value.
|
2008-12-16 18:05:22 +00:00
|
|
|
|
*
|
2006-12-21 06:30:28 +00:00
|
|
|
|
* @param home memory home used to allocate new header structure.
|
|
|
|
|
* @param fmt string used as a printf()-style format
|
|
|
|
|
* @param ... argument list for format
|
2008-12-16 18:05:22 +00:00
|
|
|
|
*
|
2006-12-21 06:30:28 +00:00
|
|
|
|
* @note This function may be implemented as a macro calling
|
|
|
|
|
* msg_header_format().
|
2008-12-16 18:05:22 +00:00
|
|
|
|
*
|
2006-12-21 06:30:28 +00:00
|
|
|
|
* @return
|
|
|
|
|
* The function msg_#xxxxxx#_format() returns a pointer to newly
|
|
|
|
|
* makes header structure, or NULL upon an error.
|
2008-12-16 18:05:22 +00:00
|
|
|
|
*
|
2006-12-21 06:30:28 +00:00
|
|
|
|
* @HIDE
|
|
|
|
|
*/
|
|
|
|
|
#if SU_HAVE_INLINE
|
|
|
|
|
su_inline
|
|
|
|
|
#endif
|
|
|
|
|
msg_#xxxxxx#_t *msg_#xxxxxx#_format(su_home_t *home, char const *fmt, ...)
|
|
|
|
|
__attribute__((__format__ (printf, 2, 3)));
|
|
|
|
|
|
|
|
|
|
#if SU_HAVE_INLINE
|
|
|
|
|
su_inline msg_#xxxxxx#_t *msg_#xxxxxx#_format(su_home_t *home, char const *fmt, ...)
|
|
|
|
|
{
|
|
|
|
|
msg_header_t *h;
|
|
|
|
|
va_list ap;
|
2008-12-16 18:05:22 +00:00
|
|
|
|
|
2006-12-21 06:30:28 +00:00
|
|
|
|
va_start(ap, fmt);
|
|
|
|
|
h = msg_header_vformat(home, msg_#xxxxxx#_class, fmt, ap);
|
|
|
|
|
va_end(ap);
|
2008-12-16 18:05:22 +00:00
|
|
|
|
|
2006-12-21 06:30:28 +00:00
|
|
|
|
return (msg_#xxxxxx#_t*)h;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/** @} */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Internal prototypes */
|
|
|
|
|
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) */
|