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();
57 if (!smbc_init_context(libsmbc->
ctx)) {
62 smbc_set_context(libsmbc->
ctx);
64 smbc_setOptionUserData(libsmbc->
ctx, h);
68 smbc_setTimeout(libsmbc->
ctx, libsmbc->
timeout);
72 if (smbc_init(NULL, 0) < 0) {
83 if (libsmbc->
fd >= 0) {
84 smbc_close(libsmbc->
fd);
88 smbc_free_context(libsmbc->
ctx, 1);
107 access = O_CREAT | O_RDWR;
110 }
else if (flags & AVIO_FLAG_WRITE) {
111 access = O_CREAT | O_WRONLY;
118 if ((libsmbc->
fd = smbc_open(url, access, 0666)) < 0) {
124 if (smbc_fstat(libsmbc->
fd, &st) < 0)
148 if ((newpos = smbc_lseek(libsmbc->
fd, pos, whence)) < 0) {
162 if ((bytes_read = smbc_read(libsmbc->
fd, buf, size)) < 0) {
176 if ((bytes_written = smbc_write(libsmbc->
fd, buf, size)) < 0) {
182 return bytes_written;
185 #define OFFSET(x) offsetof(LIBSMBContext, x)
186 #define D AV_OPT_FLAG_DECODING_PARAM
187 #define E AV_OPT_FLAG_ENCODING_PARAM
189 {
"timeout",
"set timeout in ms of socket I/O operations",
OFFSET(timeout),
AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX,
D|
E },
210 .priv_data_class = &libsmbclient_context_class,