mirror of
https://gitee.com/xiaohuolufeihua/bizhang_-obav.git
synced 2026-05-22 01:12:31 +00:00
Some fixes for getopt_long
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
};
|
||||
|
||||
@@ -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));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user