Hi, I have attached a very simple c program, that first does a smbc_init and then a smbc_opendir. The problem: smbc_init return an error (No such file or directory) and then i get a segmentation fault. I don't know what possibly could be the problem. Maybe some of you guys have an idea. I think i have libsmbclient from samba 2.2.7(compiled on my own system) and the rest of the samba stuff is the one that comes with mandrake 8.2. Thanks, Razvan Rotaru -------------- next part -------------- /* Unix SMB/Netbios implementation. Version 2.0 SMB client library test program Copyright (C) Andrew Tridgell 1998 Copyright (C) Richard Sharpe 2000 Copyright (C) John Terpsra 2000 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <stdio.h> #include <errno.h> #include <string.h> #include <unistd.h> #include <libsmbclient.h> void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen, char *username, int unmaxlen, char *password, int pwmaxlen) { char temp[128]; fprintf(stdout, "Need password for //%s/%s\n", server, share); fprintf(stdout, "Enter workgroup: [%s] ", workgroup); fgets(temp, sizeof(temp), stdin); if (temp[strlen(temp) - 1] == 0x0a) /* A new line? */ temp[strlen(temp) - 1] = 0x00; if (temp[0]) strncpy(workgroup, temp, wgmaxlen - 1); fprintf(stdout, "Enter username: [%s] ", username); fgets(temp, sizeof(temp), stdin); if (temp[strlen(temp) - 1] == 0x0a) /* A new line? */ temp[strlen(temp) - 1] = 0x00; if (temp[0]) strncpy(username, temp, unmaxlen - 1); fprintf(stdout, "Enter password: [%s] ", password); fgets(temp, sizeof(temp), stdin); if (temp[strlen(temp) - 1] == 0x0a) /* A new line? */ temp[strlen(temp) - 1] = 0x00; if (temp[0]) strncpy(password, temp, pwmaxlen - 1); } int main(int argc, char *argv[]) { int err, fd, dh; //char dirbuf[512]; //char *dirp; struct stat st1, st2; struct smbc_dirent dirp[128]; char path[]="smb://cherban/"; err = smbc_init(auth_fn, 10); if (err < 0) { fprintf(stderr, "Initializing the smbclient library : %s\n", strerror(errno)); } dh=smbc_opendir(path); if (dh <0) { fprintf(stderr, "Could not open directory: %s: %s\n",path,strerror(errno)); exit(1); } /* Now, list those directories, but in funny ways ... */ /* if ((dirc = smbc_getdents(dh1,dirp,sizeof(struct smbc_dirent)*128)) < 0) { fprintf(stderr, "Problems getting directory entries: %s\n", strerror(errno)); exit(1); } */ /* Now, process the list of names ... */ /* fprintf(stdout, "Directory listing, size = %u\n", dirc); while (dirc > 0) { dsize = ((struct smbc_dirent *)dirp)->dirlen; fprintf(stdout, "Dir Ent, Type: %u, Name: %s, Comment: %s\n", ((struct smbc_dirent *)dirp)->smbc_type, ((struct smbc_dirent *)dirp)->name, ((struct smbc_dirent *)dirp)->comment); dirp += dsize; (char *)dirc -= dsize; } */ return 0; }