~ubuntu-branches/ubuntu/trusty/ejabberd/trusty-proposed

« back to all changes in this revision

Viewing changes to src/expat_erl.c

  • Committer: Bazaar Package Importer
  • Author(s): Gerfried Fuchs, Konstantin Khomoutov, Gerfried Fuchs
  • Date: 2009-12-04 18:22:49 UTC
  • mfrom: (1.1.11 upstream)
  • Revision ID: james.westby@ubuntu.com-20091204182249-6jfmdz8878h7oaos
Tags: 2.1.0-1
[ Konstantin Khomoutov ]
* New upstream release (Closes: #519858).
  This also adds support for LDAPS upstream (Closes: #526145).
* Do not depend on cdbs anymore, port debian/rules to dh+quilt,
  remove build dependency on patchutils, use erlang-depends.
* Bump debhelper version to 7, standards base to 3.8.3
* Depend on erlang R13B.
* Recommend imagemagick (for captcha support).
* Remove deprecated patches (ssl.patch patch, dynamic_compile_loglevel.patch,
  ldaps.patch, update.patch, proxy.patch, caps.patch, convert.patch,
  s2s.patch).
* Replace mod_ctlextra with mod_admin_extra.
* Use upstream inetrc file.
* Bring debian/ejabberd.cfg and ejabberdctl in sync with upstream.
* Update ejabberdctl manual page.
* Provide NEWS file.
* Rework README.Debian:
  * Group all information into sections.
  * Describe issues with epam binary (Closes: #502791).
  * Discuss how to use DBMS backends (Closes: #540915, #507144).
  * Discuss upgrading from 2.0.x series.
* Implement PID file management (Closes: #519858).
* Make logrotate process all files matching "*.log".
* Improve init script:
  * Make init script LSB-compliant.
  * Implement "live" target which allows to run ejabberd in foreground.
* Make captcha.sh use bash explicitly.
* Rework node-generation for ejabberdctl to fix ejabberd's atom table
  overflows while preserving the possibility to run several versions
  of ejabberdctl concurrently as before.
* Add webadmin patch restoring compatibility with Erlang/OTP <= R12B-4.
* Integrate upstream patch for EJAB-1106.
* Add upstream patch for EJAB-1098.
* Add upstream patch for EJAB-1045.
* Add Konstantin Khomoutov to uploaders.
* Add Japanese debconf translation (thanks to Hideki Yamane)
  (Closes: #558071).

[ Gerfried Fuchs ]
* Build-Depend on po-debconf so po2debconf can be called.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: expat_erl.c 2000 2009-03-24 23:09:46Z badlop $ */
 
1
/*
 
2
 * ejabberd, Copyright (C) 2002-2009   ProcessOne
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or
 
5
 * modify it under the terms of the GNU General Public License as
 
6
 * published by the Free Software Foundation; either version 2 of the
 
7
 * License, or (at your option) any later version.
 
8
 *
 
9
 * This program is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
 * General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU General Public License
 
15
 * along with this program; if not, write to the Free Software
 
16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 
17
 * 02111-1307 USA
 
18
 *
 
19
 */
 
20
 
2
21
 
3
22
#include <stdio.h>
4
23
#include <string.h>
6
25
#include <ei.h>
7
26
#include <expat.h>
8
27
 
9
 
#define EI_ENCODE_STRING_BUG
10
 
 
11
 
#ifdef EI_ENCODE_STRING_BUG
12
 
 
13
 
/*
14
 
 * Workaround for EI encode_string bug
15
 
 */
16
 
 
17
 
int x_fix_buff(ei_x_buff* x, int szneeded);
18
 
 
19
 
#define put8(s,n) do { \
20
 
  (s)[0] = (char)((n) & 0xff); \
21
 
  (s) += 1; \
22
 
} while (0) 
23
 
 
24
 
#define put16be(s,n) do { \
25
 
  (s)[0] = ((n) >>  8) & 0xff; \
26
 
  (s)[1] = (n) & 0xff; \
27
 
  (s) += 2; \
28
 
} while (0)
29
 
 
30
 
#define put32be(s,n) do {  \
31
 
  (s)[0] = ((n) >>  24) & 0xff; \
32
 
  (s)[1] = ((n) >>  16) & 0xff; \
33
 
  (s)[2] = ((n) >>  8) & 0xff;  \
34
 
  (s)[3] = (n) & 0xff; \
35
 
  (s) += 4; \
36
 
} while (0)
37
 
 
38
 
int ei_encode_string_len_fixed(char *buf, int *index, const char *p, int len)
39
 
{
40
 
    char *s = buf + *index;
41
 
    char *s0 = s;
42
 
    int i;
43
 
 
44
 
    if (len <= 0xffff) {
45
 
        if (!buf) s += 3;
46
 
        else {
47
 
            put8(s,ERL_STRING_EXT);
48
 
            put16be(s,len);
49
 
            memmove(s,p,len);   /* unterminated string */
50
 
        }
51
 
        s += len;
52
 
    }
53
 
    else {
54
 
        if (!buf) s += 6 + (2*len);
55
 
        else {
56
 
            /* strings longer than 65535 are encoded as lists */
57
 
            put8(s,ERL_LIST_EXT);
58
 
            put32be(s,len);
59
 
 
60
 
            for (i=0; i<len; i++) {
61
 
                put8(s,ERL_SMALL_INTEGER_EXT);
62
 
                put8(s,p[i]);
63
 
            }
64
 
 
65
 
            put8(s,ERL_NIL_EXT);
66
 
        }
67
 
    }
68
 
 
69
 
    *index += s-s0; 
70
 
 
71
 
    return 0; 
72
 
}
73
 
 
74
 
int ei_encode_string_fixed(char *buf, int *index, const char *p)
75
 
{
76
 
    return ei_encode_string_len_fixed(buf, index, p, strlen(p));
77
 
}
78
 
 
79
 
int ei_x_encode_string_len_fixed(ei_x_buff* x, const char* s, int len)
80
 
{
81
 
    int i = x->index;
82
 
    ei_encode_string_len_fixed(NULL, &i, s, len);
83
 
    if (!x_fix_buff(x, i))
84
 
        return -1;
85
 
    return ei_encode_string_len_fixed(x->buff, &x->index, s, len);
86
 
}
87
 
 
88
 
int ei_x_encode_string_fixed(ei_x_buff* x, const char* s)
89
 
{
90
 
    return ei_x_encode_string_len_fixed(x, s, strlen(s));
91
 
}
92
 
 
93
 
#else
94
 
 
95
 
#define ei_encode_string_len_fixed(buf, index, p, len) \
96
 
        ei_encode_string_len(buf, index, p, len)
97
 
#define ei_encode_string_fixed(buf, index, p) \
98
 
        ei_encode_string(buf, index, p)
99
 
#define ei_x_encode_string_len_fixed(x, s, len) \
100
 
        ei_x_encode_string_len(x, s, len)
101
 
#define ei_x_encode_string_fixed(x, s) \
102
 
        ei_x_encode_string(x, s)
103
 
 
104
 
#endif
105
28
 
106
29
#define XML_START 0
107
30
#define XML_END   1
128
51
   ei_x_encode_tuple_header(&event_buf, 2);
129
52
   ei_x_encode_long(&event_buf, XML_START);
130
53
   ei_x_encode_tuple_header(&event_buf, 2);
131
 
   ei_x_encode_string_fixed(&event_buf, name);
 
54
   ei_x_encode_string(&event_buf, name);
132
55
 
133
56
   for (i = 0; atts[i]; i += 2) {}
134
57
 
139
62
      for (i = 0; atts[i]; i += 2)
140
63
      {
141
64
         ei_x_encode_tuple_header(&event_buf, 2);
142
 
         ei_x_encode_string_fixed(&event_buf, atts[i]);
143
 
         ei_x_encode_string_fixed(&event_buf, atts[i+1]);
 
65
         ei_x_encode_string(&event_buf, atts[i]);
 
66
         ei_x_encode_string(&event_buf, atts[i+1]);
144
67
      }
145
68
   }
146
69
 
155
78
   ei_x_encode_list_header(&event_buf, 1);
156
79
   ei_x_encode_tuple_header(&event_buf, 2);
157
80
   ei_x_encode_long(&event_buf, XML_END);
158
 
   ei_x_encode_string_fixed(&event_buf, name);
 
81
   ei_x_encode_string(&event_buf, name);
159
82
   return NULL;
160
83
}
161
84
 
225
148
            ei_x_encode_long(&event_buf, XML_ERROR);
226
149
            ei_x_encode_tuple_header(&event_buf, 2);
227
150
            ei_x_encode_long(&event_buf, errcode);
228
 
            ei_x_encode_string_fixed(&event_buf, errstring);
 
151
            ei_x_encode_string(&event_buf, errstring);
229
152
         }
230
153
 
231
154
         ei_x_encode_empty_list(&event_buf);