summaryrefslogtreecommitdiff
path: root/libarchive
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@users.sourceforge.net>2008-10-28 17:10:07 +0100
committerTomas Bzatek <tbzatek@users.sourceforge.net>2008-10-28 17:10:07 +0100
commitda1cdfc3ada7109330a92955239bdc7981e95430 (patch)
treea816308895fd45de50a0dc06cada0c1b50b4ccfe /libarchive
parentc4db474055a604156e1acf162991e625fd340fa5 (diff)
downloadtuxcmd-modules-da1cdfc3ada7109330a92955239bdc7981e95430.tar.xz
Password callback support from all VFS modulesv0.6.54
Diffstat (limited to 'libarchive')
-rw-r--r--libarchive/libarchive.c54
1 files changed, 33 insertions, 21 deletions
diff --git a/libarchive/libarchive.c b/libarchive/libarchive.c
index 4a360bd..be6326b 100644
--- a/libarchive/libarchive.c
+++ b/libarchive/libarchive.c
@@ -1,5 +1,5 @@
/* libarchive plugin for Tux Commander
- * version 0.1.0, designed for libarchive 2.5.5
+ * version 0.1.1, designed for libarchive 2.5.5
* Copyright (C) 2008 Tomas Bzatek <tbzatek@users.sourceforge.net>
* Check for updates on tuxcmd.sourceforge.net
*
@@ -47,8 +47,8 @@
-#define VERSION "0.1.0"
-#define BUILD_DATE "2008-10-05"
+#define VERSION "0.1.1"
+#define BUILD_DATE "2008-10-28"
#define DEFAULT_BLOCK_SIZE 65536
@@ -73,6 +73,11 @@ struct TVFSGlobs {
struct VfsFilelistData *vfs_filelist;
u_int64_t total_size;
+
+ TVFSAskQuestionCallback callback_ask_question;
+ TVFSAskPasswordCallback callback_ask_password;
+ TVFSProgressCallback callback_progress;
+ void *callback_data;
};
@@ -92,6 +97,12 @@ VFSNew (TVFSLogFunc log_func)
memset (globs, 0, sizeof (struct TVFSGlobs));
globs->block_size = DEFAULT_BLOCK_SIZE;
+
+ globs->callback_data = NULL;
+ globs->callback_ask_question = NULL;
+ globs->callback_ask_password = NULL;
+ globs->callback_progress = NULL;
+
globs->log_func = log_func;
if (globs->log_func != NULL) globs->log_func((char*)"libarchive plugin: VFSInit");
@@ -99,6 +110,19 @@ VFSNew (TVFSLogFunc log_func)
}
void
+VFSSetCallbacks (struct TVFSGlobs *globs,
+ TVFSAskQuestionCallback ask_question_callback,
+ TVFSAskPasswordCallback ask_password_callback,
+ TVFSProgressCallback progress_func,
+ void *data)
+{
+ globs->callback_ask_question = ask_question_callback;
+ globs->callback_ask_password = ask_password_callback;
+ globs->callback_progress = progress_func;
+ globs->callback_data = data;
+}
+
+void
VFSFree (struct TVFSGlobs *globs)
{
if (globs->log_func != NULL) globs->log_func((char*)"libarchive plugin: VFSDestroy");
@@ -297,18 +321,6 @@ TVFSResult VFSChangeDir(struct TVFSGlobs *globs, char *NewPath)
else return cVFS_Failed;
}
-
-int VFSLogin(struct TVFSGlobs *globs, char *user, char *pass)
-{
- return cVFS_Not_Supported;
-}
-
-int VFSSetPassword(struct TVFSGlobs *globs, char *pass)
-{
- printf("(WW) VFSSetPassword: Not supported in libarchive plugin.\n");
- return cVFS_Not_Supported;
-}
-
int VFSGetPasswordRequired(struct TVFSGlobs *globs)
{
return FALSE;
@@ -480,7 +492,7 @@ int VFSTwoSameFiles(struct TVFSGlobs *globs, const char *Path1, const char *Path
* Quote: "This implementation minimizes copying of data and is sparse-file aware."
**/
static TVFSResult
-my_archive_read_data_into_fd(struct archive *a, struct archive_entry *entry, const char *sDstName, size_t max_block, TVFSCopyCallBackFunc pCallBackProgress, void *data, int Append)
+my_archive_read_data_into_fd(struct TVFSGlobs *globs, struct archive *a, struct archive_entry *entry, const char *sDstName, size_t max_block, int Append)
{
int r;
int fd;
@@ -529,8 +541,8 @@ my_archive_read_data_into_fd(struct archive *a, struct archive_entry *entry, con
size -= bytes_written;
log(" (II) my_archive_read_data_into_fd: bytes_written = %u, total_written = %u\n", bytes_written, total_written);
- if (pCallBackProgress) {
- if (! pCallBackProgress(total_written, file_size, data)) {
+ if (globs->callback_progress) {
+ if (! globs->callback_progress(total_written, file_size, globs->callback_data)) {
cancel = TRUE;
break;
}
@@ -553,7 +565,7 @@ my_archive_read_data_into_fd(struct archive *a, struct archive_entry *entry, con
}
-TVFSResult VFSCopyOut(struct TVFSGlobs *globs, const char *sSrcName, const char *sDstName, TVFSCopyCallBackFunc pCallBackProgress, void *data, int Append)
+TVFSResult VFSCopyOut(struct TVFSGlobs *globs, const char *sSrcName, const char *sDstName, int Append)
{
if ((sSrcName == NULL) || (sDstName == NULL) || (strlen(sSrcName) < 1) || (strlen(sDstName) < 1)) {
printf("(EE) VFSCopyOut: The value of 'sSrcName' or 'sDstName' is NULL or empty\n");
@@ -602,7 +614,7 @@ TVFSResult VFSCopyOut(struct TVFSGlobs *globs, const char *sSrcName, const char
// printf("--> found file, extracting\n");
fprintf(stderr, "(II) VFSCopyOut: extract_file_path(sDstName) = '%s', extract_file_name(sDstName) = '%s' \n", extract_file_path(sDstName), extract_file_name(sDstName));
- Result = my_archive_read_data_into_fd(a, entry, sDstName, globs->block_size, pCallBackProgress, data, Append);
+ Result = my_archive_read_data_into_fd(globs, a, entry, sDstName, globs->block_size, Append);
break;
}
}
@@ -615,7 +627,7 @@ TVFSResult VFSCopyOut(struct TVFSGlobs *globs, const char *sSrcName, const char
return Result;
}
-TVFSResult VFSCopyIn(struct TVFSGlobs *globs, const char *sSrcName, const char *sDstName, TVFSCopyCallBackFunc pCallBackProgress, void *data, int Append)
+TVFSResult VFSCopyIn(struct TVFSGlobs *globs, const char *sSrcName, const char *sDstName, int Append)
{
printf("(WW) VFSCopyIn: Not supported in libarchive plugin.\n");
return cVFS_Not_Supported;