Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sqlmapproject
GitHub Repository: sqlmapproject/sqlmap
Path: blob/master/lib/core/readlineng.py
2989 views
1
#!/usr/bin/env python
2
3
"""
4
Copyright (c) 2006-2025 sqlmap developers (https://sqlmap.org)
5
See the file 'LICENSE' for copying permission
6
"""
7
8
_readline = None
9
try:
10
from readline import *
11
import readline as _readline
12
except:
13
try:
14
from pyreadline import *
15
import pyreadline as _readline
16
except:
17
pass
18
19
from lib.core.data import logger
20
from lib.core.settings import IS_WIN
21
from lib.core.settings import PLATFORM
22
23
if IS_WIN and _readline:
24
try:
25
_outputfile = _readline.GetOutputFile()
26
except AttributeError:
27
debugMsg = "Failed GetOutputFile when using platform's "
28
debugMsg += "readline library"
29
logger.debug(debugMsg)
30
31
_readline = None
32
33
# Test to see if libedit is being used instead of GNU readline.
34
# Thanks to Boyd Waters for this patch.
35
uses_libedit = False
36
37
if PLATFORM == "mac" and _readline:
38
import commands
39
40
(status, result) = commands.getstatusoutput("otool -L %s | grep libedit" % _readline.__file__)
41
42
if status == 0 and len(result) > 0:
43
# We are bound to libedit - new in Leopard
44
_readline.parse_and_bind("bind ^I rl_complete")
45
46
debugMsg = "Leopard libedit detected when using platform's "
47
debugMsg += "readline library"
48
logger.debug(debugMsg)
49
50
uses_libedit = True
51
52
# the clear_history() function was only introduced in Python 2.4 and is
53
# actually optional in the readline API, so we must explicitly check for its
54
# existence. Some known platforms actually don't have it. This thread:
55
# http://mail.python.org/pipermail/python-dev/2003-August/037845.html
56
# has the original discussion.
57
if _readline:
58
if not hasattr(_readline, "clear_history"):
59
def clear_history():
60
pass
61
62
_readline.clear_history = clear_history
63
64