X-Git-Url: https://git.pterodactylus.net/?p=ecparse.git;a=blobdiff_plain;f=Main.cpp;h=8466ad802b056d45a31454b879104e521a14bb4b;hp=aa44bdcaa909b3327758a3869e193eb446ff6151;hb=b85b2b73e8493ad0f379da96f87d0d3e12c56413;hpb=5e0a94e6216815749aebab3950abcb7522e314d5 diff --git a/Main.cpp b/Main.cpp index aa44bdc..8466ad8 100644 --- a/Main.cpp +++ b/Main.cpp @@ -2,11 +2,52 @@ * © 2008 by David Roden */ +#include #include "Main.h" +void printSyntaxHelp() { + printf("ecparse %s - © 2008 by David ‘Bombe’ Roden ]\n"); +} + int main(int argc, char** argv) { FileReaderInput* fileReaderInput; CollectionReader* collectionReader; + char* currentArgument; + char* fileToOpen = NULL; + FILE* file = NULL; + int argumentIndex; + ED2KLink* nextLink = NULL; + + for (argumentIndex = 1; argumentIndex < argc; argumentIndex++) { + currentArgument = argv[argumentIndex]; + if (!strcmp("--help", currentArgument) || !strcmp("-h", currentArgument)) { + printSyntaxHelp(); + } else if (!strcmp("--verbose", currentArgument) || !strcmp("-v", currentArgument)) { + GlobalSettings::setVerbose(true); + } else if (!strcmp("--file", currentArgument) || !strcmp("-f", 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; }