#include <pakfire/request.h>
-int pakfire_ui_confirm(struct pakfire* pakfire, void* data,
- const char* message, const char* question);
-
int pakfire_ui_pick_solution(struct pakfire* pakfire, struct pakfire_request* request);
#endif
pakfire_log_set_priority(p, log_priority(env));
}
- // Setup confirm callback
- pakfire_set_confirm_callback(p, pakfire_ui_confirm, NULL);
-
// Initialise configuration
r = pakfire_config_create(&p->config);
if (r)
#include <pakfire/request.h>
#include <pakfire/ui.h>
-int pakfire_ui_confirm(struct pakfire* pakfire, void* data, const char* message,
- const char* question) {
- // The message is only printed once
- printf("%s\n", message);
-
- char* line = NULL;
- size_t length = 0;
- int r = 1;
-
- while (1) {
- // Print question
- printf("%s ", question);
-
- // Wait for user to enter something
- ssize_t bytes_read = getline(&line, &length, stdin);
- if (bytes_read < 0)
- goto END;
-
- // Must have one character and newline
- if (!line || strlen(line) != 2)
- continue;
-
- switch (*line) {
- // Positive response
- case 'Y':
- case 'y':
- r = 0;
- goto END;
-
- // Negative response
- case 'N':
- case 'n':
- r = 1;
- goto END;
-
- // Unknown input, repeat
- default:
- continue;
- }
- }
-
-END:
- if (line)
- free(line);
-
- return r;
-}
-
static int pakfire_ui_enter_number(struct pakfire* pakfire, const char* question,
unsigned int* choice, unsigned int min, unsigned int max) {
char* line = NULL;