21 #include <libsmbclient.h>
39 char *workgroup,
int workgroup_len,
40 char *username,
int username_len,
41 char *password,
int password_len)
51 libsmbc->
ctx = smbc_new_context();
56 if (!smbc_init_context(libsmbc->
ctx)) {
60 smbc_set_context(libsmbc->
ctx);
62 smbc_setOptionUserData(libsmbc->
ctx, h);
66 smbc_setTimeout(libsmbc->
ctx, libsmbc->
timeout);
70 if (smbc_init(NULL, 0) < 0) {
80 if (libsmbc->
fd >= 0) {
81 smbc_close(libsmbc->
fd);
85 smbc_free_context(libsmbc->
ctx, 1);
104 access = O_CREAT | O_RDWR;
107 }
else if (flags & AVIO_FLAG_WRITE) {
108 access = O_CREAT | O_WRONLY;
115 if ((libsmbc->
fd = smbc_open(url, access, 0666)) < 0) {
121 if (smbc_fstat(libsmbc->
fd, &st) < 0)
145 if ((newpos = smbc_lseek(libsmbc->
fd, pos, whence)) < 0) {
159 if ((bytes_read = smbc_read(libsmbc->
fd, buf, size)) < 0) {
172 if ((bytes_written = smbc_write(libsmbc->
fd, buf, size)) < 0) {
177 return bytes_written;
180 #define OFFSET(x) offsetof(LIBSMBContext, x)
181 #define D AV_OPT_FLAG_DECODING_PARAM
182 #define E AV_OPT_FLAG_ENCODING_PARAM
184 {
"timeout",
"set timeout in ms of socket I/O operations",
OFFSET(timeout),
AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX,
D|
E },
205 .priv_data_class = &libsmbclient_context_class,