diff options
| author | Valery Febvre <vfebvre at easter-eggs.com> | 2004-07-09 00:02:16 +0000 |
|---|---|---|
| committer | Valery Febvre <vfebvre at easter-eggs.com> | 2004-07-09 00:02:16 +0000 |
| commit | 628f94861cb2601988ea3495afed972a2b3830cf (patch) | |
| tree | 5b6b3f80272dd0183c47b9bdf0365a1dabae0c98 /python | |
| parent | a1d16b708c749d039bb7c620899f716002781228 (diff) | |
| download | lasso-628f94861cb2601988ea3495afed972a2b3830cf.tar.gz lasso-628f94861cb2601988ea3495afed972a2b3830cf.tar.xz lasso-628f94861cb2601988ea3495afed972a2b3830cf.zip | |
Initial commit
Diffstat (limited to 'python')
| -rw-r--r-- | python/environs/py_server.c | 83 | ||||
| -rw-r--r-- | python/environs/py_server.h | 42 |
2 files changed, 125 insertions, 0 deletions
diff --git a/python/environs/py_server.c b/python/environs/py_server.c new file mode 100644 index 00000000..c1df5dee --- /dev/null +++ b/python/environs/py_server.c @@ -0,0 +1,83 @@ +/* $Id$ + * + * PyLasso -- Python bindings for Lasso library + * + * Copyright (C) 2004 Entr'ouvert + * http://lasso.labs.libre-entreprise.org + * + * Authors: Valery Febvre <vfebvre@easter-eggs.com> + * Nicolas Clapies <nclapies@entrouvert.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "../../lassomod.h" + +#include "py_server.h" + +PyObject *LassoServer_wrap(LassoServer *server) { + PyObject *ret; + + if (server == NULL) { + Py_INCREF(Py_None); + return (Py_None); + } + ret = PyCObject_FromVoidPtrAndDesc((void *) server, + (char *) "LassoServer *", NULL); + return (ret); +} + +/******************************************************************************/ + +PyObject *server_new(PyObject *self, PyObject *args) { + gchar *metadata; + gchar *public_key = NULL; + gchar *private_key = NULL; + gchar *certificate = NULL; + guint signature_method = 0; + + if (CheckArgs(args, "Ssssi:server_new")) { + if(!PyArg_ParseTuple(args, (char *) "szzz|i:server_new", + &metadata, &public_key, &private_key, &certificate, + &signature_method)) + return NULL; + } + else return NULL; + + server = lasso_server_new(metadata, public_key, private_key, + certificate, signature_method); + + return (LassoServer_wrap(LASSO_SERVER(server))); +} + +PyObject *server_add_provider(PyObject *self, PyObject *args) { + PyObject *server_obj; + gchar *metadata; + gchar *public_key = NULL; + gchar *certificat = NULL; + + if (CheckArgs(args, "OSss:server_add_provider")) { + if(!PyArg_ParseTuple(args, (char *) "Oszz:server_add_provider", + &server_obj, &metadata, &public_key, &certificat)) + return NULL; + } + else return NULL; + + lasso_server_add_provider(LassoServer_get(server_obj), + metadata, public_key, certificat); + + Py_INCREF(Py_None); + return (Py_None); +} diff --git a/python/environs/py_server.h b/python/environs/py_server.h new file mode 100644 index 00000000..9c05001f --- /dev/null +++ b/python/environs/py_server.h @@ -0,0 +1,42 @@ +/* $Id$ + * + * PyLasso -- Python bindings for Lasso library + * + * Copyright (C) 2004 Entr'ouvert + * http://lasso.labs.libre-entreprise.org + * + * Authors: Valery Febvre <vfebvre@easter-eggs.com> + * Nicolas Clapies <nclapies@entrouvert.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __PYLASSO_PY_SERVER_H__ +#define __PYLASSO_PY_SERVER_H__ + +#include <lasso/environs/server.h> + +typedef struct { + PyObject_HEAD + LassoServer *obj; +} LassoServer_object; + +#define LassoServer_get(v) (((v) == Py_None) ? NULL : (((LassoServer_object *)(PyObject_GetAttr(v, PyString_FromString("_o"))))->obj)) +PyObject *LassoServer_wrap(LassoServer *server); + +PyObject *server_new(PyObject *self, PyObject *args); +PyObject *server_add_provider(PyObject *self, PyObject *args); + +#endif /* __PYLASSO_PY_SERVER_H__ */ |
