Code formating
This commit is contained in:
@@ -2,12 +2,12 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "util.h"
|
|
||||||
#include "crc.h"
|
|
||||||
#include "fileutil.h"
|
|
||||||
#include "filenode.h"
|
|
||||||
#include "actionfilenode.h"
|
#include "actionfilenode.h"
|
||||||
#include "actionfilenodecopy.h"
|
#include "actionfilenodecopy.h"
|
||||||
|
#include "crc.h"
|
||||||
|
#include "filenode.h"
|
||||||
|
#include "fileutil.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
#define MaxDeltaTime 0
|
#define MaxDeltaTime 0
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#ifndef _ACTIONFILENODECOPY_H_
|
#ifndef _ACTIONFILENODECOPY_H_
|
||||||
#define _ACTIONFILENODECOPY_H_
|
#define _ACTIONFILENODECOPY_H_
|
||||||
|
|
||||||
#include "filenode.h"
|
|
||||||
#include "actionfilenode.h"
|
#include "actionfilenode.h"
|
||||||
|
#include "filenode.h"
|
||||||
|
|
||||||
ActionFileNode ActionFileNode_BuildCopy(FileNode fileNodeLeft,
|
ActionFileNode ActionFileNode_BuildCopy(FileNode fileNodeLeft,
|
||||||
FileNode fileNodeRight);
|
FileNode fileNodeRight);
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#ifndef _ACTIONFILENODESYNC_H_
|
#ifndef _ACTIONFILENODESYNC_H_
|
||||||
#define _ACTIONFILENODESYNC_H_
|
#define _ACTIONFILENODESYNC_H_
|
||||||
|
|
||||||
#include "filenode.h"
|
|
||||||
#include "actionfilenode.h"
|
#include "actionfilenode.h"
|
||||||
|
#include "filenode.h"
|
||||||
|
|
||||||
ActionFileNode ActionFileNode_BuildSync(FileNode fileNodeLeft,
|
ActionFileNode ActionFileNode_BuildSync(FileNode fileNodeLeft,
|
||||||
FileNode fileNodeRight);
|
FileNode fileNodeRight);
|
||||||
|
|||||||
@@ -2,10 +2,10 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "util.h"
|
|
||||||
#include "crc.h"
|
#include "crc.h"
|
||||||
#include "fileutil.h"
|
|
||||||
#include "filenode.h"
|
#include "filenode.h"
|
||||||
|
#include "fileutil.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
FileNode _freeFileNode = NULL;
|
FileNode _freeFileNode = NULL;
|
||||||
int _n_filenode = 0;
|
int _n_filenode = 0;
|
||||||
|
|||||||
@@ -2,29 +2,29 @@
|
|||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#define _WIN32_WINNT 0x0501
|
#define _WIN32_WINNT 0x0501
|
||||||
#include <direct.h>
|
#include <direct.h>
|
||||||
#include <windows.h>
|
|
||||||
#include <io.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <io.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <windows.h>
|
||||||
#else
|
#else
|
||||||
|
#include <dirent.h>
|
||||||
|
#include <errno.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <utime.h>
|
|
||||||
#include <dirent.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <errno.h>
|
#include <utime.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "util.h"
|
|
||||||
#include "fileutil.h"
|
#include "fileutil.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
long long FileTime_to_POSIX(FILETIME fileTime) {
|
long long FileTime_to_POSIX(FILETIME fileTime) {
|
||||||
|
|||||||
36
src/main.c
36
src/main.c
@@ -2,14 +2,14 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "util.h"
|
#include "actionfilenode.h"
|
||||||
|
#include "actionfilenodecopy.h"
|
||||||
|
#include "actionfilenodesync.h"
|
||||||
#include "crc.h"
|
#include "crc.h"
|
||||||
|
#include "filenode.h"
|
||||||
#include "fileutil.h"
|
#include "fileutil.h"
|
||||||
#include "parameteroperation.h"
|
#include "parameteroperation.h"
|
||||||
#include "filenode.h"
|
#include "util.h"
|
||||||
#include "actionfilenode.h"
|
|
||||||
#include "actionfilenodesync.h"
|
|
||||||
#include "actionfilenodecopy.h"
|
|
||||||
|
|
||||||
FileNode CheckDir(char *path, int recheck) {
|
FileNode CheckDir(char *path, int recheck) {
|
||||||
char dirNodesFile[MaxPath];
|
char dirNodesFile[MaxPath];
|
||||||
@@ -42,7 +42,8 @@ FileNode CheckDir(char *path, int recheck) {
|
|||||||
return fileNode;
|
return fileNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintStatistics(ActionFileNode actionFileNode, ActionFileNodeResult result) {
|
void PrintStatistics(ActionFileNode actionFileNode,
|
||||||
|
ActionFileNodeResult result) {
|
||||||
ActionQueueStatistics statistics;
|
ActionQueueStatistics statistics;
|
||||||
if (ActionFileNode_Statistics(actionFileNode, &statistics, result) == 0) {
|
if (ActionFileNode_Statistics(actionFileNode, &statistics, result) == 0) {
|
||||||
Print("Noting to do.\n");
|
Print("Noting to do.\n");
|
||||||
@@ -165,7 +166,8 @@ int Copy(char *pathLeft, char *pathRight, int reCheck, int dryRun) {
|
|||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct SApplicationConfiguration TApplicationConfiguration, *ApplicationConfiguration;
|
typedef struct SApplicationConfiguration TApplicationConfiguration,
|
||||||
|
*ApplicationConfiguration;
|
||||||
struct SApplicationConfiguration {
|
struct SApplicationConfiguration {
|
||||||
char *Dirs[10];
|
char *Dirs[10];
|
||||||
bool NoScan;
|
bool NoScan;
|
||||||
@@ -175,7 +177,8 @@ struct SApplicationConfiguration {
|
|||||||
bool NoAction;
|
bool NoAction;
|
||||||
char *Log;
|
char *Log;
|
||||||
};
|
};
|
||||||
TApplicationConfiguration defaultConfig = { {NULL}, false, false, false, false, false, NULL };
|
TApplicationConfiguration defaultConfig = {{NULL}, false, false, false,
|
||||||
|
false, false, NULL};
|
||||||
|
|
||||||
bool SetParam_Dir(int argc, char *argv[], void *data) {
|
bool SetParam_Dir(int argc, char *argv[], void *data) {
|
||||||
ApplicationConfiguration config = (ApplicationConfiguration)data;
|
ApplicationConfiguration config = (ApplicationConfiguration)data;
|
||||||
@@ -184,7 +187,9 @@ bool SetParam_Dir(int argc, char *argv[], void *data) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
char **destDir = config->Dirs;
|
char **destDir = config->Dirs;
|
||||||
while (destDir[0] != NULL) { destDir++; }
|
while (destDir[0] != NULL) {
|
||||||
|
destDir++;
|
||||||
|
}
|
||||||
destDir[0] = argv[0];
|
destDir[0] = argv[0];
|
||||||
destDir++;
|
destDir++;
|
||||||
destDir = NULL;
|
destDir = NULL;
|
||||||
@@ -305,7 +310,8 @@ TParameterOperation _parameterOperations[] = {
|
|||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
TApplicationConfiguration config = defaultConfig;
|
TApplicationConfiguration config = defaultConfig;
|
||||||
|
|
||||||
int parameterParsingResult = ParameterOperation_Parse(argc, argv, _parameterOperations, &config);
|
int parameterParsingResult =
|
||||||
|
ParameterOperation_Parse(argc, argv, _parameterOperations, &config);
|
||||||
if (parameterParsingResult <= 0) {
|
if (parameterParsingResult <= 0) {
|
||||||
ParameterOperation_PrintHelp(_parameterOperations);
|
ParameterOperation_PrintHelp(_parameterOperations);
|
||||||
return 0;
|
return 0;
|
||||||
@@ -314,7 +320,8 @@ int main(int argc, char *argv[]) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Print("\n================================ FileSync ===================================\n");
|
Print("\n================================ FileSync "
|
||||||
|
"===================================\n");
|
||||||
|
|
||||||
if (config.Copy == false && config.Sync == false) {
|
if (config.Copy == false && config.Sync == false) {
|
||||||
Print("Error: Action not specified.\n");
|
Print("Error: Action not specified.\n");
|
||||||
@@ -325,12 +332,13 @@ int main(int argc, char *argv[]) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (config.Copy) {
|
if (config.Copy) {
|
||||||
Copy(config.Dirs[0], config.Dirs[1], (config.NoScan == false), config.Dummy);
|
Copy(config.Dirs[0], config.Dirs[1], (config.NoScan == false),
|
||||||
|
config.Dummy);
|
||||||
}
|
}
|
||||||
if (config.Sync) {
|
if (config.Sync) {
|
||||||
Sync(config.Dirs[0], config.Dirs[1], (config.NoScan == false), config.Dummy);
|
Sync(config.Dirs[0], config.Dirs[1], (config.NoScan == false),
|
||||||
|
config.Dummy);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,17 @@
|
|||||||
#include "util.h"
|
|
||||||
#include "parameteroperation.h"
|
#include "parameteroperation.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
int ParameterOperation_Parse(int argumentCount, char *arguments[], TParameterOperation parameterOperations[], void *data) {
|
int ParameterOperation_Parse(int argumentCount, char *arguments[],
|
||||||
|
TParameterOperation parameterOperations[],
|
||||||
|
void *data) {
|
||||||
int processedParams = 0;
|
int processedParams = 0;
|
||||||
char **currentArguments = arguments + 1;
|
char **currentArguments = arguments + 1;
|
||||||
for (int i = 1; i < argumentCount; i++) {
|
for (int i = 1; i < argumentCount; i++) {
|
||||||
char *currentArgument = currentArguments[0];
|
char *currentArgument = currentArguments[0];
|
||||||
currentArguments++;
|
currentArguments++;
|
||||||
if (currentArgument[0] != '-') {
|
if (currentArgument[0] != '-') {
|
||||||
Print("Error: Garbage found \"%s\" in position %d.\n", arguments[i], i + 1);
|
Print("Error: Garbage found \"%s\" in position %d.\n", arguments[i],
|
||||||
|
i + 1);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
while (currentArgument[0] == '-') {
|
while (currentArgument[0] == '-') {
|
||||||
@@ -18,14 +21,19 @@ int ParameterOperation_Parse(int argumentCount, char *arguments[], TParameterOpe
|
|||||||
int j = 0;
|
int j = 0;
|
||||||
while (parameterOperations[j].Name != NULL) {
|
while (parameterOperations[j].Name != NULL) {
|
||||||
ParameterOperation parameterOperation = ¶meterOperations[j];
|
ParameterOperation parameterOperation = ¶meterOperations[j];
|
||||||
if (String_CompareCaseInsensitive(currentArgument, parameterOperation->Name) == 0) {
|
if (String_CompareCaseInsensitive(currentArgument,
|
||||||
|
parameterOperation->Name) == 0) {
|
||||||
if ((i + parameterOperation->NumItems) >= argumentCount) {
|
if ((i + parameterOperation->NumItems) >= argumentCount) {
|
||||||
Print("Error: Parsing parameter \"-%s\" in position %d, missig parameter data.\n", parameterOperations[j].Name, i + 1);
|
Print("Error: Parsing parameter \"-%s\" in position %d, "
|
||||||
|
"missig parameter data.\n",
|
||||||
|
parameterOperations[j].Name, i + 1);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
bool result = parameterOperation->SetFunc(parameterOperation->NumItems, currentArguments, data);
|
bool result = parameterOperation->SetFunc(
|
||||||
|
parameterOperation->NumItems, currentArguments, data);
|
||||||
if (result == false) {
|
if (result == false) {
|
||||||
Print("Error: Parsing parameter \"-%s\" in position %d.\n", parameterOperations[j].Name, i + 1);
|
Print("Error: Parsing parameter \"-%s\" in position %d.\n",
|
||||||
|
parameterOperations[j].Name, i + 1);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
currentArguments += parameterOperation->NumItems;
|
currentArguments += parameterOperation->NumItems;
|
||||||
@@ -37,7 +45,8 @@ int ParameterOperation_Parse(int argumentCount, char *arguments[], TParameterOpe
|
|||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
if (processed == false) {
|
if (processed == false) {
|
||||||
Print("Error: Unknow parameter \"%s\" in position %d.\n", arguments[i], i + 1);
|
Print("Error: Unknow parameter \"%s\" in position %d.\n",
|
||||||
|
arguments[i], i + 1);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,9 @@ struct SParameterOperation {
|
|||||||
bool (*SetFunc)(int argumentCount, char *arguments[], void *data);
|
bool (*SetFunc)(int argumentCount, char *arguments[], void *data);
|
||||||
};
|
};
|
||||||
|
|
||||||
int ParameterOperation_Parse(int argumentCount, char *arguments[], TParameterOperation parameterOperations[], void *data);
|
int ParameterOperation_Parse(int argumentCount, char *arguments[],
|
||||||
|
TParameterOperation parameterOperations[],
|
||||||
|
void *data);
|
||||||
|
|
||||||
void ParameterOperation_PrintHelp(TParameterOperation parameterOperations[]);
|
void ParameterOperation_PrintHelp(TParameterOperation parameterOperations[]);
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <stdarg.h>
|
|
||||||
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
@@ -158,18 +158,18 @@ int PrintDataSize(long long size) {
|
|||||||
return Print("% 8.3f TiB", tibSize);
|
return Print("% 8.3f TiB", tibSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FILE *outFile = NULL;
|
FILE *outFile = NULL;
|
||||||
|
|
||||||
/////////////////////////////
|
/////////////////////////////
|
||||||
// Print_SetOutFile
|
// Print_SetOutFile
|
||||||
//
|
//
|
||||||
void Print_SetOutFile(char *fileOut) {
|
void Print_SetOutFile(char *fileOut) {
|
||||||
if (fileOut == NULL) { return; }
|
if (fileOut == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
outFile = fopen(fileOut, "a");
|
outFile = fopen(fileOut, "a");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define Print_BuferSize 4096
|
#define Print_BuferSize 4096
|
||||||
/////////////////////////////
|
/////////////////////////////
|
||||||
// Print
|
// Print
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
#ifndef _UTIL_
|
#ifndef _UTIL_
|
||||||
#define _UTIL_
|
#define _UTIL_
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#ifndef bool
|
||||||
typedef int bool;
|
typedef int bool;
|
||||||
|
#endif
|
||||||
#define true 1
|
#define true 1
|
||||||
#define false 0
|
#define false 0
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user