X-Git-Url: http://git.tuebingen.mpg.de/?p=adu.git;a=blobdiff_plain;f=interactive.c;h=61b4f293562bfe8077f9bcc25f528887605bb7ce;hp=08f700f7a6cd2d423d0a37e84e9ee09727536745;hb=6744ce67f91c410f69de0763fb6faa01a8a53b28;hpb=25e4fb919ce9b87aeb5aa3456b687c5c3ba55a9e diff --git a/interactive.c b/interactive.c index 08f700f..61b4f29 100644 --- a/interactive.c +++ b/interactive.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008 Andre Noll + * Copyright (C) 2008 Andre Noll * * Licensed under the GPL v2. For licencing details see COPYING. */ @@ -110,7 +110,6 @@ static int icom_reset(__a_unused char *line) static int icom_set(char *line) { - int ret; struct select_cmdline_parser_params params = { .override = 1, .initialize = 0, @@ -127,12 +126,24 @@ static int icom_set(char *line) fi = NULL; free(admissible_uids); admissible_uids = NULL; - ret = parse_select_options(line, ¶ms, &admissible_uids, &fi); - if (ret >= 0) - return ret; - return icom_reset(NULL); + return parse_select_options(line, ¶ms, &admissible_uids, &fi); } +/** + * Wrapper for isspace. + * NetBSD needs this. + */ +/* + * The values should be cast to an unsigned char first, then to int. + * Why? Because the isdigit (as do all other is/to functions/macros) + * expect a number from 0 upto and including 255 as their (int) argument. + * Because char is signed on most systems, casting it to int immediately + * gives the functions an argument between -128 and 127 (inclusive), + * which they will use as an array index, and which will thus fail + * horribly for characters which have their most significant bit set. + */ +#define adu_isspace(c) isspace((int)(unsigned char)(c)) + static int exec_interactive_command(char *line) { const char const *delim = "\t\n\f\r\v "; @@ -145,7 +156,7 @@ static int exec_interactive_command(char *line) return 1; len = strlen(line); - while (len && isspace(line[len - 1])) { + while (len && adu_isspace(line[len - 1])) { line[len - 1] = '\0'; len--; } @@ -208,19 +219,20 @@ out: int com_interactive(void) { char line[255]; - int ret = 1; + int ret; select_cmdline_parser_init(&select_conf); ret = parse_select_options(NULL, NULL, &admissible_uids, &fi); if (ret< 0) return ret; - ret = read_uid_file(conf.database_dir_arg); + ret = read_uid_file(); if (ret < 0) return ret; while (read_input_line(line, sizeof(line)) >= 0) { ret = exec_interactive_command(line); if (ret < 0) printf("%s\n", adu_strerror(-ret)); + fflush(NULL); } return ret; }