#include "readfile.h"
#include "help.h"
+extern void (*printEvent)(const char *output, unsigned long long splitgroesse);
extern void useage();
extern file_size_t * read_input_file();
extern int splitter(file_size_t *input, const char *output,
}
}
+void printHumanReadSize(const char *output, unsigned long long splitgroesse)
+{
+ unsigned long long humanread;
+ char einheit[6] = {'B', 'K', 'M', 'G', 'T', 'P'};
+ int i = 0;
+
+ humanread = splitgroesse;
+ while (humanread >= 1024) {
+ humanread /= 1024;
+ i++;
+ }
+
+ if (i > sizeof(einheit)/sizeof(einheit[0]))
+ i = 0;
+
+ printf("Restlicher Platz in Bytes(%s): %lld (%lld %c)\n", output,
+ splitgroesse, humanread, einheit[i]);
+}
+
int main(int argc, char *argv[])
{
if (argc <= 3) {
return 1;
}
+ printEvent = printHumanReadSize;
const char *input = argv[1];
const char *output = argv[2];
#include "discspan.h"
#include "splitter.h"
-void printHumanReadSize(const char *output, unsigned long long splitgroesse)
-{
- unsigned long long humanread;
- char einheit[6] = {'B', 'K', 'M', 'G', 'T', 'P'};
- int i = 0;
-
- humanread = splitgroesse;
- while (humanread >= 1024) {
- humanread /= 1024;
- i++;
- }
-
- if (i > sizeof(einheit)/sizeof(einheit[0]))
- i = 0;
-
- printf("Restlicher Platz in Bytes(%s): %lld (%lld %c)\n", output,
- splitgroesse, humanread, einheit[i]);
-}
-
void writeOutputFile(const char *outputPath, file_size_t *disc, int length)
{
FILE *out = fopen(outputPath, "w");
fclose(out);
}
+void onPrintEvent(const char *output, unsigned long long splitgroesse)
+{
+ if (printEvent != NULL)
+ printEvent(output, splitgroesse);
+}
+
int splitter(file_size_t *input, const char *output,
unsigned long long splitgroesse, int length)
{
writeOutputFile(output, disc, disccount);
- printHumanReadSize(output, splitgroesse);
+ onPrintEvent(output, splitgroesse);
if (restcount > 0) {
memcpy(input, rest, length * sizeof(file_size_t));
#ifndef _SPLITTER_H
#define _SPLITTER_H
+/**
+ * PrintEvent umd Informationen Anzeigen zur laufzeit Anzeigen zu lassen.
+ *
+ * @param output Ausgabedateinamen
+ * @param splitgroesse die Bytes, die uebrig geblieben sind
+ */
+void (*printEvent)(const char *output, unsigned long long splitgroesse);
+
/**
* Schreibt in eine Datei die Pfade der Dateien, die auf das Medium passen. Wenn
* ein Rest uebrig bleibt wird das Array reallociert und die Restlange zurueck-