summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am12
-rw-r--r--NEWS2
-rw-r--r--Tachometer.c779
-rw-r--r--cgps.c6
-rw-r--r--driver_evermore.c2
-rw-r--r--driver_garmin.c86
-rw-r--r--driver_italk.c15
-rw-r--r--driver_navcom.c11
-rw-r--r--driver_sirf.c7
-rw-r--r--driver_tsip.c26
-rw-r--r--driver_ubx.c10
-rw-r--r--driver_zodiac.c4
-rw-r--r--gpsd.c52
-rw-r--r--json.c4
-rw-r--r--libgpsd_core.c4
-rw-r--r--subframe.c33
-rw-r--r--test_packet.c15
-rw-r--r--xgpsspeed.c96
-rw-r--r--xgpsspeed.icon62
19 files changed, 639 insertions, 587 deletions
diff --git a/Makefile.am b/Makefile.am
index f09a4d04..a506e27d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -84,9 +84,7 @@ endif
#
xgpsspeed_c_sources = \
xgpsspeed.c \
- Tachometer.c \
- TachometerP.h \
- Tachometer.h
+ Tachometer.c
xgpsspeed_SOURCES = \
$(xgpsspeed_c_sources) \
xgpsspeed.icon
@@ -417,8 +415,7 @@ endif
noinst_HEADERS = gpsd_config.h \
driver_italk.h driver_rtcm2.h driver_superstar2.h \
driver_ubx.h gpsmon.h gpsdclient.h json.h gps_json.h \
- revision.h
-
+ revision.h TachometerP.h Tachometer.h
nodist_include_HEADERS = gpsd.h
if LIBGPSMM_ENABLE
@@ -546,11 +543,10 @@ splint: gpsd.h packet_names.h
cppcheck: gpsd.h packet_names.h
cppcheck --template gcc --all --force .
-# Re-indent the codebase in aa uniform style for readability.
-# FIXME: Except for xgpsspeed - Tachometer.c makes GNU indent lose it.
+# Re-indent the codebase in a uniform style for readability.
INDENT_FILES = $(gpsd_c_sources) $(libgpsd_c_sources) $(libgps_c_sources) \
$(cgps_SOURCES) $(gpsmon_SOURCES) $(gpspipe_SOURCES) \
- $(gpxlogger_SOURCES) $(gpsdecode_SOURCES) \
+ $(xgpsspeed_SOURCES) $(gpxlogger_SOURCES) $(gpsdecode_SOURCES) \
$(test_bits_SOURCES) $(test_packet_SOURCES) \
$(test_mkgmtime_SOURCES) $(test_geoid_SOURCES) $(test_json_SOURCES)
INDENT_OPTIONS = --indent-level4 \
diff --git a/NEWS b/NEWS
index 204b06ce..1104ff9b 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,4 @@
-* Mon Apr 26 2010 Eric S. Raymond <esr@snark.thyrsus.com> - 2.95
+* Mon Apr 26 2010 Eric S. Raymond <esr@snark.thyrsus.com> - 2.95~dev
Rationalize clearing and generation of DOPs, this makes epx/epy
much more generally available. Fixed the test productions for
the udev magic and added a troubleshooting note in INSTALL. cgps
diff --git a/Tachometer.c b/Tachometer.c
index c453f9f5..5e913527 100644
--- a/Tachometer.c
+++ b/Tachometer.c
@@ -18,7 +18,7 @@
#include "gpsd_config.h"
#include "gps.h"
-#define D2R 0.0174532925199432957692369076848861271 /* radians = pi/180 */
+#define D2R 0.0174532925199432957692369076848861271 /* radians = pi/180 */
/****************************************************************
*
@@ -26,56 +26,62 @@
*
****************************************************************/
-typedef struct {
- unsigned char digit[7];
- } DigitRec;
+typedef struct
+{
+ unsigned char digit[7];
+} DigitRec;
-typedef struct {
- int nofline;
- XPoint point_list[5];
- } StringRec;
+typedef struct
+{
+ int nofline;
+ XPoint point_list[5];
+} StringRec;
/*@ +charint @*/
/* Number character database - like an LED */
static DigitRec num_segment[] = {
- {{1,1,1,1,1,1,0}},
- {{0,1,1,0,0,0,0}},
- {{1,1,0,1,1,0,1}},
- {{1,1,1,1,0,0,1}},
- {{0,1,1,0,0,1,1}},
- {{1,0,1,1,0,1,1}},
- {{1,0,1,1,1,1,1}},
- {{1,1,1,0,0,0,0}},
- {{1,1,1,1,1,1,1}},
- {{1,1,1,1,0,1,1}}};
-
-static XSegment offset[] = {
- {-10,-10, 10,-10},
- { 10,-10, 10, 0},
- { 10, 0, 10, 10},
- { 10, 10,-10, 10},
- {-10, 10,-10, 0},
- {-10, 0,-10,-10},
- {-10, 0, 10, 0}};
+ {{1, 1, 1, 1, 1, 1, 0}},
+ {{0, 1, 1, 0, 0, 0, 0}},
+ {{1, 1, 0, 1, 1, 0, 1}},
+ {{1, 1, 1, 1, 0, 0, 1}},
+ {{0, 1, 1, 0, 0, 1, 1}},
+ {{1, 0, 1, 1, 0, 1, 1}},
+ {{1, 0, 1, 1, 1, 1, 1}},
+ {{1, 1, 1, 0, 0, 0, 0}},
+ {{1, 1, 1, 1, 1, 1, 1}},
+ {{1, 1, 1, 1, 0, 1, 1}}
+};
+
+static XSegment offset[] = {
+ {-10, -10, 10, -10},
+ {10, -10, 10, 0},
+ {10, 0, 10, 10},
+ {10, 10, -10, 10},
+ {-10, 10, -10, 0},
+ {-10, 0, -10, -10},
+ {-10, 0, 10, 0}
+};
/*@ -initallelements @*/
/* " X 10 %" character database */
-static StringRec char_data[] = {
- { 2, /* "X" */
- {{-17, -5},
- {-7, 5}}},
- { 2,
- {{-7, -5},
- {-17, 5}}},
- { 2, /* "1" */
- {{-2, -5},
- {-2, 5}}},
- { 5, /* "0" */
- {{2, -5},
- {12, -5},
- {12, 5},
- {2, 5},
- {2, -5}}}};
+static StringRec char_data[] = {
+ {2, /* "X" */
+ {{-17, -5},
+ {-7, 5}}},
+ {2,
+ {{-7, -5},
+ {-17, 5}}},
+ {2, /* "1" */
+ {{-2, -5},
+ {-2, 5}}},
+ {5, /* "0" */
+ {{2, -5},
+ {12, -5},
+ {12, 5},
+ {2, 5},
+ {2, -5}}}
+};
+
/*@ -initallelements @*/
/*@ -charint @*/
@@ -83,400 +89,423 @@ static StringRec char_data[] = {
#define offst(field) XtOffset(TachometerWidget, field)
static XtResource resources[] = {
{XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
- offst(tachometer.scale), XtRString, "XtDefaultForeground"},
+ offst(tachometer.scale), XtRString, "XtDefaultForeground"}
+ ,
{XtNtachometerCircleColor, XtCBorderColor, XtRPixel, sizeof(Pixel),
- offst(tachometer.circle), XtRString, "XtDefaultForeground"},
+ offst(tachometer.circle), XtRString, "XtDefaultForeground"}
+ ,
{XtNtachometerNeedleColor, XtCBorderColor, XtRPixel, sizeof(Pixel),
- offst(tachometer.needle), XtRString, "XtDefaultForeground"},
+ offst(tachometer.needle), XtRString, "XtDefaultForeground"}
+ ,
{XtNtachometerNeedleSpeed, XtCtachometerNeedleSpeed, XtRInt,
- sizeof(int), offst(tachometer.speed), XtRImmediate, (caddr_t) 1},
+ sizeof(int), offst(tachometer.speed), XtRImmediate, (caddr_t) 1},
{XtNvalue, XtCValue, XtRInt, sizeof(int),
- offst(tachometer.value), XtRImmediate, (caddr_t) 0},
+ offst(tachometer.value), XtRImmediate, (caddr_t) 0},
{XtNheight, XtCHeight, XtRDimension, sizeof(Dimension),
- offst(core.height), XtRImmediate, (caddr_t) 100},
+ offst(core.height), XtRImmediate, (caddr_t) 100}
+ ,
{XtNwidth, XtCWidth, XtRDimension, sizeof(Dimension),
- offst(core.width), XtRImmediate, (caddr_t) 100},
+ offst(core.width), XtRImmediate, (caddr_t) 100}
+ ,
{XtNborderWidth, XtCBorderWidth, XtRDimension, sizeof(Dimension),
- offst(core.border_width), XtRImmediate, (caddr_t) 0},
+ offst(core.border_width), XtRImmediate, (caddr_t) 0}
+ ,
{XtNinternalBorderWidth, XtCBorderWidth, XtRDimension, sizeof(Dimension),
- offst(tachometer.internal_border), XtRImmediate, (caddr_t) 0},
+ offst(tachometer.internal_border), XtRImmediate, (caddr_t) 0}
+ ,
};
+
/*@ -nullderef -immediatetrans +type +nullassign @*/
static void Initialize(Widget request, Widget new),
- Realize(Widget w, Mask *valueMask, XSetWindowAttributes *attributes),
- Resize(Widget w), Redisplay(Widget w, XEvent *event, Region region),
- Destroy(Widget w);
+Realize(Widget w, Mask * valueMask, XSetWindowAttributes * attributes),
+Resize(Widget w), Redisplay(Widget w, XEvent * event, Region region),
+Destroy(Widget w);
static Boolean SetValues(Widget current, Widget request UNUSED, Widget new);
/*@ -fullinitblock @*/
TachometerClassRec tachometerClassRec = {
- {
-/* core_class fields */
+ {
+/* core_class fields */
#define superclass (&simpleClassRec)
- /* superclass */ (WidgetClass) superclass,
- /* class_name */ "Tachometer",
- /* widget_size */ sizeof(TachometerRec),
- /* class_initialize */ NULL,
- /* class_part_initialize */ NULL,
- /* class_inited */ FALSE,
- /* initialize */ (XtInitProc) Initialize,
- /* initialize_hook */ NULL,
- /* realize */ Realize,
- /* actions */ NULL,
- /* num_actions */ 0,
- /* resources */ resources,
- /* num_resources */ XtNumber(resources),
- /* xrm_class */ NULLQUARK,
- /* compress_motion */ TRUE,
- /* compress_exposure */ TRUE,
- /* compress_enterleave */ TRUE,
- /* visible_interest */ FALSE,
- /* destroy */ Destroy,
- /* resize */ Resize,
- /* expose */ Redisplay,
- /* set_values */ (XtSetValuesFunc) SetValues,
- /* set_values_hook */ NULL,
- /* set_values_almost */ XtInheritSetValuesAlmost,
- /* get_values_hook */ NULL,
- /* accept_focus */ NULL,
- /* version */ XtVersion,
- /* callback_private */ NULL,
- /* tm_table */ NULL,
- /* query_geometry */ NULL,
- /* display_accelerator */ XtInheritDisplayAccelerator,
- /* extension */ NULL
- },
+ /* superclass */ (WidgetClass) superclass,
+ /* class_name */ "Tachometer",
+ /* widget_size */ sizeof(TachometerRec),
+ /* class_initialize */ NULL,
+ /* class_part_initialize */ NULL,
+ /* class_inited */ FALSE,
+ /* initialize */ (XtInitProc) Initialize,
+ /* initialize_hook */ NULL,
+ /* realize */ Realize,
+ /* actions */ NULL,
+ /* num_actions */ 0,
+ /* resources */ resources,
+ /* num_resources */ XtNumber(resources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ TRUE,
+ /* compress_exposure */ TRUE,
+ /* compress_enterleave */ TRUE,
+ /* visible_interest */ FALSE,
+ /* destroy */ Destroy,
+ /* resize */ Resize,
+ /* expose */ Redisplay,
+ /* set_values */ (XtSetValuesFunc) SetValues,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ XtInheritSetValuesAlmost,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ NULL,
+ /* version */ XtVersion,
+ /* callback_private */ NULL,
+ /* tm_table */ NULL,
+ /* query_geometry */ NULL,
+ /* display_accelerator */ XtInheritDisplayAccelerator,
+ /* extension */ NULL
+ }
+ ,
/* Simple class fields initialization */
- {
- /* change_sensitive */ XtInheritChangeSensitive
- }
+ {
+ /* change_sensitive */ XtInheritChangeSensitive
+ }
};
+
/*@ +fullinitblock @*/
-WidgetClass tachometerWidgetClass = (WidgetClass)&tachometerClassRec;
+WidgetClass tachometerWidgetClass = (WidgetClass) & tachometerClassRec;
/* Private procedures */
-static void FastFillCircle(
- Display *d, Drawable w, GC gc,
- Cardinal center_x, Cardinal center_y, Cardinal radius_x, Cardinal radius_y)
+static void FastFillCircle(Display * d, Drawable w, GC gc,
+ Cardinal center_x, Cardinal center_y,
+ Cardinal radius_x, Cardinal radius_y)
{
/*@ -compdef @*/
- XPoint points[360];
- Cardinal angle;
-
- for (angle = 0; angle < 360; angle++) {
- points[angle].x = (short) (sin((double) angle * D2R) *
- (double) radius_x + (double) center_x);
- points[angle].y = (short) (cos((double) angle * D2R) *
- (double) radius_y + (double) center_y);
- }
- (void)XFillPolygon(d, w, gc, points, 360, Complex, CoordModeOrigin);
+ XPoint points[360];
+ Cardinal angle;
+
+ for (angle = 0; angle < 360; angle++) {
+ points[angle].x = (short)(sin((double)angle * D2R) *
+ (double)radius_x + (double)center_x);
+ points[angle].y = (short)(cos((double)angle * D2R) *
+ (double)radius_y + (double)center_y);
+ }
+ (void)XFillPolygon(d, w, gc, points, 360, Complex, CoordModeOrigin);
/*@ +compdef @*/
}
-static void DrawSingleNumber(TachometerWidget w, int which, Cardinal x, Cardinal y)
+static void DrawSingleNumber(TachometerWidget w, int which, Cardinal x,
+ Cardinal y)
{
- XSegment segments[7];
- Cardinal nsegments, width, height, count;
-
- width = (Cardinal)((w->core.width / 2) - w->tachometer.internal_border);
- height = (Cardinal)((w->core.height / 2) - w->tachometer.internal_border);
- if ((width == 0) || (height == 0))
- return;
-
- /*@ +charint -compdef */
- for (count = 0, nsegments = 0; count < 7; count++)
- if (num_segment[which].digit[count] == 1) {
- segments[nsegments].x1 = (short)
- (x + ((double)offset[count].x1 * ((double)width/200.0)));
- segments[nsegments].y1 = (short)
- (y + ((double)offset[count].y1 * ((double)height/200.0)));
- segments[nsegments].x2 = (short)
- (x + ((double)offset[count].x2 * ((double)width/200.0)));
- segments[nsegments].y2 = (short)
- (y + ((double)offset[count].y2 * ((double)height/200.0)));
- nsegments++;
- }
-
- (void)XDrawSegments(XtDisplay(w), XtWindow(w),
- w->tachometer.scale_GC, segments, (int)nsegments);
- /*@ -charint +compdef */
+ XSegment segments[7];
+ Cardinal nsegments, width, height, count;
+
+ width = (Cardinal) ((w->core.width / 2) - w->tachometer.internal_border);
+ height =
+ (Cardinal) ((w->core.height / 2) - w->tachometer.internal_border);
+ if ((width == 0) || (height == 0))
+ return;
+
+ /*@ +charint -compdef */
+ for (count = 0, nsegments = 0; count < 7; count++)
+ if (num_segment[which].digit[count] == 1) {
+ segments[nsegments].x1 = (short)
+ (x + ((double)offset[count].x1 * ((double)width / 200.0)));
+ segments[nsegments].y1 = (short)
+ (y + ((double)offset[count].y1 * ((double)height / 200.0)));
+ segments[nsegments].x2 = (short)
+ (x + ((double)offset[count].x2 * ((double)width / 200.0)));
+ segments[nsegments].y2 = (short)
+ (y + ((double)offset[count].y2 * ((double)height / 200.0)));
+ nsegments++;
+ }
+
+ (void)XDrawSegments(XtDisplay(w), XtWindow(w),
+ w->tachometer.scale_GC, segments, (int)nsegments);
+ /*@ -charint +compdef */
}
static void DrawNumbers(TachometerWidget w, int which, Cardinal x, Cardinal y)
{
- if (which == 10) {
- DrawSingleNumber(w, 1, (Cardinal) ((double) x * 0.9), y);
- DrawSingleNumber(w, 0, x, y);
- } else
- DrawSingleNumber(w, which, x, y);
+ if (which == 10) {
+ DrawSingleNumber(w, 1, (Cardinal) ((double)x * 0.9), y);
+ DrawSingleNumber(w, 0, x, y);
+ } else
+ DrawSingleNumber(w, which, x, y);
}
static void DrawLabelString(TachometerWidget w)
{
- XPoint points[5];
- int char_count, data_count;
- Cardinal ry, center_x, center_y, radius_x, radius_y;
- GC gc;
-
- center_x = (Cardinal)(w->core.width / 2);
- center_y = (Cardinal)(w->core.height / 2);
- radius_x = center_x - w->tachometer.internal_border;
- radius_y = center_y - w->tachometer.internal_border;
- if (!(center_x != 0 && center_y != 0 && (radius_x > 0) && (radius_y > 0)))
- return;
-
- ry = (Cardinal)(radius_y * 0.35 + center_y);
- gc = w->tachometer.scale_GC;
- /*@ -compdef @*/
- for (char_count = 0; char_count < 4; char_count++) {
- for (data_count = 0; data_count < char_data[char_count].nofline
- ; data_count++) {
- points[data_count].x = (short)
- ((char_data[char_count].point_list[data_count].x) *
- (double) radius_x * 0.01 + center_x);
- points[data_count].y = (short)
- ((char_data[char_count].point_list[data_count].y) *
- (double) radius_y * 0.01 + ry);
- }
- (void)XDrawLines(XtDisplay(w), XtWindow(w), gc, points,
- char_data[char_count].nofline, CoordModeOrigin);
- }
- /*@ +compdef @*/
+ XPoint points[5];
+ int char_count, data_count;
+ Cardinal ry, center_x, center_y, radius_x, radius_y;
+ GC gc;
+
+ center_x = (Cardinal) (w->core.width / 2);
+ center_y = (Cardinal) (w->core.height / 2);
+ radius_x = center_x - w->tachometer.internal_border;
+ radius_y = center_y - w->tachometer.internal_border;
+ if (!(center_x != 0 && center_y != 0 && (radius_x > 0) && (radius_y > 0)))
+ return;
+
+ ry = (Cardinal) (radius_y * 0.35 + center_y);
+ gc = w->tachometer.scale_GC;
+ /*@ -compdef @*/
+ for (char_count = 0; char_count < 4; char_count++) {
+ for (data_count = 0; data_count < char_data[char_count].nofline;
+ data_count++) {
+ points[data_count].x = (short)
+ ((char_data[char_count].point_list[data_count].x) *
+ (double)radius_x * 0.01 + center_x);
+ points[data_count].y = (short)
+ ((char_data[char_count].point_list[data_count].y) *
+ (double)radius_y * 0.01 + ry);
+ }
+ (void)XDrawLines(XtDisplay(w), XtWindow(w), gc, points,
+ char_data[char_count].nofline, CoordModeOrigin);
+ }
+ /*@ +compdef @*/
}
static void DrawGauge(TachometerWidget w)
{
- XPoint points[4];
- Cardinal in_gauge_x, in_gauge_y, out_gauge_x, out_gauge_y;
- Cardinal number_x, number_y, center_x, center_y, radius_x, radius_y;
- GC gc;
- double step, jump = 1.0;
-
- /*@ -type -unsignedcompare -compdef @*/
- center_x = w->core.width / 2; center_y = w->core.height / 2;
- radius_x = center_x - w->tachometer.internal_border;
- radius_y = center_y - w->tachometer.internal_border;
- if ((center_x==0) || (center_y==0) || (radius_x<=0) || (radius_y<=0))
- return; /* Can't draw anything */
-
- gc = w->tachometer.scale_GC;
- for (step = 330.0; step >= 30.0; step -= jump) {
- if ((Cardinal) (step) % 30 == 0) {
- points[0].x = sin((step + 1.0)*D2R) * radius_x*0.75 + center_x;
- points[0].y = cos((step + 1.0)*D2R) * radius_y*0.75 + center_y;
- points[1].x = sin((step - 1.0)*D2R) * radius_x*0.75 + center_x;
- points[1].y = cos((step - 1.0)*D2R) * radius_y*0.75 + center_y;
- points[2].x = sin((step - 1.0)*D2R) * radius_x*0.85 + center_x;
- points[2].y = cos((step - 1.0)*D2R) * radius_y*0.85 + center_y;
- points[3].x = sin((step + 1.0)*D2R) * radius_x*0.85 + center_x;
- points[3].y = cos((step + 1.0)*D2R) * radius_y*0.85 + center_y;
- (void)XFillPolygon(XtDisplay(w), XtWindow(w), gc, points, 4,
- Complex, CoordModeOrigin);
-
- number_x = sin((step + 1.0)*D2R) * radius_x*0.65 + center_x;
- number_y = cos((step + 1.0)*D2R) * radius_y*0.65 + center_y;
- if ((int)((330.0 - step) / 30.0) == 1)
- jump = 3.0;
- DrawNumbers(w, (unsigned char) ((330.0 - step) / 30.0),
- number_x, number_y);
- } else {
- in_gauge_x = sin(step * D2R) * radius_x * 0.8 + center_x;
- in_gauge_y = cos(step * D2R) * radius_y * 0.8 + center_y;
- out_gauge_x = sin(step * D2R) * radius_x * 0.85 + center_x;
- out_gauge_y = cos(step * D2R) * radius_y * 0.85 + center_y;
- (void)XDrawLine(XtDisplay(w), XtWindow(w), gc, in_gauge_x,
- in_gauge_y, out_gauge_x, out_gauge_y);
- }
- }
- /*@ +type +unsignedcompare +compdef @*/
-
- DrawLabelString(w);
+ XPoint points[4];
+ Cardinal in_gauge_x, in_gauge_y, out_gauge_x, out_gauge_y;
+ Cardinal number_x, number_y, center_x, center_y, radius_x, radius_y;
+ GC gc;
+ double step, jump = 1.0;
+
+ /*@ -type -unsignedcompare -compdef @*/
+ center_x = w->core.width / 2;
+ center_y = w->core.height / 2;
+ radius_x = center_x - w->tachometer.internal_border;
+ radius_y = center_y - w->tachometer.internal_border;
+ if ((center_x == 0) || (center_y == 0) || (radius_x <= 0)
+ || (radius_y <= 0))
+ return; /* Can't draw anything */
+
+ gc = w->tachometer.scale_GC;
+ for (step = 330.0; step >= 30.0; step -= jump) {
+ if ((Cardinal) (step) % 30 == 0) {
+ points[0].x =
+ sin((step + 1.0) * D2R) * radius_x * 0.75 + center_x;
+ points[0].y =
+ cos((step + 1.0) * D2R) * radius_y * 0.75 + center_y;
+ points[1].x =
+ sin((step - 1.0) * D2R) * radius_x * 0.75 + center_x;
+ points[1].y =
+ cos((step - 1.0) * D2R) * radius_y * 0.75 + center_y;
+ points[2].x =
+ sin((step - 1.0) * D2R) * radius_x * 0.85 + center_x;
+ points[2].y =
+ cos((step - 1.0) * D2R) * radius_y * 0.85 + center_y;
+ points[3].x =
+ sin((step + 1.0) * D2R) * radius_x * 0.85 + center_x;
+ points[3].y =
+ cos((step + 1.0) * D2R) * radius_y * 0.85 + center_y;
+ (void)XFillPolygon(XtDisplay(w), XtWindow(w), gc, points, 4,
+ Complex, CoordModeOrigin);
+
+ number_x = sin((step + 1.0) * D2R) * radius_x * 0.65 + center_x;
+ number_y = cos((step + 1.0) * D2R) * radius_y * 0.65 + center_y;
+ if ((int)((330.0 - step) / 30.0) == 1)
+ jump = 3.0;
+ DrawNumbers(w, (unsigned char)((330.0 - step) / 30.0),
+ number_x, number_y);
+ } else {
+ in_gauge_x = sin(step * D2R) * radius_x * 0.8 + center_x;
+ in_gauge_y = cos(step * D2R) * radius_y * 0.8 + center_y;
+ out_gauge_x = sin(step * D2R) * radius_x * 0.85 + center_x;
+ out_gauge_y = cos(step * D2R) * radius_y * 0.85 + center_y;
+ (void)XDrawLine(XtDisplay(w), XtWindow(w), gc, in_gauge_x,
+ in_gauge_y, out_gauge_x, out_gauge_y);
+ }
+ }
+ /*@ +type +unsignedcompare +compdef @*/
+
+ DrawLabelString(w);
}
static void DrawNeedle(TachometerWidget w, int load)
{
- XPoint points[6];
- double cur_theta1, cur_theta2, cur_theta3, cur_theta4, cur_theta5;
- Cardinal center_x, center_y, radius_x, radius_y;
-
- /*@ -type -unsignedcompare -compdef @*/
- center_x = w->core.width / 2; center_y = w->core.height / 2;
- radius_x = center_x - w->tachometer.internal_border;
- radius_y = center_y - w->tachometer.internal_border;
- if ((center_x==0) || (center_y==0) || (radius_x<=0) || (radius_y<=0))
- return; /* can't draw anything */
-
- cur_theta1 = (double) (330 - (load * 3)) * D2R;
- cur_theta2 = (double) (330 - (load * 3) + 1) * D2R;
- cur_theta3 = (double) (330 - (load * 3) - 1) * D2R;
- cur_theta4 = (330.0 - ((double) load * 3.0) + 7.0) * D2R;
- cur_theta5 = (330.0 - ((double) load * 3.0) - 7.0) * D2R;
-
- points[0].x = (short)(sin(cur_theta1) * radius_x * 0.75 + center_x);
- points[0].y = (short)(cos(cur_theta1) * radius_y * 0.75 + center_y);
- points[1].x = (short)(sin(cur_theta2) * radius_x * 0.7 + center_x);
- points[1].y = (short)(cos(cur_theta2) * radius_y * 0.7 + center_y);
- points[2].x = (short)(sin(cur_theta4) * radius_x * 0.1 + center_x);
- points[2].y = (short)(cos(cur_theta4) * radius_y * 0.1 + center_y);
- points[3].x = (short)(sin(cur_theta5) * radius_x * 0.1 + center_x);
- points[3].y = (short)(cos(cur_theta5) * radius_y * 0.1 + center_y);
- points[4].x = (short)(sin(cur_theta3) * radius_x * 0.7 + center_x);
- points[4].y = (short)(cos(cur_theta3) * radius_y * 0.7 + center_y);
- /*@ -usedef @*/
- points[5].x = points[0].x;
- points[5].y = points[0].y;
- /*@ +usedef @*/
-
- (void)XDrawLines(XtDisplay(w), XtWindow(w),
- w->tachometer.needle_GC, points, 6, CoordModeOrigin);
- /*@ +type +unsignedcompare +compdef @*/
+ XPoint points[6];
+ double cur_theta1, cur_theta2, cur_theta3, cur_theta4, cur_theta5;
+ Cardinal center_x, center_y, radius_x, radius_y;
+
+ /*@ -type -unsignedcompare -compdef @*/
+ center_x = w->core.width / 2;
+ center_y = w->core.height / 2;
+ radius_x = center_x - w->tachometer.internal_border;
+ radius_y = center_y - w->tachometer.internal_border;
+ if ((center_x == 0) || (center_y == 0) || (radius_x <= 0)
+ || (radius_y <= 0))
+ return; /* can't draw anything */
+
+ cur_theta1 = (double)(330 - (load * 3)) * D2R;
+ cur_theta2 = (double)(330 - (load * 3) + 1) * D2R;
+ cur_theta3 = (double)(330 - (load * 3) - 1) * D2R;
+ cur_theta4 = (330.0 - ((double)load * 3.0) + 7.0) * D2R;
+ cur_theta5 = (330.0 - ((double)load * 3.0) - 7.0) * D2R;
+
+ points[0].x = (short)(sin(cur_theta1) * radius_x * 0.75 + center_x);
+ points[0].y = (short)(cos(cur_theta1) * radius_y * 0.75 + center_y);
+ points[1].x = (short)(sin(cur_theta2) * radius_x * 0.7 + center_x);
+ points[1].y = (short)(cos(cur_theta2) * radius_y * 0.7 + center_y);
+ points[2].x = (short)(sin(cur_theta4) * radius_x * 0.1 + center_x);
+ points[2].y = (short)(cos(cur_theta4) * radius_y * 0.1 + center_y);
+ points[3].x = (short)(sin(cur_theta5) * radius_x * 0.1 + center_x);
+ points[3].y = (short)(cos(cur_theta5) * radius_y * 0.1 + center_y);
+ points[4].x = (short)(sin(cur_theta3) * radius_x * 0.7 + center_x);
+ points[4].y = (short)(cos(cur_theta3) * radius_y * 0.7 + center_y);
+ /*@ -usedef @*/
+ points[5].x = points[0].x;
+ points[5].y = points[0].y;
+ /*@ +usedef @*/
+
+ (void)XDrawLines(XtDisplay(w), XtWindow(w),
+ w->tachometer.needle_GC, points, 6, CoordModeOrigin);
+ /*@ +type +unsignedcompare +compdef @*/
}
static void DrawTachometer(TachometerWidget w)
{
- Cardinal center_x, center_y, radius_x, radius_y;
-
- /*@ -type -unsignedcompare -compdef @*/
- center_x = w->core.width / 2; center_y = w->core.height / 2;
- radius_x = center_x - w->tachometer.internal_border;
- radius_y = center_y - w->tachometer.internal_border;
- if ((center_x==0) || (center_y==0) || (radius_x<=0) || (radius_y<=0))
- return; /* Can't draw anything -- no room */
-
- /* Big circle */
- FastFillCircle(XtDisplay(w), XtWindow(w), w->tachometer.circle_GC,
- center_x, center_y, radius_x, radius_y);
- /* Inner circle same color as the background */
- FastFillCircle(XtDisplay(w), XtWindow(w), w->tachometer.background_GC,
- center_x, center_y, (Cardinal) (radius_x * 0.95),
- (Cardinal) (radius_y * 0.95));
- /* Small circle */
- FastFillCircle(XtDisplay(w), XtWindow(w), w->tachometer.circle_GC,
- center_x, center_y, (Cardinal) (radius_x * 0.1),
- (Cardinal) (radius_y * 0.1));
- /* Draw the details */
- DrawGauge(w);
- DrawNeedle(w, w->tachometer.value);
- /*@ +type +unsignedcompare +compdef @*/
+ Cardinal center_x, center_y, radius_x, radius_y;
+
+ /*@ -type -unsignedcompare -compdef @*/
+ center_x = w->core.width / 2;
+ center_y = w->core.height / 2;
+ radius_x = center_x - w->tachometer.internal_border;
+ radius_y = center_y - w->tachometer.internal_border;
+ if ((center_x == 0) || (center_y == 0) || (radius_x <= 0)
+ || (radius_y <= 0))
+ return; /* Can't draw anything -- no room */
+
+ /* Big circle */
+ FastFillCircle(XtDisplay(w), XtWindow(w), w->tachometer.circle_GC,
+ center_x, center_y, radius_x, radius_y);
+ /* Inner circle same color as the background */
+ FastFillCircle(XtDisplay(w), XtWindow(w), w->tachometer.background_GC,
+ center_x, center_y, (Cardinal) (radius_x * 0.95),
+ (Cardinal) (radius_y * 0.95));
+ /* Small circle */
+ FastFillCircle(XtDisplay(w), XtWindow(w), w->tachometer.circle_GC,
+ center_x, center_y, (Cardinal) (radius_x * 0.1),
+ (Cardinal) (radius_y * 0.1));
+ /* Draw the details */
+ DrawGauge(w);
+ DrawNeedle(w, w->tachometer.value);
+ /*@ +type +unsignedcompare +compdef @*/
}
static void MoveNeedle(TachometerWidget w, int new)
{
int step, old, loop;
- old = w->tachometer.value;
- if (new > 100)
- new = 100;
- if (old == new)
- return;
- else if (old < new)
- step = (w->tachometer.speed ? w->tachometer.speed : new - old);
- else
- step = (w->tachometer.speed ? -w->tachometer.speed : new - old);
-
- /*@ -usedef @*/
- if (old < new) {
- for (loop = old; loop < new; loop += step)
+ old = w->tachometer.value;
+ if (new > 100)
+ new = 100;
+ if (old == new)
+ return;
+ else if (old < new)
+ step = (w->tachometer.speed ? w->tachometer.speed : new - old);
+ else
+ step = (w->tachometer.speed ? -w->tachometer.speed : new - old);
+
+ /*@ -usedef @*/
+ if (old < new) {
+ for (loop = old; loop < new; loop += step)
DrawNeedle(w, loop);
- for (loop = old + step; loop <= new; loop += step)
+ for (loop = old + step; loop <= new; loop += step)
DrawNeedle(w, loop);
- } else {
- for (loop = old; loop > new; loop += step)
+ } else {
+ for (loop = old; loop > new; loop += step)
DrawNeedle(w, loop);
- for (loop = old + step; loop >= new; loop += step)
+ for (loop = old + step; loop >= new; loop += step)
DrawNeedle(w, loop);
- }
-
- if (loop != new + step) /* The final needle wasn't printed */
- DrawNeedle(w, new);
- /*@ +usedef @*/
-
- w->tachometer.value = new;
+ }
+
+ if (loop != new + step) /* The final needle wasn't printed */
+ DrawNeedle(w, new);
+ /*@ +usedef @*/
+
+ w->tachometer.value = new;
}
static void GetneedleGC(TachometerWidget ta)
{
- XGCValues values;
+ XGCValues values;
- values.background = ta->core.background_pixel;
- values.foreground = ta->tachometer.needle ^ ta->core.background_pixel;
+ values.background = ta->core.background_pixel;
+ values.foreground = ta->tachometer.needle ^ ta->core.background_pixel;
values.function = GXxor;
/*@ -type -compdef -mustfreeonly @*/
- ta->tachometer.needle_GC = XtGetGC(
- (Widget)ta,
- (unsigned) GCFunction | GCBackground | GCForeground,
- &values);
+ ta->tachometer.needle_GC = XtGetGC((Widget) ta,
+ (unsigned)GCFunction | GCBackground |
+ GCForeground, &values);
/*@ +type +compdef +mustfreeonly @*/
}
static void GetscaleGC(TachometerWidget ta)
{
- XGCValues values;
+ XGCValues values;
- values.foreground = ta->tachometer.scale;
- values.background = ta->core.background_pixel;
+ values.foreground = ta->tachometer.scale;
+ values.background = ta->core.background_pixel;
/*@ -type -compdef -mustfreeonly @*/
- ta->tachometer.scale_GC = XtGetGC(
- (Widget)ta,
- (unsigned) GCForeground | GCBackground,
- &values);
+ ta->tachometer.scale_GC = XtGetGC((Widget) ta,
+ (unsigned)GCForeground | GCBackground,
+ &values);
/*@ +type +compdef +mustfreeonly @*/
}
static void GetcircleGC(TachometerWidget ta)
{
- XGCValues values;
+ XGCValues values;
- values.foreground = ta->tachometer.circle;
- values.background = ta->core.background_pixel;
+ values.foreground = ta->tachometer.circle;
+ values.background = ta->core.background_pixel;
/*@ -type -compdef -mustfreeonly @*/
- ta->tachometer.circle_GC = XtGetGC(
- (Widget)ta,
- (unsigned) GCForeground | GCBackground,
- &values);
+ ta->tachometer.circle_GC = XtGetGC((Widget) ta,
+ (unsigned)GCForeground | GCBackground,
+ &values);
/*@ +type +compdef +mustfreeonly @*/
}
static void GetbackgroundGC(TachometerWidget ta)
{
- XGCValues values;
+ XGCValues values;
- values.foreground = ta->core.background_pixel;
- values.background = ta->core.background_pixel;
+ values.foreground = ta->core.background_pixel;
+ values.background = ta->core.background_pixel;
/*@ -type -compdef -mustfreeonly @*/
- ta->tachometer.background_GC = XtGetGC(
- (Widget)ta,
- (unsigned) GCForeground | GCBackground,
- &values);
+ ta->tachometer.background_GC = XtGetGC((Widget) ta,
+ (unsigned)GCForeground |
+ GCBackground, &values);
/*@ +type +compdef +mustfreeonly @*/
}
static void Initialize(Widget request UNUSED, Widget new)
{
TachometerWidget ta = (TachometerWidget) new;
-
+
GetneedleGC(ta);
GetcircleGC(ta);
GetscaleGC(ta);
GetbackgroundGC(ta);
ta->tachometer.width = ta->tachometer.height = 0;
-} /* Initialize */
+} /* Initialize */
-static void Realize(Widget w, Mask *valueMask, XSetWindowAttributes *attributes)
+static void Realize(Widget w, Mask * valueMask,
+ XSetWindowAttributes * attributes)
{
*valueMask |= CWBitGravity;
attributes->bit_gravity = NorthWestGravity;
(*superclass->core_class.realize) (w, valueMask, attributes);
-} /* Realize */
+} /* Realize */
-static void Redisplay(Widget w, XEvent *event, Region region UNUSED)
+static void Redisplay(Widget w, XEvent * event, Region region UNUSED)
{
- if (event->xexpose.count == 0)
- DrawTachometer((TachometerWidget) w);
-} /* Redisplay */
+ if (event->xexpose.count == 0)
+ DrawTachometer((TachometerWidget) w);
+} /* Redisplay */
static void Resize(Widget w)
{
@@ -488,7 +517,7 @@ static void Resize(Widget w)
return;
(void)XClearWindow(XtDisplay(w), XtWindow(w));
-
+
if ((ta->core.width <= ta->tachometer.width) &&
(ta->core.height <= ta->tachometer.height))
/* Only redraw here if no expose events are going to be */
@@ -498,70 +527,70 @@ static void Resize(Widget w)
ta->tachometer.width = ta->core.width;
ta->tachometer.height = ta->core.height;
-} /* Resize */
+} /* Resize */
static Boolean SetValues(Widget current, Widget request UNUSED, Widget new)
/* Set specified arguments into widget */
{
/*@ -type -boolops -predboolothers @*/
- Boolean back, changed = (Boolean)False;
-
- TachometerWidget curta = (TachometerWidget) current;
- TachometerWidget newta = (TachometerWidget) new;
-
- back = (curta->core.background_pixel != newta->core.background_pixel);
- if (back || (curta->tachometer.needle != newta->tachometer.needle)) {
- (void)XtReleaseGC(new, newta->tachometer.needle_GC);
- GetneedleGC(newta);
- changed = True;
- }
- if (back || (curta->tachometer.scale != newta->tachometer.scale)) {
- (void)XtReleaseGC(new, newta->tachometer.scale_GC);
- GetscaleGC(newta);
- changed = True;
- }
- if (back || (curta->tachometer.circle != newta->tachometer.circle)) {
- (void)XtReleaseGC(new, newta->tachometer.circle_GC);
- GetcircleGC(newta);
- changed = True;
- }
- if (back) {
- (void)XtReleaseGC(new, newta->tachometer.background_GC);
- GetbackgroundGC(newta);
- changed = True;
- }
- if (curta->tachometer.value != newta->tachometer.value) {
- MoveNeedle(newta, newta->tachometer.value);
- changed = True;
- }
+ Boolean back, changed = (Boolean) False;
+
+ TachometerWidget curta = (TachometerWidget) current;
+ TachometerWidget newta = (TachometerWidget) new;
+
+ back = (curta->core.background_pixel != newta->core.background_pixel);
+ if (back || (curta->tachometer.needle != newta->tachometer.needle)) {
+ (void)XtReleaseGC(new, newta->tachometer.needle_GC);
+ GetneedleGC(newta);
+ changed = True;
+ }
+ if (back || (curta->tachometer.scale != newta->tachometer.scale)) {
+ (void)XtReleaseGC(new, newta->tachometer.scale_GC);
+ GetscaleGC(newta);
+ changed = True;
+ }
+ if (back || (curta->tachometer.circle != newta->tachometer.circle)) {
+ (void)XtReleaseGC(new, newta->tachometer.circle_GC);
+ GetcircleGC(newta);
+ changed = True;
+ }
+ if (back) {
+ (void)XtReleaseGC(new, newta->tachometer.background_GC);
+ GetbackgroundGC(newta);
+ changed = True;
+ }
+ if (curta->tachometer.value != newta->tachometer.value) {
+ MoveNeedle(newta, newta->tachometer.value);
+ changed = True;
+ }
/*@ +type +boolops +predboolothers @*/
- return(changed);
+ return (changed);
}
static void Destroy(Widget w)
{
TachometerWidget ta = (TachometerWidget) w;
-
- (void)XtReleaseGC( w, ta->tachometer.needle_GC );
- (void)XtReleaseGC( w, ta->tachometer.circle_GC );
- (void)XtReleaseGC( w, ta->tachometer.scale_GC );
- (void)XtReleaseGC( w, ta->tachometer.background_GC );
+
+ (void)XtReleaseGC(w, ta->tachometer.needle_GC);
+ (void)XtReleaseGC(w, ta->tachometer.circle_GC);
+ (void)XtReleaseGC(w, ta->tachometer.scale_GC);
+ (void)XtReleaseGC(w, ta->tachometer.background_GC);
}
/* Exported Procedures */
int TachometerGetValue(Widget w)
{
- return(((TachometerWidget) w)->tachometer.value);
+ return (((TachometerWidget) w)->tachometer.value);
}
int TachometerSetValue(Widget w, int i)
{
- int old;
- TachometerWidget ta = (TachometerWidget) w;
+ int old;
+ TachometerWidget ta = (TachometerWidget) w;
- old = ta->tachometer.value;
- MoveNeedle(ta, i);
- return(old);
+ old = ta->tachometer.value;
+ MoveNeedle(ta, i);
+ return (old);
}
diff --git a/cgps.c b/cgps.c
index 7017d3b4..4dbdf84c 100644
--- a/cgps.c
+++ b/cgps.c
@@ -397,10 +397,8 @@ static void windowsetup(void)
"Latitude Err:");
(void)mvwprintw(datawin, 12, DATAWIN_DESC_OFFSET,
"Altitude Err:");
- (void)mvwprintw(datawin, 13, DATAWIN_DESC_OFFSET,
- "Course Err:");
- (void)mvwprintw(datawin, 14, DATAWIN_DESC_OFFSET,
- "Speed Err:");
+ (void)mvwprintw(datawin, 13, DATAWIN_DESC_OFFSET, "Course Err:");
+ (void)mvwprintw(datawin, 14, DATAWIN_DESC_OFFSET, "Speed Err:");
}
(void)wborder(datawin, 0, 0, 0, 0, 0, 0, 0, 0);
diff --git a/driver_evermore.c b/driver_evermore.c
index 4a637e8b..c8563a97 100644
--- a/driver_evermore.c
+++ b/driver_evermore.c
@@ -281,7 +281,7 @@ gps_mask_t evermore_parse(struct gps_device_t * session, unsigned char *buf,
session->context->leap_seconds;
/*@ end @*/
session->gpsdata.satellites_visible = (int)getub(buf2, 8);
- gpsd_zero_satellites(&session->gpsdata);
+ gpsd_zero_satellites(&session->gpsdata);
memset(session->gpsdata.used, 0, sizeof(session->gpsdata.used));
if (session->gpsdata.satellites_visible > 12) {
gpsd_report(LOG_WARN,
diff --git a/driver_garmin.c b/driver_garmin.c
index d7f325b2..6c264934 100644
--- a/driver_garmin.c
+++ b/driver_garmin.c
@@ -209,8 +209,8 @@ typedef struct
// next 3 items
float msl_hght; /* height of WGS 84 above MSL (meters) */
int16_t leap_sec; /* diff between GPS and UTC (seconds) */
- int32_t grmn_days; /* days from UTC December 31st, 1989 to the
- * beginning of the current week */
+ int32_t grmn_days; /* days from UTC December 31st, 1989 to the
+ * beginning of the current week */
} cpo_pvt_data;
typedef struct
@@ -819,54 +819,54 @@ static void Build_Send_SER_Packet(struct gps_device_t *session,
/*@-compdef -usedef@*/
static bool is_usb_device(const char *path UNUSED, int vendor, int product)
{
- // discover devices
- libusb_device **list;
- ssize_t cnt;
- ssize_t i = 0;
- bool found = false;
-
- gpsd_report(LOG_SHOUT, "attempting USB device enumeration.\n");
- /*@i2@*/libusb_init(NULL);
-
- /*@-nullpass@*/
- if ((cnt = libusb_get_device_list(NULL, &list)) < 0) {
- gpsd_report(LOG_ERROR, "USB device list call failed.\n");
- /*@i1@*/libusb_exit(NULL);
- return false;
- }
- /*@+nullpass@*/
+ // discover devices
+ libusb_device **list;
+ ssize_t cnt;
+ ssize_t i = 0;
+ bool found = false;
+
+ gpsd_report(LOG_SHOUT, "attempting USB device enumeration.\n");
+ /*@i2@*/ libusb_init(NULL);
+
+ /*@-nullpass@*/
+ if ((cnt = libusb_get_device_list(NULL, &list)) < 0) {
+ gpsd_report(LOG_ERROR, "USB device list call failed.\n");
+ /*@i1@*/ libusb_exit(NULL);
+ return false;
+ }
+ /*@+nullpass@*/
- for (i = 0; i < cnt; i++) {
- struct libusb_device_descriptor desc;
- libusb_device *dev = list[i];
+ for (i = 0; i < cnt; i++) {
+ struct libusb_device_descriptor desc;
+ libusb_device *dev = list[i];
- int r = libusb_get_device_descriptor(dev, &desc);
- if (r < 0) {
- gpsd_report(LOG_ERROR,
- "USB descriptor fetch failed on device %zd.\n",
- i);
- continue;
- }
+ int r = libusb_get_device_descriptor(dev, &desc);
+ if (r < 0) {
+ gpsd_report(LOG_ERROR,
+ "USB descriptor fetch failed on device %zd.\n", i);
+ continue;
+ }
- /* we can extract device descriptor data */
- gpsd_report(LOG_SHOUT, "%04x:%04x (bus %d, device %d)\n",
- desc.idVendor, desc.idProduct,
- libusb_get_bus_number(dev),
- libusb_get_device_address(dev));
+ /* we can extract device descriptor data */
+ gpsd_report(LOG_SHOUT, "%04x:%04x (bus %d, device %d)\n",
+ desc.idVendor, desc.idProduct,
+ libusb_get_bus_number(dev),
+ libusb_get_device_address(dev));
- /* we match if vendor and product ID are right */
- if (desc.idVendor == 0x91e && desc.idProduct == 3) {
- found = true;
- break;
- }
+ /* we match if vendor and product ID are right */
+ if (desc.idVendor == 0x91e && desc.idProduct == 3) {
+ found = true;
+ break;
}
+ }
- gpsd_report(LOG_SHOUT, "vendor/product match with %04x:%04x %sfound\n",
- vendor, product, found ? "" : "not ");
- libusb_free_device_list(list, 1);
- /*@i1@*/libusb_exit(NULL);
- return found;
+ gpsd_report(LOG_SHOUT, "vendor/product match with %04x:%04x %sfound\n",
+ vendor, product, found ? "" : "not ");
+ libusb_free_device_list(list, 1);
+ /*@i1@*/ libusb_exit(NULL);
+ return found;
}
+
/*@-compdef -usedef@*/
#endif /* HAVE_LIBUSB || S_SPLINT_S */
diff --git a/driver_italk.c b/driver_italk.c
index 0b0b920a..f1c7c33e 100644
--- a/driver_italk.c
+++ b/driver_italk.c
@@ -64,8 +64,8 @@ static gps_mask_t decode_itk_navfix(struct gps_device_t *session,
session->context->gps_week = gps_week;
tow = (uint) getleul(buf, 7 + 84);
session->context->gps_tow = tow / 1000.0;
- t = gpstime_to_unix((int)gps_week,session->context->gps_tow)
- - session->context->leap_seconds;
+ t = gpstime_to_unix((int)gps_week, session->context->gps_tow)
+ - session->context->leap_seconds;
session->newdata.time = t;
mask |= TIME_IS;
@@ -139,8 +139,8 @@ static gps_mask_t decode_itk_prnstatus(struct gps_device_t *session,
session->context->gps_week = gps_week;
tow = (uint) getleul(buf, 7 + 6);
session->context->gps_tow = tow / 1000.0;
- t = gpstime_to_unix((int)gps_week,session->context->gps_tow)
- - session->context->leap_seconds;
+ t = gpstime_to_unix((int)gps_week, session->context->gps_tow)
+ - session->context->leap_seconds;
session->gpsdata.skyview_time = t;
gpsd_zero_satellites(&session->gpsdata);
@@ -204,8 +204,8 @@ static gps_mask_t decode_itk_utcionomodel(struct gps_device_t *session,
session->context->gps_week = gps_week;
tow = (uint) getleul(buf, 7 + 38);
session->context->gps_tow = tow / 1000.0;
- t = gpstime_to_unix((int)gps_week,session->context->gps_tow)
- - session->context->leap_seconds;
+ t = gpstime_to_unix((int)gps_week, session->context->gps_tow)
+ - session->context->leap_seconds;
session->newdata.time = t;
gpsd_report(LOG_DATA,
@@ -241,7 +241,8 @@ static gps_mask_t decode_itk_subframe(struct gps_device_t *session,
* words with parity checking done but parity bits still present."
*/
for (i = 0; i < 10; i++)
- words[i] = (unsigned int)(getleul(buf, 7 + 14 + 4*i) >> 6) & 0xffffff;
+ words[i] =
+ (unsigned int)(getleul(buf, 7 + 14 + 4 * i) >> 6) & 0xffffff;
gpsd_interpret_subframe(session, words);
return ONLINE_IS;
diff --git a/driver_navcom.c b/driver_navcom.c
index 4e5ebe07..a4d8f814 100644
--- a/driver_navcom.c
+++ b/driver_navcom.c
@@ -419,7 +419,7 @@ static gps_mask_t handle_0xb1(struct gps_device_t *session)
session->context->gps_tow = tow / 1000.0;
session->newdata.time =
gpstime_to_unix((int)week, session->context->gps_tow)
- - session->context->leap_seconds;
+ - session->context->leap_seconds;
/* Satellites used */
sats_used = (uint32_t) getleul(buf, 9);
@@ -743,7 +743,7 @@ static gps_mask_t handle_0x86(struct gps_device_t *session)
/*@ ignore @*//*@ splint is confused @ */
session->gpsdata.skyview_time =
gpstime_to_unix((int)week, session->context->gps_tow)
- - session->context->leap_seconds;
+ - session->context->leap_seconds;
/*@ end @*/
/* Give this driver a single point of truth about DOPs */
//session->gpsdata.dop.pdop = (int)pdop / 10.0;
@@ -843,8 +843,9 @@ static gps_mask_t handle_0xb0(struct gps_device_t *session)
char time_str[24];
session->context->gps_week = (unsigned short)week;
session->context->gps_tow = (double)tow / 1000.0;
- (void)unix_to_iso8601(gpstime_to_unix((int)week, session->context->gps_tow),
- time_str, sizeof(time_str));
+ (void)
+ unix_to_iso8601(gpstime_to_unix((int)week, session->context->gps_tow),
+ time_str, sizeof(time_str));
gpsd_report(LOG_PROG,
"Navcom: received packet type 0xb0 (Raw Meas. Data Block)\n");
@@ -940,7 +941,7 @@ static gps_mask_t handle_0xb5(struct gps_device_t *session)
/*@ ignore @*//*@ splint is confused @ */
session->newdata.time =
gpstime_to_unix((int)week, session->context->gps_tow)
- - session->context->leap_seconds;
+ - session->context->leap_seconds;
/*@ end @*/
gpsd_report(LOG_PROG,
"Navcom: received packet type 0xb5 (Pseudorange Noise Statistics)\n");
diff --git a/driver_sirf.c b/driver_sirf.c
index 36611b87..925c6541 100644
--- a/driver_sirf.c
+++ b/driver_sirf.c
@@ -475,8 +475,8 @@ static gps_mask_t sirf_msg_svinfo(struct gps_device_t *session,
/*@ ignore @*//*@ splint is confused @ */
session->gpsdata.skyview_time
=
- gpstime_to_unix( session->context->gps_week, session->context->gps_tow)
- - session->context->leap_seconds;
+ gpstime_to_unix(session->context->gps_week, session->context->gps_tow)
+ - session->context->leap_seconds;
/*@ end @*/
for (i = st = 0; i < SIRF_CHANNELS; i++) {
int off = 8 + 15 * i;
@@ -617,7 +617,8 @@ static gps_mask_t sirf_msg_navsol(struct gps_device_t *session,
session->context->gps_tow = (double)getbeul(buf, 24) * 1e-2;
/*@ ignore @*//*@ splint is confused @ */
session->newdata.time =
- gpstime_to_unix(session->context->gps_week, session->context->gps_tow) -
+ gpstime_to_unix(session->context->gps_week,
+ session->context->gps_tow) -
session->context->leap_seconds;
/*@ end @*/
#ifdef NTPSHM_ENABLE
diff --git a/driver_tsip.c b/driver_tsip.c
index 25ee5dac..97342884 100644
--- a/driver_tsip.c
+++ b/driver_tsip.c
@@ -199,8 +199,10 @@ static gps_mask_t tsip_analyze(struct gps_device_t *session)
session->context->valid |= LEAP_SECOND_VALID;
session->context->gps_tow = f1;
- session->newdata.time = gpstime_to_unix(session->context->gps_week
- , session->context->gps_tow) - session->context->leap_seconds;
+ session->newdata.time =
+ gpstime_to_unix(session->context->gps_week,
+ session->context->gps_tow) -
+ session->context->leap_seconds;
mask |= TIME_IS;
}
gpsd_report(LOG_INF, "GPS Time %f %d %f\n", f1, s1, f2);
@@ -297,8 +299,8 @@ static gps_mask_t tsip_analyze(struct gps_device_t *session)
if (session->context->gps_week) {
session->newdata.time =
gpstime_to_unix((int)session->context->gps_week,
- session->context->gps_tow)
- - session->context->leap_seconds;
+ session->context->gps_tow)
+ - session->context->leap_seconds;
mask |= TIME_IS;
}
mask |= LATLON_IS | ALTITUDE_IS | CLEAR_IS | REPORT_IS;
@@ -560,8 +562,8 @@ static gps_mask_t tsip_analyze(struct gps_device_t *session)
if (session->context->gps_week) {
session->newdata.time =
gpstime_to_unix((int)session->context->gps_week,
- session->context->gps_tow)
- - session->context->leap_seconds;
+ session->context->gps_tow)
+ - session->context->leap_seconds;
mask |= TIME_IS;
}
gpsd_report(LOG_INF, "GPS DP LLA %f %f %f %f\n",
@@ -656,11 +658,11 @@ static gps_mask_t tsip_analyze(struct gps_device_t *session)
session->context->valid |= LEAP_SECOND_VALID;
}
session->context->gps_week = (unsigned short)s4;
- session->context->gps_tow = (double)ul1 * 1e-3;
+ session->context->gps_tow = (double)ul1 *1e-3;
/*@ ignore @*//*@ splint is confused @ */
session->newdata.time =
gpstime_to_unix((int)s4, session->context->gps_tow)
- - session->context->leap_seconds;
+ - session->context->leap_seconds;
/*@ end @*/
mask |=
TIME_IS | LATLON_IS | ALTITUDE_IS | SPEED_IS | TRACK_IS |
@@ -698,12 +700,12 @@ static gps_mask_t tsip_analyze(struct gps_device_t *session)
session->context->valid |= LEAP_SECOND_VALID;
}
session->context->gps_week = (unsigned short)s1;
- session->context->gps_tow = (double)ul1 * 1e3;
+ session->context->gps_tow = (double)ul1 *1e3;
/*@ ignore @*//*@ splint is confused @ */
session->newdata.time =
- gpstime_to_unix(session->context->gps_week,
+ gpstime_to_unix(session->context->gps_week,
session->context->gps_tow)
- - session->context->leap_seconds;
+ - session->context->leap_seconds;
/*@ end @*/
session->gpsdata.status = STATUS_NO_FIX;
session->newdata.mode = MODE_NO_FIX;
@@ -770,7 +772,7 @@ static gps_mask_t tsip_analyze(struct gps_device_t *session)
session->context->gps_week = s1;
session->context->gps_tow = (double)ul1;
session->newdata.time =
- gpstime_to_unix((int)s1, session->context->gps_tow)
+ gpstime_to_unix((int)s1, session->context->gps_tow)
- (double)s2;
mask |= TIME_IS;
gpsd_report(LOG_DATA, "SP-TTS 0xab time=%.2f mask={TIME}\n",
diff --git a/driver_ubx.c b/driver_ubx.c
index ca5c0c50..93a14be9 100644
--- a/driver_ubx.c
+++ b/driver_ubx.c
@@ -75,9 +75,9 @@ ubx_msg_nav_sol(struct gps_device_t *session, unsigned char *buf,
session->context->gps_week = gw;
session->context->gps_tow = tow / 1000.0;
- t = gpstime_to_unix((int)session->context->gps_week,
- session->context->gps_tow)
- - session->context->leap_seconds;
+ t = gpstime_to_unix((int)session->context->gps_week,
+ session->context->gps_tow)
+ - session->context->leap_seconds;
session->newdata.time = t;
mask |= TIME_IS;
}
@@ -188,8 +188,8 @@ ubx_msg_nav_timegps(struct gps_device_t *session, unsigned char *buf,
session->context->gps_tow = tow / 1000.0;
t = gpstime_to_unix((int)session->context->gps_week,
- session->context->gps_tow)
- - session->context->leap_seconds;
+ session->context->gps_tow)
+ - session->context->leap_seconds;
session->newdata.time = t;
gpsd_report(LOG_DATA, "TIMEGPS: time=%.2f mask={TIME}\n",
diff --git a/driver_zodiac.c b/driver_zodiac.c
index a96d8f65..fb40381d 100644
--- a/driver_zodiac.c
+++ b/driver_zodiac.c
@@ -152,7 +152,7 @@ static gps_mask_t handle1000(struct gps_device_t *session)
/* solution_type = getzword(11); */
session->gpsdata.satellites_used = (int)getzword(12);
/* polar_navigation = getzword(13); */
- session->context->gps_week = (unsigned short)getzword(14);
+ session->context->gps_week = (unsigned short)getzword(14);
/* gps_seconds = getzlong(15); */
/* gps_nanoseconds = getzlong(17); */
unpacked_date.tm_mday = (int)getzword(19);
@@ -241,7 +241,7 @@ static gps_mask_t handle1002(struct gps_device_t *session)
}
}
session->context->gps_week = (unsigned short)gps_week;
- session->context->gps_tow = (double) gps_seconds;
+ session->context->gps_tow = (double)gps_seconds;
session->gpsdata.skyview_time =
gpstime_to_unix(gps_week, session->context->gps_tow);
gpsd_report(LOG_DATA, "1002: visible=%d used=%d mask={SATELLITE|USED}\n",
diff --git a/gpsd.c b/gpsd.c
index 87dbc4ed..1f8254c7 100644
--- a/gpsd.c
+++ b/gpsd.c
@@ -153,11 +153,13 @@ static bool in_background = false;
static bool listen_global = false;
static bool nowait = false;
static jmp_buf restartbuf;
-static enum {disabled,
- enabled,
- fulfilled,
- holding}
- quit_when_quiescent = disabled;
+static enum
+{ disabled,
+ enabled,
+ fulfilled,
+ holding
+}
+quit_when_quiescent = disabled;
static unsigned int devices_expected;
/* *INDENT-OFF* */
@@ -716,7 +718,7 @@ static bool awaken(struct gps_device_t *device)
/* open that device */
if (!initialized_device(device)) {
if (!open_device(device->gpsdata.dev.path)) {
- gpsd_report(LOG_PROG, "%s: open failed\n",
+ gpsd_report(LOG_PROG, "%s: open failed\n",
device->gpsdata.dev.path);
free_device(device);
return false;
@@ -727,13 +729,12 @@ static bool awaken(struct gps_device_t *device)
gpsd_report(LOG_PROG,
"device %d (fd=%d, path %s) already active.\n",
(int)(device - devices),
- device->gpsdata.gps_fd,
- device->gpsdata.dev.path);
+ device->gpsdata.gps_fd, device->gpsdata.dev.path);
return true;
} else {
if (gpsd_activate(device) < 0) {
gpsd_report(LOG_ERROR, "%s: device activation failed.\n",
- device->gpsdata.dev.path);
+ device->gpsdata.dev.path);
return false;
} else {
gpsd_report(LOG_RAW,
@@ -863,10 +864,12 @@ static void handle_control(int sfd, char *buf)
ignore_return(write(sfd, "ERROR\n", 6));
}
}
- } else if (buf[0] == '$') { /* undocumented */
- p = snarfline(buf+1, &stash);
+ } else if (buf[0] == '$') { /* undocumented */
+ p = snarfline(buf + 1, &stash);
devices_expected = (unsigned)atoi(stash);
- gpsd_report(LOG_INF, "<= control(%d): quit-when-quiescent set, %d devices expected\n", sfd, devices_expected);
+ gpsd_report(LOG_INF,
+ "<= control(%d): quit-when-quiescent set, %d devices expected\n",
+ sfd, devices_expected);
quit_when_quiescent = enabled;
ignore_return(write(sfd, "OK\n", 3));
}
@@ -1654,7 +1657,9 @@ int main(int argc, char *argv[])
sub < subscribers + MAXSUBSCRIBERS; sub++)
if (sub->active != 0
&& sub->policy.watcher
- && (sub->policy.devpath[0] == '\0' || strcmp(sub->policy.devpath, device->gpsdata.dev.path)==0))
+ && (sub->policy.devpath[0] == '\0'
+ || strcmp(sub->policy.devpath,
+ device->gpsdata.dev.path) == 0))
listeners = true;
if (listeners)
(void)awaken(device);
@@ -1738,9 +1743,10 @@ int main(int argc, char *argv[])
}
#endif /* BINARY_ENABLE */
/* *INDENT-ON* */
- } /* subscribers */
- } /* devices */
+ } /* subscribers */
+ }
+ /* devices */
/* watch all channels associated with this device */
for (sub = subscribers; sub < subscribers + MAXSUBSCRIBERS; sub++) {
if (sub->active == 0)
@@ -1961,8 +1967,9 @@ int main(int argc, char *argv[])
}
}
}
- } /* nowait */
+ }
+ /* nowait */
/*
* This code enables a test harness to use the undocumented
* $<n> control-socket command to tell the daemon to notice
@@ -1978,7 +1985,7 @@ int main(int argc, char *argv[])
if (quit_when_quiescent == enabled) {
if (activecount == devices_expected) {
quit_when_quiescent = fulfilled;
- gpsd_report(LOG_INF,
+ gpsd_report(LOG_INF,
"expected number of devices are connected\n");
}
}
@@ -1986,7 +1993,7 @@ int main(int argc, char *argv[])
if (quit_when_quiescent == fulfilled) {
if (activecount == 0) {
quit_when_quiescent = holding;
- gpsd_report(LOG_INF,
+ gpsd_report(LOG_INF,
"all expected devices are quiescent\n");
}
}
@@ -1994,7 +2001,8 @@ int main(int argc, char *argv[])
if (quit_when_quiescent == holding) {
int waiting = 0;
if (activecount == 0) {
- for (device = devices; device < devices + MAXDEVICES; device++)
+ for (device = devices; device < devices + MAXDEVICES;
+ device++)
if (allocated_device(device))
if (device->packet.inbuflen > 0)
waiting++;
@@ -2004,7 +2012,7 @@ int main(int argc, char *argv[])
}
}
}
- } /* quit_when_quiescent */
+ } /* quit_when_quiescent */
}
/* if we make it here, we got a signal... deal with it */
@@ -2012,7 +2020,7 @@ int main(int argc, char *argv[])
if (SIGHUP == (int)signalled)
longjmp(restartbuf, 1);
- gpsd_report(LOG_WARN, "received terminating signal %d.\n",signalled);
+ gpsd_report(LOG_WARN, "received terminating signal %d.\n", signalled);
/* try to undo all device configurations */
for (dfd = 0; dfd < MAXDEVICES; dfd++) {
@@ -2020,7 +2028,7 @@ int main(int argc, char *argv[])
(void)gpsd_wrap(&devices[dfd]);
}
-clean_shutdown:
+ clean_shutdown:
gpsd_report(LOG_WARN, "exiting.\n");
/*
* A linger option was set on each client socket when it was
diff --git a/json.c b/json.c
index e191aac3..27f39a28 100644
--- a/json.c
+++ b/json.c
@@ -251,8 +251,8 @@ static int json_internal_read_object(const char *cp,
json_debug_trace((1, "Collected attribute name %s\n",
attrbuf));
for (cursor = attrs; cursor->attribute != NULL; cursor++) {
- json_debug_trace((2, "Checking against %s\n",
- cursor->attribute));
+ json_debug_trace((2, "Checking against %s\n",
+ cursor->attribute));
if (strcmp(cursor->attribute, attrbuf) == 0)
break;
}
diff --git a/libgpsd_core.c b/libgpsd_core.c
index 836b662d..11c4c79e 100644
--- a/libgpsd_core.c
+++ b/libgpsd_core.c
@@ -254,7 +254,7 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg)
log = "Too long for 5Hz, too short for 1Hz\n";
} else if (1001000 > cycle) {
/* looks like PPS pulse or square wave */
- if (0 == duration) {
+ if (0 == duration) {
ok = 1;
log = "PPS invisible pulse\n";
} else if (499000 > duration) {
@@ -451,7 +451,7 @@ char /*@observer@*/ *gpsd_id( /*@in@ */ struct gps_device_t *session)
}
static void gpsd_error_model(struct gps_device_t *session,
- struct gps_fix_t *fix, struct gps_fix_t *oldfix)
+ struct gps_fix_t *fix, struct gps_fix_t *oldfix)
/* compute errors and derived quantities */
{
/*
diff --git a/subframe.c b/subframe.c
index d5b8e840..6eb2a9d7 100644
--- a/subframe.c
+++ b/subframe.c
@@ -22,7 +22,7 @@ static char sf5map[] =
/*@ -usedef @*/
int gpsd_interpret_subframe_raw(struct gps_device_t *session,
- unsigned int words[])
+ unsigned int words[])
{
unsigned int i;
unsigned int preamble, parity;
@@ -51,8 +51,8 @@ int gpsd_interpret_subframe_raw(struct gps_device_t *session,
words[5], words[6], words[7], words[8], words[9]);
preamble = (words[0] >> 22) & 0xff;
- if (preamble == 0x8b) { /* preamble is inverted */
- words[0] ^= 0x3fffffc0; /* invert */
+ if (preamble == 0x8b) { /* preamble is inverted */
+ words[0] ^= 0x3fffffc0; /* invert */
} else if (preamble != 0x74) {
gpsd_report(LOG_WARN,
"50B: gpsd_interpret_subframe_raw: bad preamble 0x%x\n",
@@ -72,8 +72,8 @@ int gpsd_interpret_subframe_raw(struct gps_device_t *session,
parity = isgps_parity(words[i]);
if (parity != (words[i] & 0x3f)) {
gpsd_report(LOG_PROG,
- "50B: gpsd_interpret_subframe_raw parity fail words[%d] 0x%x != 0x%x\n", i,
- parity, (words[i] & 0x1));
+ "50B: gpsd_interpret_subframe_raw parity fail words[%d] 0x%x != 0x%x\n",
+ i, parity, (words[i] & 0x1));
return 0;
}
words[i] = (words[i] >> 6) & 0xffffff;
@@ -108,8 +108,8 @@ void gpsd_interpret_subframe(struct gps_device_t *session,
preamble = (unsigned int)((words[0] >> 16) & 0xffL);
if (preamble == 0x8b) {
- preamble ^= 0xff;
- words[0] ^= 0xffffff;
+ preamble ^= 0xff;
+ words[0] ^= 0xffffff;
}
if (preamble != 0x74) {
gpsd_report(LOG_WARN,
@@ -131,9 +131,9 @@ void gpsd_interpret_subframe(struct gps_device_t *session,
switch (subframe) {
case 1:
/* get Week Number WN) from subframe 1 */
- session->context->gps_week = (unsigned short)((words[2] & 0xffc000) >> 14);
- gpsd_report(LOG_PROG,
- "50B: WN: %u\n", session->context->gps_week);
+ session->context->gps_week =
+ (unsigned short)((words[2] & 0xffc000) >> 14);
+ gpsd_report(LOG_PROG, "50B: WN: %u\n", session->context->gps_week);
break;
case 4:
switch (pageid) {
@@ -187,7 +187,7 @@ void gpsd_interpret_subframe(struct gps_device_t *session,
leap = (words[8] & 0xff0000) >> 16; /* current leap seconds */
/* careful WN is 10 bits, but WNlsf is 8 bits! */
wnlsf = (words[8] & 0x00ff00) >> 8; /* WNlsf (Week Number of LSF) */
- dn = (words[8] & 0x0000FF); /* DN (Day Number of LSF) */
+ dn = (words[8] & 0x0000FF); /* DN (Day Number of LSF) */
lsf = (words[9] & 0xff0000) >> 16; /* leap second future */
/*
* On SiRFs, the 50BPS data is passed on even when the
@@ -196,16 +196,17 @@ void gpsd_interpret_subframe(struct gps_device_t *session,
*/
if (LEAP_SECONDS > leap) {
/* something wrong */
- gpsd_report(LOG_ERROR, "50B: Invalid leap_seconds: %d\n", leap);
+ gpsd_report(LOG_ERROR, "50B: Invalid leap_seconds: %d\n",
+ leap);
leap = LEAP_SECONDS;
session->context->valid &= ~LEAP_SECOND_VALID;
} else {
gpsd_report(LOG_INF,
- "50B: leap-seconds: %d, lsf: %d, WNlsf: %d, DN: %d \n",
- leap, lsf, wnlsf, dn);
+ "50B: leap-seconds: %d, lsf: %d, WNlsf: %d, DN: %d \n",
+ leap, lsf, wnlsf, dn);
session->context->valid |= LEAP_SECOND_VALID;
- if ( leap != lsf ) {
- gpsd_report(LOG_PROG, "50B: leap-second change coming\n");
+ if (leap != lsf) {
+ gpsd_report(LOG_PROG, "50B: leap-second change coming\n");
}
}
session->context->leap_seconds = (int)leap;
diff --git a/test_packet.c b/test_packet.c
index d43f7b00..d9109d64 100644
--- a/test_packet.c
+++ b/test_packet.c
@@ -276,7 +276,8 @@ static int packet_test(struct map *mp)
mp->legend);
++failure;
} else
- printf("%2zi: %s test succeeded.\n", mp - singletests + 1, mp->legend);
+ printf("%2zi: %s test succeeded.\n", mp - singletests + 1,
+ mp->legend);
#ifdef DUMPIT
for (cp = packet.outbuffer;
cp < packet.outbuffer + packet.outbuflen; cp++) {
@@ -311,9 +312,8 @@ static void runon_test(struct map *mp)
(void)fputs(mp->test, stdout);
do {
st = packet_get(nullfd, &packet);
- printf("packet_parse() returned %zd\n", st);
- } while
- (st > 0);
+ printf("packet_parse() returned %zd\n", st);
+ } while (st > 0);
/*@ +compdef +uniondef +usedef +formatcode @*/
}
@@ -337,10 +337,11 @@ int main(int argc, char *argv[])
if (singletest)
failcount += packet_test(singletests + singletest - 1);
- else
- {
+ else {
(void)fputs("=== Packet identification tests\n ===", stdout);
- for (mp = singletests; mp < singletests + sizeof(singletests) / sizeof(singletests[0]); mp++)
+ for (mp = singletests;
+ mp < singletests + sizeof(singletests) / sizeof(singletests[0]);
+ mp++)
failcount += packet_test(mp);
(void)fputs("=== EOF with buffer nonempty test ===\n", stdout);
runon_test(&runontests[0]);
diff --git a/xgpsspeed.c b/xgpsspeed.c
index 81d7e2d1..8571d6a2 100644
--- a/xgpsspeed.c
+++ b/xgpsspeed.c
@@ -26,12 +26,13 @@
/*@ -nullassign @*/
static XrmOptionDescRec options[] = {
-{"-rv", "*reverseVideo", XrmoptionNoArg, "TRUE"},
-{"-nc", "*needleColor", XrmoptionSepArg, NULL},
-{"-needlecolor","*needleColor", XrmoptionSepArg, NULL},
-{"-speedunits", "*speedunits", XrmoptionSepArg, NULL},
+ {"-rv", "*reverseVideo", XrmoptionNoArg, "TRUE"},
+ {"-nc", "*needleColor", XrmoptionSepArg, NULL},
+ {"-needlecolor", "*needleColor", XrmoptionSepArg, NULL},
+ {"-speedunits", "*speedunits", XrmoptionSepArg, NULL},
};
-String fallback_resources[] = {NULL};
+String fallback_resources[] = { NULL };
+
/*@ +nullassign @*/
static struct gps_data_t *gpsdata;
@@ -43,17 +44,20 @@ static struct fixsource_t source;
static int debug;
#endif /* CLIENTDEBUG_ENABLE */
-static void update_display(struct gps_data_t *gpsdata,
+static void update_display(struct gps_data_t *gpsdata,
char *buf UNUSED, size_t len UNUSED)
{
/* this is where we implement source-device filtering */
- if (gpsdata->dev.path[0]!='\0' && source.device!=NULL && strcmp(source.device, gpsdata->dev.path) != 0)
+ if (gpsdata->dev.path[0] != '\0' && source.device != NULL
+ && strcmp(source.device, gpsdata->dev.path) != 0)
return;
else {
int temp_int = (int)rint(gpsdata->fix.speed * speedfactor);
- if (temp_int < 0) temp_int = 0;
- else if (temp_int > 100) temp_int = 100;
+ if (temp_int < 0)
+ temp_int = 0;
+ else if (temp_int > 100)
+ temp_int = 100;
(void)TachometerSetValue(tacho, temp_int);
}
@@ -70,43 +74,44 @@ static void handle_input(XtPointer client_data UNUSED,
static char *get_resource(Widget w, char *name, char *default_value)
{
- XtResource xtr;
- char *value = NULL;
-
- /*@ -observertrans -statictrans -immediatetrans -compdestroy -nullpass @*/
- xtr.resource_name = name;
- xtr.resource_class = "AnyClass";
- xtr.resource_type = XtRString;
- xtr.resource_size = (Cardinal)sizeof(String);
- xtr.resource_offset = 0;
- xtr.default_type = XtRImmediate;
- xtr.default_addr = default_value;
- XtGetApplicationResources(w, &value, &xtr, 1, NULL, 0);
- if (value) return value;
- /*@ +observertrans +statictrans +immediatetrans +compdestroy +nullpass @*/
- /*@i@*/return default_value;
+ XtResource xtr;
+ char *value = NULL;
+
+ /*@ -observertrans -statictrans -immediatetrans -compdestroy -nullpass @*/
+ xtr.resource_name = name;
+ xtr.resource_class = "AnyClass";
+ xtr.resource_type = XtRString;
+ xtr.resource_size = (Cardinal) sizeof(String);
+ xtr.resource_offset = 0;
+ xtr.default_type = XtRImmediate;
+ xtr.default_addr = default_value;
+ XtGetApplicationResources(w, &value, &xtr, 1, NULL, 0);
+ if (value)
+ return value;
+ /*@ +observertrans +statictrans +immediatetrans +compdestroy +nullpass @*/
+ /*@i@*/ return default_value;
}
/*@ -mustfreefresh @*/
int main(int argc, char **argv)
{
- Arg args[10];
+ Arg args[10];
XtAppContext app;
int option;
char *speedunits;
Widget base;
/*@ -compdef -nullpass -onlytrans @*/
- toplevel = XtVaAppInitialize(&app, "xgpsspeed",
+ toplevel = XtVaAppInitialize(&app, "xgpsspeed",
options, XtNumber(options),
&argc, argv, fallback_resources, NULL);
/*@ +compdef +nullpass +onlytrans @*/
- speedfactor = MPS_TO_MPH; /* Software maintained in US */
+ speedfactor = MPS_TO_MPH; /* Software maintained in US */
speedunits = get_resource(toplevel, "speedunits", "mph");
- if (strcmp(speedunits, "kph")==0)
+ if (strcmp(speedunits, "kph") == 0)
speedfactor = MPS_TO_KPH;
- else if (strcmp(speedunits, "knots")==0)
+ else if (strcmp(speedunits, "knots") == 0)
speedfactor = MPS_TO_KNOTS;
while ((option = getopt(argc, argv, "D:hV")) != -1) {
@@ -120,8 +125,12 @@ int main(int argc, char **argv)
case 'V':
(void)printf("xgpsspeed %s\n", VERSION);
exit(0);
- case 'h': default:
- (void)fputs("usage: gps [-h] [-V] [-rv] [-nc] [-needlecolor] [-speedunits {mph,kph,knots}] [server[:port]]\n", stderr);
+ case 'h':
+ default:
+ (void)
+ fputs
+ ("usage: gps [-h] [-V] [-rv] [-nc] [-needlecolor] [-speedunits {mph,kph,knots}] [server[:port]]\n",
+ stderr);
exit(1);
}
}
@@ -135,11 +144,12 @@ int main(int argc, char **argv)
/*@ -immediatetrans -usedef -observertrans -statictrans -nullpass @*/
/**** Shell Widget ****/
(void)XtSetArg(args[0], XtNiconPixmap,
- XCreateBitmapFromData(XtDisplay(toplevel),
- XtScreen(toplevel)->root, (char*)xgps_bits,
- xgps_width, xgps_height));
+ XCreateBitmapFromData(XtDisplay(toplevel),
+ XtScreen(toplevel)->root,
+ (char *)xgps_bits, xgps_width,
+ xgps_height));
(void)XtSetValues(toplevel, args, 1);
-
+
/**** Form widget ****/
base = XtCreateManagedWidget("pane", panedWidgetClass, toplevel, NULL, 0);
@@ -149,18 +159,19 @@ int main(int argc, char **argv)
/**** Label widget ****/
if (speedfactor == MPS_TO_MPH)
- (void)XtSetArg(args[0], XtNlabel, "Miles per Hour");
+ (void)XtSetArg(args[0], XtNlabel, "Miles per Hour");
else if (speedfactor == MPS_TO_KPH)
- (void)XtSetArg(args[0], XtNlabel, "Km per Hour");
- else
- (void)XtSetArg(args[0], XtNlabel, "Knots");
+ (void)XtSetArg(args[0], XtNlabel, "Km per Hour");
+ else
+ (void)XtSetArg(args[0], XtNlabel, "Knots");
/*@ +immediatetrans +usedef +observertrans +statictrans -compmempass @*/
(void)XtCreateManagedWidget("name", labelWidgetClass, base, args, 1);
-
+
/**** Tachometer widget ****/
/*@ -onlytrans -mustfreeonly @*/
- tacho = XtCreateManagedWidget("meter", tachometerWidgetClass,base,NULL,0);
+ tacho =
+ XtCreateManagedWidget("meter", tachometerWidgetClass, base, NULL, 0);
(void)XtRealizeWidget(toplevel);
if (!(gpsdata = gps_open(source.server, source.port))) {
@@ -171,7 +182,7 @@ int main(int argc, char **argv)
/*@ -usedef @*/
(void)XtAppAddInput(app, gpsdata->gps_fd, (XtPointer) XtInputReadMask,
- handle_input, NULL);
+ handle_input, NULL);
/*@ +nullpass +usedef @*/
gps_set_raw_hook(gpsdata, update_display);
@@ -184,4 +195,5 @@ int main(int argc, char **argv)
return 0;
/*@ +compdestroy @*/
}
+
/*@ +mustfreefresh @*/
diff --git a/xgpsspeed.icon b/xgpsspeed.icon
index e84cc1a9..c925f83b 100644
--- a/xgpsspeed.icon
+++ b/xgpsspeed.icon
@@ -2,34 +2,36 @@
#define xgps_width 50
#define xgps_height 50
static unsigned char xgps_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xe0, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc,
- 0xff, 0x01, 0x00, 0x00, 0x00, 0x80, 0x1f, 0xc2, 0x0f, 0x00, 0x00, 0x00,
- 0xc0, 0x03, 0x02, 0x1e, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x02, 0x78, 0x00,
- 0x00, 0x00, 0xb8, 0x00, 0x02, 0xf0, 0x00, 0x00, 0x00, 0x1c, 0x01, 0x00,
- 0xc8, 0x01, 0x00, 0x00, 0x06, 0x01, 0x00, 0x04, 0x03, 0x00, 0x00, 0x07,
- 0x02, 0x00, 0x02, 0x07, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x06, 0x00,
- 0x80, 0x01, 0x00, 0x00, 0x00, 0x0c, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x00,
- 0x1c, 0x00, 0xc0, 0x02, 0x00, 0x00, 0x00, 0x1a, 0x00, 0xff, 0x0c, 0x00,
- 0x00, 0x80, 0xf9, 0x03, 0x6f, 0x10, 0x00, 0x00, 0x40, 0xb0, 0x03, 0x6f,
- 0x00, 0x00, 0x00, 0x00, 0xb0, 0x03, 0x67, 0x00, 0x00, 0x00, 0x00, 0x30,
- 0x03, 0x37, 0x00, 0x00, 0x00, 0x00, 0x60, 0x03, 0x37, 0x00, 0x00, 0x00,
- 0x00, 0x60, 0x03, 0x37, 0x00, 0x00, 0x02, 0x00, 0x60, 0x03, 0x37, 0x00,
- 0x00, 0x07, 0x00, 0x60, 0x03, 0xf7, 0x03, 0x80, 0x0d, 0x00, 0x7e, 0x03,
- 0x37, 0x00, 0x00, 0x3f, 0x00, 0x60, 0x03, 0x37, 0x00, 0x00, 0xf2, 0x00,
- 0x60, 0x03, 0x37, 0x00, 0x00, 0xc0, 0x03, 0x60, 0x03, 0x37, 0x00, 0x00,
- 0x00, 0x07, 0x60, 0x03, 0x67, 0x00, 0x00, 0x00, 0x1c, 0x30, 0x03, 0x6f,
- 0x00, 0x00, 0x00, 0x30, 0xb0, 0x03, 0x6f, 0x0c, 0x00, 0x00, 0x80, 0xb1,
- 0x03, 0xff, 0x03, 0x00, 0x00, 0x00, 0xfe, 0x03, 0xc0, 0x00, 0x00, 0x00,
- 0x00, 0x18, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x80, 0x01,
- 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x83, 0x00, 0x00, 0x08, 0x06, 0x00,
- 0x00, 0x47, 0x00, 0x00, 0x10, 0x07, 0x00, 0x00, 0x26, 0x00, 0x00, 0x20,
- 0x03, 0x00, 0x00, 0x1c, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x38, 0x00,
- 0x00, 0xe0, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00,
- 0xc0, 0x03, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x80, 0x1f, 0xc0, 0x0f, 0x00,
- 0x00, 0x00, 0x00, 0xfc, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x3f,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00};
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xe0, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc,
+ 0xff, 0x01, 0x00, 0x00, 0x00, 0x80, 0x1f, 0xc2, 0x0f, 0x00, 0x00, 0x00,
+ 0xc0, 0x03, 0x02, 0x1e, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x02, 0x78, 0x00,
+ 0x00, 0x00, 0xb8, 0x00, 0x02, 0xf0, 0x00, 0x00, 0x00, 0x1c, 0x01, 0x00,
+ 0xc8, 0x01, 0x00, 0x00, 0x06, 0x01, 0x00, 0x04, 0x03, 0x00, 0x00, 0x07,
+ 0x02, 0x00, 0x02, 0x07, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x06, 0x00,
+ 0x80, 0x01, 0x00, 0x00, 0x00, 0x0c, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x00,
+ 0x1c, 0x00, 0xc0, 0x02, 0x00, 0x00, 0x00, 0x1a, 0x00, 0xff, 0x0c, 0x00,
+ 0x00, 0x80, 0xf9, 0x03, 0x6f, 0x10, 0x00, 0x00, 0x40, 0xb0, 0x03, 0x6f,
+ 0x00, 0x00, 0x00, 0x00, 0xb0, 0x03, 0x67, 0x00, 0x00, 0x00, 0x00, 0x30,
+ 0x03, 0x37, 0x00, 0x00, 0x00, 0x00, 0x60, 0x03, 0x37, 0x00, 0x00, 0x00,
+ 0x00, 0x60, 0x03, 0x37, 0x00, 0x00, 0x02, 0x00, 0x60, 0x03, 0x37, 0x00,
+ 0x00, 0x07, 0x00, 0x60, 0x03, 0xf7, 0x03, 0x80, 0x0d, 0x00, 0x7e, 0x03,
+ 0x37, 0x00, 0x00, 0x3f, 0x00, 0x60, 0x03, 0x37, 0x00, 0x00, 0xf2, 0x00,
+ 0x60, 0x03, 0x37, 0x00, 0x00, 0xc0, 0x03, 0x60, 0x03, 0x37, 0x00, 0x00,
+ 0x00, 0x07, 0x60, 0x03, 0x67, 0x00, 0x00, 0x00, 0x1c, 0x30, 0x03, 0x6f,
+ 0x00, 0x00, 0x00, 0x30, 0xb0, 0x03, 0x6f, 0x0c, 0x00, 0x00, 0x80, 0xb1,
+ 0x03, 0xff, 0x03, 0x00, 0x00, 0x00, 0xfe, 0x03, 0xc0, 0x00, 0x00, 0x00,
+ 0x00, 0x18, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x80, 0x01,
+ 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x83, 0x00, 0x00, 0x08, 0x06, 0x00,
+ 0x00, 0x47, 0x00, 0x00, 0x10, 0x07, 0x00, 0x00, 0x26, 0x00, 0x00, 0x20,
+ 0x03, 0x00, 0x00, 0x1c, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x38, 0x00,
+ 0x00, 0xe0, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00,
+ 0xc0, 0x03, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x80, 0x1f, 0xc0, 0x0f, 0x00,
+ 0x00, 0x00, 0x00, 0xfc, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x3f,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00
+};
+
/*@ +type @*/