1 /*
2 * $Id: msg_fline.cpp 850 2008-04-04 21:29:36Z sayer $
3 *
4 * Copyright (C) 2007 Raphael Coeffic
5 *
6 * This file is part of SEMS, a free SIP media server.
7 *
8 * SEMS is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version. This program is released under
12 * the GPL with the additional exemption that compiling, linking,
13 * and/or using OpenSSL is allowed.
14 *
15 * For a license to use the SEMS software under conditions
16 * other than those described here, or to purchase support for this
17 * software, please contact iptel.org by e-mail at the following addresses:
18 * info@iptel.org
19 *
20 * SEMS is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 */
29
30
31 #include "msg_fline.h"
32
33 #include <assert.h>
34 #include <stdlib.h>
35
status_code_wr(char ** c,int code)36 inline void status_code_wr(char** c, int code)
37 {
38 div_t d = div(code, 100);
39 *((*c)++) = d.quot + '0';
40 d = div(d.rem, 10);
41 *((*c)++) = d.quot + '0';
42 *((*c)++) = d.rem + '0';
43 }
44
45
status_line_wr(char ** c,int status_code,const cstring & reason)46 void status_line_wr(char** c, int status_code,
47 const cstring& reason)
48 {
49 memcpy(*c,"SIP/2.0 ",8);
50 *c += 8;
51
52 status_code_wr(c,status_code);
53
54 *((*c)++) = SP;
55
56 memcpy(*c,reason.s,reason.len);
57 *c += reason.len;
58
59 *((*c)++) = CR;
60 *((*c)++) = LF;
61 }
62
request_line_wr(char ** c,const cstring & method,const cstring & ruri)63 void request_line_wr(char** c,
64 const cstring& method,
65 const cstring& ruri)
66 {
67 memcpy(*c,method.s,method.len);
68 *c += method.len;
69
70 *((*c)++) = SP;
71
72 memcpy(*c,ruri.s,ruri.len);
73 *c += ruri.len;
74
75 memcpy(*c," SIP/2.0",8);
76 *c += 8;
77
78 *((*c)++) = CR;
79 *((*c)++) = LF;
80 }
81
82
83 /** EMACS **
84 * Local variables:
85 * mode: c++
86 * c-basic-offset: 4
87 * End:
88 */
89