ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/ermyth/modules/rpc/include/xml/rpc.h
Revision: 1.1
Committed: Thu Jul 19 08:24:56 2007 UTC (19 years, 3 months ago) by pippijn
Content type: text/plain
Branch: MAIN
Log Message:
initial import. the most important changes since Atheme are:
- fixed many memory leaks
- fixed many bugs
- converted to C++ and use more STL containers
- added a (not very enhanced yet) perl module
- greatly improved XML-RPC speed
- added a JSON-RPC module with code from json-cpp
- added a valgrind memcheck module to operserv
- added a more object oriented base64 implementation
- added a specialised unit test framework
- improved stability
- use gettimeofday() if available
- reworked adding/removing commands
- MemoServ IGNORE DEL can now remove indices

File Contents

# User Rev Content
1 pippijn 1.1 /*
2     * Copyright © 2007 Pippijn van Steenhoven / The Ermyth Team
3     * Copyright © 2005 Atheme Development Group
4     * and Trystan Scott Lee <trystan@nomadirc.net>
5     *
6     * XMLRPC library header, hacked up for Atheme.
7     *
8     * $Id: rpc.h,v 1.1 2007-07-11 11:04:46 pippijn Exp $
9     */
10     #ifndef XMLRPC_H
11     #define XMLRPC_H
12    
13     #include "atheme.h"
14    
15     #define stricmp strcasecmp
16    
17     enum
18     {
19     XMLRPC_CONT = 0,
20     XMLRPC_STOP = 1
21     };
22    
23     enum xmlrpc_error
24     {
25     XMLRPC_ERR_OK = 0,
26     XMLRPC_ERR_MEMORY = 1,
27     XMLRPC_ERR_PARAMS = 2,
28     XMLRPC_ERR_EXISTS = 3,
29     XMLRPC_ERR_NOEXIST = 4,
30     XMLRPC_ERR_NOUSER = 5,
31     XMLRPC_ERR_NOLOAD = 6,
32     XMLRPC_ERR_NOUNLOAD = 7,
33     XMLRPC_ERR_SYNTAX = 8,
34     XMLRPC_ERR_NODELETE = 9,
35     XMLRPC_ERR_UNKNOWN = 10,
36     XMLRPC_ERR_FILE_IO = 11,
37     XMLRPC_ERR_NOSERVICE = 12
38     };
39    
40     /*
41     * Header that defines much of the xml/xmlrpc library
42     */
43    
44     #define XMLRPC_BUFSIZE 1024
45     #define XMLLIB_VERSION "1.0.0"
46     #define XMLLIB_AUTHOR "Trystan Scott Lee <trystan@nomadirc.net>"
47    
48     #define MAX_CMD_HASH 1024
49    
50     #define XMLRPC_ON "on"
51     #define XMLRPC_OFF "off"
52    
53     #define XMLRPC_I4 "i4"
54     #define XMLRPC_INT "integer"
55    
56     enum
57     {
58     XMLRPC_HTTP_HEADER = 1,
59     XMLRPC_ENCODE = 2,
60     XMLRPC_INTTAG = 3
61     };
62    
63     inline int
64     gen_cmd_hash (char const *arg)
65     {
66     return ((arg[0] & 31) << 5 | (arg[1] & 31)); /* Will gen a hash from a string :) */
67     }
68    
69     typedef int (*XMLRPCMethodFunc)(void *userdata, int ac, char **av);
70    
71     struct xmlrpc_cmd {
72     XMLRPCMethodFunc func;
73     char *name;
74     xmlrpc_cmd *next;
75     };
76    
77     struct xmlrpc_cmdhash {
78     char *name;
79     xmlrpc_cmd *xml;
80     xmlrpc_cmdhash *next;
81     };
82    
83     extern xmlrpc_cmdhash *xmlrpc_cmds[MAX_CMD_HASH];
84    
85     struct xmlrpc_set
86     {
87     char *(*setbuffer)(char *buffer, int len);
88     char *encode;
89     int httpheader;
90     char *inttagstart;
91     char *inttagend;
92     };
93    
94     E void xmlrpc_process(char *buffer, void *userdata);
95     E int xmlrpc_register_method(char const *name, XMLRPCMethodFunc func);
96     E int xmlrpc_unregister_method(char const *method);
97    
98     E char *xmlrpc_string(char *buf, char const *value);
99    
100     E void xmlrpc_set_buffer(char *(*func)(char *buffer, int len));
101     E void xmlrpc_generic_error(int code, char const *string);
102     E void xmlrpc_send(int argc, ...);
103     E void xmlrpc_char_encode(char *outbuffer, char const *s1);
104     E char *xmlrpc_decode_string(char *buf);
105    
106     #endif