test_class.h 5.2 KB
Newer Older
Pekka Pessi's avatar
Pekka Pessi committed
1 2 3 4 5 6 7
/*
 * This file is part of the Sofia-SIP package
 *
 * Copyright (C) 2005 Nokia Corporation.
 *
 * Contact: Pekka Pessi <pekka.pessi@nokia.com>
 *
8
 * This library is free software; you can redistribute it and/or
Pekka Pessi's avatar
Pekka Pessi committed
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
 * 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
 *
 */

25 26 27
#ifndef TEST_CLASS_H
/** Defined when <test_class.h> has been included. */
#define TEST_CLASS_H 
Pekka Pessi's avatar
Pekka Pessi committed
28

29 30
/**@ingroup test_msg
 * @file test_class.h
Pekka Pessi's avatar
Pekka Pessi committed
31 32 33 34 35 36 37
 * @brief Message and header classes for testing.
 *
 * @author Pekka Pessi <Pekka.Pessi@nokia.com>
 *
 * @date Created: Thu Jun 29 15:58:06 2000 ppessi
 */

38
#ifndef URL_H
39
#include <sofia-sip/url.h>
40
#endif
Pekka Pessi's avatar
Pekka Pessi committed
41
#ifndef MSG_H
42
#include <sofia-sip/msg.h>
Pekka Pessi's avatar
Pekka Pessi committed
43 44
#endif
#ifndef MSG_HEADER_H
45
#include <sofia-sip/msg_header.h>
Pekka Pessi's avatar
Pekka Pessi committed
46
#endif
47
#ifndef MSG_MIME_H
48
#include <sofia-sip/msg_mime.h>
49 50
#endif
#ifndef MSG_MCLASS_H
51
#include <sofia-sip/msg_mclass.h>
52 53 54
#endif

SOFIA_BEGIN_DECLS
Pekka Pessi's avatar
Pekka Pessi committed
55

56
#define MSG_TEST_PROTOCOL_TAG ((void *)(size_t)0xdeadbeef)
Pekka Pessi's avatar
Pekka Pessi committed
57 58 59 60 61 62 63 64 65 66 67 68

#define MSG_TEST_VERSION_CURRENT "msg/1.0"

extern msg_mclass_t const msg_test_mclass[1];

extern msg_href_t const msg_content_length_href[1];

typedef struct msg_request_s msg_request_t;
typedef struct msg_status_s  msg_status_t;

/** Request line. */
struct msg_request_s { 
69 70 71 72 73
  msg_common_t     rq_common[1];   /**< Common fragment info */
  msg_header_t    *rq_next;	   /**< Link to next header */
  char const      *rq_method_name; /**< Method name */
  url_t            rq_url[1];	   /**< RequestURI */
  char const      *rq_version;     /**< Protocol version */
Pekka Pessi's avatar
Pekka Pessi committed
74 75 76 77
}; 

/** Status line. */
struct msg_status_s { 
78 79 80 81 82
  msg_common_t   st_common[1];	/**< Common fragment info */
  msg_header_t *st_next;	/**< Link to next (dummy) */
  char const    *st_version;	/**< Protocol version */
  int            st_status;	/**< Status code */
  char const    *st_phrase;	/**< Status phrase */
Pekka Pessi's avatar
Pekka Pessi committed
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
};

/** Message object for tests. */
typedef struct msg_test_s {
  msg_common_t        msg_common[1]; /**< For recursive inclusion */
  msg_pub_t          *msg_next;
  void               *msg_user;	     /**< User data */
  unsigned            msg_size;
  unsigned            msg_flags;
  msg_error_t        *msg_error;

  msg_request_t      *msg_request;
  msg_status_t       *msg_status;

  /* === Headers start here */
  msg_content_type_t     *msg_content_type;     /**< Content-Type */
  msg_content_disposition_t *msg_content_disposition;
                                                /**< Content-Disposition */
  msg_content_location_t *msg_content_location; /**< Content-Location */
  msg_content_language_t *msg_content_language; /**< Content-Language */

  msg_accept_t           *msg_accept;           /**< Accept */
  msg_accept_charset_t   *msg_accept_charset;	/**< Accept-Charset */
  msg_accept_encoding_t  *msg_accept_encoding;	/**< Accept-Encoding */
  msg_accept_language_t  *msg_accept_language;	/**< Accept-Language */
  msg_mime_version_t     *msg_mime_version;	/**< MIME-Version */
  msg_content_md5_t      *msg_content_md5;	/**< Content-MD5 */
  msg_content_encoding_t *msg_content_encoding; 
						/**< Content-Encoding */
  msg_content_length_t   *msg_content_length;	/**< Content-Length */
  /* === Headers end here */

  msg_unknown_t      *msg_unknown;
  msg_separator_t    *msg_separator;
  msg_payload_t      *msg_payload;
  msg_multipart_t    *msg_multipart;
} msg_test_t;

union msg_test_u
{
  msg_common_t    sh_common[1];
  struct {
    msg_common_t  shn_common;
    msg_header_t *shn_next;
  }               sh_header_next[1];

  msg_request_t             sh_request[1];
  msg_status_t              sh_status[1];
  msg_accept_t              sh_accept[1];
  msg_accept_charset_t      sh_accept_charset[1];
  msg_accept_encoding_t     sh_accept_encoding[1];
  msg_accept_language_t     sh_accept_language[1];
  msg_content_disposition_t sh_content_disposition[1];
  msg_content_encoding_t    sh_content_encoding[1];
  msg_content_id_t          sh_content_id[1];
  msg_content_md5_t         sh_content_md5[1];
  msg_content_language_t    sh_content_language[1];
  msg_content_length_t      sh_content_length[1]; 
  msg_content_location_t    sh_content_location[1];
  msg_content_type_t        sh_content_type[1];
  msg_mime_version_t        sh_mime_version[1];

  msg_generic_t   sh_generic[1];
  msg_numeric_t   sh_numeric[1];
  msg_list_t      sh_list[1];
  msg_auth_t      sh_auth[1];
  msg_separator_t sh_separator[1];
  msg_payload_t   sh_payload[1];
  msg_unknown_t   sh_unknown[1];
};

154 155
issize_t msg_test_extract_body(msg_t *, msg_pub_t *,
			       char b[], isize_t bsiz, int eos);
Pekka Pessi's avatar
Pekka Pessi committed
156

157
su_inline
Pekka Pessi's avatar
Pekka Pessi committed
158 159
msg_test_t *msg_test_public(msg_t *msg)
{
160
  return (msg_test_t *)msg_public(msg, MSG_TEST_PROTOCOL_TAG);
Pekka Pessi's avatar
Pekka Pessi committed
161 162
}

163 164
SOFIA_END_DECLS

165
#endif /* !defined(TEST_CLASS_H) */