]> gitweb.hhaalo.de Git - discspan.git/commitdiff
fix: codestyle discpan.c
authorBastian Dehn <hhaalo@arcor.de>
Sun, 3 Dec 2017 19:44:03 +0000 (20:44 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Sun, 3 Dec 2017 19:44:03 +0000 (20:44 +0100)
discspan.c

index 5ff9325c8e386b3432ee2602b551e2aedfce8ab7..33076392da71e4ef77db90e00af70ba225832873 100644 (file)
@@ -10,7 +10,7 @@ int exists(const char *fname)
 {
        struct stat buffer;
 
-       if (stat(fname, &buffer) == 0)
+       if(stat(fname, &buffer) == 0)
                return 0;
        else
                return 1;
@@ -23,11 +23,11 @@ void printHumanReadSize(const char *output, unsigned long long int splitgroesse)
        char i = 0;
 
        humanread = splitgroesse;
-       while (humanread >= 1024) {
+       while(humanread >= 1024) {
                i++;
                humanread /= 1024;
 
-               switch (i) {
+               switch(i) {
                case 1:
                        einheit = 'K';
                        break;
@@ -40,8 +40,8 @@ void printHumanReadSize(const char *output, unsigned long long int splitgroesse)
                }
        }
 
-       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,
@@ -58,17 +58,17 @@ void splitter(const char *input, char *output, const char *rest,
        unsigned long long filesize;
        struct stat st;
 
-       while (fscanf(in, "%[^\n]\n", pfad) == 1) {
+       while(fscanf(in, "%[^\n]\n", pfad) == 1) {
                stat(pfad, &st);
 
                // filesize inklusive overhead
                filesize = 33 + strlen(pfad) + st.st_size;
 
-               if (splitgroesse >= filesize) {
+               if(splitgroesse >= filesize) {
                        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);
@@ -78,7 +78,7 @@ void splitter(const char *input, char *output, const char *rest,
        fclose(in);
        fclose(out);
 
-       if (exists(rest) == 0)
+       if(exists(rest) == 0)
                fclose(re);
 
        printHumanReadSize(output, splitgroesse);
@@ -86,14 +86,14 @@ void splitter(const char *input, char *output, const char *rest,
 
 int cmpfunc(const void *filea, 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;
+       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
                return -2;
@@ -115,21 +115,21 @@ void filesize_sort(const char *input, const char *output,
        out = fopen(output, "w");
 
        // input-Datei Zeilenanzahl
-       while (fscanf(in, "%[^\n]\n", pfad) == 1) {
+       while(fscanf(in, "%[^\n]\n", pfad) == 1) {
                lines++;
        }
        fseek(in, 0L, SEEK_SET);
 
        // struct Array with Dateienanzahl
        struct file_size *fs = NULL;
-       fs = (struct file_size *) malloc((lines -1) * sizeof(struct file_size));
+       fs = (struct file_size *)malloc((lines - 1) * sizeof(struct file_size));
        lines = 0;
 
-       while (fscanf(in, "%[^\n]\n", pfad) == 1) {
+       while(fscanf(in, "%[^\n]\n", pfad) == 1) {
                // Lese Dateieigenschaften in st struct
                stat(pfad, &st);
 
-               if (st.st_size <= split) {
+               if(st.st_size <= split) {
                        // kopiert den pfad String ins struct
                        strcpy(fs[lines].name, pfad);
                        // Filesize in struct
@@ -137,28 +137,28 @@ void filesize_sort(const char *input, const char *output,
                        lines++;
                } else {
                        // irgnore List erstellen
-                       if (exists("ignore") == 1)
+                       if(exists("ignore") == 1)
                                ignore = fopen("ignore", "w");
 
                        fprintf(ignore, "%s\n", pfad);
                }
        }
 
-       fs = (struct file_size *)
-               realloc(fs, (lines+1) * sizeof(struct file_size));
+       fs = (struct file_size *)realloc(fs,
+                       (lines + 1) * sizeof(struct file_size));
 
        // sortiere das array fs mit stucts
        qsort(fs, lines, sizeof(struct file_size), cmpfunc);
 
        // schreibe in out die sortieren liste
-       for (int i = 0; i < lines; i++) {
+       for(int i = 0; i < lines; i++) {
                fprintf(out, "%s\n", fs[i].name);
        }
 
        // schliesse alle Textdateien
        fclose(in);
        fclose(out);
-       if (exists("ignore") == 0)
+       if(exists("ignore") == 0)
                fclose(ignore);
 }
 
@@ -199,14 +199,14 @@ int main(int argc, char *argv[])
        unsigned long long split = dvd5;
 
        // gib die Funktionsübersicht aus bei zu wenig Parameter
-       if (argc <= 3) {
+       if(argc <= 3) {
                usage();
                return 1;
        }
 
        // Lese Parameter ein
        int c;
-       while ((c = getopt(argc, argv, ":59bdcf:")) != -1) {
+       while((c = getopt(argc, argv, ":59bdcf:")) != -1) {
                switch(c) {
                case '5':
                        split = dvd5;
@@ -232,9 +232,9 @@ int main(int argc, char *argv[])
 
        char outname[sizeof output] = "";
        int num = 1;
-       while (exists(rest) == 0) {
-               sprintf(outname, "%s%03d", output , num++);
-               if (exists(rest) == 0) {
+       while(exists(rest) == 0) {
+               sprintf(outname, "%s%03d", output, num++);
+               if(exists(rest) == 0) {
                        filecopy(rest, work);
                        remove(rest);
                }