diff -ur c:\FGCVS\fgcom\iaxclient\lib\audio_openal.c fgcom\iaxclient\lib\audio_openal.c
--- c:\FGCVS\fgcom\iaxclient\lib\audio_openal.c	Mon Jul 11 15:10:42 2011
+++ fgcom\iaxclient\lib\audio_openal.c	Wed Jul 13 17:48:44 2011
@@ -1,3 +1,5 @@
+
+
 #include "iaxclient_lib.h"
 
 #ifdef __APPLE__
diff -ur c:\FGCVS\fgcom\iaxclient\lib\codec_speex.c fgcom\iaxclient\lib\codec_speex.c
--- c:\FGCVS\fgcom\iaxclient\lib\codec_speex.c	Mon Jul 11 15:10:42 2011
+++ fgcom\iaxclient\lib\codec_speex.c	Wed Jul 13 17:45:48 2011
@@ -192,7 +192,7 @@
     if(set->vbr) {
       speex_encoder_ctl(encstate->state, SPEEX_SET_VBR_QUALITY, &set->quality);
     } else {
-      int quality = set->quality;
+      int quality = (int)set->quality;
       speex_encoder_ctl(encstate->state, SPEEX_SET_QUALITY, &quality);
     }
   }
diff -ur c:\FGCVS\fgcom\iaxclient\lib\gsm\inc\config.h fgcom\iaxclient\lib\gsm\inc\config.h
--- c:\FGCVS\fgcom\iaxclient\lib\gsm\inc\config.h	Mon Jul 11 15:10:28 2011
+++ fgcom\iaxclient\lib\gsm\inc\config.h	Tue Jul 26 10:58:03 2011
@@ -9,6 +9,18 @@
 #ifndef	CONFIG_H
 #define	CONFIG_H
 
+//#define FGCOM_DEBUG_ALL
+#undef FGCOM_DEBUG_ALL
+
+#ifdef _MSC_VER
+#pragma warning(disable: 4996 4244 4305 4018)
+#if ( !defined(NDEBUG) || defined(FGCOM_DEBUG_ALL))
+#define ADD_FGCOM_DEBUG
+#define DEBUG_SUPPORT
+#define DEBUG_DEFAULT
+#endif
+#endif
+
 /*efine	SIGHANDLER_T	int 		/* signal handlers are void	*/
 /*efine HAS_SYSV_SIGNAL	1		/* sigs not blocked/reset?	*/
 
diff -ur c:\FGCVS\fgcom\iaxclient\lib\gsm\src\add.c fgcom\iaxclient\lib\gsm\src\add.c
--- c:\FGCVS\fgcom\iaxclient\lib\gsm\src\add.c	Mon Jul 11 15:10:28 2011
+++ fgcom\iaxclient\lib\gsm\src\add.c	Wed Jul 13 17:45:48 2011
@@ -10,6 +10,8 @@
  *  See private.h for the more commonly used macro versions.
  */
 
+#include "config.h"
+
 #include	<stdio.h>
 #include	<assert.h>
 
diff -ur c:\FGCVS\fgcom\iaxclient\lib\gsm\src\decode.c fgcom\iaxclient\lib\gsm\src\decode.c
--- c:\FGCVS\fgcom\iaxclient\lib\gsm\src\decode.c	Mon Jul 11 15:10:28 2011
+++ fgcom\iaxclient\lib\gsm\src\decode.c	Wed Jul 13 17:45:48 2011
@@ -6,6 +6,8 @@
 
 /* $Header$ */
 
+#include "config.h"
+
 #include <stdio.h>
 
 #include	"private.h"
diff -ur c:\FGCVS\fgcom\iaxclient\lib\gsm\src\long_term.c fgcom\iaxclient\lib\gsm\src\long_term.c
--- c:\FGCVS\fgcom\iaxclient\lib\gsm\src\long_term.c	Mon Jul 11 15:10:28 2011
+++ fgcom\iaxclient\lib\gsm\src\long_term.c	Wed Jul 13 17:45:48 2011
@@ -6,6 +6,8 @@
 
 /* $Header$ */
 
+#include "config.h"
+
 #include <stdio.h>
 #include <assert.h>
 
diff -ur c:\FGCVS\fgcom\iaxclient\lib\gsm\src\lpc.c fgcom\iaxclient\lib\gsm\src\lpc.c
--- c:\FGCVS\fgcom\iaxclient\lib\gsm\src\lpc.c	Mon Jul 11 15:10:28 2011
+++ fgcom\iaxclient\lib\gsm\src\lpc.c	Wed Jul 13 17:45:48 2011
@@ -6,6 +6,8 @@
 
 /* $Header$ */
 
+#include "config.h"
+
 #include <stdio.h>
 #include <assert.h>
 
diff -ur c:\FGCVS\fgcom\iaxclient\lib\gsm\src\preprocess.c fgcom\iaxclient\lib\gsm\src\preprocess.c
--- c:\FGCVS\fgcom\iaxclient\lib\gsm\src\preprocess.c	Mon Jul 11 15:10:28 2011
+++ fgcom\iaxclient\lib\gsm\src\preprocess.c	Wed Jul 13 17:45:48 2011
@@ -6,6 +6,8 @@
 
 /* $Header$ */
 
+#include "config.h"
+
 #include	<stdio.h>
 #include	<assert.h>
 
diff -ur c:\FGCVS\fgcom\iaxclient\lib\gsm\src\rpe.c fgcom\iaxclient\lib\gsm\src\rpe.c
--- c:\FGCVS\fgcom\iaxclient\lib\gsm\src\rpe.c	Mon Jul 11 15:10:28 2011
+++ fgcom\iaxclient\lib\gsm\src\rpe.c	Wed Jul 13 17:45:48 2011
@@ -6,6 +6,8 @@
 
 /* $Header$ */
 
+#include "config.h"
+
 #include <stdio.h>
 #include <assert.h>
 
Only in fgcom\iaxclient\lib: iax-org.dsw
diff -ur c:\FGCVS\fgcom\iaxclient\lib\iaxclient_lib.c fgcom\iaxclient\lib\iaxclient_lib.c
--- c:\FGCVS\fgcom\iaxclient\lib\iaxclient_lib.c	Mon Jul 11 15:10:42 2011
+++ fgcom\iaxclient\lib\iaxclient_lib.c	Tue Jul 26 17:27:08 2011
@@ -14,6 +14,9 @@
  * This program is free software, distributed under the terms of
  * the GNU Lesser (Library) General Public License
  */
+
+#include "config.h"
+
 #if defined(WIN32)  ||  defined(_WIN32_WCE)
 #include <stdlib.h>
 #endif
@@ -228,6 +231,9 @@
     }
 }
 
+#ifdef ADD_FGCOM_DEBUG
+static char last_event[1024];
+#endif
 
 void iaxc_usermsg(int type, const char *fmt, ...)
 {
@@ -240,7 +246,12 @@
     va_start(args, fmt);
     vsnprintf(e.ev.text.message, IAXC_EVENT_BUFSIZ, fmt, args);
     va_end(args);
-
+#ifdef ADD_FGCOM_DEBUG
+    if ( strlen(e.ev.text.message) && (strcmp(last_event,e.ev.text.message)) ) {
+        printf("usrmsg: %s\n",e.ev.text.message);
+        strcpy(last_event,e.ev.text.message);
+    }
+#endif
     iaxc_post_event(e);
 }
 
@@ -622,6 +633,9 @@
 THREADFUNCDECL(iaxc_processor)
 {
     THREADFUNCRET(ret);
+#ifdef ADD_FGCOM_DEBUG
+    printf("Started thread iaxc_processor\n");
+#endif
     /* Increase Priority */
     iaxc_prioboostbegin(); 
 
@@ -633,6 +647,9 @@
     }
 
     iaxc_prioboostend(); 
+#ifdef ADD_FGCOM_DEBUG
+    printf("Ended thread iaxc_processor\n");
+#endif
     return ret;
 }
 
@@ -1410,7 +1427,7 @@
 }
 
 #ifndef LIBVER
-#define LIBVER "SVN UNKNOWN"
+#define LIBVER "SVN v260"
 #endif
 
 EXPORT char* iaxc_version(char* ver)
diff -ur c:\FGCVS\fgcom\iaxclient\lib\iaxclient_lib.h fgcom\iaxclient\lib\iaxclient_lib.h
--- c:\FGCVS\fgcom\iaxclient\lib\iaxclient_lib.h	Mon Jul 11 15:10:42 2011
+++ fgcom\iaxclient\lib\iaxclient_lib.h	Wed Jul 13 17:45:48 2011
@@ -15,6 +15,7 @@
  */
 #ifndef _iaxclient_lib_h
 #define _iaxclient_lib_h
+#include "config.h"
 
 #ifdef __cplusplus
 extern "C" {
diff -ur c:\FGCVS\fgcom\iaxclient\lib\libiax2\src\iax.c fgcom\iaxclient\lib\libiax2\src\iax.c
--- c:\FGCVS\fgcom\iaxclient\lib\libiax2\src\iax.c	Mon Jul 11 15:10:30 2011
+++ fgcom\iaxclient\lib\libiax2\src\iax.c	Wed Jul 13 17:45:48 2011
@@ -10,6 +10,8 @@
  * the GNU Lesser (Library) General Public License
  */
 
+#include "config.h"
+
 #if defined(WIN32)  ||  defined(_WIN32_WCE)
 #undef __STRICT_ANSI__ //for strdup with ms
 
diff -ur c:\FGCVS\fgcom\iaxclient\lib\libspeex\bits.c fgcom\iaxclient\lib\libspeex\bits.c
--- c:\FGCVS\fgcom\iaxclient\lib\libspeex\bits.c	Mon Jul 11 15:10:41 2011
+++ fgcom\iaxclient\lib\libspeex\bits.c	Wed Jul 13 19:05:42 2011
@@ -358,3 +358,5 @@
    while (bits->bitPtr<BITS_PER_CHAR-1)
       speex_bits_pack(bits, 1, 1);
 }
+
+// eof -bits.c
Only in c:\FGCVS\fgcom\iaxclient\lib\libspeex\include: .svn
Only in c:\FGCVS\fgcom\iaxclient\lib\libspeex\include\speex: .svn
diff -ur c:\FGCVS\fgcom\iaxclient\lib\libspeex\ltp.c fgcom\iaxclient\lib\libspeex\ltp.c
--- c:\FGCVS\fgcom\iaxclient\lib\libspeex\ltp.c	Mon Jul 11 15:10:41 2011
+++ fgcom\iaxclient\lib\libspeex\ltp.c	Tue Jul 26 17:44:16 2011
@@ -157,7 +157,7 @@
    VARDECL(spx_word32_t *corr);
    VARDECL(spx_word32_t *energy);
    VARDECL(spx_word32_t *score);
-   VARDECL(spx_word16_t *swn2);
+   //VARDECL(spx_word16_t *swn2);
    spx_word16_t *swn;
 
    ALLOC(best_score, N, spx_word32_t);
diff -ur c:\FGCVS\fgcom\iaxclient\lib\sox\resample.c fgcom\iaxclient\lib\sox\resample.c
--- c:\FGCVS\fgcom\iaxclient\lib\sox\resample.c	Mon Jul 11 15:10:40 2011
+++ fgcom\iaxclient\lib\sox\resample.c	Wed Jul 13 17:45:48 2011
@@ -52,6 +52,9 @@
 
 /* Modified to compile outside of SoX by Steve Kann <stevek@stevek.com>
  * 14Apr2003 */
+
+#include "config.h"
+
 #define _USE_MATH_DEFINES
 #include <math.h>
 #include <stdlib.h>
diff -ur c:\FGCVS\fgcom\iaxclient\lib\spandsp\plc.c fgcom\iaxclient\lib\spandsp\plc.c
--- c:\FGCVS\fgcom\iaxclient\lib\spandsp\plc.c	Mon Jul 11 15:10:27 2011
+++ fgcom\iaxclient\lib\spandsp\plc.c	Wed Jul 13 17:45:48 2011
@@ -28,6 +28,7 @@
  */
 
 /*! \file */
+#include "config.h"
 
 #include <stdio.h>
 #include <stdlib.h>
diff -ur c:\FGCVS\fgcom\src\fgcom.cpp fgcom\src\fgcom.cpp
--- c:\FGCVS\fgcom\src\fgcom.cpp	Mon Jul 11 15:10:50 2011
+++ fgcom\src\fgcom.cpp	Tue Jul 26 18:46:16 2011
@@ -26,6 +26,7 @@
  *
  */
 
+#include "config.h"
 #include <iostream>
 #include <plib/netSocket.h>
 #include "fgcom.h"
@@ -92,7 +93,7 @@
 struct fgdata data;
 char icao[5];
 double special_frq[] =
-  { 999.999, 910.0, 123.45, 122.75, 123.5, 121.5, 732.34 - 1.0 };
+  { 999.999, 910.0, 123.45, 122.75, 123.5, 121.5, 732.34, - 1.0 };
 double *special_frequencies;
 
 double previous_com_frequency = 0.0;
@@ -223,7 +224,7 @@
 {
   int numbytes;
   static char buf[MAXBUFLEN];
-  int c;
+ // int c;
   int ret = 0;
 
 	prog = strdup( argv[0] );
@@ -571,9 +572,53 @@
   exit (1);
 }
 
+#ifdef FGCOM_DEBUG_ALL
+typedef struct tagECB {
+    int type;
+    char * desc;
+}ECB, *PECB;
+static int last_event_type = -1;
+static int same_event_count = 0;
+static char * previous_event = 0;
+
+ECB ecb[] = {
+    {IAXC_EVENT_LEVELS, "IAXC_EVENT_LEVELS"},
+    {IAXC_EVENT_TEXT, "IAXC_EVENT_TEXT"},
+    {IAXC_EVENT_STATE,"IAXC_EVENT_STATE"},
+    {IAXC_EVENT_NETSTAT,"IAXC_EVENT_NETSTAT"},
+    {IAXC_EVENT_REGISTRATION,"IAXC_EVENT_REGISTRATION"},
+    {0,0}
+};
+
+void show_event(iaxc_event e)
+{
+    PECB pecb = &ecb[0];
+    while (pecb->desc) {
+        if (e.type == pecb->type) {
+            if (last_event_type == e.type) {
+                same_event_count++;
+            } else {
+                if (same_event_count && previous_event) 
+                    printf("iaxc event: %s for %d\n", previous_event, same_event_count);
+                printf("iaxc event: %s\n", pecb->desc);
+                previous_event = pecb->desc;
+                same_event_count = 0;
+                last_event_type = e.type;
+            }
+            return;
+        }
+        pecb++;
+    }
+    printf("iaxc event: UNKNOWN (%d)\n", e.type);
+}
+#endif // #ifdef FGCOM_DEBUG_ALL
+
 int
 iaxc_callback (iaxc_event e)
 {
+#ifdef FGCOM_DEBUG_ALL
+    show_event(e);
+#endif // #ifdef FGCOM_DEBUG_ALL
   switch (e.type)
     {
     case IAXC_EVENT_LEVELS:
@@ -916,11 +961,11 @@
 	{
 		l_allocated += ALLOC_CHUNK_SIZE;
 
-		if(SUCCESS(parser_init(file)))
+		if(FGC_SUCCESS(parser_init(file)))
 		{
 			l_count = 0;
 
-			while(SUCCESS(parser_get_next_value(&l_value)))
+			while(FGC_SUCCESS(parser_get_next_value(&l_value)))
 			{
 				if(l_count >= l_allocated)
 				{
@@ -935,9 +980,16 @@
 			}
 
 			/* Last value of the array must be -1.0 which is the terminator. */
-			if(l_count == l_allocated)
+            if(l_count == l_allocated)
 				l_pfrq = (double *)realloc(l_pfrq, (l_count + 1) * sizeof(double));
 			l_pfrq[l_count] = -1.0;
+#ifdef DEBUG
+            printf("Read in %d frequencies... ", l_count);
+            for (int f_cnt = 0; f_cnt < l_count; f_cnt++)
+                printf("%3.3f ", l_pfrq[f_cnt]);
+            printf("\n");
+#endif
+
 		}
 	}
 
@@ -952,6 +1004,7 @@
 {
   FILE *fp;
   int ret;
+  int count = 0;
   struct airport airport_tmp;
   struct airport *first = NULL;
   struct airport *my_airport = NULL;
@@ -971,6 +1024,7 @@
 			&airport_tmp.lat, &airport_tmp.lon,
 			airport_tmp.type, airport_tmp.text)) == 6)
     {
+        count++;
       if ((my_airport =
 	   (struct airport *) malloc (sizeof (struct airport))) == NULL)
 	{
@@ -997,7 +1051,7 @@
       quit (0);
     }
 
-  printf ("done.\n");
+  printf ("done %d airpots.\n",count);
   return (first);
 }
 
diff -ur c:\FGCVS\fgcom\src\fgcom.h fgcom\src\fgcom.h
--- c:\FGCVS\fgcom\src\fgcom.h	Mon Jul 11 15:10:50 2011
+++ fgcom\src\fgcom.h	Tue Jul 26 17:49:19 2011
@@ -17,13 +17,15 @@
 #define HAVE_IAX12		/* Only for newer iaxclient libraries */
 #endif
 
-#define VERSION "1.2.3"
+#define VERSION "1.2.4" // WIN32 port completed
+// #define VERSION "1.2.3" - original svn 260 downloaded
 #define DEFAULT_USER "guest"
 #define DEFAULT_PASSWORD "guest"
 #define DEFAULT_FG_SERVER "localhost"
 #define DEFAULT_FG_PORT 16661
 #define DEFAULT_CODE 1
-#define DEFAULT_VOIP_SERVER "mpserver13.flightgear.org"
+//#define DEFAULT_VOIP_SERVER "mpserver13.flightgear.org"
+#define DEFAULT_VOIP_SERVER "fgcom.flightgear.org.uk"
 #define DEFAULT_CODEC 'u'
 #define DEFAULT_IAX_CODEC IAXC_FORMAT_ULAW
 #define DEFAULT_IAX_AUDIO AUDIO_INTERNAL
@@ -37,8 +39,8 @@
 #define MAX_COM 4;
 #define DEFAULT_ALARM_TIMER 15
 
-#define SUCCESS(__x__)		(__x__ == 0)
-#define FAILED(__x__)		(__x__ < 0)
+#define FGC_SUCCESS(__x__)		(__x__ == 0)
+#define FGC_FAILED(__x__)		(__x__ < 0)
 
 
 struct airport
diff -ur c:\FGCVS\fgcom\src\fgcom_init.cpp fgcom\src\fgcom_init.cpp
--- c:\FGCVS\fgcom\src\fgcom_init.cpp	Mon Jul 11 15:10:50 2011
+++ fgcom\src\fgcom_init.cpp	Tue Jul 26 17:40:36 2011
@@ -8,6 +8,7 @@
 // Huge part rewritten by Tobias Ramforth to fit needs of FGCOM.
 // <tobias@ramforth.com>
 //
+// Removed SimGear dependency
 //
 // This program is free software; you can redistribute it and/or
 // modify it under the terms of the GNU General Public License as
@@ -52,33 +53,23 @@
 #  define _G_NO_EXTERN_TEMPLATES
 #endif
 
-#include <simgear/compiler.h>
-
 #include <string>
-
-#include <simgear/constants.h>
-#include <simgear/debug/logstream.hxx>
-#include <simgear/structure/exception.hxx>
-#include <simgear/structure/event_mgr.hxx>
-#include <simgear/math/sg_geodesy.hxx>
-#include <simgear/math/interpolater.hxx>
-#include <simgear/misc/sg_path.hxx>
-#include <simgear/misc/sgstream.hxx>
-#include <simgear/timing/sg_time.hxx>
-#include <simgear/timing/lowleveltime.h>
+#include <map>
 
 #include <iomanip>
 #include <errno.h>
 #include <stdarg.h>
 #include <sys/types.h>
+#ifndef _MSC_VER
 #include <pwd.h>
+#endif
 
 #include "fgcom_init.h"
 #include "getopt.h"
 #include "fgcom.h"
 
-using
-  std::string;
+using namespace std;
+using std::string;
 
 #define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x)))
 
@@ -292,10 +283,21 @@
 
   if (homedir == NULL)
     {
+#ifdef _MSC_VER
+        char * hdrive = getenv("HOMEDRIVE");
+        char * hpath = getenv("HOMEPATH");
+        if (hdrive && hpath) {
+            static char hd[264];
+            strcpy(hd,hdrive);
+            strcat(hd,hpath);
+            homedir = _strdup(hd);
+        }
+#else
       struct passwd *
 	pwd = getpwent ();
 
       homedir = strdup (pwd->pw_dir);
+#endif
     }
 
 /*#if defined( unix ) || defined( __CYGWIN__ )
@@ -304,6 +306,7 @@
 	fgcomParseOptions(config.str());
 #endif*/
 
+#if 0 // no check for .fgcomrc - not used not needed
   // Check for ~/.fgfsrc
   if (homedir != NULL)
     {
@@ -318,6 +321,7 @@
       config.append (".fgcomrc");
       _fgcomParseOptions (config);
     }
+#endif
 
 /*#if defined( unix ) || defined( __CYGWIN__ )
 	// Check for ~/.fgfsrc.hostname
@@ -443,7 +447,6 @@
 	  if (arg_name.empty ())
 	    {
 	      std::cerr << "Unknown option '" << arg << "'" << std::endl;
-	      SG_LOG (SG_GENERAL, SG_ALERT, "Unknown option '" << arg << "'");
 	      return FGCOM_OPTIONS_ERROR;
 	    }
 
@@ -461,7 +464,6 @@
 	  else
 	    {
 	      std::cerr << "Unknown option '" << arg << "'" << std::endl;
-	      SG_LOG (SG_GENERAL, SG_ALERT, "Unknown option '" << arg << "'");
 	      return FGCOM_OPTIONS_ERROR;
 	    }
 	}
@@ -484,22 +486,21 @@
 		{
 		  std::cerr << "Option '" << arg << "' needs a parameter" <<
 		    std::endl;
-		  SG_LOG (SG_GENERAL, SG_ALERT,
-			  "Option '" << arg << "' needs a parameter");
 		  return FGCOM_OPTIONS_ERROR;
 		}
 	      else
 		{
 		  std::cerr << "Option '" << arg <<
 		    "' does not have a parameter" << std::endl;
-		  SG_LOG (SG_GENERAL, SG_ALERT,
-			  "Option '" << arg << "' does not have a parameter");
 		  return FGCOM_OPTIONS_ERROR;
 		}
 	      break;
 	    case OPTION_FLOAT:
 	      if (!arg_value.empty ())
 		{
+#ifdef _MSC_VER
+            float temp = atof(arg_value.c_str());
+#else
 		  char *
 		    end;
 		  float
@@ -511,12 +512,9 @@
 		    {
 		      std::cerr << "Cannot parse float value '" << arg_value
 			<< "' for option " << arg_name << "!" << std::endl;
-		      SG_LOG (SG_GENERAL, SG_ALERT,
-			      "Cannot parse float value '" << arg_value <<
-			      "' for option " << arg_name << "!");
 		      return FGCOM_OPTIONS_ERROR;
 		    }
-
+#endif
 		  *(float *) (entry->parameter) = temp;
 		  if (*(float *) (entry->parameter) != temp
 		      || errno == ERANGE)
@@ -524,9 +522,6 @@
 		      std::cerr << "Float value '" << arg_value <<
 			"' for option " << arg_name << " out of range!" <<
 			std::endl;
-		      SG_LOG (SG_GENERAL, SG_ALERT,
-			      "Float value '" << arg_value << "' for option "
-			      << arg_name << " out of range!");
 		      return FGCOM_OPTIONS_ERROR;
 		    }
 		}
@@ -534,8 +529,6 @@
 		{
 		  std::cerr << "Option '" << arg << "' needs a parameter" <<
 		    std::endl;
-		  SG_LOG (SG_GENERAL, SG_ALERT,
-			  "Option '" << arg << "' needs a parameter");
 		  return FGCOM_OPTIONS_ERROR;
 		}
 	      break;
@@ -553,9 +546,6 @@
 		    {
 		      std::cerr << "Cannot parse double value '" << arg_value
 			<< "' for option " << arg_name << "!" << std::endl;
-		      SG_LOG (SG_GENERAL, SG_ALERT,
-			      "Cannot parse double value '" << arg_value <<
-			      "' for option " << arg_name << "!");
 		      return FGCOM_OPTIONS_ERROR;
 		    }
 
@@ -566,9 +556,6 @@
 		      std::cerr << "Double value '" << arg_value <<
 			"' for option " << arg_name << " out of range!" <<
 			std::endl;
-		      SG_LOG (SG_GENERAL, SG_ALERT,
-			      "Double value '" << arg_value << "' for option "
-			      << arg_name << " out of range!");
 		      return FGCOM_OPTIONS_ERROR;
 		    }
 		}
@@ -576,8 +563,6 @@
 		{
 		  std::cerr << "Option '" << arg << "' needs a parameter" <<
 		    std::endl;
-		  SG_LOG (SG_GENERAL, SG_ALERT,
-			  "Option '" << arg << "' needs a parameter");
 		  return FGCOM_OPTIONS_ERROR;
 		}
 	      break;
@@ -595,9 +580,6 @@
 		    {
 		      std::cerr << "Cannot parse integer value '" << arg_value
 			<< "' for option " << arg_name << "!" << std::endl;
-		      SG_LOG (SG_GENERAL, SG_ALERT,
-			      "Cannot parse integer value '" << arg_value <<
-			      "' for option " << arg_name << "!");
 		      return FGCOM_OPTIONS_ERROR;
 		    }
 
@@ -607,10 +589,6 @@
 		      std::cerr << "Integer value '" << arg_value <<
 			"' for option " << arg_name << " out of range!" <<
 			std::endl;
-		      SG_LOG (SG_GENERAL, SG_ALERT,
-			      "Integer value '" << arg_value <<
-			      "' for option " << arg_name <<
-			      " out of range!");
 		      return FGCOM_OPTIONS_ERROR;
 		    }
 		}
@@ -618,8 +596,6 @@
 		{
 		  std::cerr << "Option '" << arg << "' needs a parameter" <<
 		    std::endl;
-		  SG_LOG (SG_GENERAL, SG_ALERT,
-			  "Option '" << arg << "' needs a parameter");
 		  return FGCOM_OPTIONS_ERROR;
 		}
 	      break;
@@ -630,9 +606,6 @@
 		    {
 		      std::cerr << "Option '" << arg <<
 			"' needs a single char as parameter" << std::endl;
-		      SG_LOG (SG_GENERAL, SG_ALERT,
-			      "Option '" << arg <<
-			      "' needs a single char as parameter");
 		      return FGCOM_OPTIONS_ERROR;
 		    }
 		  else
@@ -644,16 +617,12 @@
 		{
 		  std::cerr << "Option '" << arg << "' needs a parameter" <<
 		    std::endl;
-		  SG_LOG (SG_GENERAL, SG_ALERT,
-			  "Option '" << arg << "' needs a parameter");
 		  return FGCOM_OPTIONS_ERROR;
 		}
 	      else
 		{
 		  std::cerr << "Option '" << arg <<
 		    "' does not have a parameter" << std::endl;
-		  SG_LOG (SG_GENERAL, SG_ALERT,
-			  "Option '" << arg << "' does not have a parameter");
 		  return FGCOM_OPTIONS_ERROR;
 		}
 	      break;
@@ -665,7 +634,6 @@
       else
 	{
 	  std::cerr << "Unknown option '" << arg << "'" << std::endl;
-	  SG_LOG (SG_GENERAL, SG_ALERT, "Unknown option '" << arg << "'");
 	  return FGCOM_OPTIONS_ERROR;
 	}
     }
@@ -723,64 +691,5 @@
   std::cout << "Successfully parsed commandline options." << std::endl;
 }
 
-// Parse config file options
-static void
-_fgcomParseOptions (const std::string & path)
-{
-  sg_gzifstream
-  in (path);
-
-  if (!in.is_open ())
-    {
-      return;
-    }
-
-#ifdef DEBUG
-  std::cout << "Processing config file: " << path << "." << std::endl;
-#endif
+// eof - fgcom_init.cpp
 
-  SG_LOG (SG_GENERAL, SG_INFO, "Processing config file: " << path);
-
-  in >> skipcomment;
-#ifndef __MWERKS__
-  while (!in.eof ())
-    {
-#else
-  char
-    c = '\0';
-  while (in.get (c) && c != '\0')
-    {
-      in.putback (c);
-#endif
-      std::string line;
-
-#if defined( macintosh )
-      getline (in, line, '\r');
-#else
-      getline (in, line, '\n');
-#endif
-
-      // catch extraneous (DOS) line ending character
-      int
-	i;
-      for (i = line.length (); i > 0; i--)
-	{
-	  if (line[i - 1] > 32)
-	    {
-	      break;
-	    }
-	}
-      line = line.substr (0, i);
-
-      std::string next_arg;
-      if (_parseOption (line, next_arg) == FGCOM_OPTIONS_ERROR)
-	{
-	  std::cerr << std::
-	    endl << "Config file parse error: " << path << " '" << line << "'"
-	    << std::endl;
-	  fgcomUsage ();
-	  exit (-1);
-	}
-      in >> skipcomment;
-    }
-}
diff -ur c:\FGCVS\fgcom\src\position.cpp fgcom\src\position.cpp
--- c:\FGCVS\fgcom\src\position.cpp	Mon Jul 11 15:10:50 2011
+++ fgcom\src\position.cpp	Tue Jul 26 16:41:59 2011
@@ -18,7 +18,7 @@
 icao2number (char *icao, float frequency, char *buf)
 {
   char icao_work[5];
-  int i;
+  //int i;
 
   if (strlen (icao) == 0)
     strcpy (icao, "ZZZZ");
@@ -30,12 +30,19 @@
   buf[16] = '\0';
 }
 
+#define GET_CLOSEST_MATCHING
+
 const char *
 icaobypos (struct airport *airports, double frequency,
 	   double plane_lat, double plane_lon, double range)
 {
-  char icao[5];
+  //char icao[5];
   double r;
+#ifdef GET_CLOSEST_MATCHING
+    struct airport *found;
+    int cnt = 0;
+    double min_dist = 999999999.0;
+#endif
 
   if (frequency >= DEFAULT_LOWER_FRQ_LIMIT
       && frequency <= DEFAULT_UPPER_FRQ_LIMIT)
@@ -58,16 +65,44 @@
 
 	      if (r <= range)
 		{
+#ifdef GET_CLOSEST_MATCHING
+#ifdef DEBUG
+		  printf
+		    ("Airport %s (%s %s at %3.3f MHz) is in range (%4.1f km)\n",
+		     airports->text, airports->icao, airports->type,
+		     frequency, r);
+#endif
+          if (r < min_dist) {
+              min_dist = r; // adjust minimum distance
+              cnt++;        // bump the count
+              found = airports; // and keep this pointer
+          }
+#else
 		  printf
 		    ("Airport %s (%s %s at %3.3f MHz) is in range (%4.1f km)\n",
 		     airports->text, airports->icao, airports->type,
 		     frequency, r);
 		  return (airports->icao);
+#endif
 		}
 	    }
 	  airports = airports->next;
 	}
+#ifdef GET_CLOSEST_MATCHING
+      if (cnt) {
+          airports = found;
+          r = min_dist;
+		  printf
+		    ("Airport %s (%s %s at %3.3f MHz) is in range (%4.1f km)\n",
+		     airports->text, airports->icao, airports->type,
+		     frequency, r);
+          return found->icao;
+      } else {
+          return "";
+      }
+#else
       return ("");
+#endif
     }
 
   return ("");
diff -ur c:\FGCVS\fgcom\src\utils.cpp fgcom\src\utils.cpp
--- c:\FGCVS\fgcom\src\utils.cpp	Mon Jul 11 15:10:50 2011
+++ fgcom\src\utils.cpp	Mon Jul 25 16:25:34 2011
@@ -1,7 +1,13 @@
 
+#ifdef _MSC_VER
+#include "config.h"
+#endif
+
 #include <sys/types.h>
 #include <sys/stat.h>
+#ifndef _MSC_VER
 #include <unistd.h>
+#endif
 #include <fcntl.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -22,11 +28,41 @@
  */
 int parser_init(const char *filename)
 {
+#ifdef _MSC_VER
 	struct stat l_stat;
-	ssize_t l_nbytes;
+    size_t l_nbytes;
 	int l_status;
-
 	s_index = 0;
+    l_status = -1;
+    FILE * fp;
+    int alloc_size;
+
+    printf("parser_init: reading file [%s]\n", filename);
+    if (stat(filename, &l_stat)) {
+        printf("parser_init: ERROR: 'stat' of file FAILED!\n");
+        return l_status;
+    }
+    fp = fopen(filename,"rb");
+    if (!fp) {
+        printf("parser_init: ERROR: 'open' of file FAILED!\n");
+        return l_status;
+    }
+    alloc_size = (l_stat.st_size + 1) * sizeof(char);
+	if((s_content = (char *)malloc(alloc_size)) != NULL)
+	{
+        if((l_nbytes = fread(s_content, 1, l_stat.st_size, fp)) == l_stat.st_size) {
+			l_status = 0;
+			s_size = l_stat.st_size;
+        } else {
+            printf("parser_init: ERROR: 'read' of file FAILED! Got %d, expected %d!\n",
+                l_nbytes, l_stat.st_size);
+        }
+    } else {
+        printf("ERROR: MEMORY FAILED on %d bytes!\n", alloc_size);
+    }
+    fclose(fp);
+#else
+    ssize_t l_nbytes;
 
 	if((s_file_handle = open(filename, O_RDONLY)) < 0)
 		return (s_file_handle);
@@ -44,6 +80,7 @@
 	}
 	close(s_file_handle);
 
+#endif
 	return(l_status);
 }
 
@@ -72,6 +109,9 @@
  * a negative value meaning that an error occured.
  *
  */
+#ifdef _MSC_VER
+#define bcopy(a,b,c) memcpy(b,a,c)
+#endif
 int parser_get_next_value(double *value)
 {
 	int l_status = 0;
@@ -96,9 +136,9 @@
 			return(-1);
 
 		/* If character is a CR, we restart for next line. */
-		if(s_content[s_index] == '\n')
+		if((s_content[s_index] == '\n')||(s_content[s_index] == '\r'))
 		{
-			s_index++;
+			s_index++;  // skip CR (or LF) characters
 			continue;
 		}
 
@@ -136,14 +176,15 @@
 					/* Prepare for next value. */
 					s_index = l_j + 1;
 					break;
-				}
+                } else {
+                    printf("ERROR: Memory allocation FAILED!\n");
+            		return(-1);
+                }
 			}
 		}
 	} /* while((s_index < s_size) && (l_status == 0)) */
 
 	return(0);
 }
-
-
 
 
