annotate src/smb/smb.c @ 3148:d443c917dab9

Remove stale library variable from Makefile, as pointed out by RafaŠČ MuŤ÷yŠČo on #audacious.
author Tony Vroon <chainsaw@gentoo.org>
date Mon, 11 May 2009 17:32:04 +0100
parents 3134a0987162
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
845
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
1 /* Audacious
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
2 * Copyright (c) 2007 Daniel Bradshaw
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
3 *
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
4 * This program is free software; you can redistribute it and/or modify
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
5 * it under the terms of the GNU General Public License as published by
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
7 * (at your option) any later version.
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
8 *
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
9 * This program is distributed in the hope that it will be useful,
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
12 * GNU General Public License for more details.
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
13 *
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
14 * You should have received a copy of the GNU General Public License
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
15 * along with this program; if not, write to the Free Software
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
17 */
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
18
1961
e8ea3a76a84e Various #include cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1954
diff changeset
19 #include "config.h"
2971
3134a0987162 - changed include path from audacious to audlegacy.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1978
diff changeset
20 #include <audlegacy/plugin.h>
845
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
21 #include <stdio.h>
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
22
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
23 #include <unistd.h>
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
24 #include <sys/stat.h>
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
25 #include <sys/types.h>
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
26
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
27 #include <libsmbclient.h>
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
28
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
29 static void smb_auth_fn(const char *srv,
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
30 const char *shr,
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
31 char *wg, int wglen,
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
32 char *un, int unlen,
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
33 char *pw, int pwlen)
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
34 {
846
76983ca8178a [svn] - Adjust indenting cause the previous indenting was painful
nazca
parents: 845
diff changeset
35 /* Does absolutely nothing :P */
845
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
36 }
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
37
871
f51f658b8e9c [svn] - make this work, i think.
nenolod
parents: 846
diff changeset
38 typedef struct _SMBFile {
845
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
39 int fd;
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
40 long length;
871
f51f658b8e9c [svn] - make this work, i think.
nenolod
parents: 846
diff changeset
41 } SMBFile;
845
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
42
871
f51f658b8e9c [svn] - make this work, i think.
nenolod
parents: 846
diff changeset
43 /* TODO: make writing work. */
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
44 VFSFile *smb_aud_vfs_fopen_impl(const gchar * path, const gchar * mode)
845
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
45 {
846
76983ca8178a [svn] - Adjust indenting cause the previous indenting was painful
nazca
parents: 845
diff changeset
46 VFSFile *file;
871
f51f658b8e9c [svn] - make this work, i think.
nenolod
parents: 846
diff changeset
47 SMBFile *handle;
846
76983ca8178a [svn] - Adjust indenting cause the previous indenting was painful
nazca
parents: 845
diff changeset
48 struct stat st;
845
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
49
846
76983ca8178a [svn] - Adjust indenting cause the previous indenting was painful
nazca
parents: 845
diff changeset
50 if (!path || !mode)
76983ca8178a [svn] - Adjust indenting cause the previous indenting was painful
nazca
parents: 845
diff changeset
51 return NULL;
845
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
52
846
76983ca8178a [svn] - Adjust indenting cause the previous indenting was painful
nazca
parents: 845
diff changeset
53 file = g_new0(VFSFile, 1);
871
f51f658b8e9c [svn] - make this work, i think.
nenolod
parents: 846
diff changeset
54 handle = g_new0(SMBFile, 1);
846
76983ca8178a [svn] - Adjust indenting cause the previous indenting was painful
nazca
parents: 845
diff changeset
55 handle->fd = smbc_open(path, O_RDONLY, 0);
845
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
56
871
f51f658b8e9c [svn] - make this work, i think.
nenolod
parents: 846
diff changeset
57 if (handle->fd < 0) {
846
76983ca8178a [svn] - Adjust indenting cause the previous indenting was painful
nazca
parents: 845
diff changeset
58 g_free(file);
76983ca8178a [svn] - Adjust indenting cause the previous indenting was painful
nazca
parents: 845
diff changeset
59 file = NULL;
76983ca8178a [svn] - Adjust indenting cause the previous indenting was painful
nazca
parents: 845
diff changeset
60 } else {
76983ca8178a [svn] - Adjust indenting cause the previous indenting was painful
nazca
parents: 845
diff changeset
61 smbc_stat(path,&st);
76983ca8178a [svn] - Adjust indenting cause the previous indenting was painful
nazca
parents: 845
diff changeset
62 handle->length = st.st_size;
76983ca8178a [svn] - Adjust indenting cause the previous indenting was painful
nazca
parents: 845
diff changeset
63 file->handle = (void *)handle;
76983ca8178a [svn] - Adjust indenting cause the previous indenting was painful
nazca
parents: 845
diff changeset
64 }
845
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
65
846
76983ca8178a [svn] - Adjust indenting cause the previous indenting was painful
nazca
parents: 845
diff changeset
66 return file;
845
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
67 }
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
68
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
69 gint smb_aud_vfs_fclose_impl(VFSFile * file)
845
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
70 {
846
76983ca8178a [svn] - Adjust indenting cause the previous indenting was painful
nazca
parents: 845
diff changeset
71 gint ret = 0;
871
f51f658b8e9c [svn] - make this work, i think.
nenolod
parents: 846
diff changeset
72 SMBFile *handle;
845
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
73
846
76983ca8178a [svn] - Adjust indenting cause the previous indenting was painful
nazca
parents: 845
diff changeset
74 if (file == NULL)
76983ca8178a [svn] - Adjust indenting cause the previous indenting was painful
nazca
parents: 845
diff changeset
75 return -1;
76983ca8178a [svn] - Adjust indenting cause the previous indenting was painful
nazca
parents: 845
diff changeset
76
76983ca8178a [svn] - Adjust indenting cause the previous indenting was painful
nazca
parents: 845
diff changeset
77 if (file->handle)
76983ca8178a [svn] - Adjust indenting cause the previous indenting was painful
nazca
parents: 845
diff changeset
78 {
871
f51f658b8e9c [svn] - make this work, i think.
nenolod
parents: 846
diff changeset
79 handle = (SMBFile *)file->handle;
846
76983ca8178a [svn] - Adjust indenting cause the previous indenting was painful
nazca
parents: 845
diff changeset
80 if (smbc_close(handle->fd) != 0)
76983ca8178a [svn] - Adjust indenting cause the previous indenting was painful
nazca
parents: 845
diff changeset
81 ret = -1;
76983ca8178a [svn] - Adjust indenting cause the previous indenting was painful
nazca
parents: 845
diff changeset
82 g_free(file->handle);
76983ca8178a [svn] - Adjust indenting cause the previous indenting was painful
nazca
parents: 845
diff changeset
83 }
845
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
84
846
76983ca8178a [svn] - Adjust indenting cause the previous indenting was painful
nazca
parents: 845
diff changeset
85 return ret;
845
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
86 }
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
87
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
88 size_t smb_aud_vfs_fread_impl(gpointer ptr, size_t size, size_t nmemb, VFSFile * file)
845
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
89 {
871
f51f658b8e9c [svn] - make this work, i think.
nenolod
parents: 846
diff changeset
90 SMBFile *handle;
846
76983ca8178a [svn] - Adjust indenting cause the previous indenting was painful
nazca
parents: 845
diff changeset
91 if (file == NULL)
76983ca8178a [svn] - Adjust indenting cause the previous indenting was painful
nazca
parents: 845
diff changeset
92 return 0;
871
f51f658b8e9c [svn] - make this work, i think.
nenolod
parents: 846
diff changeset
93 handle = (SMBFile *)file->handle;
846
76983ca8178a [svn] - Adjust indenting cause the previous indenting was painful
nazca
parents: 845
diff changeset
94 return smbc_read(handle->fd, ptr, size * nmemb);
845
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
95 }
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
96
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
97 size_t smb_aud_vfs_fwrite_impl(gconstpointer ptr, size_t size, size_t nmemb, VFSFile * file)
845
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
98 {
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
99 return 0;
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
100 }
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
101
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
102 gint smb_aud_vfs_getc_impl(VFSFile *file)
845
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
103 {
871
f51f658b8e9c [svn] - make this work, i think.
nenolod
parents: 846
diff changeset
104 SMBFile *handle;
f51f658b8e9c [svn] - make this work, i think.
nenolod
parents: 846
diff changeset
105 char temp;
f51f658b8e9c [svn] - make this work, i think.
nenolod
parents: 846
diff changeset
106 handle = (SMBFile *)file->handle;
846
76983ca8178a [svn] - Adjust indenting cause the previous indenting was painful
nazca
parents: 845
diff changeset
107 smbc_read(handle->fd, &temp, 1);
871
f51f658b8e9c [svn] - make this work, i think.
nenolod
parents: 846
diff changeset
108 return (gint) temp;
845
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
109 }
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
110
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
111 gint smb_aud_vfs_fseek_impl(VFSFile * file, glong offset, gint whence)
845
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
112 {
871
f51f658b8e9c [svn] - make this work, i think.
nenolod
parents: 846
diff changeset
113 SMBFile *handle;
846
76983ca8178a [svn] - Adjust indenting cause the previous indenting was painful
nazca
parents: 845
diff changeset
114 glong roffset = offset;
76983ca8178a [svn] - Adjust indenting cause the previous indenting was painful
nazca
parents: 845
diff changeset
115 gint ret = 0;
845
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
116 if (file == NULL)
846
76983ca8178a [svn] - Adjust indenting cause the previous indenting was painful
nazca
parents: 845
diff changeset
117 return 0;
845
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
118
871
f51f658b8e9c [svn] - make this work, i think.
nenolod
parents: 846
diff changeset
119 handle = (SMBFile *)file->handle;
845
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
120
846
76983ca8178a [svn] - Adjust indenting cause the previous indenting was painful
nazca
parents: 845
diff changeset
121 if (whence == SEEK_END)
76983ca8178a [svn] - Adjust indenting cause the previous indenting was painful
nazca
parents: 845
diff changeset
122 {
76983ca8178a [svn] - Adjust indenting cause the previous indenting was painful
nazca
parents: 845
diff changeset
123 roffset = handle->length + offset;
76983ca8178a [svn] - Adjust indenting cause the previous indenting was painful
nazca
parents: 845
diff changeset
124 if (roffset < 0)
76983ca8178a [svn] - Adjust indenting cause the previous indenting was painful
nazca
parents: 845
diff changeset
125 roffset = 0;
76983ca8178a [svn] - Adjust indenting cause the previous indenting was painful
nazca
parents: 845
diff changeset
126
76983ca8178a [svn] - Adjust indenting cause the previous indenting was painful
nazca
parents: 845
diff changeset
127 ret = smbc_lseek(handle->fd, roffset, SEEK_SET);
76983ca8178a [svn] - Adjust indenting cause the previous indenting was painful
nazca
parents: 845
diff changeset
128 //printf("%ld -> %ld = %d\n",offset, roffset, ret);
76983ca8178a [svn] - Adjust indenting cause the previous indenting was painful
nazca
parents: 845
diff changeset
129 }
76983ca8178a [svn] - Adjust indenting cause the previous indenting was painful
nazca
parents: 845
diff changeset
130 else
76983ca8178a [svn] - Adjust indenting cause the previous indenting was painful
nazca
parents: 845
diff changeset
131 {
76983ca8178a [svn] - Adjust indenting cause the previous indenting was painful
nazca
parents: 845
diff changeset
132 if (roffset < 0)
76983ca8178a [svn] - Adjust indenting cause the previous indenting was painful
nazca
parents: 845
diff changeset
133 roffset = 0;
76983ca8178a [svn] - Adjust indenting cause the previous indenting was painful
nazca
parents: 845
diff changeset
134 ret = smbc_lseek(handle->fd, roffset, whence);
76983ca8178a [svn] - Adjust indenting cause the previous indenting was painful
nazca
parents: 845
diff changeset
135 //printf("%ld %d = %d\n",roffset, whence, ret);
76983ca8178a [svn] - Adjust indenting cause the previous indenting was painful
nazca
parents: 845
diff changeset
136 }
845
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
137
846
76983ca8178a [svn] - Adjust indenting cause the previous indenting was painful
nazca
parents: 845
diff changeset
138 return ret;
845
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
139 }
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
140
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
141 gint smb_aud_vfs_ungetc_impl(gint c, VFSFile *file)
845
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
142 {
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
143 smb_aud_vfs_fseek_impl(file, -1, SEEK_CUR);
845
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
144 return c;
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
145 }
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
146
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
147 void smb_aud_vfs_rewind_impl(VFSFile * file)
845
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
148 {
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
149 smb_aud_vfs_fseek_impl(file, 0, SEEK_SET);
845
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
150 }
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
151
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
152 glong
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
153 smb_aud_vfs_ftell_impl(VFSFile * file)
845
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
154 {
871
f51f658b8e9c [svn] - make this work, i think.
nenolod
parents: 846
diff changeset
155 SMBFile *handle;
f51f658b8e9c [svn] - make this work, i think.
nenolod
parents: 846
diff changeset
156 handle = (SMBFile *)file->handle;
846
76983ca8178a [svn] - Adjust indenting cause the previous indenting was painful
nazca
parents: 845
diff changeset
157 return smbc_lseek(handle->fd, 0, SEEK_CUR);
845
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
158 }
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
159
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
160 gboolean
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
161 smb_aud_vfs_feof_impl(VFSFile * file)
845
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
162 {
871
f51f658b8e9c [svn] - make this work, i think.
nenolod
parents: 846
diff changeset
163 SMBFile *handle;
845
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
164 off_t at;
871
f51f658b8e9c [svn] - make this work, i think.
nenolod
parents: 846
diff changeset
165
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
166 at = smb_aud_vfs_ftell_impl(file);
871
f51f658b8e9c [svn] - make this work, i think.
nenolod
parents: 846
diff changeset
167
846
76983ca8178a [svn] - Adjust indenting cause the previous indenting was painful
nazca
parents: 845
diff changeset
168 //printf("%d %d %ld %ld\n",sizeof(int), sizeof(off_t), at, handle->length);
845
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
169 return (gboolean) (at == handle->length) ? TRUE : FALSE;
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
170 }
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
171
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
172 gint
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
173 smb_aud_vfs_truncate_impl(VFSFile * file, glong size)
845
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
174 {
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
175 return -1;
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
176 }
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
177
965
ertzing
parents: 873
diff changeset
178 off_t
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
179 smb_aud_vfs_fsize_impl(VFSFile * file)
965
ertzing
parents: 873
diff changeset
180 {
971
ertzing
parents: 965
diff changeset
181 SMBFile *handle = (SMBFile *)file->handle;
ertzing
parents: 965
diff changeset
182
ertzing
parents: 965
diff changeset
183 return handle->length;
965
ertzing
parents: 873
diff changeset
184 }
ertzing
parents: 873
diff changeset
185
845
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
186 VFSConstructor smb_const = {
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
187 "smb://",
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
188 smb_aud_vfs_fopen_impl,
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
189 smb_aud_vfs_fclose_impl,
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
190 smb_aud_vfs_fread_impl,
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
191 smb_aud_vfs_fwrite_impl,
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
192 smb_aud_vfs_getc_impl,
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
193 smb_aud_vfs_ungetc_impl,
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
194 smb_aud_vfs_fseek_impl,
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
195 smb_aud_vfs_rewind_impl,
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
196 smb_aud_vfs_ftell_impl,
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
197 smb_aud_vfs_feof_impl,
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
198 smb_aud_vfs_truncate_impl,
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
199 smb_aud_vfs_fsize_impl
845
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
200 };
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
201
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
202 static void init(void)
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
203 {
871
f51f658b8e9c [svn] - make this work, i think.
nenolod
parents: 846
diff changeset
204 int err;
f51f658b8e9c [svn] - make this work, i think.
nenolod
parents: 846
diff changeset
205
f51f658b8e9c [svn] - make this work, i think.
nenolod
parents: 846
diff changeset
206 err = smbc_init(smb_auth_fn, 1);
872
ad00b785dec0 [svn] - Slight tweak ... smbc_init returns 0 on sucess, not fail
nazca
parents: 871
diff changeset
207 if (err < 0)
871
f51f658b8e9c [svn] - make this work, i think.
nenolod
parents: 846
diff changeset
208 {
f51f658b8e9c [svn] - make this work, i think.
nenolod
parents: 846
diff changeset
209 g_message("[smb] not starting samba support due to error code %d", err);
f51f658b8e9c [svn] - make this work, i think.
nenolod
parents: 846
diff changeset
210 return;
f51f658b8e9c [svn] - make this work, i think.
nenolod
parents: 846
diff changeset
211 }
f51f658b8e9c [svn] - make this work, i think.
nenolod
parents: 846
diff changeset
212
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
213 aud_vfs_register_transport(&smb_const);
845
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
214 }
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
215
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
216 static void cleanup(void)
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
217 {
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
218 #if 0
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
219 aud_vfs_unregister_transport(&smb_const);
845
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
220 #endif
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
221 }
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
222
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
223 LowlevelPlugin llp_smb = {
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
224 NULL,
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
225 NULL,
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
226 "smb:// URI Transport",
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
227 init,
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
228 cleanup,
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
229 };
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
230
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
231 LowlevelPlugin *get_lplugin_info(void)
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
232 {
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
233 return &llp_smb;
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
234 }
71c6cbf25348 [svn] - Prototype smb:// vfs transport. Needs testing.
nazca
parents:
diff changeset
235