From: Bastian Dehn Date: Sun, 19 Nov 2017 17:06:42 +0000 (+0100) Subject: fix: Codestyle in discspan.c X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=2f5da41207b972e427974c53fb2244a70657f3c6;p=discspan.git fix: Codestyle in discspan.c --- diff --git a/discspan.c b/discspan.c index 101de81..1d63a39 100644 --- a/discspan.c +++ b/discspan.c @@ -5,9 +5,11 @@ #include #include "file_size.h" -void filecopy(const char *fsource, - const char *ftarget) { - FILE *source; FILE *target; +void filecopy(const char * fsource, + const char *ftarget) +{ + FILE *source; + FILE *target; char ch; source = fopen(fsource, "r"); @@ -21,17 +23,19 @@ void filecopy(const char *fsource, fclose(target); } -int exists(const char *fname) { +int exists(const char *fname) +{ struct stat buffer; - if (stat(fname, &buffer) == 0) { + if (stat(fname, &buffer) == 0) return 0; - } else { + else return 1; - } } -void printHumanReadSize(const char *output, unsigned long long int splitgroesse) { +void printHumanReadSize(const char *output, + unsigned long long int splitgroesse) +{ unsigned long long humanread; char einheit = 'B'; char i = 0; @@ -42,25 +46,30 @@ void printHumanReadSize(const char *output, unsigned long long int splitgroesse) humanread /= 1024; switch (i) { - case 1: - einheit = 'K'; - break; - case 2: - einheit = 'M'; - break; - case 3: - einheit = 'G'; - break; + case 1: + einheit = 'K'; + break; + case 2: + einheit = 'M'; + break; + case 3: + einheit = 'G'; + break; } } - printf("Restlicher Platz in Bytes(%s): %lld (%lld %c)\n", output, splitgroesse, humanread, einheit); + printf("Restlicher Platz in Bytes(%s): %lld (%lld %c)\n", + output, splitgroesse, humanread, einheit); } void splitter(const char *input, - char *output, const char *rest, - unsigned long long splitgroesse) { - FILE *in; FILE *out; FILE *re; + char *output, + const char *rest, + unsigned long long splitgroesse) +{ + FILE *in; + FILE *out; + FILE *re; in = fopen(input, "r"); out = fopen(output, "w"); @@ -79,9 +88,8 @@ void splitter(const char *input, splitgroesse -= filesize; fprintf(out, "%s\n", pfad); } else { - if (exists(rest) == 1) { + if (exists(rest) == 1) re = fopen(rest, "w"); - } fprintf(re, "%s\n", pfad); } @@ -90,35 +98,37 @@ void splitter(const char *input, fclose(in); fclose(out); - if (exists(rest) == 0) { + if (exists(rest) == 0) fclose(re); - } printHumanReadSize(output, splitgroesse); } int cmpfunc(const void *filea, - const void *fileb) { + const void *fileb) +{ long long unsigned int a = ((const struct file_size*) filea)->fsize; long long unsigned int b = ((const struct file_size*) fileb)->fsize; - if (a < b) { + if (a < b) return 1; - } else if (a > b) { + else if (a > b) return -1; - } else if (a == b) { + else if (a == b) return 0; - } else { + else return -2; - } } void filesize_sort(const char *input, - const char *output, - const long long unsigned int split) { + const char *output, + const long long unsigned int split) +{ // in: input Textdatei; out: output Textdatei; // ignore: output Textdatei; zugrosse Dateien - FILE *in; FILE *out; FILE *ignore; + FILE *in; + FILE *out; + FILE *ignore; char pfad[255]; struct stat st; int lines = 0; @@ -149,9 +159,8 @@ void filesize_sort(const char *input, lines++; } else { // irgnore List erstellen - if (exists("ignore") == 1) { + if (exists("ignore") == 1) ignore = fopen("ignore", "w"); - } fprintf(ignore, "%s\n", pfad); } @@ -170,12 +179,12 @@ void filesize_sort(const char *input, // schliesse alle Textdateien fclose(in); fclose(out); - if (exists("ignore") == 0) { + if (exists("ignore") == 0) fclose(ignore); - } } -void usage() { +void usage() +{ printf("\nUsage: discspan