├── README.md ├── docs ├── scapy-IPv6_HITB06.pdf ├── scapy.pdf ├── scapy_pacsec05.pdf ├── scapydoc.pdf └── scapyguide.pdf ├── examples ├── fuzz.py ├── hexpcap.py ├── icmpv6.py ├── ping.py ├── plot.py ├── scan.py ├── synscan.py ├── tracert.py └── wifi.py ├── install-kali.sh ├── install-osx.sh └── patches ├── pylibpcap-0.6.4-rfmon-mac.patch └── scapy-2.2.0-rfmon-mac.patch /README.md: -------------------------------------------------------------------------------- 1 | ## WiFi 2 | 3 | http://stackoverflow.com/questions/10818661/scapy-retrieving-rssi-from-wifi-packets 4 | 5 | http://hackoftheday.securitytube.net/2013/04/wi-fi-ssid-sniffer-in-12-lines-of.html 6 | 7 | http://hackoftheday.securitytube.net/2013/03/wi-fi-sniffer-in-10-lines-of-python.html 8 | 9 | http://scholarworks.sjsu.edu/cgi/viewcontent.cgi?article=1191&context=etd_projects 10 | 11 | http://pen-testing.sans.org/blog/2011/10/13/special-request-wireless-client-sniffing-with-scapy 12 | 13 | http://raidersec.blogspot.com/2013/01/wireless-deauth-attack-using-aireplay.html -------------------------------------------------------------------------------- /docs/scapy-IPv6_HITB06.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0x90/scapy-scripts/b4f8490e7b533e2036db5e011bba99dbb31aa5b0/docs/scapy-IPv6_HITB06.pdf -------------------------------------------------------------------------------- /docs/scapy.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0x90/scapy-scripts/b4f8490e7b533e2036db5e011bba99dbb31aa5b0/docs/scapy.pdf -------------------------------------------------------------------------------- /docs/scapy_pacsec05.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0x90/scapy-scripts/b4f8490e7b533e2036db5e011bba99dbb31aa5b0/docs/scapy_pacsec05.pdf -------------------------------------------------------------------------------- /docs/scapydoc.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0x90/scapy-scripts/b4f8490e7b533e2036db5e011bba99dbb31aa5b0/docs/scapydoc.pdf -------------------------------------------------------------------------------- /docs/scapyguide.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0x90/scapy-scripts/b4f8490e7b533e2036db5e011bba99dbb31aa5b0/docs/scapyguide.pdf -------------------------------------------------------------------------------- /examples/fuzz.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- encoding: utf-8 -*- 3 | # 4 | 5 | __author__ = '090h' 6 | __license__ = 'GPL' 7 | 8 | from sys import argv, exit 9 | from os import path 10 | 11 | send(IP(dst="target")/fuzz(UDP()/NTP(version=4)),loop=1) 12 | 13 | if __name__ == '__main__': 14 | pass -------------------------------------------------------------------------------- /examples/hexpcap.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- encoding: utf-8 -*- 3 | # Hexfump packets from PCAP file. 4 | 5 | __author__ = '090h' 6 | __license__ = 'GPL' 7 | 8 | from sys import argv, exit 9 | from os import path 10 | from scapy.all import * 11 | 12 | 13 | def hexdump_pcap(filename): 14 | if not path.exists(filename): 15 | return 16 | 17 | pkts = sniff(offline=filename) 18 | for pkt in pkts: 19 | pkt.hexdump() 20 | raw_input('Press any key to continue.') 21 | 22 | if __name__ == '__main__': 23 | if len(argv) == 1: 24 | print('Usage:\n\thexpcap.py ') 25 | exit(1) 26 | 27 | hexdump_pcap(argv) -------------------------------------------------------------------------------- /examples/icmpv6.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- encoding: utf-8 -*- 3 | # 4 | 5 | __author__ = '090h' 6 | __license__ = 'GPL' 7 | 8 | from sys import argv, exit 9 | from os import path 10 | from scapy.all import * 11 | 12 | # 13 | fuzz(ICMPv6NDOptPrefixInfo()) 14 | # 15 | 16 | sendp(Ether()/IPv6(dst="ff02::1")/ICMPv6ND_RA()/ICMPv6NDOptPrefixInfo(prefix="2001:db8:bad:cafe::",prefixlen=129), loop=1, inter=0.5) -------------------------------------------------------------------------------- /examples/ping.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- encoding: utf-8 -*- 3 | # 4 | 5 | __author__ = '090h' 6 | __license__ = 'GPL' 7 | 8 | from sys import argv, exit 9 | from os import path 10 | from scapy.all import * 11 | 12 | def arp_ping(host): 13 | '''ARP Ping''' 14 | 15 | # The fastest way to discover hosts on a local ethernet network is to use the ARP Ping method: 16 | ans, unans = srp(Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst=host), timeout=2) 17 | 18 | # Answers can be reviewed with the following command: 19 | ans.summary(lambda (s, r): r.sprintf("%Ether.src% %ARP.psrc%")) 20 | 21 | 22 | def icmp_ping(host): 23 | ''' ICMP Ping ''' 24 | 25 | # Classical ICMP Ping can be emulated using the following command: 26 | ans, unans = sr(IP(dst=host)/ICMP()) 27 | 28 | # Information on live hosts can be collected with the following request: 29 | ans.summary(lambda (s, r): r.sprintf("%IP.src% is alive")) 30 | 31 | 32 | def tcp_ping(host, port): 33 | ''' TCP Ping ''' 34 | 35 | # In cases where ICMP echo requests are blocked, we can still use various TCP Pings 36 | # such as TCP SYN Ping below: 37 | ans, unans = sr(IP(dst=host)/TCP(dport=port, flags="S")) 38 | 39 | # Any response to our probes will indicate a live host. We can collect results with the following command: 40 | ans.summary(lambda(s, r): r.sprintf("%IP.src% is alive")) 41 | 42 | def udp_ping(host, port=0): 43 | ''' UDP Ping ''' 44 | # If all else fails there is always UDP Ping which will produce ICMP Port unreachable errors 45 | # from live hosts. Here you can pick any port which is most likely to be closed, 46 | # such as port 0: 47 | ans, unans = sr(IP(dst=host)/UDP(dport=port)) 48 | 49 | # Once again, results can be collected with this command: 50 | ans.summary(lambda(s, r): r.sprintf("%IP.src% is alive")) 51 | 52 | if __name__ == '__main__': 53 | # own variant 54 | arp_ping('10.0.0.1/24') 55 | 56 | # Scapy also includes a built-in arping() function which performs similar to the above two commands: 57 | arping("10.0.0.*") 58 | 59 | icmp_ping('10') 60 | 61 | tcp_ping() -------------------------------------------------------------------------------- /examples/plot.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- encoding: utf-8 -*- 3 | # 4 | 5 | __author__ = '090h' 6 | __license__ = 'GPL' 7 | 8 | from sys import argv, exit 9 | from os import path 10 | from scapy.all import * 11 | 12 | def plot(): 13 | a, b = sr(IP(dst="www.target.com")/TCP(sport=[RandShort()]*1000)) 14 | a.plot(lambda x: x[1].id) 15 | 16 | def traceroute_graph(): 17 | res, unans = traceroute( 18 | ["www.microsoft.com", "www.cisco.com", "www.yahoo.com", "www.wanadoo.fr", "www.pacsec.com"], 19 | dport=[80,443], 20 | maxttl=20, 21 | retry=-2) 22 | 23 | res.graph() # piped to ImageMagick's display program. Image below. 24 | # res.graph(type="ps",target="| lp") # piped to postscript printer 25 | # res.graph(target="> /tmp/graph.svg") # saved to file 26 | 27 | res.trace3D() 28 | 29 | # Graphical dumps (PDF, PS) 30 | # If you have PyX installed, you can make a graphical 31 | # PostScript/PDF dump of a packet or a list of packets 32 | # (see the ugly PNG image below. PostScript/PDF are far better quality...): 33 | 34 | a[423].pdfdump(layer_shift=1) 35 | a[423].psdump("/tmp/isakmp_pkt.eps",layer_shift=1) 36 | 37 | 38 | if __name__ == '__main__': 39 | pass -------------------------------------------------------------------------------- /examples/scan.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- encoding: utf-8 -*- 3 | # 4 | 5 | __author__ = '090h' 6 | __license__ = 'GPL' 7 | 8 | from sys import argv, exit 9 | from os import path 10 | 11 | def ack_scan(host): 12 | ans,unans = sr(IP(dst=host)/TCP(dport=[80,666], flags="A")) 13 | # We can find unfiltered ports in answered packets: 14 | for s, r in ans: 15 | if s[TCP].dport == r[TCP].sport: 16 | print str(s[TCP].dport) + " is unfiltered" 17 | 18 | # Similarly, filtered ports can be found with unanswered packets: 19 | for s in unans: 20 | print str(s[TCP].dport) + " is filtered" 21 | 22 | def xmas_scan(host): 23 | ''' Xmas Scan can be launced using the following command ''' 24 | ans,unans = sr(IP(dst="192.168.1.1")/TCP(dport=666,flags="FPU") ) 25 | # Checking RST responses will reveal closed ports on the target. 26 | 27 | def ip_scan(host): 28 | # A lower level IP Scan can be used to enumerate supported protocols: 29 | ans,unans = sr(IP(dst="192.168.1.1", proto=(0,255))/"SCAPY", retry=2) 30 | 31 | if __name__ == '__main__': 32 | pass -------------------------------------------------------------------------------- /examples/synscan.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- encoding: utf-8 -*- 3 | # 4 | 5 | __author__ = '090h' 6 | __license__ = 'GPL' 7 | 8 | from sys import argv, exit 9 | from os import path 10 | 11 | Classic SYN Scan can be initialized by executing the following command from Scapy’s prompt: 12 | 13 | >>> sr1(IP(dst="72.14.207.99")/TCP(dport=80,flags="S")) 14 | 15 | 16 | From the above output, we can see Google returned “SA” or SYN-ACK flags indicating an open port. 17 | 18 | Use either notations to scan ports 400 through 443 on the system: 19 | 20 | >>> sr(IP(dst="192.168.1.1")/TCP(sport=666,dport=(440,443),flags="S")) 21 | or 22 | 23 | >>> sr(IP(dst="192.168.1.1")/TCP(sport=RandShort(),dport=[440,441,442,443],flags="S")) 24 | In order to quickly review responses simply request a summary of collected packets: 25 | 26 | >>> ans,unans = _ 27 | >>> ans.summary() 28 | 29 | if __name__ == '__main__': 30 | pass -------------------------------------------------------------------------------- /examples/tracert.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- encoding: utf-8 -*- 3 | # 4 | 5 | __author__ = '090h' 6 | __license__ = 'GPL' 7 | 8 | from scapy.all import * 9 | hostname = "google.com" 10 | for i in range(1, 28): 11 | pkt = IP(dst=hostname, ttl=i) / UDP(dport=33434) 12 | # Send the packet and get a reply 13 | reply = sr1(pkt, verbose=0) 14 | if reply is None: 15 | # No reply =( 16 | break 17 | elif reply.type == 3: 18 | # We've reached our destination 19 | print "Done!", reply.src 20 | break 21 | else: 22 | # We're in the middle somewhere 23 | print "%d hops away: " % i , reply.src -------------------------------------------------------------------------------- /examples/wifi.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- encoding: utf-8 -*- 3 | # 4 | 5 | __author__ = '090h' 6 | __license__ = 'GPL' 7 | 8 | from sys import argv, exit 9 | from os import path, geteuid 10 | from subprocess import Popen 11 | 12 | 13 | def shell_exec(cmd): 14 | Popen(cmd, shell=True).wait() 15 | 16 | # you can have a kind of FakeAP: 17 | def fake_ap(essid, iface='wlan0', channel=1): 18 | ''' 19 | Wireless frame injection 20 | Provided that your wireless card and driver are correctly configured for frame injection 21 | ''' 22 | if geteuid() != 0: 23 | print('You must be root!') 24 | return 25 | shell_exec('ifconfig %s up' % iface).wait() 26 | shell_exec('iwpriv %s hostapd %s' % (iface, channel)) 27 | shell_exec('ifconfig %sap up' % iface) 28 | 29 | sendp(Dot11(addr1="ff:ff:ff:ff:ff:ff", 30 | addr2=RandMAC(), 31 | addr3=RandMAC())/ 32 | Dot11Beacon(cap="ESS")/ 33 | Dot11Elt(ID="SSID",info=RandString(RandNum(1,50)))/ 34 | Dot11Elt(ID="Rates",info='\x82\x84\x0b\x16')/ 35 | Dot11Elt(ID="DSset",info="\x03")/ 36 | Dot11Elt(ID="TIM",info="\x00\x01\x00\x00"),iface="wlan0ap",loop=1) 37 | 38 | # Wireless sniffing 39 | # The following command will display information similar to most wireless sniffers: 40 | def scan_ap(iface='wlan0'): 41 | sniff(iface=iface, 42 | prn=lambda x: x.sprintf("{Dot11Beacon:%Dot11.addr3%\t%Dot11Beacon.info%\t%PrismHeader.channel%\tDot11Beacon.cap%}")) 43 | 44 | 45 | if __name__ == '__main__': 46 | pass -------------------------------------------------------------------------------- /install-kali.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Python requirements 4 | 5 | 6 | apt-get install scapy -y 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /install-osx.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Install scapy+pylibpcap+rfmon patch in Mac OS X 4 | # 5 | 6 | 7 | # Make sure only root can run our script 8 | if [[ $EUID -ne 0 ]]; then 9 | echo "This script must be run as root!" 1>&2 10 | exit 1 11 | fi 12 | 13 | # Check for MacPorts installed 14 | if [ ! -f /opt/local/bin/port ]; then 15 | echo "Please install Xcode and MacPorts first!" 16 | exit 1 17 | fi 18 | 19 | echo "Installing dependencies.." 20 | port selfupdate 21 | port install libdnet py27-libdnet py-readline py-gnuplot py-crypto py-pyx swig 22 | 23 | echo "Installed patched version of pylibpcap" 24 | cd /tmp 25 | wget http://downloads.sourceforge.net/project/pylibpcap/pylibpcap/0.6.4/pylibpcap-0.6.4.tar.gz 26 | wget https://raw.githubusercontent.com/0x90/iSniff/master/patches/pylibpcap-0.6.4-rfmon-mac.patch 27 | tar xzvf pylibpcap-0.6.4.tar.gz 28 | patch -p0 < pylibpcap-0.6.4-rfmon-mac.patch 29 | cd pylibpcap-0.6.4 30 | python setup.py install 31 | 32 | echo "Installed patched version of scapy" 33 | cd /tmp 34 | wget http://www.secdev.org/projects/scapy/files/scapy-2.2.0.tar.gz 35 | wget https://raw.githubusercontent.com/0x90/iSniff/master/patches/scapy-2.2.0-rfmon-mac.patch 36 | tar xzvf scapy-2.2.0.tar.gz 37 | patch -p0 < scapy-2.2.0-rfmon-mac.patch 38 | cd scapy-2.2.0 39 | python setup.py install 40 | 41 | echo "Cleaning /tmp" 42 | cd /tmp 43 | rm -f *rfmon-mac.patch 44 | rm -f pylibpcap-0.6.4.tar.gz scapy-2.2.0.tar.gz 45 | rm -rf pylibpcap-0.6.4 scapy-2.2.0 -------------------------------------------------------------------------------- /patches/pylibpcap-0.6.4-rfmon-mac.patch: -------------------------------------------------------------------------------- 1 | diff -ru pylibpcap-0.6.4/pcap.c pylibpcap-0.6.4-mac/pcap.c 2 | --- pylibpcap-0.6.4/pcap.c 2012-01-05 19:13:47.000000000 -0500 3 | +++ pylibpcap-0.6.4-mac/pcap.c 2014-04-11 20:29:02.000000000 -0400 4 | @@ -1,15 +1,16 @@ 5 | /* ---------------------------------------------------------------------------- 6 | * This file was automatically generated by SWIG (http://www.swig.org). 7 | - * Version 1.3.31 8 | - * 9 | - * This file is not intended to be easily readable and contains a number of 10 | + * Version 3.0.0 11 | + * 12 | + * This file is not intended to be easily readable and contains a number of 13 | * coding conventions designed to improve portability and efficiency. Do not make 14 | - * changes to this file unless you know what you are doing--modify the SWIG 15 | - * interface file instead. 16 | + * changes to this file unless you know what you are doing--modify the SWIG 17 | + * interface file instead. 18 | * ----------------------------------------------------------------------------- */ 19 | 20 | #define SWIGPYTHON 21 | #define SWIG_PYTHON_DIRECTOR_NO_VTABLE 22 | + 23 | /* ----------------------------------------------------------------------------- 24 | * This section contains generic SWIG labels for method/variable 25 | * declarations/attributes, and other compiler dependent labels. 26 | @@ -17,14 +18,14 @@ 27 | 28 | /* template workaround for compilers that cannot correctly implement the C++ standard */ 29 | #ifndef SWIGTEMPLATEDISAMBIGUATOR 30 | -# if defined(__SUNPRO_CC) 31 | -# if (__SUNPRO_CC <= 0x560) 32 | -# define SWIGTEMPLATEDISAMBIGUATOR template 33 | -# else 34 | -# define SWIGTEMPLATEDISAMBIGUATOR 35 | -# endif 36 | +# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) 37 | +# define SWIGTEMPLATEDISAMBIGUATOR template 38 | +# elif defined(__HP_aCC) 39 | +/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ 40 | +/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ 41 | +# define SWIGTEMPLATEDISAMBIGUATOR template 42 | # else 43 | -# define SWIGTEMPLATEDISAMBIGUATOR 44 | +# define SWIGTEMPLATEDISAMBIGUATOR 45 | # endif 46 | #endif 47 | 48 | @@ -41,14 +42,20 @@ 49 | #ifndef SWIGUNUSED 50 | # if defined(__GNUC__) 51 | # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) 52 | -# define SWIGUNUSED __attribute__ ((__unused__)) 53 | +# define SWIGUNUSED __attribute__ ((__unused__)) 54 | # else 55 | # define SWIGUNUSED 56 | # endif 57 | # elif defined(__ICC) 58 | -# define SWIGUNUSED __attribute__ ((__unused__)) 59 | +# define SWIGUNUSED __attribute__ ((__unused__)) 60 | # else 61 | -# define SWIGUNUSED 62 | +# define SWIGUNUSED 63 | +# endif 64 | +#endif 65 | + 66 | +#ifndef SWIG_MSC_UNSUPPRESS_4505 67 | +# if defined(_MSC_VER) 68 | +# pragma warning(disable : 4505) /* unreferenced local function has been removed */ 69 | # endif 70 | #endif 71 | 72 | @@ -56,7 +63,7 @@ 73 | # ifdef __cplusplus 74 | # define SWIGUNUSEDPARM(p) 75 | # else 76 | -# define SWIGUNUSEDPARM(p) p SWIGUNUSED 77 | +# define SWIGUNUSEDPARM(p) p SWIGUNUSED 78 | # endif 79 | #endif 80 | 81 | @@ -99,7 +106,7 @@ 82 | # define SWIGSTDCALL __stdcall 83 | # else 84 | # define SWIGSTDCALL 85 | -# endif 86 | +# endif 87 | #endif 88 | 89 | /* Deal with Microsoft's attempt at deprecating C standard runtime functions */ 90 | @@ -107,20 +114,32 @@ 91 | # define _CRT_SECURE_NO_DEPRECATE 92 | #endif 93 | 94 | +/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ 95 | +#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) 96 | +# define _SCL_SECURE_NO_DEPRECATE 97 | +#endif 98 | + 99 | 100 | -/* Python.h has to appear first */ 101 | -#include 102 | + 103 | +#if defined(_DEBUG) && defined(SWIG_PYTHON_INTERPRETER_NO_DEBUG) 104 | +/* Use debug wrappers with the Python release dll */ 105 | +# undef _DEBUG 106 | +# include 107 | +# define _DEBUG 108 | +#else 109 | +# include 110 | +#endif 111 | 112 | /* ----------------------------------------------------------------------------- 113 | * swigrun.swg 114 | * 115 | - * This file contains generic CAPI SWIG runtime support for pointer 116 | + * This file contains generic C API SWIG runtime support for pointer 117 | * type checking. 118 | * ----------------------------------------------------------------------------- */ 119 | 120 | /* This should only be incremented when either the layout of swig_type_info changes, 121 | or for whatever reason, the runtime changes incompatibly */ 122 | -#define SWIG_RUNTIME_VERSION "3" 123 | +#define SWIG_RUNTIME_VERSION "4" 124 | 125 | /* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ 126 | #ifdef SWIG_TYPE_TABLE 127 | @@ -133,11 +152,11 @@ 128 | 129 | /* 130 | You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for 131 | - creating a static or dynamic library from the swig runtime code. 132 | - In 99.9% of the cases, swig just needs to declare them as 'static'. 133 | - 134 | - But only do this if is strictly necessary, ie, if you have problems 135 | - with your compiler or so. 136 | + creating a static or dynamic library from the SWIG runtime code. 137 | + In 99.9% of the cases, SWIG just needs to declare them as 'static'. 138 | + 139 | + But only do this if strictly necessary, ie, if you have problems 140 | + with your compiler or suchlike. 141 | */ 142 | 143 | #ifndef SWIGRUNTIME 144 | @@ -155,22 +174,23 @@ 145 | 146 | /* Flags for pointer conversions */ 147 | #define SWIG_POINTER_DISOWN 0x1 148 | +#define SWIG_CAST_NEW_MEMORY 0x2 149 | 150 | /* Flags for new pointer objects */ 151 | #define SWIG_POINTER_OWN 0x1 152 | 153 | 154 | -/* 155 | +/* 156 | Flags/methods for returning states. 157 | - 158 | - The swig conversion methods, as ConvertPtr, return and integer 159 | + 160 | + The SWIG conversion methods, as ConvertPtr, return an integer 161 | that tells if the conversion was successful or not. And if not, 162 | an error code can be returned (see swigerrors.swg for the codes). 163 | - 164 | + 165 | Use the following macros/flags to set or process the returning 166 | states. 167 | - 168 | - In old swig versions, you usually write code as: 169 | + 170 | + In old versions of SWIG, code such as the following was usually written: 171 | 172 | if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) { 173 | // success code 174 | @@ -178,7 +198,7 @@ 175 | //fail code 176 | } 177 | 178 | - Now you can be more explicit as: 179 | + Now you can be more explicit: 180 | 181 | int res = SWIG_ConvertPtr(obj,vptr,ty.flags); 182 | if (SWIG_IsOK(res)) { 183 | @@ -187,7 +207,7 @@ 184 | // fail code 185 | } 186 | 187 | - that seems to be the same, but now you can also do 188 | + which is the same really, but now you can also do 189 | 190 | Type *ptr; 191 | int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags); 192 | @@ -202,28 +222,28 @@ 193 | } else { 194 | // fail code 195 | } 196 | - 197 | + 198 | I.e., now SWIG_ConvertPtr can return new objects and you can 199 | identify the case and take care of the deallocation. Of course that 200 | - requires also to SWIG_ConvertPtr to return new result values, as 201 | + also requires SWIG_ConvertPtr to return new result values, such as 202 | 203 | - int SWIG_ConvertPtr(obj, ptr,...) { 204 | - if () { 205 | - if () { 206 | - *ptr = ; 207 | - return SWIG_NEWOBJ; 208 | - } else { 209 | - *ptr = ; 210 | - return SWIG_OLDOBJ; 211 | - } 212 | - } else { 213 | - return SWIG_BADOBJ; 214 | - } 215 | + int SWIG_ConvertPtr(obj, ptr,...) { 216 | + if () { 217 | + if () { 218 | + *ptr = ; 219 | + return SWIG_NEWOBJ; 220 | + } else { 221 | + *ptr = ; 222 | + return SWIG_OLDOBJ; 223 | + } 224 | + } else { 225 | + return SWIG_BADOBJ; 226 | + } 227 | } 228 | 229 | Of course, returning the plain '0(success)/-1(fail)' still works, but you can be 230 | more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the 231 | - swig errors code. 232 | + SWIG errors code. 233 | 234 | Finally, if the SWIG_CASTRANK_MODE is enabled, the result code 235 | allows to return the 'cast rank', for example, if you have this 236 | @@ -232,18 +252,17 @@ 237 | int fooi(int); 238 | 239 | and you call 240 | - 241 | + 242 | food(1) // cast rank '1' (1 -> 1.0) 243 | fooi(1) // cast rank '0' 244 | 245 | just use the SWIG_AddCast()/SWIG_CheckState() 246 | +*/ 247 | 248 | - 249 | - */ 250 | -#define SWIG_OK (0) 251 | +#define SWIG_OK (0) 252 | #define SWIG_ERROR (-1) 253 | #define SWIG_IsOK(r) (r >= 0) 254 | -#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError) 255 | +#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError) 256 | 257 | /* The CastRankLimit says how many bits are used for the cast rank */ 258 | #define SWIG_CASTRANKLIMIT (1 << 8) 259 | @@ -264,7 +283,6 @@ 260 | #define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r) 261 | #define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK)) 262 | 263 | - 264 | /* Cast-Rank Mode */ 265 | #if defined(SWIG_CASTRANK_MODE) 266 | # ifndef SWIG_TypeRank 267 | @@ -275,30 +293,28 @@ 268 | # endif 269 | # define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1) 270 | # define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK) 271 | -SWIGINTERNINLINE int SWIG_AddCast(int r) { 272 | +SWIGINTERNINLINE int SWIG_AddCast(int r) { 273 | return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; 274 | } 275 | -SWIGINTERNINLINE int SWIG_CheckState(int r) { 276 | - return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; 277 | +SWIGINTERNINLINE int SWIG_CheckState(int r) { 278 | + return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; 279 | } 280 | #else /* no cast-rank mode */ 281 | -# define SWIG_AddCast 282 | +# define SWIG_AddCast(r) (r) 283 | # define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0) 284 | #endif 285 | 286 | 287 | - 288 | - 289 | #include 290 | 291 | #ifdef __cplusplus 292 | extern "C" { 293 | #endif 294 | 295 | -typedef void *(*swig_converter_func)(void *); 296 | +typedef void *(*swig_converter_func)(void *, int *); 297 | typedef struct swig_type_info *(*swig_dycast_func)(void **); 298 | 299 | -/* Structure to store inforomation on one type */ 300 | +/* Structure to store information on one type */ 301 | typedef struct swig_type_info { 302 | const char *name; /* mangled name of this type */ 303 | const char *str; /* human readable name of this type */ 304 | @@ -328,7 +344,7 @@ 305 | void *clientdata; /* Language specific module data */ 306 | } swig_module_info; 307 | 308 | -/* 309 | +/* 310 | Compare two type names skipping the space characters, therefore 311 | "char*" == "char *" and "Class" == "Class", etc. 312 | 313 | @@ -343,23 +359,23 @@ 314 | while ((*f2 == ' ') && (f2 != l2)) ++f2; 315 | if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1; 316 | } 317 | - return (l1 - f1) - (l2 - f2); 318 | + return (int)((l1 - f1) - (l2 - f2)); 319 | } 320 | 321 | /* 322 | Check type equivalence in a name list like ||... 323 | - Return 0 if not equal, 1 if equal 324 | + Return 0 if equal, -1 if nb < tb, 1 if nb > tb 325 | */ 326 | SWIGRUNTIME int 327 | -SWIG_TypeEquiv(const char *nb, const char *tb) { 328 | - int equiv = 0; 329 | +SWIG_TypeCmp(const char *nb, const char *tb) { 330 | + int equiv = 1; 331 | const char* te = tb + strlen(tb); 332 | const char* ne = nb; 333 | - while (!equiv && *ne) { 334 | + while (equiv != 0 && *ne) { 335 | for (nb = ne; *ne; ++ne) { 336 | if (*ne == '|') break; 337 | } 338 | - equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; 339 | + equiv = SWIG_TypeNameComp(nb, ne, tb, te); 340 | if (*ne) ++ne; 341 | } 342 | return equiv; 343 | @@ -367,69 +383,76 @@ 344 | 345 | /* 346 | Check type equivalence in a name list like ||... 347 | - Return 0 if equal, -1 if nb < tb, 1 if nb > tb 348 | + Return 0 if not equal, 1 if equal 349 | */ 350 | SWIGRUNTIME int 351 | -SWIG_TypeCompare(const char *nb, const char *tb) { 352 | - int equiv = 0; 353 | - const char* te = tb + strlen(tb); 354 | - const char* ne = nb; 355 | - while (!equiv && *ne) { 356 | - for (nb = ne; *ne; ++ne) { 357 | - if (*ne == '|') break; 358 | - } 359 | - equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; 360 | - if (*ne) ++ne; 361 | - } 362 | - return equiv; 363 | +SWIG_TypeEquiv(const char *nb, const char *tb) { 364 | + return SWIG_TypeCmp(nb, tb) == 0 ? 1 : 0; 365 | } 366 | 367 | - 368 | -/* think of this as a c++ template<> or a scheme macro */ 369 | -#define SWIG_TypeCheck_Template(comparison, ty) \ 370 | - if (ty) { \ 371 | - swig_cast_info *iter = ty->cast; \ 372 | - while (iter) { \ 373 | - if (comparison) { \ 374 | - if (iter == ty->cast) return iter; \ 375 | - /* Move iter to the top of the linked list */ \ 376 | - iter->prev->next = iter->next; \ 377 | - if (iter->next) \ 378 | - iter->next->prev = iter->prev; \ 379 | - iter->next = ty->cast; \ 380 | - iter->prev = 0; \ 381 | - if (ty->cast) ty->cast->prev = iter; \ 382 | - ty->cast = iter; \ 383 | - return iter; \ 384 | - } \ 385 | - iter = iter->next; \ 386 | - } \ 387 | - } \ 388 | - return 0 389 | - 390 | /* 391 | Check the typename 392 | */ 393 | SWIGRUNTIME swig_cast_info * 394 | SWIG_TypeCheck(const char *c, swig_type_info *ty) { 395 | - SWIG_TypeCheck_Template(strcmp(iter->type->name, c) == 0, ty); 396 | + if (ty) { 397 | + swig_cast_info *iter = ty->cast; 398 | + while (iter) { 399 | + if (strcmp(iter->type->name, c) == 0) { 400 | + if (iter == ty->cast) 401 | + return iter; 402 | + /* Move iter to the top of the linked list */ 403 | + iter->prev->next = iter->next; 404 | + if (iter->next) 405 | + iter->next->prev = iter->prev; 406 | + iter->next = ty->cast; 407 | + iter->prev = 0; 408 | + if (ty->cast) ty->cast->prev = iter; 409 | + ty->cast = iter; 410 | + return iter; 411 | + } 412 | + iter = iter->next; 413 | + } 414 | + } 415 | + return 0; 416 | } 417 | 418 | -/* Same as previous function, except strcmp is replaced with a pointer comparison */ 419 | +/* 420 | + Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison 421 | +*/ 422 | SWIGRUNTIME swig_cast_info * 423 | -SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) { 424 | - SWIG_TypeCheck_Template(iter->type == from, into); 425 | +SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *ty) { 426 | + if (ty) { 427 | + swig_cast_info *iter = ty->cast; 428 | + while (iter) { 429 | + if (iter->type == from) { 430 | + if (iter == ty->cast) 431 | + return iter; 432 | + /* Move iter to the top of the linked list */ 433 | + iter->prev->next = iter->next; 434 | + if (iter->next) 435 | + iter->next->prev = iter->prev; 436 | + iter->next = ty->cast; 437 | + iter->prev = 0; 438 | + if (ty->cast) ty->cast->prev = iter; 439 | + ty->cast = iter; 440 | + return iter; 441 | + } 442 | + iter = iter->next; 443 | + } 444 | + } 445 | + return 0; 446 | } 447 | 448 | /* 449 | Cast a pointer up an inheritance hierarchy 450 | */ 451 | SWIGRUNTIMEINLINE void * 452 | -SWIG_TypeCast(swig_cast_info *ty, void *ptr) { 453 | - return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr); 454 | +SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) { 455 | + return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory); 456 | } 457 | 458 | -/* 459 | +/* 460 | Dynamic pointer casting. Down an inheritance hierarchy 461 | */ 462 | SWIGRUNTIME swig_type_info * 463 | @@ -473,7 +496,7 @@ 464 | return type->name; 465 | } 466 | 467 | -/* 468 | +/* 469 | Set the clientdata field for a type 470 | */ 471 | SWIGRUNTIME void 472 | @@ -481,14 +504,14 @@ 473 | swig_cast_info *cast = ti->cast; 474 | /* if (ti->clientdata == clientdata) return; */ 475 | ti->clientdata = clientdata; 476 | - 477 | + 478 | while (cast) { 479 | if (!cast->converter) { 480 | swig_type_info *tc = cast->type; 481 | if (!tc->clientdata) { 482 | SWIG_TypeClientData(tc, clientdata); 483 | } 484 | - } 485 | + } 486 | cast = cast->next; 487 | } 488 | } 489 | @@ -497,31 +520,31 @@ 490 | SWIG_TypeClientData(ti, clientdata); 491 | ti->owndata = 1; 492 | } 493 | - 494 | + 495 | /* 496 | Search for a swig_type_info structure only by mangled name 497 | Search is a O(log #types) 498 | - 499 | - We start searching at module start, and finish searching when start == end. 500 | + 501 | + We start searching at module start, and finish searching when start == end. 502 | Note: if start == end at the beginning of the function, we go all the way around 503 | the circular list. 504 | */ 505 | SWIGRUNTIME swig_type_info * 506 | -SWIG_MangledTypeQueryModule(swig_module_info *start, 507 | - swig_module_info *end, 508 | +SWIG_MangledTypeQueryModule(swig_module_info *start, 509 | + swig_module_info *end, 510 | const char *name) { 511 | swig_module_info *iter = start; 512 | do { 513 | if (iter->size) { 514 | - register size_t l = 0; 515 | - register size_t r = iter->size - 1; 516 | + size_t l = 0; 517 | + size_t r = iter->size - 1; 518 | do { 519 | /* since l+r >= 0, we can (>> 1) instead (/ 2) */ 520 | - register size_t i = (l + r) >> 1; 521 | + size_t i = (l + r) >> 1; 522 | const char *iname = iter->types[i]->name; 523 | if (iname) { 524 | - register int compare = strcmp(name, iname); 525 | - if (compare == 0) { 526 | + int compare = strcmp(name, iname); 527 | + if (compare == 0) { 528 | return iter->types[i]; 529 | } else if (compare < 0) { 530 | if (i) { 531 | @@ -546,14 +569,14 @@ 532 | Search for a swig_type_info structure for either a mangled name or a human readable name. 533 | It first searches the mangled names of the types, which is a O(log #types) 534 | If a type is not found it then searches the human readable names, which is O(#types). 535 | - 536 | - We start searching at module start, and finish searching when start == end. 537 | + 538 | + We start searching at module start, and finish searching when start == end. 539 | Note: if start == end at the beginning of the function, we go all the way around 540 | the circular list. 541 | */ 542 | SWIGRUNTIME swig_type_info * 543 | -SWIG_TypeQueryModule(swig_module_info *start, 544 | - swig_module_info *end, 545 | +SWIG_TypeQueryModule(swig_module_info *start, 546 | + swig_module_info *end, 547 | const char *name) { 548 | /* STEP 1: Search the name field using binary search */ 549 | swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); 550 | @@ -564,7 +587,7 @@ 551 | of the str field (the human readable name) */ 552 | swig_module_info *iter = start; 553 | do { 554 | - register size_t i = 0; 555 | + size_t i = 0; 556 | for (; i < iter->size; ++i) { 557 | if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) 558 | return iter->types[i]; 559 | @@ -572,56 +595,56 @@ 560 | iter = iter->next; 561 | } while (iter != end); 562 | } 563 | - 564 | + 565 | /* neither found a match */ 566 | return 0; 567 | } 568 | 569 | -/* 570 | +/* 571 | Pack binary data into a string 572 | */ 573 | SWIGRUNTIME char * 574 | SWIG_PackData(char *c, void *ptr, size_t sz) { 575 | static const char hex[17] = "0123456789abcdef"; 576 | - register const unsigned char *u = (unsigned char *) ptr; 577 | - register const unsigned char *eu = u + sz; 578 | + const unsigned char *u = (unsigned char *) ptr; 579 | + const unsigned char *eu = u + sz; 580 | for (; u != eu; ++u) { 581 | - register unsigned char uu = *u; 582 | + unsigned char uu = *u; 583 | *(c++) = hex[(uu & 0xf0) >> 4]; 584 | *(c++) = hex[uu & 0xf]; 585 | } 586 | return c; 587 | } 588 | 589 | -/* 590 | +/* 591 | Unpack binary data from a string 592 | */ 593 | SWIGRUNTIME const char * 594 | SWIG_UnpackData(const char *c, void *ptr, size_t sz) { 595 | - register unsigned char *u = (unsigned char *) ptr; 596 | - register const unsigned char *eu = u + sz; 597 | + unsigned char *u = (unsigned char *) ptr; 598 | + const unsigned char *eu = u + sz; 599 | for (; u != eu; ++u) { 600 | - register char d = *(c++); 601 | - register unsigned char uu; 602 | + char d = *(c++); 603 | + unsigned char uu; 604 | if ((d >= '0') && (d <= '9')) 605 | uu = ((d - '0') << 4); 606 | else if ((d >= 'a') && (d <= 'f')) 607 | uu = ((d - ('a'-10)) << 4); 608 | - else 609 | + else 610 | return (char *) 0; 611 | d = *(c++); 612 | if ((d >= '0') && (d <= '9')) 613 | uu |= (d - '0'); 614 | else if ((d >= 'a') && (d <= 'f')) 615 | uu |= (d - ('a'-10)); 616 | - else 617 | + else 618 | return (char *) 0; 619 | *u = uu; 620 | } 621 | return c; 622 | } 623 | 624 | -/* 625 | +/* 626 | Pack 'void *' into a string buffer. 627 | */ 628 | SWIGRUNTIME char * 629 | @@ -681,22 +704,92 @@ 630 | #endif 631 | 632 | /* Errors in SWIG */ 633 | -#define SWIG_UnknownError -1 634 | -#define SWIG_IOError -2 635 | -#define SWIG_RuntimeError -3 636 | -#define SWIG_IndexError -4 637 | -#define SWIG_TypeError -5 638 | -#define SWIG_DivisionByZero -6 639 | -#define SWIG_OverflowError -7 640 | -#define SWIG_SyntaxError -8 641 | -#define SWIG_ValueError -9 642 | +#define SWIG_UnknownError -1 643 | +#define SWIG_IOError -2 644 | +#define SWIG_RuntimeError -3 645 | +#define SWIG_IndexError -4 646 | +#define SWIG_TypeError -5 647 | +#define SWIG_DivisionByZero -6 648 | +#define SWIG_OverflowError -7 649 | +#define SWIG_SyntaxError -8 650 | +#define SWIG_ValueError -9 651 | #define SWIG_SystemError -10 652 | #define SWIG_AttributeError -11 653 | -#define SWIG_MemoryError -12 654 | +#define SWIG_MemoryError -12 655 | #define SWIG_NullReferenceError -13 656 | 657 | 658 | 659 | +/* Compatibility macros for Python 3 */ 660 | +#if PY_VERSION_HEX >= 0x03000000 661 | + 662 | +#define PyClass_Check(obj) PyObject_IsInstance(obj, (PyObject *)&PyType_Type) 663 | +#define PyInt_Check(x) PyLong_Check(x) 664 | +#define PyInt_AsLong(x) PyLong_AsLong(x) 665 | +#define PyInt_FromLong(x) PyLong_FromLong(x) 666 | +#define PyInt_FromSize_t(x) PyLong_FromSize_t(x) 667 | +#define PyString_Check(name) PyBytes_Check(name) 668 | +#define PyString_FromString(x) PyUnicode_FromString(x) 669 | +#define PyString_Format(fmt, args) PyUnicode_Format(fmt, args) 670 | +#define PyString_AsString(str) PyBytes_AsString(str) 671 | +#define PyString_Size(str) PyBytes_Size(str) 672 | +#define PyString_InternFromString(key) PyUnicode_InternFromString(key) 673 | +#define Py_TPFLAGS_HAVE_CLASS Py_TPFLAGS_BASETYPE 674 | +#define PyString_AS_STRING(x) PyUnicode_AS_STRING(x) 675 | +#define _PyLong_FromSsize_t(x) PyLong_FromSsize_t(x) 676 | + 677 | +#endif 678 | + 679 | +#ifndef Py_TYPE 680 | +# define Py_TYPE(op) ((op)->ob_type) 681 | +#endif 682 | + 683 | +/* SWIG APIs for compatibility of both Python 2 & 3 */ 684 | + 685 | +#if PY_VERSION_HEX >= 0x03000000 686 | +# define SWIG_Python_str_FromFormat PyUnicode_FromFormat 687 | +#else 688 | +# define SWIG_Python_str_FromFormat PyString_FromFormat 689 | +#endif 690 | + 691 | + 692 | +/* Warning: This function will allocate a new string in Python 3, 693 | + * so please call SWIG_Python_str_DelForPy3(x) to free the space. 694 | + */ 695 | +SWIGINTERN char* 696 | +SWIG_Python_str_AsChar(PyObject *str) 697 | +{ 698 | +#if PY_VERSION_HEX >= 0x03000000 699 | + char *cstr; 700 | + char *newstr; 701 | + Py_ssize_t len; 702 | + str = PyUnicode_AsUTF8String(str); 703 | + PyBytes_AsStringAndSize(str, &cstr, &len); 704 | + newstr = (char *) malloc(len+1); 705 | + memcpy(newstr, cstr, len+1); 706 | + Py_XDECREF(str); 707 | + return newstr; 708 | +#else 709 | + return PyString_AsString(str); 710 | +#endif 711 | +} 712 | + 713 | +#if PY_VERSION_HEX >= 0x03000000 714 | +# define SWIG_Python_str_DelForPy3(x) free( (void*) (x) ) 715 | +#else 716 | +# define SWIG_Python_str_DelForPy3(x) 717 | +#endif 718 | + 719 | + 720 | +SWIGINTERN PyObject* 721 | +SWIG_Python_str_FromChar(const char *c) 722 | +{ 723 | +#if PY_VERSION_HEX >= 0x03000000 724 | + return PyUnicode_FromString(c); 725 | +#else 726 | + return PyString_FromString(c); 727 | +#endif 728 | +} 729 | 730 | /* Add PyOS_snprintf for old Pythons */ 731 | #if PY_VERSION_HEX < 0x02020000 732 | @@ -743,6 +836,7 @@ 733 | # define PyObject_GenericGetAttr 0 734 | # endif 735 | #endif 736 | + 737 | /* Py_NotImplemented is defined in 2.1 and up. */ 738 | #if PY_VERSION_HEX < 0x02010000 739 | # ifndef Py_NotImplemented 740 | @@ -750,7 +844,6 @@ 741 | # endif 742 | #endif 743 | 744 | - 745 | /* A crude PyString_AsStringAndSize implementation for old Pythons */ 746 | #if PY_VERSION_HEX < 0x02010000 747 | # ifndef PyString_AsStringAndSize 748 | @@ -765,7 +858,6 @@ 749 | # endif 750 | #endif 751 | 752 | - 753 | /* PyBool_FromLong for old Pythons */ 754 | #if PY_VERSION_HEX < 0x02030000 755 | static 756 | @@ -784,6 +876,67 @@ 757 | typedef int Py_ssize_t; 758 | # define PY_SSIZE_T_MAX INT_MAX 759 | # define PY_SSIZE_T_MIN INT_MIN 760 | +typedef inquiry lenfunc; 761 | +typedef intargfunc ssizeargfunc; 762 | +typedef intintargfunc ssizessizeargfunc; 763 | +typedef intobjargproc ssizeobjargproc; 764 | +typedef intintobjargproc ssizessizeobjargproc; 765 | +typedef getreadbufferproc readbufferproc; 766 | +typedef getwritebufferproc writebufferproc; 767 | +typedef getsegcountproc segcountproc; 768 | +typedef getcharbufferproc charbufferproc; 769 | +static long PyNumber_AsSsize_t (PyObject *x, void *SWIGUNUSEDPARM(exc)) 770 | +{ 771 | + long result = 0; 772 | + PyObject *i = PyNumber_Int(x); 773 | + if (i) { 774 | + result = PyInt_AsLong(i); 775 | + Py_DECREF(i); 776 | + } 777 | + return result; 778 | +} 779 | +#endif 780 | + 781 | +#if PY_VERSION_HEX < 0x02050000 782 | +#define PyInt_FromSize_t(x) PyInt_FromLong((long)x) 783 | +#endif 784 | + 785 | +#if PY_VERSION_HEX < 0x02040000 786 | +#define Py_VISIT(op) \ 787 | + do { \ 788 | + if (op) { \ 789 | + int vret = visit((op), arg); \ 790 | + if (vret) \ 791 | + return vret; \ 792 | + } \ 793 | + } while (0) 794 | +#endif 795 | + 796 | +#if PY_VERSION_HEX < 0x02030000 797 | +typedef struct { 798 | + PyTypeObject type; 799 | + PyNumberMethods as_number; 800 | + PyMappingMethods as_mapping; 801 | + PySequenceMethods as_sequence; 802 | + PyBufferProcs as_buffer; 803 | + PyObject *name, *slots; 804 | +} PyHeapTypeObject; 805 | +#endif 806 | + 807 | +#if PY_VERSION_HEX < 0x02030000 808 | +typedef destructor freefunc; 809 | +#endif 810 | + 811 | +#if ((PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION > 6) || \ 812 | + (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION > 0) || \ 813 | + (PY_MAJOR_VERSION > 3)) 814 | +# define SWIGPY_USE_CAPSULE 815 | +# define SWIGPY_CAPSULE_NAME ((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION ".type_pointer_capsule" SWIG_TYPE_TABLE_NAME) 816 | +#endif 817 | + 818 | +#if PY_VERSION_HEX < 0x03020000 819 | +#define PyDescr_TYPE(x) (((PyDescrObject *)(x))->d_type) 820 | +#define PyDescr_NAME(x) (((PyDescrObject *)(x))->d_name) 821 | #endif 822 | 823 | /* ----------------------------------------------------------------------------- 824 | @@ -843,19 +996,20 @@ 825 | 826 | if (PyErr_Occurred()) PyErr_Fetch(&type, &value, &traceback); 827 | if (value) { 828 | + char *tmp; 829 | PyObject *old_str = PyObject_Str(value); 830 | PyErr_Clear(); 831 | Py_XINCREF(type); 832 | - PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg); 833 | + 834 | + PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg); 835 | + SWIG_Python_str_DelForPy3(tmp); 836 | Py_DECREF(old_str); 837 | Py_DECREF(value); 838 | } else { 839 | - PyErr_Format(PyExc_RuntimeError, mesg); 840 | + PyErr_SetString(PyExc_RuntimeError, mesg); 841 | } 842 | } 843 | 844 | - 845 | - 846 | #if defined(SWIG_PYTHON_NO_THREADS) 847 | # if defined(SWIG_PYTHON_THREADS) 848 | # undef SWIG_PYTHON_THREADS 849 | @@ -929,9 +1083,6 @@ 850 | 851 | #ifdef __cplusplus 852 | extern "C" { 853 | -#if 0 854 | -} /* cc-mode */ 855 | -#endif 856 | #endif 857 | 858 | /* ----------------------------------------------------------------------------- 859 | @@ -952,18 +1103,29 @@ 860 | swig_type_info **ptype; 861 | } swig_const_info; 862 | 863 | -#ifdef __cplusplus 864 | -#if 0 865 | -{ /* cc-mode */ 866 | + 867 | +/* ----------------------------------------------------------------------------- 868 | + * Wrapper of PyInstanceMethod_New() used in Python 3 869 | + * It is exported to the generated module, used for -fastproxy 870 | + * ----------------------------------------------------------------------------- */ 871 | +#if PY_VERSION_HEX >= 0x03000000 872 | +SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func) 873 | +{ 874 | + return PyInstanceMethod_New(func); 875 | +} 876 | +#else 877 | +SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *SWIGUNUSEDPARM(func)) 878 | +{ 879 | + return NULL; 880 | +} 881 | #endif 882 | + 883 | +#ifdef __cplusplus 884 | } 885 | #endif 886 | 887 | 888 | /* ----------------------------------------------------------------------------- 889 | - * See the LICENSE file for information on copyright, usage and redistribution 890 | - * of SWIG, and the README file for authors - http://www.swig.org/release.html. 891 | - * 892 | * pyrun.swg 893 | * 894 | * This file contains the runtime support for Python modules 895 | @@ -978,7 +1140,15 @@ 896 | #define SWIG_Python_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, 0) 897 | #define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtr(obj, pptr, type, flags) 898 | #define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, own) 899 | -#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(ptr, type, flags) 900 | + 901 | +#ifdef SWIGPYTHON_BUILTIN 902 | +#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(self, ptr, type, flags) 903 | +#else 904 | +#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(NULL, ptr, type, flags) 905 | +#endif 906 | + 907 | +#define SWIG_InternalNewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(NULL, ptr, type, flags) 908 | + 909 | #define SWIG_CheckImplicit(ty) SWIG_Python_CheckImplicit(ty) 910 | #define SWIG_AcquirePtr(ptr, src) SWIG_Python_AcquirePtr(ptr, src) 911 | #define swig_owntype int 912 | @@ -993,7 +1163,7 @@ 913 | 914 | /* for C or C++ function pointers */ 915 | #define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_Python_ConvertFunctionPtr(obj, pptr, type) 916 | -#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_Python_NewPointerObj(ptr, type, 0) 917 | +#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_Python_NewPointerObj(NULL, ptr, type, 0) 918 | 919 | /* for C++ member pointers, ie, member methods */ 920 | #define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) 921 | @@ -1002,9 +1172,9 @@ 922 | 923 | /* Runtime API */ 924 | 925 | -#define SWIG_GetModule(clientdata) SWIG_Python_GetModule() 926 | +#define SWIG_GetModule(clientdata) SWIG_Python_GetModule(clientdata) 927 | #define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer) 928 | -#define SWIG_NewClientData(obj) PySwigClientData_New(obj) 929 | +#define SWIG_NewClientData(obj) SwigPyClientData_New(obj) 930 | 931 | #define SWIG_SetErrorObj SWIG_Python_SetErrorObj 932 | #define SWIG_SetErrorMsg SWIG_Python_SetErrorMsg 933 | @@ -1028,7 +1198,7 @@ 934 | SWIGINTERN void 935 | SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) { 936 | SWIG_PYTHON_THREAD_BEGIN_BLOCK; 937 | - PyErr_SetString(errtype, (char *) msg); 938 | + PyErr_SetString(errtype, msg); 939 | SWIG_PYTHON_THREAD_END_BLOCK; 940 | } 941 | 942 | @@ -1036,12 +1206,41 @@ 943 | 944 | /* Set a constant value */ 945 | 946 | +#if defined(SWIGPYTHON_BUILTIN) 947 | + 948 | +SWIGINTERN void 949 | +SwigPyBuiltin_AddPublicSymbol(PyObject *seq, const char *key) { 950 | + PyObject *s = PyString_InternFromString(key); 951 | + PyList_Append(seq, s); 952 | + Py_DECREF(s); 953 | +} 954 | + 955 | +SWIGINTERN void 956 | +SWIG_Python_SetConstant(PyObject *d, PyObject *public_interface, const char *name, PyObject *obj) { 957 | +#if PY_VERSION_HEX < 0x02030000 958 | + PyDict_SetItemString(d, (char *)name, obj); 959 | +#else 960 | + PyDict_SetItemString(d, name, obj); 961 | +#endif 962 | + Py_DECREF(obj); 963 | + if (public_interface) 964 | + SwigPyBuiltin_AddPublicSymbol(public_interface, name); 965 | +} 966 | + 967 | +#else 968 | + 969 | SWIGINTERN void 970 | SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) { 971 | - PyDict_SetItemString(d, (char*) name, obj); 972 | +#if PY_VERSION_HEX < 0x02030000 973 | + PyDict_SetItemString(d, (char *)name, obj); 974 | +#else 975 | + PyDict_SetItemString(d, name, obj); 976 | +#endif 977 | Py_DECREF(obj); 978 | } 979 | 980 | +#endif 981 | + 982 | /* Append a value to the result obj */ 983 | 984 | SWIGINTERN PyObject* 985 | @@ -1090,32 +1289,40 @@ 986 | /* Unpack the argument tuple */ 987 | 988 | SWIGINTERN int 989 | -SWIG_Python_UnpackTuple(PyObject *args, const char *name, int min, int max, PyObject **objs) 990 | +SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs) 991 | { 992 | if (!args) { 993 | if (!min && !max) { 994 | return 1; 995 | } else { 996 | PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got none", 997 | - name, (min == max ? "" : "at least "), min); 998 | + name, (min == max ? "" : "at least "), (int)min); 999 | return 0; 1000 | } 1001 | } 1002 | if (!PyTuple_Check(args)) { 1003 | + if (min <= 1 && max >= 1) { 1004 | + int i; 1005 | + objs[0] = args; 1006 | + for (i = 1; i < max; ++i) { 1007 | + objs[i] = 0; 1008 | + } 1009 | + return 2; 1010 | + } 1011 | PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple"); 1012 | return 0; 1013 | } else { 1014 | - register int l = PyTuple_GET_SIZE(args); 1015 | + Py_ssize_t l = PyTuple_GET_SIZE(args); 1016 | if (l < min) { 1017 | PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", 1018 | - name, (min == max ? "" : "at least "), min, l); 1019 | + name, (min == max ? "" : "at least "), (int)min, (int)l); 1020 | return 0; 1021 | } else if (l > max) { 1022 | PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", 1023 | - name, (min == max ? "" : "at most "), max, l); 1024 | + name, (min == max ? "" : "at most "), (int)max, (int)l); 1025 | return 0; 1026 | } else { 1027 | - register int i; 1028 | + int i; 1029 | for (i = 0; i < l; ++i) { 1030 | objs[i] = PyTuple_GET_ITEM(args, i); 1031 | } 1032 | @@ -1154,11 +1361,11 @@ 1033 | 1034 | #define SWIG_POINTER_IMPLICIT_CONV (SWIG_POINTER_DISOWN << 1) 1035 | 1036 | +#define SWIG_BUILTIN_TP_INIT (SWIG_POINTER_OWN << 2) 1037 | +#define SWIG_BUILTIN_INIT (SWIG_BUILTIN_TP_INIT | SWIG_POINTER_OWN) 1038 | + 1039 | #ifdef __cplusplus 1040 | extern "C" { 1041 | -#if 0 1042 | -} /* cc-mode */ 1043 | -#endif 1044 | #endif 1045 | 1046 | /* How to access Py_None */ 1047 | @@ -1200,7 +1407,7 @@ 1048 | return none; 1049 | } 1050 | 1051 | -/* PySwigClientData */ 1052 | +/* SwigPyClientData */ 1053 | 1054 | typedef struct { 1055 | PyObject *klass; 1056 | @@ -1209,30 +1416,31 @@ 1057 | PyObject *destroy; 1058 | int delargs; 1059 | int implicitconv; 1060 | -} PySwigClientData; 1061 | + PyTypeObject *pytype; 1062 | +} SwigPyClientData; 1063 | 1064 | SWIGRUNTIMEINLINE int 1065 | SWIG_Python_CheckImplicit(swig_type_info *ty) 1066 | { 1067 | - PySwigClientData *data = (PySwigClientData *)ty->clientdata; 1068 | + SwigPyClientData *data = (SwigPyClientData *)ty->clientdata; 1069 | return data ? data->implicitconv : 0; 1070 | } 1071 | 1072 | SWIGRUNTIMEINLINE PyObject * 1073 | SWIG_Python_ExceptionType(swig_type_info *desc) { 1074 | - PySwigClientData *data = desc ? (PySwigClientData *) desc->clientdata : 0; 1075 | + SwigPyClientData *data = desc ? (SwigPyClientData *) desc->clientdata : 0; 1076 | PyObject *klass = data ? data->klass : 0; 1077 | return (klass ? klass : PyExc_RuntimeError); 1078 | } 1079 | 1080 | 1081 | -SWIGRUNTIME PySwigClientData * 1082 | -PySwigClientData_New(PyObject* obj) 1083 | +SWIGRUNTIME SwigPyClientData * 1084 | +SwigPyClientData_New(PyObject* obj) 1085 | { 1086 | if (!obj) { 1087 | return 0; 1088 | } else { 1089 | - PySwigClientData *data = (PySwigClientData *)malloc(sizeof(PySwigClientData)); 1090 | + SwigPyClientData *data = (SwigPyClientData *)malloc(sizeof(SwigPyClientData)); 1091 | /* the klass element */ 1092 | data->klass = obj; 1093 | Py_INCREF(data->klass); 1094 | @@ -1275,19 +1483,19 @@ 1095 | data->delargs = 0; 1096 | } 1097 | data->implicitconv = 0; 1098 | + data->pytype = 0; 1099 | return data; 1100 | } 1101 | } 1102 | 1103 | SWIGRUNTIME void 1104 | -PySwigClientData_Del(PySwigClientData* data) 1105 | -{ 1106 | +SwigPyClientData_Del(SwigPyClientData *data) { 1107 | Py_XDECREF(data->newraw); 1108 | Py_XDECREF(data->newargs); 1109 | Py_XDECREF(data->destroy); 1110 | } 1111 | 1112 | -/* =============== PySwigObject =====================*/ 1113 | +/* =============== SwigPyObject =====================*/ 1114 | 1115 | typedef struct { 1116 | PyObject_HEAD 1117 | @@ -1295,24 +1503,31 @@ 1118 | swig_type_info *ty; 1119 | int own; 1120 | PyObject *next; 1121 | -} PySwigObject; 1122 | +#ifdef SWIGPYTHON_BUILTIN 1123 | + PyObject *dict; 1124 | +#endif 1125 | +} SwigPyObject; 1126 | 1127 | SWIGRUNTIME PyObject * 1128 | -PySwigObject_long(PySwigObject *v) 1129 | +SwigPyObject_long(SwigPyObject *v) 1130 | { 1131 | return PyLong_FromVoidPtr(v->ptr); 1132 | } 1133 | 1134 | SWIGRUNTIME PyObject * 1135 | -PySwigObject_format(const char* fmt, PySwigObject *v) 1136 | +SwigPyObject_format(const char* fmt, SwigPyObject *v) 1137 | { 1138 | PyObject *res = NULL; 1139 | PyObject *args = PyTuple_New(1); 1140 | if (args) { 1141 | - if (PyTuple_SetItem(args, 0, PySwigObject_long(v)) == 0) { 1142 | - PyObject *ofmt = PyString_FromString(fmt); 1143 | + if (PyTuple_SetItem(args, 0, SwigPyObject_long(v)) == 0) { 1144 | + PyObject *ofmt = SWIG_Python_str_FromChar(fmt); 1145 | if (ofmt) { 1146 | +#if PY_VERSION_HEX >= 0x03000000 1147 | + res = PyUnicode_Format(ofmt,args); 1148 | +#else 1149 | res = PyString_Format(ofmt,args); 1150 | +#endif 1151 | Py_DECREF(ofmt); 1152 | } 1153 | Py_DECREF(args); 1154 | @@ -1322,104 +1537,118 @@ 1155 | } 1156 | 1157 | SWIGRUNTIME PyObject * 1158 | -PySwigObject_oct(PySwigObject *v) 1159 | +SwigPyObject_oct(SwigPyObject *v) 1160 | { 1161 | - return PySwigObject_format("%o",v); 1162 | + return SwigPyObject_format("%o",v); 1163 | } 1164 | 1165 | SWIGRUNTIME PyObject * 1166 | -PySwigObject_hex(PySwigObject *v) 1167 | +SwigPyObject_hex(SwigPyObject *v) 1168 | { 1169 | - return PySwigObject_format("%x",v); 1170 | + return SwigPyObject_format("%x",v); 1171 | } 1172 | 1173 | SWIGRUNTIME PyObject * 1174 | #ifdef METH_NOARGS 1175 | -PySwigObject_repr(PySwigObject *v) 1176 | +SwigPyObject_repr(SwigPyObject *v) 1177 | #else 1178 | -PySwigObject_repr(PySwigObject *v, PyObject *args) 1179 | +SwigPyObject_repr(SwigPyObject *v, PyObject *args) 1180 | #endif 1181 | { 1182 | const char *name = SWIG_TypePrettyName(v->ty); 1183 | - PyObject *hex = PySwigObject_hex(v); 1184 | - PyObject *repr = PyString_FromFormat("", name, PyString_AsString(hex)); 1185 | - Py_DECREF(hex); 1186 | + PyObject *repr = SWIG_Python_str_FromFormat("", (name ? name : "unknown"), (void *)v); 1187 | if (v->next) { 1188 | -#ifdef METH_NOARGS 1189 | - PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next); 1190 | -#else 1191 | - PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next, args); 1192 | -#endif 1193 | +# ifdef METH_NOARGS 1194 | + PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next); 1195 | +# else 1196 | + PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next, args); 1197 | +# endif 1198 | +# if PY_VERSION_HEX >= 0x03000000 1199 | + PyObject *joined = PyUnicode_Concat(repr, nrep); 1200 | + Py_DecRef(repr); 1201 | + Py_DecRef(nrep); 1202 | + repr = joined; 1203 | +# else 1204 | PyString_ConcatAndDel(&repr,nrep); 1205 | +# endif 1206 | } 1207 | return repr; 1208 | } 1209 | 1210 | SWIGRUNTIME int 1211 | -PySwigObject_print(PySwigObject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) 1212 | +SwigPyObject_compare(SwigPyObject *v, SwigPyObject *w) 1213 | { 1214 | -#ifdef METH_NOARGS 1215 | - PyObject *repr = PySwigObject_repr(v); 1216 | -#else 1217 | - PyObject *repr = PySwigObject_repr(v, NULL); 1218 | -#endif 1219 | - if (repr) { 1220 | - fputs(PyString_AsString(repr), fp); 1221 | - Py_DECREF(repr); 1222 | - return 0; 1223 | - } else { 1224 | - return 1; 1225 | - } 1226 | + void *i = v->ptr; 1227 | + void *j = w->ptr; 1228 | + return (i < j) ? -1 : ((i > j) ? 1 : 0); 1229 | } 1230 | 1231 | -SWIGRUNTIME PyObject * 1232 | -PySwigObject_str(PySwigObject *v) 1233 | +/* Added for Python 3.x, would it also be useful for Python 2.x? */ 1234 | +SWIGRUNTIME PyObject* 1235 | +SwigPyObject_richcompare(SwigPyObject *v, SwigPyObject *w, int op) 1236 | { 1237 | - char result[SWIG_BUFFER_SIZE]; 1238 | - return SWIG_PackVoidPtr(result, v->ptr, v->ty->name, sizeof(result)) ? 1239 | - PyString_FromString(result) : 0; 1240 | + PyObject* res; 1241 | + if( op != Py_EQ && op != Py_NE ) { 1242 | + Py_INCREF(Py_NotImplemented); 1243 | + return Py_NotImplemented; 1244 | + } 1245 | + res = PyBool_FromLong( (SwigPyObject_compare(v, w)==0) == (op == Py_EQ) ? 1 : 0); 1246 | + return res; 1247 | } 1248 | 1249 | -SWIGRUNTIME int 1250 | -PySwigObject_compare(PySwigObject *v, PySwigObject *w) 1251 | -{ 1252 | - void *i = v->ptr; 1253 | - void *j = w->ptr; 1254 | - return (i < j) ? -1 : ((i > j) ? 1 : 0); 1255 | -} 1256 | 1257 | -SWIGRUNTIME PyTypeObject* _PySwigObject_type(void); 1258 | +SWIGRUNTIME PyTypeObject* SwigPyObject_TypeOnce(void); 1259 | 1260 | +#ifdef SWIGPYTHON_BUILTIN 1261 | +static swig_type_info *SwigPyObject_stype = 0; 1262 | SWIGRUNTIME PyTypeObject* 1263 | -PySwigObject_type(void) { 1264 | - static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigObject_type(); 1265 | +SwigPyObject_type(void) { 1266 | + SwigPyClientData *cd; 1267 | + assert(SwigPyObject_stype); 1268 | + cd = (SwigPyClientData*) SwigPyObject_stype->clientdata; 1269 | + assert(cd); 1270 | + assert(cd->pytype); 1271 | + return cd->pytype; 1272 | +} 1273 | +#else 1274 | +SWIGRUNTIME PyTypeObject* 1275 | +SwigPyObject_type(void) { 1276 | + static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyObject_TypeOnce(); 1277 | return type; 1278 | } 1279 | +#endif 1280 | 1281 | SWIGRUNTIMEINLINE int 1282 | -PySwigObject_Check(PyObject *op) { 1283 | - return ((op)->ob_type == PySwigObject_type()) 1284 | - || (strcmp((op)->ob_type->tp_name,"PySwigObject") == 0); 1285 | +SwigPyObject_Check(PyObject *op) { 1286 | +#ifdef SWIGPYTHON_BUILTIN 1287 | + PyTypeObject *target_tp = SwigPyObject_type(); 1288 | + if (PyType_IsSubtype(op->ob_type, target_tp)) 1289 | + return 1; 1290 | + return (strcmp(op->ob_type->tp_name, "SwigPyObject") == 0); 1291 | +#else 1292 | + return (Py_TYPE(op) == SwigPyObject_type()) 1293 | + || (strcmp(Py_TYPE(op)->tp_name,"SwigPyObject") == 0); 1294 | +#endif 1295 | } 1296 | 1297 | SWIGRUNTIME PyObject * 1298 | -PySwigObject_New(void *ptr, swig_type_info *ty, int own); 1299 | +SwigPyObject_New(void *ptr, swig_type_info *ty, int own); 1300 | 1301 | SWIGRUNTIME void 1302 | -PySwigObject_dealloc(PyObject *v) 1303 | +SwigPyObject_dealloc(PyObject *v) 1304 | { 1305 | - PySwigObject *sobj = (PySwigObject *) v; 1306 | + SwigPyObject *sobj = (SwigPyObject *) v; 1307 | PyObject *next = sobj->next; 1308 | - if (sobj->own) { 1309 | + if (sobj->own == SWIG_POINTER_OWN) { 1310 | swig_type_info *ty = sobj->ty; 1311 | - PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0; 1312 | + SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; 1313 | PyObject *destroy = data ? data->destroy : 0; 1314 | if (destroy) { 1315 | /* destroy is always a VARARGS method */ 1316 | PyObject *res; 1317 | if (data->delargs) { 1318 | - /* we need to create a temporal object to carry the destroy operation */ 1319 | - PyObject *tmp = PySwigObject_New(sobj->ptr, ty, 0); 1320 | + /* we need to create a temporary object to carry the destroy operation */ 1321 | + PyObject *tmp = SwigPyObject_New(sobj->ptr, ty, 0); 1322 | res = SWIG_Python_CallFunctor(destroy, tmp); 1323 | Py_DECREF(tmp); 1324 | } else { 1325 | @@ -1428,27 +1657,28 @@ 1326 | res = ((*meth)(mself, v)); 1327 | } 1328 | Py_XDECREF(res); 1329 | - } else { 1330 | - const char *name = SWIG_TypePrettyName(ty); 1331 | + } 1332 | #if !defined(SWIG_PYTHON_SILENT_MEMLEAK) 1333 | - printf("swig/python detected a memory leak of type '%s', no destructor found.\n", name); 1334 | -#endif 1335 | + else { 1336 | + const char *name = SWIG_TypePrettyName(ty); 1337 | + printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown")); 1338 | } 1339 | +#endif 1340 | } 1341 | Py_XDECREF(next); 1342 | PyObject_DEL(v); 1343 | } 1344 | 1345 | SWIGRUNTIME PyObject* 1346 | -PySwigObject_append(PyObject* v, PyObject* next) 1347 | +SwigPyObject_append(PyObject* v, PyObject* next) 1348 | { 1349 | - PySwigObject *sobj = (PySwigObject *) v; 1350 | + SwigPyObject *sobj = (SwigPyObject *) v; 1351 | #ifndef METH_O 1352 | PyObject *tmp = 0; 1353 | if (!PyArg_ParseTuple(next,(char *)"O:append", &tmp)) return NULL; 1354 | next = tmp; 1355 | #endif 1356 | - if (!PySwigObject_Check(next)) { 1357 | + if (!SwigPyObject_Check(next)) { 1358 | return NULL; 1359 | } 1360 | sobj->next = next; 1361 | @@ -1458,12 +1688,12 @@ 1362 | 1363 | SWIGRUNTIME PyObject* 1364 | #ifdef METH_NOARGS 1365 | -PySwigObject_next(PyObject* v) 1366 | +SwigPyObject_next(PyObject* v) 1367 | #else 1368 | -PySwigObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) 1369 | +SwigPyObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) 1370 | #endif 1371 | { 1372 | - PySwigObject *sobj = (PySwigObject *) v; 1373 | + SwigPyObject *sobj = (SwigPyObject *) v; 1374 | if (sobj->next) { 1375 | Py_INCREF(sobj->next); 1376 | return sobj->next; 1377 | @@ -1474,56 +1704,58 @@ 1378 | 1379 | SWIGINTERN PyObject* 1380 | #ifdef METH_NOARGS 1381 | -PySwigObject_disown(PyObject *v) 1382 | +SwigPyObject_disown(PyObject *v) 1383 | #else 1384 | -PySwigObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) 1385 | +SwigPyObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) 1386 | #endif 1387 | { 1388 | - PySwigObject *sobj = (PySwigObject *)v; 1389 | + SwigPyObject *sobj = (SwigPyObject *)v; 1390 | sobj->own = 0; 1391 | return SWIG_Py_Void(); 1392 | } 1393 | 1394 | SWIGINTERN PyObject* 1395 | #ifdef METH_NOARGS 1396 | -PySwigObject_acquire(PyObject *v) 1397 | +SwigPyObject_acquire(PyObject *v) 1398 | #else 1399 | -PySwigObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) 1400 | +SwigPyObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) 1401 | #endif 1402 | { 1403 | - PySwigObject *sobj = (PySwigObject *)v; 1404 | + SwigPyObject *sobj = (SwigPyObject *)v; 1405 | sobj->own = SWIG_POINTER_OWN; 1406 | return SWIG_Py_Void(); 1407 | } 1408 | 1409 | SWIGINTERN PyObject* 1410 | -PySwigObject_own(PyObject *v, PyObject *args) 1411 | +SwigPyObject_own(PyObject *v, PyObject *args) 1412 | { 1413 | PyObject *val = 0; 1414 | #if (PY_VERSION_HEX < 0x02020000) 1415 | if (!PyArg_ParseTuple(args,(char *)"|O:own",&val)) 1416 | -#else 1417 | +#elif (PY_VERSION_HEX < 0x02050000) 1418 | if (!PyArg_UnpackTuple(args, (char *)"own", 0, 1, &val)) 1419 | +#else 1420 | + if (!PyArg_UnpackTuple(args, "own", 0, 1, &val)) 1421 | #endif 1422 | { 1423 | return NULL; 1424 | } 1425 | else 1426 | { 1427 | - PySwigObject *sobj = (PySwigObject *)v; 1428 | + SwigPyObject *sobj = (SwigPyObject *)v; 1429 | PyObject *obj = PyBool_FromLong(sobj->own); 1430 | if (val) { 1431 | #ifdef METH_NOARGS 1432 | if (PyObject_IsTrue(val)) { 1433 | - PySwigObject_acquire(v); 1434 | + SwigPyObject_acquire(v); 1435 | } else { 1436 | - PySwigObject_disown(v); 1437 | + SwigPyObject_disown(v); 1438 | } 1439 | #else 1440 | if (PyObject_IsTrue(val)) { 1441 | - PySwigObject_acquire(v,args); 1442 | + SwigPyObject_acquire(v,args); 1443 | } else { 1444 | - PySwigObject_disown(v,args); 1445 | + SwigPyObject_disown(v,args); 1446 | } 1447 | #endif 1448 | } 1449 | @@ -1534,44 +1766,47 @@ 1450 | #ifdef METH_O 1451 | static PyMethodDef 1452 | swigobject_methods[] = { 1453 | - {(char *)"disown", (PyCFunction)PySwigObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"}, 1454 | - {(char *)"acquire", (PyCFunction)PySwigObject_acquire, METH_NOARGS, (char *)"aquires ownership of the pointer"}, 1455 | - {(char *)"own", (PyCFunction)PySwigObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, 1456 | - {(char *)"append", (PyCFunction)PySwigObject_append, METH_O, (char *)"appends another 'this' object"}, 1457 | - {(char *)"next", (PyCFunction)PySwigObject_next, METH_NOARGS, (char *)"returns the next 'this' object"}, 1458 | - {(char *)"__repr__",(PyCFunction)PySwigObject_repr, METH_NOARGS, (char *)"returns object representation"}, 1459 | + {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"}, 1460 | + {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_NOARGS, (char *)"acquires ownership of the pointer"}, 1461 | + {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, 1462 | + {(char *)"append", (PyCFunction)SwigPyObject_append, METH_O, (char *)"appends another 'this' object"}, 1463 | + {(char *)"next", (PyCFunction)SwigPyObject_next, METH_NOARGS, (char *)"returns the next 'this' object"}, 1464 | + {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_NOARGS, (char *)"returns object representation"}, 1465 | {0, 0, 0, 0} 1466 | }; 1467 | #else 1468 | static PyMethodDef 1469 | swigobject_methods[] = { 1470 | - {(char *)"disown", (PyCFunction)PySwigObject_disown, METH_VARARGS, (char *)"releases ownership of the pointer"}, 1471 | - {(char *)"acquire", (PyCFunction)PySwigObject_acquire, METH_VARARGS, (char *)"aquires ownership of the pointer"}, 1472 | - {(char *)"own", (PyCFunction)PySwigObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, 1473 | - {(char *)"append", (PyCFunction)PySwigObject_append, METH_VARARGS, (char *)"appends another 'this' object"}, 1474 | - {(char *)"next", (PyCFunction)PySwigObject_next, METH_VARARGS, (char *)"returns the next 'this' object"}, 1475 | - {(char *)"__repr__",(PyCFunction)PySwigObject_repr, METH_VARARGS, (char *)"returns object representation"}, 1476 | + {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_VARARGS, (char *)"releases ownership of the pointer"}, 1477 | + {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_VARARGS, (char *)"aquires ownership of the pointer"}, 1478 | + {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, 1479 | + {(char *)"append", (PyCFunction)SwigPyObject_append, METH_VARARGS, (char *)"appends another 'this' object"}, 1480 | + {(char *)"next", (PyCFunction)SwigPyObject_next, METH_VARARGS, (char *)"returns the next 'this' object"}, 1481 | + {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_VARARGS, (char *)"returns object representation"}, 1482 | {0, 0, 0, 0} 1483 | }; 1484 | #endif 1485 | 1486 | #if PY_VERSION_HEX < 0x02020000 1487 | SWIGINTERN PyObject * 1488 | -PySwigObject_getattr(PySwigObject *sobj,char *name) 1489 | +SwigPyObject_getattr(SwigPyObject *sobj,char *name) 1490 | { 1491 | return Py_FindMethod(swigobject_methods, (PyObject *)sobj, name); 1492 | } 1493 | #endif 1494 | 1495 | SWIGRUNTIME PyTypeObject* 1496 | -_PySwigObject_type(void) { 1497 | +SwigPyObject_TypeOnce(void) { 1498 | static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer"; 1499 | - 1500 | - static PyNumberMethods PySwigObject_as_number = { 1501 | + 1502 | + static PyNumberMethods SwigPyObject_as_number = { 1503 | (binaryfunc)0, /*nb_add*/ 1504 | (binaryfunc)0, /*nb_subtract*/ 1505 | (binaryfunc)0, /*nb_multiply*/ 1506 | + /* nb_divide removed in Python 3 */ 1507 | +#if PY_VERSION_HEX < 0x03000000 1508 | (binaryfunc)0, /*nb_divide*/ 1509 | +#endif 1510 | (binaryfunc)0, /*nb_remainder*/ 1511 | (binaryfunc)0, /*nb_divmod*/ 1512 | (ternaryfunc)0,/*nb_power*/ 1513 | @@ -1585,94 +1820,122 @@ 1514 | 0, /*nb_and*/ 1515 | 0, /*nb_xor*/ 1516 | 0, /*nb_or*/ 1517 | - (coercion)0, /*nb_coerce*/ 1518 | - (unaryfunc)PySwigObject_long, /*nb_int*/ 1519 | - (unaryfunc)PySwigObject_long, /*nb_long*/ 1520 | +#if PY_VERSION_HEX < 0x03000000 1521 | + 0, /*nb_coerce*/ 1522 | +#endif 1523 | + (unaryfunc)SwigPyObject_long, /*nb_int*/ 1524 | +#if PY_VERSION_HEX < 0x03000000 1525 | + (unaryfunc)SwigPyObject_long, /*nb_long*/ 1526 | +#else 1527 | + 0, /*nb_reserved*/ 1528 | +#endif 1529 | (unaryfunc)0, /*nb_float*/ 1530 | - (unaryfunc)PySwigObject_oct, /*nb_oct*/ 1531 | - (unaryfunc)PySwigObject_hex, /*nb_hex*/ 1532 | -#if PY_VERSION_HEX >= 0x02020000 1533 | - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */ 1534 | -#elif PY_VERSION_HEX >= 0x02000000 1535 | +#if PY_VERSION_HEX < 0x03000000 1536 | + (unaryfunc)SwigPyObject_oct, /*nb_oct*/ 1537 | + (unaryfunc)SwigPyObject_hex, /*nb_hex*/ 1538 | +#endif 1539 | +#if PY_VERSION_HEX >= 0x03000000 /* 3.0 */ 1540 | + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index, nb_inplace_divide removed */ 1541 | +#elif PY_VERSION_HEX >= 0x02050000 /* 2.5.0 */ 1542 | + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */ 1543 | +#elif PY_VERSION_HEX >= 0x02020000 /* 2.2.0 */ 1544 | + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */ 1545 | +#elif PY_VERSION_HEX >= 0x02000000 /* 2.0.0 */ 1546 | 0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */ 1547 | #endif 1548 | }; 1549 | 1550 | - static PyTypeObject pyswigobject_type; 1551 | + static PyTypeObject swigpyobject_type; 1552 | static int type_init = 0; 1553 | if (!type_init) { 1554 | - const PyTypeObject tmp 1555 | - = { 1556 | - PyObject_HEAD_INIT(NULL) 1557 | - 0, /* ob_size */ 1558 | - (char *)"PySwigObject", /* tp_name */ 1559 | - sizeof(PySwigObject), /* tp_basicsize */ 1560 | - 0, /* tp_itemsize */ 1561 | - (destructor)PySwigObject_dealloc, /* tp_dealloc */ 1562 | - (printfunc)PySwigObject_print, /* tp_print */ 1563 | + const PyTypeObject tmp = { 1564 | + /* PyObject header changed in Python 3 */ 1565 | +#if PY_VERSION_HEX >= 0x03000000 1566 | + PyVarObject_HEAD_INIT(NULL, 0) 1567 | +#else 1568 | + PyObject_HEAD_INIT(NULL) 1569 | + 0, /* ob_size */ 1570 | +#endif 1571 | + (char *)"SwigPyObject", /* tp_name */ 1572 | + sizeof(SwigPyObject), /* tp_basicsize */ 1573 | + 0, /* tp_itemsize */ 1574 | + (destructor)SwigPyObject_dealloc, /* tp_dealloc */ 1575 | + 0, /* tp_print */ 1576 | #if PY_VERSION_HEX < 0x02020000 1577 | - (getattrfunc)PySwigObject_getattr, /* tp_getattr */ 1578 | + (getattrfunc)SwigPyObject_getattr, /* tp_getattr */ 1579 | +#else 1580 | + (getattrfunc)0, /* tp_getattr */ 1581 | +#endif 1582 | + (setattrfunc)0, /* tp_setattr */ 1583 | +#if PY_VERSION_HEX >= 0x03000000 1584 | + 0, /* tp_reserved in 3.0.1, tp_compare in 3.0.0 but not used */ 1585 | #else 1586 | - (getattrfunc)0, /* tp_getattr */ 1587 | + (cmpfunc)SwigPyObject_compare, /* tp_compare */ 1588 | #endif 1589 | - (setattrfunc)0, /* tp_setattr */ 1590 | - (cmpfunc)PySwigObject_compare, /* tp_compare */ 1591 | - (reprfunc)PySwigObject_repr, /* tp_repr */ 1592 | - &PySwigObject_as_number, /* tp_as_number */ 1593 | - 0, /* tp_as_sequence */ 1594 | - 0, /* tp_as_mapping */ 1595 | - (hashfunc)0, /* tp_hash */ 1596 | - (ternaryfunc)0, /* tp_call */ 1597 | - (reprfunc)PySwigObject_str, /* tp_str */ 1598 | - PyObject_GenericGetAttr, /* tp_getattro */ 1599 | - 0, /* tp_setattro */ 1600 | - 0, /* tp_as_buffer */ 1601 | - Py_TPFLAGS_DEFAULT, /* tp_flags */ 1602 | - swigobject_doc, /* tp_doc */ 1603 | - 0, /* tp_traverse */ 1604 | - 0, /* tp_clear */ 1605 | - 0, /* tp_richcompare */ 1606 | - 0, /* tp_weaklistoffset */ 1607 | + (reprfunc)SwigPyObject_repr, /* tp_repr */ 1608 | + &SwigPyObject_as_number, /* tp_as_number */ 1609 | + 0, /* tp_as_sequence */ 1610 | + 0, /* tp_as_mapping */ 1611 | + (hashfunc)0, /* tp_hash */ 1612 | + (ternaryfunc)0, /* tp_call */ 1613 | + 0, /* tp_str */ 1614 | + PyObject_GenericGetAttr, /* tp_getattro */ 1615 | + 0, /* tp_setattro */ 1616 | + 0, /* tp_as_buffer */ 1617 | + Py_TPFLAGS_DEFAULT, /* tp_flags */ 1618 | + swigobject_doc, /* tp_doc */ 1619 | + 0, /* tp_traverse */ 1620 | + 0, /* tp_clear */ 1621 | + (richcmpfunc)SwigPyObject_richcompare,/* tp_richcompare */ 1622 | + 0, /* tp_weaklistoffset */ 1623 | #if PY_VERSION_HEX >= 0x02020000 1624 | - 0, /* tp_iter */ 1625 | - 0, /* tp_iternext */ 1626 | - swigobject_methods, /* tp_methods */ 1627 | - 0, /* tp_members */ 1628 | - 0, /* tp_getset */ 1629 | - 0, /* tp_base */ 1630 | - 0, /* tp_dict */ 1631 | - 0, /* tp_descr_get */ 1632 | - 0, /* tp_descr_set */ 1633 | - 0, /* tp_dictoffset */ 1634 | - 0, /* tp_init */ 1635 | - 0, /* tp_alloc */ 1636 | - 0, /* tp_new */ 1637 | - 0, /* tp_free */ 1638 | - 0, /* tp_is_gc */ 1639 | - 0, /* tp_bases */ 1640 | - 0, /* tp_mro */ 1641 | - 0, /* tp_cache */ 1642 | - 0, /* tp_subclasses */ 1643 | - 0, /* tp_weaklist */ 1644 | + 0, /* tp_iter */ 1645 | + 0, /* tp_iternext */ 1646 | + swigobject_methods, /* tp_methods */ 1647 | + 0, /* tp_members */ 1648 | + 0, /* tp_getset */ 1649 | + 0, /* tp_base */ 1650 | + 0, /* tp_dict */ 1651 | + 0, /* tp_descr_get */ 1652 | + 0, /* tp_descr_set */ 1653 | + 0, /* tp_dictoffset */ 1654 | + 0, /* tp_init */ 1655 | + 0, /* tp_alloc */ 1656 | + 0, /* tp_new */ 1657 | + 0, /* tp_free */ 1658 | + 0, /* tp_is_gc */ 1659 | + 0, /* tp_bases */ 1660 | + 0, /* tp_mro */ 1661 | + 0, /* tp_cache */ 1662 | + 0, /* tp_subclasses */ 1663 | + 0, /* tp_weaklist */ 1664 | #endif 1665 | #if PY_VERSION_HEX >= 0x02030000 1666 | - 0, /* tp_del */ 1667 | + 0, /* tp_del */ 1668 | +#endif 1669 | +#if PY_VERSION_HEX >= 0x02060000 1670 | + 0, /* tp_version */ 1671 | #endif 1672 | #ifdef COUNT_ALLOCS 1673 | - 0,0,0,0 /* tp_alloc -> tp_next */ 1674 | + 0,0,0,0 /* tp_alloc -> tp_next */ 1675 | #endif 1676 | - }; 1677 | - pyswigobject_type = tmp; 1678 | - pyswigobject_type.ob_type = &PyType_Type; 1679 | + }; 1680 | + swigpyobject_type = tmp; 1681 | type_init = 1; 1682 | +#if PY_VERSION_HEX < 0x02020000 1683 | + swigpyobject_type.ob_type = &PyType_Type; 1684 | +#else 1685 | + if (PyType_Ready(&swigpyobject_type) < 0) 1686 | + return NULL; 1687 | +#endif 1688 | } 1689 | - return &pyswigobject_type; 1690 | + return &swigpyobject_type; 1691 | } 1692 | 1693 | SWIGRUNTIME PyObject * 1694 | -PySwigObject_New(void *ptr, swig_type_info *ty, int own) 1695 | +SwigPyObject_New(void *ptr, swig_type_info *ty, int own) 1696 | { 1697 | - PySwigObject *sobj = PyObject_NEW(PySwigObject, PySwigObject_type()); 1698 | + SwigPyObject *sobj = PyObject_NEW(SwigPyObject, SwigPyObject_type()); 1699 | if (sobj) { 1700 | sobj->ptr = ptr; 1701 | sobj->ty = ty; 1702 | @@ -1691,10 +1954,10 @@ 1703 | void *pack; 1704 | swig_type_info *ty; 1705 | size_t size; 1706 | -} PySwigPacked; 1707 | +} SwigPyPacked; 1708 | 1709 | SWIGRUNTIME int 1710 | -PySwigPacked_print(PySwigPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags)) 1711 | +SwigPyPacked_print(SwigPyPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags)) 1712 | { 1713 | char result[SWIG_BUFFER_SIZE]; 1714 | fputs("pack, v->size, 0, sizeof(result))) { 1724 | - return PyString_FromFormat("", result, v->ty->name); 1725 | + return SWIG_Python_str_FromFormat("", result, v->ty->name); 1726 | } else { 1727 | - return PyString_FromFormat("", v->ty->name); 1728 | + return SWIG_Python_str_FromFormat("", v->ty->name); 1729 | } 1730 | } 1731 | 1732 | SWIGRUNTIME PyObject * 1733 | -PySwigPacked_str(PySwigPacked *v) 1734 | +SwigPyPacked_str(SwigPyPacked *v) 1735 | { 1736 | char result[SWIG_BUFFER_SIZE]; 1737 | if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){ 1738 | - return PyString_FromFormat("%s%s", result, v->ty->name); 1739 | + return SWIG_Python_str_FromFormat("%s%s", result, v->ty->name); 1740 | } else { 1741 | - return PyString_FromString(v->ty->name); 1742 | + return SWIG_Python_str_FromChar(v->ty->name); 1743 | } 1744 | } 1745 | 1746 | SWIGRUNTIME int 1747 | -PySwigPacked_compare(PySwigPacked *v, PySwigPacked *w) 1748 | +SwigPyPacked_compare(SwigPyPacked *v, SwigPyPacked *w) 1749 | { 1750 | size_t i = v->size; 1751 | size_t j = w->size; 1752 | @@ -1738,104 +2001,120 @@ 1753 | return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size); 1754 | } 1755 | 1756 | -SWIGRUNTIME PyTypeObject* _PySwigPacked_type(void); 1757 | +SWIGRUNTIME PyTypeObject* SwigPyPacked_TypeOnce(void); 1758 | 1759 | SWIGRUNTIME PyTypeObject* 1760 | -PySwigPacked_type(void) { 1761 | - static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigPacked_type(); 1762 | +SwigPyPacked_type(void) { 1763 | + static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyPacked_TypeOnce(); 1764 | return type; 1765 | } 1766 | 1767 | SWIGRUNTIMEINLINE int 1768 | -PySwigPacked_Check(PyObject *op) { 1769 | - return ((op)->ob_type == _PySwigPacked_type()) 1770 | - || (strcmp((op)->ob_type->tp_name,"PySwigPacked") == 0); 1771 | +SwigPyPacked_Check(PyObject *op) { 1772 | + return ((op)->ob_type == SwigPyPacked_TypeOnce()) 1773 | + || (strcmp((op)->ob_type->tp_name,"SwigPyPacked") == 0); 1774 | } 1775 | 1776 | SWIGRUNTIME void 1777 | -PySwigPacked_dealloc(PyObject *v) 1778 | +SwigPyPacked_dealloc(PyObject *v) 1779 | { 1780 | - if (PySwigPacked_Check(v)) { 1781 | - PySwigPacked *sobj = (PySwigPacked *) v; 1782 | + if (SwigPyPacked_Check(v)) { 1783 | + SwigPyPacked *sobj = (SwigPyPacked *) v; 1784 | free(sobj->pack); 1785 | } 1786 | PyObject_DEL(v); 1787 | } 1788 | 1789 | SWIGRUNTIME PyTypeObject* 1790 | -_PySwigPacked_type(void) { 1791 | +SwigPyPacked_TypeOnce(void) { 1792 | static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer"; 1793 | - static PyTypeObject pyswigpacked_type; 1794 | - static int type_init = 0; 1795 | + static PyTypeObject swigpypacked_type; 1796 | + static int type_init = 0; 1797 | if (!type_init) { 1798 | - const PyTypeObject tmp 1799 | - = { 1800 | - PyObject_HEAD_INIT(NULL) 1801 | - 0, /* ob_size */ 1802 | - (char *)"PySwigPacked", /* tp_name */ 1803 | - sizeof(PySwigPacked), /* tp_basicsize */ 1804 | - 0, /* tp_itemsize */ 1805 | - (destructor)PySwigPacked_dealloc, /* tp_dealloc */ 1806 | - (printfunc)PySwigPacked_print, /* tp_print */ 1807 | - (getattrfunc)0, /* tp_getattr */ 1808 | - (setattrfunc)0, /* tp_setattr */ 1809 | - (cmpfunc)PySwigPacked_compare, /* tp_compare */ 1810 | - (reprfunc)PySwigPacked_repr, /* tp_repr */ 1811 | - 0, /* tp_as_number */ 1812 | - 0, /* tp_as_sequence */ 1813 | - 0, /* tp_as_mapping */ 1814 | - (hashfunc)0, /* tp_hash */ 1815 | - (ternaryfunc)0, /* tp_call */ 1816 | - (reprfunc)PySwigPacked_str, /* tp_str */ 1817 | - PyObject_GenericGetAttr, /* tp_getattro */ 1818 | - 0, /* tp_setattro */ 1819 | - 0, /* tp_as_buffer */ 1820 | - Py_TPFLAGS_DEFAULT, /* tp_flags */ 1821 | - swigpacked_doc, /* tp_doc */ 1822 | - 0, /* tp_traverse */ 1823 | - 0, /* tp_clear */ 1824 | - 0, /* tp_richcompare */ 1825 | - 0, /* tp_weaklistoffset */ 1826 | + const PyTypeObject tmp = { 1827 | + /* PyObject header changed in Python 3 */ 1828 | +#if PY_VERSION_HEX>=0x03000000 1829 | + PyVarObject_HEAD_INIT(NULL, 0) 1830 | +#else 1831 | + PyObject_HEAD_INIT(NULL) 1832 | + 0, /* ob_size */ 1833 | +#endif 1834 | + (char *)"SwigPyPacked", /* tp_name */ 1835 | + sizeof(SwigPyPacked), /* tp_basicsize */ 1836 | + 0, /* tp_itemsize */ 1837 | + (destructor)SwigPyPacked_dealloc, /* tp_dealloc */ 1838 | + (printfunc)SwigPyPacked_print, /* tp_print */ 1839 | + (getattrfunc)0, /* tp_getattr */ 1840 | + (setattrfunc)0, /* tp_setattr */ 1841 | +#if PY_VERSION_HEX>=0x03000000 1842 | + 0, /* tp_reserved in 3.0.1 */ 1843 | +#else 1844 | + (cmpfunc)SwigPyPacked_compare, /* tp_compare */ 1845 | +#endif 1846 | + (reprfunc)SwigPyPacked_repr, /* tp_repr */ 1847 | + 0, /* tp_as_number */ 1848 | + 0, /* tp_as_sequence */ 1849 | + 0, /* tp_as_mapping */ 1850 | + (hashfunc)0, /* tp_hash */ 1851 | + (ternaryfunc)0, /* tp_call */ 1852 | + (reprfunc)SwigPyPacked_str, /* tp_str */ 1853 | + PyObject_GenericGetAttr, /* tp_getattro */ 1854 | + 0, /* tp_setattro */ 1855 | + 0, /* tp_as_buffer */ 1856 | + Py_TPFLAGS_DEFAULT, /* tp_flags */ 1857 | + swigpacked_doc, /* tp_doc */ 1858 | + 0, /* tp_traverse */ 1859 | + 0, /* tp_clear */ 1860 | + 0, /* tp_richcompare */ 1861 | + 0, /* tp_weaklistoffset */ 1862 | #if PY_VERSION_HEX >= 0x02020000 1863 | - 0, /* tp_iter */ 1864 | - 0, /* tp_iternext */ 1865 | - 0, /* tp_methods */ 1866 | - 0, /* tp_members */ 1867 | - 0, /* tp_getset */ 1868 | - 0, /* tp_base */ 1869 | - 0, /* tp_dict */ 1870 | - 0, /* tp_descr_get */ 1871 | - 0, /* tp_descr_set */ 1872 | - 0, /* tp_dictoffset */ 1873 | - 0, /* tp_init */ 1874 | - 0, /* tp_alloc */ 1875 | - 0, /* tp_new */ 1876 | - 0, /* tp_free */ 1877 | - 0, /* tp_is_gc */ 1878 | - 0, /* tp_bases */ 1879 | - 0, /* tp_mro */ 1880 | - 0, /* tp_cache */ 1881 | - 0, /* tp_subclasses */ 1882 | - 0, /* tp_weaklist */ 1883 | + 0, /* tp_iter */ 1884 | + 0, /* tp_iternext */ 1885 | + 0, /* tp_methods */ 1886 | + 0, /* tp_members */ 1887 | + 0, /* tp_getset */ 1888 | + 0, /* tp_base */ 1889 | + 0, /* tp_dict */ 1890 | + 0, /* tp_descr_get */ 1891 | + 0, /* tp_descr_set */ 1892 | + 0, /* tp_dictoffset */ 1893 | + 0, /* tp_init */ 1894 | + 0, /* tp_alloc */ 1895 | + 0, /* tp_new */ 1896 | + 0, /* tp_free */ 1897 | + 0, /* tp_is_gc */ 1898 | + 0, /* tp_bases */ 1899 | + 0, /* tp_mro */ 1900 | + 0, /* tp_cache */ 1901 | + 0, /* tp_subclasses */ 1902 | + 0, /* tp_weaklist */ 1903 | #endif 1904 | #if PY_VERSION_HEX >= 0x02030000 1905 | - 0, /* tp_del */ 1906 | + 0, /* tp_del */ 1907 | +#endif 1908 | +#if PY_VERSION_HEX >= 0x02060000 1909 | + 0, /* tp_version */ 1910 | #endif 1911 | #ifdef COUNT_ALLOCS 1912 | - 0,0,0,0 /* tp_alloc -> tp_next */ 1913 | + 0,0,0,0 /* tp_alloc -> tp_next */ 1914 | #endif 1915 | - }; 1916 | - pyswigpacked_type = tmp; 1917 | - pyswigpacked_type.ob_type = &PyType_Type; 1918 | + }; 1919 | + swigpypacked_type = tmp; 1920 | type_init = 1; 1921 | +#if PY_VERSION_HEX < 0x02020000 1922 | + swigpypacked_type.ob_type = &PyType_Type; 1923 | +#else 1924 | + if (PyType_Ready(&swigpypacked_type) < 0) 1925 | + return NULL; 1926 | +#endif 1927 | } 1928 | - return &pyswigpacked_type; 1929 | + return &swigpypacked_type; 1930 | } 1931 | 1932 | SWIGRUNTIME PyObject * 1933 | -PySwigPacked_New(void *ptr, size_t size, swig_type_info *ty) 1934 | +SwigPyPacked_New(void *ptr, size_t size, swig_type_info *ty) 1935 | { 1936 | - PySwigPacked *sobj = PyObject_NEW(PySwigPacked, PySwigPacked_type()); 1937 | + SwigPyPacked *sobj = PyObject_NEW(SwigPyPacked, SwigPyPacked_type()); 1938 | if (sobj) { 1939 | void *pack = malloc(size); 1940 | if (pack) { 1941 | @@ -1852,10 +2131,10 @@ 1942 | } 1943 | 1944 | SWIGRUNTIME swig_type_info * 1945 | -PySwigPacked_UnpackData(PyObject *obj, void *ptr, size_t size) 1946 | +SwigPyPacked_UnpackData(PyObject *obj, void *ptr, size_t size) 1947 | { 1948 | - if (PySwigPacked_Check(obj)) { 1949 | - PySwigPacked *sobj = (PySwigPacked *)obj; 1950 | + if (SwigPyPacked_Check(obj)) { 1951 | + SwigPyPacked *sobj = (SwigPyPacked *)obj; 1952 | if (sobj->size != size) return 0; 1953 | memcpy(ptr, sobj->pack, size); 1954 | return sobj->ty; 1955 | @@ -1871,73 +2150,96 @@ 1956 | SWIGRUNTIMEINLINE PyObject * 1957 | _SWIG_This(void) 1958 | { 1959 | - return PyString_FromString("this"); 1960 | + return SWIG_Python_str_FromChar("this"); 1961 | } 1962 | 1963 | +static PyObject *swig_this = NULL; 1964 | + 1965 | SWIGRUNTIME PyObject * 1966 | SWIG_This(void) 1967 | { 1968 | - static PyObject *SWIG_STATIC_POINTER(swig_this) = _SWIG_This(); 1969 | + if (swig_this == NULL) 1970 | + swig_this = _SWIG_This(); 1971 | return swig_this; 1972 | } 1973 | 1974 | /* #define SWIG_PYTHON_SLOW_GETSET_THIS */ 1975 | 1976 | -SWIGRUNTIME PySwigObject * 1977 | +/* TODO: I don't know how to implement the fast getset in Python 3 right now */ 1978 | +#if PY_VERSION_HEX>=0x03000000 1979 | +#define SWIG_PYTHON_SLOW_GETSET_THIS 1980 | +#endif 1981 | + 1982 | +SWIGRUNTIME SwigPyObject * 1983 | SWIG_Python_GetSwigThis(PyObject *pyobj) 1984 | { 1985 | - if (PySwigObject_Check(pyobj)) { 1986 | - return (PySwigObject *) pyobj; 1987 | - } else { 1988 | - PyObject *obj = 0; 1989 | + PyObject *obj; 1990 | + 1991 | + if (SwigPyObject_Check(pyobj)) 1992 | + return (SwigPyObject *) pyobj; 1993 | + 1994 | +#ifdef SWIGPYTHON_BUILTIN 1995 | + (void)obj; 1996 | +# ifdef PyWeakref_CheckProxy 1997 | + if (PyWeakref_CheckProxy(pyobj)) { 1998 | + pyobj = PyWeakref_GET_OBJECT(pyobj); 1999 | + if (pyobj && SwigPyObject_Check(pyobj)) 2000 | + return (SwigPyObject*) pyobj; 2001 | + } 2002 | +# endif 2003 | + return NULL; 2004 | +#else 2005 | + 2006 | + obj = 0; 2007 | + 2008 | #if (!defined(SWIG_PYTHON_SLOW_GETSET_THIS) && (PY_VERSION_HEX >= 0x02030000)) 2009 | - if (PyInstance_Check(pyobj)) { 2010 | - obj = _PyInstance_Lookup(pyobj, SWIG_This()); 2011 | + if (PyInstance_Check(pyobj)) { 2012 | + obj = _PyInstance_Lookup(pyobj, SWIG_This()); 2013 | + } else { 2014 | + PyObject **dictptr = _PyObject_GetDictPtr(pyobj); 2015 | + if (dictptr != NULL) { 2016 | + PyObject *dict = *dictptr; 2017 | + obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0; 2018 | } else { 2019 | - PyObject **dictptr = _PyObject_GetDictPtr(pyobj); 2020 | - if (dictptr != NULL) { 2021 | - PyObject *dict = *dictptr; 2022 | - obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0; 2023 | - } else { 2024 | #ifdef PyWeakref_CheckProxy 2025 | - if (PyWeakref_CheckProxy(pyobj)) { 2026 | - PyObject *wobj = PyWeakref_GET_OBJECT(pyobj); 2027 | - return wobj ? SWIG_Python_GetSwigThis(wobj) : 0; 2028 | - } 2029 | + if (PyWeakref_CheckProxy(pyobj)) { 2030 | + PyObject *wobj = PyWeakref_GET_OBJECT(pyobj); 2031 | + return wobj ? SWIG_Python_GetSwigThis(wobj) : 0; 2032 | + } 2033 | #endif 2034 | - obj = PyObject_GetAttr(pyobj,SWIG_This()); 2035 | - if (obj) { 2036 | - Py_DECREF(obj); 2037 | - } else { 2038 | - if (PyErr_Occurred()) PyErr_Clear(); 2039 | - return 0; 2040 | - } 2041 | + obj = PyObject_GetAttr(pyobj,SWIG_This()); 2042 | + if (obj) { 2043 | + Py_DECREF(obj); 2044 | + } else { 2045 | + if (PyErr_Occurred()) PyErr_Clear(); 2046 | + return 0; 2047 | } 2048 | } 2049 | + } 2050 | #else 2051 | - obj = PyObject_GetAttr(pyobj,SWIG_This()); 2052 | - if (obj) { 2053 | - Py_DECREF(obj); 2054 | - } else { 2055 | - if (PyErr_Occurred()) PyErr_Clear(); 2056 | - return 0; 2057 | - } 2058 | + obj = PyObject_GetAttr(pyobj,SWIG_This()); 2059 | + if (obj) { 2060 | + Py_DECREF(obj); 2061 | + } else { 2062 | + if (PyErr_Occurred()) PyErr_Clear(); 2063 | + return 0; 2064 | + } 2065 | #endif 2066 | - if (obj && !PySwigObject_Check(obj)) { 2067 | - /* a PyObject is called 'this', try to get the 'real this' 2068 | - PySwigObject from it */ 2069 | - return SWIG_Python_GetSwigThis(obj); 2070 | - } 2071 | - return (PySwigObject *)obj; 2072 | + if (obj && !SwigPyObject_Check(obj)) { 2073 | + /* a PyObject is called 'this', try to get the 'real this' 2074 | + SwigPyObject from it */ 2075 | + return SWIG_Python_GetSwigThis(obj); 2076 | } 2077 | + return (SwigPyObject *)obj; 2078 | +#endif 2079 | } 2080 | 2081 | /* Acquire a pointer value */ 2082 | 2083 | SWIGRUNTIME int 2084 | SWIG_Python_AcquirePtr(PyObject *obj, int own) { 2085 | - if (own) { 2086 | - PySwigObject *sobj = SWIG_Python_GetSwigThis(obj); 2087 | + if (own == SWIG_POINTER_OWN) { 2088 | + SwigPyObject *sobj = SWIG_Python_GetSwigThis(obj); 2089 | if (sobj) { 2090 | int oldown = sobj->own; 2091 | sobj->own = own; 2092 | @@ -1951,80 +2253,105 @@ 2093 | 2094 | SWIGRUNTIME int 2095 | SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) { 2096 | - if (!obj) return SWIG_ERROR; 2097 | - if (obj == Py_None) { 2098 | - if (ptr) *ptr = 0; 2099 | + int res; 2100 | + SwigPyObject *sobj; 2101 | + int implicit_conv = (flags & SWIG_POINTER_IMPLICIT_CONV) != 0; 2102 | + 2103 | + if (!obj) 2104 | + return SWIG_ERROR; 2105 | + if (obj == Py_None && !implicit_conv) { 2106 | + if (ptr) 2107 | + *ptr = 0; 2108 | return SWIG_OK; 2109 | - } else { 2110 | - PySwigObject *sobj = SWIG_Python_GetSwigThis(obj); 2111 | - while (sobj) { 2112 | - void *vptr = sobj->ptr; 2113 | - if (ty) { 2114 | - swig_type_info *to = sobj->ty; 2115 | - if (to == ty) { 2116 | - /* no type cast needed */ 2117 | - if (ptr) *ptr = vptr; 2118 | - break; 2119 | - } else { 2120 | - swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); 2121 | - if (!tc) { 2122 | - sobj = (PySwigObject *)sobj->next; 2123 | - } else { 2124 | - if (ptr) *ptr = SWIG_TypeCast(tc,vptr); 2125 | - break; 2126 | - } 2127 | - } 2128 | + } 2129 | + 2130 | + res = SWIG_ERROR; 2131 | + 2132 | + sobj = SWIG_Python_GetSwigThis(obj); 2133 | + if (own) 2134 | + *own = 0; 2135 | + while (sobj) { 2136 | + void *vptr = sobj->ptr; 2137 | + if (ty) { 2138 | + swig_type_info *to = sobj->ty; 2139 | + if (to == ty) { 2140 | + /* no type cast needed */ 2141 | + if (ptr) *ptr = vptr; 2142 | + break; 2143 | } else { 2144 | - if (ptr) *ptr = vptr; 2145 | - break; 2146 | - } 2147 | - } 2148 | - if (sobj) { 2149 | - if (own) *own = sobj->own; 2150 | - if (flags & SWIG_POINTER_DISOWN) { 2151 | - sobj->own = 0; 2152 | + swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); 2153 | + if (!tc) { 2154 | + sobj = (SwigPyObject *)sobj->next; 2155 | + } else { 2156 | + if (ptr) { 2157 | + int newmemory = 0; 2158 | + *ptr = SWIG_TypeCast(tc,vptr,&newmemory); 2159 | + if (newmemory == SWIG_CAST_NEW_MEMORY) { 2160 | + assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */ 2161 | + if (own) 2162 | + *own = *own | SWIG_CAST_NEW_MEMORY; 2163 | + } 2164 | + } 2165 | + break; 2166 | + } 2167 | } 2168 | - return SWIG_OK; 2169 | } else { 2170 | - int res = SWIG_ERROR; 2171 | - if (flags & SWIG_POINTER_IMPLICIT_CONV) { 2172 | - PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0; 2173 | - if (data && !data->implicitconv) { 2174 | - PyObject *klass = data->klass; 2175 | - if (klass) { 2176 | - PyObject *impconv; 2177 | - data->implicitconv = 1; /* avoid recursion and call 'explicit' constructors*/ 2178 | - impconv = SWIG_Python_CallFunctor(klass, obj); 2179 | - data->implicitconv = 0; 2180 | - if (PyErr_Occurred()) { 2181 | - PyErr_Clear(); 2182 | - impconv = 0; 2183 | - } 2184 | - if (impconv) { 2185 | - PySwigObject *iobj = SWIG_Python_GetSwigThis(impconv); 2186 | - if (iobj) { 2187 | - void *vptr; 2188 | - res = SWIG_Python_ConvertPtrAndOwn((PyObject*)iobj, &vptr, ty, 0, 0); 2189 | - if (SWIG_IsOK(res)) { 2190 | - if (ptr) { 2191 | - *ptr = vptr; 2192 | - /* transfer the ownership to 'ptr' */ 2193 | - iobj->own = 0; 2194 | - res = SWIG_AddCast(res); 2195 | - res = SWIG_AddNewMask(res); 2196 | - } else { 2197 | - res = SWIG_AddCast(res); 2198 | - } 2199 | - } 2200 | - } 2201 | - Py_DECREF(impconv); 2202 | - } 2203 | - } 2204 | - } 2205 | + if (ptr) *ptr = vptr; 2206 | + break; 2207 | + } 2208 | + } 2209 | + if (sobj) { 2210 | + if (own) 2211 | + *own = *own | sobj->own; 2212 | + if (flags & SWIG_POINTER_DISOWN) { 2213 | + sobj->own = 0; 2214 | + } 2215 | + res = SWIG_OK; 2216 | + } else { 2217 | + if (implicit_conv) { 2218 | + SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; 2219 | + if (data && !data->implicitconv) { 2220 | + PyObject *klass = data->klass; 2221 | + if (klass) { 2222 | + PyObject *impconv; 2223 | + data->implicitconv = 1; /* avoid recursion and call 'explicit' constructors*/ 2224 | + impconv = SWIG_Python_CallFunctor(klass, obj); 2225 | + data->implicitconv = 0; 2226 | + if (PyErr_Occurred()) { 2227 | + PyErr_Clear(); 2228 | + impconv = 0; 2229 | + } 2230 | + if (impconv) { 2231 | + SwigPyObject *iobj = SWIG_Python_GetSwigThis(impconv); 2232 | + if (iobj) { 2233 | + void *vptr; 2234 | + res = SWIG_Python_ConvertPtrAndOwn((PyObject*)iobj, &vptr, ty, 0, 0); 2235 | + if (SWIG_IsOK(res)) { 2236 | + if (ptr) { 2237 | + *ptr = vptr; 2238 | + /* transfer the ownership to 'ptr' */ 2239 | + iobj->own = 0; 2240 | + res = SWIG_AddCast(res); 2241 | + res = SWIG_AddNewMask(res); 2242 | + } else { 2243 | + res = SWIG_AddCast(res); 2244 | + } 2245 | + } 2246 | + } 2247 | + Py_DECREF(impconv); 2248 | + } 2249 | + } 2250 | } 2251 | - return res; 2252 | + } 2253 | + if (!SWIG_IsOK(res) && obj == Py_None) { 2254 | + if (ptr) 2255 | + *ptr = 0; 2256 | + if (PyErr_Occurred()) 2257 | + PyErr_Clear(); 2258 | + res = SWIG_OK; 2259 | } 2260 | } 2261 | + return res; 2262 | } 2263 | 2264 | /* Convert a function ptr value */ 2265 | @@ -2039,14 +2366,19 @@ 2266 | /* here we get the method pointer for callbacks */ 2267 | const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); 2268 | const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0; 2269 | - if (desc) { 2270 | + if (desc) 2271 | desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0; 2272 | - if (!desc) return SWIG_ERROR; 2273 | - } 2274 | + if (!desc) 2275 | + return SWIG_ERROR; 2276 | if (ty) { 2277 | swig_cast_info *tc = SWIG_TypeCheck(desc,ty); 2278 | - if (!tc) return SWIG_ERROR; 2279 | - *ptr = SWIG_TypeCast(tc,vptr); 2280 | + if (tc) { 2281 | + int newmemory = 0; 2282 | + *ptr = SWIG_TypeCast(tc,vptr,&newmemory); 2283 | + assert(!newmemory); /* newmemory handling not yet implemented */ 2284 | + } else { 2285 | + return SWIG_ERROR; 2286 | + } 2287 | } else { 2288 | *ptr = vptr; 2289 | } 2290 | @@ -2058,7 +2390,7 @@ 2291 | 2292 | SWIGRUNTIME int 2293 | SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) { 2294 | - swig_type_info *to = PySwigPacked_UnpackData(obj, ptr, sz); 2295 | + swig_type_info *to = SwigPyPacked_UnpackData(obj, ptr, sz); 2296 | if (!to) return SWIG_ERROR; 2297 | if (ty) { 2298 | if (to != ty) { 2299 | @@ -2075,12 +2407,12 @@ 2300 | * ----------------------------------------------------------------------------- */ 2301 | 2302 | /* 2303 | - Create a new instance object, whitout calling __init__, and set the 2304 | + Create a new instance object, without calling __init__, and set the 2305 | 'this' attribute. 2306 | */ 2307 | 2308 | SWIGRUNTIME PyObject* 2309 | -SWIG_Python_NewShadowInstance(PySwigClientData *data, PyObject *swig_this) 2310 | +SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this) 2311 | { 2312 | #if (PY_VERSION_HEX >= 0x02020000) 2313 | PyObject *inst = 0; 2314 | @@ -2104,19 +2436,31 @@ 2315 | #endif 2316 | } 2317 | } else { 2318 | +#if PY_VERSION_HEX >= 0x03000000 2319 | + inst = ((PyTypeObject*) data->newargs)->tp_new((PyTypeObject*) data->newargs, Py_None, Py_None); 2320 | + if (inst) { 2321 | + PyObject_SetAttr(inst, SWIG_This(), swig_this); 2322 | + Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG; 2323 | + } 2324 | +#else 2325 | PyObject *dict = PyDict_New(); 2326 | - PyDict_SetItem(dict, SWIG_This(), swig_this); 2327 | - inst = PyInstance_NewRaw(data->newargs, dict); 2328 | - Py_DECREF(dict); 2329 | + if (dict) { 2330 | + PyDict_SetItem(dict, SWIG_This(), swig_this); 2331 | + inst = PyInstance_NewRaw(data->newargs, dict); 2332 | + Py_DECREF(dict); 2333 | + } 2334 | +#endif 2335 | } 2336 | return inst; 2337 | #else 2338 | #if (PY_VERSION_HEX >= 0x02010000) 2339 | - PyObject *inst; 2340 | + PyObject *inst = 0; 2341 | PyObject *dict = PyDict_New(); 2342 | - PyDict_SetItem(dict, SWIG_This(), swig_this); 2343 | - inst = PyInstance_NewRaw(data->newargs, dict); 2344 | - Py_DECREF(dict); 2345 | + if (dict) { 2346 | + PyDict_SetItem(dict, SWIG_This(), swig_this); 2347 | + inst = PyInstance_NewRaw(data->newargs, dict); 2348 | + Py_DECREF(dict); 2349 | + } 2350 | return (PyObject *) inst; 2351 | #else 2352 | PyInstanceObject *inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type); 2353 | @@ -2167,12 +2511,12 @@ 2354 | SWIGINTERN PyObject * 2355 | SWIG_Python_InitShadowInstance(PyObject *args) { 2356 | PyObject *obj[2]; 2357 | - if (!SWIG_Python_UnpackTuple(args,(char*)"swiginit", 2, 2, obj)) { 2358 | + if (!SWIG_Python_UnpackTuple(args, "swiginit", 2, 2, obj)) { 2359 | return NULL; 2360 | } else { 2361 | - PySwigObject *sthis = SWIG_Python_GetSwigThis(obj[0]); 2362 | + SwigPyObject *sthis = SWIG_Python_GetSwigThis(obj[0]); 2363 | if (sthis) { 2364 | - PySwigObject_append((PyObject*) sthis, obj[1]); 2365 | + SwigPyObject_append((PyObject*) sthis, obj[1]); 2366 | } else { 2367 | SWIG_Python_SetSwigThis(obj[0], obj[1]); 2368 | } 2369 | @@ -2183,29 +2527,59 @@ 2370 | /* Create a new pointer object */ 2371 | 2372 | SWIGRUNTIME PyObject * 2373 | -SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int flags) { 2374 | - if (!ptr) { 2375 | +SWIG_Python_NewPointerObj(PyObject *self, void *ptr, swig_type_info *type, int flags) { 2376 | + SwigPyClientData *clientdata; 2377 | + PyObject * robj; 2378 | + int own; 2379 | + 2380 | + if (!ptr) 2381 | return SWIG_Py_Void(); 2382 | - } else { 2383 | - int own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0; 2384 | - PyObject *robj = PySwigObject_New(ptr, type, own); 2385 | - PySwigClientData *clientdata = type ? (PySwigClientData *)(type->clientdata) : 0; 2386 | - if (clientdata && !(flags & SWIG_POINTER_NOSHADOW)) { 2387 | - PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj); 2388 | - if (inst) { 2389 | - Py_DECREF(robj); 2390 | - robj = inst; 2391 | + 2392 | + clientdata = type ? (SwigPyClientData *)(type->clientdata) : 0; 2393 | + own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0; 2394 | + if (clientdata && clientdata->pytype) { 2395 | + SwigPyObject *newobj; 2396 | + if (flags & SWIG_BUILTIN_TP_INIT) { 2397 | + newobj = (SwigPyObject*) self; 2398 | + if (newobj->ptr) { 2399 | + PyObject *next_self = clientdata->pytype->tp_alloc(clientdata->pytype, 0); 2400 | + while (newobj->next) 2401 | + newobj = (SwigPyObject *) newobj->next; 2402 | + newobj->next = next_self; 2403 | + newobj = (SwigPyObject *)next_self; 2404 | } 2405 | + } else { 2406 | + newobj = PyObject_New(SwigPyObject, clientdata->pytype); 2407 | + } 2408 | + if (newobj) { 2409 | + newobj->ptr = ptr; 2410 | + newobj->ty = type; 2411 | + newobj->own = own; 2412 | + newobj->next = 0; 2413 | +#ifdef SWIGPYTHON_BUILTIN 2414 | + newobj->dict = 0; 2415 | +#endif 2416 | + return (PyObject*) newobj; 2417 | } 2418 | - return robj; 2419 | + return SWIG_Py_Void(); 2420 | } 2421 | + 2422 | + assert(!(flags & SWIG_BUILTIN_TP_INIT)); 2423 | + 2424 | + robj = SwigPyObject_New(ptr, type, own); 2425 | + if (robj && clientdata && !(flags & SWIG_POINTER_NOSHADOW)) { 2426 | + PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj); 2427 | + Py_DECREF(robj); 2428 | + robj = inst; 2429 | + } 2430 | + return robj; 2431 | } 2432 | 2433 | /* Create a new packed object */ 2434 | 2435 | SWIGRUNTIMEINLINE PyObject * 2436 | SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) { 2437 | - return ptr ? PySwigPacked_New((void *) ptr, sz, type) : SWIG_Py_Void(); 2438 | + return ptr ? SwigPyPacked_New((void *) ptr, sz, type) : SWIG_Py_Void(); 2439 | } 2440 | 2441 | /* -----------------------------------------------------------------------------* 2442 | @@ -2217,15 +2591,19 @@ 2443 | #endif 2444 | 2445 | SWIGRUNTIME swig_module_info * 2446 | -SWIG_Python_GetModule(void) { 2447 | +SWIG_Python_GetModule(void *SWIGUNUSEDPARM(clientdata)) { 2448 | static void *type_pointer = (void *)0; 2449 | /* first check if module already created */ 2450 | if (!type_pointer) { 2451 | #ifdef SWIG_LINK_RUNTIME 2452 | type_pointer = SWIG_ReturnGlobalTypeList((void *)0); 2453 | #else 2454 | +# ifdef SWIGPY_USE_CAPSULE 2455 | + type_pointer = PyCapsule_Import(SWIGPY_CAPSULE_NAME, 0); 2456 | +# else 2457 | type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, 2458 | (char*)"type_pointer" SWIG_TYPE_TABLE_NAME); 2459 | +# endif 2460 | if (PyErr_Occurred()) { 2461 | PyErr_Clear(); 2462 | type_pointer = (void *)0; 2463 | @@ -2268,33 +2646,54 @@ 2464 | #endif 2465 | 2466 | SWIGRUNTIME void 2467 | +#ifdef SWIGPY_USE_CAPSULE 2468 | +SWIG_Python_DestroyModule(PyObject *obj) 2469 | +#else 2470 | SWIG_Python_DestroyModule(void *vptr) 2471 | +#endif 2472 | { 2473 | +#ifdef SWIGPY_USE_CAPSULE 2474 | + swig_module_info *swig_module = (swig_module_info *) PyCapsule_GetPointer(obj, SWIGPY_CAPSULE_NAME); 2475 | +#else 2476 | swig_module_info *swig_module = (swig_module_info *) vptr; 2477 | +#endif 2478 | swig_type_info **types = swig_module->types; 2479 | size_t i; 2480 | for (i =0; i < swig_module->size; ++i) { 2481 | swig_type_info *ty = types[i]; 2482 | if (ty->owndata) { 2483 | - PySwigClientData *data = (PySwigClientData *) ty->clientdata; 2484 | - if (data) PySwigClientData_Del(data); 2485 | + SwigPyClientData *data = (SwigPyClientData *) ty->clientdata; 2486 | + if (data) SwigPyClientData_Del(data); 2487 | } 2488 | } 2489 | Py_DECREF(SWIG_This()); 2490 | + swig_this = NULL; 2491 | } 2492 | 2493 | SWIGRUNTIME void 2494 | SWIG_Python_SetModule(swig_module_info *swig_module) { 2495 | - static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} };/* Sentinel */ 2496 | - 2497 | - PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, 2498 | - swig_empty_runtime_method_table); 2499 | +#if PY_VERSION_HEX >= 0x03000000 2500 | + /* Add a dummy module object into sys.modules */ 2501 | + PyObject *module = PyImport_AddModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION); 2502 | +#else 2503 | + static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} }; /* Sentinel */ 2504 | + PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, swig_empty_runtime_method_table); 2505 | +#endif 2506 | +#ifdef SWIGPY_USE_CAPSULE 2507 | + PyObject *pointer = PyCapsule_New((void *) swig_module, SWIGPY_CAPSULE_NAME, SWIG_Python_DestroyModule); 2508 | + if (pointer && module) { 2509 | + PyModule_AddObject(module, (char*)"type_pointer_capsule" SWIG_TYPE_TABLE_NAME, pointer); 2510 | + } else { 2511 | + Py_XDECREF(pointer); 2512 | + } 2513 | +#else 2514 | PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule); 2515 | if (pointer && module) { 2516 | PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer); 2517 | } else { 2518 | Py_XDECREF(pointer); 2519 | } 2520 | +#endif 2521 | } 2522 | 2523 | /* The python cached type query */ 2524 | @@ -2308,16 +2707,24 @@ 2525 | SWIG_Python_TypeQuery(const char *type) 2526 | { 2527 | PyObject *cache = SWIG_Python_TypeCache(); 2528 | - PyObject *key = PyString_FromString(type); 2529 | + PyObject *key = SWIG_Python_str_FromChar(type); 2530 | PyObject *obj = PyDict_GetItem(cache, key); 2531 | swig_type_info *descriptor; 2532 | if (obj) { 2533 | +#ifdef SWIGPY_USE_CAPSULE 2534 | + descriptor = (swig_type_info *) PyCapsule_GetPointer(obj, NULL); 2535 | +#else 2536 | descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj); 2537 | +#endif 2538 | } else { 2539 | - swig_module_info *swig_module = SWIG_Python_GetModule(); 2540 | + swig_module_info *swig_module = SWIG_GetModule(0); 2541 | descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type); 2542 | if (descriptor) { 2543 | +#ifdef SWIGPY_USE_CAPSULE 2544 | + obj = PyCapsule_New((void*) descriptor, NULL, NULL); 2545 | +#else 2546 | obj = PyCObject_FromVoidPtr(descriptor, NULL); 2547 | +#endif 2548 | PyDict_SetItem(cache, key, obj); 2549 | Py_DECREF(obj); 2550 | } 2551 | @@ -2335,21 +2742,23 @@ 2552 | 2553 | SWIGRUNTIME int 2554 | SWIG_Python_AddErrMesg(const char* mesg, int infront) 2555 | -{ 2556 | +{ 2557 | if (PyErr_Occurred()) { 2558 | PyObject *type = 0; 2559 | PyObject *value = 0; 2560 | PyObject *traceback = 0; 2561 | PyErr_Fetch(&type, &value, &traceback); 2562 | if (value) { 2563 | + char *tmp; 2564 | PyObject *old_str = PyObject_Str(value); 2565 | Py_XINCREF(type); 2566 | PyErr_Clear(); 2567 | if (infront) { 2568 | - PyErr_Format(type, "%s %s", mesg, PyString_AsString(old_str)); 2569 | + PyErr_Format(type, "%s %s", mesg, tmp = SWIG_Python_str_AsChar(old_str)); 2570 | } else { 2571 | - PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg); 2572 | + PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg); 2573 | } 2574 | + SWIG_Python_str_DelForPy3(tmp); 2575 | Py_DECREF(old_str); 2576 | } 2577 | return 1; 2578 | @@ -2372,11 +2781,11 @@ 2579 | } 2580 | 2581 | SWIGRUNTIMEINLINE const char * 2582 | -PySwigObject_GetDesc(PyObject *self) 2583 | +SwigPyObject_GetDesc(PyObject *self) 2584 | { 2585 | - PySwigObject *v = (PySwigObject *)self; 2586 | + SwigPyObject *v = (SwigPyObject *)self; 2587 | swig_type_info *ty = v ? v->ty : 0; 2588 | - return ty ? ty->str : (char*)""; 2589 | + return ty ? ty->str : ""; 2590 | } 2591 | 2592 | SWIGRUNTIME void 2593 | @@ -2384,10 +2793,10 @@ 2594 | { 2595 | if (type) { 2596 | #if defined(SWIG_COBJECT_TYPES) 2597 | - if (obj && PySwigObject_Check(obj)) { 2598 | - const char *otype = (const char *) PySwigObject_GetDesc(obj); 2599 | + if (obj && SwigPyObject_Check(obj)) { 2600 | + const char *otype = (const char *) SwigPyObject_GetDesc(obj); 2601 | if (otype) { 2602 | - PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'PySwigObject(%s)' is received", 2603 | + PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'SwigPyObject(%s)' is received", 2604 | type, otype); 2605 | return; 2606 | } 2607 | @@ -2397,10 +2806,11 @@ 2608 | const char *otype = (obj ? obj->ob_type->tp_name : 0); 2609 | if (otype) { 2610 | PyObject *str = PyObject_Str(obj); 2611 | - const char *cstr = str ? PyString_AsString(str) : 0; 2612 | + const char *cstr = str ? SWIG_Python_str_AsChar(str) : 0; 2613 | if (cstr) { 2614 | PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received", 2615 | type, otype, cstr); 2616 | + SWIG_Python_str_DelForPy3(cstr); 2617 | } else { 2618 | PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received", 2619 | type, otype); 2620 | @@ -2418,23 +2828,75 @@ 2621 | 2622 | /* Convert a pointer value, signal an exception on a type mismatch */ 2623 | SWIGRUNTIME void * 2624 | -SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags) { 2625 | +SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int SWIGUNUSEDPARM(argnum), int flags) { 2626 | void *result; 2627 | if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) { 2628 | PyErr_Clear(); 2629 | - if (flags & SWIG_POINTER_EXCEPTION) { 2630 | +#if SWIG_POINTER_EXCEPTION 2631 | + if (flags) { 2632 | SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); 2633 | SWIG_Python_ArgFail(argnum); 2634 | } 2635 | +#endif 2636 | } 2637 | return result; 2638 | } 2639 | 2640 | +#ifdef SWIGPYTHON_BUILTIN 2641 | +SWIGRUNTIME int 2642 | +SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) { 2643 | + PyTypeObject *tp = obj->ob_type; 2644 | + PyObject *descr; 2645 | + PyObject *encoded_name; 2646 | + descrsetfunc f; 2647 | + int res = -1; 2648 | + 2649 | +# ifdef Py_USING_UNICODE 2650 | + if (PyString_Check(name)) { 2651 | + name = PyUnicode_Decode(PyString_AsString(name), PyString_Size(name), NULL, NULL); 2652 | + if (!name) 2653 | + return -1; 2654 | + } else if (!PyUnicode_Check(name)) 2655 | +# else 2656 | + if (!PyString_Check(name)) 2657 | +# endif 2658 | + { 2659 | + PyErr_Format(PyExc_TypeError, "attribute name must be string, not '%.200s'", name->ob_type->tp_name); 2660 | + return -1; 2661 | + } else { 2662 | + Py_INCREF(name); 2663 | + } 2664 | + 2665 | + if (!tp->tp_dict) { 2666 | + if (PyType_Ready(tp) < 0) 2667 | + goto done; 2668 | + } 2669 | + 2670 | + descr = _PyType_Lookup(tp, name); 2671 | + f = NULL; 2672 | + if (descr != NULL) 2673 | + f = descr->ob_type->tp_descr_set; 2674 | + if (!f) { 2675 | + if (PyString_Check(name)) { 2676 | + encoded_name = name; 2677 | + Py_INCREF(name); 2678 | + } else { 2679 | + encoded_name = PyUnicode_AsUTF8String(name); 2680 | + } 2681 | + PyErr_Format(PyExc_AttributeError, "'%.100s' object has no attribute '%.200s'", tp->tp_name, PyString_AsString(encoded_name)); 2682 | + Py_DECREF(encoded_name); 2683 | + } else { 2684 | + res = f(descr, obj, value); 2685 | + } 2686 | + 2687 | + done: 2688 | + Py_DECREF(name); 2689 | + return res; 2690 | +} 2691 | +#endif 2692 | + 2693 | 2694 | #ifdef __cplusplus 2695 | -#if 0 2696 | -{ /* cc-mode */ 2697 | -#endif 2698 | } 2699 | #endif 2700 | 2701 | @@ -2467,11 +2929,16 @@ 2702 | /*----------------------------------------------- 2703 | @(target):= _pcap.so 2704 | ------------------------------------------------*/ 2705 | -#define SWIG_init init_pcap 2706 | +#if PY_VERSION_HEX >= 0x03000000 2707 | +# define SWIG_init PyInit__pcap 2708 | + 2709 | +#else 2710 | +# define SWIG_init init_pcap 2711 | 2712 | +#endif 2713 | #define SWIG_name "_pcap" 2714 | 2715 | -#define SWIGVERSION 0x010331 2716 | +#define SWIGVERSION 0x030000 2717 | #define SWIG_VERSION SWIGVERSION 2718 | 2719 | 2720 | @@ -2499,9 +2966,13 @@ 2721 | if (size > INT_MAX) { 2722 | swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); 2723 | return pchar_descriptor ? 2724 | - SWIG_NewPointerObj((char *)(carray), pchar_descriptor, 0) : SWIG_Py_Void(); 2725 | + SWIG_InternalNewPointerObj((char *)(carray), pchar_descriptor, 0) : SWIG_Py_Void(); 2726 | } else { 2727 | +#if PY_VERSION_HEX >= 0x03000000 2728 | + return PyUnicode_FromStringAndSize(carray, (int)(size)); 2729 | +#else 2730 | return PyString_FromStringAndSize(carray, (int)(size)); 2731 | +#endif 2732 | } 2733 | } else { 2734 | return SWIG_Py_Void(); 2735 | @@ -2532,10 +3003,28 @@ 2736 | SWIGINTERN int 2737 | SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) 2738 | { 2739 | - if (PyString_Check(obj)) { 2740 | +#if PY_VERSION_HEX>=0x03000000 2741 | + if (PyUnicode_Check(obj)) 2742 | +#else 2743 | + if (PyString_Check(obj)) 2744 | +#endif 2745 | + { 2746 | char *cstr; Py_ssize_t len; 2747 | +#if PY_VERSION_HEX>=0x03000000 2748 | + if (!alloc && cptr) { 2749 | + /* We can't allow converting without allocation, since the internal 2750 | + representation of string in Python 3 is UCS-2/UCS-4 but we require 2751 | + a UTF-8 representation. 2752 | + TODO(bhy) More detailed explanation */ 2753 | + return SWIG_RuntimeError; 2754 | + } 2755 | + obj = PyUnicode_AsUTF8String(obj); 2756 | + PyBytes_AsStringAndSize(obj, &cstr, &len); 2757 | + if(alloc) *alloc = SWIG_NEWOBJ; 2758 | +#else 2759 | PyString_AsStringAndSize(obj, &cstr, &len); 2760 | - if (cptr) { 2761 | +#endif 2762 | + if (cptr) { 2763 | if (alloc) { 2764 | /* 2765 | In python the user should not be able to modify the inner 2766 | @@ -2560,10 +3049,16 @@ 2767 | *alloc = SWIG_OLDOBJ; 2768 | } 2769 | } else { 2770 | - *cptr = PyString_AsString(obj); 2771 | + #if PY_VERSION_HEX>=0x03000000 2772 | + assert(0); /* Should never reach here in Python 3 */ 2773 | + #endif 2774 | + *cptr = SWIG_Python_str_AsChar(obj); 2775 | } 2776 | } 2777 | if (psize) *psize = len + 1; 2778 | +#if PY_VERSION_HEX>=0x03000000 2779 | + Py_XDECREF(obj); 2780 | +#endif 2781 | return SWIG_OK; 2782 | } else { 2783 | swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); 2784 | @@ -2585,14 +3080,12 @@ 2785 | 2786 | 2787 | #include 2788 | -#ifndef LLONG_MIN 2789 | -# define LLONG_MIN LONG_LONG_MIN 2790 | -#endif 2791 | -#ifndef LLONG_MAX 2792 | -# define LLONG_MAX LONG_LONG_MAX 2793 | -#endif 2794 | -#ifndef ULLONG_MAX 2795 | -# define ULLONG_MAX ULONG_LONG_MAX 2796 | +#if !defined(SWIG_NO_LLONG_MAX) 2797 | +# if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__) 2798 | +# define LLONG_MAX __LONG_LONG_MAX__ 2799 | +# define LLONG_MIN (-LLONG_MAX - 1LL) 2800 | +# define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL) 2801 | +# endif 2802 | #endif 2803 | 2804 | 2805 | @@ -2736,13 +3229,10 @@ 2806 | static char _doc_pcapObject_dump_open[] = "dump_open(filename)\n\n" "Opens a saved pcap/tcpdump-format file for writing. 'filename' is the name\n" "of the file to open. The filename '-' is synonymous with stdout"; 2807 | static char _doc_pcapObject_setnonblock[] = "setnonblock(nonblock)\n\n" "Puts the pcapObject in non-blocking mode ('nonblock'==1) or blocking mode\n" "('nonblock'==0). Non-blocking behavior is only applicable to the\n" "dispatch method, and not the loop and next methods. It has no effect on\n" "savefiles."; 2808 | 2809 | - #define SWIG_From_long PyInt_FromLong 2810 | - 2811 | - 2812 | -SWIGINTERNINLINE PyObject * 2813 | -SWIG_From_int (int value) 2814 | -{ 2815 | - return SWIG_From_long (value); 2816 | +SWIGINTERNINLINE PyObject* 2817 | + SWIG_From_int (int value) 2818 | +{ 2819 | + return PyInt_FromLong((long) value); 2820 | } 2821 | 2822 | static char _doc_pcapObject_getnonblock[] = "getnonblock()\n\n" "Returns the non-blocking status of the pcapObject (returns 1 for\n" "non-blocking, returns 0 for blocking). 0 is always returned for savefiles\n" "Non-blocking behavior is only applicable to the dispatch method, and not\n" "the loop and next methods. It has no effect on savefiles."; 2823 | @@ -2784,6 +3274,32 @@ 2824 | } 2825 | 2826 | 2827 | +SWIGINTERN PyObject *_wrap_delete_pcapObject(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { 2828 | + PyObject *resultobj = 0; 2829 | + pcapObject *arg1 = (pcapObject *) 0 ; 2830 | + void *argp1 = 0 ; 2831 | + int res1 = 0 ; 2832 | + PyObject * obj0 = 0 ; 2833 | + 2834 | + if (!PyArg_ParseTuple(args,(char *)"O:delete_pcapObject",&obj0)) SWIG_fail; 2835 | + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_pcapObject, SWIG_POINTER_DISOWN | 0 ); 2836 | + if (!SWIG_IsOK(res1)) { 2837 | + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_pcapObject" "', argument " "1"" of type '" "pcapObject *""'"); 2838 | + } 2839 | + arg1 = (pcapObject *)(argp1); 2840 | + { 2841 | + delete_pcapObject(arg1); 2842 | + if(PyErr_Occurred()) { 2843 | + SWIG_fail; 2844 | + } 2845 | + } 2846 | + resultobj = SWIG_Py_Void(); 2847 | + return resultobj; 2848 | +fail: 2849 | + return NULL; 2850 | +} 2851 | + 2852 | + 2853 | SWIGINTERN PyObject *_wrap_pcapObject_open_live(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { 2854 | PyObject *resultobj = 0; 2855 | pcapObject *arg1 = (pcapObject *) 0 ; 2856 | @@ -3007,10 +3523,10 @@ 2857 | SWIGINTERN PyObject *_wrap_pcapObject_getnonblock(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { 2858 | PyObject *resultobj = 0; 2859 | pcapObject *arg1 = (pcapObject *) 0 ; 2860 | - int result; 2861 | void *argp1 = 0 ; 2862 | int res1 = 0 ; 2863 | PyObject * obj0 = 0 ; 2864 | + int result; 2865 | 2866 | if (!PyArg_ParseTuple(args,(char *)"O:pcapObject_getnonblock",&obj0)) SWIG_fail; 2867 | res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_pcapObject, 0 | 0 ); 2868 | @@ -3143,7 +3659,6 @@ 2869 | pcapObject *arg1 = (pcapObject *) 0 ; 2870 | int arg2 ; 2871 | PyObject *arg3 = (PyObject *) 0 ; 2872 | - int result; 2873 | void *argp1 = 0 ; 2874 | int res1 = 0 ; 2875 | int val2 ; 2876 | @@ -3151,6 +3666,7 @@ 2877 | PyObject * obj0 = 0 ; 2878 | PyObject * obj1 = 0 ; 2879 | PyObject * obj2 = 0 ; 2880 | + int result; 2881 | 2882 | if (!PyArg_ParseTuple(args,(char *)"OOO:pcapObject_dispatch",&obj0,&obj1,&obj2)) SWIG_fail; 2883 | res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_pcapObject, 0 | 0 ); 2884 | @@ -3182,10 +3698,10 @@ 2885 | SWIGINTERN PyObject *_wrap_pcapObject_next(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { 2886 | PyObject *resultobj = 0; 2887 | pcapObject *arg1 = (pcapObject *) 0 ; 2888 | - PyObject *result = 0 ; 2889 | void *argp1 = 0 ; 2890 | int res1 = 0 ; 2891 | PyObject * obj0 = 0 ; 2892 | + PyObject *result = 0 ; 2893 | 2894 | if (!PyArg_ParseTuple(args,(char *)"O:pcapObject_next",&obj0)) SWIG_fail; 2895 | res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_pcapObject, 0 | 0 ); 2896 | @@ -3211,10 +3727,10 @@ 2897 | SWIGINTERN PyObject *_wrap_pcapObject_datalink(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { 2898 | PyObject *resultobj = 0; 2899 | pcapObject *arg1 = (pcapObject *) 0 ; 2900 | - int result; 2901 | void *argp1 = 0 ; 2902 | int res1 = 0 ; 2903 | PyObject * obj0 = 0 ; 2904 | + int result; 2905 | 2906 | if (!PyArg_ParseTuple(args,(char *)"O:pcapObject_datalink",&obj0)) SWIG_fail; 2907 | res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_pcapObject, 0 | 0 ); 2908 | @@ -3238,10 +3754,10 @@ 2909 | SWIGINTERN PyObject *_wrap_pcapObject_datalinks(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { 2910 | PyObject *resultobj = 0; 2911 | pcapObject *arg1 = (pcapObject *) 0 ; 2912 | - PyObject *result = 0 ; 2913 | void *argp1 = 0 ; 2914 | int res1 = 0 ; 2915 | PyObject * obj0 = 0 ; 2916 | + PyObject *result = 0 ; 2917 | 2918 | if (!PyArg_ParseTuple(args,(char *)"O:pcapObject_datalinks",&obj0)) SWIG_fail; 2919 | res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_pcapObject, 0 | 0 ); 2920 | @@ -3267,10 +3783,10 @@ 2921 | SWIGINTERN PyObject *_wrap_pcapObject_snapshot(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { 2922 | PyObject *resultobj = 0; 2923 | pcapObject *arg1 = (pcapObject *) 0 ; 2924 | - int result; 2925 | void *argp1 = 0 ; 2926 | int res1 = 0 ; 2927 | PyObject * obj0 = 0 ; 2928 | + int result; 2929 | 2930 | if (!PyArg_ParseTuple(args,(char *)"O:pcapObject_snapshot",&obj0)) SWIG_fail; 2931 | res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_pcapObject, 0 | 0 ); 2932 | @@ -3294,10 +3810,10 @@ 2933 | SWIGINTERN PyObject *_wrap_pcapObject_is_swapped(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { 2934 | PyObject *resultobj = 0; 2935 | pcapObject *arg1 = (pcapObject *) 0 ; 2936 | - int result; 2937 | void *argp1 = 0 ; 2938 | int res1 = 0 ; 2939 | PyObject * obj0 = 0 ; 2940 | + int result; 2941 | 2942 | if (!PyArg_ParseTuple(args,(char *)"O:pcapObject_is_swapped",&obj0)) SWIG_fail; 2943 | res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_pcapObject, 0 | 0 ); 2944 | @@ -3321,10 +3837,10 @@ 2945 | SWIGINTERN PyObject *_wrap_pcapObject_major_version(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { 2946 | PyObject *resultobj = 0; 2947 | pcapObject *arg1 = (pcapObject *) 0 ; 2948 | - int result; 2949 | void *argp1 = 0 ; 2950 | int res1 = 0 ; 2951 | PyObject * obj0 = 0 ; 2952 | + int result; 2953 | 2954 | if (!PyArg_ParseTuple(args,(char *)"O:pcapObject_major_version",&obj0)) SWIG_fail; 2955 | res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_pcapObject, 0 | 0 ); 2956 | @@ -3348,10 +3864,10 @@ 2957 | SWIGINTERN PyObject *_wrap_pcapObject_minor_version(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { 2958 | PyObject *resultobj = 0; 2959 | pcapObject *arg1 = (pcapObject *) 0 ; 2960 | - int result; 2961 | void *argp1 = 0 ; 2962 | int res1 = 0 ; 2963 | PyObject * obj0 = 0 ; 2964 | + int result; 2965 | 2966 | if (!PyArg_ParseTuple(args,(char *)"O:pcapObject_minor_version",&obj0)) SWIG_fail; 2967 | res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_pcapObject, 0 | 0 ); 2968 | @@ -3375,10 +3891,10 @@ 2969 | SWIGINTERN PyObject *_wrap_pcapObject_stats(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { 2970 | PyObject *resultobj = 0; 2971 | pcapObject *arg1 = (pcapObject *) 0 ; 2972 | - PyObject *result = 0 ; 2973 | void *argp1 = 0 ; 2974 | int res1 = 0 ; 2975 | PyObject * obj0 = 0 ; 2976 | + PyObject *result = 0 ; 2977 | 2978 | if (!PyArg_ParseTuple(args,(char *)"O:pcapObject_stats",&obj0)) SWIG_fail; 2979 | res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_pcapObject, 0 | 0 ); 2980 | @@ -3404,10 +3920,10 @@ 2981 | SWIGINTERN PyObject *_wrap_pcapObject_fileno(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { 2982 | PyObject *resultobj = 0; 2983 | pcapObject *arg1 = (pcapObject *) 0 ; 2984 | - int result; 2985 | void *argp1 = 0 ; 2986 | int res1 = 0 ; 2987 | PyObject * obj0 = 0 ; 2988 | + int result; 2989 | 2990 | if (!PyArg_ParseTuple(args,(char *)"O:pcapObject_fileno",&obj0)) SWIG_fail; 2991 | res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_pcapObject, 0 | 0 ); 2992 | @@ -3428,62 +3944,84 @@ 2993 | } 2994 | 2995 | 2996 | -SWIGINTERN PyObject *_wrap_delete_pcapObject__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { 2997 | +SWIGINTERN PyObject *_wrap_pcapObject_pcap_set_rfmon(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { 2998 | PyObject *resultobj = 0; 2999 | pcapObject *arg1 = (pcapObject *) 0 ; 3000 | + char *arg2 = (char *) 0 ; 3001 | + int arg3 ; 3002 | void *argp1 = 0 ; 3003 | int res1 = 0 ; 3004 | + int res2 ; 3005 | + char *buf2 = 0 ; 3006 | + int alloc2 = 0 ; 3007 | + int val3 ; 3008 | + int ecode3 = 0 ; 3009 | PyObject * obj0 = 0 ; 3010 | + PyObject * obj1 = 0 ; 3011 | + PyObject * obj2 = 0 ; 3012 | + int result; 3013 | 3014 | - if (!PyArg_ParseTuple(args,(char *)"O:delete_pcapObject",&obj0)) SWIG_fail; 3015 | - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_pcapObject, SWIG_POINTER_DISOWN | 0 ); 3016 | + if (!PyArg_ParseTuple(args,(char *)"OOO:pcapObject_pcap_set_rfmon",&obj0,&obj1,&obj2)) SWIG_fail; 3017 | + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_pcapObject, 0 | 0 ); 3018 | if (!SWIG_IsOK(res1)) { 3019 | - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_pcapObject" "', argument " "1"" of type '" "pcapObject *""'"); 3020 | + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pcapObject_pcap_set_rfmon" "', argument " "1"" of type '" "pcapObject *""'"); 3021 | } 3022 | arg1 = (pcapObject *)(argp1); 3023 | + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); 3024 | + if (!SWIG_IsOK(res2)) { 3025 | + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "pcapObject_pcap_set_rfmon" "', argument " "2"" of type '" "char *""'"); 3026 | + } 3027 | + arg2 = (char *)(buf2); 3028 | + ecode3 = SWIG_AsVal_int(obj2, &val3); 3029 | + if (!SWIG_IsOK(ecode3)) { 3030 | + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "pcapObject_pcap_set_rfmon" "', argument " "3"" of type '" "int""'"); 3031 | + } 3032 | + arg3 = (int)(val3); 3033 | { 3034 | - free((char *) arg1); 3035 | - 3036 | + result = (int)pcapObject_pcap_set_rfmon(arg1,arg2,arg3); 3037 | if(PyErr_Occurred()) { 3038 | SWIG_fail; 3039 | } 3040 | } 3041 | - resultobj = SWIG_Py_Void(); 3042 | + resultobj = SWIG_From_int((int)(result)); 3043 | + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); 3044 | return resultobj; 3045 | fail: 3046 | + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); 3047 | return NULL; 3048 | } 3049 | 3050 | 3051 | -SWIGINTERN PyObject *_wrap_delete_pcapObject(PyObject *self, PyObject *args) { 3052 | - int argc; 3053 | - PyObject *argv[2]; 3054 | - int ii; 3055 | - 3056 | - if (!PyTuple_Check(args)) SWIG_fail; 3057 | - argc = PyObject_Length(args); 3058 | - for (ii = 0; (ii < argc) && (ii < 1); ii++) { 3059 | - argv[ii] = PyTuple_GET_ITEM(args,ii); 3060 | +SWIGINTERN PyObject *_wrap_pcapObject_pcap_activate(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { 3061 | + PyObject *resultobj = 0; 3062 | + pcapObject *arg1 = (pcapObject *) 0 ; 3063 | + void *argp1 = 0 ; 3064 | + int res1 = 0 ; 3065 | + PyObject * obj0 = 0 ; 3066 | + int result; 3067 | + 3068 | + if (!PyArg_ParseTuple(args,(char *)"O:pcapObject_pcap_activate",&obj0)) SWIG_fail; 3069 | + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_pcapObject, 0 | 0 ); 3070 | + if (!SWIG_IsOK(res1)) { 3071 | + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pcapObject_pcap_activate" "', argument " "1"" of type '" "pcapObject *""'"); 3072 | } 3073 | - if (argc == 1) { 3074 | - int _v; 3075 | - void *vptr = 0; 3076 | - int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_pcapObject, 0); 3077 | - _v = SWIG_CheckState(res); 3078 | - if (_v) { 3079 | - return _wrap_delete_pcapObject__SWIG_1(self, args); 3080 | + arg1 = (pcapObject *)(argp1); 3081 | + { 3082 | + result = (int)pcapObject_pcap_activate(arg1); 3083 | + if(PyErr_Occurred()) { 3084 | + SWIG_fail; 3085 | } 3086 | } 3087 | - 3088 | + resultobj = SWIG_From_int((int)(result)); 3089 | + return resultobj; 3090 | fail: 3091 | - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'delete_pcapObject'.\n Possible C/C++ prototypes are:\n ~pcapObject()\n pcapObject::~pcapObject()\n"); 3092 | return NULL; 3093 | } 3094 | 3095 | 3096 | SWIGINTERN PyObject *pcapObject_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { 3097 | PyObject *obj; 3098 | - if (!PyArg_ParseTuple(args,(char*)"O|swigregister", &obj)) return NULL; 3099 | + if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL; 3100 | SWIG_TypeNewClientData(SWIGTYPE_p_pcapObject, SWIG_NewClientData(obj)); 3101 | return SWIG_Py_Void(); 3102 | } 3103 | @@ -3509,10 +4047,10 @@ 3104 | SWIGINTERN PyObject *_wrap_findalldevs(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { 3105 | PyObject *resultobj = 0; 3106 | int arg1 = (int) 1 ; 3107 | - PyObject *result = 0 ; 3108 | int val1 ; 3109 | int ecode1 = 0 ; 3110 | PyObject * obj0 = 0 ; 3111 | + PyObject *result = 0 ; 3112 | 3113 | if (!PyArg_ParseTuple(args,(char *)"|O:findalldevs",&obj0)) SWIG_fail; 3114 | if (obj0) { 3115 | @@ -3540,11 +4078,11 @@ 3116 | SWIGINTERN PyObject *_wrap_lookupnet(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { 3117 | PyObject *resultobj = 0; 3118 | char *arg1 = (char *) 0 ; 3119 | - PyObject *result = 0 ; 3120 | int res1 ; 3121 | char *buf1 = 0 ; 3122 | int alloc1 = 0 ; 3123 | PyObject * obj0 = 0 ; 3124 | + PyObject *result = 0 ; 3125 | 3126 | if (!PyArg_ParseTuple(args,(char *)"O:lookupnet",&obj0)) SWIG_fail; 3127 | res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); 3128 | @@ -3572,11 +4110,11 @@ 3129 | SWIGINTERN PyObject *_wrap_aton(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { 3130 | PyObject *resultobj = 0; 3131 | char *arg1 = (char *) 0 ; 3132 | - PyObject *result = 0 ; 3133 | int res1 ; 3134 | char *buf1 = 0 ; 3135 | int alloc1 = 0 ; 3136 | PyObject * obj0 = 0 ; 3137 | + PyObject *result = 0 ; 3138 | 3139 | if (!PyArg_ParseTuple(args,(char *)"O:aton",&obj0)) SWIG_fail; 3140 | res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); 3141 | @@ -3604,8 +4142,8 @@ 3142 | SWIGINTERN PyObject *_wrap_ntoa(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { 3143 | PyObject *resultobj = 0; 3144 | in_addr_t arg1 ; 3145 | - char *result = 0 ; 3146 | PyObject * obj0 = 0 ; 3147 | + char *result = 0 ; 3148 | 3149 | if (!PyArg_ParseTuple(args,(char *)"O:ntoa",&obj0)) SWIG_fail; 3150 | { 3151 | @@ -3640,32 +4178,35 @@ 3152 | 3153 | 3154 | static PyMethodDef SwigMethods[] = { 3155 | - { (char *)"new_pcapObject", _wrap_new_pcapObject, METH_VARARGS, _doc_new_pcapObject }, 3156 | - { (char *)"pcapObject_open_live", _wrap_pcapObject_open_live, METH_VARARGS, _doc_pcapObject_open_live }, 3157 | - { (char *)"pcapObject_open_dead", _wrap_pcapObject_open_dead, METH_VARARGS, _doc_pcapObject_open_dead }, 3158 | - { (char *)"pcapObject_open_offline", _wrap_pcapObject_open_offline, METH_VARARGS, _doc_pcapObject_open_offline }, 3159 | - { (char *)"pcapObject_dump_open", _wrap_pcapObject_dump_open, METH_VARARGS, _doc_pcapObject_dump_open }, 3160 | - { (char *)"pcapObject_setnonblock", _wrap_pcapObject_setnonblock, METH_VARARGS, _doc_pcapObject_setnonblock }, 3161 | - { (char *)"pcapObject_getnonblock", _wrap_pcapObject_getnonblock, METH_VARARGS, _doc_pcapObject_getnonblock }, 3162 | - { (char *)"pcapObject_setfilter", _wrap_pcapObject_setfilter, METH_VARARGS, _doc_pcapObject_setfilter }, 3163 | - { (char *)"pcapObject_loop", _wrap_pcapObject_loop, METH_VARARGS, _doc_pcapObject_loop }, 3164 | - { (char *)"pcapObject_dispatch", _wrap_pcapObject_dispatch, METH_VARARGS, _doc_pcapObject_dispatch }, 3165 | - { (char *)"pcapObject_next", _wrap_pcapObject_next, METH_VARARGS, _doc_pcapObject_next }, 3166 | - { (char *)"pcapObject_datalink", _wrap_pcapObject_datalink, METH_VARARGS, _doc_pcapObject_datalink }, 3167 | - { (char *)"pcapObject_datalinks", _wrap_pcapObject_datalinks, METH_VARARGS, _doc_pcapObject_datalinks }, 3168 | - { (char *)"pcapObject_snapshot", _wrap_pcapObject_snapshot, METH_VARARGS, _doc_pcapObject_snapshot }, 3169 | - { (char *)"pcapObject_is_swapped", _wrap_pcapObject_is_swapped, METH_VARARGS, _doc_pcapObject_is_swapped }, 3170 | - { (char *)"pcapObject_major_version", _wrap_pcapObject_major_version, METH_VARARGS, _doc_pcapObject_major_version }, 3171 | - { (char *)"pcapObject_minor_version", _wrap_pcapObject_minor_version, METH_VARARGS, _doc_pcapObject_minor_version }, 3172 | - { (char *)"pcapObject_stats", _wrap_pcapObject_stats, METH_VARARGS, _doc_pcapObject_stats }, 3173 | - { (char *)"pcapObject_fileno", _wrap_pcapObject_fileno, METH_VARARGS, _doc_pcapObject_fileno }, 3174 | - { (char *)"delete_pcapObject", _wrap_delete_pcapObject, METH_VARARGS, _doc_delete_pcapObject }, 3175 | + { (char *)"SWIG_PyInstanceMethod_New", (PyCFunction)SWIG_PyInstanceMethod_New, METH_O, NULL}, 3176 | + { (char *)"new_pcapObject", _wrap_new_pcapObject, METH_VARARGS, NULL}, 3177 | + { (char *)"delete_pcapObject", _wrap_delete_pcapObject, METH_VARARGS, NULL}, 3178 | + { (char *)"pcapObject_open_live", _wrap_pcapObject_open_live, METH_VARARGS, NULL}, 3179 | + { (char *)"pcapObject_open_dead", _wrap_pcapObject_open_dead, METH_VARARGS, NULL}, 3180 | + { (char *)"pcapObject_open_offline", _wrap_pcapObject_open_offline, METH_VARARGS, NULL}, 3181 | + { (char *)"pcapObject_dump_open", _wrap_pcapObject_dump_open, METH_VARARGS, NULL}, 3182 | + { (char *)"pcapObject_setnonblock", _wrap_pcapObject_setnonblock, METH_VARARGS, NULL}, 3183 | + { (char *)"pcapObject_getnonblock", _wrap_pcapObject_getnonblock, METH_VARARGS, NULL}, 3184 | + { (char *)"pcapObject_setfilter", _wrap_pcapObject_setfilter, METH_VARARGS, NULL}, 3185 | + { (char *)"pcapObject_loop", _wrap_pcapObject_loop, METH_VARARGS, NULL}, 3186 | + { (char *)"pcapObject_dispatch", _wrap_pcapObject_dispatch, METH_VARARGS, NULL}, 3187 | + { (char *)"pcapObject_next", _wrap_pcapObject_next, METH_VARARGS, NULL}, 3188 | + { (char *)"pcapObject_datalink", _wrap_pcapObject_datalink, METH_VARARGS, NULL}, 3189 | + { (char *)"pcapObject_datalinks", _wrap_pcapObject_datalinks, METH_VARARGS, NULL}, 3190 | + { (char *)"pcapObject_snapshot", _wrap_pcapObject_snapshot, METH_VARARGS, NULL}, 3191 | + { (char *)"pcapObject_is_swapped", _wrap_pcapObject_is_swapped, METH_VARARGS, NULL}, 3192 | + { (char *)"pcapObject_major_version", _wrap_pcapObject_major_version, METH_VARARGS, NULL}, 3193 | + { (char *)"pcapObject_minor_version", _wrap_pcapObject_minor_version, METH_VARARGS, NULL}, 3194 | + { (char *)"pcapObject_stats", _wrap_pcapObject_stats, METH_VARARGS, NULL}, 3195 | + { (char *)"pcapObject_fileno", _wrap_pcapObject_fileno, METH_VARARGS, NULL}, 3196 | + { (char *)"pcapObject_pcap_set_rfmon", _wrap_pcapObject_pcap_set_rfmon, METH_VARARGS, NULL}, 3197 | + { (char *)"pcapObject_pcap_activate", _wrap_pcapObject_pcap_activate, METH_VARARGS, NULL}, 3198 | { (char *)"pcapObject_swigregister", pcapObject_swigregister, METH_VARARGS, NULL}, 3199 | - { (char *)"lookupdev", _wrap_lookupdev, METH_VARARGS, _doc_lookupdev }, 3200 | - { (char *)"findalldevs", _wrap_findalldevs, METH_VARARGS, _doc_findalldevs }, 3201 | - { (char *)"lookupnet", _wrap_lookupnet, METH_VARARGS, _doc_lookupnet }, 3202 | - { (char *)"aton", _wrap_aton, METH_VARARGS, _doc_aton }, 3203 | - { (char *)"ntoa", _wrap_ntoa, METH_VARARGS, _doc_ntoa }, 3204 | + { (char *)"lookupdev", _wrap_lookupdev, METH_VARARGS, NULL}, 3205 | + { (char *)"findalldevs", _wrap_findalldevs, METH_VARARGS, NULL}, 3206 | + { (char *)"lookupnet", _wrap_lookupnet, METH_VARARGS, NULL}, 3207 | + { (char *)"aton", _wrap_aton, METH_VARARGS, NULL}, 3208 | + { (char *)"ntoa", _wrap_ntoa, METH_VARARGS, NULL}, 3209 | { NULL, NULL, 0, NULL } 3210 | }; 3211 | 3212 | @@ -3703,18 +4244,18 @@ 3213 | #endif 3214 | /* ----------------------------------------------------------------------------- 3215 | * Type initialization: 3216 | - * This problem is tough by the requirement that no dynamic 3217 | - * memory is used. Also, since swig_type_info structures store pointers to 3218 | + * This problem is tough by the requirement that no dynamic 3219 | + * memory is used. Also, since swig_type_info structures store pointers to 3220 | * swig_cast_info structures and swig_cast_info structures store pointers back 3221 | - * to swig_type_info structures, we need some lookup code at initialization. 3222 | - * The idea is that swig generates all the structures that are needed. 3223 | - * The runtime then collects these partially filled structures. 3224 | - * The SWIG_InitializeModule function takes these initial arrays out of 3225 | + * to swig_type_info structures, we need some lookup code at initialization. 3226 | + * The idea is that swig generates all the structures that are needed. 3227 | + * The runtime then collects these partially filled structures. 3228 | + * The SWIG_InitializeModule function takes these initial arrays out of 3229 | * swig_module, and does all the lookup, filling in the swig_module.types 3230 | * array with the correct data and linking the correct swig_cast_info 3231 | * structures together. 3232 | * 3233 | - * The generated swig_type_info structures are assigned staticly to an initial 3234 | + * The generated swig_type_info structures are assigned statically to an initial 3235 | * array. We just loop through that array, and handle each type individually. 3236 | * First we lookup if this type has been already loaded, and if so, use the 3237 | * loaded structure instead of the generated one. Then we have to fill in the 3238 | @@ -3724,17 +4265,17 @@ 3239 | * a column is one of the swig_cast_info structures for that type. 3240 | * The cast_initial array is actually an array of arrays, because each row has 3241 | * a variable number of columns. So to actually build the cast linked list, 3242 | - * we find the array of casts associated with the type, and loop through it 3243 | + * we find the array of casts associated with the type, and loop through it 3244 | * adding the casts to the list. The one last trick we need to do is making 3245 | * sure the type pointer in the swig_cast_info struct is correct. 3246 | * 3247 | - * First off, we lookup the cast->type name to see if it is already loaded. 3248 | + * First off, we lookup the cast->type name to see if it is already loaded. 3249 | * There are three cases to handle: 3250 | * 1) If the cast->type has already been loaded AND the type we are adding 3251 | * casting info to has not been loaded (it is in this module), THEN we 3252 | * replace the cast->type pointer with the type pointer that has already 3253 | * been loaded. 3254 | - * 2) If BOTH types (the one we are adding casting info to, and the 3255 | + * 2) If BOTH types (the one we are adding casting info to, and the 3256 | * cast->type) are loaded, THEN the cast info has already been loaded by 3257 | * the previous module so we just ignore it. 3258 | * 3) Finally, if cast->type has not already been loaded, then we add that 3259 | @@ -3758,9 +4299,7 @@ 3260 | SWIG_InitializeModule(void *clientdata) { 3261 | size_t i; 3262 | swig_module_info *module_head, *iter; 3263 | - int found; 3264 | - 3265 | - clientdata = clientdata; 3266 | + int found, init; 3267 | 3268 | /* check to see if the circular list has been setup, if not, set it up */ 3269 | if (swig_module.next==0) { 3270 | @@ -3768,6 +4307,9 @@ 3271 | swig_module.type_initial = swig_type_initial; 3272 | swig_module.cast_initial = swig_cast_initial; 3273 | swig_module.next = &swig_module; 3274 | + init = 1; 3275 | + } else { 3276 | + init = 0; 3277 | } 3278 | 3279 | /* Try and load any already created modules */ 3280 | @@ -3796,6 +4338,12 @@ 3281 | module_head->next = &swig_module; 3282 | } 3283 | 3284 | + /* When multiple interpreters are used, a module could have already been initialized in 3285 | + a different interpreter, but not yet have a pointer in this interpreter. 3286 | + In this case, we do not want to continue adding types... everything should be 3287 | + set up already */ 3288 | + if (init == 0) return; 3289 | + 3290 | /* Now work on filling in swig_module.types */ 3291 | #ifdef SWIGRUNTIME_DEBUG 3292 | printf("SWIG_InitializeModule: size %d\n", swig_module.size); 3293 | @@ -3958,26 +4506,58 @@ 3294 | 3295 | SWIGINTERN PyObject * 3296 | swig_varlink_repr(swig_varlinkobject *SWIGUNUSEDPARM(v)) { 3297 | +#if PY_VERSION_HEX >= 0x03000000 3298 | + return PyUnicode_InternFromString(""); 3299 | +#else 3300 | return PyString_FromString(""); 3301 | +#endif 3302 | } 3303 | 3304 | SWIGINTERN PyObject * 3305 | swig_varlink_str(swig_varlinkobject *v) { 3306 | +#if PY_VERSION_HEX >= 0x03000000 3307 | + PyObject *str = PyUnicode_InternFromString("("); 3308 | + PyObject *tail; 3309 | + PyObject *joined; 3310 | + swig_globalvar *var; 3311 | + for (var = v->vars; var; var=var->next) { 3312 | + tail = PyUnicode_FromString(var->name); 3313 | + joined = PyUnicode_Concat(str, tail); 3314 | + Py_DecRef(str); 3315 | + Py_DecRef(tail); 3316 | + str = joined; 3317 | + if (var->next) { 3318 | + tail = PyUnicode_InternFromString(", "); 3319 | + joined = PyUnicode_Concat(str, tail); 3320 | + Py_DecRef(str); 3321 | + Py_DecRef(tail); 3322 | + str = joined; 3323 | + } 3324 | + } 3325 | + tail = PyUnicode_InternFromString(")"); 3326 | + joined = PyUnicode_Concat(str, tail); 3327 | + Py_DecRef(str); 3328 | + Py_DecRef(tail); 3329 | + str = joined; 3330 | +#else 3331 | PyObject *str = PyString_FromString("("); 3332 | - swig_globalvar *var; 3333 | + swig_globalvar *var; 3334 | for (var = v->vars; var; var=var->next) { 3335 | PyString_ConcatAndDel(&str,PyString_FromString(var->name)); 3336 | if (var->next) PyString_ConcatAndDel(&str,PyString_FromString(", ")); 3337 | } 3338 | PyString_ConcatAndDel(&str,PyString_FromString(")")); 3339 | +#endif 3340 | return str; 3341 | } 3342 | 3343 | SWIGINTERN int 3344 | swig_varlink_print(swig_varlinkobject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) { 3345 | + char *tmp; 3346 | PyObject *str = swig_varlink_str(v); 3347 | fprintf(fp,"Swig global variables "); 3348 | - fprintf(fp,"%s\n", PyString_AsString(str)); 3349 | + fprintf(fp,"%s\n", tmp = SWIG_Python_str_AsChar(str)); 3350 | + SWIG_Python_str_DelForPy3(tmp); 3351 | Py_DECREF(str); 3352 | return 0; 3353 | } 3354 | @@ -4005,7 +4585,7 @@ 3355 | var = var->next; 3356 | } 3357 | if (res == NULL && !PyErr_Occurred()) { 3358 | - PyErr_SetString(PyExc_NameError,"Unknown C global variable"); 3359 | + PyErr_Format(PyExc_AttributeError, "Unknown C global variable '%s'", n); 3360 | } 3361 | return res; 3362 | } 3363 | @@ -4022,7 +4602,7 @@ 3364 | var = var->next; 3365 | } 3366 | if (res == 1 && !PyErr_Occurred()) { 3367 | - PyErr_SetString(PyExc_NameError,"Unknown C global variable"); 3368 | + PyErr_Format(PyExc_AttributeError, "Unknown C global variable '%s'", n); 3369 | } 3370 | return res; 3371 | } 3372 | @@ -4031,19 +4611,23 @@ 3373 | swig_varlink_type(void) { 3374 | static char varlink__doc__[] = "Swig var link object"; 3375 | static PyTypeObject varlink_type; 3376 | - static int type_init = 0; 3377 | + static int type_init = 0; 3378 | if (!type_init) { 3379 | - const PyTypeObject tmp 3380 | - = { 3381 | + const PyTypeObject tmp = { 3382 | + /* PyObject header changed in Python 3 */ 3383 | +#if PY_VERSION_HEX >= 0x03000000 3384 | + PyVarObject_HEAD_INIT(NULL, 0) 3385 | +#else 3386 | PyObject_HEAD_INIT(NULL) 3387 | - 0, /* Number of items in variable part (ob_size) */ 3388 | - (char *)"swigvarlink", /* Type name (tp_name) */ 3389 | - sizeof(swig_varlinkobject), /* Basic size (tp_basicsize) */ 3390 | - 0, /* Itemsize (tp_itemsize) */ 3391 | - (destructor) swig_varlink_dealloc, /* Deallocator (tp_dealloc) */ 3392 | - (printfunc) swig_varlink_print, /* Print (tp_print) */ 3393 | - (getattrfunc) swig_varlink_getattr, /* get attr (tp_getattr) */ 3394 | - (setattrfunc) swig_varlink_setattr, /* Set attr (tp_setattr) */ 3395 | + 0, /* ob_size */ 3396 | +#endif 3397 | + (char *)"swigvarlink", /* tp_name */ 3398 | + sizeof(swig_varlinkobject), /* tp_basicsize */ 3399 | + 0, /* tp_itemsize */ 3400 | + (destructor) swig_varlink_dealloc, /* tp_dealloc */ 3401 | + (printfunc) swig_varlink_print, /* tp_print */ 3402 | + (getattrfunc) swig_varlink_getattr, /* tp_getattr */ 3403 | + (setattrfunc) swig_varlink_setattr, /* tp_setattr */ 3404 | 0, /* tp_compare */ 3405 | (reprfunc) swig_varlink_repr, /* tp_repr */ 3406 | 0, /* tp_as_number */ 3407 | @@ -4051,7 +4635,7 @@ 3408 | 0, /* tp_as_mapping */ 3409 | 0, /* tp_hash */ 3410 | 0, /* tp_call */ 3411 | - (reprfunc)swig_varlink_str, /* tp_str */ 3412 | + (reprfunc) swig_varlink_str, /* tp_str */ 3413 | 0, /* tp_getattro */ 3414 | 0, /* tp_setattro */ 3415 | 0, /* tp_as_buffer */ 3416 | @@ -4067,13 +4651,21 @@ 3417 | #if PY_VERSION_HEX >= 0x02030000 3418 | 0, /* tp_del */ 3419 | #endif 3420 | +#if PY_VERSION_HEX >= 0x02060000 3421 | + 0, /* tp_version */ 3422 | +#endif 3423 | #ifdef COUNT_ALLOCS 3424 | 0,0,0,0 /* tp_alloc -> tp_next */ 3425 | #endif 3426 | }; 3427 | varlink_type = tmp; 3428 | - varlink_type.ob_type = &PyType_Type; 3429 | type_init = 1; 3430 | +#if PY_VERSION_HEX < 0x02020000 3431 | + varlink_type.ob_type = &PyType_Type; 3432 | +#else 3433 | + if (PyType_Ready(&varlink_type) < 0) 3434 | + return NULL; 3435 | +#endif 3436 | } 3437 | return &varlink_type; 3438 | } 3439 | @@ -4124,7 +4716,7 @@ 3440 | for (i = 0; constants[i].type; ++i) { 3441 | switch(constants[i].type) { 3442 | case SWIG_PY_POINTER: 3443 | - obj = SWIG_NewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0); 3444 | + obj = SWIG_InternalNewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0); 3445 | break; 3446 | case SWIG_PY_BINARY: 3447 | obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype)); 3448 | @@ -4164,15 +4756,15 @@ 3449 | } 3450 | } 3451 | if (ci) { 3452 | - size_t shift = (ci->ptype) - types; 3453 | - swig_type_info *ty = types_initial[shift]; 3454 | - size_t ldoc = (c - methods[i].ml_doc); 3455 | - size_t lptr = strlen(ty->name)+2*sizeof(void*)+2; 3456 | - char *ndoc = (char*)malloc(ldoc + lptr + 10); 3457 | - if (ndoc) { 3458 | - char *buff = ndoc; 3459 | - void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0; 3460 | - if (ptr) { 3461 | + void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0; 3462 | + if (ptr) { 3463 | + size_t shift = (ci->ptype) - types; 3464 | + swig_type_info *ty = types_initial[shift]; 3465 | + size_t ldoc = (c - methods[i].ml_doc); 3466 | + size_t lptr = strlen(ty->name)+2*sizeof(void*)+2; 3467 | + char *ndoc = (char*)malloc(ldoc + lptr + 10); 3468 | + if (ndoc) { 3469 | + char *buff = ndoc; 3470 | strncpy(buff, methods[i].ml_doc, ldoc); 3471 | buff += ldoc; 3472 | strncpy(buff, "swig_ptr: ", 10); 3473 | @@ -4197,18 +4789,131 @@ 3474 | #ifdef __cplusplus 3475 | extern "C" 3476 | #endif 3477 | -SWIGEXPORT void SWIG_init(void) { 3478 | - PyObject *m, *d; 3479 | + 3480 | +SWIGEXPORT 3481 | +#if PY_VERSION_HEX >= 0x03000000 3482 | +PyObject* 3483 | +#else 3484 | +void 3485 | +#endif 3486 | +SWIG_init(void) { 3487 | + PyObject *m, *d, *md; 3488 | +#if PY_VERSION_HEX >= 0x03000000 3489 | + static struct PyModuleDef SWIG_module = { 3490 | +# if PY_VERSION_HEX >= 0x03020000 3491 | + PyModuleDef_HEAD_INIT, 3492 | +# else 3493 | + { 3494 | + PyObject_HEAD_INIT(NULL) 3495 | + NULL, /* m_init */ 3496 | + 0, /* m_index */ 3497 | + NULL, /* m_copy */ 3498 | + }, 3499 | +# endif 3500 | + (char *) SWIG_name, 3501 | + NULL, 3502 | + -1, 3503 | + SwigMethods, 3504 | + NULL, 3505 | + NULL, 3506 | + NULL, 3507 | + NULL 3508 | + }; 3509 | +#endif 3510 | + 3511 | +#if defined(SWIGPYTHON_BUILTIN) 3512 | + static SwigPyClientData SwigPyObject_clientdata = { 3513 | + 0, 0, 0, 0, 0, 0, 0 3514 | + }; 3515 | + static PyGetSetDef this_getset_def = { 3516 | + (char *)"this", &SwigPyBuiltin_ThisClosure, NULL, NULL, NULL 3517 | + }; 3518 | + static SwigPyGetSet thisown_getset_closure = { 3519 | + (PyCFunction) SwigPyObject_own, 3520 | + (PyCFunction) SwigPyObject_own 3521 | + }; 3522 | + static PyGetSetDef thisown_getset_def = { 3523 | + (char *)"thisown", SwigPyBuiltin_GetterClosure, SwigPyBuiltin_SetterClosure, NULL, &thisown_getset_closure 3524 | + }; 3525 | + PyObject *metatype_args; 3526 | + PyTypeObject *builtin_pytype; 3527 | + int builtin_base_count; 3528 | + swig_type_info *builtin_basetype; 3529 | + PyObject *tuple; 3530 | + PyGetSetDescrObject *static_getset; 3531 | + PyTypeObject *metatype; 3532 | + SwigPyClientData *cd; 3533 | + PyObject *public_interface, *public_symbol; 3534 | + PyObject *this_descr; 3535 | + PyObject *thisown_descr; 3536 | + int i; 3537 | + 3538 | + (void)builtin_pytype; 3539 | + (void)builtin_base_count; 3540 | + (void)builtin_basetype; 3541 | + (void)tuple; 3542 | + (void)static_getset; 3543 | + 3544 | + /* metatype is used to implement static member variables. */ 3545 | + metatype_args = Py_BuildValue("(s(O){})", "SwigPyObjectType", &PyType_Type); 3546 | + assert(metatype_args); 3547 | + metatype = (PyTypeObject *) PyType_Type.tp_call((PyObject *) &PyType_Type, metatype_args, NULL); 3548 | + assert(metatype); 3549 | + Py_DECREF(metatype_args); 3550 | + metatype->tp_setattro = (setattrofunc) &SwigPyObjectType_setattro; 3551 | + assert(PyType_Ready(metatype) >= 0); 3552 | +#endif 3553 | 3554 | /* Fix SwigMethods to carry the callback ptrs when needed */ 3555 | SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial); 3556 | 3557 | +#if PY_VERSION_HEX >= 0x03000000 3558 | + m = PyModule_Create(&SWIG_module); 3559 | +#else 3560 | m = Py_InitModule((char *) SWIG_name, SwigMethods); 3561 | - d = PyModule_GetDict(m); 3562 | +#endif 3563 | + md = d = PyModule_GetDict(m); 3564 | + (void)md; 3565 | 3566 | SWIG_InitializeModule(0); 3567 | - SWIG_InstallConstants(d,swig_const_table); 3568 | 3569 | +#ifdef SWIGPYTHON_BUILTIN 3570 | + SwigPyObject_stype = SWIG_MangledTypeQuery("_p_SwigPyObject"); 3571 | + assert(SwigPyObject_stype); 3572 | + cd = (SwigPyClientData*) SwigPyObject_stype->clientdata; 3573 | + if (!cd) { 3574 | + SwigPyObject_stype->clientdata = &SwigPyObject_clientdata; 3575 | + SwigPyObject_clientdata.pytype = SwigPyObject_TypeOnce(); 3576 | + } else if (SwigPyObject_TypeOnce()->tp_basicsize != cd->pytype->tp_basicsize) { 3577 | + PyErr_SetString(PyExc_RuntimeError, "Import error: attempted to load two incompatible swig-generated modules."); 3578 | +# if PY_VERSION_HEX >= 0x03000000 3579 | + return NULL; 3580 | +# else 3581 | + return; 3582 | +# endif 3583 | + } 3584 | + 3585 | + /* All objects have a 'this' attribute */ 3586 | + this_descr = PyDescr_NewGetSet(SwigPyObject_type(), &this_getset_def); 3587 | + (void)this_descr; 3588 | + 3589 | + /* All objects have a 'thisown' attribute */ 3590 | + thisown_descr = PyDescr_NewGetSet(SwigPyObject_type(), &thisown_getset_def); 3591 | + (void)thisown_descr; 3592 | + 3593 | + public_interface = PyList_New(0); 3594 | + public_symbol = 0; 3595 | + (void)public_symbol; 3596 | + 3597 | + PyDict_SetItemString(md, "__all__", public_interface); 3598 | + Py_DECREF(public_interface); 3599 | + for (i = 0; SwigMethods[i].ml_name != NULL; ++i) 3600 | + SwigPyBuiltin_AddPublicSymbol(public_interface, SwigMethods[i].ml_name); 3601 | + for (i = 0; swig_const_table[i].name != 0; ++i) 3602 | + SwigPyBuiltin_AddPublicSymbol(public_interface, swig_const_table[i].name); 3603 | +#endif 3604 | + 3605 | + SWIG_InstallConstants(d,swig_const_table); 3606 | 3607 | SWIG_Python_SetConstant(d, "pcap_doc",SWIG_FromCharPtr("pcap module\n-----------\npcapObject(): Returns a pcapObject instance, with the following methods.\nPlease see the __doc__ attributes of the instance methods of a pcapObject\nfor more information. (there are no method __doc__ attributes in the\nclass). Also please note that at this time, method __doc__ attributes are\nonly functional for python2.\n open_live(device, snaplen, promisc, to_ms)\n open_dead(linktype, snaplen)\n open_offline(filename)\n dump_open(filename)\n setnonblock(nonblock)\n getnonblock()\n setfilter(filter, optimize, netmask)\n loop(count, callback)\n dispatch(count, callback)\n next()\n datalink()\n snapshot()\n is_swapped()\n major_version()\n stats()\n fileno()\n\nPlease see the __doc__ attributes of the following pcap module functions\nfor further information:\n lookupdev()\n lookupnet(device)\n findalldevs()\n aton(addr)\n ntoa(addr)\n")); 3608 | SWIG_Python_SetConstant(d, "pcapObject_open_live_doc",SWIG_FromCharPtr("open_live(device, snaplen, promisc, to_ms)\n\nOpens the interface specificed by \'device\' for packet capture. \'snaplen\'\nis the maximum number of bytes to capture per packet, \'promisc\' indicates\nwhether promiscuous mode should be used, and \'to_ms\' specifies the read\ntimeout in milliseconds.")); 3609 | @@ -4260,5 +4965,10 @@ 3610 | PyModule_AddStringConstant(m, "version", pcap_lib_version()); 3611 | #endif 3612 | 3613 | +#if PY_VERSION_HEX >= 0x03000000 3614 | + return m; 3615 | +#else 3616 | + return; 3617 | +#endif 3618 | } 3619 | 3620 | diff -ru pylibpcap-0.6.4/pcap.i pylibpcap-0.6.4-mac/pcap.i 3621 | --- pylibpcap-0.6.4/pcap.i 2012-01-05 18:43:07.000000000 -0500 3622 | +++ pylibpcap-0.6.4-mac/pcap.i 2014-04-11 19:56:25.000000000 -0400 3623 | @@ -154,6 +154,8 @@ 3624 | DOC(pcapObject_stats,pcapObject_stats_doc) 3625 | int fileno(void); 3626 | DOC(pcapObject_fileno,pcapObject_fileno_doc) 3627 | + int pcap_set_rfmon(char *device, int rfmon); 3628 | + int pcap_activate(); 3629 | } 3630 | } pcapObject; 3631 | 3632 | diff -ru pylibpcap-0.6.4/pcap.py pylibpcap-0.6.4-mac/pcap.py 3633 | --- pylibpcap-0.6.4/pcap.py 2012-01-05 19:13:47.000000000 -0500 3634 | +++ pylibpcap-0.6.4-mac/pcap.py 2014-04-11 20:29:02.000000000 -0400 3635 | @@ -1,12 +1,35 @@ 3636 | # This file was automatically generated by SWIG (http://www.swig.org). 3637 | -# Version 1.3.31 3638 | +# Version 3.0.0 3639 | # 3640 | -# Don't modify this file, modify the SWIG interface instead. 3641 | -# This file is compatible with both classic and new-style classes. 3642 | +# Do not make changes to this file unless you know what you are doing--modify 3643 | +# the SWIG interface file instead. 3644 | + 3645 | + 3646 | 3647 | -import _pcap 3648 | -import new 3649 | -new_instancemethod = new.instancemethod 3650 | + 3651 | + 3652 | +from sys import version_info 3653 | +if version_info >= (2,6,0): 3654 | + def swig_import_helper(): 3655 | + from os.path import dirname 3656 | + import imp 3657 | + fp = None 3658 | + try: 3659 | + fp, pathname, description = imp.find_module('_pcap', [dirname(__file__)]) 3660 | + except ImportError: 3661 | + import _pcap 3662 | + return _pcap 3663 | + if fp is not None: 3664 | + try: 3665 | + _mod = imp.load_module('_pcap', fp, pathname, description) 3666 | + finally: 3667 | + fp.close() 3668 | + return _mod 3669 | + _pcap = swig_import_helper() 3670 | + del swig_import_helper 3671 | +else: 3672 | + import _pcap 3673 | +del version_info 3674 | try: 3675 | _swig_property = property 3676 | except NameError: 3677 | @@ -14,12 +37,12 @@ 3678 | def _swig_setattr_nondynamic(self,class_type,name,value,static=1): 3679 | if (name == "thisown"): return self.this.own(value) 3680 | if (name == "this"): 3681 | - if type(value).__name__ == 'PySwigObject': 3682 | + if type(value).__name__ == 'SwigPyObject': 3683 | self.__dict__[name] = value 3684 | return 3685 | method = class_type.__swig_setmethods__.get(name,None) 3686 | if method: return method(self,value) 3687 | - if (not static) or hasattr(self,name): 3688 | + if (not static): 3689 | self.__dict__[name] = value 3690 | else: 3691 | raise AttributeError("You cannot add attributes to %s" % self) 3692 | @@ -31,23 +54,43 @@ 3693 | if (name == "thisown"): return self.this.own() 3694 | method = class_type.__swig_getmethods__.get(name,None) 3695 | if method: return method(self) 3696 | - raise AttributeError,name 3697 | + raise AttributeError(name) 3698 | 3699 | def _swig_repr(self): 3700 | try: strthis = "proxy of " + self.this.__repr__() 3701 | except: strthis = "" 3702 | return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,) 3703 | 3704 | -import types 3705 | try: 3706 | - _object = types.ObjectType 3707 | + _object = object 3708 | _newclass = 1 3709 | except AttributeError: 3710 | class _object : pass 3711 | _newclass = 0 3712 | -del types 3713 | 3714 | 3715 | +pcap_doc = _pcap.pcap_doc 3716 | +pcapObject_open_live_doc = _pcap.pcapObject_open_live_doc 3717 | +pcapObject_open_dead_doc = _pcap.pcapObject_open_dead_doc 3718 | +pcapObject_open_offline_doc = _pcap.pcapObject_open_offline_doc 3719 | +pcapObject_dump_open_doc = _pcap.pcapObject_dump_open_doc 3720 | +pcapObject_setnonblock_doc = _pcap.pcapObject_setnonblock_doc 3721 | +pcapObject_getnonblock_doc = _pcap.pcapObject_getnonblock_doc 3722 | +pcapObject_setfilter_doc = _pcap.pcapObject_setfilter_doc 3723 | +pcapObject_loop_doc = _pcap.pcapObject_loop_doc 3724 | +pcapObject_dispatch_doc = _pcap.pcapObject_dispatch_doc 3725 | +pcapObject_next_doc = _pcap.pcapObject_next_doc 3726 | +pcapObject_datalink_doc = _pcap.pcapObject_datalink_doc 3727 | +pcapObject_datalinks_doc = _pcap.pcapObject_datalinks_doc 3728 | +pcapObject_snapshot_doc = _pcap.pcapObject_snapshot_doc 3729 | +pcapObject_is_swapped_doc = _pcap.pcapObject_is_swapped_doc 3730 | +pcapObject_major_version_doc = _pcap.pcapObject_major_version_doc 3731 | +pcapObject_minor_version_doc = _pcap.pcapObject_minor_version_doc 3732 | +pcapObject_stats_doc = _pcap.pcapObject_stats_doc 3733 | +pcapObject_fileno_doc = _pcap.pcapObject_fileno_doc 3734 | +lookupdev_doc = _pcap.lookupdev_doc 3735 | +lookupnet_doc = _pcap.lookupnet_doc 3736 | +findalldevs_doc = _pcap.findalldevs_doc 3737 | __doc__ = _pcap.__doc__ 3738 | for dltname, dltvalue in _pcap.DLT.items(): 3739 | globals()[dltname] = dltvalue 3740 | @@ -60,57 +103,55 @@ 3741 | __swig_getmethods__ = {} 3742 | __getattr__ = lambda self, name: _swig_getattr(self, pcapObject, name) 3743 | __repr__ = _swig_repr 3744 | - def __init__(self, *args): 3745 | - import sys 3746 | - if int(sys.version[0])>='2': 3747 | - self.datalink.im_func.__doc__ = _pcap.pcapObject_datalink.__doc__ 3748 | - self.fileno.im_func.__doc__ = _pcap.pcapObject_fileno.__doc__ 3749 | - self.datalinks.im_func.__doc__ = _pcap.pcapObject_datalinks.__doc__ 3750 | - self.major_version.im_func.__doc__ = _pcap.pcapObject_major_version.__doc__ 3751 | - self.minor_version.im_func.__doc__ = _pcap.pcapObject_minor_version.__doc__ 3752 | - self.getnonblock.im_func.__doc__ = _pcap.pcapObject_getnonblock.__doc__ 3753 | - self.open_live.im_func.__doc__ = _pcap.pcapObject_open_live.__doc__ 3754 | - self.dispatch.im_func.__doc__ = _pcap.pcapObject_dispatch.__doc__ 3755 | - self.setnonblock.im_func.__doc__ = _pcap.pcapObject_setnonblock.__doc__ 3756 | - self.stats.im_func.__doc__ = _pcap.pcapObject_stats.__doc__ 3757 | - self.is_swapped.im_func.__doc__ = _pcap.pcapObject_is_swapped.__doc__ 3758 | - self.open_dead.im_func.__doc__ = _pcap.pcapObject_open_dead.__doc__ 3759 | - self.dump_open.im_func.__doc__ = _pcap.pcapObject_dump_open.__doc__ 3760 | - self.next.im_func.__doc__ = _pcap.pcapObject_next.__doc__ 3761 | - self.open_offline.im_func.__doc__ = _pcap.pcapObject_open_offline.__doc__ 3762 | - self.snapshot.im_func.__doc__ = _pcap.pcapObject_snapshot.__doc__ 3763 | - self.loop.im_func.__doc__ = _pcap.pcapObject_loop.__doc__ 3764 | - self.setfilter.im_func.__doc__ = _pcap.pcapObject_setfilter.__doc__ 3765 | - this = _pcap.new_pcapObject(*args) 3766 | + def __init__(self): 3767 | + this = _pcap.new_pcapObject() 3768 | try: self.this.append(this) 3769 | except: self.this = this 3770 | - def open_live(*args): return _pcap.pcapObject_open_live(*args) 3771 | - def open_dead(*args): return _pcap.pcapObject_open_dead(*args) 3772 | - def open_offline(*args): return _pcap.pcapObject_open_offline(*args) 3773 | - def dump_open(*args): return _pcap.pcapObject_dump_open(*args) 3774 | - def setnonblock(*args): return _pcap.pcapObject_setnonblock(*args) 3775 | - def getnonblock(*args): return _pcap.pcapObject_getnonblock(*args) 3776 | - def setfilter(*args): return _pcap.pcapObject_setfilter(*args) 3777 | - def loop(*args): return _pcap.pcapObject_loop(*args) 3778 | - def dispatch(*args): return _pcap.pcapObject_dispatch(*args) 3779 | - def next(*args): return _pcap.pcapObject_next(*args) 3780 | - def datalink(*args): return _pcap.pcapObject_datalink(*args) 3781 | - def datalinks(*args): return _pcap.pcapObject_datalinks(*args) 3782 | - def snapshot(*args): return _pcap.pcapObject_snapshot(*args) 3783 | - def is_swapped(*args): return _pcap.pcapObject_is_swapped(*args) 3784 | - def major_version(*args): return _pcap.pcapObject_major_version(*args) 3785 | - def minor_version(*args): return _pcap.pcapObject_minor_version(*args) 3786 | - def stats(*args): return _pcap.pcapObject_stats(*args) 3787 | - def fileno(*args): return _pcap.pcapObject_fileno(*args) 3788 | __swig_destroy__ = _pcap.delete_pcapObject 3789 | __del__ = lambda self : None; 3790 | + def open_live(self, *args): return _pcap.pcapObject_open_live(self, *args) 3791 | + def open_dead(self, *args): return _pcap.pcapObject_open_dead(self, *args) 3792 | + def open_offline(self, *args): return _pcap.pcapObject_open_offline(self, *args) 3793 | + def dump_open(self, *args): return _pcap.pcapObject_dump_open(self, *args) 3794 | + def setnonblock(self, *args): return _pcap.pcapObject_setnonblock(self, *args) 3795 | + def getnonblock(self): return _pcap.pcapObject_getnonblock(self) 3796 | + def setfilter(self, *args): return _pcap.pcapObject_setfilter(self, *args) 3797 | + def loop(self, *args): return _pcap.pcapObject_loop(self, *args) 3798 | + def dispatch(self, *args): return _pcap.pcapObject_dispatch(self, *args) 3799 | + def next(self): return _pcap.pcapObject_next(self) 3800 | + def datalink(self): return _pcap.pcapObject_datalink(self) 3801 | + def datalinks(self): return _pcap.pcapObject_datalinks(self) 3802 | + def snapshot(self): return _pcap.pcapObject_snapshot(self) 3803 | + def is_swapped(self): return _pcap.pcapObject_is_swapped(self) 3804 | + def major_version(self): return _pcap.pcapObject_major_version(self) 3805 | + def minor_version(self): return _pcap.pcapObject_minor_version(self) 3806 | + def stats(self): return _pcap.pcapObject_stats(self) 3807 | + def fileno(self): return _pcap.pcapObject_fileno(self) 3808 | + def pcap_set_rfmon(self, *args): return _pcap.pcapObject_pcap_set_rfmon(self, *args) 3809 | + def pcap_activate(self): return _pcap.pcapObject_pcap_activate(self) 3810 | pcapObject_swigregister = _pcap.pcapObject_swigregister 3811 | pcapObject_swigregister(pcapObject) 3812 | 3813 | + 3814 | +def lookupdev(): 3815 | + return _pcap.lookupdev() 3816 | lookupdev = _pcap.lookupdev 3817 | + 3818 | +def findalldevs(unpack=1): 3819 | + return _pcap.findalldevs(unpack) 3820 | findalldevs = _pcap.findalldevs 3821 | + 3822 | +def lookupnet(*args): 3823 | + return _pcap.lookupnet(*args) 3824 | lookupnet = _pcap.lookupnet 3825 | + 3826 | +def aton(*args): 3827 | + return _pcap.aton(*args) 3828 | aton = _pcap.aton 3829 | + 3830 | +def ntoa(*args): 3831 | + return _pcap.ntoa(*args) 3832 | ntoa = _pcap.ntoa 3833 | +# This file is compatible with both classic and new-style classes. 3834 | 3835 | 3836 | diff -ru pylibpcap-0.6.4/pcap_interface.c pylibpcap-0.6.4-mac/pcap_interface.c 3837 | --- pylibpcap-0.6.4/pcap_interface.c 2012-01-05 17:14:08.000000000 -0500 3838 | +++ pylibpcap-0.6.4-mac/pcap_interface.c 2014-04-11 19:54:47.000000000 -0400 3839 | @@ -392,6 +392,30 @@ 3840 | return pcap_minor_version(self->pcap); 3841 | } 3842 | 3843 | +int pcapObject_pcap_set_rfmon(pcapObject *self, char *device, int rfmon) 3844 | +{ 3845 | + char ebuf[PCAP_ERRBUF_SIZE]; 3846 | + int status; 3847 | + pcap_t *opened; 3848 | + 3849 | + Py_BEGIN_ALLOW_THREADS 3850 | + opened = pcap_create(device, ebuf); 3851 | + Py_END_ALLOW_THREADS 3852 | + 3853 | + if ( opened != NULL ) 3854 | + status = pcap_set_rfmon(opened, rfmon); 3855 | + 3856 | + if (status == 0) 3857 | + self->pcap = opened; 3858 | + 3859 | + return status; 3860 | +} 3861 | + 3862 | +int pcapObject_pcap_activate(pcapObject *self) 3863 | +{ 3864 | + return pcap_activate(self->pcap); 3865 | +} 3866 | + 3867 | 3868 | PyObject *pcapObject_stats(pcapObject *self) 3869 | { 3870 | -------------------------------------------------------------------------------- /patches/scapy-2.2.0-rfmon-mac.patch: -------------------------------------------------------------------------------- 1 | --- scapy-2.1.0-rfmon/scapy/arch/pcapdnet.py 2009-09-23 10:27:36.000000000 -0400 2 | +++ scapy-2.1.0/scapy/arch/pcapdnet.py 2014-04-11 20:54:49.000000000 -0400 3 | @@ -52,7 +52,14 @@ 4 | class _PcapWrapper_libpcap: 5 | def __init__(self, *args, **kargs): 6 | self.pcap = pcap.pcapObject() 7 | - self.pcap.open_live(*args, **kargs) 8 | + if sys.platform == 'darwin' and 'pcap_set_rfmon' not in dir(self.pcap): 9 | + warning("Mac OS WiFI monitor mode not supported unless python-libpcap patched for OS X is used.") 10 | + 11 | + if sys.platform == 'darwin': 12 | + self.pcap.pcap_set_rfmon(args[0], 1) 13 | + self.pcap.pcap_activate() 14 | + else: 15 | + self.pcap.open_live(*args, **kargs) 16 | def setfilter(self, filter): 17 | self.pcap.setfilter(filter, 0, 0) 18 | def next(self): 19 | @@ -67,6 +74,8 @@ 20 | elif hasattr(pcap,"open_live"): # python-pcapy 21 | class _PcapWrapper_pcapy: 22 | def __init__(self, *args, **kargs): 23 | + if sys.platform == 'darwin': 24 | + warning("Mac OS WiFI monitor mode not supported unless patched python-libpcap is used.") 25 | self.pcap = pcap.open_live(*args, **kargs) 26 | def next(self): 27 | try: --------------------------------------------------------------------------------