pyunbound work

git-svn-id: file:///svn/unbound/trunk@1572 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
Wouter Wijngaards 2009-04-01 14:34:13 +00:00
parent 7ad28caa41
commit 0b4fe963d5
37 changed files with 39 additions and 5543 deletions

View file

@ -40,6 +40,7 @@ UNBOUND_RUN_DIR=@UNBOUND_RUN_DIR@
CHECKLOCK_SRC=@CHECKLOCK_SRC@ CHECKLOCK_SRC=@CHECKLOCK_SRC@
UB_ON_WINDOWS=@UB_ON_WINDOWS@ UB_ON_WINDOWS=@UB_ON_WINDOWS@
WITH_PYTHONMODULE=@WITH_PYTHONMODULE@ WITH_PYTHONMODULE=@WITH_PYTHONMODULE@
WITH_PYUNBOUND=@WITH_PYUNBOUND@
SWIG=@SWIG@ SWIG=@SWIG@
YACC=@YACC@ YACC=@YACC@
@ -285,6 +286,17 @@ $(srcdir)/pythonmod/pythonmod.c: pythonmod/interface.h
$Q$(SWIG) $(CPPFLAGS) -o $@ -python $< $Q$(SWIG) $(CPPFLAGS) -o $@ -python $<
endif endif
ifeq "$(WITH_PYUNBOUND)" "yes"
libunbound/python/libunbound_wrap.c: $(srcdir)/libunbound/python/libunbound.i $(srcdir)/libunbound/unbound.h
@-if test ! -d $(dir $@); then $(INSTALL) -d $(patsubst %/,%,$(dir $@)); fi
$(INFO) Swig $<
$Q$(SWIG) -python -o $@ $(CPPFLAGS) $<
_unbound.la: $(BUILD)libunbound/python/libunbound_wrap.lo libunbound.la
$(INFO) Link $@
$Q$(LIBTOOL) --tag=CC --mode=link $(strip $(CC) $(RUNTIME_PATH) $(CFLAGS) $(LDFLAGS) -module -no-undefined) -o $@ $< -L. -L.libs -lunbound $(LIBS)
endif
util/config_file.c: util/configparser.h util/config_file.c: util/configparser.h
util/configlexer.c: $(srcdir)/util/configlexer.lex util/configparser.h util/configlexer.c: $(srcdir)/util/configlexer.lex util/configparser.h
$(INFO) Lex $< $(INFO) Lex $<

View file

@ -12,4 +12,3 @@ distribution but may be helpful.
* unbound_cacti.tar.gz : setup files for cacti statistics report * unbound_cacti.tar.gz : setup files for cacti statistics report
* selinux: the .fc and .te files for SElinux protection of the unbound daemon * selinux: the .fc and .te files for SElinux protection of the unbound daemon
* unbound.plist: launchd configuration file for MacOSX. * unbound.plist: launchd configuration file for MacOSX.
* python: use libunbound from python.

File diff suppressed because it is too large Load diff

View file

@ -4,6 +4,8 @@
Still tries to do so, could work when deployed in intranet. Still tries to do so, could work when deployed in intranet.
Higher verbosity shows the error. Higher verbosity shows the error.
- new libunbound calls documented. - new libunbound calls documented.
- pyunbound in libunbound/python. Removed compile warnings.
Makefile to make it.
30 March 2009: Wouter 30 March 2009: Wouter
- Fixup LDFLAGS from libevent sourcedir compile configure restore. - Fixup LDFLAGS from libevent sourcedir compile configure restore.

View file

@ -314,7 +314,7 @@ Convert error value from one of the unbound library functions
to a human readable string. to a human readable string.
.TP .TP
.B ub_ctx_print_local_zones .B ub_ctx_print_local_zones
Debug printout the local authority information to stdout. Debug printout the local authority information to debug output.
.TP .TP
.B ub_ctx_zone_add .B ub_ctx_zone_add
Add new zone to local authority info, like local\-zone \fIunbound.conf\fR(5) Add new zone to local authority info, like local\-zone \fIunbound.conf\fR(5)

View file

@ -63,6 +63,7 @@
/* result generation */ /* result generation */
%typemap(argout,noblock=1) (struct ub_result** result) %typemap(argout,noblock=1) (struct ub_result** result)
{ {
if(1) { /* new code block for variable on stack */
PyObject* tuple; PyObject* tuple;
tuple = PyTuple_New(2); tuple = PyTuple_New(2);
PyTuple_SetItem(tuple, 0, $result); PyTuple_SetItem(tuple, 0, $result);
@ -73,6 +74,7 @@
} }
$result = tuple; $result = tuple;
} }
}
// ================================================================================ // ================================================================================
@ -751,7 +753,8 @@ Result: ['74.125.43.147', '74.125.43.99', '74.125.43.103', '74.125.43.104']
PyObject* _ub_result_data(struct ub_result* result) { PyObject* _ub_result_data(struct ub_result* result) {
PyObject *list; PyObject *list;
int i,j,cnt; int i,cnt;
(void)self;
if ((result == 0) || (!result->havedata) || (result->data == 0)) if ((result == 0) || (!result->havedata) || (result->data == 0))
return Py_None; return Py_None;
@ -843,12 +846,14 @@ int ub_ctx_debugout(struct ub_ctx* ctx, FILE* out);
/* result generation */ /* result generation */
%typemap(argout,noblock=1) (int* async_id) %typemap(argout,noblock=1) (int* async_id)
{ {
if(1) { /* new code block for variable on stack */
PyObject* tuple; PyObject* tuple;
tuple = PyTuple_New(2); tuple = PyTuple_New(2);
PyTuple_SetItem(tuple, 0, $result); PyTuple_SetItem(tuple, 0, $result);
PyTuple_SetItem(tuple, 1, SWIG_From_int(asyncid)); PyTuple_SetItem(tuple, 1, SWIG_From_int(asyncid));
$result = tuple; $result = tuple;
} }
}
// Grab a Python function object as a Python object. // Grab a Python function object as a Python object.
%typemap(in) (PyObject *pyfunc) { %typemap(in) (PyObject *pyfunc) {
@ -871,7 +876,7 @@ int _ub_resolve_async(struct ub_ctx* ctx, char* name, int rrtype, int rrclass, v
static void PythonCallBack(void* iddata, int status, struct ub_result* result) static void PythonCallBack(void* iddata, int status, struct ub_result* result)
{ {
PyObject *func, *arglist; PyObject *arglist;
PyObject *fresult; PyObject *fresult;
struct cb_data* id; struct cb_data* id;
id = (struct cb_data*) iddata; id = (struct cb_data*) iddata;
@ -887,15 +892,16 @@ int _ub_resolve_async(struct ub_ctx* ctx, char* name, int rrtype, int rrclass, v
} }
int _ub_resolve_async(struct ub_ctx* ctx, char* name, int rrtype, int rrclass, PyObject* mydata, PyObject *pyfunc, int* async_id) { int _ub_resolve_async(struct ub_ctx* ctx, char* name, int rrtype, int rrclass, PyObject* mydata, PyObject *pyfunc, int* async_id) {
int r;
struct cb_data* id; struct cb_data* id;
id = (struct cb_data*) malloc(sizeof(struct cb_data)); id = (struct cb_data*) malloc(sizeof(struct cb_data));
id->data = mydata; id->data = mydata;
id->func = pyfunc; id->func = pyfunc;
int i = ub_resolve_async(ctx,name,rrtype,rrclass, (void *) id, PythonCallBack, async_id); r = ub_resolve_async(ctx,name,rrtype,rrclass, (void *) id, PythonCallBack, async_id);
Py_INCREF(mydata); Py_INCREF(mydata);
Py_INCREF(pyfunc); Py_INCREF(pyfunc);
return i; return r;
} }
%} %}

View file

@ -471,7 +471,7 @@ void ub_resolve_free(struct ub_result* result);
const char* ub_strerror(int err); const char* ub_strerror(int err);
/** /**
* Debug routine. Print the local zone information to stdout. * Debug routine. Print the local zone information to debug output.
* @param ctx: context. Is finalized by the routine. * @param ctx: context. Is finalized by the routine.
* @return 0 if OK, else error. * @return 0 if OK, else error.
*/ */