msg 1.12.11devel
|
00001 /* 00002 * This file is part of the Sofia-SIP package 00003 * 00004 * Copyright (C) 2005 Nokia Corporation. 00005 * 00006 * Contact: Pekka Pessi <pekka.pessi@nokia-email.address.hidden> 00007 * 00008 * This library is free software; you can redistribute it and/or 00009 * modify it under the terms of the GNU Lesser General Public License 00010 * as published by the Free Software Foundation; either version 2.1 of 00011 * the License, or (at your option) any later version. 00012 * 00013 * This library is distributed in the hope that it will be useful, but 00014 * WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 * Lesser General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public 00019 * License along with this library; if not, write to the Free Software 00020 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 00021 * 02110-1301 USA 00022 * 00023 */ 00024 00025 #ifndef MSG_PROTOS_H 00026 00027 #define MSG_PROTOS_H 00028 00041 #ifndef MSG_HEADER_H 00042 #include <sofia-sip/msg_header.h> 00043 #endif 00044 00045 SOFIA_BEGIN_DECLS 00046 00047 enum { 00048 msg_request_hash = -1, 00049 msg_status_hash = -2 00050 }; 00051 00052 00053 /* Declare internal prototypes for unknown headers */ 00054 00059 enum { 00061 msg_unknown_hash = -3 00062 }; 00063 00065 MSG_DLL msg_parse_f msg_unknown_d; 00066 00068 MSG_DLL msg_print_f msg_unknown_e; 00069 00078 MSG_DLL extern msg_hclass_t msg_unknown_class[]; 00079 00091 #define MSG_UNKNOWN_INIT() MSG_HDR_INIT(unknown) 00092 00107 #if SU_HAVE_INLINE 00108 su_inline msg_unknown_t *msg_unknown_init(msg_unknown_t x[1]) 00109 { 00110 return MSG_HEADER_INIT(x, msg_unknown_class, sizeof(msg_unknown_t)); 00111 } 00112 #else 00113 #define msg_unknown_init(x) \ 00114 MSG_HEADER_INIT(x, msg_unknown_class, sizeof(msg_unknown_t)) 00115 #endif 00116 00130 #if SU_HAVE_INLINE 00131 su_inline int msg_is_unknown(msg_header_t const *header) 00132 { 00133 msg_generic_t const *h = (msg_generic_t *)header; 00134 return h && h->g_common->h_class->hc_hash == msg_unknown_hash; 00135 } 00136 #else 00137 int msg_is_unknown(msg_header_t const *header); 00138 #endif 00139 00167 #if SU_HAVE_INLINE 00168 su_inline 00169 #endif 00170 msg_unknown_t *msg_unknown_dup(su_home_t *home, 00171 msg_unknown_t const *header) 00172 __attribute__((__malloc__)); 00173 00174 #if SU_HAVE_INLINE 00175 su_inline 00176 msg_unknown_t *msg_unknown_dup(su_home_t *home, 00177 msg_unknown_t const *header) 00178 { 00179 return (msg_unknown_t *) 00180 msg_header_dup_as(home, msg_unknown_class, (msg_header_t const *)header); 00181 } 00182 #endif 00183 00184 00213 #if SU_HAVE_INLINE 00214 su_inline 00215 #endif 00216 msg_unknown_t *msg_unknown_copy(su_home_t *home, 00217 msg_unknown_t const *header) 00218 __attribute__((__malloc__)); 00219 00220 #if SU_HAVE_INLINE 00221 su_inline 00222 msg_unknown_t *msg_unknown_copy(su_home_t *home, 00223 msg_unknown_t const *header) 00224 { 00225 return (msg_unknown_t *) 00226 msg_header_copy_as(home, msg_unknown_class, (msg_header_t const *)header); 00227 } 00228 #endif 00229 00248 #if SU_HAVE_INLINE 00249 su_inline msg_unknown_t *msg_unknown_make(su_home_t *home, char const *s) 00250 { 00251 return (msg_unknown_t*)msg_header_make(home, msg_unknown_class, s); 00252 } 00253 #else 00254 msg_unknown_t *msg_unknown_make(su_home_t *home, char const *s) 00255 __attribute__((__malloc__)); 00256 #endif 00257 00280 #if SU_HAVE_INLINE 00281 su_inline 00282 #endif 00283 msg_unknown_t *msg_unknown_format(su_home_t *home, char const *fmt, ...) 00284 __attribute__((__malloc__, __format__ (printf, 2, 3))); 00285 00286 #if SU_HAVE_INLINE 00287 su_inline msg_unknown_t *msg_unknown_format(su_home_t *home, char const *fmt, ...) 00288 { 00289 msg_header_t *h; 00290 va_list ap; 00291 00292 va_start(ap, fmt); 00293 h = msg_header_vformat(home, msg_unknown_class, fmt, ap); 00294 va_end(ap); 00295 00296 return (msg_unknown_t*)h; 00297 } 00298 #endif 00299 00302 /* Declare internal prototypes for erroneous headers */ 00303 00308 enum { 00310 msg_error_hash = -4 00311 }; 00312 00314 MSG_DLL msg_parse_f msg_error_d; 00315 00317 MSG_DLL msg_print_f msg_error_e; 00318 00327 MSG_DLL extern msg_hclass_t msg_error_class[]; 00328 00340 #define MSG_ERROR_INIT() MSG_HDR_INIT(error) 00341 00356 #if SU_HAVE_INLINE 00357 su_inline msg_error_t *msg_error_init(msg_error_t x[1]) 00358 { 00359 return MSG_HEADER_INIT(x, msg_error_class, sizeof(msg_error_t)); 00360 } 00361 #else 00362 #define msg_error_init(x) \ 00363 MSG_HEADER_INIT(x, msg_error_class, sizeof(msg_error_t)) 00364 #endif 00365 00379 #if SU_HAVE_INLINE 00380 su_inline int msg_is_error(msg_header_t const *header) 00381 { 00382 msg_generic_t const *h = (msg_generic_t *)header; 00383 return h && h->g_common->h_class->hc_hash == msg_error_hash; 00384 } 00385 #else 00386 int msg_is_error(msg_header_t const *header); 00387 #endif 00388 00416 #if SU_HAVE_INLINE 00417 su_inline 00418 #endif 00419 msg_error_t *msg_error_dup(su_home_t *home, 00420 msg_error_t const *header) 00421 __attribute__((__malloc__)); 00422 00423 #if SU_HAVE_INLINE 00424 su_inline 00425 msg_error_t *msg_error_dup(su_home_t *home, 00426 msg_error_t const *header) 00427 { 00428 return (msg_error_t *) 00429 msg_header_dup_as(home, msg_error_class, (msg_header_t const *)header); 00430 } 00431 #endif 00432 00433 00462 #if SU_HAVE_INLINE 00463 su_inline 00464 #endif 00465 msg_error_t *msg_error_copy(su_home_t *home, 00466 msg_error_t const *header) 00467 __attribute__((__malloc__)); 00468 00469 #if SU_HAVE_INLINE 00470 su_inline 00471 msg_error_t *msg_error_copy(su_home_t *home, 00472 msg_error_t const *header) 00473 { 00474 return (msg_error_t *) 00475 msg_header_copy_as(home, msg_error_class, (msg_header_t const *)header); 00476 } 00477 #endif 00478 00497 #if SU_HAVE_INLINE 00498 su_inline msg_error_t *msg_error_make(su_home_t *home, char const *s) 00499 { 00500 return (msg_error_t*)msg_header_make(home, msg_error_class, s); 00501 } 00502 #else 00503 msg_error_t *msg_error_make(su_home_t *home, char const *s) 00504 __attribute__((__malloc__)); 00505 #endif 00506 00529 #if SU_HAVE_INLINE 00530 su_inline 00531 #endif 00532 msg_error_t *msg_error_format(su_home_t *home, char const *fmt, ...) 00533 __attribute__((__malloc__, __format__ (printf, 2, 3))); 00534 00535 #if SU_HAVE_INLINE 00536 su_inline msg_error_t *msg_error_format(su_home_t *home, char const *fmt, ...) 00537 { 00538 msg_header_t *h; 00539 va_list ap; 00540 00541 va_start(ap, fmt); 00542 h = msg_header_vformat(home, msg_error_class, fmt, ap); 00543 va_end(ap); 00544 00545 return (msg_error_t*)h; 00546 } 00547 #endif 00548 00551 /* Declare internal prototypes for separator line between headers and body */ 00552 00557 enum { 00559 msg_separator_hash = -5 00560 }; 00561 00563 MSG_DLL msg_parse_f msg_separator_d; 00564 00566 MSG_DLL msg_print_f msg_separator_e; 00567 00576 MSG_DLL extern msg_hclass_t msg_separator_class[]; 00577 00589 #define MSG_SEPARATOR_INIT() MSG_HDR_INIT(separator) 00590 00605 #if SU_HAVE_INLINE 00606 su_inline msg_separator_t *msg_separator_init(msg_separator_t x[1]) 00607 { 00608 return MSG_HEADER_INIT(x, msg_separator_class, sizeof(msg_separator_t)); 00609 } 00610 #else 00611 #define msg_separator_init(x) \ 00612 MSG_HEADER_INIT(x, msg_separator_class, sizeof(msg_separator_t)) 00613 #endif 00614 00628 #if SU_HAVE_INLINE 00629 su_inline int msg_is_separator(msg_header_t const *header) 00630 { 00631 msg_generic_t const *h = (msg_generic_t *)header; 00632 return h && h->g_common->h_class->hc_hash == msg_separator_hash; 00633 } 00634 #else 00635 int msg_is_separator(msg_header_t const *header); 00636 #endif 00637 00665 #if SU_HAVE_INLINE 00666 su_inline 00667 #endif 00668 msg_separator_t *msg_separator_dup(su_home_t *home, 00669 msg_separator_t const *header) 00670 __attribute__((__malloc__)); 00671 00672 #if SU_HAVE_INLINE 00673 su_inline 00674 msg_separator_t *msg_separator_dup(su_home_t *home, 00675 msg_separator_t const *header) 00676 { 00677 return (msg_separator_t *) 00678 msg_header_dup_as(home, msg_separator_class, (msg_header_t const *)header); 00679 } 00680 #endif 00681 00682 00711 #if SU_HAVE_INLINE 00712 su_inline 00713 #endif 00714 msg_separator_t *msg_separator_copy(su_home_t *home, 00715 msg_separator_t const *header) 00716 __attribute__((__malloc__)); 00717 00718 #if SU_HAVE_INLINE 00719 su_inline 00720 msg_separator_t *msg_separator_copy(su_home_t *home, 00721 msg_separator_t const *header) 00722 { 00723 return (msg_separator_t *) 00724 msg_header_copy_as(home, msg_separator_class, (msg_header_t const *)header); 00725 } 00726 #endif 00727 00746 #if SU_HAVE_INLINE 00747 su_inline msg_separator_t *msg_separator_make(su_home_t *home, char const *s) 00748 { 00749 return (msg_separator_t*)msg_header_make(home, msg_separator_class, s); 00750 } 00751 #else 00752 msg_separator_t *msg_separator_make(su_home_t *home, char const *s) 00753 __attribute__((__malloc__)); 00754 #endif 00755 00778 #if SU_HAVE_INLINE 00779 su_inline 00780 #endif 00781 msg_separator_t *msg_separator_format(su_home_t *home, char const *fmt, ...) 00782 __attribute__((__malloc__, __format__ (printf, 2, 3))); 00783 00784 #if SU_HAVE_INLINE 00785 su_inline msg_separator_t *msg_separator_format(su_home_t *home, char const *fmt, ...) 00786 { 00787 msg_header_t *h; 00788 va_list ap; 00789 00790 va_start(ap, fmt); 00791 h = msg_header_vformat(home, msg_separator_class, fmt, ap); 00792 va_end(ap); 00793 00794 return (msg_separator_t*)h; 00795 } 00796 #endif 00797 00800 /* Declare internal prototypes for message payload */ 00801 00806 enum { 00808 msg_payload_hash = -6 00809 }; 00810 00812 MSG_DLL msg_parse_f msg_payload_d; 00813 00815 MSG_DLL msg_print_f msg_payload_e; 00816 00825 MSG_DLL extern msg_hclass_t msg_payload_class[]; 00826 00838 #define MSG_PAYLOAD_INIT() MSG_HDR_INIT(payload) 00839 00854 #if SU_HAVE_INLINE 00855 su_inline msg_payload_t *msg_payload_init(msg_payload_t x[1]) 00856 { 00857 return MSG_HEADER_INIT(x, msg_payload_class, sizeof(msg_payload_t)); 00858 } 00859 #else 00860 #define msg_payload_init(x) \ 00861 MSG_HEADER_INIT(x, msg_payload_class, sizeof(msg_payload_t)) 00862 #endif 00863 00877 #if SU_HAVE_INLINE 00878 su_inline int msg_is_payload(msg_header_t const *header) 00879 { 00880 msg_generic_t const *h = (msg_generic_t *)header; 00881 return h && h->g_common->h_class->hc_hash == msg_payload_hash; 00882 } 00883 #else 00884 int msg_is_payload(msg_header_t const *header); 00885 #endif 00886 00914 #if SU_HAVE_INLINE 00915 su_inline 00916 #endif 00917 msg_payload_t *msg_payload_dup(su_home_t *home, 00918 msg_payload_t const *header) 00919 __attribute__((__malloc__)); 00920 00921 #if SU_HAVE_INLINE 00922 su_inline 00923 msg_payload_t *msg_payload_dup(su_home_t *home, 00924 msg_payload_t const *header) 00925 { 00926 return (msg_payload_t *) 00927 msg_header_dup_as(home, msg_payload_class, (msg_header_t const *)header); 00928 } 00929 #endif 00930 00931 00960 #if SU_HAVE_INLINE 00961 su_inline 00962 #endif 00963 msg_payload_t *msg_payload_copy(su_home_t *home, 00964 msg_payload_t const *header) 00965 __attribute__((__malloc__)); 00966 00967 #if SU_HAVE_INLINE 00968 su_inline 00969 msg_payload_t *msg_payload_copy(su_home_t *home, 00970 msg_payload_t const *header) 00971 { 00972 return (msg_payload_t *) 00973 msg_header_copy_as(home, msg_payload_class, (msg_header_t const *)header); 00974 } 00975 #endif 00976 00995 #if SU_HAVE_INLINE 00996 su_inline msg_payload_t *msg_payload_make(su_home_t *home, char const *s) 00997 { 00998 return (msg_payload_t*)msg_header_make(home, msg_payload_class, s); 00999 } 01000 #else 01001 msg_payload_t *msg_payload_make(su_home_t *home, char const *s) 01002 __attribute__((__malloc__)); 01003 #endif 01004 01027 #if SU_HAVE_INLINE 01028 su_inline 01029 #endif 01030 msg_payload_t *msg_payload_format(su_home_t *home, char const *fmt, ...) 01031 __attribute__((__malloc__, __format__ (printf, 2, 3))); 01032 01033 #if SU_HAVE_INLINE 01034 su_inline msg_payload_t *msg_payload_format(su_home_t *home, char const *fmt, ...) 01035 { 01036 msg_header_t *h; 01037 va_list ap; 01038 01039 va_start(ap, fmt); 01040 h = msg_header_vformat(home, msg_payload_class, fmt, ap); 01041 va_end(ap); 01042 01043 return (msg_payload_t*)h; 01044 } 01045 #endif 01046 01050 SOFIA_END_DECLS 01051 01052 #endif