mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 21:38:32 +08:00
ACPICA: Common: Enhance acpi_getopt() to improve portability
This patch enhances acpi_getopt() by converting the standard C library invocations into portable ACPI string APIs and acpi_log_error() to improve portability. Lv Zheng. Signed-off-by: Lv Zheng <lv.zheng@intel.com> Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This commit is contained in:
parent
3c9349c937
commit
a92e95773d
@ -210,6 +210,8 @@ void acpi_ut_subsystem_shutdown(void);
|
|||||||
|
|
||||||
acpi_size acpi_ut_strlen(const char *string);
|
acpi_size acpi_ut_strlen(const char *string);
|
||||||
|
|
||||||
|
char *acpi_ut_strchr(const char *string, int ch);
|
||||||
|
|
||||||
char *acpi_ut_strcpy(char *dst_string, const char *src_string);
|
char *acpi_ut_strcpy(char *dst_string, const char *src_string);
|
||||||
|
|
||||||
char *acpi_ut_strncpy(char *dst_string,
|
char *acpi_ut_strncpy(char *dst_string,
|
||||||
|
@ -1254,4 +1254,8 @@ struct acpi_memory_list {
|
|||||||
#define ACPI_FILE_BEGIN 0x01
|
#define ACPI_FILE_BEGIN 0x01
|
||||||
#define ACPI_FILE_END 0x02
|
#define ACPI_FILE_END 0x02
|
||||||
|
|
||||||
|
/* Definitions of getopt */
|
||||||
|
|
||||||
|
#define ACPI_OPT_END -1
|
||||||
|
|
||||||
#endif /* __ACTYPES_H__ */
|
#endif /* __ACTYPES_H__ */
|
||||||
|
@ -51,14 +51,12 @@
|
|||||||
* "f|" - Option has required single-char sub-options
|
* "f|" - Option has required single-char sub-options
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <acpi/acpi.h>
|
#include <acpi/acpi.h>
|
||||||
#include "accommon.h"
|
#include "accommon.h"
|
||||||
#include "acapps.h"
|
#include "acapps.h"
|
||||||
|
|
||||||
#define ACPI_OPTION_ERROR(msg, badchar) \
|
#define ACPI_OPTION_ERROR(msg, badchar) \
|
||||||
if (acpi_gbl_opterr) {fprintf (stderr, "%s%c\n", msg, badchar);}
|
if (acpi_gbl_opterr) {acpi_log_error ("%s%c\n", msg, badchar);}
|
||||||
|
|
||||||
int acpi_gbl_opterr = 1;
|
int acpi_gbl_opterr = 1;
|
||||||
int acpi_gbl_optind = 1;
|
int acpi_gbl_optind = 1;
|
||||||
@ -113,7 +111,7 @@ int acpi_getopt_argument(int argc, char **argv)
|
|||||||
* PARAMETERS: argc, argv - from main
|
* PARAMETERS: argc, argv - from main
|
||||||
* opts - options info list
|
* opts - options info list
|
||||||
*
|
*
|
||||||
* RETURN: Option character or EOF
|
* RETURN: Option character or ACPI_OPT_END
|
||||||
*
|
*
|
||||||
* DESCRIPTION: Get the next option
|
* DESCRIPTION: Get the next option
|
||||||
*
|
*
|
||||||
@ -128,10 +126,10 @@ int acpi_getopt(int argc, char **argv, char *opts)
|
|||||||
if (acpi_gbl_optind >= argc ||
|
if (acpi_gbl_optind >= argc ||
|
||||||
argv[acpi_gbl_optind][0] != '-' ||
|
argv[acpi_gbl_optind][0] != '-' ||
|
||||||
argv[acpi_gbl_optind][1] == '\0') {
|
argv[acpi_gbl_optind][1] == '\0') {
|
||||||
return (EOF);
|
return (ACPI_OPT_END);
|
||||||
} else if (strcmp(argv[acpi_gbl_optind], "--") == 0) {
|
} else if (ACPI_STRCMP(argv[acpi_gbl_optind], "--") == 0) {
|
||||||
acpi_gbl_optind++;
|
acpi_gbl_optind++;
|
||||||
return (EOF);
|
return (ACPI_OPT_END);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,7 +140,7 @@ int acpi_getopt(int argc, char **argv, char *opts)
|
|||||||
/* Make sure that the option is legal */
|
/* Make sure that the option is legal */
|
||||||
|
|
||||||
if (current_char == ':' ||
|
if (current_char == ':' ||
|
||||||
(opts_ptr = strchr(opts, current_char)) == NULL) {
|
(opts_ptr = ACPI_STRCHR(opts, current_char)) == NULL) {
|
||||||
ACPI_OPTION_ERROR("Illegal option: -", current_char);
|
ACPI_OPTION_ERROR("Illegal option: -", current_char);
|
||||||
|
|
||||||
if (argv[acpi_gbl_optind][++current_char_ptr] == '\0') {
|
if (argv[acpi_gbl_optind][++current_char_ptr] == '\0') {
|
||||||
|
@ -166,7 +166,8 @@ static int ap_do_options(int argc, char **argv)
|
|||||||
|
|
||||||
/* Command line options */
|
/* Command line options */
|
||||||
|
|
||||||
while ((j = acpi_getopt(argc, argv, AP_SUPPORTED_OPTIONS)) != EOF)
|
while ((j =
|
||||||
|
acpi_getopt(argc, argv, AP_SUPPORTED_OPTIONS)) != ACPI_OPT_END)
|
||||||
switch (j) {
|
switch (j) {
|
||||||
/*
|
/*
|
||||||
* Global options
|
* Global options
|
||||||
|
Loading…
Reference in New Issue
Block a user