Mercurial > mplayer.hg
annotate libmpdemux/stream_smb.c @ 17267:123b780115e7
for roff: add missing linebreak in uspp description
author | wanderer |
---|---|
date | Fri, 30 Dec 2005 05:08:37 +0000 |
parents | 6ff3379a0862 |
children | d2d9d011203f |
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 |
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 "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
|
10 #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
|
11 #include "help_mp.h" |
17012 | 12 #include "m_option.h" |
13 #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
|
14 |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
15 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
|
16 } 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
|
17 }; |
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 #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
|
20 // 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
|
21 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
|
22 { 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
|
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 |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
25 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
|
26 "smb", |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
27 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
|
28 &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
|
29 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
|
30 }; |
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 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
|
33 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
|
34 |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
35 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
|
36 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
|
37 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
|
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 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
|
40 |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
41 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
|
42 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
|
43 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
|
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 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
|
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 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
|
48 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
|
49 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
|
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 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
|
52 |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
53 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
|
54 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
|
55 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
|
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 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
|
58 } |
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 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
|
61 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
|
62 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
|
63 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
|
64 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
|
65 } |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
66 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
|
67 } |
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 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
|
70 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
|
71 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
|
72 } |
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 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
|
75 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
|
76 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
|
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 |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
79 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
|
80 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
|
81 } |
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 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
|
84 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
|
85 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
|
86 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
|
87 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
|
88 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
|
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 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
|
91 |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
92 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
|
93 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
|
94 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
|
95 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
|
96 else { |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
97 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
|
98 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
|
99 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
|
100 } |
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 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
|
103 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
|
104 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
|
105 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
|
106 } |
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 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
|
109 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
|
110 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
|
111 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
|
112 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
|
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 |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
115 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
|
116 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
|
117 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
|
118 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
|
119 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
|
120 } |
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 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
|
123 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
|
124 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
|
125 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
|
126 else { |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
127 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
|
128 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
|
129 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
|
130 } |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
131 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
|
132 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
|
133 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
|
134 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
|
135 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
|
136 |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
137 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
|
138 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
|
139 } |
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 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
|
142 "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
|
143 "smb", |
07a841d9a8e1
ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff
changeset
|
144 "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
|
145 "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
|
146 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
|
147 {"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
|
148 &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
|
149 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
|
150 }; |
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 #endif |