From: Daniel Salzman Date: Fri, 16 Nov 2018 11:45:44 +0000 (+0100) Subject: scripts: remove obsolete scripts X-Git-Tag: v2.8.0~167 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ea4bceb2cebbd71bfa3822708cfb75fa0d6a2428;p=thirdparty%2Fknot-dns.git scripts: remove obsolete scripts --- diff --git a/scripts/cleanup-includes.py b/scripts/cleanup-includes.py deleted file mode 100755 index 640458e9f3..0000000000 --- a/scripts/cleanup-includes.py +++ /dev/null @@ -1,98 +0,0 @@ -#!/usr/bin/python -Es -# vim: et:sw=4:ts=4:sts=4 -# -# Check #includes in source files and: -# - fix includes to be relative to src/ -# - check if is the first include in all .c sources -# - -import os -import re -import sys - -class SourceProcessor(object): - def __init__(self): - self._log_prefix = None - - def process(self, filename, code): - raise NotImplemented() - - def log(self, message): - print >>sys.stderr, "[%s] %s" % (self._log_prefix, message) - -class FixIncludePaths(SourceProcessor): - def __init__(self, src_root, search_paths): - self._log_prefix = "include-paths" - self._src_root = src_root - self._search_paths = search_paths - - def _fix_include(self, filename, include): - current_path = os.path.split(filename)[0] - for search_path in [current_path] + self._search_paths: - new_include = os.path.join(search_path, include) - if os.path.exists(new_include): - new_include = os.path.relpath(new_include, self._src_root) - return new_include - return include - - def process(self, filename, code): - def callback(match): - (prefix, path, suffix) = match.groups() - fixed_path = self._fix_include(filename, path) - return "%s%s%s" % (prefix, fixed_path, suffix) - - fixed_code = re.sub(r'(#\s*include\s+")([^"]+)(")', callback, code) - if code != fixed_code: - self.log("fixed %s" % filename) - - return fixed_code - -class TestConfigH(SourceProcessor): - def __init__(self): - self._log_prefix = "config.h" - - def _check_code(self, code): - first_include = re.search('#\s*include\s+(".+"|<.+>)', code) - return first_include is not None and first_include.group(1) == "" - - def process(self, filename, code): - if not re.search(r'\.h$', filename) and not self._check_code(code): - self.log("config.h is not first include in %s" % filename) - return code - -# ---------------------------------------------------------------------------- - -from subprocess import Popen, PIPE - -def run(command): - p = Popen(command, stdout=PIPE, stderr=PIPE) - (out, errout) = p.communicate() - if p.returncode != 0: - raise Exception("Command %s failed.", command) - return out - -# ---------------------------------------------------------------------------- - -git_root = run(["git", "rev-parse", "--show-toplevel"]).strip() -os.chdir(git_root) - -command = ["git", "ls-files", "src/*.h", "src/*.c", "src/*.y"] -filenames = run(command).splitlines() - -pipeline = [ - FixIncludePaths("src", ["src", "src/libknot"]), - TestConfigH(), -] - -for filename in filenames: - code = open(filename, "r").read() - modified = False - - for processor in pipeline: - new_code = processor.process(filename, code) - if new_code != code: - modified = True - code = new_code - - if modified: - open(filename, "w").write(code) diff --git a/scripts/null-check-free.cocci b/scripts/null-check-free.cocci deleted file mode 100644 index 0aab422434..0000000000 --- a/scripts/null-check-free.cocci +++ /dev/null @@ -1,14 +0,0 @@ -// -// No null check required before calling free() -// - -@@ -expression E; -@@ -( --if (E) { free(E); } -+free(E); -| --if (E != NULL) { free(E); } -+free(E); -) diff --git a/scripts/parse_dump.py b/scripts/parse_dump.py deleted file mode 100755 index 4097fc4339..0000000000 --- a/scripts/parse_dump.py +++ /dev/null @@ -1,145 +0,0 @@ -#!/usr/bin/python -from scapy.all import * -from binascii import * -import base64 -import sys -import dns.rdata -import dns.rrset -from struct import * - -fr = open(sys.argv[1] + ".raw_data", 'wb') -fp = open(sys.argv[1] + ".parsed_data", 'wb') - -def chop_and_write_rr_query(rr): - name = dns.name.from_text(rr.qname) -# print rr.qname - - wire = name.to_wire() - fp.write(pack('B', len(wire))) -# print len(wire) - fp.write(wire) - fp.write(pack('H', rr.qtype)) - fp.write(pack('H', rr.qclass)) - -def chop_and_write_rr_response(rr): - name = dns.name.from_text(rr.rrname) -# print rr.rrname - - wire = name.to_wire() - fp.write(pack('B', len(wire))) - fp.write(wire) - fp.write(pack('H', rr.type)) - fp.write(pack('H', rr.rclass)) - fp.write(pack('L', rr.ttl)) - - try: - rdata = dns.rdata.from_wire(rr.rclass, rr.type, rr.rdata, 0, len(rr.rdata)) - fp.write(pack('H', len(rr.rdata))) -# print "type ", rr.type, "length ", len(rr.rdata) -# OPT has length 0 - it should have no rdata - rdata.to_wire(fp) - except: - - try: -# if rr.rdata[0] != '\#': - rdata = dns.rdata.from_text(rr.rclass, rr.type, rr.rdata) - try: - fp.write(pack('H', len(rdata))) - except: - # no length - no way to know wire length - try: -# print "unknown length for type", rr.type -# if rr.type == 2: -# fp.seek(1, 1) -# old = fp.tell() -# rdata.to_wire(fp) -# size = fp.tell() - old -# fp.seek(-(size + 1), 1) -# fp.write(pack('B', size)) -# fp.seek(0, 2) -# else: - rdata.to_wire(fp) - except Exception as e: - print 'Error, exiting: ', e - sys.exit(-1) - except Exception as e: - print 'Error,', e - print 'could not parse rdata type: ', rr.type - print 'dumping directly (hopefully it is SOA)' -# i need to do some kind of rollback here... - fp.write(pack('H', len(rr.rdata))) - fp.write(rr.rdata) - - - if rr.type == 50: - f = open('nsec3debug', 'wb') - rdata.to_wire(f) - f.close() - -def chop_and_write_section_response(section): - if section == None: - return - i = 0 - rr = section.getlayer(i); - while rr != None: - chop_and_write_rr_response(rr) - i += 1 - rr = section.getlayer(i) - -def chop_and_write_section_query(section): - if section == None: - return - i = 0 - rr = section.getlayer(i); - while rr != None: - chop_and_write_rr_query(rr) - i += 1 - rr = section.getlayer(i) - -def chop_and_write_packet(packet): - fp.write(pack('H', packet.id)) -# fp.write(pack('H', packet.qr)) -# fp.write(pack('H', packet.opcode)) -# fp.write(pack('H', packet.aa)) #TODO these are not uint16_t -# fp.write(pack('H', packet.rcode)) - fp.write(pack('H', packet.qdcount)) - fp.write(pack('H', packet.ancount)) - fp.write(pack('H', packet.nscount)) - fp.write(pack('H', packet.arcount)) - -#write query flag - fp.write(pack('H', packet.qr)) - - chop_and_write_section_query(packet.qd) - chop_and_write_section_response(packet.an) - chop_and_write_section_response(packet.ns) - chop_and_write_section_response(packet.ar) - -packets = rdpcap(sys.argv[1]) - -total_length = len(packets) - -fr.write(pack('L', total_length)) -fp.write(pack('L', total_length)) - -for packet in packets: - try: - data = a2b_hex(str(packet['DNS']).encode('hex')) - fr.write(pack('H', packet.qr)) - fr.write(pack('H', len(data))) - fr.write(data) - chop_and_write_packet(packet['DNS']) - except IndexError: - print 'non-DNS packet' - total_length -= 1 - -fr.seek(0) -fp.seek(0) - -fr.write(pack('L', total_length)) -fp.write(pack('L', total_length)) - -print 'written ', total_length, 'packets' - -fr.close() -fp.close() diff --git a/scripts/pcap2dnsp.py b/scripts/pcap2dnsp.py deleted file mode 100755 index 305f8bbc08..0000000000 --- a/scripts/pcap2dnsp.py +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/python -from scapy.all import * -import sys - -nstypes = { 0:"ANY", 255:"ALL",1:"A", 2:"NS", 3:"MD", 4:"MD", 5:"CNAME", 6:"SOA", 7: "MB", 8:"MG", 9:"MR",10:"NULL",11:"WKS",12:"PTR",13:"HINFO",14:"MINFO",15:"MX",16:"TXT", 17:"RP",18:"AFSDB",28:"AAAA", 33:"SRV",38:"A6",39:"DNAME"} - -a=rdpcap(sys.argv[1]); - -f=open(sys.argv[2], 'w'); - -for i in a: - try: - f.write(i[3].qname+' '+nstypes[i[3].qtype]+'\n') - except: - continue - -f.close() diff --git a/scripts/rrset-deep-free-remove-arg.cocci b/scripts/rrset-deep-free-remove-arg.cocci deleted file mode 100644 index 4a63a51150..0000000000 --- a/scripts/rrset-deep-free-remove-arg.cocci +++ /dev/null @@ -1,15 +0,0 @@ -// -// Remove third argument from knot_rrset_deep_free{,no_sig}() calls -// - -@@ -expression E1, E2, E3; -@@ -( - knot_rrset_deep_free -| - knot_rrset_deep_free_no_sig -) - (E1, E2 -- , E3 - ) diff --git a/scripts/unused-macro.cocci b/scripts/unused-macro.cocci deleted file mode 100644 index 47f0fccc58..0000000000 --- a/scripts/unused-macro.cocci +++ /dev/null @@ -1,11 +0,0 @@ -// -// Use UNUSED(var) macro instead of casting expression to void. -// - -@@ -expression E; -@@ -( --(void)E; -+UNUSED(E); -)