svn commit: samba r15391 - in branches/SAMBA_4_0/source: libcli libcli/swig scripting/swig

tpot at samba.org tpot at samba.org
Tue May 2 10:59:31 GMT 2006


Author: tpot
Date: 2006-05-02 10:59:31 +0000 (Tue, 02 May 2006)
New Revision: 15391

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=15391

Log:
Wrap up the nbt_name_query() function as a bit of an experiment.  It 
seemed to work quite well and this technique might be good for 
generating an interface to use for automated testing.

Tested by doing a nbt lookup against smbd.

Added:
   branches/SAMBA_4_0/source/libcli/swig/
   branches/SAMBA_4_0/source/libcli/swig/libcli_nbt.i
Modified:
   branches/SAMBA_4_0/source/libcli/config.mk
   branches/SAMBA_4_0/source/scripting/swig/config.mk


Changeset:
Modified: branches/SAMBA_4_0/source/libcli/config.mk
===================================================================
--- branches/SAMBA_4_0/source/libcli/config.mk	2006-05-02 10:46:03 UTC (rev 15390)
+++ branches/SAMBA_4_0/source/libcli/config.mk	2006-05-02 10:59:31 UTC (rev 15391)
@@ -56,6 +56,11 @@
 PUBLIC_DEPENDENCIES = LIBNDR NDR_NBT LIBCLI_COMPOSITE LIBEVENTS \
 	NDR_SECURITY samba-socket
 
+[LIBRARY::swig_libcli_nbt]
+LIBRARY_REALNAME = swig/_libcli_nbt.$(SHLIBEXT)
+OBJ_FILES = swig/libcli_nbt_wrap.o
+PUBLIC_DEPENDENCIES = LIBCLI_NBT DYNCONFIG LIBSAMBA-CONFIG
+
 [SUBSYSTEM::LIBCLI_DGRAM]
 OBJ_FILES = \
 	dgram/dgramsocket.o \


Property changes on: branches/SAMBA_4_0/source/libcli/swig
___________________________________________________________________
Name: svn:ignore
   + _*.so
*.pyc
libcli_nbt.py
libcli_nbt_wrap.c


Added: branches/SAMBA_4_0/source/libcli/swig/libcli_nbt.i
===================================================================
--- branches/SAMBA_4_0/source/libcli/swig/libcli_nbt.i	2006-05-02 10:46:03 UTC (rev 15390)
+++ branches/SAMBA_4_0/source/libcli/swig/libcli_nbt.i	2006-05-02 10:59:31 UTC (rev 15391)
@@ -0,0 +1,136 @@
+/* 
+   Unix SMB/CIFS implementation.
+
+   Swig interface to libcli_nbt library.
+
+   Copyright (C) 2006 Tim Potter <tpot at samba.org>
+
+     ** NOTE! The following LGPL license applies to the tdb
+     ** library. This does NOT imply that all of Samba is released
+     ** under the LGPL
+   
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2 of the License, or (at your option) any later version.
+
+   This library 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
+
+%module libcli_nbt
+
+%{
+
+#include "includes.h"
+#include "lib/talloc/talloc.h"
+#include "lib/events/events.h"
+#include "libcli/nbt/libnbt.h"
+
+/* Undo strcpy safety macro as it's used by swig )-: */
+
+#undef strcpy
+
+%}
+
+%apply bool { BOOL };
+%apply int { uint8_t };
+%apply int { int8_t };
+%apply unsigned int { uint16_t };
+%apply int { int16_t };
+
+%typemap(in) uint32_t {
+	if (PyLong_Check($input))
+		$1 = PyLong_AsUnsignedLong($input);
+	else if (PyInt_Check($input))
+		$1 = PyInt_AsLong($input);
+	else {
+		PyErr_SetString(PyExc_TypeError,"Expected a long or an int");
+		return NULL;
+	}
+}
+
+%typemap(out) uint32_t {
+	$result = PyLong_FromUnsignedLong($1);
+}
+
+%apply unsigned long long { uint64_t };
+%apply long long { int64_t };
+
+%typemap(in) NTSTATUS {
+        if (PyLong_Check($input))
+                $1 = NT_STATUS(PyLong_AsUnsignedLong($input));
+        else if (PyInt_Check($input))
+                $1 = NT_STATUS(PyInt_AsLong($input));
+        else {
+                PyErr_SetString(PyExc_TypeError, "Expected a long or an int");
+                return NULL;
+        }
+}
+
+%typemap(out) NTSTATUS {
+        $result = PyLong_FromUnsignedLong(NT_STATUS_V($1));
+}
+
+TALLOC_CTX *talloc_init(char *name);
+int talloc_free(TALLOC_CTX *ptr);
+
+/* Function prototypes */
+
+struct event_context *event_context_init(TALLOC_CTX *mem_ctx);
+
+struct nbt_name_socket *nbt_name_socket_init(TALLOC_CTX *mem_ctx, 
+					     struct event_context *event_ctx);
+
+enum nbt_name_type {
+	NBT_NAME_CLIENT=0x00,
+	NBT_NAME_MS=0x01,
+	NBT_NAME_USER=0x03,
+	NBT_NAME_SERVER=0x20,
+	NBT_NAME_PDC=0x1B,
+	NBT_NAME_LOGON=0x1C,
+	NBT_NAME_MASTER=0x1D,
+	NBT_NAME_BROWSER=0x1E
+};
+
+struct nbt_name {
+	const char *name;
+	const char *scope;
+	enum nbt_name_type type;
+};
+
+%rename(data_in) in;
+%rename(data_out) out;
+
+struct nbt_name_query {
+	struct {
+		struct nbt_name name;
+		const char *dest_addr;
+		BOOL broadcast;
+		BOOL wins_lookup;
+		int timeout; /* in seconds */
+		int retries;
+	} in;
+	struct {
+		const char *reply_from;
+		struct nbt_name name;
+		int16_t num_addrs;
+		const char **reply_addrs;
+	} out;
+};
+
+%include "carrays.i"
+%array_functions(char *, char_ptr_array);
+
+%rename(do_nbt_name_query) nbt_name_query;
+
+NTSTATUS nbt_name_query(struct nbt_name_socket *nbtsock, 
+			TALLOC_CTX *mem_ctx, struct nbt_name_query *io);
+
+void lp_load(void);

Modified: branches/SAMBA_4_0/source/scripting/swig/config.mk
===================================================================
--- branches/SAMBA_4_0/source/scripting/swig/config.mk	2006-05-02 10:46:03 UTC (rev 15390)
+++ branches/SAMBA_4_0/source/scripting/swig/config.mk	2006-05-02 10:59:31 UTC (rev 15391)
@@ -8,7 +8,8 @@
 #######################
 
 # Swig extensions
-swig: lib/tdb/swig/_tdb.$(SHLIBEXT) lib/ldb/swig/_ldb.$(SHLIBEXT)
+swig: lib/tdb/swig/_tdb.$(SHLIBEXT) lib/ldb/swig/_ldb.$(SHLIBEXT) \
+	libcli/swig/_libcli_nbt.$(SHLIBEXT)
 
 .SUFFIXES: _wrap.c .i
 



More information about the samba-cvs mailing list