1 /* -*- Mode
: C
; c-basic-offset
: 2 -*- */
2 /*****************************************************************************
4 * Python bindings for LASH
6 * Copyright
(C
) 2006 Nedko Arnaudov
<nedko@arnaudov.name
>
8 * This program is free software
; you can redistribute it and
/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation
; either version
2 of the License
, or
11 * (at your option
) any later version.
13 * This program is distributed in the hope that it will be useful
,
14 * but WITHOUT
ANY WARRANTY
; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program
; if not
, write to the Free Software
20 * Foundation
, Inc.
, 51 Franklin St
, Fifth Floor
, Boston
, MA
02110-1301 USA.
22 *****************************************************************************/
24 #ifndef LASH_I__74601D15_FF3A_4086_B6F6_8D626BBCD7A2__INCLUDED
25 #define LASH_I__74601D15_FF3A_4086_B6F6_8D626BBCD7A2__INCLUDED
30 %typemap
(in
) (int
*argc
, char
***argv
)
34 if
(!PyList_Check
($input
))
36 PyErr_SetString
(PyExc_ValueError
, "Expecting a list");
40 $
1 = (int
*) malloc
(sizeof
(int
));
43 PyErr_SetString
(PyExc_ValueError
, "malloc() failed.");
47 *$
1 = PyList_Size
($input
);
49 $
2 = (char
***) malloc
(sizeof
(char
**));
52 PyErr_SetString
(PyExc_ValueError
, "malloc() failed.");
56 *$
2 = (char
**) malloc
((*$
1+1)*sizeof
(char
*));
59 PyErr_SetString
(PyExc_ValueError
, "malloc() failed.");
63 for
(i
= 0; i
< *$
1; i
++)
65 PyObject
*s
= PyList_GetItem
($input
,i
);
66 if
(!PyString_Check
(s
))
68 PyErr_SetString
(PyExc_ValueError
, "List items must be strings");
72 (*$
2)[i
] = PyString_AsString
(s
);
78 %typemap
(argout
) (int
*argc
, char
***argv
)
82 for
(i
= 0; i
< *$
1; i
++)
84 PyObject
*s
= PyString_FromString
((*$
2)[i
]);
85 PyList_SetItem
($input
,i
,s
);
88 while
(i
< PySequence_Size
($input
))
90 PySequence_DelItem
($input
,i
);
94 %typemap
(freearg
) (int
*argc
, char
***argv
)
98 //printf
("freeing argc pointer storage\n");
107 //printf
("freeing array pointed by argv pointer storage\n");
111 //printf
("freeing argv pointer storage\n");
118 #include
<lash
/client_interface.h
>
119 #include
<lash
/types.h
>
120 #include
<lash
/event.h
>
121 #include
<lash
/config.h
>
123 typedef unsigned char
* uuid_t_compat
;
124 #define uuid_t uuid_t_compat
129 %include
<lash
/client_interface.h
>
130 %include
<lash
/types.h
>
131 %include
<lash
/event.h
>
132 %include
<lash
/config.h
>
135 #endif
/* #ifndef LASH_I__74601D15_FF3A_4086_B6F6_8D626BBCD7A2__INCLUDED
*/