Rind 8 gadi atpakaļ
revīzija
098c348830

BIN
Toolchain/arm/libgfaipc.so.1.0.0


BIN
Toolchain/arm/libgfaipcd.so.1.0.0


+ 28 - 0
Toolchain/gfaipc.h

@@ -0,0 +1,28 @@
+// gfaipc.h :
+//
+
+#if !defined(AGD_GFAIPC_H__6126047E_C1B1_4ACE_BD49_8780C7E5E068__INCLUDED_)
+#define AGD_GFAIPC_H__6126047E_C1B1_4ACE_BD49_8780C7E5E068__INCLUDED_
+
+#ifdef __cplusplus
+extern "C" {
+#endif	//	__cplusplus
+
+/////////////////////////////////////////////////////////////////////////////
+// gfaipc.h - Declarations:
+
+typedef void				*HSHM;
+
+HSHM	GfaIpcAcquireSHM	(const char *pszUuid, size_t nSizeElement, size_t nCntElements, const char *pszDescName);
+void	GfaIpcReleaseSHM	(HSHM hShm);
+void*	GfaIpcAcquirePointer(HSHM hShm);
+void	GfaIpcReleasePointer(HSHM hShm, const void *p);
+void	GfaIpcLockSHM		(HSHM hShm);
+void	GfaIpcUnlockSHM		(HSHM hShm);
+void	GfaIpcDumpSHMROT	(void);
+
+/////////////////////////////////////////////////////////////////////////////
+#ifdef __cplusplus
+}
+#endif	//	__cplusplus
+#endif	//	!defined(AGD_GFAIPC_H__6126047E_C1B1_4ACE_BD49_8780C7E5E068__INCLUDED_)

+ 51 - 0
Toolchain/install.sh

@@ -0,0 +1,51 @@
+#!/bin/bash
+set -e
+set -o pipefail
+
+TOOLCHAIN_SYSROOT="/opt/GfA/T_C49xL448RT_Qt57x/usr/arm-buildroot-linux-gnueabihf/sysroot"
+
+LIBBASENAMEREL="gfaipc"
+LIBBASENAMEDBG="gfaipcd"
+LIBDBGx86_64SRC="x86_64/lib$LIBBASENAMEDBG.so.1.0.0"
+LIBRELx86_64SRC="x86_64/lib$LIBBASENAMEREL.so.1.0.0"
+LIBDBGARMSRC="arm/lib$LIBBASENAMEDBG.so.1.0.0"
+LIBRELARMSRC="arm/lib$LIBBASENAMEREL.so.1.0.0"
+INCSRC="$LIBBASENAMEREL.h"
+
+LIBDBGx86_64DST="/usr/lib/"
+LIBRELx86_64DST="/usr/lib/"
+INCDSTx86_64DST="/usr/include/"
+
+LIBDBGARMDST_LOC="$TOOLCHAIN_SYSROOT/usr/lib/"
+LIBRELARMDST_LOC="$TOOLCHAIN_SYSROOT/usr/lib/"
+INCDSTARM_LOC="$TOOLCHAIN_SYSROOT/usr/include/"
+
+sudo cp $LIBDBGx86_64SRC $LIBDBGx86_64DST
+sudo cp $LIBRELx86_64SRC $LIBRELx86_64DST
+sudo cp $INCSRC $INCDSTx86_64DST
+
+sudo ln -sfnr /usr/lib/lib$LIBBASENAMEDBG.so.1.0.0 /usr/lib/lib$LIBBASENAMEDBG.so.1
+sudo ln -sfnr /usr/lib/lib$LIBBASENAMEDBG.so.1 /usr/lib/lib$LIBBASENAMEDBG.so
+sudo ln -sfnr /usr/lib/lib$LIBBASENAMEREL.so.1.0.0 /usr/lib/lib$LIBBASENAMEREL.so.1
+sudo ln -sfnr /usr/lib/lib$LIBBASENAMEREL.so.1 /usr/lib/lib$LIBBASENAMEREL.so
+
+cp $LIBDBGARMSRC $LIBDBGARMDST_LOC
+cp $LIBRELARMSRC $LIBRELARMDST_LOC
+cp $INCSRC $INCDSTARM_LOC
+
+ln -sfnr $TOOLCHAIN_SYSROOT/usr/lib/lib$LIBBASENAMEDBG.so.1.0.0 $TOOLCHAIN_SYSROOT/usr/lib/lib$LIBBASENAMEDBG.so.1
+ln -sfnr $TOOLCHAIN_SYSROOT/usr/lib/lib$LIBBASENAMEDBG.so.1 $TOOLCHAIN_SYSROOT/usr/lib/lib$LIBBASENAMEDBG.so
+ln -sfnr $TOOLCHAIN_SYSROOT/usr/lib/lib$LIBBASENAMEREL.so.1.0.0 $TOOLCHAIN_SYSROOT/usr/lib/lib$LIBBASENAMEREL.so.1
+ln -sfnr $TOOLCHAIN_SYSROOT/usr/lib/lib$LIBBASENAMEREL.so.1 $TOOLCHAIN_SYSROOT/usr/lib/lib$LIBBASENAMEREL.so
+
+REMPWD="root"
+REMUSR="$REMPWD@192.168.0.125"
+pscp -pw $REMPWD $LIBDBGARMSRC $REMUSR:/usr/lib/ > /dev/null
+pscp -pw $REMPWD $LIBRELARMSRC $REMUSR:/usr/lib/ > /dev/null
+
+plink -batch -t -pw $REMPWD $REMUSR ln -sfn /usr/lib/lib$LIBBASENAMEDBG.so.1.0.0 /usr/lib/lib$LIBBASENAMEDBG.so.1
+plink -batch -t -pw $REMPWD $REMUSR ln -sfn /usr/lib/lib$LIBBASENAMEDBG.so.1 /usr/lib/lib$LIBBASENAMEDBG.so
+plink -batch -t -pw $REMPWD $REMUSR ln -sfn /usr/lib/lib$LIBBASENAMEREL.so.1.0.0 /usr/lib/lib$LIBBASENAMEREL.so.1
+plink -batch -t -pw $REMPWD $REMUSR ln -sfn /usr/lib/lib$LIBBASENAMEREL.so.1 /usr/lib/lib$LIBBASENAMEREL.so
+
+echo Done.

BIN
Toolchain/x86_64/libgfaipc.so.1.0.0


BIN
Toolchain/x86_64/libgfaipcd.so.1.0.0


+ 1058 - 0
Win32/getopt.c

@@ -0,0 +1,1058 @@
+/* Getopt for GNU.
+   NOTE: getopt is now part of the C library, so if you don't know what
+   "Keep this file name-space clean" means, talk to drepper@gnu.org
+   before changing it!
+
+   Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000
+   	Free Software Foundation, Inc.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+/* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>.
+   Ditto for AIX 3.2 and <stdlib.h>.  */
+
+#define HAVE_STRING_H	1
+
+#ifndef _NO_PROTO
+# define _NO_PROTO
+#endif
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#if !defined __STDC__ || !__STDC__
+/* This is a separate conditional since some stdc systems
+   reject `defined (const)'.  */
+# ifndef const
+#  define const
+# endif
+#endif
+
+#include <stdio.h>
+
+/* Comment out all this code if we are using the GNU C Library, and are not
+   actually compiling the library itself.  This code is part of the GNU C
+   Library, but also included in many other GNU distributions.  Compiling
+   and linking in this code is a waste when using the GNU C library
+   (especially if it is a shared library).  Rather than having every GNU
+   program understand `configure --with-gnu-libc' and omit the object files,
+   it is simpler to just do this in the source for each such file.  */
+
+#define GETOPT_INTERFACE_VERSION 2
+#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2
+# include <gnu-versions.h>
+# if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
+#  define ELIDE_CODE
+# endif
+#endif
+
+#ifndef ELIDE_CODE
+
+
+/* This needs to come after some library #include
+   to get __GNU_LIBRARY__ defined.  */
+#ifdef	__GNU_LIBRARY__
+/* Don't include stdlib.h for non-GNU C libraries because some of them
+   contain conflicting prototypes for getopt.  */
+# include <stdlib.h>
+# include <unistd.h>
+#endif	/* GNU C library.  */
+
+#ifdef VMS
+# include <unixlib.h>
+# if HAVE_STRING_H - 0
+#  include <string.h>
+# endif
+#endif
+
+#ifndef _
+/* This is for other GNU distributions with internationalized messages.
+   When compiling libc, the _ macro is predefined.  */
+# ifdef HAVE_LIBINTL_H
+#  include <libintl.h>
+#  define _(msgid)	gettext (msgid)
+# else
+#  define _(msgid)	(msgid)
+# endif
+#endif
+
+/* This version of `getopt' appears to the caller like standard Unix `getopt'
+   but it behaves differently for the user, since it allows the user
+   to intersperse the options with the other arguments.
+
+   As `getopt' works, it permutes the elements of ARGV so that,
+   when it is done, all the options precede everything else.  Thus
+   all application programs are extended to handle flexible argument order.
+
+   Setting the environment variable POSIXLY_CORRECT disables permutation.
+   Then the behavior is completely standard.
+
+   GNU application programs can use a third alternative mode in which
+   they can distinguish the relative order of options and other arguments.  */
+
+#include "getopt.h"
+
+/* For communication from `getopt' to the caller.
+   When `getopt' finds an option that takes an argument,
+   the argument value is returned here.
+   Also, when `ordering' is RETURN_IN_ORDER,
+   each non-option ARGV-element is returned here.  */
+
+char *optarg;
+
+/* Index in ARGV of the next element to be scanned.
+   This is used for communication to and from the caller
+   and for communication between successive calls to `getopt'.
+
+   On entry to `getopt', zero means this is the first call; initialize.
+
+   When `getopt' returns -1, this is the index of the first of the
+   non-option elements that the caller should itself scan.
+
+   Otherwise, `optind' communicates from one call to the next
+   how much of ARGV has been scanned so far.  */
+
+/* 1003.2 says this must be 1 before any call.  */
+int optind = 1;
+
+/* Formerly, initialization of getopt depended on optind==0, which
+   causes problems with re-calling getopt as programs generally don't
+   know that. */
+
+int __getopt_initialized;
+
+/* The next char to be scanned in the option-element
+   in which the last option character we returned was found.
+   This allows us to pick up the scan where we left off.
+
+   If this is zero, or a null string, it means resume the scan
+   by advancing to the next ARGV-element.  */
+
+static char *nextchar;
+
+/* Callers store zero here to inhibit the error message
+   for unrecognized options.  */
+
+int opterr = 1;
+
+/* Set to an option character which was unrecognized.
+   This must be initialized on some systems to avoid linking in the
+   system's own getopt implementation.  */
+
+int optopt = '?';
+
+/* Describe how to deal with options that follow non-option ARGV-elements.
+
+   If the caller did not specify anything,
+   the default is REQUIRE_ORDER if the environment variable
+   POSIXLY_CORRECT is defined, PERMUTE otherwise.
+
+   REQUIRE_ORDER means don't recognize them as options;
+   stop option processing when the first non-option is seen.
+   This is what Unix does.
+   This mode of operation is selected by either setting the environment
+   variable POSIXLY_CORRECT, or using `+' as the first character
+   of the list of option characters.
+
+   PERMUTE is the default.  We permute the contents of ARGV as we scan,
+   so that eventually all the non-options are at the end.  This allows options
+   to be given in any order, even with programs that were not written to
+   expect this.
+
+   RETURN_IN_ORDER is an option available to programs that were written
+   to expect options and other ARGV-elements in any order and that care about
+   the ordering of the two.  We describe each non-option ARGV-element
+   as if it were the argument of an option with character code 1.
+   Using `-' as the first character of the list of option characters
+   selects this mode of operation.
+
+   The special argument `--' forces an end of option-scanning regardless
+   of the value of `ordering'.  In the case of RETURN_IN_ORDER, only
+   `--' can cause `getopt' to return -1 with `optind' != ARGC.  */
+
+static enum
+{
+  REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
+} ordering;
+
+/* Value of POSIXLY_CORRECT environment variable.  */
+static char *posixly_correct;
+
+#ifdef	__GNU_LIBRARY__
+/* We want to avoid inclusion of string.h with non-GNU libraries
+   because there are many ways it can cause trouble.
+   On some systems, it contains special magic macros that don't work
+   in GCC.  */
+# include <string.h>
+# define my_index	strchr
+#else
+
+# if HAVE_STRING_H
+#  include <string.h>
+# else
+#  include <strings.h>
+# endif
+
+/* Avoid depending on library functions or files
+   whose names are inconsistent.  */
+
+#ifndef getenv
+extern char *getenv ();
+#endif
+
+static char *
+my_index (str, chr)
+     const char *str;
+     int chr;
+{
+  while (*str)
+    {
+      if (*str == chr)
+	return (char *) str;
+      str++;
+    }
+  return 0;
+}
+
+/* If using GCC, we can safely declare strlen this way.
+   If not using GCC, it is ok not to declare it.  */
+#ifdef __GNUC__
+/* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h.
+   That was relevant to code that was here before.  */
+# if (!defined __STDC__ || !__STDC__) && !defined strlen
+/* gcc with -traditional declares the built-in strlen to return int,
+   and has done so at least since version 2.4.5. -- rms.  */
+extern int strlen (const char *);
+# endif /* not __STDC__ */
+#endif /* __GNUC__ */
+
+#endif /* not __GNU_LIBRARY__ */
+
+/* Handle permutation of arguments.  */
+
+/* Describe the part of ARGV that contains non-options that have
+   been skipped.  `first_nonopt' is the index in ARGV of the first of them;
+   `last_nonopt' is the index after the last of them.  */
+
+static int first_nonopt;
+static int last_nonopt;
+
+#ifdef _LIBC
+/* Bash 2.0 gives us an environment variable containing flags
+   indicating ARGV elements that should not be considered arguments.  */
+
+/* Defined in getopt_init.c  */
+extern char *__getopt_nonoption_flags;
+
+static int nonoption_flags_max_len;
+static int nonoption_flags_len;
+
+static int original_argc;
+static char *const *original_argv;
+
+/* Make sure the environment variable bash 2.0 puts in the environment
+   is valid for the getopt call we must make sure that the ARGV passed
+   to getopt is that one passed to the process.  */
+static void
+__attribute__ ((unused))
+store_args_and_env (int argc, char *const *argv)
+{
+  /* XXX This is no good solution.  We should rather copy the args so
+     that we can compare them later.  But we must not use malloc(3).  */
+  original_argc = argc;
+  original_argv = argv;
+}
+# ifdef text_set_element
+text_set_element (__libc_subinit, store_args_and_env);
+# endif /* text_set_element */
+
+# define SWAP_FLAGS(ch1, ch2) \
+  if (nonoption_flags_len > 0)						      \
+    {									      \
+      char __tmp = __getopt_nonoption_flags[ch1];			      \
+      __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2];	      \
+      __getopt_nonoption_flags[ch2] = __tmp;				      \
+    }
+#else	/* !_LIBC */
+# define SWAP_FLAGS(ch1, ch2)
+#endif	/* _LIBC */
+
+/* Exchange two adjacent subsequences of ARGV.
+   One subsequence is elements [first_nonopt,last_nonopt)
+   which contains all the non-options that have been skipped so far.
+   The other is elements [last_nonopt,optind), which contains all
+   the options processed since those non-options were skipped.
+
+   `first_nonopt' and `last_nonopt' are relocated so that they describe
+   the new indices of the non-options in ARGV after they are moved.  */
+
+#if defined __STDC__ && __STDC__
+static void exchange (char **);
+#endif
+
+static void
+exchange (argv)
+     char **argv;
+{
+  int bottom = first_nonopt;
+  int middle = last_nonopt;
+  int top = optind;
+  char *tem;
+
+  /* Exchange the shorter segment with the far end of the longer segment.
+     That puts the shorter segment into the right place.
+     It leaves the longer segment in the right place overall,
+     but it consists of two parts that need to be swapped next.  */
+
+#ifdef _LIBC
+  /* First make sure the handling of the `__getopt_nonoption_flags'
+     string can work normally.  Our top argument must be in the range
+     of the string.  */
+  if (nonoption_flags_len > 0 && top >= nonoption_flags_max_len)
+    {
+      /* We must extend the array.  The user plays games with us and
+	 presents new arguments.  */
+      char *new_str = malloc (top + 1);
+      if (new_str == NULL)
+	nonoption_flags_len = nonoption_flags_max_len = 0;
+      else
+	{
+	  memset (__mempcpy (new_str, __getopt_nonoption_flags,
+			     nonoption_flags_max_len),
+		  '\0', top + 1 - nonoption_flags_max_len);
+	  nonoption_flags_max_len = top + 1;
+	  __getopt_nonoption_flags = new_str;
+	}
+    }
+#endif
+
+  while (top > middle && middle > bottom)
+    {
+      if (top - middle > middle - bottom)
+	{
+	  /* Bottom segment is the short one.  */
+	  int len = middle - bottom;
+	  register int i;
+
+	  /* Swap it with the top part of the top segment.  */
+	  for (i = 0; i < len; i++)
+	    {
+	      tem = argv[bottom + i];
+	      argv[bottom + i] = argv[top - (middle - bottom) + i];
+	      argv[top - (middle - bottom) + i] = tem;
+	      SWAP_FLAGS (bottom + i, top - (middle - bottom) + i);
+	    }
+	  /* Exclude the moved bottom segment from further swapping.  */
+	  top -= len;
+	}
+      else
+	{
+	  /* Top segment is the short one.  */
+	  int len = top - middle;
+	  register int i;
+
+	  /* Swap it with the bottom part of the bottom segment.  */
+	  for (i = 0; i < len; i++)
+	    {
+	      tem = argv[bottom + i];
+	      argv[bottom + i] = argv[middle + i];
+	      argv[middle + i] = tem;
+	      SWAP_FLAGS (bottom + i, middle + i);
+	    }
+	  /* Exclude the moved top segment from further swapping.  */
+	  bottom += len;
+	}
+    }
+
+  /* Update records for the slots the non-options now occupy.  */
+
+  first_nonopt += (optind - last_nonopt);
+  last_nonopt = optind;
+}
+
+/* Initialize the internal data when the first call is made.  */
+
+#if defined __STDC__ && __STDC__
+static const char *_getopt_initialize (int, char *const *, const char *);
+#endif
+static const char *
+_getopt_initialize (argc, argv, optstring)
+     int argc;
+     char *const *argv;
+     const char *optstring;
+{
+  /* Start processing options with ARGV-element 1 (since ARGV-element 0
+     is the program name); the sequence of previously skipped
+     non-option ARGV-elements is empty.  */
+
+  first_nonopt = last_nonopt = optind;
+
+  nextchar = NULL;
+
+  posixly_correct = getenv ("POSIXLY_CORRECT");
+
+  /* Determine how to handle the ordering of options and nonoptions.  */
+
+  if (optstring[0] == '-')
+    {
+      ordering = RETURN_IN_ORDER;
+      ++optstring;
+    }
+  else if (optstring[0] == '+')
+    {
+      ordering = REQUIRE_ORDER;
+      ++optstring;
+    }
+  else if (posixly_correct != NULL)
+    ordering = REQUIRE_ORDER;
+  else
+    ordering = PERMUTE;
+
+#ifdef _LIBC
+  if (posixly_correct == NULL
+      && argc == original_argc && argv == original_argv)
+    {
+      if (nonoption_flags_max_len == 0)
+	{
+	  if (__getopt_nonoption_flags == NULL
+	      || __getopt_nonoption_flags[0] == '\0')
+	    nonoption_flags_max_len = -1;
+	  else
+	    {
+	      const char *orig_str = __getopt_nonoption_flags;
+	      int len = nonoption_flags_max_len = strlen (orig_str);
+	      if (nonoption_flags_max_len < argc)
+		nonoption_flags_max_len = argc;
+	      __getopt_nonoption_flags =
+		(char *) malloc (nonoption_flags_max_len);
+	      if (__getopt_nonoption_flags == NULL)
+		nonoption_flags_max_len = -1;
+	      else
+		memset (__mempcpy (__getopt_nonoption_flags, orig_str, len),
+			'\0', nonoption_flags_max_len - len);
+	    }
+	}
+      nonoption_flags_len = nonoption_flags_max_len;
+    }
+  else
+    nonoption_flags_len = 0;
+#endif
+
+  return optstring;
+}
+
+/* Scan elements of ARGV (whose length is ARGC) for option characters
+   given in OPTSTRING.
+
+   If an element of ARGV starts with '-', and is not exactly "-" or "--",
+   then it is an option element.  The characters of this element
+   (aside from the initial '-') are option characters.  If `getopt'
+   is called repeatedly, it returns successively each of the option characters
+   from each of the option elements.
+
+   If `getopt' finds another option character, it returns that character,
+   updating `optind' and `nextchar' so that the next call to `getopt' can
+   resume the scan with the following option character or ARGV-element.
+
+   If there are no more option characters, `getopt' returns -1.
+   Then `optind' is the index in ARGV of the first ARGV-element
+   that is not an option.  (The ARGV-elements have been permuted
+   so that those that are not options now come last.)
+
+   OPTSTRING is a string containing the legitimate option characters.
+   If an option character is seen that is not listed in OPTSTRING,
+   return '?' after printing an error message.  If you set `opterr' to
+   zero, the error message is suppressed but we still return '?'.
+
+   If a char in OPTSTRING is followed by a colon, that means it wants an arg,
+   so the following text in the same ARGV-element, or the text of the following
+   ARGV-element, is returned in `optarg'.  Two colons mean an option that
+   wants an optional arg; if there is text in the current ARGV-element,
+   it is returned in `optarg', otherwise `optarg' is set to zero.
+
+   If OPTSTRING starts with `-' or `+', it requests different methods of
+   handling the non-option ARGV-elements.
+   See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
+
+   Long-named options begin with `--' instead of `-'.
+   Their names may be abbreviated as long as the abbreviation is unique
+   or is an exact match for some defined option.  If they have an
+   argument, it follows the option name in the same ARGV-element, separated
+   from the option name by a `=', or else the in next ARGV-element.
+   When `getopt' finds a long-named option, it returns 0 if that option's
+   `flag' field is nonzero, the value of the option's `val' field
+   if the `flag' field is zero.
+
+   The elements of ARGV aren't really const, because we permute them.
+   But we pretend they're const in the prototype to be compatible
+   with other systems.
+
+   LONGOPTS is a vector of `struct option' terminated by an
+   element containing a name which is zero.
+
+   LONGIND returns the index in LONGOPT of the long-named option found.
+   It is only valid when a long-named option has been found by the most
+   recent call.
+
+   If LONG_ONLY is nonzero, '-' as well as '--' can introduce
+   long-named options.  */
+
+int
+_getopt_internal (argc, argv, optstring, longopts, longind, long_only)
+     int argc;
+     char *const *argv;
+     const char *optstring;
+     const struct option *longopts;
+     int *longind;
+     int long_only;
+{
+  int print_errors = opterr;
+  if (optstring[0] == ':')
+    print_errors = 0;
+
+  optarg = NULL;
+
+  if (optind == 0 || !__getopt_initialized)
+    {
+      if (optind == 0)
+	optind = 1;	/* Don't scan ARGV[0], the program name.  */
+      optstring = _getopt_initialize (argc, argv, optstring);
+      __getopt_initialized = 1;
+    }
+
+  /* Test whether ARGV[optind] points to a non-option argument.
+     Either it does not have option syntax, or there is an environment flag
+     from the shell indicating it is not an option.  The later information
+     is only used when the used in the GNU libc.  */
+#ifdef _LIBC
+# define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0'	      \
+		      || (optind < nonoption_flags_len			      \
+			  && __getopt_nonoption_flags[optind] == '1'))
+#else
+# define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0')
+#endif
+
+  if (nextchar == NULL || *nextchar == '\0')
+    {
+      /* Advance to the next ARGV-element.  */
+
+      /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been
+	 moved back by the user (who may also have changed the arguments).  */
+      if (last_nonopt > optind)
+	last_nonopt = optind;
+      if (first_nonopt > optind)
+	first_nonopt = optind;
+
+      if (ordering == PERMUTE)
+	{
+	  /* If we have just processed some options following some non-options,
+	     exchange them so that the options come first.  */
+
+	  if (first_nonopt != last_nonopt && last_nonopt != optind)
+	    exchange ((char **) argv);
+	  else if (last_nonopt != optind)
+	    first_nonopt = optind;
+
+	  /* Skip any additional non-options
+	     and extend the range of non-options previously skipped.  */
+
+	  while (optind < argc && NONOPTION_P)
+	    optind++;
+	  last_nonopt = optind;
+	}
+
+      /* The special ARGV-element `--' means premature end of options.
+	 Skip it like a null option,
+	 then exchange with previous non-options as if it were an option,
+	 then skip everything else like a non-option.  */
+
+      if (optind != argc && !strcmp (argv[optind], "--"))
+	{
+	  optind++;
+
+	  if (first_nonopt != last_nonopt && last_nonopt != optind)
+	    exchange ((char **) argv);
+	  else if (first_nonopt == last_nonopt)
+	    first_nonopt = optind;
+	  last_nonopt = argc;
+
+	  optind = argc;
+	}
+
+      /* If we have done all the ARGV-elements, stop the scan
+	 and back over any non-options that we skipped and permuted.  */
+
+      if (optind == argc)
+	{
+	  /* Set the next-arg-index to point at the non-options
+	     that we previously skipped, so the caller will digest them.  */
+	  if (first_nonopt != last_nonopt)
+	    optind = first_nonopt;
+	  return -1;
+	}
+
+      /* If we have come to a non-option and did not permute it,
+	 either stop the scan or describe it to the caller and pass it by.  */
+
+      if (NONOPTION_P)
+	{
+	  if (ordering == REQUIRE_ORDER)
+	    return -1;
+	  optarg = argv[optind++];
+	  return 1;
+	}
+
+      /* We have found another option-ARGV-element.
+	 Skip the initial punctuation.  */
+
+      nextchar = (argv[optind] + 1
+		  + (longopts != NULL && argv[optind][1] == '-'));
+    }
+
+  /* Decode the current option-ARGV-element.  */
+
+  /* Check whether the ARGV-element is a long option.
+
+     If long_only and the ARGV-element has the form "-f", where f is
+     a valid short option, don't consider it an abbreviated form of
+     a long option that starts with f.  Otherwise there would be no
+     way to give the -f short option.
+
+     On the other hand, if there's a long option "fubar" and
+     the ARGV-element is "-fu", do consider that an abbreviation of
+     the long option, just like "--fu", and not "-f" with arg "u".
+
+     This distinction seems to be the most useful approach.  */
+
+  if (longopts != NULL
+      && (argv[optind][1] == '-'
+	  || (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1])))))
+    {
+      char *nameend;
+      const struct option *p;
+      const struct option *pfound = NULL;
+      int exact = 0;
+      int ambig = 0;
+      int indfound = -1;
+      int option_index;
+
+      for (nameend = nextchar; *nameend && *nameend != '='; nameend++)
+	/* Do nothing.  */ ;
+
+      /* Test all long options for either exact match
+	 or abbreviated matches.  */
+      for (p = longopts, option_index = 0; p->name; p++, option_index++)
+	if (!strncmp (p->name, nextchar, nameend - nextchar))
+	  {
+	    if ((unsigned int) (nameend - nextchar)
+		== (unsigned int) strlen (p->name))
+	      {
+		/* Exact match found.  */
+		pfound = p;
+		indfound = option_index;
+		exact = 1;
+		break;
+	      }
+	    else if (pfound == NULL)
+	      {
+		/* First nonexact match found.  */
+		pfound = p;
+		indfound = option_index;
+	      }
+	    else
+	      /* Second or later nonexact match found.  */
+	      ambig = 1;
+	  }
+
+      if (ambig && !exact)
+	{
+	  if (print_errors)
+	    fprintf (stderr, _("%s: option `%s' is ambiguous\n"),
+		     argv[0], argv[optind]);
+	  nextchar += strlen (nextchar);
+	  optind++;
+	  optopt = 0;
+	  return '?';
+	}
+
+      if (pfound != NULL)
+	{
+	  option_index = indfound;
+	  optind++;
+	  if (*nameend)
+	    {
+	      /* Don't test has_arg with >, because some C compilers don't
+		 allow it to be used on enums.  */
+	      if (pfound->has_arg)
+		optarg = nameend + 1;
+	      else
+		{
+		  if (print_errors)
+		    {
+		      if (argv[optind - 1][1] == '-')
+			/* --option */
+			fprintf (stderr,
+				 _("%s: option `--%s' doesn't allow an argument\n"),
+				 argv[0], pfound->name);
+		      else
+			/* +option or -option */
+			fprintf (stderr,
+				 _("%s: option `%c%s' doesn't allow an argument\n"),
+				 argv[0], argv[optind - 1][0], pfound->name);
+		    }
+
+		  nextchar += strlen (nextchar);
+
+		  optopt = pfound->val;
+		  return '?';
+		}
+	    }
+	  else if (pfound->has_arg == 1)
+	    {
+	      if (optind < argc)
+		optarg = argv[optind++];
+	      else
+		{
+		  if (print_errors)
+		    fprintf (stderr,
+			   _("%s: option `%s' requires an argument\n"),
+			   argv[0], argv[optind - 1]);
+		  nextchar += strlen (nextchar);
+		  optopt = pfound->val;
+		  return optstring[0] == ':' ? ':' : '?';
+		}
+	    }
+	  nextchar += strlen (nextchar);
+	  if (longind != NULL)
+	    *longind = option_index;
+	  if (pfound->flag)
+	    {
+	      *(pfound->flag) = pfound->val;
+	      return 0;
+	    }
+	  return pfound->val;
+	}
+
+      /* Can't find it as a long option.  If this is not getopt_long_only,
+	 or the option starts with '--' or is not a valid short
+	 option, then it's an error.
+	 Otherwise interpret it as a short option.  */
+      if (!long_only || argv[optind][1] == '-'
+	  || my_index (optstring, *nextchar) == NULL)
+	{
+	  if (print_errors)
+	    {
+	      if (argv[optind][1] == '-')
+		/* --option */
+		fprintf (stderr, _("%s: unrecognized option `--%s'\n"),
+			 argv[0], nextchar);
+	      else
+		/* +option or -option */
+		fprintf (stderr, _("%s: unrecognized option `%c%s'\n"),
+			 argv[0], argv[optind][0], nextchar);
+	    }
+	  nextchar = (char *) "";
+	  optind++;
+	  optopt = 0;
+	  return '?';
+	}
+    }
+
+  /* Look at and handle the next short option-character.  */
+
+  {
+    char c = *nextchar++;
+    char *temp = my_index (optstring, c);
+
+    /* Increment `optind' when we start to process its last character.  */
+    if (*nextchar == '\0')
+      ++optind;
+
+    if (temp == NULL || c == ':')
+      {
+	if (print_errors)
+	  {
+	    if (posixly_correct)
+	      /* 1003.2 specifies the format of this message.  */
+	      fprintf (stderr, _("%s: illegal option -- %c\n"),
+		       argv[0], c);
+	    else
+	      fprintf (stderr, _("%s: invalid option -- %c\n"),
+		       argv[0], c);
+	  }
+	optopt = c;
+	return '?';
+      }
+    /* Convenience. Treat POSIX -W foo same as long option --foo */
+    if (temp[0] == 'W' && temp[1] == ';')
+      {
+	char *nameend;
+	const struct option *p;
+	const struct option *pfound = NULL;
+	int exact = 0;
+	int ambig = 0;
+	int indfound = 0;
+	int option_index;
+
+	/* This is an option that requires an argument.  */
+	if (*nextchar != '\0')
+	  {
+	    optarg = nextchar;
+	    /* If we end this ARGV-element by taking the rest as an arg,
+	       we must advance to the next element now.  */
+	    optind++;
+	  }
+	else if (optind == argc)
+	  {
+	    if (print_errors)
+	      {
+		/* 1003.2 specifies the format of this message.  */
+		fprintf (stderr, _("%s: option requires an argument -- %c\n"),
+			 argv[0], c);
+	      }
+	    optopt = c;
+	    if (optstring[0] == ':')
+	      c = ':';
+	    else
+	      c = '?';
+	    return c;
+	  }
+	else
+	  /* We already incremented `optind' once;
+	     increment it again when taking next ARGV-elt as argument.  */
+	  optarg = argv[optind++];
+
+	/* optarg is now the argument, see if it's in the
+	   table of longopts.  */
+
+	for (nextchar = nameend = optarg; *nameend && *nameend != '='; nameend++)
+	  /* Do nothing.  */ ;
+
+	/* Test all long options for either exact match
+	   or abbreviated matches.  */
+	for (p = longopts, option_index = 0; p->name; p++, option_index++)
+	  if (!strncmp (p->name, nextchar, nameend - nextchar))
+	    {
+	      if ((unsigned int) (nameend - nextchar) == strlen (p->name))
+		{
+		  /* Exact match found.  */
+		  pfound = p;
+		  indfound = option_index;
+		  exact = 1;
+		  break;
+		}
+	      else if (pfound == NULL)
+		{
+		  /* First nonexact match found.  */
+		  pfound = p;
+		  indfound = option_index;
+		}
+	      else
+		/* Second or later nonexact match found.  */
+		ambig = 1;
+	    }
+	if (ambig && !exact)
+	  {
+	    if (print_errors)
+	      fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"),
+		       argv[0], argv[optind]);
+	    nextchar += strlen (nextchar);
+	    optind++;
+	    return '?';
+	  }
+	if (pfound != NULL)
+	  {
+	    option_index = indfound;
+	    if (*nameend)
+	      {
+		/* Don't test has_arg with >, because some C compilers don't
+		   allow it to be used on enums.  */
+		if (pfound->has_arg)
+		  optarg = nameend + 1;
+		else
+		  {
+		    if (print_errors)
+		      fprintf (stderr, _("\
+%s: option `-W %s' doesn't allow an argument\n"),
+			       argv[0], pfound->name);
+
+		    nextchar += strlen (nextchar);
+		    return '?';
+		  }
+	      }
+	    else if (pfound->has_arg == 1)
+	      {
+		if (optind < argc)
+		  optarg = argv[optind++];
+		else
+		  {
+		    if (print_errors)
+		      fprintf (stderr,
+			       _("%s: option `%s' requires an argument\n"),
+			       argv[0], argv[optind - 1]);
+		    nextchar += strlen (nextchar);
+		    return optstring[0] == ':' ? ':' : '?';
+		  }
+	      }
+	    nextchar += strlen (nextchar);
+	    if (longind != NULL)
+	      *longind = option_index;
+	    if (pfound->flag)
+	      {
+		*(pfound->flag) = pfound->val;
+		return 0;
+	      }
+	    return pfound->val;
+	  }
+	  nextchar = NULL;
+	  return 'W';	/* Let the application handle it.   */
+      }
+    if (temp[1] == ':')
+      {
+	if (temp[2] == ':')
+	  {
+	    /* This is an option that accepts an argument optionally.  */
+	    if (*nextchar != '\0')
+	      {
+		optarg = nextchar;
+		optind++;
+	      }
+	    else
+	      optarg = NULL;
+	    nextchar = NULL;
+	  }
+	else
+	  {
+	    /* This is an option that requires an argument.  */
+	    if (*nextchar != '\0')
+	      {
+		optarg = nextchar;
+		/* If we end this ARGV-element by taking the rest as an arg,
+		   we must advance to the next element now.  */
+		optind++;
+	      }
+	    else if (optind == argc)
+	      {
+		if (print_errors)
+		  {
+		    /* 1003.2 specifies the format of this message.  */
+		    fprintf (stderr,
+			     _("%s: option requires an argument -- %c\n"),
+			     argv[0], c);
+		  }
+		optopt = c;
+		if (optstring[0] == ':')
+		  c = ':';
+		else
+		  c = '?';
+	      }
+	    else
+	      /* We already incremented `optind' once;
+		 increment it again when taking next ARGV-elt as argument.  */
+	      optarg = argv[optind++];
+	    nextchar = NULL;
+	  }
+      }
+    return c;
+  }
+}
+
+int
+getopt (argc, argv, optstring)
+     int argc;
+     char *const *argv;
+     const char *optstring;
+{
+  return _getopt_internal (argc, argv, optstring,
+			   (const struct option *) 0,
+			   (int *) 0,
+			   0);
+}
+
+#endif	/* Not ELIDE_CODE.  */
+
+#ifdef TEST
+
+/* Compile with -DTEST to make an executable for use in testing
+   the above definition of `getopt'.  */
+
+int
+main (argc, argv)
+     int argc;
+     char **argv;
+{
+  int c;
+  int digit_optind = 0;
+
+  while (1)
+    {
+      int this_option_optind = optind ? optind : 1;
+
+      c = getopt (argc, argv, "abc:d:0123456789");
+      if (c == -1)
+	break;
+
+      switch (c)
+	{
+	case '0':
+	case '1':
+	case '2':
+	case '3':
+	case '4':
+	case '5':
+	case '6':
+	case '7':
+	case '8':
+	case '9':
+	  if (digit_optind != 0 && digit_optind != this_option_optind)
+	    printf ("digits occur in two different argv-elements.\n");
+	  digit_optind = this_option_optind;
+	  printf ("option %c\n", c);
+	  break;
+
+	case 'a':
+	  printf ("option a\n");
+	  break;
+
+	case 'b':
+	  printf ("option b\n");
+	  break;
+
+	case 'c':
+	  printf ("option c with value `%s'\n", optarg);
+	  break;
+
+	case '?':
+	  break;
+
+	default:
+	  printf ("?? getopt returned character code 0%o ??\n", c);
+	}
+    }
+
+  if (optind < argc)
+    {
+      printf ("non-option ARGV-elements: ");
+      while (optind < argc)
+	printf ("%s ", argv[optind++]);
+      printf ("\n");
+    }
+
+  exit (0);
+}
+
+#endif /* TEST */

+ 191 - 0
Win32/getopt.h

@@ -0,0 +1,191 @@
+/* Declarations for getopt.
+   Copyright (C) 1989-2016 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#ifndef _GETOPT_H
+
+#ifndef __need_getopt
+# define _GETOPT_H 1
+#endif
+
+/* If __GNU_LIBRARY__ is not already defined, either we are being used
+   standalone, or this is the first header included in the source file.
+   If we are being used with glibc, we need to include <features.h>, but
+   that does not exist if we are standalone.  So: if __GNU_LIBRARY__ is
+   not defined, include <ctype.h>, which will pull in <features.h> for us
+   if it's from glibc.  (Why ctype.h?  It's guaranteed to exist and it
+   doesn't flood the namespace with stuff the way some other headers do.)  */
+#if !defined __GNU_LIBRARY__
+# include <ctype.h>
+#endif
+
+#ifndef __THROW
+# ifndef __GNUC_PREREQ
+#  define __GNUC_PREREQ(maj, min) (0)
+# endif
+# if defined __cplusplus && __GNUC_PREREQ (2,8)
+#  define __THROW	throw ()
+# else
+#  define __THROW
+# endif
+#endif
+
+#ifdef	__cplusplus
+extern "C" {
+#endif
+
+/* For communication from `getopt' to the caller.
+   When `getopt' finds an option that takes an argument,
+   the argument value is returned here.
+   Also, when `ordering' is RETURN_IN_ORDER,
+   each non-option ARGV-element is returned here.  */
+
+extern char *optarg;
+
+/* Index in ARGV of the next element to be scanned.
+   This is used for communication to and from the caller
+   and for communication between successive calls to `getopt'.
+
+   On entry to `getopt', zero means this is the first call; initialize.
+
+   When `getopt' returns -1, this is the index of the first of the
+   non-option elements that the caller should itself scan.
+
+   Otherwise, `optind' communicates from one call to the next
+   how much of ARGV has been scanned so far.  */
+
+extern int optind;
+
+/* Callers store zero here to inhibit the error message `getopt' prints
+   for unrecognized options.  */
+
+extern int opterr;
+
+/* Set to an option character which was unrecognized.  */
+
+extern int optopt;
+
+#ifndef __need_getopt
+/* Describe the long-named options requested by the application.
+   The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
+   of `struct option' terminated by an element containing a name which is
+   zero.
+
+   The field `has_arg' is:
+   no_argument		(or 0) if the option does not take an argument,
+   required_argument	(or 1) if the option requires an argument,
+   optional_argument 	(or 2) if the option takes an optional argument.
+
+   If the field `flag' is not NULL, it points to a variable that is set
+   to the value given in the field `val' when the option is found, but
+   left unchanged if the option is not found.
+
+   To have a long-named option do something other than set an `int' to
+   a compiled-in constant, such as set a value from `optarg', set the
+   option's `flag' field to zero and its `val' field to a nonzero
+   value (the equivalent single-letter option character, if there is
+   one).  For long options that have a zero `flag' field, `getopt'
+   returns the contents of the `val' field.  */
+
+struct option
+{
+  const char *name;
+  /* has_arg can't be an enum because some compilers complain about
+     type mismatches in all the code that assumes it is an int.  */
+  int has_arg;
+  int *flag;
+  int val;
+};
+
+/* Names for the values of the `has_arg' field of `struct option'.  */
+
+# define no_argument		0
+# define required_argument	1
+# define optional_argument	2
+#endif	/* need getopt */
+
+
+/* Get definitions and prototypes for functions to process the
+   arguments in ARGV (ARGC of them, minus the program name) for
+   options given in OPTS.
+
+   Return the option character from OPTS just read.  Return -1 when
+   there are no more options.  For unrecognized options, or options
+   missing arguments, `optopt' is set to the option letter, and '?' is
+   returned.
+
+   The OPTS string is a list of characters which are recognized option
+   letters, optionally followed by colons, specifying that that letter
+   takes an argument, to be placed in `optarg'.
+
+   If a letter in OPTS is followed by two colons, its argument is
+   optional.  This behavior is specific to the GNU `getopt'.
+
+   The argument `--' causes premature termination of argument
+   scanning, explicitly telling `getopt' that there are no more
+   options.
+
+   If OPTS begins with `--', then non-option arguments are treated as
+   arguments to the option '\0'.  This behavior is specific to the GNU
+   `getopt'.  */
+
+#ifdef __GNU_LIBRARY__
+/* Many other libraries have conflicting prototypes for getopt, with
+   differences in the consts, in stdlib.h.  To avoid compilation
+   errors, only prototype getopt for the GNU C library.  */
+extern int getopt (int ___argc, char *const *___argv, const char *__shortopts)
+       __THROW;
+
+# if defined __need_getopt && defined __USE_POSIX2 \
+  && !defined __USE_POSIX_IMPLICITLY && !defined __USE_GNU
+/* The GNU getopt has more functionality than the standard version.  The
+   additional functionality can be disable at runtime.  This redirection
+   helps to also do this at runtime.  */
+#  ifdef __REDIRECT
+  extern int __REDIRECT_NTH (getopt, (int ___argc, char *const *___argv,
+				      const char *__shortopts),
+			     __posix_getopt);
+#  else
+extern int __posix_getopt (int ___argc, char *const *___argv,
+			   const char *__shortopts) __THROW;
+#   define getopt __posix_getopt
+#  endif
+# endif
+#else /* not __GNU_LIBRARY__ */
+extern int getopt ();
+#endif /* __GNU_LIBRARY__ */
+
+#ifndef __need_getopt
+extern int getopt_long (int ___argc, char *const *___argv,
+			const char *__shortopts,
+		        const struct option *__longopts, int *__longind)
+       __THROW;
+extern int getopt_long_only (int ___argc, char *const *___argv,
+			     const char *__shortopts,
+		             const struct option *__longopts, int *__longind)
+       __THROW;
+
+#endif
+
+#ifdef	__cplusplus
+}
+#endif
+
+/* Make sure we later can get all the definitions and declarations.  */
+#undef __need_getopt
+
+#endif /* getopt.h */

+ 288 - 0
Win32/gettext.h

@@ -0,0 +1,288 @@
+/* Convenience header for conditional use of GNU <libintl.h>.
+   Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2011, 2015 Free
+   Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#ifndef _LIBGETTEXT_H
+#define _LIBGETTEXT_H 1
+
+/* NLS can be disabled through the configure --disable-nls option.  */
+#if ENABLE_NLS
+
+/* Get declarations of GNU message catalog functions.  */
+# include <libintl.h>
+
+/* You can set the DEFAULT_TEXT_DOMAIN macro to specify the domain used by
+   the gettext() and ngettext() macros.  This is an alternative to calling
+   textdomain(), and is useful for libraries.  */
+# ifdef DEFAULT_TEXT_DOMAIN
+#  undef gettext
+#  define gettext(Msgid) \
+     dgettext (DEFAULT_TEXT_DOMAIN, Msgid)
+#  undef ngettext
+#  define ngettext(Msgid1, Msgid2, N) \
+     dngettext (DEFAULT_TEXT_DOMAIN, Msgid1, Msgid2, N)
+# endif
+
+#else
+
+/* Solaris /usr/include/locale.h includes /usr/include/libintl.h, which
+   chokes if dcgettext is defined as a macro.  So include it now, to make
+   later inclusions of <locale.h> a NOP.  We don't include <libintl.h>
+   as well because people using "gettext.h" will not include <libintl.h>,
+   and also including <libintl.h> would fail on SunOS 4, whereas <locale.h>
+   is OK.  */
+#if defined(__sun)
+# include <locale.h>
+#endif
+
+/* Many header files from the libstdc++ coming with g++ 3.3 or newer include
+   <libintl.h>, which chokes if dcgettext is defined as a macro.  So include
+   it now, to make later inclusions of <libintl.h> a NOP.  */
+#if defined(__cplusplus) && defined(__GNUG__) && (__GNUC__ >= 3)
+# include <cstdlib>
+# if (__GLIBC__ >= 2 && !defined __UCLIBC__) || _GLIBCXX_HAVE_LIBINTL_H
+#  include <libintl.h>
+# endif
+#endif
+
+/* Disabled NLS.
+   The casts to 'const char *' serve the purpose of producing warnings
+   for invalid uses of the value returned from these functions.
+   On pre-ANSI systems without 'const', the config.h file is supposed to
+   contain "#define const".  */
+# undef gettext
+# define gettext(Msgid) ((const char *) (Msgid))
+# undef dgettext
+# define dgettext(Domainname, Msgid) ((void) (Domainname), gettext (Msgid))
+# undef dcgettext
+# define dcgettext(Domainname, Msgid, Category) \
+    ((void) (Category), dgettext (Domainname, Msgid))
+# undef ngettext
+# define ngettext(Msgid1, Msgid2, N) \
+    ((N) == 1 \
+     ? ((void) (Msgid2), (const char *) (Msgid1)) \
+     : ((void) (Msgid1), (const char *) (Msgid2)))
+# undef dngettext
+# define dngettext(Domainname, Msgid1, Msgid2, N) \
+    ((void) (Domainname), ngettext (Msgid1, Msgid2, N))
+# undef dcngettext
+# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \
+    ((void) (Category), dngettext (Domainname, Msgid1, Msgid2, N))
+# undef textdomain
+# define textdomain(Domainname) ((const char *) (Domainname))
+# undef bindtextdomain
+# define bindtextdomain(Domainname, Dirname) \
+    ((void) (Domainname), (const char *) (Dirname))
+# undef bind_textdomain_codeset
+# define bind_textdomain_codeset(Domainname, Codeset) \
+    ((void) (Domainname), (const char *) (Codeset))
+
+#endif
+
+/* Prefer gnulib's setlocale override over libintl's setlocale override.  */
+#ifdef GNULIB_defined_setlocale
+# undef setlocale
+# define setlocale rpl_setlocale
+#endif
+
+/* A pseudo function call that serves as a marker for the automated
+   extraction of messages, but does not call gettext().  The run-time
+   translation is done at a different place in the code.
+   The argument, String, should be a literal string.  Concatenated strings
+   and other string expressions won't work.
+   The macro's expansion is not parenthesized, so that it is suitable as
+   initializer for static 'char[]' or 'const char[]' variables.  */
+#define gettext_noop(String) String
+
+/* The separator between msgctxt and msgid in a .mo file.  */
+#define GETTEXT_CONTEXT_GLUE "\004"
+
+/* Pseudo function calls, taking a MSGCTXT and a MSGID instead of just a
+   MSGID.  MSGCTXT and MSGID must be string literals.  MSGCTXT should be
+   short and rarely need to change.
+   The letter 'p' stands for 'particular' or 'special'.  */
+#ifdef DEFAULT_TEXT_DOMAIN
+# define pgettext(Msgctxt, Msgid) \
+   pgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
+#else
+# define pgettext(Msgctxt, Msgid) \
+   pgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
+#endif
+#define dpgettext(Domainname, Msgctxt, Msgid) \
+  pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
+#define dcpgettext(Domainname, Msgctxt, Msgid, Category) \
+  pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, Category)
+#ifdef DEFAULT_TEXT_DOMAIN
+# define npgettext(Msgctxt, Msgid, MsgidPlural, N) \
+   npgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
+#else
+# define npgettext(Msgctxt, Msgid, MsgidPlural, N) \
+   npgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
+#endif
+#define dnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
+  npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
+#define dcnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N, Category) \
+  npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, Category)
+
+#ifdef __GNUC__
+__inline
+#else
+#ifdef __cplusplus
+inline
+#endif
+#endif
+static const char *
+pgettext_aux (const char *domain,
+              const char *msg_ctxt_id, const char *msgid,
+              int category)
+{
+  const char *translation = dcgettext (domain, msg_ctxt_id, category);
+  if (translation == msg_ctxt_id)
+    return msgid;
+  else
+    return translation;
+}
+
+#ifdef __GNUC__
+__inline
+#else
+#ifdef __cplusplus
+inline
+#endif
+#endif
+static const char *
+npgettext_aux (const char *domain,
+               const char *msg_ctxt_id, const char *msgid,
+               const char *msgid_plural, unsigned long int n,
+               int category)
+{
+  const char *translation =
+    dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
+  if (translation == msg_ctxt_id || translation == msgid_plural)
+    return (n == 1 ? msgid : msgid_plural);
+  else
+    return translation;
+}
+
+/* The same thing extended for non-constant arguments.  Here MSGCTXT and MSGID
+   can be arbitrary expressions.  But for string literals these macros are
+   less efficient than those above.  */
+
+#include <string.h>
+
+#if (((__GNUC__ >= 3 || __GNUG__ >= 2) && !defined __STRICT_ANSI__) \
+     /* || __STDC_VERSION__ >= 199901L */ )
+# define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 1
+#else
+# define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 0
+#endif
+
+#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+#include <stdlib.h>
+#endif
+
+#define pgettext_expr(Msgctxt, Msgid) \
+  dcpgettext_expr (NULL, Msgctxt, Msgid, LC_MESSAGES)
+#define dpgettext_expr(Domainname, Msgctxt, Msgid) \
+  dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES)
+
+#ifdef __GNUC__
+__inline
+#else
+#ifdef __cplusplus
+inline
+#endif
+#endif
+static const char *
+dcpgettext_expr (const char *domain,
+                 const char *msgctxt, const char *msgid,
+                 int category)
+{
+  size_t msgctxt_len = strlen (msgctxt) + 1;
+  size_t msgid_len = strlen (msgid) + 1;
+  const char *translation;
+#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+  char msg_ctxt_id[msgctxt_len + msgid_len];
+#else
+  char buf[1024];
+  char *msg_ctxt_id =
+    (msgctxt_len + msgid_len <= sizeof (buf)
+     ? buf
+     : (char *) malloc (msgctxt_len + msgid_len));
+  if (msg_ctxt_id != NULL)
+#endif
+    {
+      memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
+      msg_ctxt_id[msgctxt_len - 1] = '\004';
+      memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
+      translation = dcgettext (domain, msg_ctxt_id, category);
+#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+      if (msg_ctxt_id != buf)
+        free (msg_ctxt_id);
+#endif
+      if (translation != msg_ctxt_id)
+        return translation;
+    }
+  return msgid;
+}
+
+#define npgettext_expr(Msgctxt, Msgid, MsgidPlural, N) \
+  dcnpgettext_expr (NULL, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
+#define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
+  dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
+
+#ifdef __GNUC__
+__inline
+#else
+#ifdef __cplusplus
+inline
+#endif
+#endif
+static const char *
+dcnpgettext_expr (const char *domain,
+                  const char *msgctxt, const char *msgid,
+                  const char *msgid_plural, unsigned long int n,
+                  int category)
+{
+  size_t msgctxt_len = strlen (msgctxt) + 1;
+  size_t msgid_len = strlen (msgid) + 1;
+  const char *translation;
+#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+  char msg_ctxt_id[msgctxt_len + msgid_len];
+#else
+  char buf[1024];
+  char *msg_ctxt_id =
+    (msgctxt_len + msgid_len <= sizeof (buf)
+     ? buf
+     : (char *) malloc (msgctxt_len + msgid_len));
+  if (msg_ctxt_id != NULL)
+#endif
+    {
+      memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
+      msg_ctxt_id[msgctxt_len - 1] = '\004';
+      memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
+      translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
+#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+      if (msg_ctxt_id != buf)
+        free (msg_ctxt_id);
+#endif
+      if (!(translation == msg_ctxt_id || translation == msgid_plural))
+        return translation;
+    }
+  return (n == 1 ? msgid : msgid_plural);
+}
+
+#endif /* _LIBGETTEXT_H */

+ 305 - 0
Win32/inttypes.h

@@ -0,0 +1,305 @@
+// ISO C9x  compliant inttypes.h for Microsoft Visual Studio
+// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 
+// 
+//  Copyright (c) 2006 Alexander Chemeris
+// 
+// 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.
+// 
+//   3. The name of the author may be used to endorse or promote products
+//      derived from this software without specific prior written permission.
+// 
+// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+// 
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef _MSC_VER // [
+#error "Use this header only with Microsoft Visual C++ compilers!"
+#endif // _MSC_VER ]
+
+#ifndef _MSC_INTTYPES_H_ // [
+#define _MSC_INTTYPES_H_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif
+
+#include "stdint.h"
+
+// 7.8 Format conversion of integer types
+
+typedef struct {
+   intmax_t quot;
+   intmax_t rem;
+} imaxdiv_t;
+
+// 7.8.1 Macros for format specifiers
+
+#if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS) // [   See footnote 185 at page 198
+
+// The fprintf macros for signed integers are:
+#define PRId8       "d"
+#define PRIi8       "i"
+#define PRIdLEAST8  "d"
+#define PRIiLEAST8  "i"
+#define PRIdFAST8   "d"
+#define PRIiFAST8   "i"
+
+#define PRId16       "hd"
+#define PRIi16       "hi"
+#define PRIdLEAST16  "hd"
+#define PRIiLEAST16  "hi"
+#define PRIdFAST16   "hd"
+#define PRIiFAST16   "hi"
+
+#define PRId32       "I32d"
+#define PRIi32       "I32i"
+#define PRIdLEAST32  "I32d"
+#define PRIiLEAST32  "I32i"
+#define PRIdFAST32   "I32d"
+#define PRIiFAST32   "I32i"
+
+#define PRId64       "I64d"
+#define PRIi64       "I64i"
+#define PRIdLEAST64  "I64d"
+#define PRIiLEAST64  "I64i"
+#define PRIdFAST64   "I64d"
+#define PRIiFAST64   "I64i"
+
+#define PRIdMAX     "I64d"
+#define PRIiMAX     "I64i"
+
+#define PRIdPTR     "Id"
+#define PRIiPTR     "Ii"
+
+// The fprintf macros for unsigned integers are:
+#define PRIo8       "o"
+#define PRIu8       "u"
+#define PRIx8       "x"
+#define PRIX8       "X"
+#define PRIoLEAST8  "o"
+#define PRIuLEAST8  "u"
+#define PRIxLEAST8  "x"
+#define PRIXLEAST8  "X"
+#define PRIoFAST8   "o"
+#define PRIuFAST8   "u"
+#define PRIxFAST8   "x"
+#define PRIXFAST8   "X"
+
+#define PRIo16       "ho"
+#define PRIu16       "hu"
+#define PRIx16       "hx"
+#define PRIX16       "hX"
+#define PRIoLEAST16  "ho"
+#define PRIuLEAST16  "hu"
+#define PRIxLEAST16  "hx"
+#define PRIXLEAST16  "hX"
+#define PRIoFAST16   "ho"
+#define PRIuFAST16   "hu"
+#define PRIxFAST16   "hx"
+#define PRIXFAST16   "hX"
+
+#define PRIo32       "I32o"
+#define PRIu32       "I32u"
+#define PRIx32       "I32x"
+#define PRIX32       "I32X"
+#define PRIoLEAST32  "I32o"
+#define PRIuLEAST32  "I32u"
+#define PRIxLEAST32  "I32x"
+#define PRIXLEAST32  "I32X"
+#define PRIoFAST32   "I32o"
+#define PRIuFAST32   "I32u"
+#define PRIxFAST32   "I32x"
+#define PRIXFAST32   "I32X"
+
+#define PRIo64       "I64o"
+#define PRIu64       "I64u"
+#define PRIx64       "I64x"
+#define PRIX64       "I64X"
+#define PRIoLEAST64  "I64o"
+#define PRIuLEAST64  "I64u"
+#define PRIxLEAST64  "I64x"
+#define PRIXLEAST64  "I64X"
+#define PRIoFAST64   "I64o"
+#define PRIuFAST64   "I64u"
+#define PRIxFAST64   "I64x"
+#define PRIXFAST64   "I64X"
+
+#define PRIoMAX     "I64o"
+#define PRIuMAX     "I64u"
+#define PRIxMAX     "I64x"
+#define PRIXMAX     "I64X"
+
+#define PRIoPTR     "Io"
+#define PRIuPTR     "Iu"
+#define PRIxPTR     "Ix"
+#define PRIXPTR     "IX"
+
+// The fscanf macros for signed integers are:
+#define SCNd8       "d"
+#define SCNi8       "i"
+#define SCNdLEAST8  "d"
+#define SCNiLEAST8  "i"
+#define SCNdFAST8   "d"
+#define SCNiFAST8   "i"
+
+#define SCNd16       "hd"
+#define SCNi16       "hi"
+#define SCNdLEAST16  "hd"
+#define SCNiLEAST16  "hi"
+#define SCNdFAST16   "hd"
+#define SCNiFAST16   "hi"
+
+#define SCNd32       "ld"
+#define SCNi32       "li"
+#define SCNdLEAST32  "ld"
+#define SCNiLEAST32  "li"
+#define SCNdFAST32   "ld"
+#define SCNiFAST32   "li"
+
+#define SCNd64       "I64d"
+#define SCNi64       "I64i"
+#define SCNdLEAST64  "I64d"
+#define SCNiLEAST64  "I64i"
+#define SCNdFAST64   "I64d"
+#define SCNiFAST64   "I64i"
+
+#define SCNdMAX     "I64d"
+#define SCNiMAX     "I64i"
+
+#ifdef _WIN64 // [
+#  define SCNdPTR     "I64d"
+#  define SCNiPTR     "I64i"
+#else  // _WIN64 ][
+#  define SCNdPTR     "ld"
+#  define SCNiPTR     "li"
+#endif  // _WIN64 ]
+
+// The fscanf macros for unsigned integers are:
+#define SCNo8       "o"
+#define SCNu8       "u"
+#define SCNx8       "x"
+#define SCNX8       "X"
+#define SCNoLEAST8  "o"
+#define SCNuLEAST8  "u"
+#define SCNxLEAST8  "x"
+#define SCNXLEAST8  "X"
+#define SCNoFAST8   "o"
+#define SCNuFAST8   "u"
+#define SCNxFAST8   "x"
+#define SCNXFAST8   "X"
+
+#define SCNo16       "ho"
+#define SCNu16       "hu"
+#define SCNx16       "hx"
+#define SCNX16       "hX"
+#define SCNoLEAST16  "ho"
+#define SCNuLEAST16  "hu"
+#define SCNxLEAST16  "hx"
+#define SCNXLEAST16  "hX"
+#define SCNoFAST16   "ho"
+#define SCNuFAST16   "hu"
+#define SCNxFAST16   "hx"
+#define SCNXFAST16   "hX"
+
+#define SCNo32       "lo"
+#define SCNu32       "lu"
+#define SCNx32       "lx"
+#define SCNX32       "lX"
+#define SCNoLEAST32  "lo"
+#define SCNuLEAST32  "lu"
+#define SCNxLEAST32  "lx"
+#define SCNXLEAST32  "lX"
+#define SCNoFAST32   "lo"
+#define SCNuFAST32   "lu"
+#define SCNxFAST32   "lx"
+#define SCNXFAST32   "lX"
+
+#define SCNo64       "I64o"
+#define SCNu64       "I64u"
+#define SCNx64       "I64x"
+#define SCNX64       "I64X"
+#define SCNoLEAST64  "I64o"
+#define SCNuLEAST64  "I64u"
+#define SCNxLEAST64  "I64x"
+#define SCNXLEAST64  "I64X"
+#define SCNoFAST64   "I64o"
+#define SCNuFAST64   "I64u"
+#define SCNxFAST64   "I64x"
+#define SCNXFAST64   "I64X"
+
+#define SCNoMAX     "I64o"
+#define SCNuMAX     "I64u"
+#define SCNxMAX     "I64x"
+#define SCNXMAX     "I64X"
+
+#ifdef _WIN64 // [
+#  define SCNoPTR     "I64o"
+#  define SCNuPTR     "I64u"
+#  define SCNxPTR     "I64x"
+#  define SCNXPTR     "I64X"
+#else  // _WIN64 ][
+#  define SCNoPTR     "lo"
+#  define SCNuPTR     "lu"
+#  define SCNxPTR     "lx"
+#  define SCNXPTR     "lX"
+#endif  // _WIN64 ]
+
+#endif // __STDC_FORMAT_MACROS ]
+
+// 7.8.2 Functions for greatest-width integer types
+
+// 7.8.2.1 The imaxabs function
+#define imaxabs _abs64
+
+// 7.8.2.2 The imaxdiv function
+
+// This is modified version of div() function from Microsoft's div.c found
+// in %MSVC.NET%\crt\src\div.c
+#ifdef STATIC_IMAXDIV // [
+static
+#else // STATIC_IMAXDIV ][
+_inline
+#endif // STATIC_IMAXDIV ]
+imaxdiv_t __cdecl imaxdiv(intmax_t numer, intmax_t denom)
+{
+   imaxdiv_t result;
+
+   result.quot = numer / denom;
+   result.rem = numer % denom;
+
+   if (numer < 0 && result.rem > 0) {
+      // did division wrong; must fix up
+      ++result.quot;
+      result.rem -= denom;
+   }
+
+   return result;
+}
+
+// 7.8.2.3 The strtoimax and strtoumax functions
+#define strtoimax _strtoi64
+#define strtoumax _strtoui64
+
+// 7.8.2.4 The wcstoimax and wcstoumax functions
+#define wcstoimax _wcstoi64
+#define wcstoumax _wcstoui64
+
+
+#endif // _MSC_INTTYPES_H_ ]

+ 55 - 0
Win32/stdbool.h

@@ -0,0 +1,55 @@
+/* Copyright (C) 2001-2002 Free Software Foundation, Inc. 
+  Written by Bruno Haible <haible@clisp.cons.org>, 2001. 
+
+
+  This program is free software; you can redistribute it and/or modify 
+  it under the terms of the GNU General Public License as published by 
+  the Free Software Foundation; either version 2, or (at your option) 
+  any later version. 
+
+
+  This program is distributed in the hope that it will be useful, 
+   but WITHOUT ANY WARRANTY; without even the implied warranty of 
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+   GNU General Public License for more details. 
+
+
+   You should have received a copy of the GNU General Public License 
+   along with this program; if not, write to the Free Software Foundation, 
+   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */ 
+
+
+#ifndef _STDBOOL_H 
+#define _STDBOOL_H 
+
+
+/* ISO C 99 <stdbool.h> for platforms that lack it.  */ 
+
+
+/* 7.16. Boolean type and values */ 
+
+
+/* BeOS <sys/socket.h> already #defines false 0, true 1.  We use the same 
+   definitions below, but temporarily we have to #undef them.  */ 
+#ifdef __BEOS__ 
+# undef false 
+# undef true 
+#endif 
+
+
+/* For the sake of symbolic names in gdb, define _Bool as an enum type.  */ 
+#ifndef __cplusplus 
+typedef enum { false = 0, true = 1 } _Bool; 
+#else 
+typedef bool _Bool; 
+#endif 
+#define bool _Bool 
+
+
+/* The other macros must be usable in preprocessor directives.  */ 
+#define false	0 
+#define true	1 
+#define __bool_true_false_are_defined 1 
+
+
+#endif /* _STDBOOL_H */ 

+ 259 - 0
Win32/stdint.h

@@ -0,0 +1,259 @@
+// ISO C9x  compliant stdint.h for Microsoft Visual Studio
+// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 
+// 
+//  Copyright (c) 2006-2013 Alexander Chemeris
+// 
+// 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.
+// 
+//   3. Neither the name of the product nor the names of its contributors may
+//      be used to endorse or promote products derived from this software
+//      without specific prior written permission.
+// 
+// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+// 
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef _MSC_VER // [
+#error "Use this header only with Microsoft Visual C++ compilers!"
+#endif // _MSC_VER ]
+
+#ifndef _MSC_STDINT_H_ // [
+#define _MSC_STDINT_H_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif
+
+#if _MSC_VER >= 1600 // [
+#include <stdint.h>
+#else // ] _MSC_VER >= 1600 [
+
+#include <limits.h>
+
+// For Visual Studio 6 in C++ mode and for many Visual Studio versions when
+// compiling for ARM we should wrap <wchar.h> include with 'extern "C++" {}'
+// or compiler give many errors like this:
+//   error C2733: second C linkage of overloaded function 'wmemchr' not allowed
+#ifdef __cplusplus
+extern "C" {
+#endif
+#  include <wchar.h>
+#ifdef __cplusplus
+}
+#endif
+
+// Define _W64 macros to mark types changing their size, like intptr_t.
+#ifndef _W64
+#  if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300
+#     define _W64 __w64
+#  else
+#     define _W64
+#  endif
+#endif
+
+
+// 7.18.1 Integer types
+
+// 7.18.1.1 Exact-width integer types
+
+// Visual Studio 6 and Embedded Visual C++ 4 doesn't
+// realize that, e.g. char has the same size as __int8
+// so we give up on __intX for them.
+#if (_MSC_VER < 1300)
+   typedef signed char       int8_t;
+   typedef signed short      int16_t;
+   typedef signed int        int32_t;
+   typedef unsigned char     uint8_t;
+   typedef unsigned short    uint16_t;
+   typedef unsigned int      uint32_t;
+#else
+   typedef signed __int8     int8_t;
+   typedef signed __int16    int16_t;
+   typedef signed __int32    int32_t;
+   typedef unsigned __int8   uint8_t;
+   typedef unsigned __int16  uint16_t;
+   typedef unsigned __int32  uint32_t;
+#endif
+typedef signed __int64       int64_t;
+typedef unsigned __int64     uint64_t;
+
+
+// 7.18.1.2 Minimum-width integer types
+typedef int8_t    int_least8_t;
+typedef int16_t   int_least16_t;
+typedef int32_t   int_least32_t;
+typedef int64_t   int_least64_t;
+typedef uint8_t   uint_least8_t;
+typedef uint16_t  uint_least16_t;
+typedef uint32_t  uint_least32_t;
+typedef uint64_t  uint_least64_t;
+
+// 7.18.1.3 Fastest minimum-width integer types
+typedef int8_t    int_fast8_t;
+typedef int16_t   int_fast16_t;
+typedef int32_t   int_fast32_t;
+typedef int64_t   int_fast64_t;
+typedef uint8_t   uint_fast8_t;
+typedef uint16_t  uint_fast16_t;
+typedef uint32_t  uint_fast32_t;
+typedef uint64_t  uint_fast64_t;
+
+// 7.18.1.4 Integer types capable of holding object pointers
+#ifdef _WIN64 // [
+   typedef signed __int64    intptr_t;
+   typedef unsigned __int64  uintptr_t;
+#else // _WIN64 ][
+   typedef _W64 signed int   intptr_t;
+   typedef _W64 unsigned int uintptr_t;
+#endif // _WIN64 ]
+
+// 7.18.1.5 Greatest-width integer types
+typedef int64_t   intmax_t;
+typedef uint64_t  uintmax_t;
+
+
+// 7.18.2 Limits of specified-width integer types
+
+#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [   See footnote 220 at page 257 and footnote 221 at page 259
+
+// 7.18.2.1 Limits of exact-width integer types
+#define INT8_MIN     ((int8_t)_I8_MIN)
+#define INT8_MAX     _I8_MAX
+#define INT16_MIN    ((int16_t)_I16_MIN)
+#define INT16_MAX    _I16_MAX
+#define INT32_MIN    ((int32_t)_I32_MIN)
+#define INT32_MAX    _I32_MAX
+#define INT64_MIN    ((int64_t)_I64_MIN)
+#define INT64_MAX    _I64_MAX
+#define UINT8_MAX    _UI8_MAX
+#define UINT16_MAX   _UI16_MAX
+#define UINT32_MAX   _UI32_MAX
+#define UINT64_MAX   _UI64_MAX
+
+// 7.18.2.2 Limits of minimum-width integer types
+#define INT_LEAST8_MIN    INT8_MIN
+#define INT_LEAST8_MAX    INT8_MAX
+#define INT_LEAST16_MIN   INT16_MIN
+#define INT_LEAST16_MAX   INT16_MAX
+#define INT_LEAST32_MIN   INT32_MIN
+#define INT_LEAST32_MAX   INT32_MAX
+#define INT_LEAST64_MIN   INT64_MIN
+#define INT_LEAST64_MAX   INT64_MAX
+#define UINT_LEAST8_MAX   UINT8_MAX
+#define UINT_LEAST16_MAX  UINT16_MAX
+#define UINT_LEAST32_MAX  UINT32_MAX
+#define UINT_LEAST64_MAX  UINT64_MAX
+
+// 7.18.2.3 Limits of fastest minimum-width integer types
+#define INT_FAST8_MIN    INT8_MIN
+#define INT_FAST8_MAX    INT8_MAX
+#define INT_FAST16_MIN   INT16_MIN
+#define INT_FAST16_MAX   INT16_MAX
+#define INT_FAST32_MIN   INT32_MIN
+#define INT_FAST32_MAX   INT32_MAX
+#define INT_FAST64_MIN   INT64_MIN
+#define INT_FAST64_MAX   INT64_MAX
+#define UINT_FAST8_MAX   UINT8_MAX
+#define UINT_FAST16_MAX  UINT16_MAX
+#define UINT_FAST32_MAX  UINT32_MAX
+#define UINT_FAST64_MAX  UINT64_MAX
+
+// 7.18.2.4 Limits of integer types capable of holding object pointers
+#ifdef _WIN64 // [
+#  define INTPTR_MIN   INT64_MIN
+#  define INTPTR_MAX   INT64_MAX
+#  define UINTPTR_MAX  UINT64_MAX
+#else // _WIN64 ][
+#  define INTPTR_MIN   INT32_MIN
+#  define INTPTR_MAX   INT32_MAX
+#  define UINTPTR_MAX  UINT32_MAX
+#endif // _WIN64 ]
+
+// 7.18.2.5 Limits of greatest-width integer types
+#define INTMAX_MIN   INT64_MIN
+#define INTMAX_MAX   INT64_MAX
+#define UINTMAX_MAX  UINT64_MAX
+
+// 7.18.3 Limits of other integer types
+
+#ifdef _WIN64 // [
+#  define PTRDIFF_MIN  _I64_MIN
+#  define PTRDIFF_MAX  _I64_MAX
+#else  // _WIN64 ][
+#  define PTRDIFF_MIN  _I32_MIN
+#  define PTRDIFF_MAX  _I32_MAX
+#endif  // _WIN64 ]
+
+#define SIG_ATOMIC_MIN  INT_MIN
+#define SIG_ATOMIC_MAX  INT_MAX
+
+#ifndef SIZE_MAX // [
+#  ifdef _WIN64 // [
+#     define SIZE_MAX  _UI64_MAX
+#  else // _WIN64 ][
+#     define SIZE_MAX  _UI32_MAX
+#  endif // _WIN64 ]
+#endif // SIZE_MAX ]
+
+// WCHAR_MIN and WCHAR_MAX are also defined in <wchar.h>
+#ifndef WCHAR_MIN // [
+#  define WCHAR_MIN  0
+#endif  // WCHAR_MIN ]
+#ifndef WCHAR_MAX // [
+#  define WCHAR_MAX  _UI16_MAX
+#endif  // WCHAR_MAX ]
+
+#define WINT_MIN  0
+#define WINT_MAX  _UI16_MAX
+
+#endif // __STDC_LIMIT_MACROS ]
+
+
+// 7.18.4 Limits of other integer types
+
+#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [   See footnote 224 at page 260
+
+// 7.18.4.1 Macros for minimum-width integer constants
+
+#define INT8_C(val)  val##i8
+#define INT16_C(val) val##i16
+#define INT32_C(val) val##i32
+#define INT64_C(val) val##i64
+
+#define UINT8_C(val)  val##ui8
+#define UINT16_C(val) val##ui16
+#define UINT32_C(val) val##ui32
+#define UINT64_C(val) val##ui64
+
+// 7.18.4.2 Macros for greatest-width integer constants
+// These #ifndef's are needed to prevent collisions with <boost/cstdint.hpp>.
+// Check out Issue 9 for the details.
+#ifndef INTMAX_C //   [
+#  define INTMAX_C   INT64_C
+#endif // INTMAX_C    ]
+#ifndef UINTMAX_C //  [
+#  define UINTMAX_C  UINT64_C
+#endif // UINTMAX_C   ]
+
+#endif // __STDC_CONSTANT_MACROS ]
+
+#endif // _MSC_VER >= 1600 ]
+
+#endif // _MSC_STDINT_H_ ]

+ 9 - 0
Win32/unistd.h

@@ -0,0 +1,9 @@
+#ifndef	_UNISTD_H
+#define	_UNISTD_H
+
+int chdir(const char *);
+char *getcwd(char *buf, size_t size);
+char *getwd(char *buf);
+char *get_current_dir_name(void);
+
+#endif	//	_UNISTD_H

+ 60 - 0
Win32/w32.def.c

@@ -0,0 +1,60 @@
+#ifdef _WIN32
+#define _CRT_SECURE_NO_WARNINGS
+#define _CRT_NONSTDC_NO_WARNINGS
+#include <windows.h>
+#include <time.h>
+#include "../Win32/w32def.h"
+#endif	//	_WIN32
+
+static struct semid_ds sds = {0};
+
+int flock(int fd, int operation)
+{
+	return 0;
+}
+
+key_t ftok (const char *__pathname, int __proj_id)
+{
+	return 0x0666;
+}
+
+int semctl (int __semid, int __semnum, int __cmd, ...)
+{
+	return 0;
+}
+
+int semget (key_t __key, int __nsems, int __semflg)
+{
+	return 123;
+}
+
+int semop (int __semid, struct sembuf *__sops, size_t __nsops)
+{
+	sds.sem_otime = time(NULL);
+	return 0;
+}
+
+int semtimedop(int semid, struct sembuf *sops, size_t nsops, const struct timespec *timeout)
+{
+	sds.sem_otime = time(NULL);
+	return 0;
+}
+
+int shmctl (int __shmid, int __cmd, struct shmid_ds *__buf)
+{
+	return 0;
+}
+
+int shmget (key_t __key, size_t __size, int __shmflg)
+{
+	return 0;
+}
+void *shmat (int __shmid, const void *__shmaddr, int __shmflg)
+{
+	return 0;
+}
+
+int shmdt (const void *__shmaddr)
+{
+	return 0;
+}

+ 164 - 0
Win32/w32def.h

@@ -0,0 +1,164 @@
+// w32def.h :
+//
+
+#if !defined(AGD_W32DEF_H__F554E2DF_9B41_4A77_A414_F4A4FE09F0D4__INCLUDED_)
+#define AGD_W32DEF_H__F554E2DF_9B41_4A77_A414_F4A4FE09F0D4__INCLUDED_
+
+#ifdef __cplusplus
+extern "C" {
+#endif	//	__cplusplus
+
+/////////////////////////////////////////////////////////////////////////////
+// w32def.h - Declarations:
+
+#define PATH_MAX	_MAX_PATH
+
+#define	LOCK_SH		1		/* Shared lock.  */ 
+#define	LOCK_EX		2		/* Exclusive lock.  */ 
+#define	LOCK_UN		8		/* Unlock.  */ 
+
+#define IPC_CREAT	01000	/* Create key if key does not exist. */ 
+#define IPC_EXCL	02000	/* Fail if key exists.  */ 
+#define IPC_NOWAIT	04000	/* Return error on wait.  */ 
+
+#define IPC_RMID	0		/* Remove identifier.  */ 
+#define IPC_SET		1		/* Set `ipc_perm' options.  */ 
+#define IPC_STAT	2		/* Get `ipc_perm' options.  */ 
+#define IPC_INFO	3
+
+#define SEM_STAT	18
+#define SEM_INFO	19
+
+#define SEM_UNDO	0x1000
+
+#define	SHM_RDONLY	010000	/* read-only access */ 
+#define	SHM_RND		020000	/* round attach address to SHMLBA boundary */ 
+#define	SHM_REMAP	040000	/* take-over region on attach */ 
+#define	SHM_EXEC	0100000	/* execution access */ 
+
+#define SHM_LOCK	11 
+#define SHM_UNLOCK	12 
+#define SHM_STAT	13
+#define SHM_INFO	14
+
+#define GETPID		11		/* get sempid */ 
+#define GETVAL		12		/* get semval */ 
+#define GETALL		13		/* get all semval's */ 
+#define GETNCNT		14		/* get semncnt */ 
+#define GETZCNT		15		/* get semzcnt */ 
+#define SETVAL		16		/* set semval */ 
+#define SETALL		17		/* set all semval's */ 
+
+typedef int				key_t;
+typedef int				uid_t;
+typedef int				gid_t;
+typedef unsigned long	shmatt_t;
+typedef unsigned short	pid_t;
+
+struct timespec
+{
+	time_t tv_sec;      /* Seconds */
+	long   tv_nsec;     /* Nanoseconds [0 .. 999999999] */
+};
+
+int flock(int fd, int operation);
+key_t ftok (const char *__pathname, int __proj_id);
+
+struct ipc_perm 
+{ 
+	key_t __key;			/* Key.  */ 
+	uid_t uid;			/* Owner's user ID.  */ 
+	gid_t gid;			/* Owner's group ID.  */ 
+	uid_t cuid;			/* Creator's user ID.  */ 
+	gid_t cgid;			/* Creator's group ID.  */ 
+	unsigned short int mode;		/* Read/write permission.  */ 
+	unsigned short int __pad1; 
+	unsigned short int __seq;		/* Sequence number.  */ 
+	unsigned short int __pad2; 
+	unsigned long int __unused1; 
+	unsigned long int __unused2; 
+}; 
+
+struct  seminfo 
+{ 
+	int semmap; 
+	int semmni; 
+	int semmns; 
+	int semmnu; 
+	int semmsl; 
+	int semopm; 
+	int semume; 
+	int semusz; 
+	int semvmx; 
+	int semaem; 
+}; 
+
+struct sembuf 
+{ 
+  unsigned short int sem_num;	/* semaphore number */ 
+  short int sem_op;				/* semaphore operation */ 
+  short int sem_flg;			/* operation flag */ 
+}; 
+ 
+struct semid_ds
+{ 
+	struct ipc_perm sem_perm;			/* operation permission struct */ 
+	time_t sem_otime;					/* last semop() time */ 
+	unsigned long int __unused1; 
+	time_t sem_ctime;					/* last time changed by semctl() */ 
+	unsigned long int __unused2; 
+	unsigned long int sem_nsems;		/* number of semaphores in set */ 
+	unsigned long int __unused3; 
+	unsigned long int __unused4; 
+}; 
+ 
+int semctl (int __semid, int __semnum, int __cmd, ...);
+int semget (key_t __key, int __nsems, int __semflg);
+int semop (int __semid, struct sembuf *__sops, size_t __nsops);
+int semtimedop(int semid, struct sembuf *sops, size_t nsops, const struct timespec *timeout);
+
+struct shmid_ds
+{
+	struct ipc_perm shm_perm;       /* operation perms */
+	size_t  shm_segsz;              /* size of segment (bytes) */
+	time_t  shm_atime;              /* last attach time */
+	time_t  shm_dtime;              /* last detach time */
+	time_t  shm_ctime;              /* last change time */
+	pid_t shm_cpid;					/* pid of creator */
+	pid_t shm_lpid;					/* pid of last operator */
+	shmatt_t shm_nattch;            /* no. of current attaches */
+	/* the following are private */
+	unsigned short   shm_npages;     /* size of segment (pages) */
+	unsigned long   *shm_pages;      /* array of ptrs to frames -> SHMMAX */ 
+	struct vm_area_struct *attaches; /* descriptors for attaches */
+};
+
+struct shminfo
+{
+	unsigned long shmmax; /* Maximum segment size */
+	unsigned long shmmin; /* Minimum segment size; always 1 */
+	unsigned long shmmni; /* Maximum number of segments */
+	unsigned long shmseg; /* Maximum number of segments that a process can attach; unused within kernel */
+	unsigned long shmall; /* Maximum number of pages of shared memory, system-wide */
+};
+
+struct shm_info
+{
+	int           used_ids;			/* # of currently existing segments */
+	unsigned long shm_tot;			/* Total number of shared memory pages */
+	unsigned long shm_rss;			/* # of resident shared memory pages */
+	unsigned long shm_swp;			/* # of swapped shared memory pages */
+	unsigned long swap_attempts;	/* Unused since Linux 2.4 */
+	unsigned long swap_successes;	/* Unused since Linux 2.4 */
+};
+
+int shmctl (int __shmid, int __cmd, struct shmid_ds *__buf);
+int shmget (key_t __key, size_t __size, int __shmflg);
+void *shmat (int __shmid, const void *__shmaddr, int __shmflg); 
+int shmdt (const void *__shmaddr);
+
+/////////////////////////////////////////////////////////////////////////////
+#ifdef __cplusplus
+}
+#endif	//	__cplusplus
+#endif	//	!defined(AGD_W32DEF_H__F554E2DF_9B41_4A77_A414_F4A4FE09F0D4__INCLUDED_)

+ 22 - 0
bin/builddbg.sh

@@ -0,0 +1,22 @@
+#!/bin/bash
+set -e
+set -o pipefail
+
+CC=c++
+CCOPTS="-g -fPIC -Wall -Wno-unused -Wno-unused-label -Wformat -Wuninitialized -Wundef -Wcast-qual -Wwrite-strings -std=c++11 -fabi-version=2 -fno-omit-frame-pointer -D_DEBUG"
+
+LIBBASENAME="gfaipcd"
+LIBFILENAME="lib$LIBBASENAME.so.1.0.0"
+LINKNAME="lib$LIBBASENAME.so"
+
+$CC $CCOPTS -c ../src/uuid.c ../src/sema.cpp ../src/shm.cpp ../src/shmrot.cpp ../src/ipcshm.cpp
+$CC -g -fPIC -shared -L. -Wl,-soname,$LIBFILENAME -o $LIBFILENAME uuid.o sema.o shm.o shmrot.o ipcshm.o -lc
+rm -f *.o
+cp $LIBFILENAME ../Toolchain/x86_64
+
+#sudo mv $LIBFILENAME /usr/lib/
+#sudo ln -sfn /usr/lib/$LIBFILENAME /usr/lib/$LINKNAME
+
+#CCOPTS="-Wall -Wextra -Wformat -Wconversion -Wuninitialized -Wundef -Wcast-qual -Wwrite-strings -fabi-version=2 -fno-omit-frame-pointer"
+#$CC -D_DEBUG -g $CCOPTS -L. -o test.bin ../main.c -l$LIBBASENAME -lconfig -lpthread -lz -lm -lrt -ldl
+

+ 22 - 0
bin/buildrel.sh

@@ -0,0 +1,22 @@
+#!/bin/bash
+set -e
+set -o pipefail
+
+CC=c++
+CCOPTS="-O3 -fPIC -Wall -Wno-unused -Wno-unused-label -Wformat -Wuninitialized -Wundef -Wcast-qual -Wwrite-strings -std=c++11 -fabi-version=2 -fno-omit-frame-pointer"
+
+LIBBASENAME="gfaipc"
+LIBFILENAME="lib$LIBBASENAME.so.1.0.0"
+LINKNAME="lib$LIBBASENAME.so"
+
+$CC $CCOPTS -c ../src/uuid.c ../src/sema.cpp ../src/shm.cpp ../src/shmrot.cpp ../src/ipcshm.cpp
+$CC -O3 -fPIC -shared -L. -Wl,-soname,$LIBFILENAME -o $LIBFILENAME uuid.o sema.o shm.o shmrot.o ipcshm.o -lc
+rm -f *.o
+cp $LIBFILENAME ../Toolchain/x86_64
+
+#sudo mv $LIBFILENAME /usr/lib/
+#sudo ln -sfn /usr/lib/$LIBFILENAME /usr/lib/$LINKNAME
+
+#CCOPTS="-Wall -Wextra -Wformat -Wconversion -Wuninitialized -Wundef -Wcast-qual -Wwrite-strings -fabi-version=2 -fno-omit-frame-pointer"
+#$CC -O3 $CCOPTS -L. -o test.bin ../main.c -l$LIBBASENAME -lconfig -lpthread -lz -lm -lrt -ldl
+

+ 23 - 0
dev/builddbg.sh

@@ -0,0 +1,23 @@
+#!/bin/bash
+set -e
+set -o pipefail
+
+SYSROOT="/opt/GfA/T_C49xL448RT_Qt57x/usr/arm-buildroot-linux-gnueabihf/sysroot"
+CC="/opt/GfA/T_C49xL448RT_Qt57x/usr/bin/arm-buildroot-linux-gnueabihf-c++"
+CCOPTS="-g -fPIC -Wall -Wno-unused -Wno-unused-label -Wformat -Wuninitialized -Wundef -Wcast-qual -Wwrite-strings -std=c++11 -fabi-version=2 -fno-omit-frame-pointer -D_DEBUG"
+
+LIBBASENAME="gfaipcd"
+LIBFILENAME="lib$LIBBASENAME.so.1.0.0"
+LINKNAME="lib$LIBBASENAME.so"
+
+$CC $CCOPTS -c ../src/uuid.c ../src/sema.cpp ../src/shm.cpp ../src/shmrot.cpp ../src/ipcshm.cpp
+$CC -g -fPIC -shared -L. -Wl,-soname,$LIBFILENAME -o $LIBFILENAME uuid.o sema.o shm.o shmrot.o ipcshm.o -lc
+rm -f *.o
+cp $LIBFILENAME ../Toolchain/arm
+
+#sudo mv $LIBFILENAME $SYSROOT/usr/lib/
+#sudo ln -sfn $SYSROOT/usr/lib/$LIBFILENAME $SYSROOT/usr/lib/$LINKNAME
+
+#CCOPTS="-Wall -Wextra -Wformat -Wconversion -Wuninitialized -Wundef -Wcast-qual -Wwrite-strings -fabi-version=2 -fno-omit-frame-pointer"
+#$CC -D_DEBUG -g $CCOPTS -L. -o testd.bin ../main.c -l$LIBBASENAME -lconfig -lpthread -lz -lm -lrt -ldl
+

+ 23 - 0
dev/buildrel.sh

@@ -0,0 +1,23 @@
+#!/bin/bash
+set -e
+set -o pipefail
+
+SYSROOT="/opt/GfA/T_C49xL448RT_Qt57x/usr/arm-buildroot-linux-gnueabihf/sysroot"
+CC="/opt/GfA/T_C49xL448RT_Qt57x/usr/bin/arm-buildroot-linux-gnueabihf-c++"
+CCOPTS="-O3 -fPIC -Wall -Wno-unused -Wno-unused-label -Wformat -Wuninitialized -Wundef -Wcast-qual -Wwrite-strings -std=c++11 -fabi-version=2 -fno-omit-frame-pointer"
+
+LIBBASENAME="gfaipc"
+LIBFILENAME="lib$LIBBASENAME.so.1.0.0"
+LINKNAME="lib$LIBBASENAME.so"
+
+$CC $CCOPTS -c ../src/uuid.c ../src/sema.cpp ../src/shm.cpp ../src/shmrot.cpp ../src/ipcshm.cpp
+$CC -O3 -fPIC -shared -L. -Wl,-soname,$LIBFILENAME -o $LIBFILENAME uuid.o sema.o shm.o shmrot.o ipcshm.o -lc
+rm -f *.o
+cp $LIBFILENAME ../Toolchain/arm
+
+#sudo mv $LIBFILENAME $SYSROOT/usr/lib/
+#sudo ln -sfn $SYSROOT/usr/lib/$LIBFILENAME $SYSROOT/usr/lib/$LINKNAME
+
+#CCOPTS="-Wall -Wextra -Wformat -Wconversion -Wuninitialized -Wundef -Wcast-qual -Wwrite-strings -fabi-version=2 -fno-omit-frame-pointer"
+#$CC -O3 $CCOPTS -L. -o testr.bin ../main.c -l$LIBBASENAME -lconfig -lpthread -lz -lm -lrt -ldl
+

BIN
gfaipc.ncb


+ 20 - 0
gfaipc.sln

@@ -0,0 +1,20 @@
+
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual Studio 2008
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gfaipc", "gfaipc.vcproj", "{F7A57D74-C9FD-436A-B4D8-162B3799CEBD}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Win32 = Debug|Win32
+		Release|Win32 = Release|Win32
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{F7A57D74-C9FD-436A-B4D8-162B3799CEBD}.Debug|Win32.ActiveCfg = Debug|Win32
+		{F7A57D74-C9FD-436A-B4D8-162B3799CEBD}.Debug|Win32.Build.0 = Debug|Win32
+		{F7A57D74-C9FD-436A-B4D8-162B3799CEBD}.Release|Win32.ActiveCfg = Release|Win32
+		{F7A57D74-C9FD-436A-B4D8-162B3799CEBD}.Release|Win32.Build.0 = Release|Win32
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+EndGlobal

BIN
gfaipc.suo


+ 253 - 0
gfaipc.vcproj

@@ -0,0 +1,253 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="9.00"
+	Name="gfaipc"
+	ProjectGUID="{F7A57D74-C9FD-436A-B4D8-162B3799CEBD}"
+	RootNamespace="gfaipc"
+	Keyword="Win32Proj"
+	TargetFrameworkVersion="196613"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="1"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories=".\Win32"
+				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="3"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				DebugInformationFormat="4"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				LinkIncremental="2"
+				GenerateDebugInformation="true"
+				SubSystem="1"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+				CommandLine="copy src\gfaipc.h install\"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="1"
+			CharacterSet="1"
+			WholeProgramOptimization="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="2"
+				EnableIntrinsicFunctions="true"
+				AdditionalIncludeDirectories=".\Win32"
+				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+				RuntimeLibrary="2"
+				EnableFunctionLevelLinking="true"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				DebugInformationFormat="3"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				LinkIncremental="1"
+				GenerateDebugInformation="true"
+				SubSystem="1"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+				CommandLine="copy src/gfaipc.h install/"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Quelldateien"
+			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+			>
+			<File
+				RelativePath=".\src\ipcshm.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\main.c"
+				>
+			</File>
+			<File
+				RelativePath=".\src\sema.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\src\shm.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\src\shmrot.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\src\uuid.c"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Headerdateien"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+			>
+			<File
+				RelativePath=".\src\defines.h"
+				>
+			</File>
+			<File
+				RelativePath=".\src\gfaipc.h"
+				>
+			</File>
+			<File
+				RelativePath=".\src\sema.h"
+				>
+			</File>
+			<File
+				RelativePath=".\src\shm.h"
+				>
+			</File>
+			<File
+				RelativePath=".\src\shmrot.h"
+				>
+			</File>
+			<File
+				RelativePath=".\src\uuid.h"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Ressourcendateien"
+			Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+			UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+			>
+		</Filter>
+		<Filter
+			Name="Win32"
+			>
+			<File
+				RelativePath=".\Win32\w32.def.c"
+				>
+			</File>
+			<File
+				RelativePath=".\Win32\w32def.h"
+				>
+			</File>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>

+ 65 - 0
gfaipc.vcproj.HCR64SSD.HCR.user

@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioUserFile
+	ProjectType="Visual C++"
+	Version="9.00"
+	ShowAllFiles="false"
+	>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			>
+			<DebugSettings
+				Command="$(TargetPath)"
+				WorkingDirectory=""
+				CommandArguments=""
+				Attach="false"
+				DebuggerType="3"
+				Remote="1"
+				RemoteMachine="HCR64SSD"
+				RemoteCommand=""
+				HttpUrl=""
+				PDBPath=""
+				SQLDebugging=""
+				Environment=""
+				EnvironmentMerge="true"
+				DebuggerFlavor=""
+				MPIRunCommand=""
+				MPIRunArguments=""
+				MPIRunWorkingDirectory=""
+				ApplicationCommand=""
+				ApplicationArguments=""
+				ShimCommand=""
+				MPIAcceptMode=""
+				MPIAcceptFilter=""
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			>
+			<DebugSettings
+				Command="$(TargetPath)"
+				WorkingDirectory=""
+				CommandArguments=""
+				Attach="false"
+				DebuggerType="3"
+				Remote="1"
+				RemoteMachine="HCR64SSD"
+				RemoteCommand=""
+				HttpUrl=""
+				PDBPath=""
+				SQLDebugging=""
+				Environment=""
+				EnvironmentMerge="true"
+				DebuggerFlavor=""
+				MPIRunCommand=""
+				MPIRunArguments=""
+				MPIRunWorkingDirectory=""
+				ApplicationCommand=""
+				ApplicationArguments=""
+				ShimCommand=""
+				MPIAcceptMode=""
+				MPIAcceptFilter=""
+			/>
+		</Configuration>
+	</Configurations>
+</VisualStudioUserFile>

+ 86 - 0
main.c

@@ -0,0 +1,86 @@
+// main.c
+//
+#ifdef _WIN32
+#define _CRT_SECURE_NO_WARNINGS
+#include <windows.h>
+#include "../Win32/w32def.h"
+#define sleep(sec)				Sleep(sec * 1000)
+#endif	//	_WIN32
+
+#include <stdio.h>
+#include "src/defines.h"
+#include "src/gfaipc.h"
+
+#define _UNUSED(v)				v = v
+
+typedef struct _TESTSTRUCT1
+{
+	int nCounter1;
+	int nCounter2;
+}TESTSTRUCT1, *LPTESTSTRUCT1;
+typedef const TESTSTRUCT1 *LPCTESTSTRUCT1;
+
+typedef struct _TESTSTRUCT2
+{
+	int nCounter1;
+	int nCounter2;
+}TESTSTRUCT2, *LPTESTSTRUCT2;
+typedef const TESTSTRUCT2 *LPCTESTSTRUCT2;
+
+#define _UUID_TESTSTRUCT1			"8c2e723a-5556-4d90-b5ed-bba8575b6f28"
+#define _UUID_TESTSTRUCT2			"8d961df7-96c4-45cd-8dd7-346227782ac0"
+
+
+int main(int argc, char *argv[])
+{
+	HSHM hShm1, hShm2;
+	LPTESTSTRUCT1 p1 = NULL;
+	LPTESTSTRUCT2 p2 = NULL;
+
+	_UNUSED(argc);
+	_UNUSED(argv);
+
+	GfaIpcDumpSHMROT();
+
+	hShm1 = GfaIpcAcquireSHM(_UUID_TESTSTRUCT1, sizeof(TESTSTRUCT1), 1, "Teststruct 1");
+	GfaIpcDumpSHMROT();
+	hShm2 = GfaIpcAcquireSHM(_UUID_TESTSTRUCT2, sizeof(TESTSTRUCT2), 1, "Teststruct 2");
+	GfaIpcDumpSHMROT();
+
+	if(hShm1 && hShm2)
+	{
+		p1 = (LPTESTSTRUCT1)GfaIpcAcquirePointer(hShm1);
+		TRACE("Get pointer: %p\n", p1);
+		p2 = (LPTESTSTRUCT2)GfaIpcAcquirePointer(hShm2);
+		TRACE("Get pointer: %p\n", p2);
+
+		TRACE("p1C1: %d, p1C2: %d\n", p1->nCounter1, p1->nCounter2);
+		TRACE("p2C1: %d, p2C2: %d\n", p2->nCounter1, p2->nCounter2);
+
+		GfaIpcLockSHM(hShm1);
+		p1->nCounter1++;
+		p1->nCounter2--;
+		GfaIpcUnlockSHM(hShm1);
+		TRACE("p1C1: %d, p1C2: %d\n", p1->nCounter1, p1->nCounter2);
+		TRACE("p2C1: %d, p2C2: %d\n", p2->nCounter1, p2->nCounter2);
+
+		GfaIpcLockSHM(hShm2);
+		p2->nCounter1--;
+		p2->nCounter2++;
+		GfaIpcUnlockSHM(hShm2);
+		TRACE("p1C1: %d, p1C2: %d\n", p1->nCounter1, p1->nCounter2);
+		TRACE("p2C1: %d, p2C2: %d\n", p2->nCounter1, p2->nCounter2);
+
+		GfaIpcReleasePointer(hShm1, p1);
+		GfaIpcReleasePointer(hShm2, p2);
+
+		GfaIpcReleaseSHM(hShm1);
+		GfaIpcReleaseSHM(hShm2);
+	}
+
+	//uuid_t uuid;
+	//_uuid_parse("8c2e723a-5556-4d90-b5ed-bba8575b6f28", &uuid);
+
+	return 0;
+}
+

+ 80 - 0
qttest/main.c

@@ -0,0 +1,80 @@
+#include <stdio.h>
+#include <gfaipc.h>
+
+#define _UNUSED(v)				v = v
+
+typedef struct _TESTSTRUCT1
+{
+    int nCounter1;
+    int nCounter2;
+}TESTSTRUCT1, *LPTESTSTRUCT1;
+typedef const TESTSTRUCT1 *LPCTESTSTRUCT1;
+
+typedef struct _TESTSTRUCT2
+{
+    int nCounter1;
+    int nCounter2;
+}TESTSTRUCT2, *LPTESTSTRUCT2;
+typedef const TESTSTRUCT2 *LPCTESTSTRUCT2;
+
+#define _UUID_TESTSTRUCT1			"8c2e723a-5556-4d90-b5ed-bba8575b6f28"
+#define _UUID_TESTSTRUCT2			"8d961df7-96c4-45cd-8dd7-346227782ac0"
+
+static HSHM g_hShm1 = NULL;
+static HSHM g_hShm2 = NULL;
+
+int main(int argc, char *argv[])
+{
+    LPTESTSTRUCT1 p1 = NULL;
+    LPTESTSTRUCT2 p2 = NULL;
+
+    _UNUSED(argc);
+    _UNUSED(argv);
+
+    GfaIpcDumpSHMROT();
+
+    g_hShm1 = GfaIpcAcquireSHM(_UUID_TESTSTRUCT1, sizeof(TESTSTRUCT1), 1, "Teststruct 1");
+    GfaIpcDumpSHMROT();
+    g_hShm2 = GfaIpcAcquireSHM(_UUID_TESTSTRUCT2, sizeof(TESTSTRUCT2), 1, "Teststruct 2");
+    GfaIpcDumpSHMROT();
+
+    if(g_hShm1 && g_hShm2)
+    {
+        p1 = (LPTESTSTRUCT1)GfaIpcAcquirePointer(g_hShm1);
+        printf("Get pointer: %p\n", p1);
+        p2 = (LPTESTSTRUCT2)GfaIpcAcquirePointer(g_hShm2);
+        printf("Get pointer: %p\n", p2);
+
+        printf("p1C1: %d, p1C2: %d\n", p1->nCounter1, p1->nCounter2);
+        printf("p2C1: %d, p2C2: %d\n", p2->nCounter1, p2->nCounter2);
+
+        GfaIpcLockSHM(g_hShm1);
+        p1->nCounter1++;
+        p1->nCounter2--;
+        GfaIpcUnlockSHM(g_hShm1);
+        printf("p1C1: %d, p1C2: %d\n", p1->nCounter1, p1->nCounter2);
+        printf("p2C1: %d, p2C2: %d\n", p2->nCounter1, p2->nCounter2);
+
+        GfaIpcLockSHM(g_hShm2);
+        p2->nCounter1--;
+        p2->nCounter2++;
+        GfaIpcUnlockSHM(g_hShm2);
+        printf("p1C1: %d, p1C2: %d\n", p1->nCounter1, p1->nCounter2);
+        printf("p2C1: %d, p2C2: %d\n", p2->nCounter1, p2->nCounter2);
+
+        if(p1)
+        {
+            GfaIpcReleasePointer(g_hShm1, p1);
+        }
+
+        if(p2)
+        {
+            GfaIpcReleasePointer(g_hShm2, p2);
+        }
+
+        GfaIpcReleaseSHM(g_hShm1);
+        GfaIpcReleaseSHM(g_hShm2);
+    }
+
+    return 0;
+}

+ 11 - 0
qttest/qttest.pro

@@ -0,0 +1,11 @@
+TEMPLATE = app
+CONFIG += console
+CONFIG -= app_bundle
+CONFIG -= qt
+
+QMAKE_LIBS += -lgfaipc
+
+target.path = /root/gfaipc
+INSTALLS += target
+
+SOURCES += main.c

+ 636 - 0
qttest/qttest.pro.user

@@ -0,0 +1,636 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE QtCreatorProject>
+<!-- Written by QtCreator 4.0.2, 2016-11-24T13:47:38. -->
+<qtcreator>
+ <data>
+  <variable>EnvironmentId</variable>
+  <value type="QByteArray">{b9ed9a41-2c05-4012-9893-a7033fe3f9d2}</value>
+ </data>
+ <data>
+  <variable>ProjectExplorer.Project.ActiveTarget</variable>
+  <value type="int">1</value>
+ </data>
+ <data>
+  <variable>ProjectExplorer.Project.EditorSettings</variable>
+  <valuemap type="QVariantMap">
+   <value type="bool" key="EditorConfiguration.AutoIndent">true</value>
+   <value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
+   <value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
+   <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
+    <value type="QString" key="language">Cpp</value>
+    <valuemap type="QVariantMap" key="value">
+     <value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
+    </valuemap>
+   </valuemap>
+   <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
+    <value type="QString" key="language">QmlJS</value>
+    <valuemap type="QVariantMap" key="value">
+     <value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
+    </valuemap>
+   </valuemap>
+   <value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
+   <value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
+   <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
+   <value type="int" key="EditorConfiguration.IndentSize">4</value>
+   <value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
+   <value type="int" key="EditorConfiguration.MarginColumn">80</value>
+   <value type="bool" key="EditorConfiguration.MouseHiding">true</value>
+   <value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
+   <value type="int" key="EditorConfiguration.PaddingMode">1</value>
+   <value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
+   <value type="bool" key="EditorConfiguration.ShowMargin">false</value>
+   <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
+   <value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
+   <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
+   <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
+   <value type="int" key="EditorConfiguration.TabSize">8</value>
+   <value type="bool" key="EditorConfiguration.UseGlobal">true</value>
+   <value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
+   <value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
+   <value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
+   <value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
+   <value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
+  </valuemap>
+ </data>
+ <data>
+  <variable>ProjectExplorer.Project.PluginSettings</variable>
+  <valuemap type="QVariantMap"/>
+ </data>
+ <data>
+  <variable>ProjectExplorer.Project.Target.0</variable>
+  <valuemap type="QVariantMap">
+   <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.7.0 GCC 64bit</value>
+   <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.7.0 GCC 64bit</value>
+   <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.57.gcc_64_kit</value>
+   <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
+   <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
+   <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
+   <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
+    <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/wrk/share/gfaipc/qttest/Debug/Desktop_Qt_5_7_0_GCC_64bit</value>
+    <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
+     <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
+      <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
+      <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">true</value>
+      <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
+      <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
+      <value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value>
+      <value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value>
+     </valuemap>
+     <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
+      <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
+      <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
+       <value type="QString">-w</value>
+       <value type="QString">-r</value>
+      </valuelist>
+      <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
+      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
+      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
+     </valuemap>
+     <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
+    </valuemap>
+    <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
+     <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
+      <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
+      <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
+       <value type="QString">-w</value>
+       <value type="QString">-r</value>
+      </valuelist>
+      <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
+      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
+      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
+     </valuemap>
+     <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Bereinigen</value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
+    </valuemap>
+    <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
+    <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
+    <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Debug</value>
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
+    <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
+    <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
+   </valuemap>
+   <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
+    <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/wrk/share/gfaipc/qttest/Release/Desktop_Qt_5_7_0_GCC_64bit</value>
+    <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
+     <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
+      <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
+      <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
+      <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
+      <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
+      <value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value>
+      <value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value>
+     </valuemap>
+     <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
+      <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
+      <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
+       <value type="QString">-w</value>
+       <value type="QString">-r</value>
+      </valuelist>
+      <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
+      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
+      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
+     </valuemap>
+     <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
+    </valuemap>
+    <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
+     <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
+      <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
+      <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
+       <value type="QString">-w</value>
+       <value type="QString">-r</value>
+      </valuelist>
+      <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
+      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
+      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
+     </valuemap>
+     <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Bereinigen</value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
+    </valuemap>
+    <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
+    <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
+    <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value>
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
+    <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
+    <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
+   </valuemap>
+   <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
+    <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/wrk/share/gfaipc/qttest/Profile/Desktop_Qt_5_7_0_GCC_64bit</value>
+    <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
+     <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
+      <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
+      <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">true</value>
+      <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
+      <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
+      <value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">true</value>
+      <value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value>
+     </valuemap>
+     <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
+      <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
+      <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
+       <value type="QString">-w</value>
+       <value type="QString">-r</value>
+      </valuelist>
+      <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
+      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
+      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
+     </valuemap>
+     <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
+    </valuemap>
+    <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
+     <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
+      <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
+      <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
+       <value type="QString">-w</value>
+       <value type="QString">-r</value>
+      </valuelist>
+      <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
+      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
+      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
+     </valuemap>
+     <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Bereinigen</value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
+    </valuemap>
+    <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
+    <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
+    <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Profile</value>
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
+    <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
+    <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
+   </valuemap>
+   <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">3</value>
+   <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
+    <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
+     <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deployment</value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
+    </valuemap>
+    <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Lokales Deployment</value>
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
+   </valuemap>
+   <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
+   <valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
+   <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
+    <value type="bool" key="Analyzer.QmlProfiler.AggregateTraces">false</value>
+    <value type="bool" key="Analyzer.QmlProfiler.FlushEnabled">false</value>
+    <value type="uint" key="Analyzer.QmlProfiler.FlushInterval">1000</value>
+    <value type="QString" key="Analyzer.QmlProfiler.LastTraceFile"></value>
+    <value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
+    <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
+    <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
+    <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
+    <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
+    <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
+    <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
+    <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
+    <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
+    <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
+    <value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
+    <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
+    <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
+    <value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
+    <value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
+    <value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
+    <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
+    <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
+    <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
+     <value type="int">0</value>
+     <value type="int">1</value>
+     <value type="int">2</value>
+     <value type="int">3</value>
+     <value type="int">4</value>
+     <value type="int">5</value>
+     <value type="int">6</value>
+     <value type="int">7</value>
+     <value type="int">8</value>
+     <value type="int">9</value>
+     <value type="int">10</value>
+     <value type="int">11</value>
+     <value type="int">12</value>
+     <value type="int">13</value>
+     <value type="int">14</value>
+    </valuelist>
+    <value type="int" key="PE.EnvironmentAspect.Base">2</value>
+    <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qttest</value>
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/wrk/share/gfaipc/qttest/qttest.pro</value>
+    <value type="bool" key="QmakeProjectManager.QmakeRunConfiguration.UseLibrarySearchPath">true</value>
+    <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
+    <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">qttest.pro</value>
+    <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
+    <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
+    <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory.default">/home/wrk/share/gfaipc/qttest/Debug/Desktop_Qt_5_7_0_GCC_64bit</value>
+    <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
+    <value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
+    <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
+    <value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
+    <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
+    <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
+   </valuemap>
+   <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
+  </valuemap>
+ </data>
+ <data>
+  <variable>ProjectExplorer.Project.Target.1</variable>
+  <valuemap type="QVariantMap">
+   <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">GfA-Device</value>
+   <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">GfA-Device</value>
+   <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{b0a415a1-ecbe-4123-8afc-05ffc0004131}</value>
+   <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
+   <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
+   <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
+   <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
+    <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/wrk/share/gfaipc/qttest/Debug/GfA_Device</value>
+    <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
+     <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
+      <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
+      <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">true</value>
+      <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
+      <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
+      <value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value>
+      <value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value>
+     </valuemap>
+     <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
+      <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
+      <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
+       <value type="QString">-w</value>
+       <value type="QString">-r</value>
+      </valuelist>
+      <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
+      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
+      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
+     </valuemap>
+     <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
+    </valuemap>
+    <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
+     <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
+      <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
+      <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
+       <value type="QString">-w</value>
+       <value type="QString">-r</value>
+      </valuelist>
+      <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
+      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
+      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
+     </valuemap>
+     <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Bereinigen</value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
+    </valuemap>
+    <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
+    <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
+    <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Debug</value>
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
+    <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
+    <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
+   </valuemap>
+   <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
+    <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/wrk/share/gfaipc/qttest/Release/GfA_Device</value>
+    <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
+     <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
+      <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
+      <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
+      <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
+      <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
+      <value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value>
+      <value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value>
+     </valuemap>
+     <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
+      <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
+      <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
+       <value type="QString">-w</value>
+       <value type="QString">-r</value>
+      </valuelist>
+      <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
+      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
+      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
+     </valuemap>
+     <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
+    </valuemap>
+    <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
+     <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
+      <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
+      <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
+       <value type="QString">-w</value>
+       <value type="QString">-r</value>
+      </valuelist>
+      <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
+      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
+      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
+     </valuemap>
+     <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Bereinigen</value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
+    </valuemap>
+    <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
+    <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
+    <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value>
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
+    <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
+    <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
+   </valuemap>
+   <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
+    <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/wrk/share/gfaipc/qttest/Profile/GfA_Device</value>
+    <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
+     <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
+      <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
+      <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">true</value>
+      <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
+      <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
+      <value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">true</value>
+      <value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value>
+     </valuemap>
+     <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
+      <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
+      <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
+       <value type="QString">-w</value>
+       <value type="QString">-r</value>
+      </valuelist>
+      <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
+      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
+      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
+     </valuemap>
+     <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
+    </valuemap>
+    <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
+     <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
+      <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
+      <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
+       <value type="QString">-w</value>
+       <value type="QString">-r</value>
+      </valuelist>
+      <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
+      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
+      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
+     </valuemap>
+     <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Bereinigen</value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
+    </valuemap>
+    <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
+    <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
+    <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Profile</value>
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
+    <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
+    <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
+   </valuemap>
+   <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">3</value>
+   <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
+    <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
+     <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
+      <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Freien Plattenplatz überprüfen</value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">RemoteLinux.CheckForFreeDiskSpaceStep</value>
+      <valuelist type="QVariantList" key="Qt4ProjectManager.MaemoRunConfiguration.LastDeployedFiles"/>
+      <valuelist type="QVariantList" key="Qt4ProjectManager.MaemoRunConfiguration.LastDeployedHosts"/>
+      <valuelist type="QVariantList" key="Qt4ProjectManager.MaemoRunConfiguration.LastDeployedRemotePaths"/>
+      <valuelist type="QVariantList" key="Qt4ProjectManager.MaemoRunConfiguration.LastDeployedSysroots"/>
+      <valuelist type="QVariantList" key="Qt4ProjectManager.MaemoRunConfiguration.LastDeployedTimes"/>
+      <value type="QString" key="RemoteLinux.CheckForFreeDiskSpaceStep.PathToCheck">/</value>
+      <value type="qulonglong" key="RemoteLinux.CheckForFreeDiskSpaceStep.RequiredSpace">5242880</value>
+     </valuemap>
+     <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
+      <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Dateien mittels SFTP hochladen</value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">RemoteLinux.DirectUploadStep</value>
+      <valuelist type="QVariantList" key="Qt4ProjectManager.MaemoRunConfiguration.LastDeployedFiles">
+       <value type="QString">/home/wrk/share/gfaipc/qttest/Debug/GfA_Device/qttest</value>
+      </valuelist>
+      <valuelist type="QVariantList" key="Qt4ProjectManager.MaemoRunConfiguration.LastDeployedHosts">
+       <value type="QString">192.168.0.125</value>
+      </valuelist>
+      <valuelist type="QVariantList" key="Qt4ProjectManager.MaemoRunConfiguration.LastDeployedRemotePaths">
+       <value type="QString">/root/gfaipc</value>
+      </valuelist>
+      <valuelist type="QVariantList" key="Qt4ProjectManager.MaemoRunConfiguration.LastDeployedSysroots">
+       <value type="QString">/opt/GfA/T_C49xL448RT_Qt57x/usr/arm-buildroot-linux-gnueabihf/sysroot</value>
+      </valuelist>
+      <valuelist type="QVariantList" key="Qt4ProjectManager.MaemoRunConfiguration.LastDeployedTimes">
+       <value type="QDateTime">2016-11-18T22:25:49</value>
+      </valuelist>
+      <value type="bool" key="RemoteLinux.GenericDirectUploadStep.IgnoreMissingFiles">false</value>
+      <value type="bool" key="RemoteLinux.GenericDirectUploadStep.Incremental">true</value>
+     </valuemap>
+     <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deployment</value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
+    </valuemap>
+    <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Auf Linux-Mobilgerät ausführen</value>
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">DeployToGenericLinux</value>
+   </valuemap>
+   <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
+   <valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
+   <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
+    <value type="bool" key="Analyzer.QmlProfiler.AggregateTraces">false</value>
+    <value type="bool" key="Analyzer.QmlProfiler.FlushEnabled">false</value>
+    <value type="uint" key="Analyzer.QmlProfiler.FlushInterval">1000</value>
+    <value type="QString" key="Analyzer.QmlProfiler.LastTraceFile"></value>
+    <value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
+    <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
+    <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
+    <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
+    <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
+    <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
+    <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
+    <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
+    <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
+    <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
+    <value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
+    <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
+    <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
+    <value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
+    <value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
+    <value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
+    <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
+    <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
+    <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
+     <value type="int">0</value>
+     <value type="int">1</value>
+     <value type="int">2</value>
+     <value type="int">3</value>
+     <value type="int">4</value>
+     <value type="int">5</value>
+     <value type="int">6</value>
+     <value type="int">7</value>
+     <value type="int">8</value>
+     <value type="int">9</value>
+     <value type="int">10</value>
+     <value type="int">11</value>
+     <value type="int">12</value>
+     <value type="int">13</value>
+     <value type="int">14</value>
+    </valuelist>
+    <value type="int" key="PE.EnvironmentAspect.Base">1</value>
+    <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qttest (auf Mobilgerät)</value>
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">RemoteLinuxRunConfiguration:qttest</value>
+    <value type="QString" key="Qt4ProjectManager.MaemoRunConfiguration.Arguments"></value>
+    <value type="QString" key="Qt4ProjectManager.MaemoRunConfiguration.TargetName">qttest</value>
+    <value type="QString" key="RemoteLinux.RunConfig.AlternateRemoteExecutable"></value>
+    <value type="bool" key="RemoteLinux.RunConfig.UseAlternateRemoteExecutable">false</value>
+    <value type="QString" key="RemoteLinux.RunConfig.WorkingDirectory"></value>
+    <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
+    <value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
+    <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
+    <value type="bool" key="RunConfiguration.UseMultiProcess">true</value>
+    <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
+    <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
+   </valuemap>
+   <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
+  </valuemap>
+ </data>
+ <data>
+  <variable>ProjectExplorer.Project.TargetCount</variable>
+  <value type="int">2</value>
+ </data>
+ <data>
+  <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
+  <value type="int">18</value>
+ </data>
+ <data>
+  <variable>Version</variable>
+  <value type="int">18</value>
+ </data>
+</qtcreator>

+ 33 - 0
src/defines.h

@@ -0,0 +1,33 @@
+// defines.h :
+//
+
+#if !defined(AGD_DEFINES_H__CBCFEAE4_7504_435D_BD29_909BA80D72CD__INCLUDED_)
+#define AGD_DEFINES_H__CBCFEAE4_7504_435D_BD29_909BA80D72CD__INCLUDED_
+
+#ifdef __cplusplus
+extern "C" {
+#endif	//	__cplusplus
+
+/////////////////////////////////////////////////////////////////////////////
+// defines.h - Declarations:
+
+#ifdef _WIN32
+#endif	//	_WIN32
+
+#ifdef __linux__
+#endif	//	__linux__
+
+#define _INVALID_ID							-1
+#define _NUMBER_OF_THE_BEAST				0666
+
+#ifdef _DEBUG
+#define TRACE								printf
+#else	//	_DEBUG
+#define TRACE(...)
+#endif	//	_DEBUG
+
+/////////////////////////////////////////////////////////////////////////////
+#ifdef __cplusplus
+}
+#endif	//	__cplusplus
+#endif	//	!defined(AGD_DEFINES_H__CBCFEAE4_7504_435D_BD29_909BA80D72CD__INCLUDED_)

+ 28 - 0
src/gfaipc.h

@@ -0,0 +1,28 @@
+// gfaipc.h :
+//
+
+#if !defined(AGD_GFAIPC_H__6126047E_C1B1_4ACE_BD49_8780C7E5E068__INCLUDED_)
+#define AGD_GFAIPC_H__6126047E_C1B1_4ACE_BD49_8780C7E5E068__INCLUDED_
+
+#ifdef __cplusplus
+extern "C" {
+#endif	//	__cplusplus
+
+/////////////////////////////////////////////////////////////////////////////
+// gfaipc.h - Declarations:
+
+typedef void				*HSHM;
+
+HSHM	GfaIpcAcquireSHM	(const char *pszUuid, size_t nSizeElement, size_t nCntElements, const char *pszDescName);
+void	GfaIpcReleaseSHM	(HSHM hShm);
+void*	GfaIpcAcquirePointer(HSHM hShm);
+void	GfaIpcReleasePointer(HSHM hShm, const void *p);
+void	GfaIpcLockSHM		(HSHM hShm);
+void	GfaIpcUnlockSHM		(HSHM hShm);
+void	GfaIpcDumpSHMROT	(void);
+
+/////////////////////////////////////////////////////////////////////////////
+#ifdef __cplusplus
+}
+#endif	//	__cplusplus
+#endif	//	!defined(AGD_GFAIPC_H__6126047E_C1B1_4ACE_BD49_8780C7E5E068__INCLUDED_)

+ 227 - 0
src/ipcshm.cpp

@@ -0,0 +1,227 @@
+// gfaipc.cpp
+//
+
+#ifdef _WIN32
+#define _CRT_SECURE_NO_WARNINGS
+#include <windows.h>
+#endif	//	_WIN32
+
+#include <stdio.h>
+#include <string.h>
+#include "defines.h"
+#include "uuid.h"
+#include "shmrot.h"
+#include "gfaipc.h"
+
+/////////////////////////////////////////////////////////////////////////////
+
+typedef struct _SHM_HANDLE
+{
+	CShm *pShm;
+}SHM_HANDLE, *LPSHM_HANDLE;
+typedef const SHM_HANDLE *LPCSHM_HANDLE;
+
+/////////////////////////////////////////////////////////////////////////////
+
+#define _IPCSHM_MAX_HANDLES			32
+
+class CShmHandle
+{
+public:
+	CShmHandle(void);
+	~CShmHandle(void);
+
+	HSHM AcquireHandle(CShm *pShm);
+	void ReleaseHandle(HSHM hShm);
+
+private:
+	SHM_HANDLE m_handles[_IPCSHM_MAX_HANDLES];
+};
+
+/////////////////////////////////////////////////////////////////////////////
+
+CShmHandle::CShmHandle(void)
+{
+	memset(m_handles, 0, sizeof(m_handles));
+}
+
+CShmHandle::~CShmHandle(void)
+{
+	for(size_t i = 0; i < _IPCSHM_MAX_HANDLES; i++)
+	{
+	}
+}
+
+HSHM CShmHandle::AcquireHandle(CShm *pShm)
+{
+	HSHM hShm = NULL;
+
+	for(int i = 0; i < _IPCSHM_MAX_HANDLES; i++)
+	{
+		if(!m_handles[i].pShm)
+		{
+			m_handles[i].pShm = pShm;
+			hShm = &m_handles[i];
+			break;
+		}
+	}
+
+	return hShm;
+}
+
+void CShmHandle::ReleaseHandle(HSHM hShm)
+{
+	for(int i = 0; i < _IPCSHM_MAX_HANDLES; i++)
+	{
+		if(&m_handles[i] == hShm)
+		{
+			m_handles[i].pShm = NULL;
+			break;
+		}
+	}
+}
+
+/////////////////////////////////////////////////////////////////////////////
+
+static CShmROT g_shmRot;
+static CShmHandle g_shmHandleMap;
+
+/////////////////////////////////////////////////////////////////////////////
+
+HSHM GfaIpcAcquireSHM(const char *pszUuid, size_t nSizeElement, size_t nCntElements, const char *pszDescName)
+{
+	HSHM hShm = NULL;
+
+	if(!g_shmRot.Created())
+	{
+		if(!g_shmRot.Create())
+		{
+			TRACE("GfaIpcAcquireSHM: Failed to create ROT!\n");
+			return NULL;
+		}
+	}
+
+	g_shmRot.Lock();
+	CShm *pShm = g_shmRot.AcquireShm(pszUuid, nSizeElement, nCntElements, pszDescName);
+
+	if(pShm)
+	{
+		hShm = g_shmHandleMap.AcquireHandle(pShm);
+
+		if(!hShm)
+		{
+			TRACE("GfaIpcAcquireSHM: Failed to acquire handle!\n");
+			g_shmRot.ReleaseShm(pShm);
+		}
+	}
+
+	g_shmRot.Unlock();
+
+	return hShm;
+}
+
+void GfaIpcReleaseSHM(HSHM hShm)
+{
+	if(hShm)
+	{
+		LPSHM_HANDLE ph = (LPSHM_HANDLE)hShm;
+		if(!ph->pShm)
+		{
+			TRACE("GfaIpcReleaseSHM: Invalid Handle!\n");
+			return;
+		}
+		g_shmRot.Lock();
+		g_shmRot.ReleaseShm(ph->pShm);
+		g_shmHandleMap.ReleaseHandle(hShm);
+		g_shmRot.Unlock();
+	}
+}
+
+void* GfaIpcAcquirePointer(HSHM hShm)
+{
+	if(hShm)
+	{
+		LPSHM_HANDLE ph = (LPSHM_HANDLE)hShm;
+		if(!ph->pShm)
+		{
+			TRACE("GfaIpcAcquirePointer: Invalid Handle!\n");
+			return NULL;
+		}
+
+		return ph->pShm->Attach();
+	}
+
+	TRACE("GfaIpcAcquirePointer: Invalid Handle!\n");
+	return NULL;
+}
+
+void GfaIpcReleasePointer(HSHM hShm, const void *p)
+{
+	if(!hShm)
+	{
+		TRACE("GfaIpcReleasePointer: Invalid Handle!\n");
+		return;
+	}
+
+	LPSHM_HANDLE ph = (LPSHM_HANDLE)hShm;
+
+	if(!ph->pShm)
+	{
+		TRACE("GfaIpcReleasePointer: Invalid Handle!\n");
+		return;
+	}
+
+	ph->pShm->Detach(p);
+}
+
+void GfaIpcLockSHM(HSHM hShm)
+{
+	if(!hShm)
+	{
+		TRACE("GfaIpcReleasePointer: Invalid Handle!\n");
+		return;
+	}
+
+	LPSHM_HANDLE ph = (LPSHM_HANDLE)hShm;
+
+	if(!ph->pShm)
+	{
+		TRACE("GfaIpcReleasePointer: Invalid Handle!\n");
+		return;
+	}
+
+	ph->pShm->Lock();
+}
+
+void GfaIpcUnlockSHM(HSHM hShm)
+{
+	if(!hShm)
+	{
+		TRACE("GfaIpcReleasePointer: Invalid Handle!\n");
+		return;
+	}
+
+	LPSHM_HANDLE ph = (LPSHM_HANDLE)hShm;
+
+	if(!ph->pShm)
+	{
+		TRACE("GfaIpcReleasePointer: Invalid Handle!\n");
+		return;
+	}
+
+	ph->pShm->Unlock();
+}
+
+void GfaIpcDumpSHMROT(void)
+{
+	if(!g_shmRot.Created())
+	{
+		if(!g_shmRot.Create())
+		{
+			TRACE("GfaIpcDumpSHMROT: Failed to create ROT!\n");
+			return;
+		}
+	}
+
+	g_shmRot.DumpEntries();
+}

+ 459 - 0
src/sema.cpp

@@ -0,0 +1,459 @@
+#ifdef _WIN32
+#define _CRT_SECURE_NO_WARNINGS
+#define _CRT_NONSTDC_NO_WARNINGS
+#include <windows.h>
+#include <io.h>
+#include "../Win32/w32def.h"
+#endif	//	_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+#ifdef __linux__
+#include <sys/file.h>
+#include <sys/ipc.h>
+#include <sys/sem.h>
+#include <sys/shm.h>
+#include <linux/limits.h>
+#endif	//	__linux__
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include "defines.h"
+#include "sema.h"
+
+/////////////////////////////////////////////////////////////////////////////
+
+#define _IS_VALID_SEMID(id)				((id) >= 0)
+
+/////////////////////////////////////////////////////////////////////////////
+
+CSemaphore::CSemaphore(void) :	m_nSemID(_INVALID_ID)
+{
+}
+
+CSemaphore::~CSemaphore(void)
+{
+	Release();
+}
+
+/////////////////////////////////////////////////////////////////////////////
+
+int CSemaphore::Create(const char *pszFilename, int nsems, unsigned short *pInitArr)
+{
+	int nFdSema, nRet = -1;
+
+	if((nFdSema = ::open(pszFilename, O_RDWR | O_CREAT | O_TRUNC, _NUMBER_OF_THE_BEAST)) >= 0)
+	{
+		if(!::flock(nFdSema, LOCK_EX))
+		{
+			key_t semKey;
+
+			if((semKey = ::ftok(pszFilename, 'R')) >= 0)
+			{
+				if((m_nSemID = ::semget(semKey, nsems, IPC_CREAT | _NUMBER_OF_THE_BEAST)) >= 0)
+				{
+					struct semid_ds sds;
+					::memset(&sds, 0, sizeof(sds));
+
+					if(!IpcStat(&sds))
+					{
+						if(!sds.sem_otime)
+						{
+							bool fCreateArr = !pInitArr;
+
+							if(fCreateArr)
+							{
+								pInitArr = new unsigned short[sds.sem_nsems];
+
+								for(unsigned long i = 0; i < sds.sem_nsems; i++)
+								{
+									pInitArr[i] = 0;
+								}
+							}
+
+							SetAll(pInitArr);
+
+							if(fCreateArr)
+								delete [] pInitArr;
+
+							struct sembuf sb[2] = {{0, 1, IPC_NOWAIT}, {0, -1, IPC_NOWAIT}};
+							Op(sb, 2);
+
+							TRACE("CSemaphore::Create: Created new Semaphore!\n");
+							nRet = 1;
+						}
+						else
+						{
+							TRACE("CSemaphore::Create: Opened existing Semaphore!\n");
+							nRet = 0;
+						}
+					}
+					else
+					{
+						TRACE("CSemaphore::Create: IpcStat failed - errno: %d!\n", errno);
+					}
+				}
+				else
+				{
+					TRACE("CSemaphore::Create: Failed to create Semaphore - errno: %d!\n", errno);
+				}
+			}
+			else
+			{
+				TRACE("CSemaphore::Create: Failed to create semKey - errno: %d!\n", errno);
+			}
+
+			::flock(nFdSema, LOCK_UN);
+		}
+		else
+		{
+			TRACE("CSemaphore::Create: Failed to create Lock on '%s' - errno: %d!\n", pszFilename, errno);
+		}
+
+		::close(nFdSema);
+	}
+	else
+	{
+		TRACE("CSemaphore::Create: Failed to create '%s' - errno: %d!\n", pszFilename, errno);
+	}
+
+	return nRet;
+}
+
+void CSemaphore::Release(void)
+{
+	if(_IS_VALID_SEMID(m_nSemID))
+	{
+		m_nSemID = _INVALID_ID;
+		TRACE("CSemaphore::Release\n");
+	}
+}
+
+/////////////////////////////////////////////////////////////////////////////
+
+int CSemaphore::Ctl(int cmd)
+{
+	union semun su;
+	su.val = 0;
+	return Ctl(0, cmd, su);
+}
+
+int CSemaphore::Ctl(int semnum, int cmd)
+{
+	union semun su;
+	su.val = 0;
+	return Ctl(semnum, cmd, su);
+}
+
+int CSemaphore::Ctl(int semnum, int cmd, int val)
+{
+	union semun su;
+	su.val = val;
+	return Ctl(semnum, cmd, su);
+}
+
+int CSemaphore::Ctl(int cmd, struct semid_ds *buf)
+{
+	union semun su;
+	su.buf = buf;
+	return Ctl(0, cmd, su);
+}
+
+int CSemaphore::Ctl(int cmd, unsigned short  *arr)
+{
+	union semun su;
+	su.array = arr;
+	return Ctl(0, cmd, su);
+}
+
+int CSemaphore::Ctl(int cmd, struct seminfo *si)
+{
+	union semun su;
+	su.__buf = si;
+	return Ctl(0, cmd, su);
+}
+
+int CSemaphore::Ctl(int semnum, int cmd, union semun su)
+{
+	if(!_IS_VALID_SEMID(m_nSemID))
+	{
+//		TRACE("CSemaphore::Ctl: Invalid SemID: %d!\n", m_nSemID);
+		errno = EINVAL;
+		return -1;
+	}
+
+	return ::semctl(m_nSemID, semnum, cmd, su);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+
+int CSemaphore::IpcStat(struct semid_ds *buf)
+{
+	return Ctl(IPC_STAT, buf);
+}
+
+int CSemaphore::IpcSet(struct semid_ds *buf)
+{
+	return Ctl(IPC_SET, buf);
+}
+
+int CSemaphore::IpcRmID(void)
+{
+	int nRet = Ctl(IPC_RMID);
+	Release();
+	return nRet;
+}
+
+int CSemaphore::IpcInfo(struct seminfo *si)
+{
+	return Ctl(IPC_INFO, si);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+
+int CSemaphore::SemStat(int index, struct semid_ds *buf)
+{
+	union semun su;
+	su.buf = buf;
+	return ::semctl(index, 0, SEM_STAT, su);
+}
+
+int CSemaphore::SemInfo(struct seminfo *si)
+{
+	return Ctl(SEM_INFO, si);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+
+int CSemaphore::GetVal(int semnum)
+{
+	return Ctl(semnum, GETVAL);
+}
+
+int CSemaphore::SetVal(int semnum, int val)
+{
+	return Ctl(semnum, SETVAL, val);
+}
+
+int CSemaphore::GetAll(unsigned short *arr)
+{
+	return Ctl(GETALL, arr);
+}
+
+int CSemaphore::SetAll(unsigned short *arr)
+{
+	return Ctl(SETALL, arr);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+
+int CSemaphore::GetPid(int semnum)
+{
+	return Ctl(semnum, GETPID);
+}
+
+int CSemaphore::GetNCnt(int semnum)
+{
+	return Ctl(semnum, GETNCNT);
+}
+
+int CSemaphore::GetZCnt(int semnum)
+{
+	return Ctl(semnum, GETZCNT);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+bool CSemaphore::Op(struct sembuf *sops, size_t nsops)
+{
+	if(!_IS_VALID_SEMID(m_nSemID))
+	{
+//		TRACE("CSemaphore::Op: Invalid SemID: %d!\n", m_nSemID);
+		errno = EINVAL;
+		return false;
+	}
+
+	return !::semop(m_nSemID, sops, nsops);
+}
+
+bool CSemaphore::TimedOp(struct sembuf *sops, size_t nsops, const struct timespec *timeout)
+{
+	if(!_IS_VALID_SEMID(m_nSemID))
+	{
+		TRACE("CSemaphore::TimedOp: Invalid SemID: %d!\n", m_nSemID);
+		errno = EINVAL;
+		return false;
+	}
+
+	return !::semtimedop(m_nSemID, sops, nsops, timeout);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+
+bool CSemaphore::Lock(int semnum)
+{
+	struct sembuf sb;
+	sb.sem_num	= (unsigned short)semnum;
+	sb.sem_op	= -1;
+	sb.sem_flg	= SEM_UNDO;
+	return Op(&sb, 1);
+}
+
+bool CSemaphore::LockTimeout(const struct timespec *timeout, int semnum)
+{
+	struct sembuf sb;
+	sb.sem_num	= (unsigned short)semnum;
+	sb.sem_op	= -1;
+	sb.sem_flg	= SEM_UNDO;
+	return TimedOp(&sb, 1, timeout);
+}
+
+bool CSemaphore::LockTimeout(unsigned long msec, int semnum)
+{
+	struct timespec to;
+	to.tv_sec	= msec / 1000;
+	to.tv_nsec	= (msec % 1000) * 1000000;
+	return LockTimeout(&to, semnum);
+}
+
+bool CSemaphore::Unlock(int semnum)
+{
+	struct sembuf sb;
+	sb.sem_num	= (unsigned short)semnum;
+	sb.sem_op	= 1;
+	sb.sem_flg	= SEM_UNDO;
+	return Op(&sb, 1);
+}
+
+bool CSemaphore::WaitZero(int semnum)
+{
+	struct sembuf sb;
+	sb.sem_num	= (unsigned short)semnum;
+	sb.sem_op	= 0;
+	sb.sem_flg	= SEM_UNDO;
+	return Op(&sb, 1);
+}
+
+bool CSemaphore::WaitZeroTimeout(const struct timespec *timeout, int semnum)
+{
+	struct sembuf sb;
+	sb.sem_num	= (unsigned short)semnum;
+	sb.sem_op	= 0;
+	sb.sem_flg	= SEM_UNDO;
+	return TimedOp(&sb, 1, timeout);
+}
+
+bool CSemaphore::WaitZeroTimeout(unsigned long msec, int semnum)
+{
+	struct timespec to;
+	to.tv_sec	= msec / 1000;
+	to.tv_nsec	= (msec % 1000) * 1000000;
+	return WaitZeroTimeout(&to, semnum);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+
+void CSemaphore::DumpIpcPerm(struct ipc_perm *ip)
+{
+	printf("__key: 0x%X\n", ip->__key);
+	printf("uid:   %d\n", ip->uid);
+	printf("gid:   %d\n", ip->gid);
+	printf("cuid:  %d\n", ip->cuid);
+	printf("cgid:  %d\n", ip->cgid);
+	printf("mode:  %hu\n", ip->mode);
+	printf("__seq: %hu\n", ip->__seq);
+}
+
+void CSemaphore::DumpSemidDs(struct semid_ds *sid)
+{
+	CSemaphore::DumpIpcPerm(&sid->sem_perm);
+	printf("sem_otime: %lu\n", sid->sem_otime);
+	printf("sem_ctime: %lu\n", sid->sem_ctime);
+	printf("sem_nsems: %lu\n", sid->sem_nsems);
+}
+
+void CSemaphore::DumpSeminfo(struct seminfo *psi)
+{
+	printf("semmap: %d\n", psi->semmap);
+	printf("semmni: %d\n", psi->semmni);
+	printf("semmns: %d\n", psi->semmns);
+	printf("semmnu: %d\n", psi->semmnu);
+	printf("semmsl: %d\n", psi->semmsl);
+	printf("semopm: %d\n", psi->semopm);
+	printf("semume: %d\n", psi->semume);
+	printf("semusz: %d\n", psi->semusz);
+	printf("semvmx: %d\n", psi->semvmx);
+	printf("semaem: %d\n\n", psi->semaem);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+CShmSemaphore::CShmSemaphore(void)
+{
+}
+
+CShmSemaphore::~CShmSemaphore(void)
+{
+	Release();
+}
+
+int CShmSemaphore::Create(const char *pszFilename)
+{
+	int nRet;
+	unsigned short nVals[2] = {1, 0};
+	if((nRet = CSemaphore::Create(pszFilename, 2, nVals)) < 0)
+		return nRet;
+	Unlock(1);
+	TRACE("CShmSemaphore::Create\n");
+	return nRet;
+}
+
+int CShmSemaphore::Create(const uuid_t &ruuid, const char *pszDir)
+{
+	if(!pszDir)
+		pszDir = "";
+
+	size_t nLenReq = strlen(pszDir) + _UUID_STRING_LEN + 2;
+
+	if(nLenReq > PATH_MAX)
+	{
+		TRACE("CShmSemaphore::Create: directory name too long\n");
+		errno = EINVAL;
+		return -1;
+	}
+
+	char szUuid[_UUID_STRING_LEN + 1];
+	char szSema[PATH_MAX];
+	_uuid_unparse(&ruuid, szUuid, sizeof(szUuid));
+	sprintf(szSema, "%s/%s.sem", pszDir, szUuid);
+	return Create(szSema);
+}
+
+void CShmSemaphore::Release(void)
+{
+	if(_IS_VALID_SEMID(m_nSemID))
+	{
+		int nRefs = GetVal(1);
+
+		if(nRefs > 1)
+		{
+			TRACE("CShmSemaphore::Release: remaining References: %d\n", nRefs - 1);
+			Lock(1);
+		}
+		else if(nRefs == 1)
+		{
+			TRACE("CShmSemaphore::Release: remaining References: %d - Semaphore removed!\n", nRefs - 1);
+			IpcRmID();
+		}
+
+		CSemaphore::Release();
+	}
+}

+ 111 - 0
src/sema.h

@@ -0,0 +1,111 @@
+// sema.h :
+//
+
+#if !defined(AGD_SEMA_H__EA777512_58F6_495A_A36F_1272222A4749__INCLUDED_)
+#define AGD_SEMA_H__EA777512_58F6_495A_A36F_1272222A4749__INCLUDED_
+
+#include <inttypes.h>
+#include <stdlib.h>
+#include "uuid.h"
+
+/////////////////////////////////////////////////////////////////////////////
+// sema.h - Declarations:
+
+#ifdef __cplusplus
+extern "C" {
+#endif	//	__cplusplus
+
+union semun
+{
+	int              val;    // Value for SETVAL
+	struct semid_ds *buf;    // Buffer for IPC_STAT, IPC_SET
+	unsigned short  *array;  // Array for GETALL, SETALL
+	struct seminfo  *__buf;  // Buffer for IPC_INFO	(Linux-specific)
+};
+
+#ifdef __cplusplus
+}
+#endif	//	__cplusplus
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+class CSemaphore
+{
+public:
+	CSemaphore(void);
+	virtual ~CSemaphore(void);
+
+	virtual int Create(const char *pszFilename, int nsems, unsigned short *pInitArr = NULL);
+	virtual void Release(void);
+
+	int Ctl(int cmd);
+	int Ctl(int semnum, int cmd);
+	int Ctl(int semnum, int cmd, int val);
+	int Ctl(int cmd, struct semid_ds *buf);
+	int Ctl(int cmd, unsigned short *arr);
+	int Ctl(int cmd, struct seminfo *si);
+
+	int IpcStat(struct semid_ds *buf);
+	int IpcInfo(struct seminfo *si);
+	int IpcSet(struct semid_ds *buf);
+	int IpcRmID(void);
+	int SemStat(int index, struct semid_ds *buf);
+	int SemInfo(struct seminfo *si);
+	int GetVal(int semnum = 0);
+	int SetVal(int semnum, int val);
+	int GetAll(unsigned short *arr);
+	int SetAll(unsigned short *arr);
+	int GetPid(int semnum = 0);
+	int GetNCnt(int semnum = 0);
+	int GetZCnt(int semnum = 0);
+
+	bool Op(struct sembuf *sops, size_t nsops);
+	bool TimedOp(struct sembuf *sops, size_t nsops, const struct timespec *timeout);
+
+	bool Lock(int semnum = 0);
+	bool LockTimeout(const struct timespec *timeout, int semnum = 0);
+	bool LockTimeout(unsigned long msec, int semnum = 0);
+	bool Unlock(int semnum = 0);
+	bool WaitZero(int semnum = 0);
+	bool WaitZeroTimeout(const struct timespec *timeout, int semnum = 0);
+	bool WaitZeroTimeout(unsigned long msec, int semnum = 0);
+
+	static void DumpIpcPerm(struct ipc_perm *ip);
+	static void DumpSemidDs(struct semid_ds *sid);
+	static void DumpSeminfo(struct seminfo *psi);
+
+protected:
+	int Ctl(int semnum, int cmd, union semun su);
+
+protected:
+	int m_nSemID;
+};
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef _WIN32
+#define _DEF_SEMA_DIR						"."
+#endif	//	_WIN32
+
+#ifdef __linux__
+#define _DEF_SEMA_DIR						"/tmp"
+#endif	//	__linux__
+
+/////////////////////////////////////////////////////////////////////////////
+
+class CShmSemaphore : public CSemaphore
+{
+public:
+	CShmSemaphore(void);
+	virtual ~CShmSemaphore(void);
+
+	virtual int Create(const char *pszFilename);
+	virtual int Create(const uuid_t &ruuid, const char *pszDir = _DEF_SEMA_DIR);
+	virtual void Release(void);
+};
+
+/////////////////////////////////////////////////////////////////////////////
+#endif	//	!defined(AGD_SEMA_H__EA777512_58F6_495A_A36F_1272222A4749__INCLUDED_)

+ 317 - 0
src/shm.cpp

@@ -0,0 +1,317 @@
+#ifdef _WIN32
+#define _CRT_SECURE_NO_WARNINGS
+#define _CRT_NONSTDC_NO_WARNINGS
+#include <windows.h>
+#include <io.h>
+#include "../Win32/w32def.h"
+#endif	//	_WIN32
+
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+#ifdef __linux__
+#include <sys/file.h>
+#include <sys/ipc.h>
+#include <sys/sem.h>
+#include <linux/limits.h>
+#include <sys/shm.h>
+#endif	//	__linux__
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include "defines.h"
+#include "shm.h"
+
+/////////////////////////////////////////////////////////////////////////////
+
+#define _IS_VALID_SHMID(id)				((id) >= 0)
+
+/////////////////////////////////////////////////////////////////////////////
+
+class CShmLocker
+{
+public:
+	CShmLocker(CShmSemaphore &rsema) :	m_bLocked(false),
+										m_rsema(rsema)
+	{
+		m_bLocked = m_rsema.Lock();
+	}
+
+	~CShmLocker(void)
+	{
+		Unlock();
+	}
+
+	void Unlock(void)
+	{
+		if(m_bLocked)
+			m_bLocked = !m_rsema.Unlock();
+	}
+
+	void UnlockRelease(void)
+	{
+		if(m_bLocked)
+		{
+			if(m_rsema.Unlock())
+				m_rsema.Release();
+			m_bLocked = false;
+		}
+	}
+
+private:
+	bool m_bLocked;
+	CShmSemaphore &m_rsema;
+};
+
+/////////////////////////////////////////////////////////////////////////////
+
+CShm::CShm(void) :	m_nShmID(_INVALID_ID)
+{
+	memset(&m_uuid, 0, sizeof(m_uuid));
+}
+
+CShm::~CShm(void)
+{
+	Release();
+}
+
+int CShm::Create(const uuid_t &ruuid, size_t nCbShm, const char *pszDir)
+{
+	if(!pszDir)
+		pszDir = "";
+
+	size_t nLenReq = strlen(pszDir) + _UUID_STRING_LEN + 2;
+
+	if(nLenReq > PATH_MAX)
+	{
+		TRACE("CShm::Create: directory name too long\n");
+		errno = EINVAL;
+		return -1;
+	}
+
+	int nRet = -1;
+	char szUuid[_UUID_STRING_LEN + 1];
+	char szShm[PATH_MAX];
+	_uuid_unparse(&ruuid, szUuid, sizeof(szUuid));
+	sprintf(szShm, "%s/%s.shm", pszDir, szUuid);
+
+	if(m_sema.Create(ruuid, pszDir) < 0)
+		return -1;
+
+	int nFdShm;
+	CShmLocker locker(m_sema);
+
+	if((nFdShm = ::open(szShm, O_RDWR | O_CREAT | O_TRUNC, _NUMBER_OF_THE_BEAST)) >= 0)
+	{
+		key_t shmKey;
+
+		if((shmKey = ::ftok(szShm, 'R')) >= 0)
+		{
+			if((m_nShmID = ::shmget(shmKey, nCbShm, IPC_CREAT | _NUMBER_OF_THE_BEAST)) >= 0)
+			{
+				struct shmid_ds sds;
+				memset(&sds, 0, sizeof(sds));
+
+				if(!IpcStat(&sds))
+				{
+					if(!sds.shm_atime)
+					{
+						void *p = ::shmat(m_nShmID, NULL, 0);
+						::shmdt(p);
+						TRACE("CShm::Create: Created new SHM: ID: %d, Size: %zu\n", m_nShmID, nCbShm);
+						nRet = 1;
+					}
+					else
+					{
+						TRACE("CShm::Create: Opened existing SHM: ID: %d, Size: %zu\n", m_nShmID, nCbShm);
+						nRet = 0;
+					}
+
+					_uuid_copy(&m_uuid, &ruuid);
+				}
+				else
+				{
+					TRACE("CShm::Create: IpcStat failed - errno: %d!\n", errno);
+				}
+			}
+			else
+			{
+				TRACE("CShm::Create: Failed to create SHM on Key: 0x%08X - errno: %d!\n", shmKey, errno);
+			}
+		}
+		else
+		{
+			TRACE("CShm::Create: Failed to create shmKey - errno: %d!\n", errno);
+		}
+
+		close(nFdShm);
+	}
+	else
+	{
+		TRACE("CShm::Create: Failed to open '%s' - errno: %d!\n", szShm, errno);
+	}
+
+	return nRet;
+}
+
+long CShm::Release(void)
+{
+	long att = -1;
+	CShmLocker locker(m_sema);
+
+	if(_IS_VALID_SHMID(m_nShmID))
+	{
+		att = GetNumAttached();
+
+		if(att == 0)
+		{
+			TRACE("CShm::Release: attached: %ld - SHM removed!\n", att);
+			IpcRmID();
+		}
+		else if(att > 0)
+		{
+			TRACE("CShm::Release: Still attached: %ld!\n", att);
+		}
+
+		m_nShmID = _INVALID_ID;
+	}
+
+	locker.UnlockRelease();
+	return att;
+}
+
+void* CShm::Attach(const void *pAddr, int shmflg)
+{
+	CShmLocker locker(m_sema);
+
+	if(!_IS_VALID_SHMID(m_nShmID))
+	{
+		TRACE("CShm::Attach: Invalid ShmID: %d!\n", m_nShmID);
+		errno = EINVAL;
+		return NULL;
+	}
+
+	void *p = ::shmat(m_nShmID, pAddr, shmflg);
+
+	if(p == (void*)-1)
+	{
+		TRACE("CShm::Attach: Failed to attach memory - errno: %d!\n", errno);
+		p = NULL;
+	}
+	else
+	{
+		TRACE("CShm::Attach: %p!\n", p);
+	}
+
+	return p;
+}
+
+void CShm::Detach(const void *pAddr)
+{
+	if(pAddr)
+	{
+		TRACE("CShm::Detach: %p!\n", pAddr);
+		CShmLocker locker(m_sema);
+		::shmdt(pAddr);
+	}
+}
+
+long CShm::GetNumAttached(void)
+{
+	long att = -1;
+	struct shmid_ds sds;
+	if(!IpcStat(&sds))
+		att = (long)sds.shm_nattch;
+	return att;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+
+int CShm::Ctl(int cmd, struct shmid_ds *pshd)
+{
+	if(!_IS_VALID_SHMID(m_nShmID))
+	{
+		TRACE("CShm::Ctl: Invalid ShmID: %d!\n", m_nShmID);
+		errno = EINVAL;
+		return -1;
+	}
+
+	return ::shmctl(m_nShmID, cmd, pshd);
+}
+
+int CShm::Ctl(int cmd)
+{
+	return Ctl(cmd, (struct shmid_ds*)NULL);
+}
+
+int CShm::Ctl(int cmd, struct shminfo *pinfo)
+{
+	return Ctl(cmd, (struct shmid_ds*)pinfo);
+}
+
+int CShm::Ctl(int cmd, struct shm_info *pinfo)
+{
+	return Ctl(cmd, (struct shmid_ds*)pinfo);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+
+int CShm::IpcStat(struct shmid_ds *buf)
+{
+	return Ctl(IPC_STAT, buf);
+}
+
+int CShm::IpcInfo(struct shminfo *si)
+{
+	return Ctl(IPC_INFO, si);
+}
+
+int CShm::IpcSet(struct shmid_ds *buf)
+{
+	return Ctl(IPC_SET, buf);
+}
+
+int CShm::IpcRmID(void)
+{
+	return Ctl(IPC_RMID);
+}
+
+int CShm::ShmStat(int index, struct shmid_ds *buf)
+{
+	return ::shmctl(index, SHM_STAT, buf);
+}
+
+int CShm::ShmInfo(struct shm_info *pinfo)
+{
+	return Ctl(SHM_INFO, pinfo);
+}
+
+int CShm::Lock(void)
+{
+	return m_sema.Lock();
+}
+
+int CShm::Unlock(void)
+{
+	return m_sema.Unlock();
+}
+
+/////////////////////////////////////////////////////////////////////////////
+
+void CShm::DumpIpcPerm(struct ipc_perm *ip)
+{
+	CSemaphore::DumpIpcPerm(ip);
+}
+
+void CShm::DumpShmidDs(struct shmid_ds *sid)
+{
+	CShm::DumpIpcPerm(&sid->shm_perm);
+	printf("shm_segsz:  %zu\n", sid->shm_segsz);
+	printf("shm_atime:  %lu\n", sid->shm_atime);
+	printf("shm_dtime:  %lu\n", sid->shm_dtime);
+	printf("shm_ctime:  %lu\n", sid->shm_ctime);
+	printf("shm_cpid:  %hd\n", sid->shm_cpid);
+	printf("shm_lpid:   %hd\n", sid->shm_lpid);
+	printf("shm_nattch: %lu\n", sid->shm_nattch);
+}

+ 66 - 0
src/shm.h

@@ -0,0 +1,66 @@
+// shm.h :
+//
+
+#if !defined(AGD_SHM_H__AD9FF941_0114_4585_8EF1_0A4ACA7DC0AD__INCLUDED_)
+#define AGD_SHM_H__AD9FF941_0114_4585_8EF1_0A4ACA7DC0AD__INCLUDED_
+
+#include "sema.h"
+
+/////////////////////////////////////////////////////////////////////////////
+// shm.h - Declarations:
+
+#ifdef _WIN32
+#define _DEF_SHM_DIR						"."
+#endif	//	_WIN32
+
+#ifdef __linux__
+#define _DEF_SHM_DIR						"/tmp"
+#endif	//	__linux__
+
+/////////////////////////////////////////////////////////////////////////////
+
+class CShm
+{
+public:
+	CShm(void);
+	virtual ~CShm(void);
+
+	int Create(const uuid_t &ruuid, size_t nCbShm, const char *pszDir = _DEF_SHM_DIR);
+	long Release(void);
+
+	void* Attach(const void *pAddr = NULL, int shmflg = 0);
+	void Detach(const void *pAddr);
+	long GetNumAttached(void);
+
+	int Ctl(int cmd);
+	int Ctl(int cmd, struct shmid_ds *pshd);
+	int Ctl(int cmd, struct shminfo *pinfo);
+	int Ctl(int cmd, struct shm_info *pinfo);
+
+	int IpcStat(struct shmid_ds *buf);
+	int IpcInfo(struct shminfo *si);
+	int IpcSet(struct shmid_ds *buf);
+	int IpcRmID(void);
+
+	int ShmStat(int index, struct shmid_ds *buf);
+	int ShmInfo(struct shm_info *pinfo);
+
+	int Lock(void);
+	int Unlock(void);
+
+	const uuid_t& Uuid() const {
+		return m_uuid;}
+
+	static void DumpIpcPerm(struct ipc_perm *ip);
+	static void DumpShmidDs(struct shmid_ds *sid);
+
+private:
+
+private:
+	int m_nShmID;
+	CShmSemaphore m_sema;
+	uuid_t m_uuid;
+};
+
+/////////////////////////////////////////////////////////////////////////////
+#endif	//	!defined(AGD_SHM_H__AD9FF941_0114_4585_8EF1_0A4ACA7DC0AD__INCLUDED_)

+ 270 - 0
src/shmrot.cpp

@@ -0,0 +1,270 @@
+#ifdef _WIN32
+#define _CRT_SECURE_NO_WARNINGS
+#define _CRT_NONSTDC_NO_WARNINGS
+#include <windows.h>
+#include <io.h>
+#include "../Win32/w32def.h"
+#endif	//	_WIN32
+
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+#ifdef __linux__
+#include <sys/file.h>
+#include <sys/ipc.h>
+#include <sys/sem.h>
+#include <linux/limits.h>
+#include <sys/shm.h>
+#endif	//	__linux__
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include "defines.h"
+#include "shmrot.h"
+
+/////////////////////////////////////////////////////////////////////////////
+
+#define _FILES_DIRECTORY				"/tmp"
+
+/////////////////////////////////////////////////////////////////////////////
+
+#define _SHMROT_ENTRY_FLAG_VALID		0x00000001
+
+/////////////////////////////////////////////////////////////////////////////
+
+// {99df2b86-f904-425d-9fcc-c83c329d0937}
+DEFINE_UUID(GUID_SHMROT, 0x99df2b86, 0xf904, 0x425d, 0x9f, 0xcc, 0xc8, 0x3c, 0x32, 0x9d, 0x09, 0x37);
+
+/////////////////////////////////////////////////////////////////////////////
+
+CShmROT::CShmROT(void)	: m_pTable(NULL)
+{
+}
+
+CShmROT::~CShmROT(void)
+{
+	Release();
+}
+
+bool CShmROT::Create(void)
+{
+	TRACE("CShmROT::Create!\n");
+
+	int nRet = m_shmRot.Create(GUID_SHMROT, sizeof(SHMROT));
+
+	if(	nRet >= 0 &&
+		(m_pTable = (LPSHMROT)m_shmRot.Attach()))
+	{
+		if(nRet == 1)
+		{
+			m_pTable->version		= _ROT_CURRENT_VERSION;
+			m_pTable->maxEntries	= _ROT_MAX_TABLE_ENTRIES;
+			m_pTable->entrySize		= (uint32_t)sizeof(SHMROT_ENTRY);
+
+		}
+		else if(nRet == 0)
+		{
+			if(m_pTable->version != _ROT_CURRENT_VERSION)
+			{
+			}
+		}
+
+		return true;
+	}
+
+	return false;
+}
+
+void CShmROT::Release(void)
+{
+	if(m_pTable)
+	{
+		TRACE("CShmROT::Release!\n");
+		m_shmRot.Detach(m_pTable);
+		m_shmRot.Release();
+		m_pTable = NULL;
+	}
+}
+
+CShm* CShmROT::AcquireShm(const char *pszUuid, size_t nSizeElement, size_t nCntElements, const char *pszDescName)
+{
+	if(!m_pTable)
+	{
+		TRACE("CShmROT::AcquireShm: ROT not initialized!\n");
+		return NULL;
+	}
+
+	uuid_t uuid;
+	CShm *pShm = NULL;
+
+	if(!_uuid_parse(pszUuid, &uuid))
+	{
+		TRACE("CShmROT::AcquireShm: invalid uuid!\n");
+		return NULL;
+	}
+
+	int nIndexFound			= -1;
+	int nFirstUnusedIndex	= -1;
+
+	for(int i = 0; i < (int)m_pTable->maxEntries; i++)
+	{
+		SHMROT_ENTRY &re = m_pTable->rot[i];
+
+		if(re.flags & _SHMROT_ENTRY_FLAG_VALID)
+		{
+			if(!_uuid_compare(&re.uuid, &uuid))
+			{
+				nIndexFound = i;
+				break;
+			}
+		}
+		else if(nFirstUnusedIndex == -1)
+		{
+			nFirstUnusedIndex = i;
+		}
+	}
+
+	if(nIndexFound >= 0)
+	{
+		SHMROT_ENTRY &re = m_pTable->rot[nIndexFound];
+
+		if(	(re.nSizeElement == nSizeElement) &&
+			(re.nCntElements == nCntElements))
+		{
+			TRACE("CShmROT::AcquireShm: Found matching SHM entry!\n");
+
+			if((pShm = new CShm))
+			{
+				if(pShm->Create(uuid, nSizeElement * nCntElements) < 0)
+				{
+					pShm->Release();
+					delete pShm;
+					pShm = NULL;
+					TRACE("CShmROT::AcquireShm: Failed to create new CShm!\n");
+				}
+			}
+			else
+			{
+				TRACE("CShmROT::AcquireShm: Failed to allocate new CShm!\n");
+			}
+		}
+		else
+		{
+			TRACE("CShmROT::AcquireShm: SHM uuid exists, but size does not match!\n");
+		}
+	}
+	else if(nFirstUnusedIndex >= 0)
+	{
+		TRACE("CShmROT::AcquireShm: Create new SHM entry!\n");
+
+		SHMROT_ENTRY &re = m_pTable->rot[nFirstUnusedIndex];
+
+		if((pShm = new CShm))
+		{
+			if(pShm->Create(uuid, nSizeElement * nCntElements) < 0)
+			{
+				pShm->Release();
+				delete pShm;
+				pShm = NULL;
+				TRACE("CShmROT::AcquireShm: Failed to create new CShm!\n");
+			}
+			else
+			{
+				re.flags		= _SHMROT_ENTRY_FLAG_VALID;
+				re.nSizeElement	= (uint32_t)nSizeElement;
+				re.nCntElements	= (uint32_t)nCntElements;
+				_uuid_copy(&re.uuid, &uuid);
+				memset(re.szDescName, 0, sizeof(re.szDescName));
+
+				if(pszDescName)
+				{
+					size_t nLen = strlen(pszDescName);
+
+					if(nLen > 0)
+					{
+						if(nLen >= _ROT_MAX_ENTRY_NAME)
+							nLen = _ROT_MAX_ENTRY_NAME - 1;
+						memcpy(re.szDescName, pszDescName, nLen);
+						re.szDescName[nLen] = '\0';
+					}
+				}
+			}
+		}
+		else
+		{
+			TRACE("CShmROT::AcquireShm: Failed to allocate new CShm!\n");
+		}
+	}
+	else
+	{
+		TRACE("CShmROT::AcquireShm: SHM uuid not found and no free entries!\n");
+	}
+
+	return pShm;
+}
+
+void CShmROT::ReleaseShm(CShm *pShm)
+{
+	if(pShm)
+	{
+		if(pShm->Release() == 0)
+		{
+			const uuid_t &ruuid = pShm->Uuid();
+
+			for(int i = 0; i < (int)m_pTable->maxEntries; i++)
+			{
+				SHMROT_ENTRY &re = m_pTable->rot[i];
+
+				if(!_uuid_compare(&re.uuid, &ruuid))
+				{
+					re.flags &= ~_SHMROT_ENTRY_FLAG_VALID;
+					break;
+				}
+			}
+		}
+
+		delete pShm;
+	}
+}
+
+int CShmROT::Lock(void)
+{
+	return m_shmRot.Lock();
+}
+
+int CShmROT::Unlock(void)
+{
+	return m_shmRot.Unlock();
+}
+
+void CShmROT::DumpEntries(void)
+{
+	if(!m_pTable)
+	{
+		printf("CShmROT::DumpEntries: ROT not initialized!\n");
+		return;
+	}
+
+	char szUuid[_UUID_STRING_LEN + 1];
+
+	Lock();
+
+	for(int i = 0; i < (int)m_pTable->maxEntries; i++)
+	{
+		SHMROT_ENTRY &re = m_pTable->rot[i];
+
+		if(re.flags & _SHMROT_ENTRY_FLAG_VALID)
+		{
+			_uuid_unparse(&re.uuid, szUuid, sizeof(szUuid));
+			printf("uuid: '%s',\n    flags: %08X,\n    size of element: %u,\n    count of elements: %u,\n    name: '%s'\n",
+					szUuid,
+					re.flags,
+					re.nSizeElement,
+					re.nCntElements,
+					re.szDescName);
+		}
+	}
+
+	Unlock();
+}

+ 71 - 0
src/shmrot.h

@@ -0,0 +1,71 @@
+// shmrot.h :
+//
+
+#if !defined(AGD_SHMROT_H__58C9857B_4E4E_4AE1_B093_DFECBB85F652__INCLUDED_)
+#define AGD_SHMROT_H__58C9857B_4E4E_4AE1_B093_DFECBB85F652__INCLUDED_
+
+#include "shm.h"
+
+/////////////////////////////////////////////////////////////////////////////
+// shmrot.h - Declarations:
+
+#define _ROT_MAX_TABLE_ENTRIES			32
+#define _ROT_MAX_ENTRY_NAME				128
+
+#define _ROT_MAKE_VERSION(ma, mi)		(((ma) << 16) | (mi))
+#define _ROT_VERSION_MAJOR(ver)			(((ver) >> 16) & 0x0000FFFF)
+#define _ROT_VERSION_MINOR(ver)			((ver) & 0x0000FFFF)
+#define _ROT_CURRENT_VERSION			_ROT_MAKE_VERSION(1, 0)
+
+/////////////////////////////////////////////////////////////////////////////
+
+typedef struct _SHMROT_ENTRY
+{
+	uuid_t uuid;
+	uint32_t flags;
+	uint32_t nSizeElement;
+	uint32_t nCntElements;
+	uint32_t reserved[5];
+	char szDescName[_ROT_MAX_ENTRY_NAME];
+}SHMROT_ENTRY, *LPSHMROT_ENTRY;
+typedef const SHMROT_ENTRY *LPCSHMROT_ENTRY;
+
+typedef struct _SHMROT
+{
+	uint32_t version;		// major << 16, minor version
+	uint32_t maxEntries;	// sollte _ROT_MAX_TABLE_ENTRIES sein
+	uint32_t entrySize;
+	uint32_t reserved[5];
+	SHMROT_ENTRY rot[_ROT_MAX_TABLE_ENTRIES];
+}SHMROT, *LPSHMROT;
+typedef const SHMROT *LPCSHMROT;
+
+/////////////////////////////////////////////////////////////////////////////
+
+class CShmROT
+{
+public:
+	CShmROT(void);
+	virtual ~CShmROT(void);
+
+	bool Create(void);
+	void Release(void);
+
+	CShm* AcquireShm(const char *pszUuid, size_t nSizeElement, size_t nCntElements, const char *pszDescName);
+	void ReleaseShm(CShm *pShm);
+
+	int Lock(void);
+	int Unlock(void);
+
+	bool Created(void) const {
+		return !!m_pTable;}
+
+	void DumpEntries(void);
+
+private:
+	CShm m_shmRot;
+	LPSHMROT m_pTable;
+};
+
+/////////////////////////////////////////////////////////////////////////////
+#endif	//	!defined(AGD_SHMROT_H__58C9857B_4E4E_4AE1_B093_DFECBB85F652__INCLUDED_)

+ 69 - 0
src/uuid.c

@@ -0,0 +1,69 @@
+#ifdef _WIN32
+#define _CRT_SECURE_NO_WARNINGS
+#include <windows.h>
+#endif	//	_WIN32
+
+#include "uuid.h"
+#include <stdio.h>
+#include <string.h>
+
+DEFINE_UUID(UUID_NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
+
+int _uuid_parse(const char *pszIn, uuid_t *uuid)
+{
+	int i, nRet = 0;
+
+	if(pszIn && uuid && strlen(pszIn) == _UUID_STRING_LEN)
+	{
+		int n[8];
+
+		nRet = sscanf(pszIn,
+				"%08x-%04hx-%04hx-%02x%02x-%02x%02x%02x%02x%02x%02x",
+				&uuid->Data1,
+				&uuid->Data2,
+				&uuid->Data3,
+				&n[0], &n[1],
+				&n[2], &n[3], &n[4], &n[5], &n[6], &n[7]);
+
+		if(nRet == 11)
+		{
+			for(i = 0; i < 8; i++)
+			{
+				uuid->Data4[i] = (unsigned char)n[i];
+			}
+		}
+	}
+
+	return nRet == 11;
+}
+
+int _uuid_unparse(const uuid_t *uuid, char *pszOut, size_t nCChOut)
+{
+	if(!uuid || !pszOut || nCChOut <= _UUID_STRING_LEN)
+		return 0;
+
+	return sprintf(pszOut, "%08x-%04hx-%04hx-%02hx%02hx-%02hx%02hx%02hx%02hx%02hx%02hx",
+				uuid->Data1,
+				uuid->Data2,
+				uuid->Data3,
+				uuid->Data4[0], uuid->Data4[1],
+				uuid->Data4[2], uuid->Data4[3], uuid->Data4[4], uuid->Data4[5], uuid->Data4[6], uuid->Data4[7]);
+}
+
+int _uuid_compare(const uuid_t *uuid1, const uuid_t *uuid2)
+{
+	if(uuid1 && uuid2)
+		return memcmp(uuid1, uuid2, sizeof(uuid_t));
+	return 0;
+}
+
+void _uuid_copy(uuid_t *uuDest, const uuid_t *uuSrc)
+{
+	if(uuDest && uuSrc)
+		memcpy(uuDest, uuSrc, sizeof(uuid_t));
+}
+
+int _uuid_is_null(const uuid_t *uuid)
+{
+	return !_uuid_compare(uuid, &UUID_NULL);
+}

+ 49 - 0
src/uuid.h

@@ -0,0 +1,49 @@
+// uuid.h :
+//
+
+#if !defined(AGD_UUID_H__E2CBFDC3_1EA5_4220_8D44_D0C26219B529__INCLUDED_)
+#define AGD_UUID_H__E2CBFDC3_1EA5_4220_8D44_D0C26219B529__INCLUDED_
+
+#include <inttypes.h>
+#include <stdlib.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif	//	__cplusplus
+
+/////////////////////////////////////////////////////////////////////////////
+// uuid.h - Declarations:
+
+#ifdef __linux__
+typedef struct _UUID
+{
+    uint32_t Data1;
+    uint16_t Data2;
+    uint16_t Data3;
+    uint8_t  Data4[8];
+}UUID;
+#define uuid_t UUID
+#endif	//	__linux__
+
+#define DEFINE_UUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
+											const uuid_t name = {l, w1, w2, {b1, b2, b3, b4, b5, b6, b7, b8}}
+
+#define _UUID_STRING_LEN					36
+
+/////////////////////////////////////////////////////////////////////////////
+
+extern const uuid_t UUID_NULL;
+
+/////////////////////////////////////////////////////////////////////////////
+
+int		_uuid_parse		(const char *pszIn, uuid_t *uuid);
+int		_uuid_unparse	(const uuid_t *uuid, char *pszOut, size_t nCChOut);
+int		_uuid_compare	(const uuid_t *uuid1, const uuid_t *uuid2);
+void	_uuid_copy		(uuid_t *uuDest, const uuid_t *uuSrc);
+int		_uuid_is_null	(const uuid_t *uuid);
+
+/////////////////////////////////////////////////////////////////////////////
+#ifdef __cplusplus
+}
+#endif	//	__cplusplus
+#endif	//	!defined(AGD_UUID_H__E2CBFDC3_1EA5_4220_8D44_D0C26219B529__INCLUDED_)