annotate stream/stream_smb.c @ 20347:c1f610e507ed

fix "typo"
author kraymer
date Sun, 22 Oct 2006 12:21:29 +0000
parents 64d82a45a05d
children 74d09d421f72
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
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
58 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
59 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
60 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
61 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
62 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
63 }
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 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 }
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 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
68 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
69 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
70 }
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
71
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 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
73 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
74 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
75 }
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
76
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
77 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
78 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
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 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
82 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
83 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
84 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
85 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
86 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
87
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
88 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
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 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
91 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
92 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
93 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
94 else {
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
95 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
96 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
97 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
98 }
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
99
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
100 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
101 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
102 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
103 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
104 }
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
105
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
106 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
107 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
108 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
109 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
110 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
111 }
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 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
114 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
115 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
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 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
121 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
122 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
123 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
124 else {
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 = 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
126 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
127 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
128 }
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->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
130 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
131 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
132 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
133 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
134
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
135 m_struct_free(&stream_opts, opts);
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
136 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
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
07a841d9a8e1 ported smb:// to the new stream api, patch by Matthieu Tourne [matthieu puntum tourne ab gmail puntum com]
nicodvb
parents:
diff changeset
139 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
140 "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
141 "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 "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
143 "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
144 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
145 {"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
146 &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
147 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
148 };