Don't let api_folder_get_content print but let it fill datastructures

This commit is contained in:
josch
2014-09-25 19:27:49 +02:00
parent 44ba88a69d
commit 0fab559a86
6 changed files with 206 additions and 19 deletions

View File

@@ -22,12 +22,17 @@
#include "../../mfapi/apicalls.h"
#include "../mfshell.h"
#include "../../mfapi/mfconn.h"
#include "../../mfapi/folder.h"
#include "../../mfapi/file.h"
#include "../commands.h" // IWYU pragma: keep
int mfshell_cmd_list(mfshell * mfshell, int argc, char *const argv[])
{
(void)argv;
int retval;
mffolder **folder_result;
mffile **file_result;
int i;
if (mfshell == NULL)
return -1;
@@ -36,15 +41,26 @@ int mfshell_cmd_list(mfshell * mfshell, int argc, char *const argv[])
fprintf(stderr, "Invalid number of arguments\n");
return -1;
}
// first folders
folder_result = NULL;
retval =
mfconn_api_folder_get_content(mfshell->conn, 0, mfshell->folder_curr);
mfconn_api_folder_get_content(mfshell->conn, 0, mfshell->folder_curr, &folder_result, NULL);
mfconn_update_secret_key(mfshell->conn);
for (i = 0; folder_result[i] != NULL; i++) {
printf("%s %s\n", folder_get_name(folder_result[i]), folder_get_key(folder_result[i]));
}
// then files
file_result = NULL;
retval =
mfconn_api_folder_get_content(mfshell->conn, 1, mfshell->folder_curr);
mfconn_api_folder_get_content(mfshell->conn, 1, mfshell->folder_curr, NULL, &file_result);
mfconn_update_secret_key(mfshell->conn);
for (i = 0; file_result[i] != NULL; i++) {
printf("%s %s\n", file_get_name(file_result[i]), file_get_key(file_result[i]));
}
return retval;
}

View File

@@ -18,6 +18,7 @@
*/
#include <stdio.h>
#include <inttypes.h>
#include "../../mfapi/apicalls.h"
#include "../mfshell.h"
@@ -28,6 +29,7 @@ int mfshell_cmd_status(mfshell * mfshell, int argc, char *const argv[])
{
(void)argv;
int retval;
uint64_t revision;
if (mfshell == NULL)
return -1;
@@ -37,8 +39,13 @@ int mfshell_cmd_status(mfshell * mfshell, int argc, char *const argv[])
return -1;
}
// then files
retval = mfconn_api_device_get_status(mfshell->conn);
retval = mfconn_api_device_get_status(mfshell->conn, &revision);
mfconn_update_secret_key(mfshell->conn);
if (retval == 0) {
printf("device_revision: %" PRIu64 "\n", revision);
} else {
fprintf(stderr, "device/get_status() unsuccessful\n");
}
return retval;
}