src/routeros_api.h: Add «extern "C"» for C++ programs.
[routeros-api.git] / src / routeros_api.h
1 /**
2  * libmikrotik - src/mikrotik.h
3  * Copyright (C) 2009  Florian octo Forster
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License as published by the
7  * Free Software Foundation; only version 2 of the License is applicable.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * 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 along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
17  *
18  * Authors:
19  *   Florian octo Forster <octo at verplant.org>
20  **/
21
22 #ifndef ROUTEROS_API_H
23 #define ROUTEROS_API_H 1
24
25 #define ROUTEROS_API_PORT "8728"
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30
31 struct ros_connection_s;
32 typedef struct ros_connection_s ros_connection_t;
33
34 struct ros_reply_s;
35 typedef struct ros_reply_s ros_reply_t;
36
37 typedef int (*ros_reply_handler_t) (ros_connection_t *c, const ros_reply_t *r,
38                 void *user_data);
39
40 /*
41  * Connection handling
42  */
43 ros_connection_t *ros_connect (const char *node, const char *service,
44                 const char *username, const char *password);
45 int ros_disconnect (ros_connection_t *con);
46
47 /* 
48  * Command execution
49  */
50 int ros_query (ros_connection_t *c,
51                 const char *command,
52                 size_t args_num, const char * const *args,
53                 ros_reply_handler_t handler, void *user_data);
54
55 /* 
56  * Reply handling
57  */
58 const ros_reply_t *ros_reply_next (const ros_reply_t *r);
59 int ros_reply_num (const ros_reply_t *r);
60
61 const char *ros_reply_status (const ros_reply_t *r);
62
63 /* Receiving reply parameters */
64 const char *ros_reply_param_key_by_index (const ros_reply_t *r,
65                 unsigned int index);
66 const char *ros_reply_param_val_by_index (const ros_reply_t *r,
67                 unsigned int index);
68 const char *ros_reply_param_val_by_key (const ros_reply_t *r, const char *key);
69
70 #ifdef __cplusplus
71 }
72 #endif
73
74 #endif /* ROUTEROS_API_H */
75
76 /* vim: set ts=2 sw=2 noet fdm=marker : */