moved src files to src subdirectory and added licence text

Fri, 28 Dec 2012 15:44:28 +0100

author
Mike Becker <universe@uap-core.de>
date
Fri, 28 Dec 2012 15:44:28 +0100
changeset 34
fa9bda32de17
parent 33
1a2d7298bc82
child 35
35120de6ee53

moved src files to src subdirectory and added licence text

.hgignore file | annotate | diff | comparison | revisions
Makefile file | annotate | diff | comparison | revisions
arguments.c file | annotate | diff | comparison | revisions
arguments.h file | annotate | diff | comparison | revisions
bfile_heuristics.c file | annotate | diff | comparison | revisions
bfile_heuristics.h file | annotate | diff | comparison | revisions
cline.c file | annotate | diff | comparison | revisions
cline.h file | annotate | diff | comparison | revisions
gcc-debug.mk file | annotate | diff | comparison | revisions
gcc.mk file | annotate | diff | comparison | revisions
mingw-debug.mk file | annotate | diff | comparison | revisions
mingw.mk file | annotate | diff | comparison | revisions
nbproject/Package-Default.bash file | annotate | diff | comparison | revisions
nbproject/configurations.xml file | annotate | diff | comparison | revisions
nbproject/private/Default.properties file | annotate | diff | comparison | revisions
nbproject/private/configurations.xml file | annotate | diff | comparison | revisions
nbproject/private/private.xml file | annotate | diff | comparison | revisions
nbproject/project.xml file | annotate | diff | comparison | revisions
regex_parser.c file | annotate | diff | comparison | revisions
regex_parser.h file | annotate | diff | comparison | revisions
scanner.c file | annotate | diff | comparison | revisions
scanner.h file | annotate | diff | comparison | revisions
settings.c file | annotate | diff | comparison | revisions
settings.h file | annotate | diff | comparison | revisions
src/arguments.c file | annotate | diff | comparison | revisions
src/arguments.h file | annotate | diff | comparison | revisions
src/bfile_heuristics.c file | annotate | diff | comparison | revisions
src/bfile_heuristics.h file | annotate | diff | comparison | revisions
src/cline.c file | annotate | diff | comparison | revisions
src/cline.h file | annotate | diff | comparison | revisions
src/regex_parser.c file | annotate | diff | comparison | revisions
src/regex_parser.h file | annotate | diff | comparison | revisions
src/scanner.c file | annotate | diff | comparison | revisions
src/scanner.h file | annotate | diff | comparison | revisions
src/settings.c file | annotate | diff | comparison | revisions
src/settings.h file | annotate | diff | comparison | revisions
src/stdinc.h file | annotate | diff | comparison | revisions
src/stream.c file | annotate | diff | comparison | revisions
src/stream.h file | annotate | diff | comparison | revisions
src/string_list.c file | annotate | diff | comparison | revisions
src/string_list.h file | annotate | diff | comparison | revisions
src/suffix_fnc.c file | annotate | diff | comparison | revisions
src/suffix_fnc.h file | annotate | diff | comparison | revisions
stdinc.h file | annotate | diff | comparison | revisions
stream.c file | annotate | diff | comparison | revisions
stream.h file | annotate | diff | comparison | revisions
string_list.c file | annotate | diff | comparison | revisions
string_list.h file | annotate | diff | comparison | revisions
suffix_fnc.c file | annotate | diff | comparison | revisions
suffix_fnc.h file | annotate | diff | comparison | revisions
--- a/.hgignore	Tue Oct 02 10:49:25 2012 +0200
+++ b/.hgignore	Fri Dec 28 15:44:28 2012 +0100
@@ -1,3 +1,8 @@
 syntax: regexp
 ^build/.*$
 
+\.orig\..*$
+\.orig$
+\.chg\..*$
+\.rej$
+\.conflict\~$
--- a/Makefile	Tue Oct 02 10:49:25 2012 +0200
+++ b/Makefile	Fri Dec 28 15:44:28 2012 +0100
@@ -38,6 +38,10 @@
 #endif
 
 VERSION_PREFIX=1.0.
+SRCDIR=src/
+BUILDDIR=build/
+OBJ = $(shell ls ${SRCDIR} | grep '\.c' | sed 's/^\([^.]*\)\.c$$/${BUILDDIR:/=\/}\1.o/g' | tr '\n' ' ')
+BIN = ${BUILDDIR}cline
 
 include ${CONF}.mk
 
@@ -52,17 +56,19 @@
 compile: ${OBJ}
 	${LD} -o ${BIN} ${OBJ} ${LDFLAGS}
 
-setup:
-	mkdir -p ${BUILDDIR}
+setup: ${BUILDDIR}
 	rm -f ${BUILDDIR}cline.o
-	mv cline.h cline.src
-	cat cline.src | sed "s/VERSION.*/VERSION=\"${VERSION_PREFIX}$(shell hg identify -n) ($(shell hg identify -i))\";/g" > cline.h
+	mv ${SRCDIR}cline.h ${SRCDIR}cline.src
+	cat ${SRCDIR}cline.src | sed "s/VERSION.*/VERSION=\"${VERSION_PREFIX}$(shell hg identify -n) ($(shell hg identify -i))\";/g" > ${SRCDIR}cline.h
+	
+${BUILDDIR}:
+	mkdir ${BUILDDIR}
 	
 teardown:
-	rm -f cline.h
-	mv cline.src cline.h
+	rm -f ${SRCDIR}cline.h
+	mv ${SRCDIR}cline.src ${SRCDIR}cline.h
 
-${BUILDDIR}%.o: %.c
+${BUILDDIR}%.o: ${SRCDIR}%.c
 	${CC} ${CFLAGS} -c -o ${BUILDDIR}$*.o $<
 
 clean:
--- a/arguments.c	Tue Oct 02 10:49:25 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * arguments.c
- *
- *  Created on: 15.09.2011
- *      Author: Mike
- */
-
-#include "arguments.h"
-
-int checkArgument(const char* arg, const char* expected) {
-  int len = strlen(expected);
-  int ret = 0;
-
-  if (arg[0] == '-') {
-    if (arg[1] != '-') {
-      for (int t = 0 ; t < len ; t++) {
-        ret |= (strchr(arg, expected[t]) > 0) << t;
-      }
-    }
-  }
-
-  return ret;
-}
-
-bool registerArgument(int* reg, int mask) {
-  bool ret = (*reg & mask) > 0;
-  *reg |= mask;
-  return ret;
-}
-
-bool checkParamOpt(int* paropt) {
-  bool ret = *paropt == 0;
-  *paropt = 1;
-  return ret;
-}
-
-void parseCSL(char* csl, string_list_t* list) {
-  if (csl != NULL) {
-    char* finder = strtok(csl, ",");
-    while (finder != NULL) {
-      add_string(list, finder);
-      finder = strtok(NULL, ",");
-    }
-  }
-}
--- a/arguments.h	Tue Oct 02 10:49:25 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-/*
- * arguments.h
- *
- *  Created on: 15.09.2011
- *      Author: Mike
- */
-
-#ifndef ARGUMENTS_H_
-#define ARGUMENTS_H_
-
-#include "stdinc.h"
-#include "string_list.h"
-
-#ifdef _cplusplus
-extern "C" {
-#endif
-
-int checkArgument(const char*, const char*);
-bool checkParamOpt(int*);
-bool registerArgument(int*, int);
-void parseCSL(char*, string_list_t*);
-
-#ifdef _cplusplus
-}
-#endif
-
-#endif /* ARGUMENTS_H_ */
--- a/bfile_heuristics.c	Tue Oct 02 10:49:25 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,57 +0,0 @@
-/*
- * bfile_heuristics.c
- *
- *  Created on: 20.10.2011
- *      Author: Mike
- */
-
-#include "bfile_heuristics.h"
-#include <ctype.h>
-
-bfile_heuristics_t *new_bfile_heuristics_t() {
-  bfile_heuristics_t *ret = malloc(sizeof(bfile_heuristics_t));
-  ret->level = BFILE_MEDIUM_ACCURACY;
-  bfile_reset(ret);
-  return ret;
-}
-
-void destroy_bfile_heuristics_t(bfile_heuristics_t *def) {
-  free(def);
-}
-
-void bfile_reset(bfile_heuristics_t *def) {
-  def->bcount = 0;
-  def->tcount = 0;
-}
-
-bool bfile_check(bfile_heuristics_t *def, int next_char) {
-  bool ret = false;
-  if (def->level != BFILE_IGNORE) {
-    def->tcount++;
-    if (!isprint(next_char) && !isspace(next_char)) {
-      def->bcount++;
-    }
-
-    if (def->tcount > 1) { /* empty files are text files */
-      switch (def->level) {
-      case BFILE_LOW_ACCURACY:
-        if (def->tcount > 15 || next_char == EOF) {
-          ret = (1.0*def->bcount)/def->tcount > 0.32;
-        }
-        break;
-      case BFILE_HIGH_ACCURACY:
-        if (def->tcount > 500 || next_char == EOF) {
-          ret = (1.0*def->bcount)/def->tcount > 0.1;
-        }
-        break;
-      default: /* BFILE_MEDIUM_ACCURACY */
-        if (def->tcount > 100 || next_char == EOF) {
-          ret = (1.0*def->bcount)/def->tcount > 0.1;
-        }
-        break;
-      }
-    }
-  }
-
-  return ret;
-}
--- a/bfile_heuristics.h	Tue Oct 02 10:49:25 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +0,0 @@
-/*
- * bfile_heuristics.h
- *
- *  Created on: 20.10.2011
- *      Author: Mike
- */
-
-#ifndef BFILE_HEURISTICS_H_
-#define BFILE_HEURISTICS_H_
-
-#include "stdinc.h"
-
-#define BFILE_IGNORE           0x00
-#define BFILE_LOW_ACCURACY     0x01
-#define BFILE_MEDIUM_ACCURACY  0x02
-#define BFILE_HIGH_ACCURACY    0x04
-
-typedef struct {
-  unsigned int level;
-  unsigned int bcount; /* 'binary' character count */
-  unsigned int tcount; /* total count */
-} bfile_heuristics_t;
-
-#ifdef _cplusplus
-extern "C" {
-#endif
-
-bfile_heuristics_t *new_bfile_heuristics_t();
-void destroy_bfile_heuristics_t(bfile_heuristics_t *def);
-void bfile_reset(bfile_heuristics_t *def);
-bool bfile_check(bfile_heuristics_t *def, int next_char);
-
-#ifdef _cplusplus
-}
-#endif
-
-#endif /* BFILE_HEURISTICS_H_ */
--- a/cline.c	Tue Oct 02 10:49:25 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,247 +0,0 @@
-/*
- * cline.c
- *
- *  Created on: 23.05.2011
- *      Author: Mike
- */
-
-#include "cline.h"
-#include "scanner.h"
-#include "settings.h"
-#include "arguments.h"
-#include "stream.h"
-#include "regex_parser.h"
-
-void printHelpText() {
-  const char* helpText = 
-    "\nUsage:"
-    "\n      cline [Options] [Directories...]"
-    "\n      cline [Options] [Directories...]"
-    "\n\nCounts the line terminator characters (\\n) within all"
-    " files in the specified\ndirectories."
-    "\n\nOptions:"
-    "\n  -b <level>          - binary file heuristics level (default medium)"
-    "\n                        One of: ignore low medium high"
-    "\n  -E <pattern>        - Excludes any line matching the <pattern>"
-    "\n  -e <start> <end>    - Excludes lines between <start> and <end>"
-    "\n                        You may use these options multiple times"
-    "\n  -h, --help          - this help text"
-    "\n  -m                  - print information about matching files only"
-    "\n  -s <suffixes>       - only count files with these suffixes (separated"
-    "\n                        by commas)"
-    "\n  -S <suffixes>       - count any file except those with these suffixes"
-    "\n                        (separated by commas)"
-    "\n  -r, -R              - includes subdirectories"
-    "\n  -v, --version       - print out version information"
-    "\n  -V                  - turn verbose output off, print the result only"
-    "\n\nShortcuts:"
-    "\n  --exclude-cstyle-comments"
-    "\n = -E \"\\s*//\" -e \"\\s*/\\*\" \"\\*/\\s*\""
-    "\n\n"
-    "The default call without any options is:"    
-    "\n  cline ./\n\n"
-    "So each file in the working directory is counted. If you want to count C"
-    "\nsource code in your working directory and its subdirectories, type:"
-    "\n  cline -rs .c\n"
-    "\nIf you want to exclude comment lines, you may use the -e/-E option."
-    "\nAfter a line matches the regex pattern <start> any following line is"
-    "\nnot counted unless a line matches the <end> pattern. A line is still "
-    "\ncounted when it does not start or end with the respective patterns."
-    "\nPlease note, that cline does not remove whitespace characters as this"
-    "\nmight not be reasonable in some cases."
-    "\n\nExample (C without comments):"
-    "\n  cline -s .c,.h --exclude-cstyle-comments";
-    
-  printf(helpText);
-}
-
-int exit_with_version(settings_t* settings) {
-  printf("cline - Revision: %s\n", VERSION);
-  destroy_settings_t(settings);
-  return 0;
-}
-
-int exit_with_help(settings_t* settings, int code) {
-  printHelpText();
-  destroy_settings_t(settings);
-  return code;
-}
-
-int main(int argc, char** argv) {
-
-  /* Settings */
-  settings_t *settings = new_settings_t();
-  if (settings == NULL) {
-    fprintf(stderr, "Memory allocation failed.\n");
-    return 1;
-  }
-
-  /* Get arguments */
-  string_list_t *directories = new_string_list_t();
-  if (directories == NULL) {
-    fprintf(stderr, "Memory allocation failed.\n");
-    return 1;
-  }
-  char* includeSuffix = NULL;
-  char* excludeSuffix = NULL;
-  int checked = 0;
-
-  for (int t = 1 ; t < argc ; t++) {
-
-    int argflags = checkArgument(argv[t], "hsSrRmvVbeE");
-    int paropt = 0;
-
-    /* s */
-    if ((argflags & 2) > 0) {
-      if (!checkParamOpt(&paropt) || registerArgument(&checked, 2)) {
-        return exit_with_help(settings, 1);
-      }
-      t++;
-      if (t >= argc) {
-        return exit_with_help(settings, 1);
-      }
-      includeSuffix = argv[t];
-    }
-    /* S */
-    if ((argflags & 4) > 0) {
-      if (!checkParamOpt(&paropt) || registerArgument(&checked, 4)) {
-        return exit_with_help(settings, 1);
-      }
-      t++;
-      if (t >= argc) {
-        return exit_with_help(settings, 1);
-      }
-      excludeSuffix = argv[t];
-    }
-    /* h */
-    if ((argflags & 1) > 0 || strcmp(argv[t], "--help") == 0) {
-      return exit_with_help(settings, 0);
-    }
-    /* r, R */
-    if ((argflags & 24) > 0) {
-      if (registerArgument(&checked, 24)) {
-        return exit_with_help(settings, 1);
-      }
-      settings->recursive = true;
-    }
-    /* m */
-    if ((argflags & 32) > 0) {
-      if (registerArgument(&checked, 32)) {
-        return exit_with_help(settings, 1);
-      }
-      settings->matchesOnly = true;
-    }
-    /* v */
-    if ((argflags & 64) > 0 || strcmp(argv[t], "--version") == 0) {
-      return exit_with_version(settings);
-    }
-    /* V */
-    if ((argflags & 128) > 0) {
-      if (registerArgument(&checked, 128)) {
-        return exit_with_help(settings, 1);
-      }
-      settings->verbose = false;
-    }
-    /* b */
-    if ((argflags & 256) > 0) {
-      if (!checkParamOpt(&paropt) || registerArgument(&checked, 256)) {
-        return exit_with_help(settings, 1);
-      }
-      t++;
-      if (t >= argc) {
-        return exit_with_help(settings, 1);
-      }
-      if (strcasecmp(argv[t], "ignore") == 0) {
-        settings->bfileHeuristics->level = BFILE_IGNORE;
-      } else if (strcasecmp(argv[t], "low") == 0) {
-        settings->bfileHeuristics->level = BFILE_LOW_ACCURACY;
-      } else if (strcasecmp(argv[t], "medium") == 0) {
-        settings->bfileHeuristics->level = BFILE_MEDIUM_ACCURACY;
-      } else if (strcasecmp(argv[t], "high") == 0) {
-        settings->bfileHeuristics->level = BFILE_HIGH_ACCURACY;
-      } else {
-        return exit_with_help(settings, 1);
-      }
-    }
-    /* e */
-    if ((argflags & 512) > 0) {
-      if (!checkParamOpt(&paropt) || t + 2 >= argc) {
-        return exit_with_help(settings, 1);
-      }
-      t++; add_string(settings->regex->pattern_list, argv[t]);
-      t++; add_string(settings->regex->pattern_list, argv[t]);
-    }
-    /* E */
-    if ((argflags & 1024) > 0) {
-      t++;
-      if (!checkParamOpt(&paropt) || t >= argc) {
-        return exit_with_help(settings, 1);
-      }
-      add_string(settings->regex->pattern_list, argv[t]);
-      add_string(settings->regex->pattern_list, "$");
-    }
-    if (argflags == 0) {
-      /* SHORTCUTS */
-      /* exclude-cstyle-comments */
-      if (strcmp(argv[t], "--exclude-cstyle-comments") == 0) {
-        add_string(settings->regex->pattern_list, "\\s*//");
-        add_string(settings->regex->pattern_list, "$");
-        add_string(settings->regex->pattern_list, "\\s*/\\*");
-        add_string(settings->regex->pattern_list, "\\*/\\s*");
-      }
-      /* Path */
-      else {
-        add_string(directories, argv[t]);
-      }
-    }
-  }
-
-  /* Configure output */
-  if (!settings->verbose) {
-    close_stdout();
-  }
-
-  /* Find tokens */
-  parseCSL(includeSuffix, settings->includeSuffixes);
-  parseCSL(excludeSuffix, settings->excludeSuffixes);
-
-  /* Scan directories */
-  if (regex_compile_all(settings->regex)) {
-    int lines = 0;
-    if (directories->count == 0) {
-        add_string(directories, ".");
-    }
-    for (int t = 0 ; t < directories->count ; t++) {
-      if (t > 0) {
-          for (int u = 0 ; u < 79 ; u++) {
-              printf("-");
-          }
-          printf("\n");
-      }
-      lines += scanDirectory((scanner_t){directories->items[t], 0}, settings);
-    }
-    destroy_string_list_t(directories);
-
-    /* Print double line and line count */
-    for (int t = 0 ; t < 79 ; t++) {
-      printf("=");
-    }
-    printf("\n%73d lines\n", lines);
-
-    if (settings->confusing_lnlen && settings->regex->pattern_list->count > 0) {
-      printf("\nSome files contain too long lines.\n"
-        "The regex parser currently supports a maximum line length of %d."
-        "\nThe result might be wrong.\n", REGEX_MAX_LINELENGTH);
-    }
-
-    if (!settings->verbose) {
-      reopen_stdout();
-      printf("%d", lines);
-    }
-    destroy_settings_t(settings);
-  }
-
-  fflush(stdout);
-  fflush(stderr);
-  return 0;
-}
--- a/cline.h	Tue Oct 02 10:49:25 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-/*
- * cline.h
- *
- *  Created on: 23.05.2011
- *      Author: Mike
- */
-
-#ifndef CLINE_H_
-#define CLINE_H_
-
-const char* VERSION=""; /* will be replaced by makefile */
-
-#include "stdinc.h"
-#include "settings.h"
-
-#ifdef _cplusplus
-extern "C" {
-#endif
-
-void printHelpText();
-int exit_with_version(settings_t*);
-int exit_with_help(settings_t*, int);
-
-#ifdef _cplusplus
-}
-#endif
-
-#endif /* CLINE_H_ */
--- a/gcc-debug.mk	Tue Oct 02 10:49:25 2012 +0200
+++ b/gcc-debug.mk	Fri Dec 28 15:44:28 2012 +0100
@@ -1,34 +1,31 @@
-#
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 
-#
-# Copyright 2011 Mike Becker. All rights reserved.
-# 
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are met:
-# 
-# 1. Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# 
-# 2. Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-# 
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
-#
-
-CC = gcc
-LD = gcc
-CFLAGS = -Wall -std=gnu99 -O0 -ggdb
-LDFLAGS = 
-BUILDDIR = build/
-OBJ = $(shell ls | grep '\.c' | sed 's/^\([^.]*\)\.c$$/${BUILDDIR:/=\/}\1.o/g' | tr '\n' ' ')
-BIN = ${BUILDDIR}cline
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 
+#
+# Copyright 2011 Mike Becker. All rights reserved.
+# 
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+# 
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+#
+
+CC = gcc
+LD = gcc
+CFLAGS = -Wall -std=gnu99 -O0 -ggdb
+LDFLAGS = 
--- a/gcc.mk	Tue Oct 02 10:49:25 2012 +0200
+++ b/gcc.mk	Fri Dec 28 15:44:28 2012 +0100
@@ -1,34 +1,31 @@
-#
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 
-#
-# Copyright 2011 Mike Becker. All rights reserved.
-# 
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are met:
-# 
-# 1. Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# 
-# 2. Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-# 
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
-#
-
-CC = gcc
-LD = gcc
-CFLAGS = -Wall -std=gnu99 -O
-LDFLAGS = 
-BUILDDIR = build/
-OBJ = $(shell ls | grep '\.c' | sed 's/^\([^.]*\)\.c$$/${BUILDDIR:/=\/}\1.o/g' | tr '\n' ' ')
-BIN = ${BUILDDIR}cline
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 
+#
+# Copyright 2011 Mike Becker. All rights reserved.
+# 
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+# 
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+#
+
+CC = gcc
+LD = gcc
+CFLAGS = -Wall -std=gnu99 -O
+LDFLAGS = 
--- a/mingw-debug.mk	Tue Oct 02 10:49:25 2012 +0200
+++ b/mingw-debug.mk	Fri Dec 28 15:44:28 2012 +0100
@@ -1,34 +1,31 @@
-#
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 
-#
-# Copyright 2011 Mike Becker. All rights reserved.
-# 
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are met:
-# 
-# 1. Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# 
-# 2. Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-# 
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
-#
-
-CC = gcc
-LD = gcc
-CFLAGS = -Wall -std=gnu99 -O0 -g
-LDFLAGS = -static -lregex
-BUILDDIR = build/
-OBJ = $(shell ls | grep '\.c' | sed 's/^\([^.]*\)\.c$$/${BUILDDIR:/=\/}\1.o/g' | tr '\n' ' ')
-BIN = ${BUILDDIR}cline
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 
+#
+# Copyright 2011 Mike Becker. All rights reserved.
+# 
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+# 
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+#
+
+CC = gcc
+LD = gcc
+CFLAGS = -Wall -std=gnu99 -O0 -g
+LDFLAGS = -static -lregex
--- a/mingw.mk	Tue Oct 02 10:49:25 2012 +0200
+++ b/mingw.mk	Fri Dec 28 15:44:28 2012 +0100
@@ -1,34 +1,31 @@
-#
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 
-#
-# Copyright 2011 Mike Becker. All rights reserved.
-# 
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are met:
-# 
-# 1. Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# 
-# 2. Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-# 
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
-#
-
-CC = gcc
-LD = gcc
-CFLAGS = -Wall -std=gnu99 -O
-LDFLAGS = -static -lregex
-BUILDDIR = build/
-OBJ = $(shell ls | grep '\.c' | sed 's/^\([^.]*\)\.c$$/${BUILDDIR:/=\/}\1.o/g' | tr '\n' ' ')
-BIN = ${BUILDDIR}cline
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 
+#
+# Copyright 2011 Mike Becker. All rights reserved.
+# 
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+# 
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+#
+
+CC = gcc
+LD = gcc
+CFLAGS = -Wall -std=gnu99 -O
+LDFLAGS = -static -lregex
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nbproject/Package-Default.bash	Fri Dec 28 15:44:28 2012 +0100
@@ -0,0 +1,75 @@
+#!/bin/bash -x
+
+#
+# Generated - do not edit!
+#
+
+# Macros
+TOP=`pwd`
+CND_PLATFORM=GNU-Linux-x86
+CND_CONF=Default
+CND_DISTDIR=dist
+CND_BUILDDIR=build
+NBTMPDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}/tmp-packaging
+TMPDIRNAME=tmp-packaging
+OUTPUT_PATH=MissingOutputInProject
+OUTPUT_BASENAME=MissingOutputInProject
+PACKAGE_TOP_DIR=cline/
+
+# Functions
+function checkReturnCode
+{
+    rc=$?
+    if [ $rc != 0 ]
+    then
+        exit $rc
+    fi
+}
+function makeDirectory
+# $1 directory path
+# $2 permission (optional)
+{
+    mkdir -p "$1"
+    checkReturnCode
+    if [ "$2" != "" ]
+    then
+      chmod $2 "$1"
+      checkReturnCode
+    fi
+}
+function copyFileToTmpDir
+# $1 from-file path
+# $2 to-file path
+# $3 permission
+{
+    cp "$1" "$2"
+    checkReturnCode
+    if [ "$3" != "" ]
+    then
+        chmod $3 "$2"
+        checkReturnCode
+    fi
+}
+
+# Setup
+cd "${TOP}"
+mkdir -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package
+rm -rf ${NBTMPDIR}
+mkdir -p ${NBTMPDIR}
+
+# Copy files and create directories and links
+cd "${TOP}"
+makeDirectory "${NBTMPDIR}/cline"
+copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}" 0755
+
+
+# Generate tar file
+cd "${TOP}"
+rm -f ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/cline.tar
+cd ${NBTMPDIR}
+tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/cline.tar *
+checkReturnCode
+
+# Cleanup
+cd "${TOP}"
+rm -rf ${NBTMPDIR}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nbproject/configurations.xml	Fri Dec 28 15:44:28 2012 +0100
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configurationDescriptor version="84">
+  <logicalFolder name="root" displayName="root" projectFiles="true" kind="ROOT">
+    <df name="cline" root=".">
+      <df name="build">
+      </df>
+      <in>arguments.c</in>
+      <in>arguments.h</in>
+      <in>bfile_heuristics.c</in>
+      <in>bfile_heuristics.h</in>
+      <in>cline.c</in>
+      <in>cline.h</in>
+      <in>regex_parser.c</in>
+      <in>regex_parser.h</in>
+      <in>scanner.c</in>
+      <in>scanner.h</in>
+      <in>settings.c</in>
+      <in>settings.h</in>
+      <in>stdinc.h</in>
+      <in>stream.c</in>
+      <in>stream.h</in>
+      <in>string_list.c</in>
+      <in>string_list.h</in>
+      <in>suffix_fnc.c</in>
+      <in>suffix_fnc.h</in>
+    </df>
+    <logicalFolder name="ExternalFiles"
+                   displayName="Important Files"
+                   projectFiles="false"
+                   kind="IMPORTANT_FILES_FOLDER">
+      <itemPath>Makefile</itemPath>
+    </logicalFolder>
+  </logicalFolder>
+  <sourceFolderFilter>^(nbproject)$</sourceFolderFilter>
+  <sourceRootList>
+    <Elem>.</Elem>
+  </sourceRootList>
+  <projectmakefile>Makefile</projectmakefile>
+  <confs>
+    <conf name="Default" type="0">
+      <toolsSet>
+        <remote-sources-mode>LOCAL_SOURCES</remote-sources-mode>
+        <compilerSet>default</compilerSet>
+      </toolsSet>
+      <codeAssistance>
+      </codeAssistance>
+      <makefileType>
+        <makeTool>
+          <buildCommandWorkingDir>.</buildCommandWorkingDir>
+          <buildCommand>${MAKE} -f Makefile</buildCommand>
+          <cleanCommand>${MAKE} -f Makefile clean</cleanCommand>
+          <executablePath></executablePath>
+        </makeTool>
+      </makefileType>
+    </conf>
+  </confs>
+</configurationDescriptor>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nbproject/private/Default.properties	Fri Dec 28 15:44:28 2012 +0100
@@ -0,0 +1,9 @@
+/home/mike/workspace/c/cline/bfile_heuristics.c=/home/mike/workspace/c/cline#-Wall -std=gnu99 -O -c -o build/bfile_heuristics.o bfile_heuristics.c
+/home/mike/workspace/c/cline/suffix_fnc.c=/home/mike/workspace/c/cline#-Wall -std=gnu99 -O -c -o build/suffix_fnc.o suffix_fnc.c
+/home/mike/workspace/c/cline/regex_parser.c=/home/mike/workspace/c/cline#-Wall -std=gnu99 -O -c -o build/regex_parser.o regex_parser.c
+/home/mike/workspace/c/cline/stream.c=/home/mike/workspace/c/cline#-Wall -std=gnu99 -O -c -o build/stream.o stream.c
+/home/mike/workspace/c/cline/settings.c=/home/mike/workspace/c/cline#-Wall -std=gnu99 -O -c -o build/settings.o settings.c
+/home/mike/workspace/c/cline/scanner.c=/home/mike/workspace/c/cline#-Wall -std=gnu99 -O -c -o build/scanner.o scanner.c
+/home/mike/workspace/c/cline/arguments.c=/home/mike/workspace/c/cline#-Wall -std=gnu99 -O -c -o build/arguments.o arguments.c
+/home/mike/workspace/c/cline/cline.c=/home/mike/workspace/c/cline#-Wall -std=gnu99 -O -c -o build/cline.o cline.c
+/home/mike/workspace/c/cline/string_list.c=/home/mike/workspace/c/cline#-Wall -std=gnu99 -O -c -o build/string_list.o string_list.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nbproject/private/configurations.xml	Fri Dec 28 15:44:28 2012 +0100
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configurationDescriptor version="84">
+  <projectmakefile>Makefile</projectmakefile>
+  <confs>
+    <conf name="Default" type="0">
+      <toolsSet>
+        <developmentServer>localhost</developmentServer>
+        <platform>2</platform>
+      </toolsSet>
+      <dbx_gdbdebugger version="1">
+        <gdb_pathmaps>
+        </gdb_pathmaps>
+        <gdb_interceptlist>
+          <gdbinterceptoptions gdb_all="false" gdb_unhandled="true" gdb_unexpected="true"/>
+        </gdb_interceptlist>
+        <gdb_options>
+          <DebugOptions>
+          </DebugOptions>
+        </gdb_options>
+        <gdb_buildfirst gdb_buildfirst_overriden="false" gdb_buildfirst_old="false"/>
+      </dbx_gdbdebugger>
+      <nativedebugger version="1">
+        <engine>gdb</engine>
+      </nativedebugger>
+      <runprofile version="9">
+        <runcommandpicklist>
+          <runcommandpicklistitem>"${OUTPUT_PATH}"</runcommandpicklistitem>
+        </runcommandpicklist>
+        <runcommand>"${OUTPUT_PATH}"</runcommand>
+        <rundir>.</rundir>
+        <buildfirst>true</buildfirst>
+        <terminal-type>0</terminal-type>
+        <remove-instrumentation>0</remove-instrumentation>
+        <environment>
+        </environment>
+      </runprofile>
+    </conf>
+  </confs>
+</configurationDescriptor>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nbproject/private/private.xml	Fri Dec 28 15:44:28 2012 +0100
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
+    <code-assistance-data xmlns="http://www.netbeans.org/ns/make-project-private/1">
+        <code-model-enabled>true</code-model-enabled>
+    </code-assistance-data>
+    <data xmlns="http://www.netbeans.org/ns/make-project-private/1">
+        <activeConfTypeElem>0</activeConfTypeElem>
+        <activeConfIndexElem>0</activeConfIndexElem>
+    </data>
+</project-private>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nbproject/project.xml	Fri Dec 28 15:44:28 2012 +0100
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://www.netbeans.org/ns/project/1">
+    <type>org.netbeans.modules.cnd.makeproject</type>
+    <configuration>
+        <data xmlns="http://www.netbeans.org/ns/make-project/1">
+            <name>cline</name>
+            <c-extensions>c</c-extensions>
+            <cpp-extensions/>
+            <header-extensions>h</header-extensions>
+            <sourceEncoding>UTF-8</sourceEncoding>
+            <make-dep-projects/>
+            <sourceRootList>
+                <sourceRootElem>.</sourceRootElem>
+            </sourceRootList>
+            <confList>
+                <confElem>
+                    <name>Default</name>
+                    <type>0</type>
+                </confElem>
+            </confList>
+        </data>
+    </configuration>
+</project>
--- a/regex_parser.c	Tue Oct 02 10:49:25 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,110 +0,0 @@
-/*
- * regex_parser.c
- *
- *  Created on: 26.01.2012
- *      Author: Mike
- */
-
-#include "regex_parser.h"
-
-regex_parser_t* new_regex_parser_t() {
-  regex_parser_t* ret = malloc(sizeof(regex_parser_t));
-  if (ret != NULL) {
-    ret->pattern_list = new_string_list_t();
-    ret->matched_lines = 0;
-    ret->pattern_match = 0;
-    ret->compiled_patterns = NULL;
-    ret->compiled_pattern_count = 0;
-  }
-  return ret;
-}
-
-void regex_destcomppats(regex_parser_t* parser) {
-  if (parser->compiled_patterns != NULL) {
-    for (int i = 0 ; i < parser->compiled_pattern_count ; i++) {
-      if (parser->compiled_patterns[i] != NULL) {
-        free(parser->compiled_patterns[i]);
-      }
-    }
-    free(parser->compiled_patterns);
-    parser->compiled_patterns = NULL;
-    parser->compiled_pattern_count = 0;
-  }
-}
-
-void destroy_regex_parser_t(regex_parser_t* parser) {
-  regex_destcomppats(parser);
-  destroy_string_list_t(parser->pattern_list);
-  free(parser);
-}
-
-bool regex_parser_matching(regex_parser_t* parser) {
-  return parser->pattern_match > 0;
-}
-
-int regex_parser_do(regex_parser_t* parser, char* input) {
-  int err = REG_NOMATCH;
-  if (parser->compiled_pattern_count > 0) {
-    regmatch_t match;
-
-    if (regex_parser_matching(parser)) {
-      parser->matched_lines++;
-
-      err = regexec(parser->compiled_patterns[parser->pattern_match],
-          input, 1, &match, 0);
-      if (err > 0 && err != REG_NOMATCH) {
-        fprintf(stderr, "Regex-Error: 0x%08x", err);
-      }
-      if (err == 0) {
-        parser->pattern_match = 0;
-        /* do not match line, if it does not end with the pattern */
-        if (match.rm_eo < strlen(input)) {
-          parser->matched_lines--;
-        }
-      }
-    } else {
-      for (int i = 0 ; i < parser->compiled_pattern_count - 1 ; i += 2) {
-        err = regexec(parser->compiled_patterns[i], input, 1, &match, 0);
-        if (err > 0 && err != REG_NOMATCH) {
-          fprintf(stderr, "Regex-Error: 0x%08x", err);
-        }
-        if (err == 0) {
-          parser->pattern_match = i+1;
-          parser->matched_lines = 0;
-          /* Check, if end pattern is also in this line */
-          regex_parser_do(parser, input);
-          /* do not match line, if it does not start with the pattern */
-          if (match.rm_so > 0 && parser->matched_lines > 0) {
-            parser->matched_lines--;
-          }
-          break;
-        }
-      }
-    }
-  }
-  return err;
-}
-
-bool regex_compile_all(regex_parser_t* parser) {
-  bool success = true;
-  size_t pcount = parser->pattern_list->count;
-  if (pcount > 0) {
-    regex_destcomppats(parser);
-    parser->compiled_patterns = calloc(pcount, sizeof(regex_t));
-    parser->compiled_pattern_count = pcount;
-
-    regex_t* re;
-    for (int i = 0 ; i < pcount ; i++) {
-      re = malloc(sizeof(regex_t));
-      if (regcomp(re, parser->pattern_list->items[i], REG_EXTENDED) == 0) {
-        parser->compiled_patterns[i] = re;
-      } else {
-        fprintf(stderr, "Cannot compile pattern: %s\n",
-            (parser->pattern_list->items[i]));
-        parser->compiled_patterns[i] = NULL;
-        success = false;
-      }
-    }
-  }
-  return success;
-}
--- a/regex_parser.h	Tue Oct 02 10:49:25 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-/*
- * regex_parser.h
- *
- *  Created on: 26.01.2012
- *      Author: Mike
- */
-
-#ifndef REGEX_PARSER_H_
-#define REGEX_PARSER_H_
-
-#define REGEX_MAX_LINELENGTH           2048
-
-#include <sys/types.h>
-#include <stdbool.h>
-#include <regex.h>
-#include "string_list.h"
-
-typedef struct {
-  string_list_t* pattern_list; /* even entries: start ; odd entries: end */
-  regex_t** compiled_patterns;
-  size_t compiled_pattern_count;
-  unsigned int pattern_match; /* save position of end pattern to match -
-                                 NULL when a start pattern shall match first */
-  unsigned int matched_lines;
-} regex_parser_t;
-
-#ifdef _cplusplus
-extern "C" {
-#endif
-
-regex_parser_t* new_regex_parser_t();
-void destroy_regex_parser_t(regex_parser_t*);
-
-bool regex_parser_matching(regex_parser_t*);
-bool regex_compile_all(regex_parser_t*);
-int regex_parser_do(regex_parser_t*, char*);
-
-#ifdef _cplusplus
-}
-#endif
-
-#endif /* REGEX_PARSER_H_ */
--- a/scanner.c	Tue Oct 02 10:49:25 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,126 +0,0 @@
-/*
- * scanner.c
- *
- *  Created on: 23.05.2011
- *      Author: Mike
- */
-
-
-#include "scanner.h"
-#include "suffix_fnc.h"
-#include "bfile_heuristics.h"
-#include "regex_parser.h"
-#include <sys/stat.h>
-
-int scanDirectory(scanner_t scanner, settings_t* settings) {
-
-  DIR *dirf;
-  struct dirent *entry;
-  int lines, a;
-  int lineSum = 0;
-  bool bfile;
-  struct stat statbuf;
-
-  if ((dirf = opendir(scanner.dir)) == NULL) {
-    printf(scanner.dir);
-    perror("  Directory access failed");
-    return 0;
-  }
-
-  while ((entry = readdir(dirf)) != NULL) {
-    if (strcmp(entry->d_name, ".") != 0 && strcmp(entry->d_name, "..") != 0) {
-      /* Construct tree view and absolute pathname strings */
-      char entryname[strlen(entry->d_name)+scanner.spaces];
-      for (int t = 0 ; t < scanner.spaces ; t++) {
-        entryname[t]=' ';
-      }
-      entryname[scanner.spaces] = 0;
-      strcat(entryname, entry->d_name);
-  
-      char filename[(1+strlen(scanner.dir)+strlen(entry->d_name))];
-      strcpy(filename, scanner.dir);
-      strncat(filename, &settings->fileSeparator, 1);
-      strcat(filename, entry->d_name);
-
-      /* Check for subdirectory */
-      if (stat(filename, &statbuf) == 0) {
-        if (!(statbuf.st_mode & S_IFREG)) {
-          printf("%-60s\n", entryname);
-          if (settings->recursive && (statbuf.st_mode & S_IFDIR)) {
-            lineSum += scanDirectory(
-                (scanner_t) {filename, scanner.spaces+1}, settings);
-          }
-          continue;
-        }
-      } else {
-        perror("  Error in stat call");
-        continue;
-      }
-
-      if ((settings->includeSuffixes->count == 0
-          || testSuffix(filename, settings->includeSuffixes))
-          && !testSuffix(filename, settings->excludeSuffixes)) {
-        /* Count lines */
-        lines = 0;
-        bfile = false;
-        bfile_reset(settings->bfileHeuristics);
-        char line_buffer[REGEX_MAX_LINELENGTH];
-        int line_buffer_offset = 0;
-
-        FILE *file = fopen(filename, "r");
-        if (file == NULL) {
-          printf(entryname);
-          perror("  File acces failed");
-          continue;
-        }
-
-        do {
-          a = fgetc(file);
-
-          bfile = bfile_check(settings->bfileHeuristics, a);
-
-          if (a == 10 || a == EOF) {
-            line_buffer[line_buffer_offset] = 0;
-            if (regex_parser_do(settings->regex, line_buffer) == 0) {
-              /* Only subtract lines when matching has finished */
-              if (!regex_parser_matching(settings->regex)) {
-                lines -= settings->regex->matched_lines;
-              }
-            }
-
-            line_buffer_offset = 0;
-            lines++;
-          } else {
-            if (line_buffer_offset < REGEX_MAX_LINELENGTH) {
-              line_buffer[line_buffer_offset] = a;
-              line_buffer_offset++;
-            } else {
-              line_buffer[line_buffer_offset-1] = 0;
-              settings->confusing_lnlen = true;
-            }
-          }
-        } while (!bfile && a != EOF);
-        fclose(file);
-
-        /* Print and sum line count */
-        if (bfile) {
-          if (!settings->matchesOnly) {
-            printf("%-60s%19s\n", entryname, "binary");
-          }
-        } else {
-          lineSum += lines;
-          printf("%-60s%13d lines\n", entryname, lines);
-        }
-      } else {
-        if (!settings->matchesOnly) {
-          /* Print hint */
-          printf("%-60s%19s\n", entryname, "no match");
-        }
-      }
-    }
-  }
-
-  closedir(dirf);
-
-  return lineSum;
-}
--- a/scanner.h	Tue Oct 02 10:49:25 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-/*
- * scanner.h
- *
- *  Created on: 23.05.2011
- *      Author: Mike
- */
-
-#ifndef SCANNER_H_
-#define SCANNER_H_
-
-#include "stdinc.h"
-#include "settings.h"
-
-typedef struct {
-  char *dir;
-  int spaces;
-} scanner_t;
-
-#ifdef _cplusplus
-extern "C" {
-#endif
-
-int scanDirectory(scanner_t scanner, settings_t* settings);
-
-#ifdef _cplusplus
-}
-#endif 
-                  
-#endif /* SCANNER_H_ */
--- a/settings.c	Tue Oct 02 10:49:25 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +0,0 @@
-/*
- * settings.c
- *
- *  Created on: 15.09.2011
- *      Author: Mike
- */
-
-#include "settings.h"
-
-settings_t* new_settings_t() {
-  settings_t *settings = malloc(sizeof(settings_t));
-  if (settings != NULL) {
-  #ifdef _WIN32
-    settings->fileSeparator      = '\\';
-  #else
-    settings->fileSeparator      = '/';
-  #endif /* _WIN32 */
-    settings->recursive          = false;
-    settings->matchesOnly        = false;
-    settings->includeSuffixes         = new_string_list_t();
-    settings->excludeSuffixes    = new_string_list_t();
-    settings->verbose            = true;
-    settings->bfileHeuristics    = new_bfile_heuristics_t();
-    settings->confusing_lnlen    = false;
-    settings->regex              = new_regex_parser_t();
-  }
-
-  return settings;
-}
-
-void destroy_settings_t(settings_t* settings) {
-  destroy_regex_parser_t(settings->regex);
-  destroy_string_list_t(settings->includeSuffixes);
-  destroy_string_list_t(settings->excludeSuffixes);
-  destroy_bfile_heuristics_t(settings->bfileHeuristics);
-  free(settings);
-}
--- a/settings.h	Tue Oct 02 10:49:25 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-/*
- * settings.h
- *
- *  Created on: 15.09.2011
- *      Author: Mike
- */
-
-#ifndef SETTINGS_H_
-#define SETTINGS_H_
-
-#include "stdinc.h"
-#include "string_list.h"
-#include "bfile_heuristics.h"
-#include "regex_parser.h"
-
-typedef struct _settings {
-  string_list_t* includeSuffixes;
-  string_list_t* excludeSuffixes;
-  regex_parser_t* regex;
-  bfile_heuristics_t* bfileHeuristics;
-  char fileSeparator;
-  bool recursive;
-  bool matchesOnly;
-  bool verbose;
-  bool confusing_lnlen; /* this flag is set by the scanner */
-} settings_t;
-
-#ifdef _cplusplus
-extern "C" {
-#endif
-
-settings_t* new_settings_t();
-void destroy_settings_t(settings_t*);
-
-#ifdef _cplusplus
-}
-#endif
-
-#endif /* SETTINGS_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/arguments.c	Fri Dec 28 15:44:28 2012 +0100
@@ -0,0 +1,70 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 
+ * Copyright 2011 Mike Becker. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ *
+ * 
+ * arguments.c
+ *
+ *  Created on: 15.09.2011
+ *      Author: Mike
+ */
+
+#include "arguments.h"
+
+int checkArgument(const char* arg, const char* expected) {
+  int len = strlen(expected);
+  int ret = 0;
+
+  if (arg[0] == '-') {
+    if (arg[1] != '-') {
+      for (int t = 0 ; t < len ; t++) {
+        ret |= (strchr(arg, expected[t]) > 0) << t;
+      }
+    }
+  }
+
+  return ret;
+}
+
+bool registerArgument(int* reg, int mask) {
+  bool ret = (*reg & mask) > 0;
+  *reg |= mask;
+  return ret;
+}
+
+bool checkParamOpt(int* paropt) {
+  bool ret = *paropt == 0;
+  *paropt = 1;
+  return ret;
+}
+
+void parseCSL(char* csl, string_list_t* list) {
+  if (csl != NULL) {
+    char* finder = strtok(csl, ",");
+    while (finder != NULL) {
+      add_string(list, finder);
+      finder = strtok(NULL, ",");
+    }
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/arguments.h	Fri Dec 28 15:44:28 2012 +0100
@@ -0,0 +1,51 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 
+ * Copyright 2011 Mike Becker. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ *
+ * arguments.h
+ *
+ *  Created on: 15.09.2011
+ *      Author: Mike
+ */
+
+#ifndef ARGUMENTS_H_
+#define ARGUMENTS_H_
+
+#include "stdinc.h"
+#include "string_list.h"
+
+#ifdef _cplusplus
+extern "C" {
+#endif
+
+int checkArgument(const char*, const char*);
+bool checkParamOpt(int*);
+bool registerArgument(int*, int);
+void parseCSL(char*, string_list_t*);
+
+#ifdef _cplusplus
+}
+#endif
+
+#endif /* ARGUMENTS_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/bfile_heuristics.c	Fri Dec 28 15:44:28 2012 +0100
@@ -0,0 +1,81 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 
+ * Copyright 2011 Mike Becker. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ *
+ * bfile_heuristics.c
+ *
+ *  Created on: 20.10.2011
+ *      Author: Mike
+ */
+
+#include "bfile_heuristics.h"
+#include <ctype.h>
+
+bfile_heuristics_t *new_bfile_heuristics_t() {
+  bfile_heuristics_t *ret = malloc(sizeof(bfile_heuristics_t));
+  ret->level = BFILE_MEDIUM_ACCURACY;
+  bfile_reset(ret);
+  return ret;
+}
+
+void destroy_bfile_heuristics_t(bfile_heuristics_t *def) {
+  free(def);
+}
+
+void bfile_reset(bfile_heuristics_t *def) {
+  def->bcount = 0;
+  def->tcount = 0;
+}
+
+bool bfile_check(bfile_heuristics_t *def, int next_char) {
+  bool ret = false;
+  if (def->level != BFILE_IGNORE) {
+    def->tcount++;
+    if (!isprint(next_char) && !isspace(next_char)) {
+      def->bcount++;
+    }
+
+    if (def->tcount > 1) { /* empty files are text files */
+      switch (def->level) {
+      case BFILE_LOW_ACCURACY:
+        if (def->tcount > 15 || next_char == EOF) {
+          ret = (1.0*def->bcount)/def->tcount > 0.32;
+        }
+        break;
+      case BFILE_HIGH_ACCURACY:
+        if (def->tcount > 500 || next_char == EOF) {
+          ret = (1.0*def->bcount)/def->tcount > 0.1;
+        }
+        break;
+      default: /* BFILE_MEDIUM_ACCURACY */
+        if (def->tcount > 100 || next_char == EOF) {
+          ret = (1.0*def->bcount)/def->tcount > 0.1;
+        }
+        break;
+      }
+    }
+  }
+
+  return ret;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/bfile_heuristics.h	Fri Dec 28 15:44:28 2012 +0100
@@ -0,0 +1,61 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 
+ * Copyright 2011 Mike Becker. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ *
+ * bfile_heuristics.h
+ *
+ *  Created on: 20.10.2011
+ *      Author: Mike
+ */
+
+#ifndef BFILE_HEURISTICS_H_
+#define BFILE_HEURISTICS_H_
+
+#include "stdinc.h"
+
+#define BFILE_IGNORE           0x00
+#define BFILE_LOW_ACCURACY     0x01
+#define BFILE_MEDIUM_ACCURACY  0x02
+#define BFILE_HIGH_ACCURACY    0x04
+
+typedef struct {
+  unsigned int level;
+  unsigned int bcount; /* 'binary' character count */
+  unsigned int tcount; /* total count */
+} bfile_heuristics_t;
+
+#ifdef _cplusplus
+extern "C" {
+#endif
+
+bfile_heuristics_t *new_bfile_heuristics_t();
+void destroy_bfile_heuristics_t(bfile_heuristics_t *def);
+void bfile_reset(bfile_heuristics_t *def);
+bool bfile_check(bfile_heuristics_t *def, int next_char);
+
+#ifdef _cplusplus
+}
+#endif
+
+#endif /* BFILE_HEURISTICS_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cline.c	Fri Dec 28 15:44:28 2012 +0100
@@ -0,0 +1,269 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 
+ * Copyright 2011 Mike Becker. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ *
+ * cline.c
+ *
+ *  Created on: 23.05.2011
+ *      Author: Mike
+ */
+
+#include "cline.h"
+#include "scanner.h"
+#include "settings.h"
+#include "arguments.h"
+#include "stream.h"
+#include "regex_parser.h"
+
+void printHelpText() {
+  printf(
+    "\nUsage:"
+    "\n      cline [Options] [Directories...]"
+    "\n      cline [Options] [Directories...]"
+    "\n\nCounts the line terminator characters (\\n) within all"
+    " files in the specified\ndirectories."
+    "\n\nOptions:"
+    "\n  -b <level>          - binary file heuristics level (default medium)"
+    "\n                        One of: ignore low medium high"
+    "\n  -E <pattern>        - Excludes any line matching the <pattern>"
+    "\n  -e <start> <end>    - Excludes lines between <start> and <end>"
+    "\n                        You may use these options multiple times"
+    "\n  -h, --help          - this help text"
+    "\n  -m                  - print information about matching files only"
+    "\n  -s <suffixes>       - only count files with these suffixes (separated"
+    "\n                        by commas)"
+    "\n  -S <suffixes>       - count any file except those with these suffixes"
+    "\n                        (separated by commas)"
+    "\n  -r, -R              - includes subdirectories"
+    "\n  -v, --version       - print out version information"
+    "\n  -V                  - turn verbose output off, print the result only"
+    "\n\nShortcuts:"
+    "\n  --exclude-cstyle-comments"
+    "\n = -E \"\\s*//\" -e \"\\s*/\\*\" \"\\*/\\s*\""
+    "\n\n"
+    "The default call without any options is:"    
+    "\n  cline ./\n\n"
+    "So each file in the working directory is counted. If you want to count C"
+    "\nsource code in your working directory and its subdirectories, type:"
+    "\n  cline -rs .c\n"
+    "\nIf you want to exclude comment lines, you may use the -e/-E option."
+    "\nAfter a line matches the regex pattern <start> any following line is"
+    "\nnot counted unless a line matches the <end> pattern. A line is still "
+    "\ncounted when it does not start or end with the respective patterns."
+    "\nPlease note, that cline does not remove whitespace characters as this"
+    "\nmight not be reasonable in some cases."
+    "\n\nExample (C without comments):"
+    "\n  cline -s .c,.h --exclude-cstyle-comments");
+}
+
+int exit_with_version(settings_t* settings) {
+  printf("cline - Revision: %s\n", VERSION);
+  destroy_settings_t(settings);
+  return 0;
+}
+
+int exit_with_help(settings_t* settings, int code) {
+  printHelpText();
+  destroy_settings_t(settings);
+  return code;
+}
+
+int main(int argc, char** argv) {
+
+  /* Settings */
+  settings_t *settings = new_settings_t();
+  if (settings == NULL) {
+    fprintf(stderr, "Memory allocation failed.\n");
+    return 1;
+  }
+
+  /* Get arguments */
+  string_list_t *directories = new_string_list_t();
+  if (directories == NULL) {
+    fprintf(stderr, "Memory allocation failed.\n");
+    return 1;
+  }
+  char* includeSuffix = NULL;
+  char* excludeSuffix = NULL;
+  int checked = 0;
+
+  for (int t = 1 ; t < argc ; t++) {
+
+    int argflags = checkArgument(argv[t], "hsSrRmvVbeE");
+    int paropt = 0;
+
+    /* s */
+    if ((argflags & 2) > 0) {
+      if (!checkParamOpt(&paropt) || registerArgument(&checked, 2)) {
+        return exit_with_help(settings, 1);
+      }
+      t++;
+      if (t >= argc) {
+        return exit_with_help(settings, 1);
+      }
+      includeSuffix = argv[t];
+    }
+    /* S */
+    if ((argflags & 4) > 0) {
+      if (!checkParamOpt(&paropt) || registerArgument(&checked, 4)) {
+        return exit_with_help(settings, 1);
+      }
+      t++;
+      if (t >= argc) {
+        return exit_with_help(settings, 1);
+      }
+      excludeSuffix = argv[t];
+    }
+    /* h */
+    if ((argflags & 1) > 0 || strcmp(argv[t], "--help") == 0) {
+      return exit_with_help(settings, 0);
+    }
+    /* r, R */
+    if ((argflags & 24) > 0) {
+      if (registerArgument(&checked, 24)) {
+        return exit_with_help(settings, 1);
+      }
+      settings->recursive = true;
+    }
+    /* m */
+    if ((argflags & 32) > 0) {
+      if (registerArgument(&checked, 32)) {
+        return exit_with_help(settings, 1);
+      }
+      settings->matchesOnly = true;
+    }
+    /* v */
+    if ((argflags & 64) > 0 || strcmp(argv[t], "--version") == 0) {
+      return exit_with_version(settings);
+    }
+    /* V */
+    if ((argflags & 128) > 0) {
+      if (registerArgument(&checked, 128)) {
+        return exit_with_help(settings, 1);
+      }
+      settings->verbose = false;
+    }
+    /* b */
+    if ((argflags & 256) > 0) {
+      if (!checkParamOpt(&paropt) || registerArgument(&checked, 256)) {
+        return exit_with_help(settings, 1);
+      }
+      t++;
+      if (t >= argc) {
+        return exit_with_help(settings, 1);
+      }
+      if (strcasecmp(argv[t], "ignore") == 0) {
+        settings->bfileHeuristics->level = BFILE_IGNORE;
+      } else if (strcasecmp(argv[t], "low") == 0) {
+        settings->bfileHeuristics->level = BFILE_LOW_ACCURACY;
+      } else if (strcasecmp(argv[t], "medium") == 0) {
+        settings->bfileHeuristics->level = BFILE_MEDIUM_ACCURACY;
+      } else if (strcasecmp(argv[t], "high") == 0) {
+        settings->bfileHeuristics->level = BFILE_HIGH_ACCURACY;
+      } else {
+        return exit_with_help(settings, 1);
+      }
+    }
+    /* e */
+    if ((argflags & 512) > 0) {
+      if (!checkParamOpt(&paropt) || t + 2 >= argc) {
+        return exit_with_help(settings, 1);
+      }
+      t++; add_string(settings->regex->pattern_list, argv[t]);
+      t++; add_string(settings->regex->pattern_list, argv[t]);
+    }
+    /* E */
+    if ((argflags & 1024) > 0) {
+      t++;
+      if (!checkParamOpt(&paropt) || t >= argc) {
+        return exit_with_help(settings, 1);
+      }
+      add_string(settings->regex->pattern_list, argv[t]);
+      add_string(settings->regex->pattern_list, "$");
+    }
+    if (argflags == 0) {
+      /* SHORTCUTS */
+      /* exclude-cstyle-comments */
+      if (strcmp(argv[t], "--exclude-cstyle-comments") == 0) {
+        add_string(settings->regex->pattern_list, "\\s*//");
+        add_string(settings->regex->pattern_list, "$");
+        add_string(settings->regex->pattern_list, "\\s*/\\*");
+        add_string(settings->regex->pattern_list, "\\*/\\s*");
+      }
+      /* Path */
+      else {
+        add_string(directories, argv[t]);
+      }
+    }
+  }
+
+  /* Configure output */
+  if (!settings->verbose) {
+    close_stdout();
+  }
+
+  /* Find tokens */
+  parseCSL(includeSuffix, settings->includeSuffixes);
+  parseCSL(excludeSuffix, settings->excludeSuffixes);
+
+  /* Scan directories */
+  if (regex_compile_all(settings->regex)) {
+    int lines = 0;
+    if (directories->count == 0) {
+        add_string(directories, ".");
+    }
+    for (int t = 0 ; t < directories->count ; t++) {
+      if (t > 0) {
+          for (int u = 0 ; u < 79 ; u++) {
+              printf("-");
+          }
+          printf("\n");
+      }
+      lines += scanDirectory((scanner_t){directories->items[t], 0}, settings);
+    }
+    destroy_string_list_t(directories);
+
+    /* Print double line and line count */
+    for (int t = 0 ; t < 79 ; t++) {
+      printf("=");
+    }
+    printf("\n%73d lines\n", lines);
+
+    if (settings->confusing_lnlen && settings->regex->pattern_list->count > 0) {
+      printf("\nSome files contain too long lines.\n"
+        "The regex parser currently supports a maximum line length of %d."
+        "\nThe result might be wrong.\n", REGEX_MAX_LINELENGTH);
+    }
+
+    if (!settings->verbose) {
+      reopen_stdout();
+      printf("%d", lines);
+    }
+    destroy_settings_t(settings);
+  }
+
+  fflush(stdout);
+  fflush(stderr);
+  return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cline.h	Fri Dec 28 15:44:28 2012 +0100
@@ -0,0 +1,52 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 
+ * Copyright 2011 Mike Becker. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ *
+ * cline.h
+ *
+ *  Created on: 23.05.2011
+ *      Author: Mike
+ */
+
+#ifndef CLINE_H_
+#define CLINE_H_
+
+const char* VERSION=""; /* will be replaced by makefile */
+
+#include "stdinc.h"
+#include "settings.h"
+
+#ifdef _cplusplus
+extern "C" {
+#endif
+
+void printHelpText();
+int exit_with_version(settings_t*);
+int exit_with_help(settings_t*, int);
+
+#ifdef _cplusplus
+}
+#endif
+
+#endif /* CLINE_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/regex_parser.c	Fri Dec 28 15:44:28 2012 +0100
@@ -0,0 +1,134 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 
+ * Copyright 2011 Mike Becker. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ *
+ * regex_parser.c
+ *
+ *  Created on: 26.01.2012
+ *      Author: Mike
+ */
+
+#include "regex_parser.h"
+
+regex_parser_t* new_regex_parser_t() {
+  regex_parser_t* ret = malloc(sizeof(regex_parser_t));
+  if (ret != NULL) {
+    ret->pattern_list = new_string_list_t();
+    ret->matched_lines = 0;
+    ret->pattern_match = 0;
+    ret->compiled_patterns = NULL;
+    ret->compiled_pattern_count = 0;
+  }
+  return ret;
+}
+
+void regex_destcomppats(regex_parser_t* parser) {
+  if (parser->compiled_patterns != NULL) {
+    for (int i = 0 ; i < parser->compiled_pattern_count ; i++) {
+      if (parser->compiled_patterns[i] != NULL) {
+        free(parser->compiled_patterns[i]);
+      }
+    }
+    free(parser->compiled_patterns);
+    parser->compiled_patterns = NULL;
+    parser->compiled_pattern_count = 0;
+  }
+}
+
+void destroy_regex_parser_t(regex_parser_t* parser) {
+  regex_destcomppats(parser);
+  destroy_string_list_t(parser->pattern_list);
+  free(parser);
+}
+
+bool regex_parser_matching(regex_parser_t* parser) {
+  return parser->pattern_match > 0;
+}
+
+int regex_parser_do(regex_parser_t* parser, char* input) {
+  int err = REG_NOMATCH;
+  if (parser->compiled_pattern_count > 0) {
+    regmatch_t match;
+
+    if (regex_parser_matching(parser)) {
+      parser->matched_lines++;
+
+      err = regexec(parser->compiled_patterns[parser->pattern_match],
+          input, 1, &match, 0);
+      if (err > 0 && err != REG_NOMATCH) {
+        fprintf(stderr, "Regex-Error: 0x%08x", err);
+      }
+      if (err == 0) {
+        parser->pattern_match = 0;
+        /* do not match line, if it does not end with the pattern */
+        if (match.rm_eo < strlen(input)) {
+          parser->matched_lines--;
+        }
+      }
+    } else {
+      for (int i = 0 ; i < parser->compiled_pattern_count - 1 ; i += 2) {
+        err = regexec(parser->compiled_patterns[i], input, 1, &match, 0);
+        if (err > 0 && err != REG_NOMATCH) {
+          fprintf(stderr, "Regex-Error: 0x%08x", err);
+        }
+        if (err == 0) {
+          parser->pattern_match = i+1;
+          parser->matched_lines = 0;
+          /* Check, if end pattern is also in this line */
+          regex_parser_do(parser, input);
+          /* do not match line, if it does not start with the pattern */
+          if (match.rm_so > 0 && parser->matched_lines > 0) {
+            parser->matched_lines--;
+          }
+          break;
+        }
+      }
+    }
+  }
+  return err;
+}
+
+bool regex_compile_all(regex_parser_t* parser) {
+  bool success = true;
+  size_t pcount = parser->pattern_list->count;
+  if (pcount > 0) {
+    regex_destcomppats(parser);
+    parser->compiled_patterns = calloc(pcount, sizeof(regex_t));
+    parser->compiled_pattern_count = pcount;
+
+    regex_t* re;
+    for (int i = 0 ; i < pcount ; i++) {
+      re = malloc(sizeof(regex_t));
+      if (regcomp(re, parser->pattern_list->items[i], REG_EXTENDED) == 0) {
+        parser->compiled_patterns[i] = re;
+      } else {
+        fprintf(stderr, "Cannot compile pattern: %s\n",
+            (parser->pattern_list->items[i]));
+        parser->compiled_patterns[i] = NULL;
+        success = false;
+      }
+    }
+  }
+  return success;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/regex_parser.h	Fri Dec 28 15:44:28 2012 +0100
@@ -0,0 +1,66 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 
+ * Copyright 2011 Mike Becker. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ *
+ * regex_parser.h
+ *
+ *  Created on: 26.01.2012
+ *      Author: Mike
+ */
+
+#ifndef REGEX_PARSER_H_
+#define REGEX_PARSER_H_
+
+#define REGEX_MAX_LINELENGTH           2048
+
+#include <sys/types.h>
+#include <stdbool.h>
+#include <regex.h>
+#include "string_list.h"
+
+typedef struct {
+  string_list_t* pattern_list; /* even entries: start ; odd entries: end */
+  regex_t** compiled_patterns;
+  size_t compiled_pattern_count;
+  unsigned int pattern_match; /* save position of end pattern to match -
+                                 NULL when a start pattern shall match first */
+  unsigned int matched_lines;
+} regex_parser_t;
+
+#ifdef _cplusplus
+extern "C" {
+#endif
+
+regex_parser_t* new_regex_parser_t();
+void destroy_regex_parser_t(regex_parser_t*);
+
+bool regex_parser_matching(regex_parser_t*);
+bool regex_compile_all(regex_parser_t*);
+int regex_parser_do(regex_parser_t*, char*);
+
+#ifdef _cplusplus
+}
+#endif
+
+#endif /* REGEX_PARSER_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/scanner.c	Fri Dec 28 15:44:28 2012 +0100
@@ -0,0 +1,150 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 
+ * Copyright 2011 Mike Becker. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ *
+ * scanner.c
+ *
+ *  Created on: 23.05.2011
+ *      Author: Mike
+ */
+
+
+#include "scanner.h"
+#include "suffix_fnc.h"
+#include "bfile_heuristics.h"
+#include "regex_parser.h"
+#include <sys/stat.h>
+
+int scanDirectory(scanner_t scanner, settings_t* settings) {
+
+  DIR *dirf;
+  struct dirent *entry;
+  int lines, a;
+  int lineSum = 0;
+  bool bfile;
+  struct stat statbuf;
+
+  if ((dirf = opendir(scanner.dir)) == NULL) {
+    printf("%s", scanner.dir);
+    perror("  Directory access failed");
+    return 0;
+  }
+
+  while ((entry = readdir(dirf)) != NULL) {
+    if (strcmp(entry->d_name, ".") != 0 && strcmp(entry->d_name, "..") != 0) {
+      /* Construct tree view and absolute pathname strings */
+      char entryname[strlen(entry->d_name)+scanner.spaces];
+      for (int t = 0 ; t < scanner.spaces ; t++) {
+        entryname[t]=' ';
+      }
+      entryname[scanner.spaces] = 0;
+      strcat(entryname, entry->d_name);
+  
+      char filename[(1+strlen(scanner.dir)+strlen(entry->d_name))];
+      strcpy(filename, scanner.dir);
+      strncat(filename, &settings->fileSeparator, 1);
+      strcat(filename, entry->d_name);
+
+      /* Check for subdirectory */
+      if (stat(filename, &statbuf) == 0) {
+        if (!(statbuf.st_mode & S_IFREG)) {
+          printf("%-60s\n", entryname);
+          if (settings->recursive && (statbuf.st_mode & S_IFDIR)) {
+            lineSum += scanDirectory(
+                (scanner_t) {filename, scanner.spaces+1}, settings);
+          }
+          continue;
+        }
+      } else {
+        perror("  Error in stat call");
+        continue;
+      }
+
+      if ((settings->includeSuffixes->count == 0
+          || testSuffix(filename, settings->includeSuffixes))
+          && !testSuffix(filename, settings->excludeSuffixes)) {
+        /* Count lines */
+        lines = 0;
+        bfile = false;
+        bfile_reset(settings->bfileHeuristics);
+        char line_buffer[REGEX_MAX_LINELENGTH];
+        int line_buffer_offset = 0;
+
+        FILE *file = fopen(filename, "r");
+        if (file == NULL) {
+          printf("%s", entryname);
+          perror("  File acces failed");
+          continue;
+        }
+
+        do {
+          a = fgetc(file);
+
+          bfile = bfile_check(settings->bfileHeuristics, a);
+
+          if (a == 10 || a == EOF) {
+            line_buffer[line_buffer_offset] = 0;
+            if (regex_parser_do(settings->regex, line_buffer) == 0) {
+              /* Only subtract lines when matching has finished */
+              if (!regex_parser_matching(settings->regex)) {
+                lines -= settings->regex->matched_lines;
+              }
+            }
+
+            line_buffer_offset = 0;
+            lines++;
+          } else {
+            if (line_buffer_offset < REGEX_MAX_LINELENGTH) {
+              line_buffer[line_buffer_offset] = a;
+              line_buffer_offset++;
+            } else {
+              line_buffer[line_buffer_offset-1] = 0;
+              settings->confusing_lnlen = true;
+            }
+          }
+        } while (!bfile && a != EOF);
+        fclose(file);
+
+        /* Print and sum line count */
+        if (bfile) {
+          if (!settings->matchesOnly) {
+            printf("%-60s%19s\n", entryname, "binary");
+          }
+        } else {
+          lineSum += lines;
+          printf("%-60s%13d lines\n", entryname, lines);
+        }
+      } else {
+        if (!settings->matchesOnly) {
+          /* Print hint */
+          printf("%-60s%19s\n", entryname, "no match");
+        }
+      }
+    }
+  }
+
+  closedir(dirf);
+
+  return lineSum;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/scanner.h	Fri Dec 28 15:44:28 2012 +0100
@@ -0,0 +1,53 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 
+ * Copyright 2011 Mike Becker. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ *
+ * scanner.h
+ *
+ *  Created on: 23.05.2011
+ *      Author: Mike
+ */
+
+#ifndef SCANNER_H_
+#define SCANNER_H_
+
+#include "stdinc.h"
+#include "settings.h"
+
+typedef struct {
+  char *dir;
+  int spaces;
+} scanner_t;
+
+#ifdef _cplusplus
+extern "C" {
+#endif
+
+int scanDirectory(scanner_t scanner, settings_t* settings);
+
+#ifdef _cplusplus
+}
+#endif 
+                  
+#endif /* SCANNER_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/settings.c	Fri Dec 28 15:44:28 2012 +0100
@@ -0,0 +1,61 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 
+ * Copyright 2011 Mike Becker. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ *
+ * settings.c
+ *
+ *  Created on: 15.09.2011
+ *      Author: Mike
+ */
+
+#include "settings.h"
+
+settings_t* new_settings_t() {
+  settings_t *settings = malloc(sizeof(settings_t));
+  if (settings != NULL) {
+  #ifdef _WIN32
+    settings->fileSeparator      = '\\';
+  #else
+    settings->fileSeparator      = '/';
+  #endif /* _WIN32 */
+    settings->recursive          = false;
+    settings->matchesOnly        = false;
+    settings->includeSuffixes         = new_string_list_t();
+    settings->excludeSuffixes    = new_string_list_t();
+    settings->verbose            = true;
+    settings->bfileHeuristics    = new_bfile_heuristics_t();
+    settings->confusing_lnlen    = false;
+    settings->regex              = new_regex_parser_t();
+  }
+
+  return settings;
+}
+
+void destroy_settings_t(settings_t* settings) {
+  destroy_regex_parser_t(settings->regex);
+  destroy_string_list_t(settings->includeSuffixes);
+  destroy_string_list_t(settings->excludeSuffixes);
+  destroy_bfile_heuristics_t(settings->bfileHeuristics);
+  free(settings);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/settings.h	Fri Dec 28 15:44:28 2012 +0100
@@ -0,0 +1,63 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 
+ * Copyright 2011 Mike Becker. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ *
+ * settings.h
+ *
+ *  Created on: 15.09.2011
+ *      Author: Mike
+ */
+
+#ifndef SETTINGS_H_
+#define SETTINGS_H_
+
+#include "stdinc.h"
+#include "string_list.h"
+#include "bfile_heuristics.h"
+#include "regex_parser.h"
+
+typedef struct _settings {
+  string_list_t* includeSuffixes;
+  string_list_t* excludeSuffixes;
+  regex_parser_t* regex;
+  bfile_heuristics_t* bfileHeuristics;
+  char fileSeparator;
+  bool recursive;
+  bool matchesOnly;
+  bool verbose;
+  bool confusing_lnlen; /* this flag is set by the scanner */
+} settings_t;
+
+#ifdef _cplusplus
+extern "C" {
+#endif
+
+settings_t* new_settings_t();
+void destroy_settings_t(settings_t*);
+
+#ifdef _cplusplus
+}
+#endif
+
+#endif /* SETTINGS_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/stdinc.h	Fri Dec 28 15:44:28 2012 +0100
@@ -0,0 +1,41 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 
+ * Copyright 2011 Mike Becker. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ *
+ * stdinc.h
+ *
+ *  Created on: 15.09.2011
+ *      Author: Mike
+ */
+
+#ifndef STDINC_H_
+#define STDINC_H_
+
+#include <stdio.h>
+#include <string.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <dirent.h>
+
+#endif /* STDINC_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/stream.c	Fri Dec 28 15:44:28 2012 +0100
@@ -0,0 +1,49 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 
+ * Copyright 2011 Mike Becker. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ *
+ * stream.c
+ *
+ *  Created on: 20.09.2011
+ *      Author: Mike
+ */
+
+#include "stream.h"
+
+void close_stdout() {
+#ifdef _WIN32
+  _STREAM_STDOUT = dup(STDOUT_FILENO);
+#endif
+  stdout = freopen("/dev/null", "w", stdout);
+}
+
+void reopen_stdout() {
+#ifdef _WIN32
+  close(STDOUT_FILENO);
+  fdopen(dup(_STREAM_STDOUT), "wa");
+  close(_STREAM_STDOUT);
+#else
+  stdout = freopen("/dev/stdout", "w", stdout);
+#endif
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/stream.h	Fri Dec 28 15:44:28 2012 +0100
@@ -0,0 +1,52 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 
+ * Copyright 2011 Mike Becker. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ *
+ * stream.h
+ *
+ *  Created on: 20.09.2011
+ *      Author: Mike
+ */
+
+#ifndef STREAM_H_
+#define STREAM_H_
+
+#include "stdinc.h"
+
+#ifdef _WIN32
+int _STREAM_STDOUT;
+#endif
+
+#ifdef _cplusplus
+extern "C" {
+#endif
+
+void close_stdout();
+void reopen_stdout();
+
+#ifdef _cplusplus
+extern "C" }
+#endif
+
+#endif /* STREAM_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/string_list.c	Fri Dec 28 15:44:28 2012 +0100
@@ -0,0 +1,58 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 
+ * Copyright 2011 Mike Becker. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ *
+ * string_list.c
+ *
+ *  Created on: 15.09.2011
+ *      Author: Mike
+ */
+
+#include "string_list.h"
+
+string_list_t* new_string_list_t() {
+  string_list_t* stringList = malloc(sizeof(string_list_t));
+  stringList->count = 0;
+  stringList->items = NULL;
+
+  return stringList;
+}
+
+void destroy_string_list_t(string_list_t* list) {
+  if (list->items != NULL) {
+    free(list->items);
+  }
+  free(list);
+}
+
+void add_string(string_list_t* list, char* item) {
+  char** reallocated_list =
+    realloc(list->items, sizeof(char*) * (list->count + 1));
+  if (reallocated_list != NULL) {
+    list->items = reallocated_list;
+    list->items[list->count] = item;
+    list->count++;
+  }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/string_list.h	Fri Dec 28 15:44:28 2012 +0100
@@ -0,0 +1,54 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 
+ * Copyright 2011 Mike Becker. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ *
+ * string_list.h
+ *
+ *  Created on: 15.09.2011
+ *      Author: Mike
+ */
+
+#ifndef STRING_LIST_H_
+#define STRING_LIST_H_
+
+#include "stdinc.h"
+
+typedef struct _string_list {
+  size_t count;
+  char** items;
+} string_list_t;
+
+#ifdef _cplusplus
+extern "C" {
+#endif
+
+string_list_t* new_string_list_t();
+void destroy_string_list_t(string_list_t*);
+void add_string(string_list_t*, char*);
+
+#ifdef _cplusplus
+}
+#endif
+
+#endif /* STRING_LIST_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/suffix_fnc.c	Fri Dec 28 15:44:28 2012 +0100
@@ -0,0 +1,49 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 
+ * Copyright 2011 Mike Becker. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ *
+ * suffix_fnc.c
+ *
+ *  Created on: 15.09.2011
+ *      Author: Mike
+ */
+
+#include "suffix_fnc.h"
+
+bool testSuffix(char* filename, string_list_t* list) {
+  bool ret = false;
+  int tokenlen, fnamelen = strlen(filename);
+  for (int t = 0 ; t < list->count ; t++) {
+    tokenlen = strlen(list->items[t]);
+    if (fnamelen >= tokenlen && tokenlen > 0) {
+      if (strncmp(filename+fnamelen-tokenlen,
+                  list->items[t], tokenlen) == 0) {
+        ret = true;
+        break;
+      }
+    }
+  }
+  return ret;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/suffix_fnc.h	Fri Dec 28 15:44:28 2012 +0100
@@ -0,0 +1,40 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 
+ * Copyright 2011 Mike Becker. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ *
+ * suffix_fnc.h
+ *
+ *  Created on: 15.09.2011
+ *      Author: Mike
+ */
+
+#ifndef SUFFIX_FNC_H_
+#define SUFFIX_FNC_H_
+
+#include "stdinc.h"
+#include "string_list.h"
+
+bool testSuffix(char*, string_list_t*);
+
+#endif /* SUFFIX_FNC_H_ */
--- a/stdinc.h	Tue Oct 02 10:49:25 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,17 +0,0 @@
-/*
- * stdinc.h
- *
- *  Created on: 15.09.2011
- *      Author: Mike
- */
-
-#ifndef STDINC_H_
-#define STDINC_H_
-
-#include <stdio.h>
-#include <string.h>
-#include <stdbool.h>
-#include <stdlib.h>
-#include <dirent.h>
-
-#endif /* STDINC_H_ */
--- a/stream.c	Tue Oct 02 10:49:25 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,25 +0,0 @@
-/*
- * stream.c
- *
- *  Created on: 20.09.2011
- *      Author: Mike
- */
-
-#include "stream.h"
-
-void close_stdout() {
-#ifdef _WIN32
-  _STREAM_STDOUT = dup(STDOUT_FILENO);
-#endif
-  freopen("/dev/null", "w", stdout);
-}
-
-void reopen_stdout() {
-#ifdef _WIN32
-  close(STDOUT_FILENO);
-  fdopen(dup(_STREAM_STDOUT), "wa");
-  close(_STREAM_STDOUT);
-#else
-  freopen("/dev/stdout", "w", stdout);
-#endif
-}
--- a/stream.h	Tue Oct 02 10:49:25 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-/*
- * stream.h
- *
- *  Created on: 20.09.2011
- *      Author: Mike
- */
-
-#ifndef STREAM_H_
-#define STREAM_H_
-
-#include "stdinc.h"
-
-#ifdef _WIN32
-int _STREAM_STDOUT;
-#endif
-
-#ifdef _cplusplus
-extern "C" {
-#endif
-
-void close_stdout();
-void reopen_stdout();
-
-#ifdef _cplusplus
-extern "C" }
-#endif
-
-#endif /* STREAM_H_ */
--- a/string_list.c	Tue Oct 02 10:49:25 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-/*
- * string_list.c
- *
- *  Created on: 15.09.2011
- *      Author: Mike
- */
-
-#include "string_list.h"
-
-string_list_t* new_string_list_t() {
-  string_list_t* stringList = malloc(sizeof(string_list_t));
-  stringList->count = 0;
-  stringList->items = NULL;
-
-  return stringList;
-}
-
-void destroy_string_list_t(string_list_t* list) {
-  if (list->items != NULL) {
-    free(list->items);
-  }
-  free(list);
-}
-
-void add_string(string_list_t* list, char* item) {
-  char** reallocated_list =
-    realloc(list->items, sizeof(char*) * (list->count + 1));
-  if (reallocated_list != NULL) {
-    list->items = reallocated_list;
-    list->items[list->count] = item;
-    list->count++;
-  }
-}
-
--- a/string_list.h	Tue Oct 02 10:49:25 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-/*
- * string_list.h
- *
- *  Created on: 15.09.2011
- *      Author: Mike
- */
-
-#ifndef STRING_LIST_H_
-#define STRING_LIST_H_
-
-#include "stdinc.h"
-
-typedef struct _string_list {
-  size_t count;
-  char** items;
-} string_list_t;
-
-#ifdef _cplusplus
-extern "C" {
-#endif
-
-string_list_t* new_string_list_t();
-void destroy_string_list_t(string_list_t*);
-void add_string(string_list_t*, char*);
-
-#ifdef _cplusplus
-}
-#endif
-
-#endif /* STRING_LIST_H_ */
--- a/suffix_fnc.c	Tue Oct 02 10:49:25 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,25 +0,0 @@
-/*
- * suffix_fnc.c
- *
- *  Created on: 15.09.2011
- *      Author: Mike
- */
-
-#include "suffix_fnc.h"
-
-bool testSuffix(char* filename, string_list_t* list) {
-  bool ret = false;
-  int tokenlen, fnamelen = strlen(filename);
-  for (int t = 0 ; t < list->count ; t++) {
-    tokenlen = strlen(list->items[t]);
-    if (fnamelen >= tokenlen && tokenlen > 0) {
-      if (strncmp(filename+fnamelen-tokenlen,
-                  list->items[t], tokenlen) == 0) {
-        ret = true;
-        break;
-      }
-    }
-  }
-  return ret;
-}
-
--- a/suffix_fnc.h	Tue Oct 02 10:49:25 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-/*
- * suffix_fnc.h
- *
- *  Created on: 15.09.2011
- *      Author: Mike
- */
-
-#ifndef SUFFIX_FNC_H_
-#define SUFFIX_FNC_H_
-
-#include "stdinc.h"
-#include "string_list.h"
-
-bool testSuffix(char*, string_list_t*);
-
-#endif /* SUFFIX_FNC_H_ */

mercurial