annotate stream/stream_smb.c @ 33771:6e774a02d00c

Remove gtkClearStruct code from mplayer() in interface.c. Move it as static function guiInfoMediumClear() where it is used and rename the symbolic constants used with this code.
author ib
date Sat, 09 Jul 2011 11:48:13 +0000
parents 77d81e27a176
children 43385f40396e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
30426
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29920
diff changeset
1 /*
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29920
diff changeset
2 * This file is part of MPlayer.
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29920
diff changeset
3 *
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29920
diff changeset
4 * MPlayer is free software; you can redistribute it and/or modify
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29920
diff changeset
5 * it under the terms of the GNU General Public License as published by
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29920
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29920
diff changeset
7 * (at your option) any later version.
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29920
diff changeset
8 *
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29920
diff changeset
9 * MPlayer is distributed in the hope that it will be useful,
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29920
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29920
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29920
diff changeset
12 * GNU General Public License for more details.
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29920
diff changeset
13 *
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29920
diff changeset
14 * You should have received a copy of the GNU General Public License along
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29920
diff changeset
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29920
diff changeset
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29920
diff changeset
17 */
15519
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
18
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
19 #include "config.h"
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
20
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
21 #include <libsmbclient.h>
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
22 #include <unistd.h>
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
23
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
24 #include "mp_msg.h"
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
25 #include "stream.h"
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
26 #include "help_mp.h"
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 15521
diff changeset
27 #include "m_option.h"
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 15521
diff changeset
28 #include "m_struct.h"
15519
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
29
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
30 static struct stream_priv_s {
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
31 } stream_priv_dflts = {
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
32 };
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
33
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
34 #define ST_OFF(f) M_ST_OFF(struct stream_priv_s,f)
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
35 // URL definition
25242
371a40dcc1cc stream_opts arrays should be const
reimar
parents: 25211
diff changeset
36 static const m_option_t stream_opts_fields[] = {
15519
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
37 { NULL, NULL, 0, 0, 0, 0, NULL }
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
38 };
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
39
25691
68015115f63a stream_opts should be const
reimar
parents: 25242
diff changeset
40 static const struct m_struct_st stream_opts = {
15519
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
41 "smb",
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
42 sizeof(struct stream_priv_s),
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
43 &stream_priv_dflts,
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
44 stream_opts_fields
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
45 };
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
46
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
47 static char smb_password[15];
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
48 static char smb_username[15];
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
49
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
50 static void smb_auth_fn(const char *server, const char *share,
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
51 char *workgroup, int wgmaxlen, char *username, int unmaxlen,
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
52 char *password, int pwmaxlen)
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
53 {
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
54 char temp[128];
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25691
diff changeset
55
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25691
diff changeset
56 strcpy(temp, "LAN");
15519
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
57 if (temp[strlen(temp) - 1] == 0x0a)
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
58 temp[strlen(temp) - 1] = 0x00;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25691
diff changeset
59
15519
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
60 if (temp[0]) strncpy(workgroup, temp, wgmaxlen - 1);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25691
diff changeset
61
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25691
diff changeset
62 strcpy(temp, smb_username);
15519
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
63 if (temp[strlen(temp) - 1] == 0x0a)
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
64 temp[strlen(temp) - 1] = 0x00;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25691
diff changeset
65
15519
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
66 if (temp[0]) strncpy(username, temp, unmaxlen - 1);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25691
diff changeset
67
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25691
diff changeset
68 strcpy(temp, smb_password);
15519
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
69 if (temp[strlen(temp) - 1] == 0x0a)
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
70 temp[strlen(temp) - 1] = 0x00;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25691
diff changeset
71
15519
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
72 if (temp[0]) strncpy(password, temp, pwmaxlen - 1);
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
73 }
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
74
21674
74d09d421f72 support for writing over smb shares
nicodvb
parents: 19271
diff changeset
75 static int control(stream_t *s, int cmd, void *arg) {
74d09d421f72 support for writing over smb shares
nicodvb
parents: 19271
diff changeset
76 switch(cmd) {
74d09d421f72 support for writing over smb shares
nicodvb
parents: 19271
diff changeset
77 case STREAM_CTRL_GET_SIZE: {
74d09d421f72 support for writing over smb shares
nicodvb
parents: 19271
diff changeset
78 off_t size = smbc_lseek(s->fd,0,SEEK_END);
74d09d421f72 support for writing over smb shares
nicodvb
parents: 19271
diff changeset
79 smbc_lseek(s->fd,s->pos,SEEK_SET);
74d09d421f72 support for writing over smb shares
nicodvb
parents: 19271
diff changeset
80 if(size != (off_t)-1) {
74d09d421f72 support for writing over smb shares
nicodvb
parents: 19271
diff changeset
81 *((off_t*)arg) = size;
74d09d421f72 support for writing over smb shares
nicodvb
parents: 19271
diff changeset
82 return 1;
74d09d421f72 support for writing over smb shares
nicodvb
parents: 19271
diff changeset
83 }
74d09d421f72 support for writing over smb shares
nicodvb
parents: 19271
diff changeset
84 }
74d09d421f72 support for writing over smb shares
nicodvb
parents: 19271
diff changeset
85 }
24257
d261f5109660 cosmetics: typo fix UNSUPORTED --> UNSUPPORTED
diego
parents: 22451
diff changeset
86 return STREAM_UNSUPPORTED;
21674
74d09d421f72 support for writing over smb shares
nicodvb
parents: 19271
diff changeset
87 }
74d09d421f72 support for writing over smb shares
nicodvb
parents: 19271
diff changeset
88
15519
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
89 static int seek(stream_t *s,off_t newpos) {
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
90 s->pos = newpos;
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
91 if(smbc_lseek(s->fd,s->pos,SEEK_SET)<0) {
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
92 s->eof=1;
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
93 return 0;
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
94 }
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
95 return 1;
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
96 }
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
97
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
98 static int fill_buffer(stream_t *s, char* buffer, int max_len){
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
99 int r = smbc_read(s->fd,buffer,max_len);
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
100 return (r <= 0) ? -1 : r;
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
101 }
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
102
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
103 static int write_buffer(stream_t *s, char* buffer, int len) {
32794
77d81e27a176 Fix stream_write_buffer to make sure all requested bytes are written
ranma
parents: 30426
diff changeset
104 int r;
77d81e27a176 Fix stream_write_buffer to make sure all requested bytes are written
ranma
parents: 30426
diff changeset
105 int wr = 0;
77d81e27a176 Fix stream_write_buffer to make sure all requested bytes are written
ranma
parents: 30426
diff changeset
106 while (wr < len) {
77d81e27a176 Fix stream_write_buffer to make sure all requested bytes are written
ranma
parents: 30426
diff changeset
107 r = smbc_write(s->fd,buffer,len);
77d81e27a176 Fix stream_write_buffer to make sure all requested bytes are written
ranma
parents: 30426
diff changeset
108 if (r <= 0)
77d81e27a176 Fix stream_write_buffer to make sure all requested bytes are written
ranma
parents: 30426
diff changeset
109 return -1;
77d81e27a176 Fix stream_write_buffer to make sure all requested bytes are written
ranma
parents: 30426
diff changeset
110 wr += r;
77d81e27a176 Fix stream_write_buffer to make sure all requested bytes are written
ranma
parents: 30426
diff changeset
111 buffer += r;
77d81e27a176 Fix stream_write_buffer to make sure all requested bytes are written
ranma
parents: 30426
diff changeset
112 }
77d81e27a176 Fix stream_write_buffer to make sure all requested bytes are written
ranma
parents: 30426
diff changeset
113 return len;
15519
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
114 }
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
115
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
116 static void close_f(stream_t *s){
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
117 smbc_close(s->fd);
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
118 }
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
119
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
120 static int open_f (stream_t *stream, int mode, void *opts, int* file_format) {
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
121 struct stream_priv_s *p = (struct stream_priv_s*)opts;
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
122 char *filename;
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
123 mode_t m = 0;
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
124 off_t len;
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
125 int fd, err;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25691
diff changeset
126
15519
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
127 filename = stream->url;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25691
diff changeset
128
15519
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
129 if(mode == STREAM_READ)
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
130 m = O_RDONLY;
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
131 else if (mode == STREAM_WRITE) //who's gonna do that ?
22451
86f7b9cab33b truncate mencoder's output file if it exists, instead of overwriting just part of it.
lorenm
parents: 21688
diff changeset
132 m = O_RDWR|O_CREAT|O_TRUNC;
15519
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
133 else {
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
134 mp_msg(MSGT_OPEN, MSGL_ERR, "[smb] Unknown open mode %d\n", mode);
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
135 m_struct_free (&stream_opts, opts);
24257
d261f5109660 cosmetics: typo fix UNSUPORTED --> UNSUPPORTED
diego
parents: 22451
diff changeset
136 return STREAM_UNSUPPORTED;
15519
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
137 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25691
diff changeset
138
15519
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
139 if(!filename) {
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
140 mp_msg(MSGT_OPEN,MSGL_ERR, "[smb] Bad url\n");
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
141 m_struct_free(&stream_opts, opts);
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
142 return STREAM_ERROR;
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
143 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25691
diff changeset
144
15519
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
145 err = smbc_init(smb_auth_fn, 1);
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
146 if (err < 0) {
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
147 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_SMBInitError,err);
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
148 m_struct_free(&stream_opts, opts);
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
149 return STREAM_ERROR;
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
150 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25691
diff changeset
151
15519
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
152 fd = smbc_open(filename, m,0644);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25691
diff changeset
153 if (fd < 0) {
15519
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
154 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_SMBFileNotFound, filename);
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
155 m_struct_free(&stream_opts, opts);
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
156 return STREAM_ERROR;
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
157 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25691
diff changeset
158
21674
74d09d421f72 support for writing over smb shares
nicodvb
parents: 19271
diff changeset
159 stream->flags = mode;
74d09d421f72 support for writing over smb shares
nicodvb
parents: 19271
diff changeset
160 len = 0;
74d09d421f72 support for writing over smb shares
nicodvb
parents: 19271
diff changeset
161 if(mode == STREAM_READ) {
21688
950dfaa7612c reindented after yesterday's commit
nicodvb
parents: 21674
diff changeset
162 len = smbc_lseek(fd,0,SEEK_END);
950dfaa7612c reindented after yesterday's commit
nicodvb
parents: 21674
diff changeset
163 smbc_lseek (fd, 0, SEEK_SET);
21674
74d09d421f72 support for writing over smb shares
nicodvb
parents: 19271
diff changeset
164 }
74d09d421f72 support for writing over smb shares
nicodvb
parents: 19271
diff changeset
165 if(len > 0 || mode == STREAM_WRITE) {
29920
4f740437ed2b Finally rename the STREAM_SEEK define to MP_STREAM_SEEK, there are just too many
reimar
parents: 29263
diff changeset
166 stream->flags |= MP_STREAM_SEEK;
15519
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
167 stream->seek = seek;
21674
74d09d421f72 support for writing over smb shares
nicodvb
parents: 19271
diff changeset
168 if(mode == STREAM_READ) stream->end_pos = len;
15519
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
169 }
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
170 stream->type = STREAMTYPE_SMB;
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
171 stream->fd = fd;
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
172 stream->fill_buffer = fill_buffer;
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
173 stream->write_buffer = write_buffer;
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
174 stream->close = close_f;
21674
74d09d421f72 support for writing over smb shares
nicodvb
parents: 19271
diff changeset
175 stream->control = control;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25691
diff changeset
176
15519
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
177 m_struct_free(&stream_opts, opts);
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
178 return STREAM_OK;
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
179 }
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
180
25211
c1d17bd6683c Mark all stream_info_t as const
reimar
parents: 24257
diff changeset
181 const stream_info_t stream_info_smb = {
15519
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
182 "Server Message Block",
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
183 "smb",
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
184 "M. Tourne",
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
185 "based on the code from 'a bulgarian' (one says)",
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
186 open_f,
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
187 {"smb", NULL},
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
188 &stream_opts,
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
189 0 //Url is an option string
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
190 };