annotate stream/stream_smb.c @ 24079:f40ff9321699

Fix a bug in stream_read_qword_le due to sign extension from int to uint64_t. Patch by Sean Veers [cf3cf3 gmail com]
author reimar
date Sun, 19 Aug 2007 08:50:58 +0000
parents 86f7b9cab33b
children d261f5109660
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 15521
diff changeset
10 #include "m_option.h"
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 15521
diff changeset
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
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
19 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
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
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
23 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
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
74d09d421f72 support for writing over smb shares
nicodvb
parents: 19271
diff changeset
58 static int control(stream_t *s, int cmd, void *arg) {
74d09d421f72 support for writing over smb shares
nicodvb
parents: 19271
diff changeset
59 switch(cmd) {
74d09d421f72 support for writing over smb shares
nicodvb
parents: 19271
diff changeset
60 case STREAM_CTRL_GET_SIZE: {
74d09d421f72 support for writing over smb shares
nicodvb
parents: 19271
diff changeset
61 off_t size = smbc_lseek(s->fd,0,SEEK_END);
74d09d421f72 support for writing over smb shares
nicodvb
parents: 19271
diff changeset
62 smbc_lseek(s->fd,s->pos,SEEK_SET);
74d09d421f72 support for writing over smb shares
nicodvb
parents: 19271
diff changeset
63 if(size != (off_t)-1) {
74d09d421f72 support for writing over smb shares
nicodvb
parents: 19271
diff changeset
64 *((off_t*)arg) = size;
74d09d421f72 support for writing over smb shares
nicodvb
parents: 19271
diff changeset
65 return 1;
74d09d421f72 support for writing over smb shares
nicodvb
parents: 19271
diff changeset
66 }
74d09d421f72 support for writing over smb shares
nicodvb
parents: 19271
diff changeset
67 }
74d09d421f72 support for writing over smb shares
nicodvb
parents: 19271
diff changeset
68 }
74d09d421f72 support for writing over smb shares
nicodvb
parents: 19271
diff changeset
69 return STREAM_UNSUPORTED;
74d09d421f72 support for writing over smb shares
nicodvb
parents: 19271
diff changeset
70 }
74d09d421f72 support for writing over smb shares
nicodvb
parents: 19271
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 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);
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
111 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
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
74d09d421f72 support for writing over smb shares
nicodvb
parents: 19271
diff changeset
134 stream->flags = mode;
74d09d421f72 support for writing over smb shares
nicodvb
parents: 19271
diff changeset
135 len = 0;
74d09d421f72 support for writing over smb shares
nicodvb
parents: 19271
diff changeset
136 if(mode == STREAM_READ) {
21688
950dfaa7612c reindented after yesterday's commit
nicodvb
parents: 21674
diff changeset
137 len = smbc_lseek(fd,0,SEEK_END);
950dfaa7612c reindented after yesterday's commit
nicodvb
parents: 21674
diff changeset
138 smbc_lseek (fd, 0, SEEK_SET);
21674
74d09d421f72 support for writing over smb shares
nicodvb
parents: 19271
diff changeset
139 }
74d09d421f72 support for writing over smb shares
nicodvb
parents: 19271
diff changeset
140 if(len > 0 || mode == STREAM_WRITE) {
74d09d421f72 support for writing over smb shares
nicodvb
parents: 19271
diff changeset
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
74d09d421f72 support for writing over smb shares
nicodvb
parents: 19271
diff changeset
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
74d09d421f72 support for writing over smb shares
nicodvb
parents: 19271
diff changeset
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
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
156 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
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 };