Mercurial > mplayer.hg
annotate stream/stream_smb.c @ 28345:3a08f32c8fa1
Do not use select n lirc code, instead set the fd non-blocking.
select can not work because lirc_nextcode buffers data internally,
causing events to be delayed until the next keypress in some cases.
Patch by Dennis Vshivkov [jaimor (at) orcon net nz]
author | reimar |
---|---|
date | Tue, 27 Jan 2009 19:06:50 +0000 |
parents | 68015115f63a |
children | 0f1b5b68af32 |
rev | line source |
---|---|
15519
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
1 |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
2 #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
|
3 |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
4 #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
|
5 #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
|
6 |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
7 #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
|
8 #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
|
9 #include "help_mp.h" |
17012 | 10 #include "m_option.h" |
11 #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
|
12 |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
13 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
|
14 } 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
|
15 }; |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
16 |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
17 #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
|
18 // URL definition |
25242 | 19 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
|
20 { 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
|
21 }; |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
22 |
25691 | 23 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
|
24 "smb", |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
25 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
|
26 &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
|
27 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
|
28 }; |
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 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
|
31 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
|
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 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
|
34 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
|
35 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
|
36 { |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
37 char temp[128]; |
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 strcpy(temp, "LAN"); |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
40 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
|
41 temp[strlen(temp) - 1] = 0x00; |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
42 |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
43 if (temp[0]) strncpy(workgroup, temp, wgmaxlen - 1); |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
44 |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
45 strcpy(temp, smb_username); |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
46 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
|
47 temp[strlen(temp) - 1] = 0x00; |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
48 |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
49 if (temp[0]) strncpy(username, temp, unmaxlen - 1); |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
50 |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
51 strcpy(temp, smb_password); |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
52 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
|
53 temp[strlen(temp) - 1] = 0x00; |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
54 |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
55 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
|
56 } |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
57 |
21674 | 58 static int control(stream_t *s, int cmd, void *arg) { |
59 switch(cmd) { | |
60 case STREAM_CTRL_GET_SIZE: { | |
61 off_t size = smbc_lseek(s->fd,0,SEEK_END); | |
62 smbc_lseek(s->fd,s->pos,SEEK_SET); | |
63 if(size != (off_t)-1) { | |
64 *((off_t*)arg) = size; | |
65 return 1; | |
66 } | |
67 } | |
68 } | |
24257 | 69 return STREAM_UNSUPPORTED; |
21674 | 70 } |
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 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
|
73 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
|
74 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
|
75 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
|
76 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
|
77 } |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
78 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
|
79 } |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
80 |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
81 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
|
82 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
|
83 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
|
84 } |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
85 |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
86 static int write_buffer(stream_t *s, char* buffer, int len) { |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
87 int r = smbc_write(s->fd,buffer,len); |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
88 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
|
89 } |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
90 |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
91 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
|
92 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
|
93 } |
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 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
|
96 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
|
97 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
|
98 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
|
99 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
|
100 int fd, err; |
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 filename = stream->url; |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
103 |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
104 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
|
105 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
|
106 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
|
107 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
|
108 else { |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
109 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
|
110 m_struct_free (&stream_opts, opts); |
24257 | 111 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
|
112 } |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
113 |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
114 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
|
115 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
|
116 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
|
117 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
|
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 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
|
121 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
|
122 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
|
123 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
|
124 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
|
125 } |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
126 |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
127 fd = smbc_open(filename, m,0644); |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
128 if (fd < 0) { |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
129 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
|
130 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
|
131 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
|
132 } |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
133 |
21674 | 134 stream->flags = mode; |
135 len = 0; | |
136 if(mode == STREAM_READ) { | |
21688 | 137 len = smbc_lseek(fd,0,SEEK_END); |
138 smbc_lseek (fd, 0, SEEK_SET); | |
21674 | 139 } |
140 if(len > 0 || mode == STREAM_WRITE) { | |
141 stream->flags |= 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
|
142 stream->seek = seek; |
21674 | 143 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
|
144 } |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
145 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
|
146 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
|
147 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
|
148 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
|
149 stream->close = close_f; |
21674 | 150 stream->control = control; |
15519
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
151 |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
152 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
|
153 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
|
154 } |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
155 |
25211 | 156 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
|
157 "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
|
158 "smb", |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
159 "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
|
160 "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
|
161 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
|
162 {"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
|
163 &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
|
164 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
|
165 }; |