diff options
author | lloyd <[email protected]> | 2006-06-03 05:55:51 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2006-06-03 05:55:51 +0000 |
commit | 5d0c13a8bf3da41581101b8fe7805367163f5b0f (patch) | |
tree | 50db10d103b37d108750f4cf8c8aba16d2df6293 /doc/python | |
parent | 82d6935b37eebc95196fb8e2c5228f6839c92232 (diff) |
Move Boost.Python wrapper from doc/ to misc/
Diffstat (limited to 'doc/python')
-rw-r--r-- | doc/python/Makefile | 36 | ||||
-rw-r--r-- | doc/python/botan/__init__.py | 9 | ||||
-rwxr-xr-x | doc/python/mkdeps.py | 35 | ||||
-rw-r--r-- | doc/python/src/base.cpp | 31 | ||||
-rw-r--r-- | doc/python/src/core.cpp | 20 | ||||
-rw-r--r-- | doc/python/src/filter.cpp | 71 | ||||
-rw-r--r-- | doc/python/src/pipe.cpp | 24 | ||||
-rw-r--r-- | doc/python/src/x509.cpp | 15 | ||||
-rwxr-xr-x | doc/python/test.py | 19 |
9 files changed, 0 insertions, 260 deletions
diff --git a/doc/python/Makefile b/doc/python/Makefile deleted file mode 100644 index dec00a632..000000000 --- a/doc/python/Makefile +++ /dev/null @@ -1,36 +0,0 @@ -CXX = g++ -LANG_FLAGS = -fPIC -Wall -W -ftemplate-depth-255 -OPT_FLAGS = -g -Os - -PYTHON_ROOT = /usr/lib/python2.3/config -PYTHON_INC = -I/usr/include/python2.3 -PYTHON_DEF = -DBOOST_PYTHON_DYNAMIC_LIB -DBOOST_PYTHON_SOURCE -BOOST_ROOT = /usr/local/src/boost - -WRAPPER_CFLAGS = $(shell botan-config --cflags) -SHARED_CFLAGS = $(LANG_FLAGS) $(OPT_FLAGS) $(PYTHON_INC) - -BOOST_CFLAGS = $(PYTHON_DEF) $(SHARED_CFLAGS) - -WRAP_SRC = $(wildcard src/*) -WRAP_OBJS = $(patsubst src/%.cpp,build/botan/%.o,$(WRAP_SRC)) - -all: botan/_botan.so - -include boost.deps - -build/libboost_python.so: $(BOOST_OBJS) - $(CXX) -fPIC -shared -o $@ $(BOOST_DEF) -L$(PYTHON_ROOT) $(PYTHON_INC) -Wl,-soname,libboost_python.so $^ - -build/botan/%.o: src/%.cpp - $(CXX) $(SHARED_CFLAGS) $(WRAPPER_CFLAGS) -c $< -o $@ - -botan/_botan.so: $(WRAP_OBJS) build/libboost_python.so - $(CXX) -shared -o $@ $(shell botan-config --libs) -L$(PYTHON_ROOT) $(WRAP_OBJS) -Lbuild/ -lboost_python -Wl,-rpath-link,. -Wl,-soname,$@ - -dirs: - mkdir -p build build/boost build/botan botan - -clean: - rm -rf build/ - rm -f botan/*.so botan/*.pyc diff --git a/doc/python/botan/__init__.py b/doc/python/botan/__init__.py deleted file mode 100644 index e6bd5266a..000000000 --- a/doc/python/botan/__init__.py +++ /dev/null @@ -1,9 +0,0 @@ -from _botan import * - -init = LibraryInitializer() - -def Filter(name): - return make_filter(name) - -#def Filter(name, key): -# return make_filter(name, key) diff --git a/doc/python/mkdeps.py b/doc/python/mkdeps.py deleted file mode 100755 index 64eafb9dc..000000000 --- a/doc/python/mkdeps.py +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/python - -import os, re, sys - -def boost_dir(): - return "/usr/local/src/boost/libs/python/src" - -def get_listing_of(dir): - list = []; - for root, dirs, files in os.walk(dir): - list = list + [os.path.join(root, name) for name in files] - list.sort() - return list - -def produce_output(list): - def obj_name(source): - return re.sub(r"^/.*/(.+).cpp$", r"build/boost/\1.o", source) - - def obj_deps(sources): - def obj_dep(source): - return obj_name(source) + ": " + source + "\n\t$(CXX) $(BOOST_CFLAGS) -c $< -o $@\n" - return map(obj_dep, sources); - - def file_lists(list): - def file_list(list, macro, trans): - return 'BOOST_' + macro + ' = ' + ' '.join(map(trans, list)) + "\n\n" - return file_list(list, 'SRC', None) + file_list(list, 'OBJS', obj_name) - - return file_lists(list) + "\n".join(obj_deps(list)) - -def main(): - print produce_output(get_listing_of(boost_dir())) - -if __name__ == "__main__": - sys.exit(main()) diff --git a/doc/python/src/base.cpp b/doc/python/src/base.cpp deleted file mode 100644 index 33457fe61..000000000 --- a/doc/python/src/base.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/************************************************* -* Wrappers for basic Botan types * -* (C) 2005-2006 Jack Lloyd <[email protected]> * -*************************************************/ - -#include <boost/python.hpp> -using namespace boost::python; - -#include <botan/init.h> -#include <botan/symkey.h> -using namespace Botan; - -void export_basic_types() - { - class_<LibraryInitializer>("LibraryInitializer") - .def(init< optional<std::string> >()); - - class_<OctetString>("OctetString") - .def(init< optional<std::string> >()) - .def("as_string", &OctetString::as_string) - .def("length", &OctetString::length) - .def(self ^= self); - - class_<SymmetricKey, bases<OctetString> >("SymmetricKey") - .def(init< optional<std::string> >()) - .def(init< u32bit >()); - - class_<InitializationVector, bases<OctetString> >("InitializationVector") - .def(init< optional<std::string> >()) - .def(init< u32bit >()); - } diff --git a/doc/python/src/core.cpp b/doc/python/src/core.cpp deleted file mode 100644 index 6c8f61c1c..000000000 --- a/doc/python/src/core.cpp +++ /dev/null @@ -1,20 +0,0 @@ -/************************************************* -* Boost.Python module definition * -* (C) 2005-2006 Jack Lloyd <[email protected]> * -*************************************************/ - -#include <boost/python.hpp> -using namespace boost::python; - -extern void export_basic_types(); -extern void export_filters(); -extern void export_pipe(); -extern void export_x509(); - -BOOST_PYTHON_MODULE(_botan) - { - export_basic_types(); - export_filters(); - export_pipe(); - export_x509(); - } diff --git a/doc/python/src/filter.cpp b/doc/python/src/filter.cpp deleted file mode 100644 index 10497f851..000000000 --- a/doc/python/src/filter.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/************************************************* -* Wrappers for Botan Filters * -* (C) 2005-2006 Jack Lloyd <[email protected]> * -*************************************************/ - -#include <boost/python.hpp> -using namespace boost::python; - -#include <botan/pipe.h> -#include <botan/lookup.h> -using namespace Botan; - -class Python_Filter : public Fanout_Filter, public wrapper<Fanout_Filter> - { - public: - virtual void write(const byte in[], u32bit len) - { - this->get_override("write")(in, len); - } - virtual void start_msg() - { - if(override start_msg = this->get_override("start_msg")) - start_msg(); - Filter::start_msg(); - } - virtual void end_msg() - { - if(override end_msg = this->get_override("end_msg")) - end_msg(); - Filter::end_msg(); - } - - Python_Filter(Filter* f) - { - if(f) { attach(f); incr_owns(); } - } - }; - -Python_Filter* make_filter1(const std::string& name) - { - printf("Trying to make filter of type %s\n", name.c_str()); - - if(have_hash(name)) - return new Python_Filter(new Hash_Filter(name)); - if(name == "Hex_Encoder") - return new Python_Filter(new Hex_Encoder); - - return 0; - } - -// FIXME: add new wrapper for Keyed_Filter here -Python_Filter* make_filter2(const std::string& name, - const SymmetricKey& key) - { - printf("Trying to make a filter of type %s (key %s)\n", name.c_str(), - key.as_string().c_str()); - return 0; - } - -void export_filters() - { - class_<Python_Filter, boost::noncopyable>("Filter", no_init) - .def("write", &Filter::write) - .def("start_msg", &Filter::start_msg) - .def("end_msg", &Filter::end_msg); - - def("make_filter", make_filter1, - return_value_policy<manage_new_object>()); - def("make_filter", make_filter2, - return_value_policy<manage_new_object>()); - } diff --git a/doc/python/src/pipe.cpp b/doc/python/src/pipe.cpp deleted file mode 100644 index e586b087f..000000000 --- a/doc/python/src/pipe.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/************************************************* -* Pipe wrapper using Boost.Python * -* (C) 2005-2006 Jack Lloyd <[email protected]> * -*************************************************/ - -#include <boost/python.hpp> -using namespace boost::python; - -#include <botan/pipe.h> -using namespace Botan; - -void export_pipe() - { - void (Pipe::*pipe_write1)(const std::string&) = &Pipe::write; - void (Pipe::*pipe_write2)(const byte[], u32bit) = &Pipe::write; - - class_<Pipe, boost::noncopyable>("Pipe") - .def(init< Python_Filter*, optional<Python_Filter*> >()) - .def("start_msg", &Pipe::start_msg) - .def("end_msg", &Pipe::end_msg) - .def("write", pipe_write1) - .def("write", pipe_write2) - .def("read_all", &Pipe::read_all_as_string); - } diff --git a/doc/python/src/x509.cpp b/doc/python/src/x509.cpp deleted file mode 100644 index dc462f48b..000000000 --- a/doc/python/src/x509.cpp +++ /dev/null @@ -1,15 +0,0 @@ -/************************************************* -* Wrappers for X.509 types * -* (C) 2005-2006 Jack Lloyd <[email protected]> * -*************************************************/ - -#include <boost/python.hpp> -using namespace boost::python; - -#include <botan/x509_key.h> - -void export_x509() - { - class_<X509_PublicKey>("x509_key", no_init) - .def( - } diff --git a/doc/python/test.py b/doc/python/test.py deleted file mode 100755 index c73cc9369..000000000 --- a/doc/python/test.py +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/python - -import sys, botan - -def do_hash(input): - pipe = botan.Pipe(botan.Filter("MD5"), botan.Filter("Hex_Encoder")) - - print pipe - pipe.start_msg() - pipe.write(input) - pipe.end_msg() - - return pipe.read_all() - -def main(): - print do_hash("foo") - -if __name__ == "__main__": - sys.exit(main()) |