-/* user.c - the itsy package management system
+/* user.c - the opkg package management system
Jamey Hicks
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
*/
-
+#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
+#include <string.h>
#include "file_util.h"
#include "str_util.h"
-#include "libopkg.h"
-
+#include "user.h"
static char *question = NULL;
static int question_len = 255;
+opkg_response_callback opkg_cb_response = NULL;
+
char *get_user_response(const char *format, ...)
{
int len = question_len;
va_list ap;
char *response;
- va_start(ap, format);
do {
if (question == NULL || len > question_len) {
question = realloc(question, len + 1);
question_len = len;
}
+
+ va_start(ap, format);
len = vsnprintf(question,question_len,format,ap);
+ va_end(ap);
} while (len > question_len);
response = strdup(opkg_cb_response(question));
str_chomp(response);