summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/pacman/log.c40
-rw-r--r--src/pacman/log.h8
-rw-r--r--src/pacman/util.c40
-rw-r--r--src/pacman/util.h1
4 files changed, 42 insertions, 47 deletions
diff --git a/src/pacman/log.c b/src/pacman/log.c
index dd70492f..caa0410b 100644
--- a/src/pacman/log.c
+++ b/src/pacman/log.c
@@ -113,4 +113,44 @@ void vprint(char *fmt, ...)
}
}
+/* presents a prompt and gets a Y/N answer
+ */
+int yesno(char *fmt, ...)
+{
+ char str[LOG_STR_LEN];
+ char response[32];
+ va_list args;
+
+ if(config->noconfirm) {
+ return(1);
+ }
+
+ va_start(args, fmt);
+ vsnprintf(str, LOG_STR_LEN, fmt, args);
+ va_end(args);
+ MSG(NL, str);
+
+ if(fgets(response, 32, stdin)) {
+ /* trim whitespace and newlines */
+ char *pch = response;
+ while(isspace(*pch)) {
+ pch++;
+ }
+ if(pch != response) {
+ memmove(response, pch, strlen(pch) + 1);
+ }
+ pch = response + strlen(response) - 1;
+ while(isspace(*pch)) {
+ pch--;
+ }
+ *++pch = 0;
+ strtrim(response);
+
+ if(!strcasecmp(response, "Y") || !strcasecmp(response, "YES") || !strlen(response)) {
+ return(1);
+ }
+ }
+ return(0);
+}
+
/* vim: set ts=2 sw=2 noet: */
diff --git a/src/pacman/log.h b/src/pacman/log.h
index 28999fd3..6cd5b346 100644
--- a/src/pacman/log.h
+++ b/src/pacman/log.h
@@ -26,11 +26,6 @@
pm_fprintf(stderr, line, "error: "); \
pm_fprintf(stderr, CL, fmt, ##args); \
} while(0)
-#define DBG(line, fmt, args...) do { \
- char str[256]; \
- snprintf(str, 256, fmt, ##args); \
- cb_log(PM_LOG_DEBUG, str); \
-} while(0)
enum {
NL, /* new line */
@@ -41,9 +36,10 @@ enum {
void cb_log(unsigned short level, char *msg);
void pm_fprintf(FILE *file, unsigned short line, char *fmt, ...);
-
void vprint(char *fmt, ...);
+int yesno(char *fmt, ...);
+
#endif /* _PM_LOG_H */
/* vim: set ts=2 sw=2 noet: */
diff --git a/src/pacman/util.c b/src/pacman/util.c
index 16939099..757244a5 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -40,7 +40,6 @@
#include "conf.h"
extern int maxcols;
-extern int neednl;
extern config_t *config;
/* does the same thing as 'mkdir -p' */
@@ -189,45 +188,6 @@ char *strtrim(char *str)
return str;
}
-/* presents a prompt and gets a Y/N answer
- */
-int yesno(char *fmt, ...)
-{
- char response[32];
- va_list args;
-
- if(config->noconfirm) {
- return(1);
- }
-
- va_start(args, fmt);
- vprintf(fmt, args);
- va_end(args);
- fflush(stdout);
- neednl = 1;
- if(fgets(response, 32, stdin)) {
- /* trim whitespace and newlines */
- char *pch = response;
- while(isspace(*pch)) {
- pch++;
- }
- if(pch != response) {
- memmove(response, pch, strlen(pch) + 1);
- }
- pch = response + strlen(response) - 1;
- while(isspace(*pch)) {
- pch--;
- }
- *++pch = 0;
- strtrim(response);
-
- if(!strcasecmp(response, "Y") || !strcasecmp(response, "YES") || !strlen(response)) {
- return(1);
- }
- }
- return(0);
-}
-
/* match a string against a regular expression */
int reg_match(char *string, char *pattern)
{
diff --git a/src/pacman/util.h b/src/pacman/util.h
index f9d8d847..3cce4d3d 100644
--- a/src/pacman/util.h
+++ b/src/pacman/util.h
@@ -45,7 +45,6 @@ int rmrf(char *path);
void indentprint(char *str, int indent);
char *strtrim(char *str);
char *strtoupper(char *str);
-int yesno(char *fmt, ...);
int reg_match(char *string, char *pattern);
#endif /* _PM_UTIL_H */