Index: trunk/BNC/src/RTCM3/clock_and_orbit/clock_orbit_rtcm.c
===================================================================
--- trunk/BNC/src/RTCM3/clock_and_orbit/clock_orbit_rtcm.c	(revision 8944)
+++ trunk/BNC/src/RTCM3/clock_and_orbit/clock_orbit_rtcm.c	(revision 8963)
@@ -1,10 +1,10 @@
 /* Programheader
 
-        Name:           clock_orbit_rtcm.c
-        Project:        RTCM3
-        Version:        $Id$
-        Authors:        Dirk Stöcker
-        Description:    state space approach for RTCM3
-*/
+ Name:           clock_orbit_rtcm.c
+ Project:        RTCM3
+ Version:        $Id$
+ Authors:        Dirk Stöcker
+ Description:    state space approach for RTCM3
+ */
 
 #include <math.h>
@@ -18,16 +18,14 @@
 #include "clock_orbit_rtcm.h"
 
-static uint32_t CRC24(long size, const unsigned char *buf)
-{
+static uint32_t CRC24(long size, const unsigned char *buf) {
   uint32_t crc = 0;
   int i;
 
-  while(size--)
-  {
+  while (size--) {
     crc ^= (*buf++) << (16);
-    for(i = 0; i < 8; i++)
-    {
+    for (i = 0; i < 8; i++)
+        {
       crc <<= 1;
-      if(crc & 0x1000000)
+      if (crc & 0x1000000)
         crc ^= 0x01864cfb;
     }
@@ -37,18 +35,17 @@
 
 /* NOTE: These defines are interlinked with below functions and directly modify
-the values. This may not be optimized in terms of final program code size but
-should be optimized in terms of speed.
-
-modified variables are:
-- everything defined in STARTDATA (only use ressize outside of the defines,
-  others are private)
-- buffer
-- size
-*/
+ the values. This may not be optimized in terms of final program code size but
+ should be optimized in terms of speed.
+
+ modified variables are:
+ - everything defined in STARTDATA (only use ressize outside of the defines,
+ others are private)
+ - buffer
+ - size
+ */
 
 #ifndef NOENCODE
 #define STOREBITS \
-  while(numbits >= 8) \
-  { \
+  while(numbits >= 8) { \
     if(!size) return 0; \
     *(buffer++) = bitbuffer>>(numbits-8); \
@@ -58,6 +55,5 @@
   }
 
-#define ADDBITS(a, b) \
-  { \
+#define ADDBITS(a, b) { \
     bitbuffer = (bitbuffer<<(a))|((b)&((1<<a)-1)); \
     numbits += (a); \
@@ -79,6 +75,5 @@
 
 #define ENDBLOCK \
-  if(numbits) { ADDBITS((8-numbits), 0) } \
-  { \
+  if(numbits) { ADDBITS((8-numbits), 0) } { \
     int len = buffer-blockstart-3; \
     blockstart[1] |= len>>8; \
@@ -151,60 +146,118 @@
 #define T_IONO_HEIGHT(a)                 SCALEADDBITS(8,   1/10000.0, a)
 
-static double URAToValue(int ura)
-{
+static double URAToValue(int ura) {
   int urac, urav;
   urac = ura >> 3;
   urav = ura & 7;
-  if(!ura)
+  if (!ura)
     return 0;
-  else if(ura == 63)
+  else if (ura == 63)
     return SSR_MAXURA;
-  return (pow(3,urac)*(1.0+urav/4.0)-1.0)/1000.0;
+  return (pow(3, urac) * (1.0 + urav / 4.0) - 1.0) / 1000.0;
 }
 
-static int ValueToURA(double val)
-{
+static int ValueToURA(double val) {
   int ura;
-  if(!val)
+  if (!val)
     return 0;
-  else if(val > 5.4665)
+  else if (val > 5.4665)
     return 63;
-  for(ura = 1; ura < 63 && val > URAToValue(ura); ++ura)
+  for (ura = 1; ura < 63 && val > URAToValue(ura); ++ura)
     ;
   return ura;
 }
 
-static const enum ClockOrbitType corbase[CLOCKORBIT_SATNUM] =
-{
-  (int) COBBASE_GPS, (int) COBBASE_GLONASS, (int) COBBASE_GALILEO,
-  (int) COBBASE_QZSS, (int) COBBASE_SBAS, (int) COBBASE_BDS
+static const enum ClockOrbitType corbase[CLOCKORBIT_SATNUM] = {
+  (int) COBBASE_GPS,
+  (int) COBBASE_GLONASS,
+  (int) COBBASE_GALILEO,
+  (int) COBBASE_QZSS,
+  (int) COBBASE_SBAS,
+  (int) COBBASE_BDS
 };
-static const enum COR_OFFSETS satoffset[CLOCKORBIT_SATNUM+1] =
-{
-  CLOCKORBIT_OFFSETGPS, CLOCKORBIT_OFFSETGLONASS, CLOCKORBIT_OFFSETGALILEO,
-  CLOCKORBIT_OFFSETQZSS, CLOCKORBIT_OFFSETSBAS, CLOCKORBIT_OFFSETBDS,
+
+static const enum COR_OFFSETS satoffset[CLOCKORBIT_SATNUM + 1] = {
+  CLOCKORBIT_OFFSETGPS,
+  CLOCKORBIT_OFFSETGLONASS,
+  CLOCKORBIT_OFFSETGALILEO,
+  CLOCKORBIT_OFFSETQZSS,
+  CLOCKORBIT_OFFSETSBAS,
+  CLOCKORBIT_OFFSETBDS,
   CLOCKORBIT_COUNTSAT
 };
+/*
+//CNES PATCH MEDIAN
+static double Median(int n, double x[50]) {
+  double temp;
+  int i, j;
+  // the following two loops sort the array x in ascending order
+  if (n <= 2)
+    return 0.0;
+
+  for (i = 0; i < n - 1; i++)
+    for (j = i + 1; j < n; j++)
+      if (x[j] < x[i]) {
+        // swap elements
+        temp = x[i];
+        x[i] = x[j];
+        x[j] = temp;
+      }
+
+  if (n % 2 == 0)
+    return ((x[n / 2] + x[n / 2 - 1]) / 2.0);
+  else
+    return x[n / 2];
+}
+//PATCH MEDIAN
+//PATCH CLKOFFSET
+ size_t MakeClockOrbit(struct ClockOrbit *co, enum ClockOrbitType type,*/
 
 size_t MakeClockOrbit(const struct ClockOrbit *co, enum ClockOrbitType type,
-int moremessagesfollow, char *buffer, size_t size)
-{
+    int moremessagesfollow, char *buffer, size_t size) {
   unsigned int status[CLOCKORBIT_SATNUM][COBOFS_NUM], i, s;
 
   memset(status, 0, sizeof(status));
-  STARTDATA
-
-  for(s = 0; s < CLOCKORBIT_SATNUM; ++s)
-  {
-    for(i = 0; i < COBOFS_NUM; ++i)
-    {
-      if(co->NumberOfSat[s] && (type == COTYPE_AUTO
-      || type == corbase[s]+i) && (co->Supplied[i] || (i <= COBOFS_CLOCK
-      && co->Supplied[COBOFS_COMBINED]) || (i == COBOFS_COMBINED
-      && co->Supplied[COBOFS_ORBIT] && co->Supplied[COBOFS_CLOCK])))
+/*  PATCH CLKOFFSET /////////////////////////////////////////////////////
+  //double tSum
+  double tOffset, tClock[50];
+  int j, tNb;
+  for (s = 0; s < CLOCKORBIT_SATNUM; ++s)
       {
+    //tSum = 0.0;
+    tOffset = 0.0;
+    tNb = 0;
+    for (j = 0; j < 50; j++)
+      tClock[j] = 0.0;
+
+    for (i = satoffset[s]; i < satoffset[s] + co->NumberOfSat[s]; ++i) {
+      if (co->Sat[i].Clock.DeltaA0)  {
+        //tSum += co->Sat[i].Clock.DeltaA0; //Average
+        tClock[tNb] = co->Sat[i].Clock.DeltaA0;	//Median
+        tNb++;
+      }
+    }
+    //tOffset = tSum/(double)tNb; //Average
+    tOffset = Median(tNb, tClock); //Median
+    for (i = satoffset[s]; i < satoffset[s] + co->NumberOfSat[s]; ++i)
+      if (co->Sat[i].Clock.DeltaA0) {
+         //clkoffset_test
+//         FILE *ficOffsetClk = fopen("ClkOffset.txt","a");
+//         fprintf(ficOffsetClk,"%d %d %d %lf %lf %lf\n",co->EpochTime[s], s, i, co->Sat[i].Clock.DeltaA0, tOffset, co->Sat[i].Clock.DeltaA0-tOffset);
+//         fclose(ficOffsetClk);
+
+        co->Sat[i].Clock.DeltaA0 -= tOffset;
+      }
+  }
+  //PATCH CLKOFFSET ///////////////////////////////////////////////////// */
+
+   STARTDATA
+
+  for (s = 0; s < CLOCKORBIT_SATNUM; ++s) {
+    for (i = 0; i < COBOFS_NUM; ++i) {
+      if (co->NumberOfSat[s] && (type == COTYPE_AUTO || type == corbase[s] + i) &&
+           (co->Supplied[i] || (i <= COBOFS_CLOCK &&  co->Supplied[COBOFS_COMBINED]) ||
+           (i == COBOFS_COMBINED && co->Supplied[COBOFS_ORBIT] && co->Supplied[COBOFS_CLOCK]))) {
         status[s][i] = 1;
-        if(i == COBOFS_COMBINED)
-        {
+        if (i == COBOFS_COMBINED) {
           status[s][COBOFS_ORBIT] = status[s][COBOFS_CLOCK] = 0;
         } /* disable single blocks for combined type */
@@ -213,20 +266,19 @@
   } /* iterate over satellite systems */
 
-  for(s = 0; s < CLOCKORBIT_SATNUM; ++s)
-  {
-    if(status[s][COBOFS_ORBIT])
-    {
+  for (s = 0; s < CLOCKORBIT_SATNUM; ++s) {
+    if (status[s][COBOFS_ORBIT]) {
       INITBLOCK
-      T_MESSAGE_NUMBER(corbase[s]+COBOFS_ORBIT)
-      switch(s)
-      {
-      case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO:
-      case CLOCKORBIT_SATQZSS: case CLOCKORBIT_SATSBAS:
-      case CLOCKORBIT_SATBDS:
-        T_GPS_EPOCH_TIME(co->EpochTime[s])
-        break;
-      case CLOCKORBIT_SATGLONASS:
-        T_GLONASS_EPOCH_TIME(co->EpochTime[s])
-        break;
+      T_MESSAGE_NUMBER(corbase[s] + COBOFS_ORBIT)
+      switch (s) {
+        case CLOCKORBIT_SATGPS:
+        case CLOCKORBIT_SATGALILEO:
+        case CLOCKORBIT_SATQZSS:
+        case CLOCKORBIT_SATSBAS:
+        case CLOCKORBIT_SATBDS:
+          T_GPS_EPOCH_TIME(co->EpochTime[s])
+          break;
+        case CLOCKORBIT_SATGLONASS:
+          T_GLONASS_EPOCH_TIME(co->EpochTime[s])
+          break;
       }
       T_SSR_UPDATE_INTERVAL(co->UpdateInterval)
@@ -237,34 +289,32 @@
       T_SSR_SOLUTION_ID(co->SSRSolutionID)
       T_NO_OF_SATELLITES(co->NumberOfSat[s])
-      for(i = satoffset[s]; i < satoffset[s]+co->NumberOfSat[s]; ++i)
-      {
-        switch(s)
-        {
-        case CLOCKORBIT_SATGPS:
-          T_GPS_SATELLITE_ID(co->Sat[i].ID)
-          T_GPS_IODE(co->Sat[i].IOD)
-          break;
-        case CLOCKORBIT_SATGLONASS:
-          T_GLONASS_SATELLITE_ID(co->Sat[i].ID)
-          T_GLONASS_IOD(co->Sat[i].IOD)
-          break;
-        case CLOCKORBIT_SATGALILEO:
-          T_GPS_SATELLITE_ID(co->Sat[i].ID)
-          T_GALILEO_IOD(co->Sat[i].IOD)
-          break;
-        case CLOCKORBIT_SATQZSS:
-          T_QZSS_SATELLITE_ID(co->Sat[i].ID)
-          T_GPS_IODE(co->Sat[i].IOD)
-          break;
-        case CLOCKORBIT_SATSBAS:
-          T_GPS_SATELLITE_ID(co->Sat[i].ID)
-          T_SBAS_T0MOD(co->Sat[i].toe)
-          T_SBAS_IODCRC(co->Sat[i].IOD)
-          break;
-        case CLOCKORBIT_SATBDS:
-          T_GPS_SATELLITE_ID(co->Sat[i].ID)
-          T_BDS_TOEMOD(co->Sat[i].toe)
-          T_BDS_IOD(co->Sat[i].IOD)
-          break;
+      for (i = satoffset[s]; i < satoffset[s] + co->NumberOfSat[s]; ++i) {
+        switch (s)         {
+          case CLOCKORBIT_SATGPS:
+            T_GPS_SATELLITE_ID(co->Sat[i].ID)
+            T_GPS_IODE(co->Sat[i].IOD)
+            break;
+          case CLOCKORBIT_SATGLONASS:
+            T_GLONASS_SATELLITE_ID(co->Sat[i].ID)
+            T_GLONASS_IOD(co->Sat[i].IOD)
+            break;
+          case CLOCKORBIT_SATGALILEO:
+            T_GPS_SATELLITE_ID(co->Sat[i].ID)
+            T_GALILEO_IOD(co->Sat[i].IOD)
+            break;
+          case CLOCKORBIT_SATQZSS:
+            T_QZSS_SATELLITE_ID(co->Sat[i].ID)
+            T_GPS_IODE(co->Sat[i].IOD)
+            break;
+          case CLOCKORBIT_SATSBAS:
+            T_GPS_SATELLITE_ID(co->Sat[i].ID)
+            T_SBAS_T0MOD(co->Sat[i].toe)
+            T_SBAS_IODCRC(co->Sat[i].IOD)
+            break;
+          case CLOCKORBIT_SATBDS:
+            T_GPS_SATELLITE_ID(co->Sat[i].ID)
+            T_BDS_TOEMOD(co->Sat[i].toe)
+            T_BDS_IOD(co->Sat[i].IOD)
+            break;
         }
         T_DELTA_RADIAL(co->Sat[i].Orbit.DeltaRadial)
@@ -277,18 +327,18 @@
       ENDBLOCK
     }
-    if(status[s][COBOFS_CLOCK])
-    {
+    if (status[s][COBOFS_CLOCK]) {
       INITBLOCK
-      T_MESSAGE_NUMBER(corbase[s]+COBOFS_CLOCK)
-      switch(s)
-      {
-      case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO:
-      case CLOCKORBIT_SATQZSS: case CLOCKORBIT_SATSBAS:
-      case CLOCKORBIT_SATBDS:
-        T_GPS_EPOCH_TIME(co->EpochTime[s])
-        break;
-      case CLOCKORBIT_SATGLONASS:
-        T_GLONASS_EPOCH_TIME(co->EpochTime[s])
-        break;
+      T_MESSAGE_NUMBER(corbase[s] + COBOFS_CLOCK)
+      switch (s) {
+        case CLOCKORBIT_SATGPS:
+        case CLOCKORBIT_SATGALILEO:
+        case CLOCKORBIT_SATQZSS:
+        case CLOCKORBIT_SATSBAS:
+        case CLOCKORBIT_SATBDS:
+          T_GPS_EPOCH_TIME(co->EpochTime[s])
+          break;
+        case CLOCKORBIT_SATGLONASS:
+          T_GLONASS_EPOCH_TIME(co->EpochTime[s])
+          break;
       }
       T_SSR_UPDATE_INTERVAL(co->UpdateInterval)
@@ -298,18 +348,18 @@
       T_SSR_SOLUTION_ID(co->SSRSolutionID)
       T_NO_OF_SATELLITES(co->NumberOfSat[s])
-      for(i = satoffset[s]; i < satoffset[s]+co->NumberOfSat[s]; ++i)
-      {
-        switch(s)
-        {
-        case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO:
-        case CLOCKORBIT_SATSBAS: case CLOCKORBIT_SATBDS:
-          T_GPS_SATELLITE_ID(co->Sat[i].ID)
-          break;
-        case CLOCKORBIT_SATQZSS:
-          T_QZSS_SATELLITE_ID(co->Sat[i].ID)
-          break;
-        case CLOCKORBIT_SATGLONASS:
-          T_GLONASS_SATELLITE_ID(co->Sat[i].ID)
-          break;
+      for (i = satoffset[s]; i < satoffset[s] + co->NumberOfSat[s]; ++i) {
+        switch (s) {
+          case CLOCKORBIT_SATGPS:
+          case CLOCKORBIT_SATGALILEO:
+          case CLOCKORBIT_SATSBAS:
+          case CLOCKORBIT_SATBDS:
+            T_GPS_SATELLITE_ID(co->Sat[i].ID)
+            break;
+          case CLOCKORBIT_SATQZSS:
+            T_QZSS_SATELLITE_ID(co->Sat[i].ID)
+            break;
+          case CLOCKORBIT_SATGLONASS:
+            T_GLONASS_SATELLITE_ID(co->Sat[i].ID)
+            break;
         }
         T_DELTA_CLOCK_C0(co->Sat[i].Clock.DeltaA0)
@@ -319,27 +369,24 @@
       ENDBLOCK
     }
-    if(status[s][COBOFS_COMBINED])
-    {
+    if (status[s][COBOFS_COMBINED]) {
 #ifdef SPLITBLOCK
       int nums = co->NumberOfSat[s];
       int left, start = satoffset[s];
-      if(nums > 28) /* split block when more than 28 sats */
-      {
+      if(nums > 28) {/* split block when more than 28 sats */
         left = nums - 28;
         nums = 28;
       }
-      else
-      {
+      else {
         left = 0;
       }
-      while(nums)
-      {
-#endif
-        INITBLOCK
-        T_MESSAGE_NUMBER(corbase[s]+COBOFS_COMBINED)
-        switch(s)
-        {
-        case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO:
-        case CLOCKORBIT_SATQZSS: case CLOCKORBIT_SATSBAS:
+      while(nums) {
+#endif
+      INITBLOCK
+      T_MESSAGE_NUMBER(corbase[s] + COBOFS_COMBINED)
+      switch (s) {
+        case CLOCKORBIT_SATGPS:
+        case CLOCKORBIT_SATGALILEO:
+        case CLOCKORBIT_SATQZSS:
+        case CLOCKORBIT_SATSBAS:
         case CLOCKORBIT_SATBDS:
           T_GPS_EPOCH_TIME(co->EpochTime[s])
@@ -348,25 +395,24 @@
           T_GLONASS_EPOCH_TIME(co->EpochTime[s])
           break;
-        }
-        T_SSR_UPDATE_INTERVAL(co->UpdateInterval)
+      }
+      T_SSR_UPDATE_INTERVAL(co->UpdateInterval)
 #ifdef SPLITBLOCK
-        T_MULTIPLE_MESSAGE_INDICATOR((moremessagesfollow || left) ? 1 : 0)
+      T_MULTIPLE_MESSAGE_INDICATOR((moremessagesfollow || left) ? 1 : 0)
 #else
-        T_MULTIPLE_MESSAGE_INDICATOR(moremessagesfollow ? 1 : 0)
-#endif
-        T_SATELLITE_REFERENCE_DATUM(co->SatRefDatum)
-        T_SSR_IOD(co->SSRIOD)
-        T_SSR_PROVIDER_ID(co->SSRProviderID)
-        T_SSR_SOLUTION_ID(co->SSRSolutionID)
+      T_MULTIPLE_MESSAGE_INDICATOR(moremessagesfollow ? 1 : 0)
+#endif
+      T_SATELLITE_REFERENCE_DATUM(co->SatRefDatum)
+      T_SSR_IOD(co->SSRIOD)
+      T_SSR_PROVIDER_ID(co->SSRProviderID)
+      T_SSR_SOLUTION_ID(co->SSRSolutionID)
 #ifdef SPLITBLOCK
-        T_NO_OF_SATELLITES(nums)
-        for(i = start; i < start+nums; ++i)
+      T_NO_OF_SATELLITES(nums)
+      for(i = start; i < start+nums; ++i)
 #else
-        T_NO_OF_SATELLITES(co->NumberOfSat[s])
-        for(i = satoffset[s]; i < satoffset[s]+co->NumberOfSat[s]; ++i)
-#endif
-        {
-          switch(s)
-          {
+      T_NO_OF_SATELLITES(co->NumberOfSat[s])
+      for (i = satoffset[s]; i < satoffset[s] + co->NumberOfSat[s]; ++i)
+#endif
+      {
+        switch (s) {
           case CLOCKORBIT_SATGPS:
             T_GPS_SATELLITE_ID(co->Sat[i].ID)
@@ -395,37 +441,37 @@
             T_BDS_IOD(co->Sat[i].IOD)
             break;
-          }
-          T_DELTA_RADIAL(co->Sat[i].Orbit.DeltaRadial)
-          T_DELTA_ALONG_TRACK(co->Sat[i].Orbit.DeltaAlongTrack)
-          T_DELTA_CROSS_TRACK(co->Sat[i].Orbit.DeltaCrossTrack)
-          T_DELTA_DOT_RADIAL(co->Sat[i].Orbit.DotDeltaRadial)
-          T_DELTA_DOT_ALONG_TRACK(co->Sat[i].Orbit.DotDeltaAlongTrack)
-          T_DELTA_DOT_CROSS_TRACK(co->Sat[i].Orbit.DotDeltaCrossTrack)
-          T_DELTA_CLOCK_C0(co->Sat[i].Clock.DeltaA0)
-          T_DELTA_CLOCK_C1(co->Sat[i].Clock.DeltaA1)
-          T_DELTA_CLOCK_C2(co->Sat[i].Clock.DeltaA2)
         }
-        ENDBLOCK
+        T_DELTA_RADIAL(co->Sat[i].Orbit.DeltaRadial)
+        T_DELTA_ALONG_TRACK(co->Sat[i].Orbit.DeltaAlongTrack)
+        T_DELTA_CROSS_TRACK(co->Sat[i].Orbit.DeltaCrossTrack)
+        T_DELTA_DOT_RADIAL(co->Sat[i].Orbit.DotDeltaRadial)
+        T_DELTA_DOT_ALONG_TRACK(co->Sat[i].Orbit.DotDeltaAlongTrack)
+        T_DELTA_DOT_CROSS_TRACK(co->Sat[i].Orbit.DotDeltaCrossTrack)
+        T_DELTA_CLOCK_C0(co->Sat[i].Clock.DeltaA0)
+        T_DELTA_CLOCK_C1(co->Sat[i].Clock.DeltaA1)
+        T_DELTA_CLOCK_C2(co->Sat[i].Clock.DeltaA2)
+      }
+      ENDBLOCK
 #ifdef SPLITBLOCK
-        start += nums;
-        nums = left;
-        left = 0;
-      }
-#endif
-    }
-    if(status[s][COBOFS_HR])
-    {
+      start += nums;
+      nums = left;
+      left = 0;
+    }
+#endif
+    }
+    if (status[s][COBOFS_HR]) {
       INITBLOCK
-      T_MESSAGE_NUMBER(corbase[s]+COBOFS_HR)
-      switch(s)
-      {
-      case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO:
-      case CLOCKORBIT_SATQZSS: case CLOCKORBIT_SATSBAS:
-      case CLOCKORBIT_SATBDS:
-        T_GPS_EPOCH_TIME(co->EpochTime[s])
-        break;
-      case CLOCKORBIT_SATGLONASS:
-        T_GLONASS_EPOCH_TIME(co->EpochTime[s])
-        break;
+      T_MESSAGE_NUMBER(corbase[s] + COBOFS_HR)
+      switch (s) {
+        case CLOCKORBIT_SATGPS:
+        case CLOCKORBIT_SATGALILEO:
+        case CLOCKORBIT_SATQZSS:
+        case CLOCKORBIT_SATSBAS:
+        case CLOCKORBIT_SATBDS:
+          T_GPS_EPOCH_TIME(co->EpochTime[s])
+          break;
+        case CLOCKORBIT_SATGLONASS:
+          T_GLONASS_EPOCH_TIME(co->EpochTime[s])
+          break;
       }
       T_SSR_UPDATE_INTERVAL(co->UpdateInterval)
@@ -435,18 +481,18 @@
       T_SSR_SOLUTION_ID(co->SSRSolutionID)
       T_NO_OF_SATELLITES(co->NumberOfSat[s])
-      for(i = satoffset[s]; i < satoffset[s]+co->NumberOfSat[s]; ++i)
-      {
-        switch(s)
-        {
-        case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO:
-        case CLOCKORBIT_SATSBAS: case CLOCKORBIT_SATBDS:
-          T_GPS_SATELLITE_ID(co->Sat[i].ID)
-          break;
-        case CLOCKORBIT_SATQZSS:
-          T_QZSS_SATELLITE_ID(co->Sat[i].ID)
-          break;
-        case CLOCKORBIT_SATGLONASS:
-          T_GLONASS_SATELLITE_ID(co->Sat[i].ID)
-          break;
+      for (i = satoffset[s]; i < satoffset[s] + co->NumberOfSat[s]; ++i) {
+        switch (s) {
+          case CLOCKORBIT_SATGPS:
+            case CLOCKORBIT_SATGALILEO:
+            case CLOCKORBIT_SATSBAS:
+            case CLOCKORBIT_SATBDS:
+            T_GPS_SATELLITE_ID(co->Sat[i].ID)
+            break;
+          case CLOCKORBIT_SATQZSS:
+            T_QZSS_SATELLITE_ID(co->Sat[i].ID)
+            break;
+          case CLOCKORBIT_SATGLONASS:
+            T_GLONASS_SATELLITE_ID(co->Sat[i].ID)
+            break;
         }
         T_HR_CLOCK_CORRECTION(co->Sat[i].hrclock)
@@ -454,18 +500,18 @@
       ENDBLOCK
     }
-    if(status[s][COBOFS_URA])
-    {
+    if (status[s][COBOFS_URA]) {
       INITBLOCK
-      T_MESSAGE_NUMBER(corbase[s]+COBOFS_URA)
-      switch(s)
-      {
-      case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO:
-      case CLOCKORBIT_SATQZSS: case CLOCKORBIT_SATSBAS:
-      case CLOCKORBIT_SATBDS:
-        T_GPS_EPOCH_TIME(co->EpochTime[s])
-        break;
-      case CLOCKORBIT_SATGLONASS:
-        T_GLONASS_EPOCH_TIME(co->EpochTime[s])
-        break;
+      T_MESSAGE_NUMBER(corbase[s] + COBOFS_URA)
+      switch (s) {
+        case CLOCKORBIT_SATGPS:
+        case CLOCKORBIT_SATGALILEO:
+        case CLOCKORBIT_SATQZSS:
+        case CLOCKORBIT_SATSBAS:
+        case CLOCKORBIT_SATBDS:
+          T_GPS_EPOCH_TIME(co->EpochTime[s])
+          break;
+        case CLOCKORBIT_SATGLONASS:
+          T_GLONASS_EPOCH_TIME(co->EpochTime[s])
+          break;
       }
       T_SSR_UPDATE_INTERVAL(co->UpdateInterval)
@@ -475,18 +521,18 @@
       T_SSR_SOLUTION_ID(co->SSRSolutionID)
       T_NO_OF_SATELLITES(co->NumberOfSat[s])
-      for(i = satoffset[s]; i < satoffset[s]+co->NumberOfSat[s]; ++i)
-      {
-        switch(s)
-        {
-        case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO:
-        case CLOCKORBIT_SATSBAS: case CLOCKORBIT_SATBDS:
-          T_GPS_SATELLITE_ID(co->Sat[i].ID)
-          break;
-        case CLOCKORBIT_SATQZSS:
-          T_QZSS_SATELLITE_ID(co->Sat[i].ID)
-          break;
-        case CLOCKORBIT_SATGLONASS:
-          T_GLONASS_SATELLITE_ID(co->Sat[i].ID)
-          break;
+      for (i = satoffset[s]; i < satoffset[s] + co->NumberOfSat[s]; ++i) {
+        switch (s) {
+          case CLOCKORBIT_SATGPS:
+          case CLOCKORBIT_SATGALILEO:
+          case CLOCKORBIT_SATSBAS:
+          case CLOCKORBIT_SATBDS:
+            T_GPS_SATELLITE_ID(co->Sat[i].ID)
+            break;
+          case CLOCKORBIT_SATQZSS:
+            T_QZSS_SATELLITE_ID(co->Sat[i].ID)
+            break;
+          case CLOCKORBIT_SATGLONASS:
+            T_GLONASS_SATELLITE_ID(co->Sat[i].ID)
+            break;
         }
         T_SSR_URA(ValueToURA(co->Sat[i].UserRangeAccuracy))
@@ -499,26 +545,24 @@
 
 size_t MakeCodeBias(const struct CodeBias *b, enum CodeBiasType type,
-int moremessagesfollow, char *buffer, size_t size)
-{
+    int moremessagesfollow, char *buffer, size_t size) {
   unsigned int s, i, j;
 
   STARTDATA
 
-  for(s = 0; s < CLOCKORBIT_SATNUM; ++s)
-  {
-    if(b->NumberOfSat[s] && (type == BTYPE_AUTO || type == corbase[s]+COBOFS_BIAS))
-    {
+  for (s = 0; s < CLOCKORBIT_SATNUM; ++s) {
+    if (b->NumberOfSat[s] && (type == BTYPE_AUTO || type == corbase[s] + COBOFS_BIAS)) {
       INITBLOCK
-      T_MESSAGE_NUMBER(corbase[s]+COBOFS_BIAS)
-      switch(s)
-      {
-      case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO:
-      case CLOCKORBIT_SATQZSS: case CLOCKORBIT_SATSBAS:
-      case CLOCKORBIT_SATBDS:
-        T_GPS_EPOCH_TIME(b->EpochTime[s])
-        break;
-      case CLOCKORBIT_SATGLONASS:
-        T_GLONASS_EPOCH_TIME(b->EpochTime[s])
-        break;
+      T_MESSAGE_NUMBER(corbase[s] + COBOFS_BIAS)
+      switch (s) {
+        case CLOCKORBIT_SATGPS:
+        case CLOCKORBIT_SATGALILEO:
+        case CLOCKORBIT_SATQZSS:
+        case CLOCKORBIT_SATSBAS:
+        case CLOCKORBIT_SATBDS:
+          T_GPS_EPOCH_TIME(b->EpochTime[s])
+          break;
+        case CLOCKORBIT_SATGLONASS:
+          T_GLONASS_EPOCH_TIME(b->EpochTime[s])
+          break;
       }
       T_SSR_UPDATE_INTERVAL(b->UpdateInterval)
@@ -528,22 +572,21 @@
       T_SSR_SOLUTION_ID(b->SSRSolutionID)
       T_NO_OF_SATELLITES(b->NumberOfSat[s])
-      for(i = satoffset[s]; i < satoffset[s]+b->NumberOfSat[s]; ++i)
-      {
-        switch(s)
-        {
-        case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO:
-        case CLOCKORBIT_SATSBAS: case CLOCKORBIT_SATBDS:
-          T_GPS_SATELLITE_ID(b->Sat[i].ID)
-          break;
-        case CLOCKORBIT_SATQZSS:
-          T_QZSS_SATELLITE_ID(b->Sat[i].ID)
-          break;
-        case CLOCKORBIT_SATGLONASS:
-          T_GLONASS_SATELLITE_ID(b->Sat[i].ID)
-          break;
+      for (i = satoffset[s]; i < satoffset[s] + b->NumberOfSat[s]; ++i) {
+        switch (s) {
+          case CLOCKORBIT_SATGPS:
+          case CLOCKORBIT_SATGALILEO:
+          case CLOCKORBIT_SATSBAS:
+          case CLOCKORBIT_SATBDS:
+            T_GPS_SATELLITE_ID(b->Sat[i].ID)
+            break;
+          case CLOCKORBIT_SATQZSS:
+            T_QZSS_SATELLITE_ID(b->Sat[i].ID)
+            break;
+          case CLOCKORBIT_SATGLONASS:
+            T_GLONASS_SATELLITE_ID(b->Sat[i].ID)
+            break;
         }
         T_NO_OF_CODE_BIASES(b->Sat[i].NumberOfCodeBiases)
-        for(j = 0; j < b->Sat[i].NumberOfCodeBiases; ++j)
-        {
+        for (j = 0; j < b->Sat[i].NumberOfCodeBiases; ++j) {
           T_SIGNAL_IDENTIFIER(b->Sat[i].Biases[j].Type)
           T_CODE_BIAS(b->Sat[i].Biases[j].Bias)
@@ -557,26 +600,24 @@
 
 size_t MakePhaseBias(const struct PhaseBias *b, enum PhaseBiasType type,
-int moremessagesfollow, char *buffer, size_t size)
-{
+    int moremessagesfollow, char *buffer, size_t size) {
   unsigned int s, i, j;
 
   STARTDATA
 
-  for(s = 0; s < CLOCKORBIT_SATNUM; ++s)
-  {
-    if(b->NumberOfSat[s] && (type == PBTYPE_AUTO || type == s+PBTYPE_BASE))
-    {
+  for (s = 0; s < CLOCKORBIT_SATNUM; ++s)       {
+    if (b->NumberOfSat[s] && (type == PBTYPE_AUTO || type == s + PBTYPE_BASE)) {
       INITBLOCK
-      T_MESSAGE_NUMBER(s+PBTYPE_BASE)
-      switch(s)
-      {
-      case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO:
-      case CLOCKORBIT_SATQZSS: case CLOCKORBIT_SATSBAS:
-      case CLOCKORBIT_SATBDS:
-        T_GPS_EPOCH_TIME(b->EpochTime[s])
-        break;
-      case CLOCKORBIT_SATGLONASS:
-        T_GLONASS_EPOCH_TIME(b->EpochTime[s])
-        break;
+      T_MESSAGE_NUMBER(s + PBTYPE_BASE)
+      switch (s) {
+        case CLOCKORBIT_SATGPS:
+        case CLOCKORBIT_SATGALILEO:
+        case CLOCKORBIT_SATQZSS:
+        case CLOCKORBIT_SATSBAS:
+        case CLOCKORBIT_SATBDS:
+          T_GPS_EPOCH_TIME(b->EpochTime[s])
+          break;
+        case CLOCKORBIT_SATGLONASS:
+          T_GLONASS_EPOCH_TIME(b->EpochTime[s])
+          break;
       }
       T_SSR_UPDATE_INTERVAL(b->UpdateInterval)
@@ -588,28 +629,30 @@
       T_MW_CONSISTENCY_INDICATOR(b->MWConsistencyIndicator ? 1 : 0)
       T_NO_OF_SATELLITES(b->NumberOfSat[s])
-      for(i = satoffset[s]; i < satoffset[s]+b->NumberOfSat[s]; ++i)
-      {
-        switch(s)
-        {
-        case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO:
-        case CLOCKORBIT_SATSBAS: case CLOCKORBIT_SATBDS:
-          T_GPS_SATELLITE_ID(b->Sat[i].ID)
-          break;
-        case CLOCKORBIT_SATQZSS:
-          T_QZSS_SATELLITE_ID(b->Sat[i].ID)
-          break;
-        case CLOCKORBIT_SATGLONASS:
-          T_GLONASS_SATELLITE_ID(b->Sat[i].ID)
-          break;
+      for (i = satoffset[s]; i < satoffset[s] + b->NumberOfSat[s]; ++i) {
+        switch (s) {
+          case CLOCKORBIT_SATGPS:
+            case CLOCKORBIT_SATGALILEO:
+            case CLOCKORBIT_SATSBAS:
+            case CLOCKORBIT_SATBDS:
+            T_GPS_SATELLITE_ID(b->Sat[i].ID)
+            break;
+          case CLOCKORBIT_SATQZSS:
+            T_QZSS_SATELLITE_ID(b->Sat[i].ID)
+            break;
+          case CLOCKORBIT_SATGLONASS:
+            T_GLONASS_SATELLITE_ID(b->Sat[i].ID)
+            break;
         }
         T_NO_OF_PHASE_BIASES(b->Sat[i].NumberOfPhaseBiases)
         T_YAW_ANGLE(b->Sat[i].YawAngle)
         T_YAW_RATE(b->Sat[i].YawRate)
-        for(j = 0; j < b->Sat[i].NumberOfPhaseBiases; ++j)
-        {
+        for (j = 0; j < b->Sat[i].NumberOfPhaseBiases; ++j) {
           T_SIGNAL_IDENTIFIER(b->Sat[i].Biases[j].Type)
-          T_INTEGER_INDICATOR(b->Sat[i].Biases[j].SignalIntegerIndicator ? 1 : 0)
-          T_WIDE_LANE_INDICATOR(b->Sat[i].Biases[j].SignalsWideLaneIntegerIndicator)
-          T_DISCONTINUITY_COUNTER(b->Sat[i].Biases[j].SignalDiscontinuityCounter)
+          T_INTEGER_INDICATOR(
+              b->Sat[i].Biases[j].SignalIntegerIndicator ? 1 : 0)
+          T_WIDE_LANE_INDICATOR(
+              b->Sat[i].Biases[j].SignalsWideLaneIntegerIndicator)
+          T_DISCONTINUITY_COUNTER(
+              b->Sat[i].Biases[j].SignalDiscontinuityCounter)
           T_PHASE_BIAS(b->Sat[i].Biases[j].Bias)
         }
@@ -621,11 +664,9 @@
 }
 
-size_t MakeVTEC(const struct VTEC *v, int moremessagesfollow, char *buffer,
-size_t size)
-{
+size_t MakeVTEC(const struct VTEC *v, int moremessagesfollow, char *buffer, size_t size) {
   unsigned int l, o, d;
 
   STARTDATA
-  INITBLOCK
+    INITBLOCK
   T_MESSAGE_NUMBER(VTEC_BASE)
 
@@ -638,20 +679,15 @@
   T_VTEC_QUALITY_INDICATOR(v->Quality)
   T_NO_IONO_LAYERS(v->NumLayers)
-  for(l = 0; l < v->NumLayers; ++l)
-  {
+  for (l = 0; l < v->NumLayers; ++l) {
     T_IONO_HEIGHT(v->Layers[l].Height)
     T_IONO_DEGREE(v->Layers[l].Degree)
     T_IONO_ORDER(v->Layers[l].Order)
-    for(o = 0; o <= v->Layers[l].Order; ++o)
-    {
-      for(d = o; d <= v->Layers[l].Degree; ++d)
-      {
+    for (o = 0; o <= v->Layers[l].Order; ++o) {
+      for (d = o; d <= v->Layers[l].Degree; ++d) {
         T_IONO_COEFF(v->Layers[l].Cosinus[d][o])
       }
     }
-    for(o = 1; o <= v->Layers[l].Order; ++o)
-    {
-      for(d = o; d <= v->Layers[l].Degree; ++d)
-      {
+    for (o = 1; o <= v->Layers[l].Order; ++o) {
+      for (d = o; d <= v->Layers[l].Degree; ++d) {
         T_IONO_COEFF(v->Layers[l].Sinus[d][o])
       }
@@ -669,6 +705,5 @@
   uint64_t bitbuffer=0;
 
-#define LOADBITS(a) \
-{ \
+#define LOADBITS(a) { \
   while((a) > numbits) \
   { \
@@ -680,7 +715,6 @@
 
 /* extract bits from data stream
-   b = variable to store result, a = number of bits */
-#define GETBITS(b, a) \
-{ \
+ b = variable to store result, a = number of bits */
+#define GETBITS(b, a) { \
   LOADBITS(a) \
   b = (bitbuffer<<(64-numbits))>>(64-(a)); \
@@ -689,7 +723,6 @@
 
 /* extract bits from data stream
-   b = variable to store result, a = number of bits */
-#define GETBITSFACTOR(b, a, c) \
-{ \
+ b = variable to store result, a = number of bits */
+#define GETBITSFACTOR(b, a, c) { \
   LOADBITS(a) \
   b = ((bitbuffer<<(64-numbits))>>(64-(a)))*(c); \
@@ -698,7 +731,6 @@
 
 /* extract signed floating value from data stream
-   b = variable to store result, a = number of bits */
-#define GETFLOATSIGN(b, a, c) \
-{ \
+ b = variable to store result, a = number of bits */
+#define GETFLOATSIGN(b, a, c) { \
   LOADBITS(a) \
   b = ((double)(((int64_t)(bitbuffer<<(64-numbits)))>>(64-(a))))*(c); \
@@ -707,7 +739,6 @@
 
 /* extract floating value from data stream
-   b = variable to store result, a = number of bits, c = scale factor */
-#define GETFLOAT(b, a, c) \
-{ \
+ b = variable to store result, a = number of bits, c = scale factor */
+#define GETFLOAT(b, a, c) { \
   LOADBITS(a) \
   b = ((double)((bitbuffer<<(sizeof(bitbuffer)*8-numbits))>>(sizeof(bitbuffer)*8-(a))))*(c); \
@@ -782,8 +813,7 @@
 #define G_IONO_HEIGHT(a)                 GETFLOAT(a, 8 ,    10000.0)
 
-enum GCOB_RETURN GetSSR(struct ClockOrbit *co, struct CodeBias *b, struct VTEC *v,
-struct PhaseBias *pb, const char *buffer, size_t size, int *bytesused)
-{
-  int mmi=0, h, rs;
+enum GCOB_RETURN GetSSR(struct ClockOrbit *co, struct CodeBias *b,struct VTEC *v,
+    struct PhaseBias *pb, const char *buffer, size_t size, int *bytesused) {
+  int mmi = 0, h, rs;
   unsigned int type, pos, i, j, s, nums, id;
   size_t sizeofrtcmblock;
@@ -791,5 +821,5 @@
   DECODESTART
 
-  if(size < 7)
+  if (size < 7)
     return GCOBR_SHORTBUFFER;
 
@@ -802,12 +832,12 @@
   G_SIZE(sizeofrtcmblock);
 
-  if((unsigned char)h != 0xD3 || rs)
+  if ((unsigned char) h != 0xD3 || rs)
     return GCOBR_UNKNOWNDATA;
-  if(size < sizeofrtcmblock + 3) /* 3 header bytes already removed */
+  if (size < sizeofrtcmblock + 3) /* 3 header bytes already removed */
     return GCOBR_MESSAGEEXCEEDSBUFFER;
-  if(CRC24(sizeofrtcmblock+3, (const unsigned char *) blockstart) !=
-  (uint32_t)((((unsigned char)buffer[sizeofrtcmblock])<<16)|
-  (((unsigned char)buffer[sizeofrtcmblock+1])<<8)|
-  (((unsigned char)buffer[sizeofrtcmblock+2]))))
+  if (CRC24(sizeofrtcmblock + 3, (const unsigned char *) blockstart) !=
+      (uint32_t) ((((unsigned char) buffer[sizeofrtcmblock]) << 16) |
+          (((unsigned char) buffer[sizeofrtcmblock + 1]) << 8) |
+          (((unsigned char) buffer[sizeofrtcmblock + 2]))))
     return GCOBR_CRCMISMATCH;
   size = sizeofrtcmblock; /* reduce size, so overflows are detected */
@@ -815,12 +845,12 @@
   G_MESSAGE_NUMBER(type)
 #ifdef DEBUG
-fprintf(stderr, "type %d size %d\n",type,sizeofrtcmblock);
-#endif
-  if(bytesused)
-    *bytesused = sizeofrtcmblock+6;
-  if(type == VTEC_BASE)
-  {
+  fprintf(stderr, "type %d size %d\n",type,sizeofrtcmblock);
+#endif
+  if (bytesused)
+    *bytesused = sizeofrtcmblock + 6;
+  if (type == VTEC_BASE) {
     unsigned int l, o, d;
-    if(!v) return GCOBR_NOVTECPARAMETER;
+    if (!v)
+      return GCOBR_NOVTECPARAMETER;
     memset(v, 0, sizeof(*v));
     G_EPOCH_TIME(v->EpochTime)
@@ -832,20 +862,15 @@
     G_VTEC_QUALITY_INDICATOR(v->Quality)
     G_NO_IONO_LAYERS(v->NumLayers)
-    for(l = 0; l < v->NumLayers; ++l)
-    {
+    for (l = 0; l < v->NumLayers; ++l) {
       G_IONO_HEIGHT(v->Layers[l].Height)
       G_IONO_DEGREE(v->Layers[l].Degree)
       G_IONO_ORDER(v->Layers[l].Order)
-      for(o = 0; o <= v->Layers[l].Order; ++o)
-      {
-        for(d = o; d <= v->Layers[l].Degree; ++d)
-        {
+      for (o = 0; o <= v->Layers[l].Order; ++o) {
+        for (d = o; d <= v->Layers[l].Degree; ++d) {
           G_IONO_COEFF(v->Layers[l].Cosinus[d][o])
         }
       }
-      for(o = 1; o <= v->Layers[l].Order; ++o)
-      {
-        for(d = o; d <= v->Layers[l].Degree; ++d)
-        {
+      for (o = 1; o <= v->Layers[l].Order; ++o) {
+        for (d = o; d <= v->Layers[l].Degree; ++d) {
           G_IONO_COEFF(v->Layers[l].Sinus[d][o])
         }
@@ -854,25 +879,25 @@
 #ifdef DEBUG
     for(type = 0; type < (int)size && (unsigned char)buffer[type] != 0xD3; ++type)
-      numbits += 8;
+    numbits += 8;
     fprintf(stderr, "numbits left %d\n",numbits);
 #endif
     return mmi ? GCOBR_MESSAGEFOLLOWS : GCOBR_OK;
   }
-  for(s = CLOCKORBIT_SATNUM; s-- > 0;)
-  {
-    if(type == PBTYPE_BASE+s)
-    {
-      if(!pb) return GCOBR_NOPHASEBIASPARAMETER;
+  for (s = CLOCKORBIT_SATNUM; s-- > 0;) {
+    if (type == PBTYPE_BASE + s) {
+      if (!pb)
+        return GCOBR_NOPHASEBIASPARAMETER;
       pb->messageType = type;
-      switch(s)
-      {
-      case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO:
-      case CLOCKORBIT_SATQZSS: case CLOCKORBIT_SATSBAS:
-      case CLOCKORBIT_SATBDS:
-        G_GPS_EPOCH_TIME(pb->EpochTime[s], pb->NumberOfSat[s])
-        break;
-      case CLOCKORBIT_SATGLONASS:
-        G_GLONASS_EPOCH_TIME(pb->EpochTime[s], pb->NumberOfSat[s])
-        break;
+      switch (s) {
+        case CLOCKORBIT_SATGPS:
+        case CLOCKORBIT_SATGALILEO:
+        case CLOCKORBIT_SATQZSS:
+        case CLOCKORBIT_SATSBAS:
+        case CLOCKORBIT_SATBDS:
+          G_GPS_EPOCH_TIME(pb->EpochTime[s], pb->NumberOfSat[s])
+          break;
+        case CLOCKORBIT_SATGLONASS:
+          G_GLONASS_EPOCH_TIME(pb->EpochTime[s], pb->NumberOfSat[s])
+          break;
       }
       G_SSR_UPDATE_INTERVAL(pb->UpdateInterval)
@@ -884,23 +909,27 @@
       G_MW_CONSISTENCY_INDICATOR(pb->MWConsistencyIndicator)
       G_NO_OF_SATELLITES(nums)
-      for(i = 0; i < nums; ++i)
-      {
-        switch(s)
-        {
-        case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO:
-        case CLOCKORBIT_SATSBAS: case CLOCKORBIT_SATBDS:
-          G_GPS_SATELLITE_ID(id)
-          break;
-        case CLOCKORBIT_SATQZSS:
-          G_QZSS_SATELLITE_ID(id)
-          break;
-        case CLOCKORBIT_SATGLONASS:
-          G_GLONASS_SATELLITE_ID(id)
-          break;
+      for (i = 0; i < nums; ++i) {
+        switch (s) {
+          case CLOCKORBIT_SATGPS:
+          case CLOCKORBIT_SATGALILEO:
+          case CLOCKORBIT_SATSBAS:
+          case CLOCKORBIT_SATBDS:
+            G_GPS_SATELLITE_ID(id)
+            break;
+          case CLOCKORBIT_SATQZSS:
+            G_QZSS_SATELLITE_ID(id)
+            break;
+          case CLOCKORBIT_SATGLONASS:
+            G_GLONASS_SATELLITE_ID(id)
+            break;
         }
-        for(pos = satoffset[s]; pos < satoffset[s]+pb->NumberOfSat[s] && pb->Sat[pos].ID != id; ++pos)
+        for (pos = satoffset[s];
+            pos < satoffset[s] + pb->NumberOfSat[s] && pb->Sat[pos].ID != id;
+            ++pos)
           ;
-        if(pos >= satoffset[s+1]) return GCOBR_DATAMISMATCH;
-        else if(pos == pb->NumberOfSat[s] + satoffset[s]) ++pb->NumberOfSat[s];
+        if (pos >= satoffset[s + 1])
+          return GCOBR_DATAMISMATCH;
+        else if (pos == pb->NumberOfSat[s] + satoffset[s])
+          ++pb->NumberOfSat[s];
         pb->Sat[pos].ID = id;
 
@@ -908,10 +937,11 @@
         G_YAW_ANGLE(pb->Sat[pos].YawAngle)
         G_YAW_RATE(pb->Sat[pos].YawRate)
-        for(j = 0; j < pb->Sat[pos].NumberOfPhaseBiases; ++j)
-        {
+        for (j = 0; j < pb->Sat[pos].NumberOfPhaseBiases; ++j) {
           G_SIGNAL_IDENTIFIER(pb->Sat[pos].Biases[j].Type)
           G_INTEGER_INDICATOR(pb->Sat[pos].Biases[j].SignalIntegerIndicator)
-          G_WIDE_LANE_INDICATOR(pb->Sat[pos].Biases[j].SignalsWideLaneIntegerIndicator)
-          G_DISCONTINUITY_COUNTER(pb->Sat[pos].Biases[j].SignalDiscontinuityCounter)
+          G_WIDE_LANE_INDICATOR(
+              pb->Sat[pos].Biases[j].SignalsWideLaneIntegerIndicator)
+          G_DISCONTINUITY_COUNTER(
+              pb->Sat[pos].Biases[j].SignalDiscontinuityCounter)
           G_PHASE_BIAS(pb->Sat[pos].Biases[j].Bias)
         }
@@ -919,382 +949,411 @@
 #ifdef DEBUG
       for(type = 0; type < (int)size && (unsigned char)buffer[type] != 0xD3; ++type)
-        numbits += 8;
+      numbits += 8;
       fprintf(stderr, "numbits left %d\n",numbits);
 #endif
       return mmi ? GCOBR_MESSAGEFOLLOWS : GCOBR_OK;
     }
-    else if(type >= corbase[s])
-    {
-      switch(type-corbase[s])
-      {
-      case COBOFS_ORBIT:
-        if(!co) return GCOBR_NOCLOCKORBITPARAMETER;
-        co->messageType = type;
-        switch(s)
-        {
-        case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO:
-        case CLOCKORBIT_SATQZSS: case CLOCKORBIT_SATSBAS:
-        case CLOCKORBIT_SATBDS:
-          G_GPS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s])
-          break;
-        case CLOCKORBIT_SATGLONASS:
-          G_GLONASS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s])
-          break;
-        }
-        G_SSR_UPDATE_INTERVAL(co->UpdateInterval)
-        G_MULTIPLE_MESSAGE_INDICATOR(mmi)
-        G_SATELLITE_REFERENCE_DATUM(co->SatRefDatum)
-        G_SSR_IOD(co->SSRIOD)
-        G_SSR_PROVIDER_ID(co->SSRProviderID)
-        G_SSR_SOLUTION_ID(co->SSRSolutionID)
-        G_NO_OF_SATELLITES(nums)
-        co->Supplied[COBOFS_ORBIT] |= 1;
+    else if (type >= corbase[s]) {
+      switch (type - corbase[s]) {
+        case COBOFS_ORBIT:
+          if (!co)
+            return GCOBR_NOCLOCKORBITPARAMETER;
+          co->messageType = type;
+          switch (s) {
+            case CLOCKORBIT_SATGPS:
+            case CLOCKORBIT_SATGALILEO:
+            case CLOCKORBIT_SATQZSS:
+            case CLOCKORBIT_SATSBAS:
+            case CLOCKORBIT_SATBDS:
+              G_GPS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s])
+              break;
+            case CLOCKORBIT_SATGLONASS:
+              G_GLONASS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s])
+              break;
+          }
+          G_SSR_UPDATE_INTERVAL(co->UpdateInterval)
+          G_MULTIPLE_MESSAGE_INDICATOR(mmi)
+          G_SATELLITE_REFERENCE_DATUM(co->SatRefDatum)
+          G_SSR_IOD(co->SSRIOD)
+          G_SSR_PROVIDER_ID(co->SSRProviderID)
+          G_SSR_SOLUTION_ID(co->SSRSolutionID)
+          G_NO_OF_SATELLITES(nums)
+          co->Supplied[COBOFS_ORBIT] |= 1;
 #ifdef DEBUG
-        fprintf(stderr, "epochtime %d ui %d mmi %d sats %d/%d rd %d\n",co->EpochTime[s],
-        co->UpdateInterval,mmi,co->NumberOfSat[s],nums, co->SatRefDatum);
-#endif
-        for(i = 0; i < nums; ++i)
-        {
-          switch(s)
-          {
-          case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO:
-          case CLOCKORBIT_SATSBAS: case CLOCKORBIT_SATBDS:
-            G_GPS_SATELLITE_ID(id)
-            break;
-          case CLOCKORBIT_SATQZSS:
-            G_QZSS_SATELLITE_ID(id)
-            break;
-          case CLOCKORBIT_SATGLONASS:
-            G_GLONASS_SATELLITE_ID(id)
-            break;
+          fprintf(stderr, "epochtime %d ui %d mmi %d sats %d/%d rd %d\n",co->EpochTime[s],
+              co->UpdateInterval,mmi,co->NumberOfSat[s],nums, co->SatRefDatum);
+#endif
+          for (i = 0; i < nums; ++i) {
+            switch (s) {
+              case CLOCKORBIT_SATGPS:
+              case CLOCKORBIT_SATGALILEO:
+              case CLOCKORBIT_SATSBAS:
+              case CLOCKORBIT_SATBDS:
+                G_GPS_SATELLITE_ID(id)
+                break;
+              case CLOCKORBIT_SATQZSS:
+                G_QZSS_SATELLITE_ID(id)
+                break;
+              case CLOCKORBIT_SATGLONASS:
+                G_GLONASS_SATELLITE_ID(id)
+                break;
+            }
+            for (pos = satoffset[s];
+                pos < satoffset[s] + co->NumberOfSat[s] && co->Sat[pos].ID != id;
+                ++pos)
+              ;
+            if (pos >= satoffset[s + 1])
+              return GCOBR_DATAMISMATCH;
+            else if (pos == co->NumberOfSat[s] + satoffset[s])
+              ++co->NumberOfSat[s];
+            co->Sat[pos].ID = id;
+
+            switch (s) {
+              case CLOCKORBIT_SATGPS:
+                case CLOCKORBIT_SATQZSS:
+                G_GPS_IODE(co->Sat[pos].IOD)
+                break;
+              case CLOCKORBIT_SATGLONASS:
+                G_GLONASS_IOD(co->Sat[pos].IOD)
+                break;
+              case CLOCKORBIT_SATGALILEO:
+                G_GALILEO_IOD(co->Sat[pos].IOD)
+                break;
+              case CLOCKORBIT_SATSBAS:
+                G_SBAS_T0MOD(co->Sat[pos].toe)
+                G_SBAS_IODCRC(co->Sat[pos].IOD)
+                break;
+              case CLOCKORBIT_SATBDS:
+                G_BDS_TOEMOD(co->Sat[pos].toe)
+                G_BDS_IOD(co->Sat[pos].IOD)
+                break;
+            }
+            G_DELTA_RADIAL(co->Sat[pos].Orbit.DeltaRadial)
+            G_DELTA_ALONG_TRACK(co->Sat[pos].Orbit.DeltaAlongTrack)
+            G_DELTA_CROSS_TRACK(co->Sat[pos].Orbit.DeltaCrossTrack)
+            G_DELTA_DOT_RADIAL(co->Sat[pos].Orbit.DotDeltaRadial)
+            G_DELTA_DOT_ALONG_TRACK(co->Sat[pos].Orbit.DotDeltaAlongTrack)
+            G_DELTA_DOT_CROSS_TRACK(co->Sat[pos].Orbit.DotDeltaCrossTrack)
+#ifdef DEBUG
+            fprintf(stderr, "id %2d iod %3d dr %8.3f da %8.3f dc %8.3f dr %8.3f da %8.3f dc %8.3f\n",
+                co->Sat[pos].ID,co->Sat[pos].IOD,co->Sat[pos].Orbit.DeltaRadial,
+                co->Sat[pos].Orbit.DeltaAlongTrack,co->Sat[pos].Orbit.DeltaCrossTrack,
+                co->Sat[pos].Orbit.DotDeltaRadial,
+                co->Sat[pos].Orbit.DotDeltaAlongTrack,
+                co->Sat[pos].Orbit.DotDeltaCrossTrack);
+#endif
           }
-          for(pos = satoffset[s]; pos < satoffset[s]+co->NumberOfSat[s] && co->Sat[pos].ID != id; ++pos)
-            ;
-          if(pos >= satoffset[s+1]) return GCOBR_DATAMISMATCH;
-          else if(pos == co->NumberOfSat[s] + satoffset[s]) ++co->NumberOfSat[s];
-          co->Sat[pos].ID = id;
-
-          switch(s)
-          {
-          case CLOCKORBIT_SATGPS:
-          case CLOCKORBIT_SATQZSS:
-            G_GPS_IODE(co->Sat[pos].IOD)
-            break;
-          case CLOCKORBIT_SATGLONASS:
-            G_GLONASS_IOD(co->Sat[pos].IOD)
-            break;
-          case CLOCKORBIT_SATGALILEO:
-            G_GALILEO_IOD(co->Sat[pos].IOD)
-            break;
-          case CLOCKORBIT_SATSBAS:
-            G_SBAS_T0MOD(co->Sat[pos].toe)
-            G_SBAS_IODCRC(co->Sat[pos].IOD)
-            break;
-          case CLOCKORBIT_SATBDS:
-            G_BDS_TOEMOD(co->Sat[pos].toe)
-            G_BDS_IOD(co->Sat[pos].IOD)
-            break;
+          break;
+        case COBOFS_CLOCK:
+          if (!co)
+            return GCOBR_NOCLOCKORBITPARAMETER;
+          co->messageType = type;
+          switch (s) {
+            case CLOCKORBIT_SATGPS:
+            case CLOCKORBIT_SATGALILEO:
+            case CLOCKORBIT_SATQZSS:
+            case CLOCKORBIT_SATSBAS:
+            case CLOCKORBIT_SATBDS:
+              G_GPS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s])
+              break;
+            case CLOCKORBIT_SATGLONASS:
+              G_GLONASS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s])
+              break;
           }
-          G_DELTA_RADIAL(co->Sat[pos].Orbit.DeltaRadial)
-          G_DELTA_ALONG_TRACK(co->Sat[pos].Orbit.DeltaAlongTrack)
-          G_DELTA_CROSS_TRACK(co->Sat[pos].Orbit.DeltaCrossTrack)
-          G_DELTA_DOT_RADIAL(co->Sat[pos].Orbit.DotDeltaRadial)
-          G_DELTA_DOT_ALONG_TRACK(co->Sat[pos].Orbit.DotDeltaAlongTrack)
-          G_DELTA_DOT_CROSS_TRACK(co->Sat[pos].Orbit.DotDeltaCrossTrack)
+          G_SSR_UPDATE_INTERVAL(co->UpdateInterval)
+          G_MULTIPLE_MESSAGE_INDICATOR(mmi)
+          G_SSR_IOD(co->SSRIOD)
+          G_SSR_PROVIDER_ID(co->SSRProviderID)
+          G_SSR_SOLUTION_ID(co->SSRSolutionID)
+          G_NO_OF_SATELLITES(nums)
+          co->Supplied[COBOFS_CLOCK] |= 1;
 #ifdef DEBUG
-          fprintf(stderr, "id %2d iod %3d dr %8.3f da %8.3f dc %8.3f dr %8.3f da %8.3f dc %8.3f\n",
-          co->Sat[pos].ID,co->Sat[pos].IOD,co->Sat[pos].Orbit.DeltaRadial,
-          co->Sat[pos].Orbit.DeltaAlongTrack,co->Sat[pos].Orbit.DeltaCrossTrack,
-          co->Sat[pos].Orbit.DotDeltaRadial,
-          co->Sat[pos].Orbit.DotDeltaAlongTrack,
-          co->Sat[pos].Orbit.DotDeltaCrossTrack);
-#endif
-        }
-        break;
-      case COBOFS_CLOCK:
-        if(!co) return GCOBR_NOCLOCKORBITPARAMETER;
-        co->messageType = type;
-        switch(s)
-        {
-        case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO:
-        case CLOCKORBIT_SATQZSS: case CLOCKORBIT_SATSBAS:
-        case CLOCKORBIT_SATBDS:
-          G_GPS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s])
-          break;
-        case CLOCKORBIT_SATGLONASS:
-          G_GLONASS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s])
-          break;
-        }
-        G_SSR_UPDATE_INTERVAL(co->UpdateInterval)
-        G_MULTIPLE_MESSAGE_INDICATOR(mmi)
-        G_SSR_IOD(co->SSRIOD)
-        G_SSR_PROVIDER_ID(co->SSRProviderID)
-        G_SSR_SOLUTION_ID(co->SSRSolutionID)
-        G_NO_OF_SATELLITES(nums)
-        co->Supplied[COBOFS_CLOCK] |= 1;
+          fprintf(stderr, "epochtime %d ui %d mmi %d sats %d/%d\n",co->EpochTime[s],
+              co->UpdateInterval,mmi,co->NumberOfSat[s],nums);
+#endif
+          for (i = 0; i < nums; ++i) {
+            switch (s) {
+              case CLOCKORBIT_SATGPS:
+                case CLOCKORBIT_SATGALILEO:
+                case CLOCKORBIT_SATSBAS:
+                case CLOCKORBIT_SATBDS:
+                G_GPS_SATELLITE_ID(id)
+                break;
+              case CLOCKORBIT_SATQZSS:
+                G_QZSS_SATELLITE_ID(id)
+                break;
+              case CLOCKORBIT_SATGLONASS:
+                G_GLONASS_SATELLITE_ID(id)
+                break;
+            }
+            for (pos = satoffset[s];
+                pos < satoffset[s] + co->NumberOfSat[s] && co->Sat[pos].ID != id;
+                ++pos)
+              ;
+            if (pos >= satoffset[s + 1])
+              return GCOBR_DATAMISMATCH;
+            else if (pos == co->NumberOfSat[s] + satoffset[s])
+              ++co->NumberOfSat[s];
+            co->Sat[pos].ID = id;
+
+            G_DELTA_CLOCK_C0(co->Sat[pos].Clock.DeltaA0)
+            G_DELTA_CLOCK_C1(co->Sat[pos].Clock.DeltaA1)
+            G_DELTA_CLOCK_C2(co->Sat[pos].Clock.DeltaA2)
 #ifdef DEBUG
-        fprintf(stderr, "epochtime %d ui %d mmi %d sats %d/%d\n",co->EpochTime[s],
-        co->UpdateInterval,mmi,co->NumberOfSat[s],nums);
-#endif
-        for(i = 0; i < nums; ++i)
-        {
-          switch(s)
-          {
-          case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO:
-          case CLOCKORBIT_SATSBAS: case CLOCKORBIT_SATBDS:
-            G_GPS_SATELLITE_ID(id)
-            break;
-          case CLOCKORBIT_SATQZSS:
-            G_QZSS_SATELLITE_ID(id)
-            break;
-          case CLOCKORBIT_SATGLONASS:
-            G_GLONASS_SATELLITE_ID(id)
-            break;
+            fprintf(stderr, "id %2d c0 %8.3f c1 %8.3f c2 %8.3f\n",
+                co->Sat[pos].ID, co->Sat[pos].Clock.DeltaA0, co->Sat[pos].Clock.DeltaA1,
+                co->Sat[pos].Clock.DeltaA2);
+#endif
           }
-          for(pos = satoffset[s]; pos < satoffset[s]+co->NumberOfSat[s] && co->Sat[pos].ID != id; ++pos)
-            ;
-          if(pos >= satoffset[s+1]) return GCOBR_DATAMISMATCH;
-          else if(pos == co->NumberOfSat[s] + satoffset[s]) ++co->NumberOfSat[s];
-          co->Sat[pos].ID = id;
-
-          G_DELTA_CLOCK_C0(co->Sat[pos].Clock.DeltaA0)
-          G_DELTA_CLOCK_C1(co->Sat[pos].Clock.DeltaA1)
-          G_DELTA_CLOCK_C2(co->Sat[pos].Clock.DeltaA2)
-#ifdef DEBUG
-          fprintf(stderr, "id %2d c0 %8.3f c1 %8.3f c2 %8.3f\n",
-          co->Sat[pos].ID, co->Sat[pos].Clock.DeltaA0, co->Sat[pos].Clock.DeltaA1,
-          co->Sat[pos].Clock.DeltaA2);
-#endif
-        }
-        break;
-      case COBOFS_COMBINED:
-        if(!co) return GCOBR_NOCLOCKORBITPARAMETER;
-        co->messageType = type;
-        switch(s)
-        {
-        case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO:
-        case CLOCKORBIT_SATQZSS: case CLOCKORBIT_SATSBAS:
-        case CLOCKORBIT_SATBDS:
-          G_GPS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s])
-          break;
-        case CLOCKORBIT_SATGLONASS:
-          G_GLONASS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s])
-          break;
-        }
-        G_SSR_UPDATE_INTERVAL(co->UpdateInterval)
-        G_MULTIPLE_MESSAGE_INDICATOR(mmi)
-        G_SATELLITE_REFERENCE_DATUM(co->SatRefDatum)
-        G_SSR_IOD(co->SSRIOD)
-        G_SSR_PROVIDER_ID(co->SSRProviderID)
-        G_SSR_SOLUTION_ID(co->SSRSolutionID)
-        G_NO_OF_SATELLITES(nums)
-        co->Supplied[COBOFS_ORBIT] |= 1;
-        co->Supplied[COBOFS_CLOCK] |= 1;
-        for(i = 0; i < nums; ++i)
-        {
-          switch(s)
-          {
-          case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO:
-          case CLOCKORBIT_SATSBAS: case CLOCKORBIT_SATBDS:
-            G_GPS_SATELLITE_ID(id)
-            break;
-          case CLOCKORBIT_SATQZSS:
-            G_QZSS_SATELLITE_ID(id)
-            break;
-          case CLOCKORBIT_SATGLONASS:
-            G_GLONASS_SATELLITE_ID(id)
-            break;
+          break;
+        case COBOFS_COMBINED:
+          if (!co)
+            return GCOBR_NOCLOCKORBITPARAMETER;
+          co->messageType = type;
+          switch (s) {
+            case CLOCKORBIT_SATGPS:
+            case CLOCKORBIT_SATGALILEO:
+            case CLOCKORBIT_SATQZSS:
+            case CLOCKORBIT_SATSBAS:
+            case CLOCKORBIT_SATBDS:
+              G_GPS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s])
+              break;
+            case CLOCKORBIT_SATGLONASS:
+              G_GLONASS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s])
+              break;
           }
-          for(pos = satoffset[s]; pos < satoffset[s]+co->NumberOfSat[s] && co->Sat[pos].ID != id; ++pos)
-            ;
-          if(pos >= satoffset[s+1]) return GCOBR_DATAMISMATCH;
-          else if(pos == co->NumberOfSat[s] + satoffset[s]) ++co->NumberOfSat[s];
-          co->Sat[pos].ID = id;
-
-          switch(s)
-          {
-          case CLOCKORBIT_SATGPS:
-          case CLOCKORBIT_SATQZSS:
-            G_GPS_IODE(co->Sat[pos].IOD)
-            break;
-          case CLOCKORBIT_SATGLONASS:
-            G_GLONASS_IOD(co->Sat[pos].IOD)
-            break;
-          case CLOCKORBIT_SATGALILEO:
-            G_GALILEO_IOD(co->Sat[pos].IOD)
-            break;
-          case CLOCKORBIT_SATSBAS:
-            G_SBAS_T0MOD(co->Sat[pos].toe)
-            G_SBAS_IODCRC(co->Sat[pos].IOD)
-            break;
-          case CLOCKORBIT_SATBDS:
-            G_BDS_TOEMOD(co->Sat[pos].toe)
-            G_BDS_IOD(co->Sat[pos].IOD)
-            break;
+          G_SSR_UPDATE_INTERVAL(co->UpdateInterval)
+          G_MULTIPLE_MESSAGE_INDICATOR(mmi)
+          G_SATELLITE_REFERENCE_DATUM(co->SatRefDatum)
+          G_SSR_IOD(co->SSRIOD)
+          G_SSR_PROVIDER_ID(co->SSRProviderID)
+          G_SSR_SOLUTION_ID(co->SSRSolutionID)
+          G_NO_OF_SATELLITES(nums)
+          co->Supplied[COBOFS_ORBIT] |= 1;
+          co->Supplied[COBOFS_CLOCK] |= 1;
+          for (i = 0; i < nums; ++i) {
+            switch (s) {
+              case CLOCKORBIT_SATGPS:
+              case CLOCKORBIT_SATGALILEO:
+              case CLOCKORBIT_SATSBAS:
+              case CLOCKORBIT_SATBDS:
+                G_GPS_SATELLITE_ID(id)
+                break;
+              case CLOCKORBIT_SATQZSS:
+                G_QZSS_SATELLITE_ID(id)
+                break;
+              case CLOCKORBIT_SATGLONASS:
+                G_GLONASS_SATELLITE_ID(id)
+                break;
+            }
+            for (pos = satoffset[s];
+                pos < satoffset[s] + co->NumberOfSat[s] && co->Sat[pos].ID != id;
+                ++pos)
+              ;
+            if (pos >= satoffset[s + 1])
+              return GCOBR_DATAMISMATCH;
+            else if (pos == co->NumberOfSat[s] + satoffset[s])
+              ++co->NumberOfSat[s];
+            co->Sat[pos].ID = id;
+
+            switch (s) {
+              case CLOCKORBIT_SATGPS:
+                case CLOCKORBIT_SATQZSS:
+                G_GPS_IODE(co->Sat[pos].IOD)
+                break;
+              case CLOCKORBIT_SATGLONASS:
+                G_GLONASS_IOD(co->Sat[pos].IOD)
+                break;
+              case CLOCKORBIT_SATGALILEO:
+                G_GALILEO_IOD(co->Sat[pos].IOD)
+                break;
+              case CLOCKORBIT_SATSBAS:
+                G_SBAS_T0MOD(co->Sat[pos].toe)
+                G_SBAS_IODCRC(co->Sat[pos].IOD)
+                break;
+              case CLOCKORBIT_SATBDS:
+                G_BDS_TOEMOD(co->Sat[pos].toe)
+                G_BDS_IOD(co->Sat[pos].IOD)
+                break;
+            }
+            G_DELTA_RADIAL(co->Sat[pos].Orbit.DeltaRadial)
+            G_DELTA_ALONG_TRACK(co->Sat[pos].Orbit.DeltaAlongTrack)
+            G_DELTA_CROSS_TRACK(co->Sat[pos].Orbit.DeltaCrossTrack)
+            G_DELTA_DOT_RADIAL(co->Sat[pos].Orbit.DotDeltaRadial)
+            G_DELTA_DOT_ALONG_TRACK(co->Sat[pos].Orbit.DotDeltaAlongTrack)
+            G_DELTA_DOT_CROSS_TRACK(co->Sat[pos].Orbit.DotDeltaCrossTrack)
+            G_DELTA_CLOCK_C0(co->Sat[pos].Clock.DeltaA0)
+            G_DELTA_CLOCK_C1(co->Sat[pos].Clock.DeltaA1)
+            G_DELTA_CLOCK_C2(co->Sat[pos].Clock.DeltaA2)
           }
-          G_DELTA_RADIAL(co->Sat[pos].Orbit.DeltaRadial)
-          G_DELTA_ALONG_TRACK(co->Sat[pos].Orbit.DeltaAlongTrack)
-          G_DELTA_CROSS_TRACK(co->Sat[pos].Orbit.DeltaCrossTrack)
-          G_DELTA_DOT_RADIAL(co->Sat[pos].Orbit.DotDeltaRadial)
-          G_DELTA_DOT_ALONG_TRACK(co->Sat[pos].Orbit.DotDeltaAlongTrack)
-          G_DELTA_DOT_CROSS_TRACK(co->Sat[pos].Orbit.DotDeltaCrossTrack)
-          G_DELTA_CLOCK_C0(co->Sat[pos].Clock.DeltaA0)
-          G_DELTA_CLOCK_C1(co->Sat[pos].Clock.DeltaA1)
-          G_DELTA_CLOCK_C2(co->Sat[pos].Clock.DeltaA2)
-        }
-        break;
-      case COBOFS_URA:
-        if(!co) return GCOBR_NOCLOCKORBITPARAMETER;
-        co->messageType = type;
-        switch(s)
-        {
-        case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO:
-        case CLOCKORBIT_SATQZSS: case CLOCKORBIT_SATSBAS:
-        case CLOCKORBIT_SATBDS:
-          G_GPS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s])
-          break;
-        case CLOCKORBIT_SATGLONASS:
-          G_GLONASS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s])
-          break;
-        }
-        G_SSR_UPDATE_INTERVAL(co->UpdateInterval)
-        G_MULTIPLE_MESSAGE_INDICATOR(mmi)
-        G_SSR_IOD(co->SSRIOD)
-        G_SSR_PROVIDER_ID(co->SSRProviderID)
-        G_SSR_SOLUTION_ID(co->SSRSolutionID)
-        G_NO_OF_SATELLITES(nums)
-        co->Supplied[COBOFS_URA] |= 1;
-        for(i = 0; i < nums; ++i)
-        {
-          switch(s)
-          {
-          case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO:
-          case CLOCKORBIT_SATSBAS: case CLOCKORBIT_SATBDS:
-            G_GPS_SATELLITE_ID(id)
-            break;
-          case CLOCKORBIT_SATQZSS:
-            G_QZSS_SATELLITE_ID(id)
-            break;
-          case CLOCKORBIT_SATGLONASS:
-            G_GLONASS_SATELLITE_ID(id)
-            break;
+          break;
+        case COBOFS_URA:
+          if (!co)
+            return GCOBR_NOCLOCKORBITPARAMETER;
+          co->messageType = type;
+          switch (s) {
+            case CLOCKORBIT_SATGPS:
+            case CLOCKORBIT_SATGALILEO:
+            case CLOCKORBIT_SATQZSS:
+            case CLOCKORBIT_SATSBAS:
+            case CLOCKORBIT_SATBDS:
+              G_GPS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s])
+              break;
+            case CLOCKORBIT_SATGLONASS:
+              G_GLONASS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s])
+              break;
           }
-          for(pos = satoffset[s]; pos < satoffset[s]+co->NumberOfSat[s] && co->Sat[pos].ID != id; ++pos)
-            ;
-          if(pos >= satoffset[s+1]) return GCOBR_DATAMISMATCH;
-          else if(pos == co->NumberOfSat[s] + satoffset[s]) ++co->NumberOfSat[s];
-          co->Sat[pos].ID = id;
-
-          G_SSR_URA(co->Sat[pos].UserRangeAccuracy)
-        }
-        break;
-      case COBOFS_HR:
-        if(!co) return GCOBR_NOCLOCKORBITPARAMETER;
-        co->messageType = type;
-        switch(s)
-        {
-        case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO:
-        case CLOCKORBIT_SATQZSS: case CLOCKORBIT_SATSBAS:
-        case CLOCKORBIT_SATBDS:
-          G_GPS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s])
-          break;
-        case CLOCKORBIT_SATGLONASS:
-          G_GLONASS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s])
-          break;
-        }
-        G_SSR_UPDATE_INTERVAL(co->UpdateInterval)
-        G_MULTIPLE_MESSAGE_INDICATOR(mmi)
-        G_SSR_IOD(co->SSRIOD)
-        G_SSR_PROVIDER_ID(co->SSRProviderID)
-        G_SSR_SOLUTION_ID(co->SSRSolutionID)
-        G_NO_OF_SATELLITES(nums)
-        co->Supplied[COBOFS_HR] |= 1;
-        for(i = 0; i < nums; ++i)
-        {
-          switch(s)
-          {
-          case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO:
-          case CLOCKORBIT_SATSBAS: case CLOCKORBIT_SATBDS:
-            G_GPS_SATELLITE_ID(id)
-            break;
-          case CLOCKORBIT_SATQZSS:
-            G_QZSS_SATELLITE_ID(id)
-            break;
-          case CLOCKORBIT_SATGLONASS:
-            G_GLONASS_SATELLITE_ID(id)
-            break;
+          G_SSR_UPDATE_INTERVAL(co->UpdateInterval)
+          G_MULTIPLE_MESSAGE_INDICATOR(mmi)
+          G_SSR_IOD(co->SSRIOD)
+          G_SSR_PROVIDER_ID(co->SSRProviderID)
+          G_SSR_SOLUTION_ID(co->SSRSolutionID)
+          G_NO_OF_SATELLITES(nums)
+          co->Supplied[COBOFS_URA] |= 1;
+          for (i = 0; i < nums; ++i) {
+            switch (s) {
+              case CLOCKORBIT_SATGPS:
+              case CLOCKORBIT_SATGALILEO:
+              case CLOCKORBIT_SATSBAS:
+              case CLOCKORBIT_SATBDS:
+                G_GPS_SATELLITE_ID(id)
+                break;
+              case CLOCKORBIT_SATQZSS:
+                G_QZSS_SATELLITE_ID(id)
+                break;
+              case CLOCKORBIT_SATGLONASS:
+                G_GLONASS_SATELLITE_ID(id)
+                break;
+            }
+            for (pos = satoffset[s];
+                pos < satoffset[s] + co->NumberOfSat[s] && co->Sat[pos].ID != id;
+                ++pos)
+              ;
+            if (pos >= satoffset[s + 1])
+              return GCOBR_DATAMISMATCH;
+            else if (pos == co->NumberOfSat[s] + satoffset[s])
+              ++co->NumberOfSat[s];
+            co->Sat[pos].ID = id;
+
+            G_SSR_URA(co->Sat[pos].UserRangeAccuracy)
           }
-          for(pos = satoffset[s]; pos < satoffset[s]+co->NumberOfSat[s] && co->Sat[pos].ID != id; ++pos)
-            ;
-          if(pos >= satoffset[s+1]) return GCOBR_DATAMISMATCH;
-          else if(pos == co->NumberOfSat[s] + satoffset[s]) ++co->NumberOfSat[s];
-          co->Sat[pos].ID = id;
-
-          G_HR_CLOCK_CORRECTION(co->Sat[pos].hrclock)
-        }
-        break;
-      case COBOFS_BIAS:
-        if(!b) return GCOBR_NOCODEBIASPARAMETER;
-        b->messageType = type;
-        switch(s)
-        {
-        case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO:
-        case CLOCKORBIT_SATQZSS: case CLOCKORBIT_SATSBAS:
-        case CLOCKORBIT_SATBDS:
-          G_GPS_EPOCH_TIME(b->EpochTime[s], b->NumberOfSat[s])
-          break;
-        case CLOCKORBIT_SATGLONASS:
-          G_GLONASS_EPOCH_TIME(b->EpochTime[s], b->NumberOfSat[s])
-          break;
-        }
-        G_SSR_UPDATE_INTERVAL(b->UpdateInterval)
-        G_MULTIPLE_MESSAGE_INDICATOR(mmi)
-        G_SSR_IOD(b->SSRIOD)
-        G_SSR_PROVIDER_ID(b->SSRProviderID)
-        G_SSR_SOLUTION_ID(b->SSRSolutionID)
-        G_NO_OF_SATELLITES(nums)
-        for(i = 0; i < nums; ++i)
-        {
-          switch(s)
-          {
-          case CLOCKORBIT_SATGPS: case CLOCKORBIT_SATGALILEO:
-          case CLOCKORBIT_SATSBAS: case CLOCKORBIT_SATBDS:
-            G_GPS_SATELLITE_ID(id)
-            break;
-          case CLOCKORBIT_SATQZSS:
-            G_QZSS_SATELLITE_ID(id)
-            break;
-          case CLOCKORBIT_SATGLONASS:
-            G_GLONASS_SATELLITE_ID(id)
-            break;
+          break;
+        case COBOFS_HR:
+          if (!co)
+            return GCOBR_NOCLOCKORBITPARAMETER;
+          co->messageType = type;
+          switch (s) {
+            case CLOCKORBIT_SATGPS:
+            case CLOCKORBIT_SATGALILEO:
+            case CLOCKORBIT_SATQZSS:
+            case CLOCKORBIT_SATSBAS:
+            case CLOCKORBIT_SATBDS:
+              G_GPS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s])
+              break;
+            case CLOCKORBIT_SATGLONASS:
+              G_GLONASS_EPOCH_TIME(co->EpochTime[s], co->NumberOfSat[s])
+              break;
           }
-          for(pos = satoffset[s]; pos < satoffset[s]+b->NumberOfSat[s] && b->Sat[pos].ID != id; ++pos)
-            ;
-          if(pos >= satoffset[s+1]) return GCOBR_DATAMISMATCH;
-          else if(pos == b->NumberOfSat[s] + satoffset[s]) ++b->NumberOfSat[s];
-          b->Sat[pos].ID = id;
-
-          G_NO_OF_CODE_BIASES(b->Sat[pos].NumberOfCodeBiases)
-          for(j = 0; j < b->Sat[pos].NumberOfCodeBiases; ++j)
-          {
-            G_SIGNAL_IDENTIFIER(b->Sat[pos].Biases[j].Type)
-            G_CODE_BIAS(b->Sat[pos].Biases[j].Bias)
+          G_SSR_UPDATE_INTERVAL(co->UpdateInterval)
+          G_MULTIPLE_MESSAGE_INDICATOR(mmi)
+          G_SSR_IOD(co->SSRIOD)
+          G_SSR_PROVIDER_ID(co->SSRProviderID)
+          G_SSR_SOLUTION_ID(co->SSRSolutionID)
+          G_NO_OF_SATELLITES(nums)
+          co->Supplied[COBOFS_HR] |= 1;
+          for (i = 0; i < nums; ++i) {
+            switch (s) {
+              case CLOCKORBIT_SATGPS:
+              case CLOCKORBIT_SATGALILEO:
+              case CLOCKORBIT_SATSBAS:
+              case CLOCKORBIT_SATBDS:
+                G_GPS_SATELLITE_ID(id)
+                break;
+              case CLOCKORBIT_SATQZSS:
+                G_QZSS_SATELLITE_ID(id)
+                break;
+              case CLOCKORBIT_SATGLONASS:
+                G_GLONASS_SATELLITE_ID(id)
+                break;
+            }
+            for (pos = satoffset[s];
+                pos < satoffset[s] + co->NumberOfSat[s] && co->Sat[pos].ID != id;
+                ++pos)
+              ;
+            if (pos >= satoffset[s + 1])
+              return GCOBR_DATAMISMATCH;
+            else if (pos == co->NumberOfSat[s] + satoffset[s])
+              ++co->NumberOfSat[s];
+            co->Sat[pos].ID = id;
+            G_HR_CLOCK_CORRECTION(co->Sat[pos].hrclock)
           }
-        }
-        break;
-      default:
-        continue;
+          break;
+        case COBOFS_BIAS:
+          if (!b)
+            return GCOBR_NOCODEBIASPARAMETER;
+          b->messageType = type;
+          switch (s) {
+            case CLOCKORBIT_SATGPS:
+            case CLOCKORBIT_SATGALILEO:
+            case CLOCKORBIT_SATQZSS:
+            case CLOCKORBIT_SATSBAS:
+            case CLOCKORBIT_SATBDS:
+              G_GPS_EPOCH_TIME(b->EpochTime[s], b->NumberOfSat[s])
+              break;
+            case CLOCKORBIT_SATGLONASS:
+              G_GLONASS_EPOCH_TIME(b->EpochTime[s], b->NumberOfSat[s])
+              break;
+          }
+          G_SSR_UPDATE_INTERVAL(b->UpdateInterval)
+          G_MULTIPLE_MESSAGE_INDICATOR(mmi)
+          G_SSR_IOD(b->SSRIOD)
+          G_SSR_PROVIDER_ID(b->SSRProviderID)
+          G_SSR_SOLUTION_ID(b->SSRSolutionID)
+          G_NO_OF_SATELLITES(nums)
+          for (i = 0; i < nums; ++i) {
+            switch (s) {
+              case CLOCKORBIT_SATGPS:
+              case CLOCKORBIT_SATGALILEO:
+              case CLOCKORBIT_SATSBAS:
+              case CLOCKORBIT_SATBDS:
+                G_GPS_SATELLITE_ID(id)
+                break;
+              case CLOCKORBIT_SATQZSS:
+                G_QZSS_SATELLITE_ID(id)
+                break;
+              case CLOCKORBIT_SATGLONASS:
+                G_GLONASS_SATELLITE_ID(id)
+                break;
+            }
+            for (pos = satoffset[s];
+                pos < satoffset[s] + b->NumberOfSat[s] && b->Sat[pos].ID != id;
+                ++pos)
+              ;
+            if (pos >= satoffset[s + 1])
+              return GCOBR_DATAMISMATCH;
+            else if (pos == b->NumberOfSat[s] + satoffset[s])
+              ++b->NumberOfSat[s];
+            b->Sat[pos].ID = id;
+
+            G_NO_OF_CODE_BIASES(b->Sat[pos].NumberOfCodeBiases)
+            for (j = 0; j < b->Sat[pos].NumberOfCodeBiases; ++j) {
+              G_SIGNAL_IDENTIFIER(b->Sat[pos].Biases[j].Type)
+              G_CODE_BIAS(b->Sat[pos].Biases[j].Bias)
+            }
+          }
+          break;
+        default:
+          continue;
       }
 #ifdef COR_LATENCY
-      if(s == CLOCKORBIT_SATGPS && type-corbase[s] != COBOFS_BIAS)
-      {
+      if(s == CLOCKORBIT_SATGPS && type-corbase[s] != COBOFS_BIAS) {
         co->epochGPS[co->epochSize] = co->EpochTime[s];
         if(co->epochSize < COR_LATENCYCOUNT)
-          ++co->epochSize;
+        ++co->epochSize;
       }
 #endif
 #ifdef DEBUG
       for(type = 0; type < (int)size && (unsigned char)buffer[type] != 0xD3; ++type)
-        numbits += 8;
+      numbits += 8;
       fprintf(stderr, "numbits left %d\n",numbits);
 #endif
