Discussion:
Trying to write a test program using libsmbclient.
Ray Van Dolson
2003-12-02 09:09:06 UTC
Permalink
I'm trying to write a test program using libsmbclient and the simplest
things aren't working quite the way it seems they should.

#include <libsmbclient.h>
#include <stdio.h>

int main() {
printf("%d\n",smbc_open("smb://TULCATE/Mp3"));
}

% gcc -o bob test.c -lsmbclient
% ./bob
-1
%

It returns -1 for any URI I throw in there. These URI's work fine when
used with smbclient directly, so I think I may be doing something wrong.
Do I need to call smbc_init() first?

Ray Van Dolson
Stephen Boyer
2003-12-02 09:09:06 UTC
Permalink
Roy,
Yes, you have to call smbc_init() first in order to initialize the library
and indicate the call back function. You also need a .smb/smb.conf
file in your HOME directory with nothing more than the following:

[global]
workgroup = WORKGROUP

In the HEAD /samba/testsuite/libsmbclient/src are examples/testprograms
that exercise all of the available libsmbclient APIs.
Date: Tue, 1 May 2001 08:03:59 -0700 (PDT)
Subject: Trying to write a test program using libsmbclient.
I'm trying to write a test program using libsmbclient and the simplest
things aren't working quite the way it seems they should.
#include <libsmbclient.h>
#include <stdio.h>
int main() {
printf("%d\n",smbc_open("smb://TULCATE/Mp3"));
}
% gcc -o bob test.c -lsmbclient
% ./bob
-1
%
It returns -1 for any URI I throw in there. These URI's work fine when
used with smbclient directly, so I think I may be doing something wrong.
Do I need to call smbc_init() first?
Ray Van Dolson
Ray Van Dolson
2003-12-02 09:09:06 UTC
Permalink
Thanks for the response. I'm having some troubles with segfaults using
the sources in the testsuite directory.

I created the .smb directory and the smb.conf as specified and compiled
for example telldir_4.c and called it as follows:

./a.out WORKGROUP username password smb://COMPUTER/Directory

I get a segmentation fault. Simply using a URI in the form of //COMPUTER
returns a -1 for the directory handle and an error of "9". I ran gdb over
the executable and it appears that it is segfaulting when smbc_opendir()
is called. I'm assuming the smb:// form of the URI is the proper one, yet
it seems to barf out on me when this is called.

smbclient on the other hand works fine, so it seems my Samba compile is
working fine. Any ideas?

Ray Van Dolson
Post by Stephen Boyer
Roy,
Yes, you have to call smbc_init() first in order to initialize the library
and indicate the call back function. You also need a .smb/smb.conf
[global]
workgroup = WORKGROUP
In the HEAD /samba/testsuite/libsmbclient/src are examples/testprograms
that exercise all of the available libsmbclient APIs.
Date: Tue, 1 May 2001 08:03:59 -0700 (PDT)
Subject: Trying to write a test program using libsmbclient.
I'm trying to write a test program using libsmbclient and the simplest
things aren't working quite the way it seems they should.
#include <libsmbclient.h>
#include <stdio.h>
int main() {
printf("%d\n",smbc_open("smb://TULCATE/Mp3"));
}
% gcc -o bob test.c -lsmbclient
% ./bob
-1
%
It returns -1 for any URI I throw in there. These URI's work fine when
used with smbclient directly, so I think I may be doing something wrong.
Do I need to call smbc_init() first?
Ray Van Dolson
Richard Sharpe
2003-12-02 09:09:07 UTC
Permalink
Post by Ray Van Dolson
I'm trying to write a test program using libsmbclient and the simplest
things aren't working quite the way it seems they should.
#include <libsmbclient.h>
#include <stdio.h>
int main() {
You need to do an smbc_init before hand ... check out the testsmbc program
or the tree.c program (both in the client directory ...)
Post by Ray Van Dolson
printf("%d\n",smbc_open("smb://TULCATE/Mp3"));
}
% gcc -o bob test.c -lsmbclient
% ./bob
-1
%
It returns -1 for any URI I throw in there. These URI's work fine when
used with smbclient directly, so I think I may be doing something wrong.
Do I need to call smbc_init() first?
Ray Van Dolson
Regards
-------
Richard Sharpe, ***@ns.aus.com
Samba (Team member, www.samba.org), Ethereal (Team member, www.ethereal.com)
Contributing author, SAMS Teach Yourself Samba in 24 Hours
Author, Special Edition, Using Samba

Loading...