// Printf("running (%ld bytes avail)\n", AvailMem(0)); #define __CLIB_PRAGMA_LIBCALL #include #include #define __NOLIBBASE__ #include "arraytypes/stringarray.h" #include "arraytypes/linearray.h" #include "configmodel.h" #include WORD DoTheWork(STRPTR filename); VOID ProcessFile(BPTR configFile); char *vers="\0$VER: ConfigReader (dd.mm.yyyy)"; char *stacksize = "$STACK:8192"; // only works when started from CLI struct Library *ContainerkitBase; VOID ProcessFile(BPTR configFile) { Array lineArray = NULL; LINEPTR line = NULL; InitialisePatterns(); lineArray = LineArrayNew(); line = LineReadIncludingContinuation(configFile); while( line != NULL ) { // Printf("successfully read line {%s}\n", LineGetRawText(line)); LineArrayAppend(lineArray, line); line = LineReadIncludingContinuation(configFile); } LineArrayFree(lineArray, TRUE); ReleasePatterns(); } WORD DoTheWork(STRPTR filename) { WORD result = RETURN_OK; if (ContainerkitBase) { CONFIGFILEPTR config = ConfigFileRead(filename); if( config != NULL ) { ConfigFileFree(config); } else { result = RETURN_ERROR; } } return result; } WORD main(WORD argc, STRPTR *argv) { WORD result = RETURN_OK; // this does nothing but the first call to Print drops a bunch of memory, // I assume because of opening some resource so this means my start and // end markers are "clean" and I can ensure I'm not leaking. Printf("\n"); ContainerkitBase = OpenLibrary("containerkit.library", 1); if( ContainerkitBase ) { Printf("\n\nrunning (%ld bytes avail)\n\n", AvailMem(0)); result = DoTheWork(argv[1]); Printf("\n\ndone (%ld bytes avail)\n\n", AvailMem(0)); CloseLibrary(ContainerkitBase); } else { Printf("failed to open library\n"); result = RETURN_ERROR; } return result; }