Start using a Map

main
Alan Francis 1 year ago
parent b06089a99a
commit a97e790238
  1. 4
      configmodel.c
  2. 0
      containers/linearray.c
  3. 0
      containers/linearray.h
  4. 18
      containers/linemap.c
  5. 13
      containers/linemap.h
  6. 0
      containers/stringarray.c
  7. 0
      containers/stringarray.h
  8. 22
      main.c
  9. 15
      smakefile
  10. 2
      testconfig.cfg

@ -1,8 +1,8 @@
#include "configmodel.h"
#include "cregex/cregex.h"
#include "arraytypes/stringarray.h"
#include "arraytypes/linearray.h"
#include "containers/stringarray.h"
#include "containers/linearray.h"
#include <proto/exec.h>
#include <proto/dos.h>

@ -0,0 +1,18 @@
#include "linemap.h"
#include "linearray.h"
LineMap LineMapNew()
{
LineMap result = NewMap(CNTKIT_KEY_STRING,
CNTKIT_CAPACITY, 8,
CNTKIT_VALUESIZE, 4,
TAG_DONE);
return result;
}
VOID LineMapFree(LineMap map)
{
// doesnt seem to delete contents
DeleteMap(map);
}

@ -0,0 +1,13 @@
#ifndef __LINEMAP_H
#define __LINEMAP_H
#include <exec/types.h>
#include <proto/containerkit.h>
#include "configmodel.h"
#define LineMap Map
LineMap LineMapNew(VOID);
VOID LineMapFree(LineMap map);
#endif

@ -3,8 +3,8 @@
#include <proto/exec.h>
#include <proto/dos.h>
#define __NOLIBBASE__
#include "arraytypes/stringarray.h"
#include "arraytypes/linearray.h"
#include "containers/stringarray.h"
#include "containers/linearray.h"
#include "configmodel.h"
#include <proto/containerkit.h>
@ -16,24 +16,6 @@ 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;

@ -11,20 +11,20 @@ LIBS = lib:sc.lib lib:amiga.lib lib:debug.lib
###############################################################################
$(NAME) : main.o configmodel.o cregex/cregex.lib arraytypes/arraytypes.lib
slink lib:c.o main.o configmodel.o to $(NAME) noicons lib $(LIBS) cregex/cregex.lib arraytypes/arraytypes.lib $(LFLAGS)
$(NAME) : main.o configmodel.o cregex/cregex.lib containers/containers.lib
slink lib:c.o main.o configmodel.o to $(NAME) noicons lib $(LIBS) cregex/cregex.lib containers/containers.lib $(LFLAGS)
cregex/cregex.lib : cregex/cregex_compile.o cregex/cregex_parse.o cregex/cregex_vm.o
JOIN cregex/cregex_compile.o cregex/cregex_parse.o cregex/cregex_vm.o AS cregex/cregex.lib
arraytypes/arraytypes.lib : arraytypes/stringarray.o arraytypes/linearray.o
JOIN arraytypes/stringarray.o arraytypes/linearray.o AS arraytypes/arraytypes.lib
containers/containers.lib : containers/stringarray.o containers/linearray.o containers/linemap.o
JOIN containers/stringarray.o containers/linearray.o containers/linemap.o AS containers/containers.lib
clean:
delete \#?.o $(NAME) ALL QUIET
cleanlibs:
delete arraytypes/arraytypes.lib arraytypes/\#?.o cregex/cregex.lib cregex/\#?.o ALL QUIET
delete containers/containers.lib containers/\#?.o cregex/cregex.lib cregex/\#?.o ALL QUIET
###############################################################################
@ -35,5 +35,6 @@ cregex/cregex_compile.o : cregex/cregex_compile.c cregex/cregex.h
cregex/cregex_parse.o : cregex/cregex_parse.c cregex/cregex.h
cregex/cregex_vm.o : cregex/cregex_vm.c cregex/cregex.h
arraytypes/stringarray.o : arraytypes/stringarray.c arraytypes/stringarray.h
arraytypes/linearray.o : arraytypes/linearray.c arraytypes/linearray.h
containers/stringarray.o : containers/stringarray.c containers/stringarray.h
containers/linearray.o : containers/linearray.c containers/linearray.h
containers/linemap.o : containers/linemap.c containers/linemap.h

@ -1,7 +1,6 @@
#this is a comment
[core]
repositoryformatversion = 0
ignorecase = true
precomposeunicode = true
[remote "origin.foo"] #this is also a coment
@ -15,5 +14,4 @@
[branch "config-file-parsing-from-book"]
remote = origin
merge = refs/heads/config-file-parsing-from-book
somekey = Alan Francis

Loading…
Cancel
Save