X-Git-Url: https://git.pterodactylus.net/?p=ecparse.git;a=blobdiff_plain;f=Main.cpp;h=8466ad802b056d45a31454b879104e521a14bb4b;hp=6b5f39f5b8f8b7ceec0a3a240efd146faff75ced;hb=7cb0ee62f4712e3f79b387ee0648da27551e9755;hpb=8a3f74ad0038469c00678280602c89e57482357c diff --git a/Main.cpp b/Main.cpp index 6b5f39f..8466ad8 100644 --- a/Main.cpp +++ b/Main.cpp @@ -15,7 +15,9 @@ int main(int argc, char** argv) { CollectionReader* collectionReader; char* currentArgument; char* fileToOpen = NULL; + FILE* file = NULL; int argumentIndex; + ED2KLink* nextLink = NULL; for (argumentIndex = 1; argumentIndex < argc; argumentIndex++) { currentArgument = argv[argumentIndex]; @@ -24,13 +26,29 @@ int main(int argc, char** argv) { } else if (!strcmp("--verbose", currentArgument) || !strcmp("-v", currentArgument)) { GlobalSettings::setVerbose(true); } else if (!strcmp("--file", currentArgument) || !strcmp("-f", currentArgument)) { - fileToOpen = currentArgument; + fileToOpen = argv[++argumentIndex]; } else { printf("Unknown Parameter: %s\n", currentArgument); return 1; } } + if (fileToOpen) { + file = fopen(fileToOpen, "r"); + fileReaderInput = new FileReaderInput(file); + } else { + fileReaderInput = new FileReaderInput(stdin); + } + + collectionReader = new CollectionReader(fileReaderInput); + while ((nextLink = collectionReader->getNextLink())) { + printf("%s\n", nextLink->getLink()); + } + + if (file) { + fclose(file); + } + return 0; }