Description: Reformat source code to Linux kernel coding style
 Reformat all C source and header files using astyle with Linux kernel
 coding style settings:
 - Linux style brace placement (K&R style)
 - Tab indentation (8 spaces)
 - Maximum line length of 80 characters
 .
 This improves code readability and consistency with Linux kernel
 coding conventions. No functional changes.
Author: Bean Huo <beanhuo@micron.com>
Forwarded: no
Last-Update: 2025-11-12

--- a/src/adaptive.c
+++ b/src/adaptive.c
@@ -48,135 +48,145 @@ extern unsigned int elc_oa; /* from enum
 unsigned int *free_wds; /* holds the freed wds - faster reuse */
 unsigned int fd; /* module global - the inotify file descriptor */
 
-void init_free_wds(unsigned int fdin) {
+void init_free_wds(unsigned int fdin)
+{
 
-  unsigned int i;
+	unsigned int i;
 
-  fd = fdin;
+	fd = fdin;
 
-  if((free_wds = (unsigned int *) malloc(max_element_count * sizeof(unsigned int))) == NULL) {
-    fprintf(stderr, "ERROR: could not allocate mem for initial free wds list!\n");
-    exit(EXIT_FAILURE);
-  }
-
-  for(i=0; i <= max_element_count; i++) {
-    free_wds[i] = UINT_MAX;
-  }
+	if((free_wds = (unsigned int *) malloc(max_element_count * sizeof(
+	                unsigned int))) == NULL) {
+		fprintf(stderr, "ERROR: could not allocate mem for initial free wds list!\n");
+		exit(EXIT_FAILURE);
+	}
+
+	for(i=0; i <= max_element_count; i++) {
+		free_wds[i] = UINT_MAX;
+	}
 
 #ifdef _DEBUG
-  printf("INIT_FREE_WDS_LIST: %i\n", max_element_count);
+	printf("INIT_FREE_WDS_LIST: %i\n", max_element_count);
 #endif
 }
 
-void adaptive_add(const char *path, struct felement *lsptr, struct stat *statdat) {
-
-  unsigned int i, id = UINT_MAX;
-  int wd;
-
-  if(isdir(path, statdat) != TRUE)
-    return;
-
-  /* searching the empty element list for a reusable entry */
-  for(i=0; i <= max_element_count; i++) {
-    if(free_wds[i] != UINT_MAX) {
-      id = free_wds[i];
-      break;
-    }
-  }
+void adaptive_add(const char *path, struct felement *lsptr,
+                  struct stat *statdat)
+{
+
+	unsigned int i, id = UINT_MAX;
+	int wd;
+
+	if(isdir(path, statdat) != TRUE)
+		return;
+
+	/* searching the empty element list for a reusable entry */
+	for(i=0; i <= max_element_count; i++) {
+		if(free_wds[i] != UINT_MAX) {
+			id = free_wds[i];
+			break;
+		}
+	}
 
-  if(id == UINT_MAX)
-    id = ++elc_oa;
+	if(id == UINT_MAX)
+		id = ++elc_oa;
 
 #ifdef _DEBUG
-  printf("ADDING: %s %i\n", path, elc_oa);
+	printf("ADDING: %s %i\n", path, elc_oa);
 #endif
-  
-  if((wd = inotify_add_watch(fd, path, IN_ALL_EVENTS)) < 0) {
-    perror("inotify_add_watch()");
-    exit(EXIT_FAILURE);
-  }
-
-  memcpy((&lsptr[id])->path, path, strlen(path));
-  //memcpy(&lsptr[id].festat, statdat, sizeof(struct stat));
-  lsptr[id].id = id;  
-  lsptr[id].wd = wd;  
+
+	if((wd = inotify_add_watch(fd, path, IN_ALL_EVENTS)) < 0) {
+		perror("inotify_add_watch()");
+		exit(EXIT_FAILURE);
+	}
+
+	memcpy((&lsptr[id])->path, path, strlen(path));
+	//memcpy(&lsptr[id].festat, statdat, sizeof(struct stat));
+	lsptr[id].id = id;
+	lsptr[id].wd = wd;
 }
 
-void adaptive_delete(const char *path, struct felement *lsptr, unsigned int wd) {
+void adaptive_delete(const char *path, struct felement *lsptr, unsigned int wd)
+{
 
-  if(wd == 1) /* dirty workaround! */
-    return;
+	if(wd == 1) /* dirty workaround! */
+		return;
 
-  unsigned int i, id = UINT_MAX;
+	unsigned int i, id = UINT_MAX;
 
-  /* getting the element id */
-  for(i=0; i <= elc_oa; i++) {
-    if(lsptr[i].wd == wd) {
-      id = lsptr[i].id;
-      break;
-    }
-  }
+	/* getting the element id */
+	for(i=0; i <= elc_oa; i++) {
+		if(lsptr[i].wd == wd) {
+			id = lsptr[i].id;
+			break;
+		}
+	}
 
 #ifdef _DEBUG
-  printf("removing wd -> %i path -> %s\n", wd, path);
+	printf("removing wd -> %i path -> %s\n", wd, path);
 #endif
-  if(inotify_rm_watch(fd, wd) != 0) {
-    if(errno == EBADF) {
-      perror("inotify_rm_watch()");
-      exit(EXIT_FAILURE);
-    }else{
+	if(inotify_rm_watch(fd, wd) != 0) {
+		if(errno == EBADF) {
+			perror("inotify_rm_watch()");
+			exit(EXIT_FAILURE);
+		} else {
 #ifdef _DEBUG
-      fprintf(stderr, "WARNING: inotify_rm_watch(): Invalid argument: maybe a symlink issue?\n");
+			fprintf(stderr,
+			        "WARNING: inotify_rm_watch(): Invalid argument: maybe a symlink issue?\n");
 #endif
-    }
-  }
+		}
+	}
 
-  /* adding the empty element list entry to the available entries list */
-  for(i=0; i <= max_element_count; i++) {
-    if(free_wds[i] == UINT_MAX) {
-      free_wds[i] = id;
-      break;
-    }
-  }
+	/* adding the empty element list entry to the available entries list */
+	for(i=0; i <= max_element_count; i++) {
+		if(free_wds[i] == UINT_MAX) {
+			free_wds[i] = id;
+			break;
+		}
+	}
 
-  //elc_oa--;
-  return;
+	//elc_oa--;
+	return;
 }
 
-int adaptive_action(int event_mask, const char *path, struct felement *lsptr, struct stat *statdat, unsigned int wd) {
-
-  switch(event_mask) {
-    case FSPY_IN_DIR_CREATE:
-          adaptive_add(path, lsptr, statdat);
-          break;
-    /*case FSPY_IN_DIR_DELETE:
-          adaptive_delete(path, wd);
-          break;*/
-    case FSPY_IN_DELETE_SELF:
-          adaptive_delete(path, lsptr, wd);
-          break;
-    /*case FSPY_IN_MOVE_SELF:
-          break;
-    case FSPY_IN_MOVED_FROM:
-          adaptive_delete(path, lsptr, statdat);
-          break;
-    case FSPY_IN_MOVED_TO:
-          adaptive_add(path, lsptr, statdat);
-          break;*/
-    default :
-          return FALSE;
-          break;
-  }
+int adaptive_action(int event_mask, const char *path, struct felement *lsptr,
+                    struct stat *statdat, unsigned int wd)
+{
+
+	switch(event_mask) {
+	case FSPY_IN_DIR_CREATE:
+		adaptive_add(path, lsptr, statdat);
+		break;
+	/*case FSPY_IN_DIR_DELETE:
+	      adaptive_delete(path, wd);
+	      break;*/
+	case FSPY_IN_DELETE_SELF:
+		adaptive_delete(path, lsptr, wd);
+		break;
+	/*case FSPY_IN_MOVE_SELF:
+	      break;
+	case FSPY_IN_MOVED_FROM:
+	      adaptive_delete(path, lsptr, statdat);
+	      break;
+	case FSPY_IN_MOVED_TO:
+	      adaptive_add(path, lsptr, statdat);
+	      break;*/
+	default :
+		return FALSE;
+		break;
+	}
 
-  return TRUE; /* foo */
+	return TRUE; /* foo */
 }
 
-int adaptive_check(int event_mask, const char *path, struct felement *lsptr, struct stat *statdat, unsigned int wd) {
-
-  if(event_mask & FSPY_IN_NEED_ACTION) {
-    if(adaptive_action(event_mask, path, lsptr, statdat, wd) == TRUE)
-      return TRUE;
-  }
+int adaptive_check(int event_mask, const char *path, struct felement *lsptr,
+                   struct stat *statdat, unsigned int wd)
+{
+
+	if(event_mask & FSPY_IN_NEED_ACTION) {
+		if(adaptive_action(event_mask, path, lsptr, statdat, wd) == TRUE)
+			return TRUE;
+	}
 
-  return FALSE;
+	return FALSE;
 }
--- a/src/adaptive.h
+++ b/src/adaptive.h
@@ -36,6 +36,7 @@
 #include "fspy.h"
 
 void init_free_wds(unsigned int fdin);
-int adaptive_check(int event_mask, const char *path, struct felement *lsptr, struct stat *statdat, unsigned int wd);
+int adaptive_check(int event_mask, const char *path, struct felement *lsptr,
+                   struct stat *statdat, unsigned int wd);
 
 #endif
--- a/src/diff.c
+++ b/src/diff.c
@@ -54,115 +54,133 @@ struct festat *felsptr;
 /* global diffing element counter */
 unsigned int delc_oa = 0;
 
-struct festat *init_diff(void) {
+struct festat *init_diff(void)
+{
 
-  dprint.s = dprint.A = dprint.M = dprint.S = dprint.O = dprint.U = dprint.G = dprint.I = dprint.D = 0;
+	dprint.s = dprint.A = dprint.M = dprint.S = dprint.O = dprint.U = dprint.G =
+	                dprint.I = dprint.D = 0;
 
-  if((felsptr = (struct festat *) malloc(DIFF_ELEMENT_INIT_COUNT * sizeof(struct festat))) == NULL) {
-    fprintf(stderr, "ERROR: could not allocate mem for initial festat list!\n");
-    exit(EXIT_FAILURE);
-  }
+	if((felsptr = (struct festat *) malloc(DIFF_ELEMENT_INIT_COUNT * sizeof(
+	                struct festat))) == NULL) {
+		fprintf(stderr, "ERROR: could not allocate mem for initial festat list!\n");
+		exit(EXIT_FAILURE);
+	}
 
 #ifdef _DEBUG
-  printf("INIT_FESTAT_LIST: %i\n", DIFF_ELEMENT_INIT_COUNT);
+	printf("INIT_FESTAT_LIST: %i\n", DIFF_ELEMENT_INIT_COUNT);
 #endif
 
-  return felsptr;
+	return felsptr;
 }
 
-struct festat *extend_diff_list(struct festat *felsptr) {
+struct festat *extend_diff_list(struct festat *felsptr)
+{
 
-  if((felsptr = (struct festat *) realloc(felsptr, (delc_oa + DIFF_ELEMENT_INIT_COUNT) * sizeof(struct festat))) == NULL) {
-    fprintf(stderr, "ERROR: could not reallocate mem to extend dir list!\n");
-    exit(EXIT_FAILURE);
-  } 
+	if((felsptr = (struct festat *) realloc(felsptr,
+	                                        (delc_oa + DIFF_ELEMENT_INIT_COUNT) * sizeof(struct festat))) == NULL) {
+		fprintf(stderr, "ERROR: could not reallocate mem to extend dir list!\n");
+		exit(EXIT_FAILURE);
+	}
 
 #ifdef _DEBUG
-  printf("EXTEND_DIFF_LIST: %i (%li)\n", delc_oa + DIFF_ELEMENT_INIT_COUNT, (delc_oa + DIFF_ELEMENT_INIT_COUNT) * sizeof(struct festat));
+	printf("EXTEND_DIFF_LIST: %i (%li)\n", delc_oa + DIFF_ELEMENT_INIT_COUNT,
+	       (delc_oa + DIFF_ELEMENT_INIT_COUNT) * sizeof(struct festat));
 #endif
 
-  return felsptr;
+	return felsptr;
 }
 
-void diffing(char *fpath, struct stat *statdat, struct diffprint *dprintptr, char *diffstring) {
+void diffing(char *fpath, struct stat *statdat, struct diffprint *dprintptr,
+             char *diffstring)
+{
+
+	char *mystrin_tmp;
+	char *mystr;
+	char mychar;
+	char *freeme;
 
-  char *mystrin_tmp;
-  char *mystr;
-  char mychar;
-  char *freeme;
-
-  unsigned int i;
+	unsigned int i;
 
 #ifdef _DEBUG
-  printf("DIFFING: %s\n", fpath);
+	printf("DIFFING: %s\n", fpath);
 #endif
 
-  /* getting the element id */
-  for(i=0; i <= delc_oa; i++) {
-    if(strcmp(felsptr[i].path, fpath) == 0)
-      break;
-  }
-
-  freeme = mystrin_tmp = strdup(diffstring);
-
-  while((mystr = strtok(mystrin_tmp, DELIM))) {
-    if(strlen(mystr) == 1) {
-      mychar = mystr[0];
-
-      switch(mychar) {
-        case  's':  if(memcmp(&felsptr[i].statdat.st_size, &statdat->st_size, sizeof(off_t))) {
-                      dprintptr->s = 1;
-                      memcpy(&felsptr[i].statdat.st_size, &statdat->st_size, sizeof(off_t));
-                    }
-                    break;
-        case  'A':  if(memcmp(&felsptr[i].statdat.st_atime, &statdat->st_atime, sizeof(time_t))) {
-                      dprintptr->A = 1;
-                      memcpy(&felsptr[i].statdat.st_atime, &statdat->st_atime, sizeof(time_t));
-                    }
-                    break;
-        case  'M':  if(memcmp(&felsptr[i].statdat.st_mtime, &statdat->st_mtime, sizeof(time_t))) {
-                      dprintptr->M = 1;
-                      memcpy(&felsptr[i].statdat.st_mtime, &statdat->st_mtime, sizeof(time_t));
-                    }
-                    break;
-        case  'S':  if(memcmp(&felsptr[i].statdat.st_ctime, &statdat->st_ctime, sizeof(time_t))) {
-                      dprintptr->S = 1;
-                      memcpy(&felsptr[i].statdat.st_ctime, &statdat->st_ctime, sizeof(time_t));
-                    }
-                    break;
-        case  'O':  if(memcmp(&felsptr[i].statdat.st_mode, &statdat->st_mode, sizeof(mode_t))) {
-                      dprintptr->O = 1;
-                      memcpy(&felsptr[i].statdat.st_mode, &statdat->st_mode, sizeof(mode_t));
-                    }
-                    break;
-        case  'U':  if(memcmp(&felsptr[i].statdat.st_uid, &statdat->st_uid, sizeof(uid_t))) {
-                      dprintptr->U = 1;
-                      memcpy(&felsptr[i].statdat.st_uid, &statdat->st_uid, sizeof(uid_t));
-                    }
-                    break;
-        case  'G':  if(memcmp(&felsptr[i].statdat.st_gid, &statdat->st_gid, sizeof(gid_t))) {
-                      dprintptr->G = 1;
-                      memcpy(&felsptr[i].statdat.st_gid, &statdat->st_gid, sizeof(gid_t));
-                    }
-                    break;
-        case  'I':  if(memcmp(&felsptr[i].statdat.st_ino, &statdat->st_ino, sizeof(ino_t))) {
-                      dprintptr->I = 1;
-                      memcpy(&felsptr[i].statdat.st_ino, &statdat->st_ino, sizeof(ino_t));
-                    }
-                    break;
-        case  'D':  if(memcmp(&felsptr[i].statdat.st_dev, &statdat->st_dev, sizeof(dev_t))) {
-                      dprintptr->D = 1;
-                      memcpy(&felsptr[i].statdat.st_dev, &statdat->st_dev, sizeof(dev_t));
-                    }
-                    break;
-        default  :  printf("diffing()->WARNING: This should never happen!!!\n");
-                    break;
-      }
-    }
-
-    freeme = mystrin_tmp;
-    mystrin_tmp = NULL;
-  }
+	/* getting the element id */
+	for(i=0; i <= delc_oa; i++) {
+		if(strcmp(felsptr[i].path, fpath) == 0)
+			break;
+	}
+
+	freeme = mystrin_tmp = strdup(diffstring);
+
+	while((mystr = strtok(mystrin_tmp, DELIM))) {
+		if(strlen(mystr) == 1) {
+			mychar = mystr[0];
+
+			switch(mychar) {
+			case  's':
+				if(memcmp(&felsptr[i].statdat.st_size, &statdat->st_size, sizeof(off_t))) {
+					dprintptr->s = 1;
+					memcpy(&felsptr[i].statdat.st_size, &statdat->st_size, sizeof(off_t));
+				}
+				break;
+			case  'A':
+				if(memcmp(&felsptr[i].statdat.st_atime, &statdat->st_atime, sizeof(time_t))) {
+					dprintptr->A = 1;
+					memcpy(&felsptr[i].statdat.st_atime, &statdat->st_atime, sizeof(time_t));
+				}
+				break;
+			case  'M':
+				if(memcmp(&felsptr[i].statdat.st_mtime, &statdat->st_mtime, sizeof(time_t))) {
+					dprintptr->M = 1;
+					memcpy(&felsptr[i].statdat.st_mtime, &statdat->st_mtime, sizeof(time_t));
+				}
+				break;
+			case  'S':
+				if(memcmp(&felsptr[i].statdat.st_ctime, &statdat->st_ctime, sizeof(time_t))) {
+					dprintptr->S = 1;
+					memcpy(&felsptr[i].statdat.st_ctime, &statdat->st_ctime, sizeof(time_t));
+				}
+				break;
+			case  'O':
+				if(memcmp(&felsptr[i].statdat.st_mode, &statdat->st_mode, sizeof(mode_t))) {
+					dprintptr->O = 1;
+					memcpy(&felsptr[i].statdat.st_mode, &statdat->st_mode, sizeof(mode_t));
+				}
+				break;
+			case  'U':
+				if(memcmp(&felsptr[i].statdat.st_uid, &statdat->st_uid, sizeof(uid_t))) {
+					dprintptr->U = 1;
+					memcpy(&felsptr[i].statdat.st_uid, &statdat->st_uid, sizeof(uid_t));
+				}
+				break;
+			case  'G':
+				if(memcmp(&felsptr[i].statdat.st_gid, &statdat->st_gid, sizeof(gid_t))) {
+					dprintptr->G = 1;
+					memcpy(&felsptr[i].statdat.st_gid, &statdat->st_gid, sizeof(gid_t));
+				}
+				break;
+			case  'I':
+				if(memcmp(&felsptr[i].statdat.st_ino, &statdat->st_ino, sizeof(ino_t))) {
+					dprintptr->I = 1;
+					memcpy(&felsptr[i].statdat.st_ino, &statdat->st_ino, sizeof(ino_t));
+				}
+				break;
+			case  'D':
+				if(memcmp(&felsptr[i].statdat.st_dev, &statdat->st_dev, sizeof(dev_t))) {
+					dprintptr->D = 1;
+					memcpy(&felsptr[i].statdat.st_dev, &statdat->st_dev, sizeof(dev_t));
+				}
+				break;
+			default  :
+				printf("diffing()->WARNING: This should never happen!!!\n");
+				break;
+			}
+		}
+
+		freeme = mystrin_tmp;
+		mystrin_tmp = NULL;
+	}
 
-  free(freeme);
+	free(freeme);
 }
--- a/src/diff.h
+++ b/src/diff.h
@@ -31,12 +31,13 @@
 #ifndef _DIFF_H
 #define _DIFF_H
 
-  #ifndef DELIM
-    #define DELIM ","
-  #endif
+#ifndef DELIM
+#define DELIM ","
+#endif
 
 struct festat *init_diff(void);
 struct festat *extend_diff_list(struct festat *felsptr);
-void diffing(char *fpath, struct stat *statdat, struct diffprint *dprintptr, char *diffstring);
+void diffing(char *fpath, struct stat *statdat, struct diffprint *dprintptr,
+             char *diffstring);
 
 #endif
--- a/src/enumdirs.c
+++ b/src/enumdirs.c
@@ -57,190 +57,204 @@ unsigned int elc_oa = 0; /* over all ele
 
 /* ATTENTION: the max num. of elements must not be greater than /proc/sys/fs/inotify/max_user_watches */
 
-int grab_max_element_count(void) {
+int grab_max_element_count(void)
+{
 
-  int fd;
-  char buf[64]={0};
+	int fd;
+	char buf[64]= {0};
 
-  fd = open("/proc/sys/fs/inotify/max_user_watches", O_RDONLY);
-  if(fd >= 0) {
-    read(fd, buf, 64);
-  }else{
-    perror("open()");
-    exit(EXIT_FAILURE);
-  }
+	fd = open("/proc/sys/fs/inotify/max_user_watches", O_RDONLY);
+	if(fd >= 0) {
+		read(fd, buf, 64);
+	} else {
+		perror("open()");
+		exit(EXIT_FAILURE);
+	}
 
-  return atoi(buf);
+	return atoi(buf);
 }
 
-struct felement *init_list(void) {
+struct felement *init_list(void)
+{
 
-  struct felement *lsptr;
+	struct felement *lsptr;
 
-  if((lsptr = (struct felement *) malloc(ELEMENT_INIT_COUNT * sizeof(struct felement))) == NULL) {
-    fprintf(stderr, "ERROR: could not allocate mem for initial dir list!\n");
-    exit(EXIT_FAILURE);
-  }
+	if((lsptr = (struct felement *) malloc(ELEMENT_INIT_COUNT * sizeof(
+	                struct felement))) == NULL) {
+		fprintf(stderr, "ERROR: could not allocate mem for initial dir list!\n");
+		exit(EXIT_FAILURE);
+	}
 
 #ifdef _DEBUG
-  printf("INIT_LIST: %i\n", ELEMENT_INIT_COUNT);
+	printf("INIT_LIST: %i\n", ELEMENT_INIT_COUNT);
 #endif
 
-  return lsptr;
+	return lsptr;
 }
 
-struct felement *extend_list(struct felement *lsptr) {
+struct felement *extend_list(struct felement *lsptr)
+{
 
-  if((lsptr = (struct felement *) realloc(lsptr, (elc_oa + ELEMENT_INIT_COUNT) * sizeof(struct felement))) == NULL) {
-    fprintf(stderr, "ERROR: could not reallocate mem to extend dir list!\n");
-    exit(EXIT_FAILURE);
-  } 
+	if((lsptr = (struct felement *) realloc(lsptr,
+	                                        (elc_oa + ELEMENT_INIT_COUNT) * sizeof(struct felement))) == NULL) {
+		fprintf(stderr, "ERROR: could not reallocate mem to extend dir list!\n");
+		exit(EXIT_FAILURE);
+	}
 
 #ifdef _DEBUG
-  printf("EXTEND_LIST: %i (%li)\n", elc_oa + ELEMENT_INIT_COUNT, (elc_oa + ELEMENT_INIT_COUNT) * sizeof(struct felement));
+	printf("EXTEND_LIST: %i (%li)\n", elc_oa + ELEMENT_INIT_COUNT,
+	       (elc_oa + ELEMENT_INIT_COUNT) * sizeof(struct felement));
 #endif
 
-  return lsptr;
+	return lsptr;
 }
 
-int pathlookup(char *lpath, unsigned int wd, struct felement *lsptr) {
+int pathlookup(char *lpath, unsigned int wd, struct felement *lsptr)
+{
 
-  unsigned int cnt = 0;
+	unsigned int cnt = 0;
 
-  /* TODO: optimize this! there should be no need to copy that value - just point to it! */
-  while(cnt <= elc_oa) {
-    if(lsptr[cnt].wd == wd) {
-      memcpy(lpath, lsptr[cnt].path, ELEMENT_SIZE);
-      return TRUE;
-    }
-    cnt++;
-  }
-
-  return FALSE;
-}
-
-struct felement *grabdirs(const char *initial_path, struct felement *lsptr, struct festat *felsptr) {
-
-  DIR *dirfd;
-  struct dirent *dp;
-  struct stat tmp_stat;
-
-  char path[ELEMENT_SIZE] = {0};
-  char ip_local[ELEMENT_SIZE] = {0};
-
-  memcpy(ip_local, initial_path, strlen(initial_path));
-
-  if((dirfd = (DIR *)opendir(ip_local)) == NULL) {
-    perror("opendir()");
-    return NULL;
-  }
-
-  if(ip_local[strlen(ip_local)-1] != '/')
-    strcat(ip_local, "/");
-
-  while(dirfd) {
-    if((dp = readdir(dirfd)) != NULL) {
-      /* TODO: optimize string handling */
-      memset(path, 0, ELEMENT_SIZE);
-      if(strlen(ip_local) > ELEMENT_SIZE) {
-        fprintf(stderr, "ERROR: grabdirs(): ip_local to long!\n");
-        exit(EXIT_FAILURE);
-      }else{
-        strcat(path, ip_local);
-      }
-      if((strlen(dp->d_name) + strlen(ip_local)) > ELEMENT_SIZE) {
-        fprintf(stderr, "ERROR: grabdirs(): ip_local + dp->d_name to long!\n");
-        exit(EXIT_FAILURE);
-      }else{
-        strcat(path, dp->d_name);
-      }
-      if(!((strcmp(dp->d_name, "..") == 0) || (strcmp(dp->d_name, ".") == 0))) {
-        if(statit(path, &tmp_stat) != TRUE) {
-          fprintf(stderr, "ERROR: grabdirs()->statit(): returned != TRUE !\n");
-          exit(EXIT_FAILURE);
-        }
-        /* TODO: !!! add the elements to the diffing list!!! */
-        if(diffstring != NULL) {
-          memcpy((&felsptr[delc_oa])->path, path, strlen(path));
-          memcpy(&felsptr[delc_oa].statdat, &tmp_stat, sizeof(struct stat));
-          felsptr[delc_oa].id = delc_oa;
-          delc_oa++;
-        }
-        if(isdir(path, &tmp_stat) == TRUE) {
-          if(path[strlen(path)-1] != '/')
-            strcat(path, "/");
+	/* TODO: optimize this! there should be no need to copy that value - just point to it! */
+	while(cnt <= elc_oa) {
+		if(lsptr[cnt].wd == wd) {
+			memcpy(lpath, lsptr[cnt].path, ELEMENT_SIZE);
+			return TRUE;
+		}
+		cnt++;
+	}
+
+	return FALSE;
+}
+
+struct felement *grabdirs(const char *initial_path, struct felement *lsptr,
+                          struct festat *felsptr)
+{
+
+	DIR *dirfd;
+	struct dirent *dp;
+	struct stat tmp_stat;
+
+	char path[ELEMENT_SIZE] = {0};
+	char ip_local[ELEMENT_SIZE] = {0};
+
+	memcpy(ip_local, initial_path, strlen(initial_path));
+
+	if((dirfd = (DIR *)opendir(ip_local)) == NULL) {
+		perror("opendir()");
+		return NULL;
+	}
+
+	if(ip_local[strlen(ip_local)-1] != '/')
+		strcat(ip_local, "/");
+
+	while(dirfd) {
+		if((dp = readdir(dirfd)) != NULL) {
+			/* TODO: optimize string handling */
+			memset(path, 0, ELEMENT_SIZE);
+			if(strlen(ip_local) > ELEMENT_SIZE) {
+				fprintf(stderr, "ERROR: grabdirs(): ip_local to long!\n");
+				exit(EXIT_FAILURE);
+			} else {
+				strcat(path, ip_local);
+			}
+			if((strlen(dp->d_name) + strlen(ip_local)) > ELEMENT_SIZE) {
+				fprintf(stderr, "ERROR: grabdirs(): ip_local + dp->d_name to long!\n");
+				exit(EXIT_FAILURE);
+			} else {
+				strcat(path, dp->d_name);
+			}
+			if(!((strcmp(dp->d_name, "..") == 0) || (strcmp(dp->d_name, ".") == 0))) {
+				if(statit(path, &tmp_stat) != TRUE) {
+					fprintf(stderr, "ERROR: grabdirs()->statit(): returned != TRUE !\n");
+					exit(EXIT_FAILURE);
+				}
+				/* TODO: !!! add the elements to the diffing list!!! */
+				if(diffstring != NULL) {
+					memcpy((&felsptr[delc_oa])->path, path, strlen(path));
+					memcpy(&felsptr[delc_oa].statdat, &tmp_stat, sizeof(struct stat));
+					felsptr[delc_oa].id = delc_oa;
+					delc_oa++;
+				}
+				if(isdir(path, &tmp_stat) == TRUE) {
+					if(path[strlen(path)-1] != '/')
+						strcat(path, "/");
 #ifdef _DEBUG
-          printf("DIR: %s\n", path);
+					printf("DIR: %s\n", path);
 #endif
-          if(!((filterstring != NULL) ? (reg_match(path) == TRUE):TRUE) && ((ifilterstring != NULL) ? (ireg_match(path) == TRUE):TRUE) && ((typestring != NULL) ? (checktype(path, NULL, typestring, NULL) == TRUE):TRUE))
-            continue;
-          if((elc_oa > 0) && (elc_oa % ELEMENT_SIZE == 0)) {
-            lsptr = (struct felement *) extend_list(lsptr);
-          }
-          if(++elc_oa > max_element_count) {
-            /* TODO: prop. we should just warn the user and stop grabbing dirs...? */
-            fprintf(stderr, "ERROR: max_user_watches (%i) reached!\n", max_element_count);
-            exit(EXIT_FAILURE);
-          }else{
-            if(strlen(path) > ELEMENT_SIZE) {
-              fprintf(stderr, "ERROR: grabdirs(): path to long!\n");
-              exit(EXIT_FAILURE);
-            }else{
-              memcpy((&lsptr[elc_oa])->path, path, strlen(path));
-              //memcpy(&lsptr[elc_oa].festat, &tmp_stat, sizeof(struct stat));
-              lsptr[elc_oa].id = elc_oa;
+					if(!((filterstring != NULL) ? (reg_match(path) == TRUE):TRUE)
+					    && ((ifilterstring != NULL) ? (ireg_match(path) == TRUE):TRUE)
+					    && ((typestring != NULL) ? (checktype(path, NULL, typestring,
+					                                NULL) == TRUE):TRUE))
+						continue;
+					if((elc_oa > 0) && (elc_oa % ELEMENT_SIZE == 0)) {
+						lsptr = (struct felement *) extend_list(lsptr);
+					}
+					if(++elc_oa > max_element_count) {
+						/* TODO: prop. we should just warn the user and stop grabbing dirs...? */
+						fprintf(stderr, "ERROR: max_user_watches (%i) reached!\n", max_element_count);
+						exit(EXIT_FAILURE);
+					} else {
+						if(strlen(path) > ELEMENT_SIZE) {
+							fprintf(stderr, "ERROR: grabdirs(): path to long!\n");
+							exit(EXIT_FAILURE);
+						} else {
+							memcpy((&lsptr[elc_oa])->path, path, strlen(path));
+							//memcpy(&lsptr[elc_oa].festat, &tmp_stat, sizeof(struct stat));
+							lsptr[elc_oa].id = elc_oa;
 #ifdef _DEBUG
-              printf("ADDED DIR: %s AS: %i\n", path, elc_oa);
+							printf("ADDED DIR: %s AS: %i\n", path, elc_oa);
 #endif
-            }
-          }
-        }else{
-          continue;
-        }
-      }else{
-        continue;
-      }
-    }else{
-      break;
-    }
-  }
-  closedir(dirfd);
+						}
+					}
+				} else {
+					continue;
+				}
+			} else {
+				continue;
+			}
+		} else {
+			break;
+		}
+	}
+	closedir(dirfd);
 
-  return lsptr;
+	return lsptr;
 }
 
 /* small an nasty recursion wrapper */
-struct felement *recwrap(char *initial_path, int recursive_depth, struct stat *statdat) {
+struct felement *recwrap(char *initial_path, int recursive_depth,
+                         struct stat *statdat)
+{
+
+	int recnt; /* temp. recusrion counter */
+	int base, sticky, elc_oa_sticky; /* helper -> placemark */
+	struct felement *lsptr;
+	struct festat *felsptr = NULL;
+
+	lsptr = init_list();
+	if(diffstring != NULL) {
+		felsptr = init_diff();
+		memcpy((&felsptr[delc_oa])->path, initial_path, strlen(initial_path));
+		memcpy(&felsptr[delc_oa].statdat, statdat, sizeof(struct stat));
+		lsptr[delc_oa].id = delc_oa;
+		delc_oa++;
+	}
+
+	/* adding initial path */
+	memcpy((&lsptr[elc_oa])->path, initial_path, strlen(initial_path));
+	lsptr[elc_oa].id = elc_oa;
+
+	if((recursive_depth == 0) || (isdir((&lsptr[elc_oa])->path, NULL) == FALSE))
+		return lsptr;
+
+	for(base = elc_oa, recnt = 0; recnt < recursive_depth; recnt++, base++) {
+		for(elc_oa_sticky = elc_oa, sticky = base; sticky <= elc_oa_sticky; sticky++) {
+			if((lsptr = grabdirs((&lsptr[sticky])->path, lsptr, felsptr)) == NULL) {
+				fprintf(stderr, "ERROR: grabdirs() returned NULL!\n");
+				exit(EXIT_FAILURE);
+			}
+		}
+	}
 
-  int recnt; /* temp. recusrion counter */
-  int base, sticky, elc_oa_sticky; /* helper -> placemark */
-  struct felement *lsptr;
-  struct festat *felsptr = NULL;
-
-  lsptr = init_list();
-  if(diffstring != NULL) {
-    felsptr = init_diff();
-    memcpy((&felsptr[delc_oa])->path, initial_path, strlen(initial_path));
-    memcpy(&felsptr[delc_oa].statdat, statdat, sizeof(struct stat));
-    lsptr[delc_oa].id = delc_oa;
-    delc_oa++;
-  }
-
-  /* adding initial path */
-  memcpy((&lsptr[elc_oa])->path, initial_path, strlen(initial_path));
-  lsptr[elc_oa].id = elc_oa;
-
-  if((recursive_depth == 0) || (isdir((&lsptr[elc_oa])->path, NULL) == FALSE))
-    return lsptr;
-
-  for(base = elc_oa, recnt = 0; recnt < recursive_depth; recnt++, base++) {
-    for(elc_oa_sticky = elc_oa, sticky = base; sticky <= elc_oa_sticky; sticky++) {
-      if((lsptr = grabdirs((&lsptr[sticky])->path, lsptr, felsptr)) == NULL) {
-        fprintf(stderr, "ERROR: grabdirs() returned NULL!\n");
-        exit(EXIT_FAILURE);
-      }
-    }
-  }
-
-  return lsptr;
+	return lsptr;
 }
--- a/src/enumdirs.h
+++ b/src/enumdirs.h
@@ -43,6 +43,7 @@ struct stat;
 
 int grab_max_element_count(void);
 int pathlookup(char *lpath, unsigned int wd, struct felement *lsptr);
-struct felement *recwrap(char *initial_path, int recursive_depth, struct stat *statdat);
+struct felement *recwrap(char *initial_path, int recursive_depth,
+                         struct stat *statdat);
 
 #endif
--- a/src/fsevents.c
+++ b/src/fsevents.c
@@ -33,74 +33,75 @@
 
 #include "fsevents.h"
 
-char *get_event_desc(int event, char *ptr) {
+char *get_event_desc(int event, char *ptr)
+{
 
-  char desc[128]={0};
+	char desc[128]= {0};
 
-  switch(event) {
-    case FSPY_IN_ACCESS:
-      sprintf(desc,"file was accessed");
-      break;
-    case FSPY_IN_MODIFY:
-      sprintf(desc, "file was modified");
-      break;
-    case FSPY_IN_ATTRIB:
-      sprintf(desc, "metadata changed");
-      break;
-    case FSPY_IN_CLOSE_WRITE:
-      sprintf(desc, "writeable file was closed");
-      break;
-    case FSPY_IN_CLOSE_NOWRITE:
-      sprintf(desc, "unwriteable file was closed");
-      break;
-    case FSPY_IN_OPEN:
-      sprintf(desc, "file was opened");
-      break;
-    case FSPY_IN_MOVED_FROM:
-      sprintf(desc, "file was moved from X");
-      break;
-    case FSPY_IN_MOVED_TO:
-      sprintf(desc, "file was moved to Y");
-      break;
-    case FSPY_IN_CREATE:
-      sprintf(desc, "file was created");
-      break;
-    case FSPY_IN_DELETE:
-      sprintf(desc, "file was deleted");
-      break;
-    case FSPY_IN_DELETE_SELF:
-      sprintf(desc, "self was deleted");
-      break;
-    case FSPY_IN_MOVE_SELF:
-      sprintf(desc, "self was moved");
-      break;
-    case FSPY_IN_UNMOUNT:
-      sprintf(desc, "backing fs was unmounted");
-      break;
-    case FSPY_IN_Q_OVERFLOW:
-      sprintf(desc, "event queued overflowed");
-      break;
-    case FSPY_IN_IGNORED:
-      sprintf(desc, "file was ignored");
-      break;
-    case FSPY_IN_DIR_CREATE:
-      sprintf(desc, "dir was created");
-      break;
-    case FSPY_IN_DIR_ATTRIB:
-      sprintf(desc, "metadata changed");
-      break;
-    case FSPY_IN_DIR_ACCESS_1:
-      sprintf(desc, "dir access (1)");
-      break;
-    case FSPY_IN_DIR_ACCESS_2:
-      sprintf(desc, "dir access (2)");
-      break;
-    case FSPY_IN_DIR_DELETE:
-      sprintf(desc, "dir was deleted");
-      break;
-    default :
-      sprintf(desc, "UNKNOWN: %x", event);
-  }
+	switch(event) {
+	case FSPY_IN_ACCESS:
+		sprintf(desc,"file was accessed");
+		break;
+	case FSPY_IN_MODIFY:
+		sprintf(desc, "file was modified");
+		break;
+	case FSPY_IN_ATTRIB:
+		sprintf(desc, "metadata changed");
+		break;
+	case FSPY_IN_CLOSE_WRITE:
+		sprintf(desc, "writeable file was closed");
+		break;
+	case FSPY_IN_CLOSE_NOWRITE:
+		sprintf(desc, "unwriteable file was closed");
+		break;
+	case FSPY_IN_OPEN:
+		sprintf(desc, "file was opened");
+		break;
+	case FSPY_IN_MOVED_FROM:
+		sprintf(desc, "file was moved from X");
+		break;
+	case FSPY_IN_MOVED_TO:
+		sprintf(desc, "file was moved to Y");
+		break;
+	case FSPY_IN_CREATE:
+		sprintf(desc, "file was created");
+		break;
+	case FSPY_IN_DELETE:
+		sprintf(desc, "file was deleted");
+		break;
+	case FSPY_IN_DELETE_SELF:
+		sprintf(desc, "self was deleted");
+		break;
+	case FSPY_IN_MOVE_SELF:
+		sprintf(desc, "self was moved");
+		break;
+	case FSPY_IN_UNMOUNT:
+		sprintf(desc, "backing fs was unmounted");
+		break;
+	case FSPY_IN_Q_OVERFLOW:
+		sprintf(desc, "event queued overflowed");
+		break;
+	case FSPY_IN_IGNORED:
+		sprintf(desc, "file was ignored");
+		break;
+	case FSPY_IN_DIR_CREATE:
+		sprintf(desc, "dir was created");
+		break;
+	case FSPY_IN_DIR_ATTRIB:
+		sprintf(desc, "metadata changed");
+		break;
+	case FSPY_IN_DIR_ACCESS_1:
+		sprintf(desc, "dir access (1)");
+		break;
+	case FSPY_IN_DIR_ACCESS_2:
+		sprintf(desc, "dir access (2)");
+		break;
+	case FSPY_IN_DIR_DELETE:
+		sprintf(desc, "dir was deleted");
+		break;
+	default :
+		sprintf(desc, "UNKNOWN: %x", event);
+	}
 
-  return memcpy(ptr, desc, strlen(desc));
+	return memcpy(ptr, desc, strlen(desc));
 }
--- a/src/fspy.c
+++ b/src/fspy.c
@@ -64,472 +64,506 @@ char *diffstring = NULL;
 char *filterstring = NULL;
 char *ifilterstring = NULL;
 
-static void print_help(void) {
+static void print_help(void)
+{
 
-  printf(
-    "Usage: fspy [options] [file/dir]\n"
-    "\n"
-    "Options:\n"
-    "  -F, --filter STRING/REGEX\ta string or regular expression which will be used to filter the output.\n"
-    "                           \t(the regex will be matched against the whole path e.g. [/etc/passwd])\n"
-    "  -I, --inverted STRING/REGEX\tits the same like -F/--filter but inverted. you can combine both.\n"
-    "                           \te.g. -F '.conf' -I 'wvdial.conf' will filter for files with \".conf\"\n"
-    "                           \tin its name but without \"wvdial.conf\" in it.\n"
-    "  -R, --recursive NUMBER\tenables the recursive engine to look at a depth of NUMBER.\n"
-    "  -A, --adaptive  \t\t(HIGHLY-EXPERIMENTAL) enables the adaptive mode. e.g. if new items will be added\n"
-    "                  \t\twithin the path fspy will automatically add those items to the watch list.\n"
-    "  -D, --diff VALUE\t\t(EXPERIMENTAL) enables the diffing feature.\n"
-    "                  \t\tVALUE may be a comma separated list of:\n"
-    "                  \t\ts - element size (byte)\n"
-    "                  \t\tA - last access time (e.g. Mon Jul 21 21:32:31 2008)\n"
-    "                  \t\tM - last modification time (e.g. Mon Jul 21 21:32:31 2008)\n"
-    "                  \t\tS - last status change time (e.g. Mon Jul 21 21:32:31 2008)\n"
-    "                  \t\tO - permissions (octal)\n"
-    "                  \t\tU - owner (uid)\n"
-    "                  \t\tG - group (gid)\n"
-    "                  \t\tI - inode number\n"
-    "                  \t\tD - device id\n"
-    "  -T, --type VALUE\t\tspecifies the type of objects to look for.\n"
-    "                  \t\tVALUE may be a comma separated list of:\n"
-    "                  \t\tf - regular file\n"
-    "                  \t\td - directory\n"
-    "                  \t\ts - symlink\n"
-    "                  \t\tp - FIFO/pipe\n"
-    "                  \t\tc - character device\n"
-    "                  \t\tb - block device\n"
-    "                  \t\to - socket\n"
-    "                  \t\tdefault is any.\n"
-    "  -O, --output VALUE\t\tspecifies output format.\n"
-    "                  \t\tVALUE may be a comma separated list of:\n"
-    "                  \t\tf - filename\n"
-    "                  \t\tp - path\n"
-    "                  \t\td - access description\n"
-    "                  \t\tt - element type\n"
-    "                  \t\ts - element size (byte)\n"
-    "                  \t\tw - watch descriptor (inotify manpage)\n"
-    "                  \t\tc - cookie (inotify manpage)\n"
-    "                  \t\tm - access mask (inotify manpage | src/fsevents.h)\n"
-    "                  \t\tl - len (inotify manpage)\n"
-    "                  \t\tA - last access time (e.g. Mon Jul 21 21:32:31 2008)\n"
-    "                  \t\tM - last modification time (e.g. Mon Jul 21 21:32:31 2008)\n"
-    "                  \t\tS - last status change time (e.g. Mon Jul 21 21:32:31 2008)\n"
-    "                  \t\tO - permissions (octal)\n"
-    "                  \t\tU - owner (uid)\n"
-    "                  \t\tG - group (gid)\n"
-    "                  \t\tI - inode number\n"
-    "                  \t\tD - device id\n"
-    "                  \t\tT - date and time (for this event) (e.g. Tue Mar 25 09:23:16 CET 2008)\n"
-    //"                  \t\ti - timestamp (for this event) (seconds since 1970-01-01 00:00:00 UTC)\n"
-    //"                  \t\tu - nanoseconds (for this event) (000000000..999999999)\n"
-    "                  \t\te.g.: '[,T,], ,d,:,p,f' would result in:\n"
-    "                  \t\t'[Mon Sep  1 12:31:25 2008] file was opened:/etc/passwd'\n"
-    "                  \t\t(take a look at the README).\n"
-    //"  -v, --verbose\t\t\tactivate verbose mode.\n"
-    //"               \t\t\tuse twice (-vv) or more for more verbose output\n"
-    "  -h, --help\t\t\tthis short help.\n"
-    "      --version\t\t\tversion information.\n"
-    "\n"
-  );
+	printf(
+	        "Usage: fspy [options] [file/dir]\n"
+	        "\n"
+	        "Options:\n"
+	        "  -F, --filter STRING/REGEX\ta string or regular expression which will be used to filter the output.\n"
+	        "                           \t(the regex will be matched against the whole path e.g. [/etc/passwd])\n"
+	        "  -I, --inverted STRING/REGEX\tits the same like -F/--filter but inverted. you can combine both.\n"
+	        "                           \te.g. -F '.conf' -I 'wvdial.conf' will filter for files with \".conf\"\n"
+	        "                           \tin its name but without \"wvdial.conf\" in it.\n"
+	        "  -R, --recursive NUMBER\tenables the recursive engine to look at a depth of NUMBER.\n"
+	        "  -A, --adaptive  \t\t(HIGHLY-EXPERIMENTAL) enables the adaptive mode. e.g. if new items will be added\n"
+	        "                  \t\twithin the path fspy will automatically add those items to the watch list.\n"
+	        "  -D, --diff VALUE\t\t(EXPERIMENTAL) enables the diffing feature.\n"
+	        "                  \t\tVALUE may be a comma separated list of:\n"
+	        "                  \t\ts - element size (byte)\n"
+	        "                  \t\tA - last access time (e.g. Mon Jul 21 21:32:31 2008)\n"
+	        "                  \t\tM - last modification time (e.g. Mon Jul 21 21:32:31 2008)\n"
+	        "                  \t\tS - last status change time (e.g. Mon Jul 21 21:32:31 2008)\n"
+	        "                  \t\tO - permissions (octal)\n"
+	        "                  \t\tU - owner (uid)\n"
+	        "                  \t\tG - group (gid)\n"
+	        "                  \t\tI - inode number\n"
+	        "                  \t\tD - device id\n"
+	        "  -T, --type VALUE\t\tspecifies the type of objects to look for.\n"
+	        "                  \t\tVALUE may be a comma separated list of:\n"
+	        "                  \t\tf - regular file\n"
+	        "                  \t\td - directory\n"
+	        "                  \t\ts - symlink\n"
+	        "                  \t\tp - FIFO/pipe\n"
+	        "                  \t\tc - character device\n"
+	        "                  \t\tb - block device\n"
+	        "                  \t\to - socket\n"
+	        "                  \t\tdefault is any.\n"
+	        "  -O, --output VALUE\t\tspecifies output format.\n"
+	        "                  \t\tVALUE may be a comma separated list of:\n"
+	        "                  \t\tf - filename\n"
+	        "                  \t\tp - path\n"
+	        "                  \t\td - access description\n"
+	        "                  \t\tt - element type\n"
+	        "                  \t\ts - element size (byte)\n"
+	        "                  \t\tw - watch descriptor (inotify manpage)\n"
+	        "                  \t\tc - cookie (inotify manpage)\n"
+	        "                  \t\tm - access mask (inotify manpage | src/fsevents.h)\n"
+	        "                  \t\tl - len (inotify manpage)\n"
+	        "                  \t\tA - last access time (e.g. Mon Jul 21 21:32:31 2008)\n"
+	        "                  \t\tM - last modification time (e.g. Mon Jul 21 21:32:31 2008)\n"
+	        "                  \t\tS - last status change time (e.g. Mon Jul 21 21:32:31 2008)\n"
+	        "                  \t\tO - permissions (octal)\n"
+	        "                  \t\tU - owner (uid)\n"
+	        "                  \t\tG - group (gid)\n"
+	        "                  \t\tI - inode number\n"
+	        "                  \t\tD - device id\n"
+	        "                  \t\tT - date and time (for this event) (e.g. Tue Mar 25 09:23:16 CET 2008)\n"
+	        //"                  \t\ti - timestamp (for this event) (seconds since 1970-01-01 00:00:00 UTC)\n"
+	        //"                  \t\tu - nanoseconds (for this event) (000000000..999999999)\n"
+	        "                  \t\te.g.: '[,T,], ,d,:,p,f' would result in:\n"
+	        "                  \t\t'[Mon Sep  1 12:31:25 2008] file was opened:/etc/passwd'\n"
+	        "                  \t\t(take a look at the README).\n"
+	        //"  -v, --verbose\t\t\tactivate verbose mode.\n"
+	        //"               \t\t\tuse twice (-vv) or more for more verbose output\n"
+	        "  -h, --help\t\t\tthis short help.\n"
+	        "      --version\t\t\tversion information.\n"
+	        "\n"
+	);
 
-  exit(EXIT_SUCCESS);
+	exit(EXIT_SUCCESS);
 }
 
-static void print_version(void) {
+static void print_version(void)
+{
 
-  printf( "version:\t %i.%i.%i\n"
-          "build:\t\t %i\n"
-          "codename:\t %s\n"
-          "author:\t\t %s\n"
-          "website:\t %s\n"
-          , MAJORVERSION, MINORVERSION, SUBMINORVERSION,
-            BUILD, CODENAME, AUTHOR, WEBSITE);
+	printf( "version:\t %i.%i.%i\n"
+	        "build:\t\t %i\n"
+	        "codename:\t %s\n"
+	        "author:\t\t %s\n"
+	        "website:\t %s\n"
+	        , MAJORVERSION, MINORVERSION, SUBMINORVERSION,
+	        BUILD, CODENAME, AUTHOR, WEBSITE);
 
-  exit(EXIT_SUCCESS);
+	exit(EXIT_SUCCESS);
 }
 
-static void my_sig_handle(int sig) {
+static void my_sig_handle(int sig)
+{
 
 #ifdef _DEBUG
-  fprintf(stderr, "caught SIGINT - shutting down!\n");
+	fprintf(stderr, "caught SIGINT - shutting down!\n");
 #endif
-  sigint = 0;
+	sigint = 0;
 }
 
-int main(int argc, char **argv) {
+int main(int argc, char **argv)
+{
 
-  int fd, wd, len = 0;
-  unsigned int cnt = 0, i = 0;
-  char    buf[BUF_LEN], *path, *lpath = NULL;
-  char    pbuf[EVENT_SIZE + 4096];
-  char    fpath[ELEMENT_SIZE * 2] = {0};
-
-  struct  inotify_event *event;
-  struct  felement      *lsptr;
-  struct  stat          *statdat;
-
-  int     co, opt_idx = 0, verbose_lvl = 0, recursive_depth = 0;
-  int     adaptive = FALSE;
-  char    *tmp_filter_string = NULL, *tmp_ifilter_string = NULL;
-  char    *tmp_recursive_depth = NULL, *tmp_output_string = NULL;
-  char    *tmp_type_string = NULL, *tmp_diff_string = NULL, *tsp = NULL, *freeme;
-
-  static const char *opt_str="F:R:O:T:I:D:Avh";
-
-  static struct option long_opts[]={
-    {"filter",          required_argument, NULL, 'F'},
-    {"recursive",       required_argument, NULL, 'R'},
-    {"diff",            required_argument, NULL, 'D'},
-    {"output",          required_argument, NULL, 'O'},
-    {"type",            required_argument, NULL, 'T'},
-    {"inverted",        required_argument, NULL, 'I'},
-    {"adaptive",        no_argument,       NULL, 'A'},
-    {"verbose",         no_argument,       NULL, 'v'},
-    {"help",            no_argument,       NULL, 'h'},
-    {"version",         no_argument,       NULL,  0 },
-    {0,                 0,                 NULL,  0 }
-  };
-
-  /* if no arguments are given... */
-  if(argc < 2)
-    print_help();
-
-  while((co = getopt_long(argc, argv, opt_str, long_opts, &opt_idx)) != -1) {
-    switch(co) {
-      case 0:
-        /* if this option sets a short opt, do nothing else now. */
-        if(long_opts[opt_idx].flag != 0)
-          break;
-        if(strcmp("version", long_opts[opt_idx].name) == 0) {
-          print_version();
-          break;
-        }
-      case 'F':
-        tmp_filter_string = strdup(optarg);
-        break;
-      case 'O':
-        tmp_output_string = strdup(optarg);
-        break;
-      case 'D':
-        tmp_diff_string = strdup(optarg);
-        break;
-      case 'T':
-        tmp_type_string = strdup(optarg);
-        break;
-      case 'R':
-        tmp_recursive_depth = strdup(optarg);
-        break;
-      case 'A':
-        adaptive = TRUE;
-        break;
-      case 'I':
-        tmp_ifilter_string = strdup(optarg);
-        break;
-      case 'v':
-        verbose_lvl++;
-        break;
-      case 'h':
-      default:
-        print_help();
-        break;
-    }   
-  }
-
-  /* check which user calls "us" */
-  if(geteuid() != 0) {
-    fprintf(stdout, "WARNING: running fspy without root permissions might affect normal operation!\n");
-  }
-
-  /* if dir/file is missing */
-  if((argc-optind) < 1)
-    print_help();
-
-  /* check the given recursive depth */
-  if(tmp_recursive_depth != NULL) {
-    if(isnumber(tmp_recursive_depth) == TRUE && strlen(tmp_recursive_depth) < (long unsigned int)(numlen(MAXRECURDEPTH) + 1)) {
-      recursive_depth = atoi(tmp_recursive_depth);
-      if(recursive_depth < MINRECURDEPTH || recursive_depth > MAXRECURDEPTH) {
-        fprintf(stderr, "ERROR: value of argument '-R/--recursive' needs to be a number between %i and %i!\n", MINRECURDEPTH, MAXRECURDEPTH);
-        exit(EXIT_FAILURE);
-      }
-      free(tmp_recursive_depth);
-    }else{
-      fprintf(stderr, "ERROR: value of argument '-R/--recursive' needs to be a number between %i and %i!\n", MINRECURDEPTH, MAXRECURDEPTH);
-      exit(EXIT_FAILURE);
-    }
-  }
-
-  /* check the given filter string */
-  if(tmp_filter_string != NULL) {
-    if(strlen(tmp_filter_string) > MAXREGEXLEN) {
-      fprintf(stderr, "ERROR: the filter string/regex (-F/--filter) need not to be longer than %i chars!\n", MAXREGEXLEN);
-      exit(EXIT_FAILURE);
-    }else{
-      if(reg_comp(tmp_filter_string) != TRUE) {
-        fprintf(stderr, "ERROR: there is a problem with your string/regex (-F/--filter)!\n");
-        exit(EXIT_FAILURE);
-      }
-      filterstring = tmp_filter_string;
-    }
-  }
-
-  /* check the given inverted filter string */
-  if(tmp_ifilter_string != NULL) {
-    if(strlen(tmp_ifilter_string) > MAXREGEXLEN) {
-      fprintf(stderr, "ERROR: the inverted filter string/regex (-I/--inverted) need not to be longer than %i chars!\n", MAXREGEXLEN);
-      exit(EXIT_FAILURE);
-    }else{
-      if(ireg_comp(tmp_ifilter_string) != TRUE) {
-        fprintf(stderr, "ERROR: there is a problem with your string/regex (-I/--inverted)!\n");
-        exit(EXIT_FAILURE);
-      }
-      ifilterstring = tmp_ifilter_string;
-    }
-  }
-
-  /* check the given type string */
-  if(tmp_type_string != NULL) {
-    if(strlen(tmp_type_string) > MAXTYPELEN) {
-      fprintf(stderr, "ERROR: the type string (-T/--type) need not to be longer than %i chars!\n", MAXTYPELEN);
-      exit(EXIT_FAILURE);
-    }else{
-      freeme = typestring = strdup(tmp_type_string);
-      while((tsp = strtok(typestring, DELIM))) {
-        if((strstr(twhitelst, tsp) == NULL) || (strlen(tsp) > 1)) {
-          fprintf(stderr, "ERROR: invalid type/format in type string (-T/--type)!\n");
-          exit(EXIT_FAILURE);
-        }
-        typestring = NULL;
-      }
-      free(freeme);
-      typestring = NULL;
-    }
-  }
-
-  /* check the given output string */
-  if(tmp_output_string != NULL) {
-    if(strlen(tmp_output_string) > MAXOUTSTRLEN) {
-      fprintf(stderr, "ERROR: the output string (-O/--output) need not to be longer than %i chars!\n", MAXOUTSTRLEN);
-      exit(EXIT_FAILURE);
-    }
-  }else{
-    if((tmp_output_string = malloc(MAXOUTSTRLEN * sizeof(char))) == NULL) {
-      fprintf(stderr, "ERROR: could not allocate mem for tmp_output_string (-O/--output)!\n");
-      exit(EXIT_FAILURE);
-    }
-    sprintf(tmp_output_string, "%s", "[,T,], ,d,:,p,f");
-  }
-
-  /* check the given diff string */
-  if(tmp_diff_string != NULL) {
-    if(strlen(tmp_diff_string) > MAXDIFFSTRLEN) {
-      fprintf(stderr, "ERROR: the diff string (-D/--diff) need not to be longer than %i chars!\n", MAXDIFFSTRLEN);
-      exit(EXIT_FAILURE);
-    }else{
-      freeme = diffstring = strdup(tmp_diff_string);
-      while((tsp = strtok(diffstring, DELIM))) {
-        if((strstr(dbasewhitelist, tsp) == NULL) || (strlen(tsp) > 1)) {
-          fprintf(stderr, "ERROR: invalid type/format in type string (-D/--diff)!\n");
-          exit(EXIT_FAILURE);
-        }
-        diffstring = NULL;
-      }
-      free(freeme);
-      freeme = diffstring = strdup(tmp_diff_string);
-      tsp = NULL;
-      while((tsp = strtok(diffstring, DELIM))) {
-        if((strstr(tmp_output_string, tsp) == NULL) || (strlen(tsp) > 1)) {
-          fprintf(stderr, "ERROR: diff string (-D/--diff) contains fields which are not contained within the output string (-O/--output)!\n");
-          exit(EXIT_FAILURE);
-        }
-        diffstring = NULL;
-      }
-      free(freeme);
-      diffstring = strdup(tmp_diff_string);
-      free(tmp_diff_string);
-    }
-  }
-
-  if((lpath = malloc(ELEMENT_SIZE * sizeof(char))) == NULL) {
-    fprintf(stderr, "ERROR: could not allocate mem for lpath (path_lookup)!\n");
-    exit(EXIT_FAILURE);
-  }
-
-  if((path = malloc(ELEMENT_SIZE * sizeof(char))) == NULL) {
-    fprintf(stderr, "ERROR: could not allocate mem for initial path variable!\n");
-    exit(EXIT_FAILURE);
-  }
-
-  if((statdat = (struct stat *) malloc(sizeof(struct stat))) == NULL) {
-    fprintf(stderr, "ERROR: could not allocate mem for statdat (main)!\n");
-    exit(EXIT_FAILURE);
-  }
-
-  /* setting the signal handler */
-  if(signal(SIGINT, my_sig_handle) == SIG_ERR) {
-    perror("signal()");
-  }
-
-  /* getting an inotify instance */
-  if((fd = inotify_init()) < 0) {
-    perror("inotify_init()");
-    exit(EXIT_FAILURE);
-  }
+	int fd, wd, len = 0;
+	unsigned int cnt = 0, i = 0;
+	char    buf[BUF_LEN], *path, *lpath = NULL;
+	char    pbuf[EVENT_SIZE + 4096];
+	char    fpath[ELEMENT_SIZE * 2] = {0};
+
+	struct  inotify_event *event;
+	struct  felement      *lsptr;
+	struct  stat          *statdat;
+
+	int     co, opt_idx = 0, verbose_lvl = 0, recursive_depth = 0;
+	int     adaptive = FALSE;
+	char    *tmp_filter_string = NULL, *tmp_ifilter_string = NULL;
+	char    *tmp_recursive_depth = NULL, *tmp_output_string = NULL;
+	char    *tmp_type_string = NULL, *tmp_diff_string = NULL, *tsp = NULL, *freeme;
+
+	static const char *opt_str="F:R:O:T:I:D:Avh";
+
+	static struct option long_opts[]= {
+		{"filter",          required_argument, NULL, 'F'},
+		{"recursive",       required_argument, NULL, 'R'},
+		{"diff",            required_argument, NULL, 'D'},
+		{"output",          required_argument, NULL, 'O'},
+		{"type",            required_argument, NULL, 'T'},
+		{"inverted",        required_argument, NULL, 'I'},
+		{"adaptive",        no_argument,       NULL, 'A'},
+		{"verbose",         no_argument,       NULL, 'v'},
+		{"help",            no_argument,       NULL, 'h'},
+		{"version",         no_argument,       NULL,  0 },
+		{0,                 0,                 NULL,  0 }
+	};
+
+	/* if no arguments are given... */
+	if(argc < 2)
+		print_help();
+
+	while((co = getopt_long(argc, argv, opt_str, long_opts, &opt_idx)) != -1) {
+		switch(co) {
+		case 0:
+			/* if this option sets a short opt, do nothing else now. */
+			if(long_opts[opt_idx].flag != 0)
+				break;
+			if(strcmp("version", long_opts[opt_idx].name) == 0) {
+				print_version();
+				break;
+			}
+		case 'F':
+			tmp_filter_string = strdup(optarg);
+			break;
+		case 'O':
+			tmp_output_string = strdup(optarg);
+			break;
+		case 'D':
+			tmp_diff_string = strdup(optarg);
+			break;
+		case 'T':
+			tmp_type_string = strdup(optarg);
+			break;
+		case 'R':
+			tmp_recursive_depth = strdup(optarg);
+			break;
+		case 'A':
+			adaptive = TRUE;
+			break;
+		case 'I':
+			tmp_ifilter_string = strdup(optarg);
+			break;
+		case 'v':
+			verbose_lvl++;
+			break;
+		case 'h':
+		default:
+			print_help();
+			break;
+		}
+	}
+
+	/* check which user calls "us" */
+	if(geteuid() != 0) {
+		fprintf(stdout,
+		        "WARNING: running fspy without root permissions might affect normal operation!\n");
+	}
+
+	/* if dir/file is missing */
+	if((argc-optind) < 1)
+		print_help();
+
+	/* check the given recursive depth */
+	if(tmp_recursive_depth != NULL) {
+		if(isnumber(tmp_recursive_depth) == TRUE
+		    && strlen(tmp_recursive_depth) < (long unsigned int)(numlen(
+		                            MAXRECURDEPTH) + 1)) {
+			recursive_depth = atoi(tmp_recursive_depth);
+			if(recursive_depth < MINRECURDEPTH || recursive_depth > MAXRECURDEPTH) {
+				fprintf(stderr,
+				        "ERROR: value of argument '-R/--recursive' needs to be a number between %i and %i!\n",
+				        MINRECURDEPTH, MAXRECURDEPTH);
+				exit(EXIT_FAILURE);
+			}
+			free(tmp_recursive_depth);
+		} else {
+			fprintf(stderr,
+			        "ERROR: value of argument '-R/--recursive' needs to be a number between %i and %i!\n",
+			        MINRECURDEPTH, MAXRECURDEPTH);
+			exit(EXIT_FAILURE);
+		}
+	}
+
+	/* check the given filter string */
+	if(tmp_filter_string != NULL) {
+		if(strlen(tmp_filter_string) > MAXREGEXLEN) {
+			fprintf(stderr,
+			        "ERROR: the filter string/regex (-F/--filter) need not to be longer than %i chars!\n",
+			        MAXREGEXLEN);
+			exit(EXIT_FAILURE);
+		} else {
+			if(reg_comp(tmp_filter_string) != TRUE) {
+				fprintf(stderr,
+				        "ERROR: there is a problem with your string/regex (-F/--filter)!\n");
+				exit(EXIT_FAILURE);
+			}
+			filterstring = tmp_filter_string;
+		}
+	}
+
+	/* check the given inverted filter string */
+	if(tmp_ifilter_string != NULL) {
+		if(strlen(tmp_ifilter_string) > MAXREGEXLEN) {
+			fprintf(stderr,
+			        "ERROR: the inverted filter string/regex (-I/--inverted) need not to be longer than %i chars!\n",
+			        MAXREGEXLEN);
+			exit(EXIT_FAILURE);
+		} else {
+			if(ireg_comp(tmp_ifilter_string) != TRUE) {
+				fprintf(stderr,
+				        "ERROR: there is a problem with your string/regex (-I/--inverted)!\n");
+				exit(EXIT_FAILURE);
+			}
+			ifilterstring = tmp_ifilter_string;
+		}
+	}
+
+	/* check the given type string */
+	if(tmp_type_string != NULL) {
+		if(strlen(tmp_type_string) > MAXTYPELEN) {
+			fprintf(stderr,
+			        "ERROR: the type string (-T/--type) need not to be longer than %i chars!\n",
+			        MAXTYPELEN);
+			exit(EXIT_FAILURE);
+		} else {
+			freeme = typestring = strdup(tmp_type_string);
+			while((tsp = strtok(typestring, DELIM))) {
+				if((strstr(twhitelst, tsp) == NULL) || (strlen(tsp) > 1)) {
+					fprintf(stderr, "ERROR: invalid type/format in type string (-T/--type)!\n");
+					exit(EXIT_FAILURE);
+				}
+				typestring = NULL;
+			}
+			free(freeme);
+			typestring = NULL;
+		}
+	}
+
+	/* check the given output string */
+	if(tmp_output_string != NULL) {
+		if(strlen(tmp_output_string) > MAXOUTSTRLEN) {
+			fprintf(stderr,
+			        "ERROR: the output string (-O/--output) need not to be longer than %i chars!\n",
+			        MAXOUTSTRLEN);
+			exit(EXIT_FAILURE);
+		}
+	} else {
+		if((tmp_output_string = malloc(MAXOUTSTRLEN * sizeof(char))) == NULL) {
+			fprintf(stderr,
+			        "ERROR: could not allocate mem for tmp_output_string (-O/--output)!\n");
+			exit(EXIT_FAILURE);
+		}
+		sprintf(tmp_output_string, "%s", "[,T,], ,d,:,p,f");
+	}
+
+	/* check the given diff string */
+	if(tmp_diff_string != NULL) {
+		if(strlen(tmp_diff_string) > MAXDIFFSTRLEN) {
+			fprintf(stderr,
+			        "ERROR: the diff string (-D/--diff) need not to be longer than %i chars!\n",
+			        MAXDIFFSTRLEN);
+			exit(EXIT_FAILURE);
+		} else {
+			freeme = diffstring = strdup(tmp_diff_string);
+			while((tsp = strtok(diffstring, DELIM))) {
+				if((strstr(dbasewhitelist, tsp) == NULL) || (strlen(tsp) > 1)) {
+					fprintf(stderr, "ERROR: invalid type/format in type string (-D/--diff)!\n");
+					exit(EXIT_FAILURE);
+				}
+				diffstring = NULL;
+			}
+			free(freeme);
+			freeme = diffstring = strdup(tmp_diff_string);
+			tsp = NULL;
+			while((tsp = strtok(diffstring, DELIM))) {
+				if((strstr(tmp_output_string, tsp) == NULL) || (strlen(tsp) > 1)) {
+					fprintf(stderr,
+					        "ERROR: diff string (-D/--diff) contains fields which are not contained within the output string (-O/--output)!\n");
+					exit(EXIT_FAILURE);
+				}
+				diffstring = NULL;
+			}
+			free(freeme);
+			diffstring = strdup(tmp_diff_string);
+			free(tmp_diff_string);
+		}
+	}
+
+	if((lpath = malloc(ELEMENT_SIZE * sizeof(char))) == NULL) {
+		fprintf(stderr, "ERROR: could not allocate mem for lpath (path_lookup)!\n");
+		exit(EXIT_FAILURE);
+	}
+
+	if((path = malloc(ELEMENT_SIZE * sizeof(char))) == NULL) {
+		fprintf(stderr, "ERROR: could not allocate mem for initial path variable!\n");
+		exit(EXIT_FAILURE);
+	}
+
+	if((statdat = (struct stat *) malloc(sizeof(struct stat))) == NULL) {
+		fprintf(stderr, "ERROR: could not allocate mem for statdat (main)!\n");
+		exit(EXIT_FAILURE);
+	}
+
+	/* setting the signal handler */
+	if(signal(SIGINT, my_sig_handle) == SIG_ERR) {
+		perror("signal()");
+	}
+
+	/* getting an inotify instance */
+	if((fd = inotify_init()) < 0) {
+		perror("inotify_init()");
+		exit(EXIT_FAILURE);
+	}
 
-  //TODO: cleanup! error checks! plausibility checks!
-  max_element_count = grab_max_element_count();
+	//TODO: cleanup! error checks! plausibility checks!
+	max_element_count = grab_max_element_count();
 
-  init_free_wds(fd); /* init the list which will hold the freed wds */
+	init_free_wds(fd); /* init the list which will hold the freed wds */
 
 #ifdef _DEBUG
-  printf("MAX_ELEMENTS: %i\n", max_element_count);
+	printf("MAX_ELEMENTS: %i\n", max_element_count);
 #endif
 
-  if(strlen((argv+optind)[0]) > ELEMENT_SIZE) {
-    fprintf(stderr, "ERROR: the given path/file string is to long!\n");
-    exit(EXIT_FAILURE);
-  }else{
-    memcpy(path, (argv+optind)[0], strlen((argv+optind)[0]));
-    if(statit(path, statdat) != TRUE) {
-      fprintf(stderr, "ERROR: main()->statit() returned != TRUE!\n");
-      exit(EXIT_FAILURE);
-    }
-    if(isdir(path, statdat) == TRUE)
-      if(path[strlen(path)-1] != '/')
-        strcat(path, "/");
-  }
+	if(strlen((argv+optind)[0]) > ELEMENT_SIZE) {
+		fprintf(stderr, "ERROR: the given path/file string is to long!\n");
+		exit(EXIT_FAILURE);
+	} else {
+		memcpy(path, (argv+optind)[0], strlen((argv+optind)[0]));
+		if(statit(path, statdat) != TRUE) {
+			fprintf(stderr, "ERROR: main()->statit() returned != TRUE!\n");
+			exit(EXIT_FAILURE);
+		}
+		if(isdir(path, statdat) == TRUE)
+			if(path[strlen(path)-1] != '/')
+				strcat(path, "/");
+	}
 
 #ifdef _DEBUG
-  printf("INIT_PATH: %s\n", path);
+	printf("INIT_PATH: %s\n", path);
 #endif
 
-  /* at this point we hand the dirty work over to the recursive directory parser */
-  lsptr = (struct felement *) recwrap(path, recursive_depth, statdat);
-  
-  while(cnt <= elc_oa) {
+	/* at this point we hand the dirty work over to the recursive directory parser */
+	lsptr = (struct felement *) recwrap(path, recursive_depth, statdat);
+
+	while(cnt <= elc_oa) {
 
 #ifdef _DEBUG
-    printf("ADDING: %s %i", (&lsptr[cnt])->path, cnt);
+		printf("ADDING: %s %i", (&lsptr[cnt])->path, cnt);
 #endif
 
-    /* adding a watch */
-    if((wd = inotify_add_watch(fd, (&lsptr[cnt])->path, IN_ALL_EVENTS)) < 0) {
-      perror("inotify_add_watch()");
-      exit(EXIT_FAILURE);
-    }
-    lsptr[cnt++].wd = wd;
+		/* adding a watch */
+		if((wd = inotify_add_watch(fd, (&lsptr[cnt])->path, IN_ALL_EVENTS)) < 0) {
+			perror("inotify_add_watch()");
+			exit(EXIT_FAILURE);
+		}
+		lsptr[cnt++].wd = wd;
 
 #ifdef _DEBUG
-    printf(" wd: %i\n", lsptr[cnt-1].wd);
+		printf(" wd: %i\n", lsptr[cnt-1].wd);
 #endif
 
-  }
+	}
 
-  /* loop unitl SIGINT arrives */
-  while(sigint) {
-    /* reading inotify_event data from the given inotify instance */
-    if((len += read(fd, buf + len, BUF_LEN - len)) < 0) {
-      perror("read()");
-    }else{
-      while(sigint) {
-        if(len < EVENT_SIZE) {
-          break;
-        }else if(len >= EVENT_SIZE) {
-          memset(pbuf, 0, EVENT_SIZE + 4096);
-          memcpy(pbuf, buf, EVENT_SIZE);
-          event = (struct inotify_event *) pbuf;
-          if((event->len > 0) && ((EVENT_SIZE + event->len) <= len)) {
-            memcpy(pbuf, buf, EVENT_SIZE + event->len);
-          }else if((EVENT_SIZE + event->len) > len) {
-            break;
-          }
-        }
-
-        if((event->len == 0) && (elc_oa == 1)) {
-          strcat(event->name, path);
-        }else{
-          memset(lpath, 0, ELEMENT_SIZE);
-          /* check if there is a path available for this element */
-          if(pathlookup(lpath, event->wd, lsptr) == FALSE)
-            strcat(lpath, "|PATH_LOOKUP_ERROR|");
-        }
-
-        memset(statdat, 0, sizeof(struct stat));
-        memset(fpath, 0, (ELEMENT_SIZE * 2));
-
-        snprintf(fpath, (ELEMENT_SIZE * 2), "%s%s", lpath, event->name);
-
-        if(statit(fpath, statdat) != TRUE) {
-          fprintf(stderr, "ERROR: main()->statit() returned != TRUE!\n");
-          exit(EXIT_FAILURE);
-        }
-
-        if(isdir(fpath, statdat) == TRUE)
-          if(fpath[strlen(fpath)-1] != '/')
-            strcat(fpath, "/");
-
-        if(((filterstring != NULL) ? (reg_match(fpath) == TRUE):TRUE) && ((ifilterstring != NULL) ? (ireg_match(fpath) == TRUE):TRUE) && ((typestring != NULL) ? (checktype(lpath, (struct inotify_event *) event, typestring, statdat) == TRUE):TRUE)) {
-          if(adaptive == TRUE)
-            adaptive_check(event->mask, fpath, lsptr, statdat, event->wd);
-          if(diffstring != NULL) {
-            dprint.s = dprint.A = dprint.M = dprint.S = dprint.O = dprint.U = dprint.G = dprint.I = dprint.D = 0;
-            diffing(fpath, statdat, &dprint, diffstring);
-          }
-          /* TODO: change print_data to use fpath instead of lpath and assembling the fqp on its own */
-          print_data(tmp_output_string, (struct inotify_event *) event, lpath, statdat, &dprint);
-          if(((len > EVENT_SIZE) && (event->len == 0)) || (len > (EVENT_SIZE + event->len) && (event->len > 0)))
-            goto more;
-        }
-
-        memset(buf, 0, BUF_LEN);
-        len = 0;
-
-        break;
-
-        more:
-
-        memmove(buf, buf + (EVENT_SIZE + event->len), (len - (EVENT_SIZE + event->len)));
-        memset(buf + (len - (EVENT_SIZE + event->len)), 0, BUF_LEN - (len - (EVENT_SIZE + event->len)));
-        len = (len - (EVENT_SIZE + event->len));
-      }
-    }
-  }
+	/* loop unitl SIGINT arrives */
+	while(sigint) {
+		/* reading inotify_event data from the given inotify instance */
+		if((len += read(fd, buf + len, BUF_LEN - len)) < 0) {
+			perror("read()");
+		} else {
+			while(sigint) {
+				if(len < EVENT_SIZE) {
+					break;
+				} else if(len >= EVENT_SIZE) {
+					memset(pbuf, 0, EVENT_SIZE + 4096);
+					memcpy(pbuf, buf, EVENT_SIZE);
+					event = (struct inotify_event *) pbuf;
+					if((event->len > 0) && ((EVENT_SIZE + event->len) <= len)) {
+						memcpy(pbuf, buf, EVENT_SIZE + event->len);
+					} else if((EVENT_SIZE + event->len) > len) {
+						break;
+					}
+				}
+
+				if((event->len == 0) && (elc_oa == 1)) {
+					strcat(event->name, path);
+				} else {
+					memset(lpath, 0, ELEMENT_SIZE);
+					/* check if there is a path available for this element */
+					if(pathlookup(lpath, event->wd, lsptr) == FALSE)
+						strcat(lpath, "|PATH_LOOKUP_ERROR|");
+				}
+
+				memset(statdat, 0, sizeof(struct stat));
+				memset(fpath, 0, (ELEMENT_SIZE * 2));
+
+				snprintf(fpath, (ELEMENT_SIZE * 2), "%s%s", lpath, event->name);
+
+				if(statit(fpath, statdat) != TRUE) {
+					fprintf(stderr, "ERROR: main()->statit() returned != TRUE!\n");
+					exit(EXIT_FAILURE);
+				}
+
+				if(isdir(fpath, statdat) == TRUE)
+					if(fpath[strlen(fpath)-1] != '/')
+						strcat(fpath, "/");
+
+				if(((filterstring != NULL) ? (reg_match(fpath) == TRUE):TRUE)
+				    && ((ifilterstring != NULL) ? (ireg_match(fpath) == TRUE):TRUE)
+				    && ((typestring != NULL) ? (checktype(lpath, (struct inotify_event *) event,
+				                                typestring, statdat) == TRUE):TRUE)) {
+					if(adaptive == TRUE)
+						adaptive_check(event->mask, fpath, lsptr, statdat, event->wd);
+					if(diffstring != NULL) {
+						dprint.s = dprint.A = dprint.M = dprint.S = dprint.O = dprint.U = dprint.G =
+						                dprint.I = dprint.D = 0;
+						diffing(fpath, statdat, &dprint, diffstring);
+					}
+					/* TODO: change print_data to use fpath instead of lpath and assembling the fqp on its own */
+					print_data(tmp_output_string, (struct inotify_event *) event, lpath, statdat,
+					           &dprint);
+					if(((len > EVENT_SIZE) && (event->len == 0))
+					    || (len > (EVENT_SIZE + event->len) && (event->len > 0)))
+						goto more;
+				}
+
+				memset(buf, 0, BUF_LEN);
+				len = 0;
+
+				break;
+
+more:
+
+				memmove(buf, buf + (EVENT_SIZE + event->len),
+				        (len - (EVENT_SIZE + event->len)));
+				memset(buf + (len - (EVENT_SIZE + event->len)), 0,
+				       BUF_LEN - (len - (EVENT_SIZE + event->len)));
+				len = (len - (EVENT_SIZE + event->len));
+			}
+		}
+	}
 
-  /* destroying regular expression element */
-  reg_dest();
+	/* destroying regular expression element */
+	reg_dest();
 
 #ifdef _DEBUG
-  printf("elc_oa: %i\n", elc_oa);
+	printf("elc_oa: %i\n", elc_oa);
 #endif
 
-  /* destroying wd's */
-  for(i = 0 ; i <= elc_oa ; i++) {
+	/* destroying wd's */
+	for(i = 0 ; i <= elc_oa ; i++) {
 #ifdef _DEBUG
-  printf("removing number -> %i wd -> %i\n", i ,lsptr[i].wd);
+		printf("removing number -> %i wd -> %i\n", i,lsptr[i].wd);
 #endif
-    if(inotify_rm_watch(fd, lsptr[i].wd) != 0) {
-      if(errno == EBADF) {
-        perror("inotify_rm_watch()");
-        exit(EXIT_FAILURE);
-      }else{
+		if(inotify_rm_watch(fd, lsptr[i].wd) != 0) {
+			if(errno == EBADF) {
+				perror("inotify_rm_watch()");
+				exit(EXIT_FAILURE);
+			} else {
 #ifdef _DEBUG
-        fprintf(stderr, "WARNING: inotify_rm_watch(): Invalid argument: maybe a symlink issue?\n");
+				fprintf(stderr,
+				        "WARNING: inotify_rm_watch(): Invalid argument: maybe a symlink issue?\n");
 #endif
-      }
-    }
-  }
-
-  /* destroying element structure */
-  free(lsptr);
-
-  /* freeing helpers */
-  free(statdat);
-  free(tmp_output_string);
-  free(lpath);
-  free(path);
+			}
+		}
+	}
+
+	/* destroying element structure */
+	free(lsptr);
+
+	/* freeing helpers */
+	free(statdat);
+	free(tmp_output_string);
+	free(lpath);
+	free(path);
 
 #ifdef _DEBUG
-  printf("safely shutting down...\n");
+	printf("safely shutting down...\n");
 #endif
 
-  return 0;
+	return 0;
 }
--- a/src/fspy.h
+++ b/src/fspy.h
@@ -47,7 +47,7 @@
 /* how long could a output string be? */
 #define MAXOUTSTRLEN    128
 /* how long could a diff string be? */
-#define MAXDIFFSTRLEN   MAXOUTSTRLEN 
+#define MAXDIFFSTRLEN   MAXOUTSTRLEN
 /* how deep you wanna look into your folder hirachie? */
 #define MINRECURDEPTH   1
 #define MAXRECURDEPTH   99
@@ -59,27 +59,27 @@
 typedef int boolean_t;
 
 struct felement {
-  unsigned int id;
-  unsigned int wd;
-  char path[ELEMENT_SIZE];
+	unsigned int id;
+	unsigned int wd;
+	char path[ELEMENT_SIZE];
 };
 
 struct festat {
-  unsigned int id;
-  char path[ELEMENT_SIZE];
-  struct stat statdat;
+	unsigned int id;
+	char path[ELEMENT_SIZE];
+	struct stat statdat;
 };
 
 struct diffprint {
-  unsigned int s;
-  unsigned int A;
-  unsigned int M;
-  unsigned int S;
-  unsigned int O;
-  unsigned int U;
-  unsigned int G;
-  unsigned int I;
-  unsigned int D;
+	unsigned int s;
+	unsigned int A;
+	unsigned int M;
+	unsigned int S;
+	unsigned int O;
+	unsigned int U;
+	unsigned int G;
+	unsigned int I;
+	unsigned int D;
 };
 
 #endif
--- a/src/isnumber.c
+++ b/src/isnumber.c
@@ -33,15 +33,16 @@
 #include "fspy.h"
 #include "isnumber.h"
 
-int isnumber(char *nbrstr) {
-  
-  int i = 0;
+int isnumber(char *nbrstr)
+{
 
-  while(nbrstr[i] != '\0') {
-    if(!isdigit(nbrstr[i]))
-      return FALSE;
-    i++;
-  }  
+	int i = 0;
 
-  return TRUE;
+	while(nbrstr[i] != '\0') {
+		if(!isdigit(nbrstr[i]))
+			return FALSE;
+		i++;
+	}
+
+	return TRUE;
 }
--- a/src/numlen.c
+++ b/src/numlen.c
@@ -31,14 +31,15 @@
 #include "fspy.h"
 #include "numlen.h"
 
-int numlen(int nbr) {
-  
-  int i = 0;
+int numlen(int nbr)
+{
 
-  while(nbr != 0) {
-    nbr = nbr / 10;
-    i++;
-  }  
+	int i = 0;
 
-  return i;
+	while(nbr != 0) {
+		nbr = nbr / 10;
+		i++;
+	}
+
+	return i;
 }
--- a/src/output.c
+++ b/src/output.c
@@ -43,87 +43,118 @@
 #include "diff.h"
 
 
-void print_data(char *mystrin, struct inotify_event *event, const char *event_fpath, struct stat *statdat, struct diffprint *dprint) {
+void print_data(char *mystrin, struct inotify_event *event,
+                const char *event_fpath, struct stat *statdat, struct diffprint *dprint)
+{
+
+	char *mystrin_tmp;
+	char *mystr;
+	char mychar;
+	char desc_ptr[128] = {0};
+	char *ctp;
+	char fpath[ELEMENT_SIZE * 2] = {0};
+	char *freeme;
+
+	const char *const normal = "\033[0m";
+	const char *const marked = "\033[1;31m";
+
+	time_t currtime;
+
+	snprintf(fpath, (ELEMENT_SIZE * 2), "%s%s", event_fpath, event->name);
+
+	freeme = mystrin_tmp = strdup(mystrin);
+
+	while((mystr = strtok(mystrin_tmp, DELIM))) {
+		if(strlen(mystr) == 1) {
+			mychar = mystr[0];
+
+			switch(mychar) {
+			case  'f':
+				printf("%s", event->name);
+				break;
+			case  'p':
+				printf("%s", event_fpath);
+				break;
+			case  'd':
+				memset(desc_ptr, 0, 128 * sizeof(char));
+				printf("%s", get_event_desc(event->mask, desc_ptr));
+				break;
+			case  'w':
+				printf("%i", event->wd);
+				break;
+			case  'c':
+				printf("%u", event->cookie);
+				break;
+			case  'm':
+				printf("0x%08x", event->mask);
+				break;
+			case  'l':
+				printf("%u", event->len);
+				break;
+			case  't':
+				memset(desc_ptr, 0, 128 * sizeof(char));
+				printf("%s", gettype(fpath, desc_ptr, statdat));
+				break;
+			/* yeah, i know, thats some kind of dirty style ;)
+			   but i dont like the additional newline at EOL... */
+			case  'A':
+				ctp = ctime(&statdat->st_atime);
+				ctp[strlen(ctp) - 1] = '\0';
+				(dprint->A == 1)?printf("%s%s%s", marked, ctp, normal):printf("%s", ctp);
+				break;
+			case  'M':
+				ctp = ctime(&statdat->st_mtime);
+				ctp[strlen(ctp) - 1] = '\0';
+				(dprint->M == 1)?printf("%s%s%s", marked, ctp, normal):printf("%s", ctp);
+				break;
+			case  'S':
+				ctp = ctime(&statdat->st_ctime);
+				ctp[strlen(ctp) - 1] = '\0';
+				(dprint->S == 1)?printf("%s%s%s", marked, ctp, normal):printf("%s", ctp);
+				break;
+			case  'T':
+				currtime = time(NULL);
+				ctp = ctime(&currtime);
+				ctp[strlen(ctp) - 1] = '\0';
+				printf("%s", ctp);
+				break;
+			case  's':
+				(dprint->s == 1)?printf("%s%lld%s", marked, (long long int) statdat->st_size,
+				                        normal):printf("%lld", (long long int) statdat->st_size);
+				break;
+			case  'U':
+				(dprint->U == 1)?printf("%s%ld%s", marked, (long int) statdat->st_uid,
+				                        normal):printf("%ld", (long int) statdat->st_uid);
+				break;
+			case  'G':
+				(dprint->G == 1)?printf("%s%ld%s", marked, (long int) statdat->st_gid,
+				                        normal):printf("%ld", (long int) statdat->st_gid);
+				break;
+			case  'O':
+				(dprint->O == 1)?printf("%s%lo%s", marked, (unsigned long int) statdat->st_mode,
+				                        normal):printf("%lo", (unsigned long int) statdat->st_mode);
+				break;
+			case  'I':
+				(dprint->I == 1)?printf("%s%ld%s", marked, (long int) statdat->st_ino,
+				                        normal):printf("%ld", (long int) statdat->st_ino);
+				break;
+			case  'D':
+				(dprint->D == 1)?printf("%s%ld%s", marked, (long int) statdat->st_dev,
+				                        normal):printf("%ld", (long int) statdat->st_dev);
+				break;
+			default  :
+				printf("%c", mychar);
+				break;
+			}
+		} else {
+			printf("%s", mystr);
+		}
+
+		freeme = mystrin_tmp;
+		mystrin_tmp = NULL;
+	}
 
-  char *mystrin_tmp;
-  char *mystr;
-  char mychar;
-  char desc_ptr[128] = {0};
-  char *ctp;
-  char fpath[ELEMENT_SIZE * 2] = {0};
-  char *freeme;
-
-  const char *const normal = "\033[0m";
-  const char *const marked = "\033[1;31m";
-
-  time_t currtime;
-  
-  snprintf(fpath, (ELEMENT_SIZE * 2), "%s%s", event_fpath, event->name);
-
-  freeme = mystrin_tmp = strdup(mystrin);
-
-  while((mystr = strtok(mystrin_tmp, DELIM))) {
-    if(strlen(mystr) == 1) {
-      mychar = mystr[0];
-
-      switch(mychar) {
-        case  'f':  printf("%s", event->name);
-                    break;
-        case  'p':  printf("%s", event_fpath);
-                    break;
-        case  'd':  memset(desc_ptr, 0, 128 * sizeof(char)); 
-                    printf("%s", get_event_desc(event->mask, desc_ptr));
-                    break;
-        case  'w':  printf("%i", event->wd);
-                    break;
-        case  'c':  printf("%u", event->cookie);
-                    break;
-        case  'm':  printf("0x%08x", event->mask);
-                    break;
-        case  'l':  printf("%u", event->len);
-                    break;
-        case  't':  memset(desc_ptr, 0, 128 * sizeof(char)); 
-                    printf("%s", gettype(fpath, desc_ptr, statdat));
-                    break;
-                    /* yeah, i know, thats some kind of dirty style ;)
-                       but i dont like the additional newline at EOL... */
-        case  'A':  ctp = ctime(&statdat->st_atime); ctp[strlen(ctp) - 1] = '\0';
-                    (dprint->A == 1)?printf("%s%s%s", marked, ctp, normal):printf("%s", ctp);
-                    break;
-        case  'M':  ctp = ctime(&statdat->st_mtime); ctp[strlen(ctp) - 1] = '\0';
-                    (dprint->M == 1)?printf("%s%s%s", marked, ctp, normal):printf("%s", ctp);
-                    break;
-        case  'S':  ctp = ctime(&statdat->st_ctime); ctp[strlen(ctp) - 1] = '\0';
-                    (dprint->S == 1)?printf("%s%s%s", marked, ctp, normal):printf("%s", ctp);
-                    break;
-        case  'T':  currtime = time(NULL);
-                    ctp = ctime(&currtime); ctp[strlen(ctp) - 1] = '\0';
-                    printf("%s", ctp);
-                    break;
-        case  's':  (dprint->s == 1)?printf("%s%lld%s", marked, (long long int) statdat->st_size, normal):printf("%lld", (long long int) statdat->st_size);
-                    break;
-        case  'U':  (dprint->U == 1)?printf("%s%ld%s", marked, (long int) statdat->st_uid, normal):printf("%ld", (long int) statdat->st_uid);
-                    break;
-        case  'G':  (dprint->G == 1)?printf("%s%ld%s", marked, (long int) statdat->st_gid, normal):printf("%ld", (long int) statdat->st_gid);
-                    break;
-        case  'O':  (dprint->O == 1)?printf("%s%lo%s", marked, (unsigned long int) statdat->st_mode, normal):printf("%lo", (unsigned long int) statdat->st_mode);
-                    break;
-        case  'I':  (dprint->I == 1)?printf("%s%ld%s", marked, (long int) statdat->st_ino, normal):printf("%ld", (long int) statdat->st_ino);
-                    break;
-        case  'D':  (dprint->D == 1)?printf("%s%ld%s", marked, (long int) statdat->st_dev, normal):printf("%ld", (long int) statdat->st_dev);
-                    break;
-        default  :  printf("%c", mychar);
-                    break;
-      }
-    }else{
-      printf("%s", mystr);
-    }
-
-    freeme = mystrin_tmp;
-    mystrin_tmp = NULL;
-  }
+	printf("\n");
 
-  printf("\n");
-
-  free(freeme);
+	free(freeme);
 }
--- a/src/output.h
+++ b/src/output.h
@@ -34,10 +34,11 @@
 #include <sys/stat.h>
 #include <sys/inotify.h>
 
-  #ifndef DELIM
-    #define DELIM ","
-  #endif
+#ifndef DELIM
+#define DELIM ","
+#endif
 
-void print_data(char *mystrin, struct inotify_event *event, const char *event_fpath, struct stat *statdat, struct diffprint *dprint);
+void print_data(char *mystrin, struct inotify_event *event,
+                const char *event_fpath, struct stat *statdat, struct diffprint *dprint);
 
 #endif
--- a/src/regmatch.c
+++ b/src/regmatch.c
@@ -38,45 +38,50 @@
 regex_t re;
 regex_t ire;
 
-int reg_comp(char *pattern) {
+int reg_comp(char *pattern)
+{
 
-  if(regcomp(&re, pattern, REG_EXTENDED|REG_NOSUB|REG_EESCAPE) != 0) {
-    perror("reg_comp()");
-    return FALSE;
-  }
+	if(regcomp(&re, pattern, REG_EXTENDED|REG_NOSUB|REG_EESCAPE) != 0) {
+		perror("reg_comp()");
+		return FALSE;
+	}
 
-  return TRUE;
+	return TRUE;
 }
 
-int ireg_comp(char *pattern) {
+int ireg_comp(char *pattern)
+{
 
-  if(regcomp(&ire, pattern, REG_EXTENDED|REG_NOSUB|REG_EESCAPE) != 0) {
-    perror("ireg_comp()");
-    return FALSE;
-  }
+	if(regcomp(&ire, pattern, REG_EXTENDED|REG_NOSUB|REG_EESCAPE) != 0) {
+		perror("ireg_comp()");
+		return FALSE;
+	}
 
-  return TRUE;
+	return TRUE;
 }
 
-int reg_match(const char *string) {
+int reg_match(const char *string)
+{
 
-  if(regexec(&re, string, (size_t) 0, NULL, 0) != 0) {
-    return FALSE;
-  }
+	if(regexec(&re, string, (size_t) 0, NULL, 0) != 0) {
+		return FALSE;
+	}
 
-  return TRUE;
+	return TRUE;
 }
 
-int ireg_match(const char *string) {
+int ireg_match(const char *string)
+{
 
-  if(!(regexec(&ire, string, (size_t) 0, NULL, 0) != 0)) {
-    return FALSE;
-  }
+	if(!(regexec(&ire, string, (size_t) 0, NULL, 0) != 0)) {
+		return FALSE;
+	}
 
-  return TRUE;
+	return TRUE;
 }
 
-void reg_dest(void) {
+void reg_dest(void)
+{
 
-  (void) regfree(&re);
+	(void) regfree(&re);
 }
--- a/src/stating.c
+++ b/src/stating.c
@@ -43,156 +43,168 @@
 /* little helper variable... do not miss to update when more types are added! */
 char twhitelst[] = "fdspcbo";
 
-char *gettype(const char *fpath, char *ptr, struct stat *statdat) {
+char *gettype(const char *fpath, char *ptr, struct stat *statdat)
+{
 
-  char desc[128] = {0};
-  
-  switch (statdat->st_mode & S_IFMT) {
-    case S_IFBLK:
-      sprintf(desc, "block device");
-      break;
-    case S_IFCHR:
-      sprintf(desc, "character device");
-      break;
-    case S_IFDIR:
-      sprintf(desc, "directory");
-      break;
-    case S_IFIFO:
-      sprintf(desc, "FIFO/pipe");
-      break;
-    case S_IFLNK:
-      sprintf(desc, "symlink");
-      break;
-    case S_IFREG:
-      sprintf(desc, "regular file");
-      break;
-    case S_IFSOCK:
-      sprintf(desc, "socket");
-      break;
-    default:
-      sprintf(desc, "UNKNOWN: %u", (statdat->st_mode & S_IFMT));
-      break;
-  }
+	char desc[128] = {0};
 
-  return memcpy(ptr, desc, strlen(desc));
-}
+	switch (statdat->st_mode & S_IFMT) {
+	case S_IFBLK:
+		sprintf(desc, "block device");
+		break;
+	case S_IFCHR:
+		sprintf(desc, "character device");
+		break;
+	case S_IFDIR:
+		sprintf(desc, "directory");
+		break;
+	case S_IFIFO:
+		sprintf(desc, "FIFO/pipe");
+		break;
+	case S_IFLNK:
+		sprintf(desc, "symlink");
+		break;
+	case S_IFREG:
+		sprintf(desc, "regular file");
+		break;
+	case S_IFSOCK:
+		sprintf(desc, "socket");
+		break;
+	default:
+		sprintf(desc, "UNKNOWN: %u", (statdat->st_mode & S_IFMT));
+		break;
+	}
 
-int checktype(const char *event_fpath, struct inotify_event *event, char *tstring, struct stat *statdat) {
+	return memcpy(ptr, desc, strlen(desc));
+}
 
-  char mychar;
-  char *tstring_tmp, *mystr;
-  char *freeme;
-
-  struct stat sb;
-
-  char fpath[ELEMENT_SIZE * 2] = {0};
-
-  /* because we call it from multiple locations... */
-  if(event == NULL) {
-    snprintf(fpath, (ELEMENT_SIZE * 2), "%s", event_fpath);
-  }else{
-    snprintf(fpath, (ELEMENT_SIZE * 2), "%s%s", event_fpath, event->name);
-  }
-
-  freeme = tstring_tmp = strdup(tstring);
-
-  if(statdat == NULL) {
-    if(statit(fpath, &sb) != TRUE) {
-      fprintf(stderr, "ERROR: checktype()->statit() returned != TRUE!\n");
-      exit(EXIT_FAILURE);
-    }
-  }else{
-    memcpy(&sb, statdat, sizeof(struct stat));
-  }
-  
-  while((mystr = strtok(tstring_tmp, DELIM))) {
-    if(strlen(mystr) == 1) {
-      mychar = mystr[0];
-
-      /* ATTENTION: do not miss to update *twhitelst at the top of this file! */
-
-      switch(mychar) {
-        case  'f':  if((sb.st_mode & S_IFMT) == S_IFREG)
-                      return TRUE;
-                    break;
-        case  'd':  if((sb.st_mode & S_IFMT) == S_IFDIR)
-                      return TRUE;
-                    break;
-        case  's':  if((sb.st_mode & S_IFMT) == S_IFLNK)
-                      return TRUE;
-                    break;
-        case  'p':  if((sb.st_mode & S_IFMT) == S_IFIFO)
-                      return TRUE;
-                    break;
-        case  'c':  if((sb.st_mode & S_IFMT) == S_IFCHR)
-                      return TRUE;
-                    break;
-        case  'b':  if((sb.st_mode & S_IFMT) == S_IFBLK)
-                      return TRUE;
-                    break;
-        case  'o':  if((sb.st_mode & S_IFMT) == S_IFSOCK)
-                      return TRUE;
-                    break;
-        default  :  /* TODO: not existant! we should check that at startup! */
-                    break;
-      }
-    }else{
-      /* TODO: implement a startup check for this value...
-               it should be of a type like this: a,b,c,d,e */
-    }
-
-    freeme = tstring_tmp;
-    tstring_tmp = NULL;
-  }
+int checktype(const char *event_fpath, struct inotify_event *event,
+              char *tstring, struct stat *statdat)
+{
+
+	char mychar;
+	char *tstring_tmp, *mystr;
+	char *freeme;
+
+	struct stat sb;
+
+	char fpath[ELEMENT_SIZE * 2] = {0};
+
+	/* because we call it from multiple locations... */
+	if(event == NULL) {
+		snprintf(fpath, (ELEMENT_SIZE * 2), "%s", event_fpath);
+	} else {
+		snprintf(fpath, (ELEMENT_SIZE * 2), "%s%s", event_fpath, event->name);
+	}
+
+	freeme = tstring_tmp = strdup(tstring);
+
+	if(statdat == NULL) {
+		if(statit(fpath, &sb) != TRUE) {
+			fprintf(stderr, "ERROR: checktype()->statit() returned != TRUE!\n");
+			exit(EXIT_FAILURE);
+		}
+	} else {
+		memcpy(&sb, statdat, sizeof(struct stat));
+	}
+
+	while((mystr = strtok(tstring_tmp, DELIM))) {
+		if(strlen(mystr) == 1) {
+			mychar = mystr[0];
+
+			/* ATTENTION: do not miss to update *twhitelst at the top of this file! */
+
+			switch(mychar) {
+			case  'f':
+				if((sb.st_mode & S_IFMT) == S_IFREG)
+					return TRUE;
+				break;
+			case  'd':
+				if((sb.st_mode & S_IFMT) == S_IFDIR)
+					return TRUE;
+				break;
+			case  's':
+				if((sb.st_mode & S_IFMT) == S_IFLNK)
+					return TRUE;
+				break;
+			case  'p':
+				if((sb.st_mode & S_IFMT) == S_IFIFO)
+					return TRUE;
+				break;
+			case  'c':
+				if((sb.st_mode & S_IFMT) == S_IFCHR)
+					return TRUE;
+				break;
+			case  'b':
+				if((sb.st_mode & S_IFMT) == S_IFBLK)
+					return TRUE;
+				break;
+			case  'o':
+				if((sb.st_mode & S_IFMT) == S_IFSOCK)
+					return TRUE;
+				break;
+			default  :  /* TODO: not existant! we should check that at startup! */
+				break;
+			}
+		} else {
+			/* TODO: implement a startup check for this value...
+			         it should be of a type like this: a,b,c,d,e */
+		}
+
+		freeme = tstring_tmp;
+		tstring_tmp = NULL;
+	}
 
-  free(freeme);
+	free(freeme);
 
-  return FALSE;
+	return FALSE;
 }
 
-int isdir(const char *path, struct stat *statdat) {
+int isdir(const char *path, struct stat *statdat)
+{
 
-  struct stat sb;
+	struct stat sb;
 
-  if(statdat == NULL) {
+	if(statdat == NULL) {
 #ifdef _DEBUG
-  printf("isdir()->STATING: %s\n", path);
+		printf("isdir()->STATING: %s\n", path);
 #endif
-    if(statit(path, &sb) != TRUE) {
-      if(errno != 0) {
-        perror("isdir()->stat()");
-      }
-      return FALSE;
-    }
-    if(S_ISDIR(sb.st_mode))
-      return TRUE;
-    
-    return FALSE;
-  }
+		if(statit(path, &sb) != TRUE) {
+			if(errno != 0) {
+				perror("isdir()->stat()");
+			}
+			return FALSE;
+		}
+		if(S_ISDIR(sb.st_mode))
+			return TRUE;
+
+		return FALSE;
+	}
 
-  if(S_ISDIR(statdat->st_mode))
-    return TRUE;
+	if(S_ISDIR(statdat->st_mode))
+		return TRUE;
 
-  return FALSE;
+	return FALSE;
 }
 
-int statit(const char *path, struct stat *buf) {
+int statit(const char *path, struct stat *buf)
+{
 
 #ifdef _DEBUG
-  printf("statit()->STATING: %s\n", path);
+	printf("statit()->STATING: %s\n", path);
 #endif
 
-  /* TODO: add exception handling for all different types of errno's */
-  if(stat(path, buf) != 0) {
-    if(errno == ENOENT) {
+	/* TODO: add exception handling for all different types of errno's */
+	if(stat(path, buf) != 0) {
+		if(errno == ENOENT) {
 #ifdef _DEBUG
-  printf("WARNING: file \"%s\" does not exist (deleted?)!\n", path);
+			printf("WARNING: file \"%s\" does not exist (deleted?)!\n", path);
 #endif
-    }else{
-      perror("statit()->stat()");
-      return FALSE;
-    }
-  }
+		} else {
+			perror("statit()->stat()");
+			return FALSE;
+		}
+	}
 
-  return TRUE;
+	return TRUE;
 }
--- a/src/stating.h
+++ b/src/stating.h
@@ -35,7 +35,8 @@
 #include <sys/inotify.h>
 
 char *gettype(const char *fpath, char *ptr, struct stat *statdat);
-int checktype(const char *event_fpath, struct inotify_event *event, char *tstring, struct stat *statdat);
+int checktype(const char *event_fpath, struct inotify_event *event,
+              char *tstring, struct stat *statdat);
 int isdir(const char *path, struct stat *statdat);
 int statit(const char *path, struct stat *buf);
 
