r4456 - in developers/alphaone/u-blox/libubx: . src

alphaone at docs.openmoko.org alphaone at docs.openmoko.org
Wed May 28 01:27:30 CEST 2008


Author: alphaone
Date: 2008-05-28 01:27:30 +0200 (Wed, 28 May 2008)
New Revision: 4456

Added:
   developers/alphaone/u-blox/libubx/src/ubx-get.c
Modified:
   developers/alphaone/u-blox/libubx/ChangeLog
   developers/alphaone/u-blox/libubx/src/Makefile.am
Log:
* libubx/src/Makefile.am, libubx/src/ubx-get.c: Add boilerplate code for ubx-get


Modified: developers/alphaone/u-blox/libubx/ChangeLog
===================================================================
--- developers/alphaone/u-blox/libubx/ChangeLog	2008-05-27 23:27:22 UTC (rev 4455)
+++ developers/alphaone/u-blox/libubx/ChangeLog	2008-05-27 23:27:30 UTC (rev 4456)
@@ -1,3 +1,8 @@
+2008-05-12	Daniel Willmann <daniel at openmoko.org>
+
+	* libubx/src/Makefile.am, libubx/src/ubx-get.c: Add boilerplate code for
+	ubx-get
+
 2008-05-02	Daniel Willmann <daniel at openmoko.org>
 
 	* COPYING src/libubx.c, src/ubx-parse.c: Add license

Modified: developers/alphaone/u-blox/libubx/src/Makefile.am
===================================================================
--- developers/alphaone/u-blox/libubx/src/Makefile.am	2008-05-27 23:27:22 UTC (rev 4455)
+++ developers/alphaone/u-blox/libubx/src/Makefile.am	2008-05-27 23:27:30 UTC (rev 4456)
@@ -1,9 +1,17 @@
 INCLUDES = -I${top_srcdir}/include
 
+bin_PROGRAMS = ubx-get
+
+ubx_get_SOURCES = \
+	ubx-get.c
+
+ubx_get_LDADD = \
+	-lubx -L${top_srcdir}/src
+
 lib_LTLIBRARIES = libubx.la
 
 libubx_la_SOURCES =	\
 	libubx.c \
 	ubx-parse.c
 
-#libdiversity_xmpp_backend_la_LIBADD =
+#libubx_la_LIBADD =

Added: developers/alphaone/u-blox/libubx/src/ubx-get.c
===================================================================
--- developers/alphaone/u-blox/libubx/src/ubx-get.c	                        (rev 0)
+++ developers/alphaone/u-blox/libubx/src/ubx-get.c	2008-05-27 23:27:30 UTC (rev 4456)
@@ -0,0 +1,110 @@
+/** ubx-get - Get configuration options of u-blox device
+ *
+ * Copyright (C) 2008 Openmoko, Inc.
+ *
+ * Authored by Daniel Willmann <daniel at openmoko.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include <getopt.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <libubx.h>
+
+
+/* Flag set by `--verbose'. */
+static int verbose_flag;
+static int get_alm, get_eph;
+static char *gpsname, *filename;
+
+int main (int argc, char *argv[])
+{
+  int c;
+
+  while (1)
+    {
+      static struct option long_options[] =
+        {
+          {"verbose", no_argument,       0, 'v'},
+					{"gps",			required_argument, 0, 'g'},
+          {"file",    required_argument, 0, 'f'},
+          {"almanac", no_argument,			 0, 'a'},
+          {"ephemeris", no_argument,		 0, 'e'},
+          {0, 0, 0, 0}
+        };
+      /* getopt_long stores the option index here. */
+      int option_index = 0;
+
+      c = getopt_long (argc, argv, "vg:f:ae",
+                       long_options, &option_index);
+
+      /* Detect the end of the options. */
+      if (c == -1)
+        break;
+
+      switch (c)
+        {
+        case 0:
+          /* If this option set a flag, do nothing else now. */
+          if (long_options[option_index].flag != 0)
+            break;
+          printf ("option %s", long_options[option_index].name);
+          if (optarg)
+            printf (" with arg %s", optarg);
+          printf ("\n");
+          break;
+
+        case 'v':
+          verbose_flag = 1;
+          break;
+
+        case 'g':
+          gpsname = optarg;
+          break;
+
+        case 'f':
+          filename = optarg;
+          break;
+
+        case 'a':
+					get_alm = 1;
+          break;
+
+        case 'e':
+					get_eph = 1;
+          break;
+
+        case '?':
+          /* getopt_long already printed an error message. */
+          break;
+
+        default:
+          abort ();
+        }
+    }
+
+  /* Print any remaining command line arguments (not options). */
+  if (optind < argc)
+    {
+      printf ("non-option ARGV-elements: ");
+      while (optind < argc)
+        printf ("%s ", argv[optind++]);
+      putchar ('\n');
+    }
+
+  exit (0);
+}
+





More information about the commitlog mailing list