21 #include <libsmbclient.h>
40 char *workgroup,
int workgroup_len,
41 char *username,
int username_len,
42 char *password,
int password_len)
52 libsmbc->
ctx = smbc_new_context();
58 if (!smbc_init_context(libsmbc->
ctx)) {
63 smbc_set_context(libsmbc->
ctx);
65 smbc_setOptionUserData(libsmbc->
ctx, h);
69 smbc_setTimeout(libsmbc->
ctx, libsmbc->
timeout);
73 if (smbc_init(
NULL, 0) < 0) {
84 if (libsmbc->
fd >= 0) {
85 smbc_close(libsmbc->
fd);
89 smbc_free_context(libsmbc->
ctx, 1);
108 access = O_CREAT | O_RDWR;
111 }
else if (flags & AVIO_FLAG_WRITE) {
112 access = O_CREAT | O_WRONLY;
119 if ((libsmbc->
fd = smbc_open(url, access, 0666)) < 0) {
125 if (smbc_fstat(libsmbc->
fd, &st) < 0)
149 if ((newpos = smbc_lseek(libsmbc->
fd, pos, whence)) < 0) {
163 if ((bytes_read = smbc_read(libsmbc->
fd, buf, size)) < 0) {
177 if ((bytes_written = smbc_write(libsmbc->
fd, buf, size)) < 0) {
183 return bytes_written;
194 if ((libsmbc->
dh = smbc_opendir(h->
filename)) < 0) {
211 struct smbc_dirent *dirent =
NULL;
221 dirent = smbc_readdir(libsmbc->
dh);
226 switch (dirent->smbc_type) {
233 case SMBC_FILE_SHARE:
242 case SMBC_COMMS_SHARE:
244 case SMBC_PRINTER_SHARE:
252 }
while (skip_entry || !strcmp(dirent->name,
".") ||
253 !strcmp(dirent->name,
".."));
264 if (!smbc_stat(url, &st)) {
267 entry->
size = st.st_size;
268 entry->
filemode = st.st_mode & 0777;
282 if (libsmbc->
dh >= 0) {
283 smbc_closedir(libsmbc->
dh);
299 if ((libsmbc->
fd = smbc_open(h->
filename, O_WRONLY, 0666)) < 0) {
304 if (smbc_fstat(libsmbc->
fd, &st) < 0) {
309 smbc_close(libsmbc->
fd);
312 if (S_ISDIR(st.st_mode)) {
351 #define OFFSET(x) offsetof(LIBSMBContext, x)
352 #define D AV_OPT_FLAG_DECODING_PARAM
353 #define E AV_OPT_FLAG_ENCODING_PARAM
355 {
"timeout",
"set timeout in ms of socket I/O operations",
OFFSET(timeout),
AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX,
D|
E },
381 .priv_data_class = &libsmbclient_context_class,
#define URL_PROTOCOL_FLAG_NETWORK
static const AVOption options[]
int64_t filemode
Unix file mode, -1 if unknown.
static void libsmbc_get_auth_data(SMBCCTX *c, const char *server, const char *share, char *workgroup, int workgroup_len, char *username, int username_len, char *password, int password_len)
#define AV_LOG_WARNING
Something somehow does not look correct.
#define LIBAVUTIL_VERSION_INT
Describes single entry of the directory.
const char * av_default_item_name(void *ptr)
Return the context name.
#define AVIO_FLAG_READ
read-only
#define AVIO_FLAG_WRITE
write-only
static int libsmbc_move(URLContext *h_src, URLContext *h_dst)
static av_cold int libsmbc_connect(URLContext *h)
static av_cold int libsmbc_close(URLContext *h)
int64_t modification_timestamp
Time of last modification in microseconds since unix epoch, -1 if unknown.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
static int64_t libsmbc_seek(URLContext *h, int64_t pos, int whence)
static int libsmbc_close_dir(URLContext *h)
static int libsmbc_write(URLContext *h, const unsigned char *buf, int size)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const URLProtocol ff_libsmbclient_protocol
static int libsmbc_read_dir(URLContext *h, AVIODirEntry **next)
int64_t access_timestamp
Time of last access in microseconds since unix epoch, -1 if unknown.
static av_always_inline av_const double trunc(double x)
static int libsmbc_read(URLContext *h, unsigned char *buf, int size)
int64_t size
File size in bytes, -1 if unknown.
char * av_strdup(const char *s)
Duplicate a string.
int type
Type of the entry.
static int libsmbc_open_dir(URLContext *h)
static int libsmbc_delete(URLContext *h)
Describe the class of an AVClass context structure.
int64_t group_id
Group ID of owner, -1 if unknown.
char * av_append_path_component(const char *path, const char *component)
Append path component to the existing path.
int64_t status_change_timestamp
Time of last status change in microseconds since unix epoch, -1 if unknown.
AVIODirEntry * ff_alloc_dir_entry(void)
Allocate directory entry with default values.
char * filename
specified URL
#define AVSEEK_SIZE
ORing this as the "whence" parameter to a seek function causes it to return the filesize without seek...
int64_t user_id
User ID of owner, -1 if unknown.
static const AVClass libsmbclient_context_class
unbuffered private I/O API
static av_cold int libsmbc_open(URLContext *h, const char *url, int flags)
static av_cold void cleanup(FlashSV2Context *s)