use gnu indent to enforce coding style and adapt source

- indent options are listed in ./.indent.pro
 - use test case to run indent
This commit is contained in:
josch
2014-09-20 10:59:54 +02:00
parent d8e00119b4
commit 097a855751
43 changed files with 1325 additions and 1278 deletions

View File

@@ -17,7 +17,6 @@
*
*/
#include <stdio.h>
#include <string.h>
@@ -25,18 +24,18 @@
#include "../mfshell.h"
#include "../../mfapi/folder.h"
#include "../../mfapi/mfconn.h"
#include "../commands.h" // IWYU pragma: keep
#include "../commands.h" // IWYU pragma: keep
int
mfshell_cmd_chdir(mfshell *mfshell, int argc, char **argv)
int mfshell_cmd_chdir(mfshell * mfshell, int argc, char **argv)
{
mffolder *folder_new;
const char *folder_curr;
const char *folder_parent;
const char *folderkey;
int retval;
mffolder *folder_new;
const char *folder_curr;
const char *folder_parent;
const char *folderkey;
int retval;
if(mfshell == NULL) return -1;
if (mfshell == NULL)
return -1;
if (argc != 2) {
fprintf(stderr, "Invalid number of arguments\n");
@@ -44,67 +43,60 @@ mfshell_cmd_chdir(mfshell *mfshell, int argc, char **argv)
}
folderkey = argv[1];
if(folderkey == NULL) return -1;
if (folderkey == NULL)
return -1;
// change to root
if(strcmp(folderkey,"/") == 0) folderkey = "myfiles";
if (strcmp(folderkey, "/") == 0)
folderkey = "myfiles";
// user wants to navigate up a level
if(strcmp(folderkey,"..") == 0)
{
if (strcmp(folderkey, "..") == 0) {
// do several sanity checks to see if we're already at the root
folder_curr = folder_get_key(mfshell->folder_curr);
if(folder_curr == NULL) return 0;
if(strcmp(folder_curr,"myfiles") == 0) return 0;
if (folder_curr == NULL)
return 0;
if (strcmp(folder_curr, "myfiles") == 0)
return 0;
folder_parent = folder_get_parent(mfshell->folder_curr);
if(folder_parent == NULL) return 0;
if (folder_parent == NULL)
return 0;
// it's pretty sure that we're not at the root
folderkey = folder_parent;
}
// check the lenght of the key
if(strlen(folderkey) != 13)
{
if (strlen(folderkey) != 13) {
// as a folder moniker, "myfiles" is an exception
if(strcmp(folderkey,"myfiles") != 0) return -1;
if (strcmp(folderkey, "myfiles") != 0)
return -1;
}
// create a new folder object to store the results
folder_new = folder_alloc();
// navigate to root is a special case
if(strcmp(folderkey,"myfiles") == 0)
{
folder_set_key(folder_new,"myfiles");
if (strcmp(folderkey, "myfiles") == 0) {
folder_set_key(folder_new, "myfiles");
retval = 0;
}
else
{
} else {
retval = mfconn_api_folder_get_info(mfshell->conn,
folder_new,(char*)folderkey);
folder_new, (char *)folderkey);
mfconn_update_secret_key(mfshell->conn);
}
if(retval == 0)
{
if(mfshell->folder_curr != NULL)
{
if (retval == 0) {
if (mfshell->folder_curr != NULL) {
folder_free(mfshell->folder_curr);
mfshell->folder_curr = NULL;
}
mfshell->folder_curr = folder_new;
}
else
{
} else {
folder_free(folder_new);
}
return retval;
}