-__attribute__((format(printf, 5, 6)))
-static void clogger(struct crypt_device *cd, int level, const char *file,
- int line, const char *format, ...)
-{
- va_list argp;
- char *target = NULL;
-
- va_start(argp, format);
-
- if (vasprintf(&target, format, argp) > 0) {
- if (level >= 0) {
- crypt_log(cd, level, target);
-#ifdef CRYPT_DEBUG
- } else if (opt_debug)
- printf("# %s:%d %s\n", file ?: "?", line, target);
-#else
- } else if (opt_debug)
- printf("# %s\n", target);
-#endif
- }
-
- va_end(argp);
- free(target);
-}
-
-static int _yesDialog(const char *msg, void *usrptr __attribute__((unused)))
-{
- char *answer = NULL;
- size_t size = 0;
- int r = 1;
-
- if(isatty(0) && !opt_batch_mode) {
- log_std("\nWARNING!\n========\n");
- log_std("%s\n\nAre you sure? (Type uppercase yes): ", msg);
- if(getline(&answer, &size, stdin) == -1) {
- perror("getline");
- free(answer);
- return 0;
- }
- if(strcmp(answer, "YES\n"))
- r = 0;
- free(answer);
- }
-
- return r;
-}
-
-static void _log(int level, const char *msg, void *usrptr __attribute__((unused)))
-{
- switch(level) {
-
- case CRYPT_LOG_NORMAL:
- fputs(msg, stdout);
- break;
- case CRYPT_LOG_VERBOSE:
- if (opt_verbose)
- fputs(msg, stdout);
- break;
- case CRYPT_LOG_ERROR:
- fputs(msg, stderr);
- break;
- case CRYPT_LOG_DEBUG:
- if (opt_debug)
- printf("# %s\n", msg);
- break;
- default:
- fprintf(stderr, "Internal error on logging class for msg: %s", msg);
- break;
- }
-}
-
-static void show_status(int errcode)