Initial commit.
[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 struct mt_connection_s;
23 typedef struct mt_connection_s mt_connection_t;
24
25 struct mt_reply_s;
26 typedef struct mt_reply_s mt_reply_t;
27
28 typedef int (*mt_reply_handler_t) (mt_connection_t *c, const mt_reply_t *r,
29                 void *user_data);
30
31 /*
32  * Connection handling
33  */
34 mt_connection_t *mt_connect (const char *node, const char *service,
35                 const char *username, const char *password);
36 int mt_disconnect (mt_connection_t *con);
37
38 /* 
39  * Command execution
40  */
41 int mt_query (mt_connection_t *c,
42                 const char *command,
43                 size_t args_num, const char * const *args,
44                 mt_reply_handler_t *handler, void *user_data);
45
46 /* 
47  * Reply handling
48  */
49 const mt_reply_t *mt_reply_next (const mt_reply_t *r);
50 int mt_reply_num (const mt_reply_t *r);
51
52 /* Receiving reply parameters */
53 const char *mt_reply_param_key_by_index (const mt_reply_t *r, unsigned int index);
54 const char *mt_reply_param_val_by_index (const mt_reply_t *r, unsigned int index);
55 const char *mt_reply_param_val_by_key (const mt_reply_t *r, const char *key);
56
57 /* vim: set ts=2 sw=2 noet fdm=marker : */