Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/crypto/external/bsd/netpgp/dist/bindings Add python bindings...



details:   https://anonhg.NetBSD.org/src/rev/5583eafafcca
branches:  trunk
changeset: 749532:5583eafafcca
user:      agc <agc%NetBSD.org@localhost>
date:      Wed Dec 02 00:32:06 2009 +0000

description:
Add python bindings for netpgp, via swig.

When using python, always add the dumb symbolic link to the library name.

diffstat:

 crypto/external/bsd/netpgp/dist/bindings/python/Makefile            |    15 +
 crypto/external/bsd/netpgp/dist/bindings/python/netpgp.h            |    91 +
 crypto/external/bsd/netpgp/dist/bindings/python/netpgp.py           |    15 +
 crypto/external/bsd/netpgp/dist/bindings/python/netpgppython.i      |     7 +
 crypto/external/bsd/netpgp/dist/bindings/python/netpgppython.py     |   112 +
 crypto/external/bsd/netpgp/dist/bindings/python/netpgppython_wrap.c |  4764 ++++++++++
 crypto/external/bsd/netpgp/dist/bindings/python/shlib_version       |     2 +
 crypto/external/bsd/netpgp/dist/bindings/swig/swigit                |     8 +-
 8 files changed, 5013 insertions(+), 1 deletions(-)

diffs (truncated from 5056 to 300 lines):

diff -r b6c40b714e68 -r 5583eafafcca crypto/external/bsd/netpgp/dist/bindings/python/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/crypto/external/bsd/netpgp/dist/bindings/python/Makefile  Wed Dec 02 00:32:06 2009 +0000
@@ -0,0 +1,15 @@
+# $NetBSD: Makefile,v 1.1 2009/12/02 00:32:06 agc Exp $
+# Automatically generated by swigit wrapper script
+
+PREFIX=/usr/pkg
+
+LIB=netpgppython
+SRCS=netpgppython_wrap.c
+WARNS=0
+MKMAN=no
+CPPFLAGS+=-I${PREFIX}/include
+CPPFLAGS+=-I/usr/pkg/include/python2.5
+LDFLAGS+=-L${PREFIX}/lib
+LDADD+=-lnetpgp
+
+.include <bsd.lib.mk>
diff -r b6c40b714e68 -r 5583eafafcca crypto/external/bsd/netpgp/dist/bindings/python/netpgp.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/crypto/external/bsd/netpgp/dist/bindings/python/netpgp.h  Wed Dec 02 00:32:06 2009 +0000
@@ -0,0 +1,91 @@
+/*-
+ * Copyright (c) 2009 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Alistair Crooks (agc%netbsd.org@localhost)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef NETPGP_H_
+#define NETPGP_H_
+
+#ifndef __BEGIN_DECLS
+#  if defined(__cplusplus)
+#  define __BEGIN_DECLS           extern "C" {
+#  define __END_DECLS             }
+#  else
+#  define __BEGIN_DECLS
+#  define __END_DECLS
+#  endif
+#endif
+
+__BEGIN_DECLS
+
+/* structure used to hold (key,value) pair information */
+typedef struct netpgp_t {
+       unsigned          c;            /* # of elements used */
+       unsigned          size;         /* size of array */
+       char            **name;         /* key names */
+       char            **value;        /* value information */
+       void             *pubring;      /* public key ring */
+       void             *secring;      /* s3kr1t key ring */
+       void             *io;           /* the io struct for results/errs */
+       void             *passfp;       /* file pointer for password input */
+} netpgp_t;
+
+/* begin and end */
+int netpgp_init(netpgp_t *);
+int netpgp_end(netpgp_t *);
+
+/* debugging, reflection and information */
+int netpgp_set_debug(const char *);
+int netpgp_get_debug(const char *);
+const char *netpgp_get_info(const char *);
+int netpgp_list_packets(netpgp_t *, char *, int, char *);
+
+/* variables */
+int netpgp_setvar(netpgp_t *, const char *, const char *);
+char *netpgp_getvar(netpgp_t *, const char *);
+
+/* key management */
+int netpgp_list_keys(netpgp_t *);
+int netpgp_list_sigs(netpgp_t *, const char *);
+int netpgp_find_key(netpgp_t *, char *);
+char *netpgp_get_key(netpgp_t *, const char *);
+int netpgp_export_key(netpgp_t *, char *);
+int netpgp_import_key(netpgp_t *, char *);
+int netpgp_generate_key(netpgp_t *, char *, int);
+
+/* file management */
+int netpgp_encrypt_file(netpgp_t *, const char *, const char *, char *, int);
+int netpgp_decrypt_file(netpgp_t *, const char *, char *, int);
+int netpgp_sign_file(netpgp_t *, const char *, const char *, char *, int, int, int);
+int netpgp_verify_file(netpgp_t *, const char *, const char *, int);
+
+/* memory signing */
+int netpgp_sign_memory(netpgp_t *, const char *, char *, size_t, char *, size_t, const unsigned, const unsigned);
+int netpgp_verify_memory(netpgp_t *, const void *, const size_t, const int);
+
+__END_DECLS
+
+#endif /* !NETPGP_H_ */
diff -r b6c40b714e68 -r 5583eafafcca crypto/external/bsd/netpgp/dist/bindings/python/netpgp.py
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/crypto/external/bsd/netpgp/dist/bindings/python/netpgp.py Wed Dec 02 00:32:06 2009 +0000
@@ -0,0 +1,15 @@
+#! /usr/bin/env python2.5
+
+# netpgp bindings for python
+import _netpgppython
+
+# initialisations
+n = _netpgppython.new_netpgp_t()
+_netpgppython.netpgp_setvar(n, "homedir", "/home/agc/.gnupg")
+_netpgppython.netpgp_setvar(n, "hash", "SHA256")
+_netpgppython.netpgp_init(n)
+
+userid = _netpgppython.netpgp_getvar(n, "userid")
+_netpgppython.netpgp_sign_file(n, userid, "a", "a.gpg", 0, 0, 0)
+_netpgppython.netpgp_verify_file(n, "a.gpg", "/dev/null", 0)
+
diff -r b6c40b714e68 -r 5583eafafcca crypto/external/bsd/netpgp/dist/bindings/python/netpgppython.i
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/crypto/external/bsd/netpgp/dist/bindings/python/netpgppython.i    Wed Dec 02 00:32:06 2009 +0000
@@ -0,0 +1,7 @@
+%module netpgppython
+%{
+#include <netpgp.h>
+
+
+%}
+%include netpgp.h
diff -r b6c40b714e68 -r 5583eafafcca crypto/external/bsd/netpgp/dist/bindings/python/netpgppython.py
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/crypto/external/bsd/netpgp/dist/bindings/python/netpgppython.py   Wed Dec 02 00:32:06 2009 +0000
@@ -0,0 +1,112 @@
+# This file was automatically generated by SWIG (http://www.swig.org).
+# Version 1.3.31
+#
+# Don't modify this file, modify the SWIG interface instead.
+# This file is compatible with both classic and new-style classes.
+
+import _netpgppython
+import new
+new_instancemethod = new.instancemethod
+try:
+    _swig_property = property
+except NameError:
+    pass # Python < 2.2 doesn't have 'property'.
+def _swig_setattr_nondynamic(self,class_type,name,value,static=1):
+    if (name == "thisown"): return self.this.own(value)
+    if (name == "this"):
+        if type(value).__name__ == 'PySwigObject':
+            self.__dict__[name] = value
+            return
+    method = class_type.__swig_setmethods__.get(name,None)
+    if method: return method(self,value)
+    if (not static) or hasattr(self,name):
+        self.__dict__[name] = value
+    else:
+        raise AttributeError("You cannot add attributes to %s" % self)
+
+def _swig_setattr(self,class_type,name,value):
+    return _swig_setattr_nondynamic(self,class_type,name,value,0)
+
+def _swig_getattr(self,class_type,name):
+    if (name == "thisown"): return self.this.own()
+    method = class_type.__swig_getmethods__.get(name,None)
+    if method: return method(self)
+    raise AttributeError,name
+
+def _swig_repr(self):
+    try: strthis = "proxy of " + self.this.__repr__()
+    except: strthis = ""
+    return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
+
+import types
+try:
+    _object = types.ObjectType
+    _newclass = 1
+except AttributeError:
+    class _object : pass
+    _newclass = 0
+del types
+
+
+class netpgp_t(_object):
+    __swig_setmethods__ = {}
+    __setattr__ = lambda self, name, value: _swig_setattr(self, netpgp_t, name, value)
+    __swig_getmethods__ = {}
+    __getattr__ = lambda self, name: _swig_getattr(self, netpgp_t, name)
+    __repr__ = _swig_repr
+    __swig_setmethods__["c"] = _netpgppython.netpgp_t_c_set
+    __swig_getmethods__["c"] = _netpgppython.netpgp_t_c_get
+    if _newclass:c = _swig_property(_netpgppython.netpgp_t_c_get, _netpgppython.netpgp_t_c_set)
+    __swig_setmethods__["size"] = _netpgppython.netpgp_t_size_set
+    __swig_getmethods__["size"] = _netpgppython.netpgp_t_size_get
+    if _newclass:size = _swig_property(_netpgppython.netpgp_t_size_get, _netpgppython.netpgp_t_size_set)
+    __swig_setmethods__["name"] = _netpgppython.netpgp_t_name_set
+    __swig_getmethods__["name"] = _netpgppython.netpgp_t_name_get
+    if _newclass:name = _swig_property(_netpgppython.netpgp_t_name_get, _netpgppython.netpgp_t_name_set)
+    __swig_setmethods__["value"] = _netpgppython.netpgp_t_value_set
+    __swig_getmethods__["value"] = _netpgppython.netpgp_t_value_get
+    if _newclass:value = _swig_property(_netpgppython.netpgp_t_value_get, _netpgppython.netpgp_t_value_set)
+    __swig_setmethods__["pubring"] = _netpgppython.netpgp_t_pubring_set
+    __swig_getmethods__["pubring"] = _netpgppython.netpgp_t_pubring_get
+    if _newclass:pubring = _swig_property(_netpgppython.netpgp_t_pubring_get, _netpgppython.netpgp_t_pubring_set)
+    __swig_setmethods__["secring"] = _netpgppython.netpgp_t_secring_set
+    __swig_getmethods__["secring"] = _netpgppython.netpgp_t_secring_get
+    if _newclass:secring = _swig_property(_netpgppython.netpgp_t_secring_get, _netpgppython.netpgp_t_secring_set)
+    __swig_setmethods__["io"] = _netpgppython.netpgp_t_io_set
+    __swig_getmethods__["io"] = _netpgppython.netpgp_t_io_get
+    if _newclass:io = _swig_property(_netpgppython.netpgp_t_io_get, _netpgppython.netpgp_t_io_set)
+    __swig_setmethods__["passfp"] = _netpgppython.netpgp_t_passfp_set
+    __swig_getmethods__["passfp"] = _netpgppython.netpgp_t_passfp_get
+    if _newclass:passfp = _swig_property(_netpgppython.netpgp_t_passfp_get, _netpgppython.netpgp_t_passfp_set)
+    def __init__(self, *args): 
+        this = _netpgppython.new_netpgp_t(*args)
+        try: self.this.append(this)
+        except: self.this = this
+    __swig_destroy__ = _netpgppython.delete_netpgp_t
+    __del__ = lambda self : None;
+netpgp_t_swigregister = _netpgppython.netpgp_t_swigregister
+netpgp_t_swigregister(netpgp_t)
+
+netpgp_init = _netpgppython.netpgp_init
+netpgp_end = _netpgppython.netpgp_end
+netpgp_set_debug = _netpgppython.netpgp_set_debug
+netpgp_get_debug = _netpgppython.netpgp_get_debug
+netpgp_get_info = _netpgppython.netpgp_get_info
+netpgp_list_packets = _netpgppython.netpgp_list_packets
+netpgp_setvar = _netpgppython.netpgp_setvar
+netpgp_getvar = _netpgppython.netpgp_getvar
+netpgp_list_keys = _netpgppython.netpgp_list_keys
+netpgp_list_sigs = _netpgppython.netpgp_list_sigs
+netpgp_find_key = _netpgppython.netpgp_find_key
+netpgp_get_key = _netpgppython.netpgp_get_key
+netpgp_export_key = _netpgppython.netpgp_export_key
+netpgp_import_key = _netpgppython.netpgp_import_key
+netpgp_generate_key = _netpgppython.netpgp_generate_key
+netpgp_encrypt_file = _netpgppython.netpgp_encrypt_file
+netpgp_decrypt_file = _netpgppython.netpgp_decrypt_file
+netpgp_sign_file = _netpgppython.netpgp_sign_file
+netpgp_verify_file = _netpgppython.netpgp_verify_file
+netpgp_sign_memory = _netpgppython.netpgp_sign_memory
+netpgp_verify_memory = _netpgppython.netpgp_verify_memory
+
+
diff -r b6c40b714e68 -r 5583eafafcca crypto/external/bsd/netpgp/dist/bindings/python/netpgppython_wrap.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/crypto/external/bsd/netpgp/dist/bindings/python/netpgppython_wrap.c       Wed Dec 02 00:32:06 2009 +0000
@@ -0,0 +1,4764 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 1.3.31
+ * 
+ * This file is not intended to be easily readable and contains a number of 
+ * coding conventions designed to improve portability and efficiency. Do not make
+ * changes to this file unless you know what you are doing--modify the SWIG 
+ * interface file instead. 
+ * ----------------------------------------------------------------------------- */
+
+#define SWIGPYTHON
+#define SWIG_PYTHON_DIRECTOR_NO_VTABLE
+/* -----------------------------------------------------------------------------
+ *  This section contains generic SWIG labels for method/variable
+ *  declarations/attributes, and other compiler dependent labels.
+ * ----------------------------------------------------------------------------- */
+
+/* template workaround for compilers that cannot correctly implement the C++ standard */
+#ifndef SWIGTEMPLATEDISAMBIGUATOR
+# if defined(__SUNPRO_CC)
+#   if (__SUNPRO_CC <= 0x560)
+#     define SWIGTEMPLATEDISAMBIGUATOR template
+#   else
+#     define SWIGTEMPLATEDISAMBIGUATOR 
+#   endif
+# else
+#   define SWIGTEMPLATEDISAMBIGUATOR 
+# endif
+#endif
+
+/* inline attribute */
+#ifndef SWIGINLINE
+# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
+#   define SWIGINLINE inline
+# else
+#   define SWIGINLINE



Home | Main Index | Thread Index | Old Index