~ubuntu-branches/ubuntu/wily/sflphone/wily

« back to all changes in this revision

Viewing changes to daemon/libs/pjproject-2.1.0/pjsip/include/pjsip/print_util.h

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2014-01-28 18:23:36 UTC
  • mfrom: (1.1.11)
  • mto: This revision was merged to the branch mainline in revision 24.
  • Revision ID: package-import@ubuntu.com-20140128182336-3xenud1kbnwmf3mz
* New upstream release 
  - Fixes "New Upstream Release" (Closes: #735846)
  - Fixes "Ringtone does not stop" (Closes: #727164)
  - Fixes "[sflphone-kde] crash on startup" (Closes: #718178)
  - Fixes "sflphone GUI crashes when call is hung up" (Closes: #736583)
* Build-Depends: ensure GnuTLS 2.6
  - libucommon-dev (>= 6.0.7-1.1), libccrtp-dev (>= 2.0.6-3)
  - Fixes "FTBFS Build-Depends libgnutls{26,28}-dev" (Closes: #722040)
* Fix "boost 1.49 is going away" unversioned Build-Depends: (Closes: #736746)
* Add Build-Depends: libsndfile-dev, nepomuk-core-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Id: print_util.h 3553 2011-05-05 06:14:19Z nanang $ */
 
2
/* 
 
3
 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
 
4
 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
 
5
 *
 
6
 * This program is free software; you can redistribute it and/or modify
 
7
 * it under the terms of the GNU General Public License as published by
 
8
 * the Free Software Foundation; either version 2 of the License, or
 
9
 * (at your option) any later version.
 
10
 *
 
11
 * This program is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 * GNU General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU General Public License
 
17
 * along with this program; if not, write to the Free Software
 
18
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
 
19
 */
 
20
#ifndef __PJSIP_PRINT_H__
 
21
#define __PJSIP_PRINT_H__
 
22
 
 
23
#define copy_advance_check(buf,str)   \
 
24
        do { \
 
25
            if ((str).slen >= (endbuf-buf)) return -1;  \
 
26
            pj_memcpy(buf, (str).ptr, (str).slen); \
 
27
            buf += (str).slen; \
 
28
        } while (0)
 
29
 
 
30
#define copy_advance_pair_check(buf,str1,len1,str2)   \
 
31
        do { \
 
32
            if (str2.slen) { \
 
33
                printed = len1+str2.slen; \
 
34
                if (printed >= (endbuf-buf)) return -1; \
 
35
                pj_memcpy(buf,str1,len1); \
 
36
                pj_memcpy(buf+len1, str2.ptr, str2.slen); \
 
37
                buf += printed; \
 
38
            } \
 
39
        } while (0)
 
40
 
 
41
#define copy_advance_pair_quote_check(buf,str1,len1,str2,quotebegin,quoteend) \
 
42
        do { \
 
43
            if (str2.slen) { \
 
44
                printed = len1+str2.slen+2; \
 
45
                if (printed >= (endbuf-buf)) return -1; \
 
46
                pj_memcpy(buf,str1,len1); \
 
47
                *(buf+len1)=quotebegin; \
 
48
                pj_memcpy(buf+len1+1, str2.ptr, str2.slen); \
 
49
                *(buf+printed-1) = quoteend; \
 
50
                buf += printed; \
 
51
            } \
 
52
        } while (0)
 
53
 
 
54
#define copy_advance_pair_quote(buf,str1,len1,str2,quotebegin,quoteend) \
 
55
        do { \
 
56
                printed = len1+str2.slen+2; \
 
57
                if (printed >= (endbuf-buf)) return -1; \
 
58
                pj_memcpy(buf,str1,len1); \
 
59
                *(buf+len1)=quotebegin; \
 
60
                pj_memcpy(buf+len1+1, str2.ptr, str2.slen); \
 
61
                *(buf+printed-1) = quoteend; \
 
62
                buf += printed; \
 
63
        } while (0)
 
64
 
 
65
#define copy_advance_pair_escape(buf,str1,len1,str2,unres)      \
 
66
        do { \
 
67
          if (str2.slen) { \
 
68
            if (len1+str2.slen >= (endbuf-buf)) return -1; \
 
69
            pj_memcpy(buf,str1,len1); \
 
70
            printed=pj_strncpy2_escape(buf+len1,&str2,(endbuf-buf-len1),&unres);\
 
71
            if (printed < 0) return -1; \
 
72
            buf += (printed+len1); \
 
73
          } \
 
74
        } while (0)
 
75
 
 
76
 
 
77
#define copy_advance_no_check(buf,str)   \
 
78
        do { \
 
79
            pj_memcpy(buf, (str).ptr, (str).slen); \
 
80
            buf += (str).slen; \
 
81
        } while (0)
 
82
 
 
83
#define copy_advance_escape(buf,str,unres)    \
 
84
        do { \
 
85
            printed = \
 
86
                pj_strncpy2_escape(buf, &(str), (endbuf-buf), &(unres)); \
 
87
            if (printed < 0) return -1; \
 
88
            buf += printed; \
 
89
        } while (0)
 
90
 
 
91
#define copy_advance_pair_no_check(buf,str1,len1,str2)   \
 
92
        if (str2.slen) { \
 
93
            pj_memcpy(buf,str1,len1); \
 
94
            pj_memcpy(buf+len1, str2.ptr, str2.slen); \
 
95
            buf += len1+str2.slen; \
 
96
        }
 
97
 
 
98
#define copy_advance            copy_advance_check
 
99
#define copy_advance_pair       copy_advance_pair_check
 
100
 
 
101
#define copy_advance_pair_quote_cond(buf,str1,len1,str2,quotebegin,quoteend) \
 
102
        do {    \
 
103
          if (str2.slen && *str2.ptr!=quotebegin) \
 
104
            copy_advance_pair_quote(buf,str1,len1,str2,quotebegin,quoteend); \
 
105
          else \
 
106
            copy_advance_pair(buf,str1,len1,str2); \
 
107
        } while (0)
 
108
 
 
109
/*
 
110
 * Internal type declarations.
 
111
 */
 
112
typedef void* (*pjsip_hdr_clone_fptr)(pj_pool_t *, const void*);
 
113
typedef int   (*pjsip_hdr_print_fptr)(void *hdr, char *buf, pj_size_t len);
 
114
 
 
115
typedef struct pjsip_hdr_name_info_t
 
116
{
 
117
    char        *name;
 
118
    unsigned     name_len;
 
119
    char        *sname;
 
120
} pjsip_hdr_name_info_t;
 
121
 
 
122
extern const pjsip_hdr_name_info_t pjsip_hdr_names[];
 
123
 
 
124
PJ_INLINE(void) init_hdr(void *hptr, pjsip_hdr_e htype, void *vptr)
 
125
{
 
126
    pjsip_hdr *hdr = (pjsip_hdr*) hptr;
 
127
    hdr->type = htype;
 
128
    hdr->name.ptr = pjsip_hdr_names[htype].name;
 
129
    hdr->name.slen = pjsip_hdr_names[htype].name_len;
 
130
    if (pjsip_hdr_names[htype].sname) {
 
131
        hdr->sname.ptr = pjsip_hdr_names[htype].sname;
 
132
        hdr->sname.slen = 1;
 
133
    } else {
 
134
        hdr->sname = hdr->name;
 
135
    }
 
136
    hdr->vptr = (pjsip_hdr_vptr*) vptr;
 
137
    pj_list_init(hdr);
 
138
}
 
139
 
 
140
#endif  /* __PJSIP_PRINT_H__ */
 
141