Mercurial > mplayer.hg
annotate libmpdemux/stream_smb.c @ 15519:07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
author | nicodvb |
---|---|
date | Thu, 19 May 2005 20:58:11 +0000 |
parents | |
children | 77a604e12143 |
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 #ifdef LIBSMBCLIENT |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
5 |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
6 #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
|
7 #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
|
8 #include <stdio.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 |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
10 #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
|
11 #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
|
12 #include "help_mp.h" |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
13 #include "../m_option.h" |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
14 #include "../m_struct.h" |
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 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
|
17 } 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
|
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 |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
20 #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
|
21 // URL definition |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
22 static m_option_t 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
|
23 { 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
|
24 }; |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
25 |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
26 static struct m_struct_st 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
|
27 "smb", |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
28 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
|
29 &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
|
30 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
|
31 }; |
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 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
|
34 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
|
35 |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
36 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
|
37 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
|
38 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
|
39 { |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
40 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
|
41 |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
42 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
|
43 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
|
44 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
|
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 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
|
47 |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
48 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
|
49 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
|
50 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
|
51 |
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[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
|
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 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
|
55 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
|
56 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
|
57 |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
58 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
|
59 } |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
60 |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
61 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
|
62 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
|
63 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
|
64 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
|
65 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
|
66 } |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
67 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
|
68 } |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
69 |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
70 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
|
71 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
|
72 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
|
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 |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
75 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
|
76 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
|
77 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
|
78 } |
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 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
|
81 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
|
82 } |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
83 |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
84 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
|
85 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
|
86 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
|
87 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
|
88 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
|
89 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
|
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 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
|
92 |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
93 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
|
94 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
|
95 else if (mode == STREAM_WRITE) //who's gonna do that ? |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
96 m = O_WRONLY; |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
97 else { |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
98 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
|
99 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
|
100 return STREAM_UNSUPORTED; |
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 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
|
104 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
|
105 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
|
106 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
|
107 } |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
108 |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
109 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
|
110 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
|
111 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
|
112 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
|
113 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
|
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 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
|
117 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
|
118 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
|
119 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
|
120 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
|
121 } |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
122 |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
123 len = smbc_lseek(fd,0,SEEK_END); |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
124 smbc_lseek (fd, 0, SEEK_SET); |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
125 if (len <= 0) |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
126 stream->flags = 0; |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
127 else { |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
128 stream->flags = STREAM_READ | STREAM_SEEK; |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
129 stream->end_pos = len; |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
130 stream->seek = seek; |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
131 } |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
132 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
|
133 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
|
134 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
|
135 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
|
136 stream->close = close_f; |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
137 |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
138 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
|
139 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
|
140 } |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
141 |
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_info_t stream_info_smb = { |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
143 "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
|
144 "smb", |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
145 "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
|
146 "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
|
147 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
|
148 {"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
|
149 &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
|
150 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
|
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 |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
153 #endif |