]> git.ipfire.org Git - pakfire.git/commitdiff
UI: Drop the default confirm callback
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 9 Nov 2022 10:08:33 +0000 (10:08 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 9 Nov 2022 10:08:33 +0000 (10:08 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/include/pakfire/ui.h
src/libpakfire/pakfire.c
src/libpakfire/ui.c

index dc1c0357a0f1dfe3fa89c7c0fad96a70c1b748fa..7bb955873631b620dd121a3ec05fde9b0deeab22 100644 (file)
@@ -25,9 +25,6 @@
 
 #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
index 0e22e86d69621c021c3f7140a51c6fb8d0bbd3d6..3b53c3afb6a60875807561a57d95ccb40bd02046 100644 (file)
@@ -748,9 +748,6 @@ PAKFIRE_EXPORT int pakfire_create(struct pakfire** pakfire, const char* path,
                        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)
index ca0d1164d084c744826b768031b28e25916cc626..61d794387ade3b245f99e92ec2ceb83227f69df5 100644 (file)
 #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;