Remove str_util.{c,h}
[oweals/opkg-lede.git] / libopkg / user.c
1 /* user.c - the opkg package management system
2
3    Jamey Hicks
4
5    Copyright (C) 2002 Hewlett Packard Company
6    Copyright (C) 2001 University of Southern California
7
8    This program is free software; you can redistribute it and/or
9    modify it under the terms of the GNU General Public License as
10    published by the Free Software Foundation; either version 2, or (at
11    your option) any later version.
12
13    This program is distributed in the hope that it will be useful, but
14    WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16    General Public License for more details.
17 */
18 #include <stdio.h>
19 #include <stdarg.h>
20 #include <unistd.h>
21 #include <ctype.h>
22
23 #include "file_util.h"
24
25 char *get_user_response(const char *format, ...)
26 {
27         int i;
28         va_list ap;
29         char *response;
30
31         va_start(ap, format);
32         vprintf(format, ap);
33         va_end(ap);
34
35         if (!isatty(fileno(stdin)))
36                 return NULL;
37
38         response = (char *)file_read_line_alloc(stdin);
39         if (response == NULL)
40                 return NULL;
41
42         for (i=0; response[i]; i++)
43                 response[i] = tolower(response[i]);
44
45         return response;
46 }