diff options
author | px4dev <px4@purgatory.org> | 2012-09-10 00:16:30 -0700 |
---|---|---|
committer | px4dev <px4@purgatory.org> | 2012-09-10 00:16:30 -0700 |
commit | b1767480d2a0930c60ca59b1b047a9018663556b (patch) | |
tree | 455b19d0a546bd212ff37399cd4cd763f0939c0a /apps/systemlib | |
parent | 68d4a26b9ead5a042edb14dd5c038df2908ea7fe (diff) | |
download | px4-firmware-b1767480d2a0930c60ca59b1b047a9018663556b.tar.gz px4-firmware-b1767480d2a0930c60ca59b1b047a9018663556b.tar.bz2 px4-firmware-b1767480d2a0930c60ca59b1b047a9018663556b.zip |
Some fixes for getopt_long
Diffstat (limited to 'apps/systemlib')
-rw-r--r-- | apps/systemlib/getopt_long.c | 18 | ||||
-rw-r--r-- | apps/systemlib/getopt_long.h | 10 | ||||
-rw-r--r-- | apps/systemlib/systemlib.c | 3 |
3 files changed, 17 insertions, 14 deletions
diff --git a/apps/systemlib/getopt_long.c b/apps/systemlib/getopt_long.c index 662d73ff1..27c38635f 100644 --- a/apps/systemlib/getopt_long.c +++ b/apps/systemlib/getopt_long.c @@ -87,9 +87,7 @@ gpietsch@comcast.net #include <stdio.h> #include <stdlib.h> #include <string.h> -#ifndef GETOPT_H #include "getopt_long.h" -#endif /* macros */ @@ -143,8 +141,8 @@ is_option (char *argv_element, int only) /* getopt_internal: the function that does all the dirty work */ static int -getopt_internal (int argc, char **argv, char *shortopts, - GETOPT_LONG_OPTION_T * longopts, int *longind, int only) +getopt_internal (int argc, char **argv, const char *shortopts, + const GETOPT_LONG_OPTION_T * longopts, int *longind, int only) { GETOPT_ORDERING_T ordering = PERMUTE; static size_t optwhere = 0; @@ -178,7 +176,7 @@ getopt_internal (int argc, char **argv, char *shortopts, shortopts++; } else - ordering = (getenv ("POSIXLY_CORRECT") != NULL) ? REQUIRE_ORDER : PERMUTE; + ordering = /*(getenv ("POSIXLY_CORRECT") != NULL) ? REQUIRE_ORDER :*/ PERMUTE; /* * based on ordering, find our next option, if we're at the beginning of @@ -381,22 +379,24 @@ getopt_internal (int argc, char **argv, char *shortopts, return optopt; } +#if 0 int getopt (int argc, char **argv, char *optstring) { return getopt_internal (argc, argv, optstring, NULL, NULL, 0); } +#endif int -getopt_long (int argc, char **argv, char *shortopts, - GETOPT_LONG_OPTION_T * longopts, int *longind) +getopt_long (int argc, char **argv, const char *shortopts, + const GETOPT_LONG_OPTION_T * longopts, int *longind) { return getopt_internal (argc, argv, shortopts, longopts, longind, 0); } int -getopt_long_only (int argc, char **argv, char *shortopts, - GETOPT_LONG_OPTION_T * longopts, int *longind) +getopt_long_only (int argc, char **argv, const char *shortopts, + const GETOPT_LONG_OPTION_T * longopts, int *longind) { return getopt_internal (argc, argv, shortopts, longopts, longind, 1); } diff --git a/apps/systemlib/getopt_long.h b/apps/systemlib/getopt_long.h index f372fedaa..3e51550a6 100644 --- a/apps/systemlib/getopt_long.h +++ b/apps/systemlib/getopt_long.h @@ -121,11 +121,13 @@ extern "C" extern int optopt; /* function prototypes */ +#if 0 int getopt (int argc, char **argv, char *optstring); - int getopt_long (int argc, char **argv, char *shortopts, - GETOPT_LONG_OPTION_T * longopts, int *longind); - int getopt_long_only (int argc, char **argv, char *shortopts, - GETOPT_LONG_OPTION_T * longopts, int *longind); +#endif + int getopt_long (int argc, char **argv, const char *shortopts, + const GETOPT_LONG_OPTION_T * longopts, int *longind); + int getopt_long_only (int argc, char **argv, const char *shortopts, + const GETOPT_LONG_OPTION_T * longopts, int *longind); #ifdef __cplusplus }; diff --git a/apps/systemlib/systemlib.c b/apps/systemlib/systemlib.c index bed5b1a10..4c7aae83e 100644 --- a/apps/systemlib/systemlib.c +++ b/apps/systemlib/systemlib.c @@ -176,7 +176,8 @@ int carrier_get_board_info(struct carrier_board_info_s *info) int ret; int fd = open("/dev/eeprom", O_RDONLY | O_NONBLOCK); - if (fd < 0) fprintf(stderr, "[boardinfo carrier] ERROR opening carrier eeprom\n"); + if (fd < 0) + return -1; /* no board */ ret = read(fd, info, sizeof(struct carrier_board_info_s)); |