Enlightenment CVS committal Author : lordchaos Project : e17 Module : apps/evfs
Dir : e17/apps/evfs/src/plugins Modified Files: Makefile.am evfs_fs_samba.c Log Message: Directory listing for SAMBA plugin =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/evfs/src/plugins/Makefile.am,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- Makefile.am 8 Oct 2005 15:39:51 -0000 1.3 +++ Makefile.am 9 Oct 2005 07:42:17 -0000 1.4 @@ -26,5 +26,5 @@ posix_la_LIBADD = @ecore_libs@ samba_la_CFLAGS = @ecore_cflags@ -samba_la_LDFLAGS = -no-undefined -module -avoid-version +samba_la_LDFLAGS = -no-undefined -module -avoid-version -lsmbclient samba_la_LIBADD = @ecore_libs@ =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/evfs/src/plugins/evfs_fs_samba.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- evfs_fs_samba.c 8 Oct 2005 15:39:51 -0000 1.1 +++ evfs_fs_samba.c 9 Oct 2005 07:42:17 -0000 1.2 @@ -38,15 +38,63 @@ #include <errno.h> #include <dirent.h> #include <Ecore_File.h> +#include <libsmbclient.h> +void evfs_dir_list(evfs_client* client, evfs_command* command); + + + +/*---------------------------------------------------------------------------*/ +/*A temporary function until we build authentication into the protocol*/ +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); + +} +/*------------------------------------------------------------------------*/ evfs_plugin_functions* evfs_plugin_init() { + int err; + printf("Initialising the samba plugin..\n"); evfs_plugin_functions* functions = calloc(1, sizeof(evfs_plugin_functions)); + + + //Initialize samba + err = smbc_init(auth_fn, 2); + functions->evfs_dir_list = &evfs_dir_list; /*functions->evfs_file_remove= &evfs_file_remove; functions->evfs_monitor_start = &evfs_monitor_start; functions->evfs_monitor_stop = &evfs_monitor_stop; @@ -59,3 +107,54 @@ char* evfs_plugin_uri_get() { return "smb"; } + +void evfs_dir_list(evfs_client* client, evfs_command* command) { + char dir[1024]; + + int fd, dh1, dh2, dh3, dsize, dirc; + int size; + char dirbuf[4096]; + char* dirp; + Ecore_List* files = ecore_list_new(); + + //Reappend smb protocol header for libsmbclient.. + snprintf(dir,1024,"smb:/%s", command->file_command.files[0]->path); + + printf("evfs_fs_samba: Listing directory %s\n", dir); + + + dh1 = smbc_opendir(dir); + dirp = (char*)dirbuf; + dirc = smbc_getdents(dh1, (struct smbc_dirent *)dirp, sizeof(dirbuf)); + + while (dirc > 0) { + evfs_filereference* reference = NEW(evfs_filereference); + + 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); + + if (((struct smbc_dirent *)dirp)->smbc_type == 7) reference->file_type = FILE_NORMAL; + else if (((struct smbc_dirent *)dirp)->smbc_type == 7) reference->file_type = FILE_DIRECTORY; + + size = + (sizeof(char) * strlen(command->file_command.files[0]->path)) + + (sizeof(char) * strlen(((struct smbc_dirent *)dirp)->name )) + + (sizeof(char) * 2 ); + reference->path = malloc(size); + snprintf(reference->path, size, "%s/%s", command->file_command.files[0]->path, ((struct smbc_dirent *)dirp)->name ); + + + + ecore_list_append(files, reference); + + dirp += dsize; + dirc -= dsize; + + } + + evfs_list_dir_event_create(client, command, files); + +} ------------------------------------------------------- This SF.Net email is sponsored by: Power Architecture Resource Center: Free content, downloads, discussions, and more. http://solutions.newsforge.com/ibmarch.tmpl _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs