aboutsummaryrefslogtreecommitdiff
path: root/buildtools
diff options
context:
space:
mode:
Diffstat (limited to 'buildtools')
-rw-r--r--buildtools/defstack.py88
-rw-r--r--buildtools/make-relaxng.py4
-rw-r--r--buildtools/make-sql-schemas.py2
-rw-r--r--buildtools/pylint.rc14
4 files changed, 104 insertions, 4 deletions
diff --git a/buildtools/defstack.py b/buildtools/defstack.py
new file mode 100644
index 00000000..4d93ce66
--- /dev/null
+++ b/buildtools/defstack.py
@@ -0,0 +1,88 @@
+# $Id$
+#
+# Tool to write search C source code for "DECLARE_STACK_OF" macro
+# calls and write corresponding type-safe "safestack" macros.
+#
+# You might want to look away now, this is nasty. Then again, OpenSSL
+# does the same thing, but in Perl, and mixing automatically generated
+# code with code maintained by humans, so "nasty" is a relative term.
+#
+# Copyright (C) 2011-2012 Internet Systems Consortium ("ISC")
+#
+# Permission to use, copy, modify, and distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+# PERFORMANCE OF THIS SOFTWARE.
+
+import fileinput
+import sys
+import re
+
+header = '''\
+/*
+ * Automatically generated, do not edit.
+ * Generator $Id$
+ */
+
+#ifndef __%__DEFSTACK_H__
+#define __%__DEFSTACK_H__
+'''
+
+footer = '''
+#endif /* __%__DEFSTACK_H__ */
+'''
+
+template = '''
+/*
+ * Safestack macros for %.
+ */
+#define sk_%_new(st) SKM_sk_new(%, (st))
+#define sk_%_new_null() SKM_sk_new_null(%)
+#define sk_%_free(st) SKM_sk_free(%, (st))
+#define sk_%_num(st) SKM_sk_num(%, (st))
+#define sk_%_value(st, i) SKM_sk_value(%, (st), (i))
+#define sk_%_set(st, i, val) SKM_sk_set(%, (st), (i), (val))
+#define sk_%_zero(st) SKM_sk_zero(%, (st))
+#define sk_%_push(st, val) SKM_sk_push(%, (st), (val))
+#define sk_%_unshift(st, val) SKM_sk_unshift(%, (st), (val))
+#define sk_%_find(st, val) SKM_sk_find(%, (st), (val))
+#define sk_%_find_ex(st, val) SKM_sk_find_ex(%, (st), (val))
+#define sk_%_delete(st, i) SKM_sk_delete(%, (st), (i))
+#define sk_%_delete_ptr(st, ptr) SKM_sk_delete_ptr(%, (st), (ptr))
+#define sk_%_insert(st, val, i) SKM_sk_insert(%, (st), (val), (i))
+#define sk_%_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(%, (st), (cmp))
+#define sk_%_dup(st) SKM_sk_dup(%, st)
+#define sk_%_pop_free(st, free_func) SKM_sk_pop_free(%, (st), (free_func))
+#define sk_%_shift(st) SKM_sk_shift(%, (st))
+#define sk_%_pop(st) SKM_sk_pop(%, (st))
+#define sk_%_sort(st) SKM_sk_sort(%, (st))
+#define sk_%_is_sorted(st) SKM_sk_is_sorted(%, (st))
+'''
+
+if len(sys.argv) < 2:
+ sys.exit("Usage: %s source.c [source.c ...]" % sys.argv[0])
+
+splitter = re.compile("[() \t]+").split
+
+token = None
+
+for line in fileinput.input():
+
+ if token is None:
+ token = "".join(c if c.isalnum() else "_" for c in fileinput.filename().upper())
+ sys.stdout.write(header.replace("%", token))
+
+ if "DECLARE_STACK_OF" in line:
+ words = splitter(line)
+ if len(words) > 1 and words[0] == "DECLARE_STACK_OF":
+ sys.stdout.write(template.replace("%", words[1]))
+
+if token is not None:
+ sys.stdout.write(footer.replace("%", token))
diff --git a/buildtools/make-relaxng.py b/buildtools/make-relaxng.py
index 0058ade5..d35f56bc 100644
--- a/buildtools/make-relaxng.py
+++ b/buildtools/make-relaxng.py
@@ -3,7 +3,7 @@ Script to generate rpki/relaxng.py.
$Id$
-Copyright (C) 2009-2011 Internet Systems Consortium ("ISC")
+Copyright (C) 2009-2012 Internet Systems Consortium ("ISC")
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
@@ -43,7 +43,7 @@ import lxml.etree
format_2 = """\
## @var %(name)s
## Parsed RelaxNG %(name)s schema
-%(name)s = lxml.etree.RelaxNG(lxml.etree.fromstring('''%(rng)s'''))
+%(name)s = lxml.etree.RelaxNG(lxml.etree.fromstring(r'''%(rng)s'''))
"""
def filename_to_symbol(s):
diff --git a/buildtools/make-sql-schemas.py b/buildtools/make-sql-schemas.py
index 3ecde014..8175bbf5 100644
--- a/buildtools/make-sql-schemas.py
+++ b/buildtools/make-sql-schemas.py
@@ -3,7 +3,7 @@ Script to generate rpki/relaxng.py.
$Id$
-Copyright (C) 2009-2011 Internet Systems Consortium ("ISC")
+Copyright (C) 2009-2012 Internet Systems Consortium ("ISC")
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
diff --git a/buildtools/pylint.rc b/buildtools/pylint.rc
index 5e555f45..872345fb 100644
--- a/buildtools/pylint.rc
+++ b/buildtools/pylint.rc
@@ -4,6 +4,18 @@
# differs enough from mine that it's not really usable without
# customization. Useful options: --help, --generate-rcfile.
+# Note that, in addition to disabling unhelpful messages globally, one
+# can disable specific messages for an entire module or for a specific
+# known issue, using magic comments in the Python source code. Form
+# of the comment is the same in either case, how much it controls
+# depends on the scope in which one places the comment. Format:
+#
+# # pylint: disable=code,code,...
+#
+# At top level in a module (eg, right before first import), it
+# disables for a module. Within blocks (eg, as a comment on the line
+# defining formal parameters to a function) it only in that scope.
+
[MASTER]
profile=no
@@ -32,7 +44,7 @@ disable-msg-cat=
#enable-msg=
# Disable the message(s) with the given id(s).
-disable-msg=R0801,R0903,R0913,C0321,R0904,W0201,E1101,W0614,C0301,R0901,C0302,R0902,R0201,W0613,R0912,R0915,W0703,W0212,R0914,W0603
+disable=R0801,R0903,R0913,C0321,R0904,W0201,E1101,W0614,C0301,R0901,C0302,R0902,R0201,W0613,R0912,R0915,W0703,W0212,R0914,W0603,W0142,I0011,C0111,C0103,R0401
[REPORTS]