char name[1];
};
+/**@ingroup structure
+ * Structure that represents all attributes of a directory entry.
+ *
+ */
+struct libsmb_file_info
+{
+ /**
+ * Size of file
+ */
+ uint64_t size;
+ /**
+ * DOS attributes of file
+ */
+ uint16_t attrs;
+ /**
+ * User ID of file
+ */
+ uid_t uid;
+ /**
+ * Group ID of file
+ */
+ gid_t gid;
+ /**
+ * Birth/Create time of file (if supported by system)
+ * Otherwise the value will be 0
+ */
+ struct timespec btime_ts;
+ /**
+ * Modified time for the file
+ */
+ struct timespec mtime_ts;
+ /**
+ * Access time for the file
+ */
+ struct timespec atime_ts;
+ /**
+ * Change time for the file
+ */
+ struct timespec ctime_ts;
+ /**
+ * Name of file
+ */
+ char *name;
+ /**
+ * Short name of file
+ */
+ char *short_name;
+};
+
+/*
+ * Logging callback function
+ */
+typedef void (*smbc_debug_callback_fn)(void *private_ptr, int level, const char *msg);
+
/*
* Flags for smbc_setxattr()
* Specify a bitwise OR of these, or 0 to add or replace as necessary
void
smbc_setDebug(SMBCCTX *c, int debug);
+/**
+ * set log callback function to capture logs from libsmbclient, this
+ * is applied at global level
+ */
+void
+smbc_setLogCallback(SMBCCTX *c, void *private_ptr,
+ smbc_debug_callback_fn fn);
+
+/** set configuration file, this is applied at global level */
+int
+smbc_setConfiguration(SMBCCTX *c, const char *file);
+
/** Get the netbios name used for making connections */
-char *
+const char *
smbc_getNetbiosName(SMBCCTX *c);
/** Set the netbios name used for making connections */
void
-smbc_setNetbiosName(SMBCCTX *c, char * netbios_name);
+smbc_setNetbiosName(SMBCCTX *c, const char *netbios_name);
/** Get the workgroup used for making connections */
-char *
+const char *
smbc_getWorkgroup(SMBCCTX *c);
/** Set the workgroup used for making connections */
-void smbc_setWorkgroup(SMBCCTX *c, char * workgroup);
+void smbc_setWorkgroup(SMBCCTX *c, const char *workgroup);
/** Get the username used for making connections */
-char *
+const char *
smbc_getUser(SMBCCTX *c);
/** Set the username used for making connections */
void
-smbc_setUser(SMBCCTX *c, char * user);
+smbc_setUser(SMBCCTX *c, const char *user);
/**
* Get the timeout used for waiting on connections and response data
smbc_readdir_fn smbc_getFunctionReaddir(SMBCCTX *c);
void smbc_setFunctionReaddir(SMBCCTX *c, smbc_readdir_fn fn);
+typedef const struct libsmb_file_info * (*smbc_readdirplus_fn)(SMBCCTX *c,
+ SMBCFILE *dir);
+smbc_readdirplus_fn smbc_getFunctionReaddirPlus(SMBCCTX *c);
+void smbc_setFunctionReaddirPlus(SMBCCTX *c, smbc_readdirplus_fn fn);
+
typedef int (*smbc_getdents_fn)(SMBCCTX *c,
SMBCFILE *dir,
struct smbc_dirent *dirp,
smbc_fstatdir_fn smbc_getFunctionFstatdir(SMBCCTX *c);
void smbc_setFunctionFstatdir(SMBCCTX *c, smbc_fstatdir_fn fn);
+#define SMBC_NOTIFY_ACTION_ADDED 1
+#define SMBC_NOTIFY_ACTION_REMOVED 2
+#define SMBC_NOTIFY_ACTION_MODIFIED 3
+#define SMBC_NOTIFY_ACTION_OLD_NAME 4
+#define SMBC_NOTIFY_ACTION_NEW_NAME 5
+#define SMBC_NOTIFY_ACTION_ADDED_STREAM 6
+#define SMBC_NOTIFY_ACTION_REMOVED_STREAM 7
+#define SMBC_NOTIFY_ACTION_MODIFIED_STREAM 8
+
+struct smbc_notify_callback_action {
+ uint32_t action;
+ const char *filename;
+};
+
+typedef int (*smbc_notify_callback_fn)(
+ const struct smbc_notify_callback_action *actions,
+ size_t num_actions, void *private_data);
+
+typedef int (*smbc_notify_fn)(SMBCCTX *c, SMBCFILE *dir, smbc_bool recursive,
+ uint32_t completion_filter,
+ unsigned callback_timeout_ms,
+ smbc_notify_callback_fn cb, void *private_data);
+smbc_notify_fn smbc_getFunctionNotify(SMBCCTX *c);
+void smbc_setFunctionNotify(SMBCCTX *c, smbc_notify_fn fn);
/*****************************************************************
*/
struct smbc_dirent* smbc_readdir(unsigned int dh);
+/**@ingroup directory
+ * Works similar as smbc_readdir but returns more information about file.
+ *
+ * @param dh Valid directory as returned by smbc_opendir()
+ *
+ * @return A const pointer to a libsmb_file_info structure,
+ * or NULL if an error occurs or end-of-directory is reached:
+ * - EBADF Invalid directory handle
+ * - EINVAL smbc_init() failed or has not been called
+ *
+ * @see smbc_open(), smbc_readdir()
+ */
+const struct libsmb_file_info *smbc_readdirplus(unsigned int dh);
+
/**@ingroup directory
* Get the current directory offset.
*/
int smbc_rmdir(const char *durl);
+/**@ingroup directory
+ * Request directory notifications
+ *
+ * @param dh Valid directory as returned by smbc_opendir()
+ *
+ * @param recursive Are changes in subdirectories wanted?
+ *
+ * @param completion_filter Bitwise-or of the SMBC_NOTIFY_CHANGE_*
+ * events that are interesting
+ *
+ * @param callback_timeout_ms If set to non-zero, interval in milliseconds
+ * that "cb" will be called with 0 actions.
+ * This gives "cb" the chance to cancel the
+ * smbc_notify call.
+ *
+ * @param cb Callback functions taking events. If "cb"
+ * returns nonzero, smbc_notify will return.
+ *
+ * @param private_data Pointer given to "cb"
+ *
+ * @return 0 on success, -1 on error with errno set
+ *
+ * @see smbc_opendir(), smbc_closedir()
+ */
+
+#define SMBC_NOTIFY_CHANGE_FILE_NAME 0x001
+#define SMBC_NOTIFY_CHANGE_DIR_NAME 0x002
+#define SMBC_NOTIFY_CHANGE_ATTRIBUTES 0x004
+#define SMBC_NOTIFY_CHANGE_SIZE 0x008
+#define SMBC_NOTIFY_CHANGE_LAST_WRITE 0x010
+#define SMBC_NOTIFY_CHANGE_LAST_ACCESS 0x020
+#define SMBC_NOTIFY_CHANGE_CREATION 0x040
+#define SMBC_NOTIFY_CHANGE_EA 0x080
+#define SMBC_NOTIFY_CHANGE_SECURITY 0x100
+#define SMBC_NOTIFY_CHANGE_STREAM_NAME 0x200
+#define SMBC_NOTIFY_CHANGE_STREAM_SIZE 0x400
+#define SMBC_NOTIFY_CHANGE_STREAM_WRITE 0x800
+
+int smbc_notify(int dh, smbc_bool recursive, uint32_t completion_filter,
+ unsigned callback_timeout_ms,
+ smbc_notify_callback_fn cb, void *private_data);
/**@ingroup attribute
* Get information about a file or directory.
smbc_opendir_fn opendir DEPRECATED_SMBC_INTERFACE;
smbc_closedir_fn closedir DEPRECATED_SMBC_INTERFACE;
smbc_readdir_fn readdir DEPRECATED_SMBC_INTERFACE;
+ smbc_readdirplus_fn readdirplus DEPRECATED_SMBC_INTERFACE;
smbc_getdents_fn getdents DEPRECATED_SMBC_INTERFACE;
smbc_mkdir_fn mkdir DEPRECATED_SMBC_INTERFACE;
smbc_rmdir_fn rmdir DEPRECATED_SMBC_INTERFACE;