Index: trunk/rtcm3torinex/rtcm3torinex.c
===================================================================
--- trunk/rtcm3torinex/rtcm3torinex.c	(revision 1824)
+++ trunk/rtcm3torinex/rtcm3torinex.c	(revision 2346)
@@ -1,5 +1,5 @@
 /*
   Converter for RTCM3 data to RINEX.
-  $Id: rtcm3torinex.c,v 1.36 2008/12/03 08:33:16 stoecker Exp $
+  $Id: rtcm3torinex.c,v 1.31 2010/01/16 11:07:57 weber Exp $
   Copyright (C) 2005-2008 by Dirk Stöcker <stoecker@alberding.eu>
 
@@ -48,8 +48,12 @@
 #endif
 
+#ifndef isinf
+#define isinf(x) 0
+#endif
+
 #include "rtcm3torinex.h"
 
 /* CVS revision and version */
-static char revisionstr[] = "$Revision: 1.36 $";
+static char revisionstr[] = "$Revision: 1.31 $";
 
 #ifndef COMPILEDATE
@@ -234,5 +238,5 @@
 }
 
-static int gnumleap(int year, int month, int day)
+int gnumleap(int year, int month, int day)
 {
   int ls = 0;
@@ -247,8 +251,9 @@
 }
 
-void updatetime(int *week, int *tow, int tk, int fixnumleap)
+/* Convert Moscow time into UTC (fixnumleap == 1) or GPS (fixnumleap == 0) */
+void updatetime(int *week, int *secOfWeek, int mSecOfWeek, int fixnumleap)
 {
   int y,m,d,k,l, nul;
-  unsigned int j = *week*(7*24*60*60) + *tow + 5*24*60*60+3*60*60;
+  unsigned int j = *week*(7*24*60*60) + *secOfWeek + 5*24*60*60+3*60*60;
   int glo_daynumber = 0, glo_timeofday;
   for(y = 1980; j >= (unsigned int)(k = (l = (365+longyear(y,0)))*24*60*60)
@@ -268,13 +273,13 @@
   glo_timeofday = j-nul;
 
-  if(tk < 5*60*1000 && glo_timeofday > 23*60*60)
-    *tow += 24*60*60;
-  else if(glo_timeofday < 5*60 && tk > 23*60*60*1000)
-    *tow -= 24*60*60;
-  *tow += tk/1000-glo_timeofday;
+  if(mSecOfWeek < 5*60*1000 && glo_timeofday > 23*60*60)
+    *secOfWeek += 24*60*60;
+  else if(glo_timeofday < 5*60 && mSecOfWeek > 23*60*60*1000)
+    *secOfWeek -= 24*60*60;
+  *secOfWeek += mSecOfWeek/1000-glo_timeofday;
   if(fixnumleap)
-    *tow -= nul;
-  if(*tow < 0) {*tow += 24*60*60*7; --*week; }
-  if(*tow >= 24*60*60*7) {*tow -= 24*60*60*7; ++*week; }
+    *secOfWeek -= nul;
+  if(*secOfWeek < 0) {*secOfWeek += 24*60*60*7; --*week; }
+  if(*secOfWeek >= 24*60*60*7) {*secOfWeek -= 24*60*60*7; ++*week; }
 }
 
@@ -635,5 +640,5 @@
         GETBITS(i,27) /* tk */
 
-        updatetime(&handle->GPSWeek, &handle->GPSTOW, i, 0);
+        updatetime(&handle->GPSWeek, &handle->GPSTOW, i, 0); /* Moscow -> GPS */
         i = handle->GPSTOW*1000;
         if(gnss->week && (gnss->timeofweek != i || gnss->week
@@ -671,4 +676,7 @@
           GETBITS(code, 1)
           GETBITS(freq, 5)
+
+          gnss->channels[num] = freq - 7;
+
           if(code)
           {
@@ -828,13 +836,4 @@
   } data;
   int  numheaders;
-};
-
-struct converttimeinfo {
-  int second;    /* seconds of GPS time [0..59] */
-  int minute;    /* minutes of GPS time [0..59] */
-  int hour;      /* hour of GPS time [0..24] */
-  int day;       /* day of GPS time [1..28..30(31)*/
-  int month;     /* month of GPS time [1..12]*/
-  int year;      /* year of GPS time [1980..] */
 };
 
@@ -1398,5 +1397,5 @@
             struct converttimeinfo cti;
 
-            updatetime(&w, &tow, e->tb*1000, 1);
+            updatetime(&w, &tow, e->tb*1000, 1);  /* Moscow - > UTC */
             converttime(&cti, w, tow);
 
@@ -1685,5 +1684,5 @@
 
 #ifndef NO_RTCM3_MAIN
-static char datestr[]     = "$Date: 2008/12/03 08:33:16 $";
+static char datestr[]     = "$Date: 2010/01/16 11:07:57 $";
 
 /* The string, which is send as agent in HTTP request */
Index: trunk/rtcm3torinex/rtcm3torinex.h
===================================================================
--- trunk/rtcm3torinex/rtcm3torinex.h	(revision 1824)
+++ trunk/rtcm3torinex/rtcm3torinex.h	(revision 2346)
@@ -4,5 +4,5 @@
 /*
   Converter for RTCM3 data to RINEX.
-  $Id: rtcm3torinex.h,v 1.14 2008/11/10 18:07:35 weber Exp $
+  $Id: rtcm3torinex.h,v 1.19 2010/01/12 12:13:23 mervart Exp $
   Copyright (C) 2005-2006 by Dirk Stöcker <stoecker@alberding.eu>
 
@@ -22,4 +22,6 @@
   or read http://www.gnu.org/licenses/gpl.txt
 */
+
+#include <stdio.h>
 
 #define PRN_GPS_START             1
@@ -98,4 +100,13 @@
 #define GNSSDF_LOCKLOSSL2     (1<<30)  /* lost lock on L2 */
 
+struct converttimeinfo {
+  int second;    /* seconds of GPS time [0..59] */
+  int minute;    /* minutes of GPS time [0..59] */
+  int hour;      /* hour of GPS time [0..24] */
+  int day;       /* day of GPS time [1..28..30(31)*/
+  int month;     /* month of GPS time [1..12]*/
+  int year;      /* year of GPS time [1980..] */
+};
+
 struct gnssdata {
   int    flags;              /* GPSF_xxx */
@@ -106,4 +117,5 @@
   int    dataflags[24];      /* GPSDF_xxx */
   int    satellites[24];     /* SV - IDs */
+  int    channels[24];       /* Glonass channels - valid of Glonass SV only */
   int    snrL1[24];          /* Important: all the 5 SV-specific fields must */
   int    snrL2[24];          /* have the same SV-order */
@@ -230,4 +242,8 @@
 #endif /* PRINTFARG */
 
+int gnumleap(int year, int month, int day);
+void updatetime(int *week, int *tow, int tk, int fixnumleap);
+void converttime(struct converttimeinfo *c, int week, int tow);
+
 void HandleHeader(struct RTCM3ParserData *Parser);
 int RTCM3Parser(struct RTCM3ParserData *handle);
