Changed sonic mode detection, fixed file listing

This commit is contained in:
Fufu Fang 2019-10-23 22:34:46 +01:00
parent f73643e32c
commit cf700e5d3d
No known key found for this signature in database
GPG Key ID: 0F6BB5EF6F8BB729
2 changed files with 27 additions and 18 deletions

View File

@ -68,6 +68,14 @@ int main(int argc, char **argv)
print_help(argv[0], 0);
exit(EXIT_FAILURE);
} else {
if (CONFIG.sonic_username && CONFIG.sonic_password) {
CONFIG.sonic_mode = 1;
} else if (CONFIG.sonic_username || CONFIG.sonic_password) {
fprintf(stderr,
"Error: You have to supply both username and password to\
activate Sonic mode.\n");
exit(EXIT_FAILURE);
}
if(!LinkSystem_init(base_url)) {
fprintf(stderr, "Error: Network initialisation failed.\n");
exit(EXIT_FAILURE);
@ -143,7 +151,6 @@ parse_arg_list(int argc, char **argv, char ***fuse_argv, int *fuse_argc)
{"cache-location", required_argument, NULL, 'L'}, /* 14 */
{"sonic-username", required_argument, NULL, 'L'}, /* 15 */
{"sonic-password", required_argument, NULL, 'L'}, /* 16 */
{"sonic", no_argument, NULL, 'L'}, /* 17 */
{0, 0, 0, 0}
};
while ((c =
@ -217,9 +224,6 @@ parse_arg_list(int argc, char **argv, char ***fuse_argv, int *fuse_argc)
case 16:
CONFIG.sonic_password = strdup(optarg);
break;
case 17:
CONFIG.sonic_mode = 1;
break;
default:
fprintf(stderr, "see httpdirfs -h for usage\n");
return 1;

View File

@ -144,19 +144,26 @@ static void XMLCALL XML_process_single_element(void *data, const char *elem,
continue;
}
if (!linkname_set) {
if (!strcmp("name", attr[i])) {
strncpy(link->linkname, attr[i+1], MAX_FILENAME_LEN);
linkname_set = 1;
continue;
}
/*
* "title" is used for directory name,
* "name" is for top level directories
*/
if (!strcmp("title", attr[i]) || !strcmp("name", attr[i])) {
strncpy(link->linkname, attr[i+1], MAX_FILENAME_LEN);
linkname_set = 1;
continue;
}
if (!strcmp("path", attr[i])) {
strncpy(link->linkname, strrchr(attr[i+1], '/') + 1,
MAX_FILENAME_LEN);
linkname_set = 1;
continue;
}
/*
* Path always appears after title, it is used for filename.
* This is why it is safe to rewrite linkname
*/
if (!strcmp("path", attr[i])) {
memset(link->linkname, 0, MAX_FILENAME_LEN);
strncpy(link->linkname, strrchr(attr[i+1], '/') + 1,
MAX_FILENAME_LEN);
linkname_set = 1;
continue;
}
if (!strcmp("isDir", attr[i])) {
@ -164,8 +171,6 @@ static void XMLCALL XML_process_single_element(void *data, const char *elem,
link->type = LINK_DIR;
} else if (!strcmp("false", attr[i+1])) {
link->type = LINK_FILE;
} else {
link->type = LINK_DIR;
}
continue;
}