Dear Ladies and Gentlemen,
I am writing to invite your comments about this futile effort to wrap a
function in the samba 2.0.9 libsmbwrapper.so shared library.
Although the XS compiles and links, one of the members of the struct
initialised by the function isn't visible (n->name should be "ipa01").
#include "perl.h"
#include "XSUB.h"
#include "/home/anwsmh/build/samba-2.0.9/source/include/includes.h"
typedef struct nmb_name Nmb;
# void make_nmb_name( struct nmb_name *n, const char *name, int type )
# {
# extern pstring global_scope;
# memset( (char *)n, '\0', sizeof(struct nmb_name) );
# StrnCpy( n->name, name, 15 );
# strupper( n->name );
# n->name_type = (unsigned int)type & 0xFF;
# StrnCpy( n->scope, global_scope, 63 );
# strupper( n->scope );
# }
MODULE = Nmb PACKAGE = Nmb
Nmb *
make_nmb_name(name, type)
char * name
int type
PREINIT:
Nmb * new_nmb;
CODE:
Newz(0, new_nmb, 1, Nmb);
make_nmb_name(new_nmb, name, type);
printf("name: %s\n", new_nmb->name);
printf("name_type: %#2.2x\n", new_nmb->name_type);
RETVAL = new_nmb;
OUTPUT:
RETVAL
MODULE = Nmb PACKAGE = NmbPtr
void
display_nmb_name(n)
Nmb * n
CODE:
/*
struct nmb_name {
char name[17];
char scope[64];
unsigned int name_type;
};
*/
printf("name: %s\n", n->name);
char *
display_nmb_type(n)
Nmb * n
CODE:
printf("name_type: %#2.2x\n", n->name_type);
tsitc> make
/usr/bin/perl -I/usr/libdata/perl/5.00503/mach
-I/usr/libdata/perl/5.00503 /usr/libdata/perl/5.00503/ExtUtils/xsubpp
-typemap /usr/libdata/perl/5.00503/ExtUtils/typemap -typemap typemap
Nmb.xs >xstmp.c && mv xstmp.c Nmb.c
Please specify prototyping behavior for Nmb.xs (see perlxs manual)
cc -c -I/home/anwsmh/build/samba-2.0.9/source/include
-I/usr/home/anwsmh/build/samba-2.0.9/source/ubiqx
-I/usr/home/anwsmh/build/samba-2.0.9/source/smbwrapper
-DVERSION=\"0.01\" -DXS_VERSION=\"0.01\" -DPIC -fpic
-I/usr/libdata/perl/5.00503/mach/CORE Nmb.c
In file included from
/home/anwsmh/build/samba-2.0.9/source/include/includes.h:652,
from Nmb.xs:5:
/home/anwsmh/build/samba-2.0.9/source/include/version.h:1: warning: `VERSION'
redefined
*Initialization*:1: warning: this is the location of the previous
definition
In file included from
/home/anwsmh/build/samba-2.0.9/source/include/includes.h:653,
from Nmb.xs:5:
/home/anwsmh/build/samba-2.0.9/source/include/smb.h:137: warning: `DEBUG'
redefined
/usr/libdata/perl/5.00503/mach/CORE/perl.h:1483: warning: this is the
location of the previous definition
In file included from
/home/anwsmh/build/samba-2.0.9/source/include/includes.h:375,
from Nmb.xs:5:
/usr/include/rpcsvc/yp_prot.h:71: warning: useless keyword or type name
in empty declaration
/usr/include/rpcsvc/yp_prot.h:71: warning: empty declaration
cc -o blib/arch/auto/Nmb/Nmb.so -Wl,-E -shared -lperl -lm Nmb.o
-L/usr/local/lib -lsmbwrapper
chmod 755 blib/arch/auto/Nmb/Nmb.so
tsitc> perl -Mblib -MNmb -e '$x = make_nmb_name("ipa01",
0x20); $x->display_nmb_name, "\n"'
Using /usr/home/anwsmh/perl/net/XS/hack/Nmb/blib
name:
name_type: 0x20
name:
tsitc>
The function is called like this from C,
struct cli_state *do_connect(char *server, char *share)
{
struct nmb_name called, calling;
char *server_n;
...
make_nmb_name(&calling, server, 0x20);
Thank you,
Yours sincerely.
--
------------------------------------------------------------------------
Stanley Hopcroft
------------------------------------------------------------------------
'...No man is an island, entire of itself; every man is a piece of the
continent, a part of the main. If a clod be washed away by the sea,
Europe is the less, as well as if a promontory were, as well as if a
manor of thy friend's or of thine own were. Any man's death diminishes
me, because I am involved in mankind; and therefore never send to know
for whom the bell tolls; it tolls for thee...'
from Meditation 17, J Donne.