mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-20 15:48:29 -04:00
AP_HAL: allow getopt_cpp on QURT
avoid using stderr
This commit is contained in:
parent
ea1e3f4928
commit
dafc9b4c6b
@ -36,12 +36,19 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <AP_HAL/AP_HAL.h>
|
#include <AP_HAL/AP_HAL.h>
|
||||||
#if HAL_OS_POSIX_IO && CONFIG_HAL_BOARD != HAL_BOARD_QURT
|
#if HAL_OS_POSIX_IO
|
||||||
|
|
||||||
#include "getopt_cpp.h"
|
#include "getopt_cpp.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#if CONFIG_HAL_BOARD == HAL_BOARD_QURT
|
||||||
|
#define GETOPT_ERROR(...) HAP_printf(__FILE__, __LINE__, __VA_ARGS__)
|
||||||
|
#else
|
||||||
|
#define GETOPT_ERROR(...) fprintf(stderr, __VA_ARGS__)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
constructor
|
constructor
|
||||||
*/
|
*/
|
||||||
@ -117,10 +124,10 @@ int GetOptLong::getoption(void)
|
|||||||
{
|
{
|
||||||
if (optstring[0] == ':')
|
if (optstring[0] == ':')
|
||||||
return BADARG;
|
return BADARG;
|
||||||
if (opterr)
|
if (opterr) {
|
||||||
fprintf(stderr,
|
GETOPT_ERROR("%s: option requires an argument -- %s\n",
|
||||||
"%s: option requires an argument -- %s\n",
|
argv[0], place);
|
||||||
argv[0], place);
|
}
|
||||||
place = "";
|
place = "";
|
||||||
optind++;
|
optind++;
|
||||||
return BADCH;
|
return BADCH;
|
||||||
@ -151,9 +158,9 @@ int GetOptLong::getoption(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opterr && optstring[0] != ':')
|
if (opterr && optstring[0] != ':') {
|
||||||
fprintf(stderr,
|
GETOPT_ERROR("%s: illegal option -- %s\n", argv[0], place);
|
||||||
"%s: illegal option -- %s\n", argv[0], place);
|
}
|
||||||
place = "";
|
place = "";
|
||||||
optind++;
|
optind++;
|
||||||
return BADCH;
|
return BADCH;
|
||||||
@ -168,9 +175,9 @@ int GetOptLong::getoption(void)
|
|||||||
{
|
{
|
||||||
if (!*place)
|
if (!*place)
|
||||||
++optind;
|
++optind;
|
||||||
if (opterr && *optstring != ':')
|
if (opterr && *optstring != ':') {
|
||||||
fprintf(stderr,
|
GETOPT_ERROR("%s: illegal option -- %c\n", argv[0], optopt);
|
||||||
"%s: illegal option -- %c\n", argv[0], optopt);
|
}
|
||||||
return BADCH;
|
return BADCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,10 +196,10 @@ int GetOptLong::getoption(void)
|
|||||||
place = "";
|
place = "";
|
||||||
if (*optstring == ':')
|
if (*optstring == ':')
|
||||||
return BADARG;
|
return BADARG;
|
||||||
if (opterr)
|
if (opterr) {
|
||||||
fprintf(stderr,
|
GETOPT_ERROR("%s: option requires an argument -- %c\n",
|
||||||
"%s: option requires an argument -- %c\n",
|
argv[0], optopt);
|
||||||
argv[0], optopt);
|
}
|
||||||
return BADCH;
|
return BADCH;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user