--- pypcap-1.1/pcap.c.orig 2007-05-28 20:38:22.000000000 +0300 +++ pypcap-1.1/pcap.c 2007-05-28 20:39:56.000000000 +0300 @@ -1,45 +1,49 @@ -/* Generated by Pyrex 0.9.3 on Sun Oct 16 19:38:39 2005 */ +/* Generated by Pyrex 0.9.5.1a on Mon May 28 20:38:29 2007 */ #include "Python.h" #include "structmember.h" #ifndef PY_LONG_LONG #define PY_LONG_LONG LONG_LONG #endif +#ifdef __cplusplus +#define __PYX_EXTERN_C extern "C" +#else +#define __PYX_EXTERN_C extern +#endif +__PYX_EXTERN_C double pow(double, double); #include "pcap.h" #include "pcap_ex.h" typedef struct {PyObject **p; char *s;} __Pyx_InternTabEntry; /*proto*/ typedef struct {PyObject **p; char *s; long n;} __Pyx_StringTabEntry; /*proto*/ -static PyObject *__Pyx_UnpackItem(PyObject *, int); /*proto*/ -static int __Pyx_EndUnpack(PyObject *, int); /*proto*/ -static int __Pyx_PrintItem(PyObject *); /*proto*/ -static int __Pyx_PrintNewline(void); /*proto*/ -static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/ -static void __Pyx_ReRaise(void); /*proto*/ -static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/ -static PyObject *__Pyx_GetExcValue(void); /*proto*/ -static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, char *name); /*proto*/ -static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/ -static int __Pyx_GetStarArgs(PyObject **args, PyObject **kwds, char *kwd_list[], int nargs, PyObject **args2, PyObject **kwds2); /*proto*/ -static void __Pyx_WriteUnraisable(char *name); /*proto*/ -static void __Pyx_AddTraceback(char *funcname); /*proto*/ -static PyTypeObject *__Pyx_ImportType(char *module_name, char *class_name, long size); /*proto*/ -static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/ -static int __Pyx_GetVtable(PyObject *dict, void *vtabptr); /*proto*/ -static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name, char *modname); /*proto*/ -static int __Pyx_InternStrings(__Pyx_InternTabEntry *t); /*proto*/ -static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/ -static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/ static PyObject *__pyx_m; static PyObject *__pyx_b; static int __pyx_lineno; static char *__pyx_filename; -staticforward char **__pyx_f; +static char **__pyx_f; static char __pyx_mdoc[] = "packet capture library\n\nThis module provides a high level interface to packet capture systems.\nAll packets on the network, even those destined for other hosts, are\naccessible through this mechanism.\n"; +static int __Pyx_GetStarArgs(PyObject **args, PyObject **kwds, char *kwd_list[], int nargs, PyObject **args2, PyObject **kwds2); /*proto*/ + +static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/ + +static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/ + +static PyObject *__Pyx_GetExcValue(void); /*proto*/ + +static void __Pyx_WriteUnraisable(char *name); /*proto*/ + +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/ + +static int __Pyx_InternStrings(__Pyx_InternTabEntry *t); /*proto*/ + +static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/ + +static void __Pyx_AddTraceback(char *funcname); /*proto*/ + /* Declarations from pcap */ struct __pyx_t_4pcap_pcap_handler_ctx { @@ -48,14 +52,12 @@ int got_exc; }; -staticforward PyTypeObject __pyx_type_4pcap_bpf; struct __pyx_obj_4pcap_bpf { PyObject_HEAD struct bpf_program fcode; }; -staticforward PyTypeObject __pyx_type_4pcap_pcap; struct __pyx_obj_4pcap_pcap { PyObject_HEAD @@ -78,6 +80,7 @@ static PyObject *__pyx_k20; static void (__pyx_f_4pcap___pcap_handler(void (*),struct pcap_pkthdr (*),char (*))); /*proto*/ + /* Implementation of pcap */ static char (__pyx_k1[]) = "Network interface or dumpfile name."; @@ -295,7 +298,7 @@ __pyx_2 = 0; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(__pyx_r); + __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); @@ -316,10 +319,6 @@ /* "/Users/dugsong/projects/pypcap/pcap.pyx":143 */ pcap_freecode((&((struct __pyx_obj_4pcap_bpf *)__pyx_v_self)->fcode)); - goto __pyx_L0; - __pyx_L1:; - __Pyx_AddTraceback("pcap.bpf.__dealloc__"); - __pyx_L0:; Py_DECREF(__pyx_v_self); } @@ -370,7 +369,7 @@ __pyx_v_p = pcap_ex_lookupdev(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__ebuf); /* "/Users/dugsong/projects/pypcap/pcap.pyx":170 */ - __pyx_1 = (__pyx_v_p == 0); + __pyx_1 = (__pyx_v_p == NULL); if (__pyx_1) { /* "/Users/dugsong/projects/pypcap/pcap.pyx":171 */ @@ -511,7 +510,7 @@ __pyx_1 = 0; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(__pyx_r); + __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); @@ -534,7 +533,7 @@ __pyx_1 = 0; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(__pyx_r); + __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); @@ -557,7 +556,7 @@ __pyx_1 = 0; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(__pyx_r); + __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); @@ -580,7 +579,7 @@ __pyx_1 = 0; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(__pyx_r); + __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); @@ -603,7 +602,7 @@ __pyx_1 = 0; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(__pyx_r); + __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); @@ -629,7 +628,7 @@ __pyx_1 = 0; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(__pyx_r); + __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); @@ -700,7 +699,7 @@ /* "/Users/dugsong/projects/pypcap/pcap.pyx":227 */ pcap_freecode((&__pyx_v_fcode)); - __pyx_r = Py_None; Py_INCREF(__pyx_r); + __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_4); @@ -730,7 +729,7 @@ __pyx_1 = PyInt_AsLong(__pyx_v_nonblock); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; goto __pyx_L1;} pcap_ex_setnonblock(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap,__pyx_1,((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__ebuf); - __pyx_r = Py_None; Py_INCREF(__pyx_r); + __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1:; __Pyx_AddTraceback("pcap.pcap.setnonblock"); @@ -752,7 +751,7 @@ static char *__pyx_argnames[] = {0}; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0; Py_INCREF(__pyx_v_self); - __pyx_v_ret = Py_None; Py_INCREF(__pyx_v_ret); + __pyx_v_ret = Py_None; Py_INCREF(Py_None); /* "/Users/dugsong/projects/pypcap/pcap.pyx":235 */ __pyx_1 = PyInt_FromLong(pcap_ex_getnonblock(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap,((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__ebuf)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; goto __pyx_L1;} @@ -794,7 +793,7 @@ __pyx_3 = 0; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(__pyx_r); + __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); @@ -822,7 +821,7 @@ __pyx_1 = 0; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(__pyx_r); + __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); @@ -874,7 +873,7 @@ __pyx_4 = 0; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(__pyx_r); + __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); @@ -920,7 +919,7 @@ Py_DECREF(__pyx_3); __pyx_3 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_r = Py_None; Py_INCREF(__pyx_r); + __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); @@ -951,7 +950,7 @@ static char *__pyx_argnames[] = {0}; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0; Py_INCREF(__pyx_v_self); - __pyx_v_pkts = Py_None; Py_INCREF(__pyx_v_pkts); + __pyx_v_pkts = Py_None; Py_INCREF(Py_None); /* "/Users/dugsong/projects/pypcap/pcap.pyx":261 */ __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; goto __pyx_L1;} @@ -980,7 +979,7 @@ __pyx_r = __pyx_v_pkts; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(__pyx_r); + __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); @@ -1023,7 +1022,7 @@ Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_cnt); Py_INCREF(__pyx_v_callback); - __pyx_v_exc = Py_None; Py_INCREF(__pyx_v_exc); + __pyx_v_exc = Py_None; Py_INCREF(Py_None); /* "/Users/dugsong/projects/pypcap/pcap.pyx":281 */ __pyx_v_ctx.callback = ((void (*))__pyx_v_callback); @@ -1046,27 +1045,25 @@ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_sys); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; goto __pyx_L1;} __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_exc_info); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; goto __pyx_L1;} - __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; goto __pyx_L1;} + __pyx_2 = PyObject_CallObject(__pyx_3, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_v_exc); - __pyx_v_exc = __pyx_4; - __pyx_4 = 0; + __pyx_v_exc = __pyx_2; + __pyx_2 = 0; /* "/Users/dugsong/projects/pypcap/pcap.pyx":288 */ __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;} __pyx_2 = PyObject_GetItem(__pyx_v_exc, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_4 = PyInt_FromLong(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;} - __pyx_3 = PyObject_GetItem(__pyx_v_exc, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;} - Py_DECREF(__pyx_4); __pyx_4 = 0; - __pyx_4 = PyInt_FromLong(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;} - __pyx_5 = PyObject_GetItem(__pyx_v_exc, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;} - Py_DECREF(__pyx_4); __pyx_4 = 0; - __Pyx_Raise(__pyx_2, __pyx_3, __pyx_5); - Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;} + __pyx_4 = PyObject_GetItem(__pyx_v_exc, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_3 = PyInt_FromLong(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;} + __pyx_5 = PyObject_GetItem(__pyx_v_exc, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + __Pyx_Raise(__pyx_2, __pyx_4, __pyx_5); + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; Py_DECREF(__pyx_5); __pyx_5 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;} goto __pyx_L2; @@ -1074,12 +1071,12 @@ __pyx_L2:; /* "/Users/dugsong/projects/pypcap/pcap.pyx":289 */ - __pyx_4 = PyInt_FromLong(__pyx_v_n); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; goto __pyx_L1;} - __pyx_r = __pyx_4; - __pyx_4 = 0; + __pyx_3 = PyInt_FromLong(__pyx_v_n); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; goto __pyx_L1;} + __pyx_r = __pyx_3; + __pyx_3 = 0; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(__pyx_r); + __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); @@ -1131,7 +1128,6 @@ /* "/Users/dugsong/projects/pypcap/pcap.pyx":304 */ while (1) { - __pyx_L2:; __pyx_1 = 1; if (!__pyx_1) break; @@ -1186,7 +1182,7 @@ } __pyx_L3:; - __pyx_r = Py_None; Py_INCREF(__pyx_r); + __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_3); @@ -1218,7 +1214,7 @@ __pyx_1 = 0; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(__pyx_r); + __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); @@ -1259,9 +1255,9 @@ __pyx_L2:; /* "/Users/dugsong/projects/pypcap/pcap.pyx":326 */ - __pyx_2 = PyInt_FromLong(__pyx_v_pstat.ps_recv); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; goto __pyx_L1;} - __pyx_3 = PyInt_FromLong(__pyx_v_pstat.ps_drop); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; goto __pyx_L1;} - __pyx_4 = PyInt_FromLong(__pyx_v_pstat.ps_ifdrop); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; goto __pyx_L1;} + __pyx_2 = PyLong_FromUnsignedLong(__pyx_v_pstat.ps_recv); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; goto __pyx_L1;} + __pyx_3 = PyLong_FromUnsignedLong(__pyx_v_pstat.ps_drop); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; goto __pyx_L1;} + __pyx_4 = PyLong_FromUnsignedLong(__pyx_v_pstat.ps_ifdrop); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; goto __pyx_L1;} __pyx_5 = PyTuple_New(3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; goto __pyx_L1;} PyTuple_SET_ITEM(__pyx_5, 0, __pyx_2); PyTuple_SET_ITEM(__pyx_5, 1, __pyx_3); @@ -1273,7 +1269,7 @@ __pyx_5 = 0; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(__pyx_r); + __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); @@ -1300,11 +1296,7 @@ __pyx_r = __pyx_v_self; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(__pyx_r); - goto __pyx_L0; - __pyx_L1:; - __Pyx_AddTraceback("pcap.pcap.__iter__"); - __pyx_r = 0; + __pyx_r = Py_None; Py_INCREF(Py_None); __pyx_L0:; Py_DECREF(__pyx_v_self); return __pyx_r; @@ -1327,7 +1319,6 @@ /* "/Users/dugsong/projects/pypcap/pcap.pyx":336 */ while (1) { - __pyx_L2:; __pyx_1 = 1; if (!__pyx_1) break; @@ -1379,9 +1370,8 @@ } __pyx_L4:; } - __pyx_L3:; - __pyx_r = Py_None; Py_INCREF(__pyx_r); + __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_3); @@ -1429,10 +1419,6 @@ } __pyx_L4:; - goto __pyx_L0; - __pyx_L1:; - __Pyx_AddTraceback("pcap.pcap.__dealloc__"); - __pyx_L0:; Py_DECREF(__pyx_v_self); } @@ -1450,7 +1436,7 @@ __pyx_1 = 0; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(__pyx_r); + __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); @@ -1476,7 +1462,7 @@ __pyx_v_p = pcap_ex_lookupdev(__pyx_v_ebuf); /* "/Users/dugsong/projects/pypcap/pcap.pyx":363 */ - __pyx_1 = (__pyx_v_p == 0); + __pyx_1 = (__pyx_v_p == NULL); if (__pyx_1) { /* "/Users/dugsong/projects/pypcap/pcap.pyx":364 */ @@ -1496,7 +1482,7 @@ __pyx_2 = 0; goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(__pyx_r); + __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); @@ -1564,12 +1550,10 @@ static PyObject *__pyx_tp_new_4pcap_bpf(PyTypeObject *t, PyObject *a, PyObject *k) { PyObject *o = (*t->tp_alloc)(t, 0); - struct __pyx_obj_4pcap_bpf *p = (struct __pyx_obj_4pcap_bpf *)o; return o; } static void __pyx_tp_dealloc_4pcap_bpf(PyObject *o) { - struct __pyx_obj_4pcap_bpf *p = (struct __pyx_obj_4pcap_bpf *)o; { PyObject *etype, *eval, *etb; PyErr_Fetch(&etype, &eval, &etb); @@ -1583,13 +1567,10 @@ } static int __pyx_tp_traverse_4pcap_bpf(PyObject *o, visitproc v, void *a) { - int e; - struct __pyx_obj_4pcap_bpf *p = (struct __pyx_obj_4pcap_bpf *)o; return 0; } static int __pyx_tp_clear_4pcap_bpf(PyObject *o) { - struct __pyx_obj_4pcap_bpf *p = (struct __pyx_obj_4pcap_bpf *)o; return 0; } @@ -1665,7 +1646,7 @@ 0, /*bf_getcharbuffer*/ }; -statichere PyTypeObject __pyx_type_4pcap_bpf = { +PyTypeObject __pyx_type_4pcap_bpf = { PyObject_HEAD_INIT(0) 0, /*ob_size*/ "pcap.bpf", /*tp_name*/ @@ -1686,7 +1667,7 @@ 0, /*tp_getattro*/ 0, /*tp_setattro*/ &__pyx_tp_as_buffer_bpf, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ "bpf(filter, dlt=DLT_RAW) -> BPF filter object", /*tp_doc*/ __pyx_tp_traverse_4pcap_bpf, /*tp_traverse*/ __pyx_tp_clear_4pcap_bpf, /*tp_clear*/ @@ -1716,12 +1697,10 @@ static PyObject *__pyx_tp_new_4pcap_pcap(PyTypeObject *t, PyObject *a, PyObject *k) { PyObject *o = (*t->tp_alloc)(t, 0); - struct __pyx_obj_4pcap_pcap *p = (struct __pyx_obj_4pcap_pcap *)o; return o; } static void __pyx_tp_dealloc_4pcap_pcap(PyObject *o) { - struct __pyx_obj_4pcap_pcap *p = (struct __pyx_obj_4pcap_pcap *)o; { PyObject *etype, *eval, *etb; PyErr_Fetch(&etype, &eval, &etb); @@ -1735,13 +1714,10 @@ } static int __pyx_tp_traverse_4pcap_pcap(PyObject *o, visitproc v, void *a) { - int e; - struct __pyx_obj_4pcap_pcap *p = (struct __pyx_obj_4pcap_pcap *)o; return 0; } static int __pyx_tp_clear_4pcap_pcap(PyObject *o) { - struct __pyx_obj_4pcap_pcap *p = (struct __pyx_obj_4pcap_pcap *)o; return 0; } @@ -1857,7 +1833,7 @@ 0, /*bf_getcharbuffer*/ }; -statichere PyTypeObject __pyx_type_4pcap_pcap = { +PyTypeObject __pyx_type_4pcap_pcap = { PyObject_HEAD_INIT(0) 0, /*ob_size*/ "pcap.pcap", /*tp_name*/ @@ -1878,7 +1854,7 @@ 0, /*tp_getattro*/ 0, /*tp_setattro*/ &__pyx_tp_as_buffer_pcap, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ "pcap(name=None, snaplen=65535, promisc=True, immediate=False) -> packet capture object\n \n Open a handle to a packet capture descriptor.\n \n Keyword arguments:\n name -- name of a network interface or dumpfile to open,\n or None to open the first available up interface\n snaplen -- maximum number of bytes to capture for each packet\n promisc -- boolean to specify promiscuous mode sniffing\n immediate -- disable buffering, if possible\n ", /*tp_doc*/ __pyx_tp_traverse_4pcap_pcap, /*tp_traverse*/ __pyx_tp_clear_4pcap_pcap, /*tp_clear*/ @@ -1912,8 +1888,10 @@ {0, 0, 0, 0} }; -DL_EXPORT(void) initpcap(void); /*proto*/ -DL_EXPORT(void) initpcap(void) { +static void __pyx_init_filenames(void); /*proto*/ + +PyMODINIT_FUNC initpcap(void); /*proto*/ +PyMODINIT_FUNC initpcap(void) { PyObject *__pyx_1 = 0; PyObject *__pyx_2 = 0; PyObject *__pyx_3 = 0; @@ -1922,6 +1900,7 @@ PyObject *__pyx_6 = 0; PyObject *__pyx_7 = 0; PyObject *__pyx_8 = 0; + __pyx_init_filenames(); __pyx_m = Py_InitModule4("pcap", __pyx_methods, __pyx_mdoc, 0, PYTHON_API_VERSION); if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; goto __pyx_L1;}; __pyx_b = PyImport_AddModule("__builtin__"); @@ -2182,10 +2161,13 @@ static char *__pyx_filenames[] = { "pcap.pyx", }; -statichere char **__pyx_f = __pyx_filenames; /* Runtime support code */ +static void __pyx_init_filenames(void) { + __pyx_f = __pyx_filenames; +} + static int __Pyx_GetStarArgs( PyObject **args, PyObject **kwds, @@ -2250,10 +2232,12 @@ bad: Py_XDECREF(args1); Py_XDECREF(kwds1); - if (*args2) + if (*args2) { Py_XDECREF(*args2); - if (*kwds2) + } + if (*kwds2) { Py_XDECREF(*kwds2); + } return -1; } @@ -2365,32 +2349,28 @@ Py_INCREF(type); Py_DECREF(tmp); } - if (PyString_Check(type)) - ; - else if (PyClass_Check(type)) + if (PyString_Check(type)) { + if (PyErr_Warn(PyExc_DeprecationWarning, + "raising a string exception is deprecated")) + goto raise_error; + } + else if (PyType_Check(type) || PyClass_Check(type)) ; /*PyErr_NormalizeException(&type, &value, &tb);*/ - else if (PyInstance_Check(type)) { + else { /* Raising an instance. The value should be a dummy. */ if (value != Py_None) { PyErr_SetString(PyExc_TypeError, - "instance exception may not have a separate value"); + "instance exception may not have a separate value"); goto raise_error; } - else { - /* Normalize to raise , */ - Py_DECREF(value); - value = type; + /* Normalize to raise , */ + Py_DECREF(value); + value = type; + if (PyInstance_Check(type)) type = (PyObject*) ((PyInstanceObject*)type)->in_class; - Py_INCREF(type); - } - } - else { - /* Not something you can raise. You get an exception - anyway, just not what you specified :-) */ - PyErr_Format(PyExc_TypeError, - "exceptions must be strings, classes, or " - "instances, not %s", type->ob_type->tp_name); - goto raise_error; + else + type = (PyObject*) type->ob_type; + Py_INCREF(type); } PyErr_Restore(type, value, tb); return;