jabberd2
2.2.17
Main Page
Data Structures
Files
File List
Globals
s2s
db.c
Go to the documentation of this file.
1
/*
2
* jabberd - Jabber Open Source Server
3
* Copyright (c) 2002 Jeremie Miller, Thomas Muldowney,
4
* Ryan Eatmon, Robert Norris
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, MA02111-1307USA
19
*/
20
21
/*
22
* this is a minimal sx plugin that hacks the "jabber:server:dialback"
23
* onto outgoing connections and adds "urn:xmpp:features:dialback" feature
24
*/
25
26
#include "
s2s.h
"
27
28
#define S2S_DB_NS_DECL " xmlns:db='" uri_DIALBACK "'"
29
#define S2S_DB_NS_DECL_LEN (uri_DIALBACK_L + 12)
30
31
static
void
_s2s_db_header
(
sx_t
s,
sx_plugin_t
p,
sx_buf_t
buf) {
32
33
if
(!(s->
flags
&
S2S_DB_HEADER
))
34
return
;
35
36
log_debug
(
ZONE
,
"hacking dialback namespace decl onto stream header"
);
37
38
/* get enough space */
39
_sx_buffer_alloc_margin
(buf, 0,
S2S_DB_NS_DECL_LEN
+ 2);
40
41
/* overwrite the trailing ">" with a decl followed by a new ">" */
42
memcpy(&buf->
data
[buf->
len
- 1],
S2S_DB_NS_DECL
">"
,
S2S_DB_NS_DECL_LEN
+1);
43
buf->
len
+=
S2S_DB_NS_DECL_LEN
;
44
}
45
47
static
void
_s2s_db_features
(
sx_t
s,
sx_plugin_t
p,
nad_t
nad) {
48
int
ns;
49
50
ns =
nad_add_namespace
(nad,
uri_URN_DIALBACK
, NULL);
51
nad_append_elem
(nad, ns,
"dialback"
, 1);
52
nad_append_elem
(nad, -1,
"required"
, 2);
53
}
54
55
int
s2s_db_init
(
sx_env_t
env,
sx_plugin_t
p, va_list args) {
56
log_debug
(
ZONE
,
"initialising dialback sx plugin"
);
57
58
p->
header
=
_s2s_db_header
;
59
p->
features
=
_s2s_db_features
;
60
61
return
0;
62
}
Generated by
1.8.1.1