mirror of https://github.com/djcb/mu.git
* lib/mu-util: add mu_util_read_password
This commit is contained in:
parent
c19b38654b
commit
52bc720258
|
@ -494,3 +494,27 @@ mu_util_printerr_encoded (const char *frm, ...)
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
char*
|
||||||
|
mu_util_read_password (const char *prompt)
|
||||||
|
{
|
||||||
|
char *pass, *tmp;
|
||||||
|
|
||||||
|
g_return_val_if_fail (prompt, NULL);
|
||||||
|
|
||||||
|
/* note: getpass is obsolete; replace with something better */
|
||||||
|
|
||||||
|
tmp = getpass (prompt);
|
||||||
|
if (!tmp) {
|
||||||
|
if (errno)
|
||||||
|
g_warning ("error: %s", strerror(errno));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
/* make sure we can free with g_free(), not free() */
|
||||||
|
|
||||||
|
pass = g_strdup (tmp);
|
||||||
|
free (tmp);
|
||||||
|
|
||||||
|
return pass;
|
||||||
|
}
|
||||||
|
|
|
@ -179,6 +179,16 @@ gboolean mu_util_printerr_encoded (const char *frm, ...) G_GNUC_PRINTF(1,2);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* read a password from stdin (without echoing), and return it.
|
||||||
|
*
|
||||||
|
* @param prompt the prompt text before the password
|
||||||
|
*
|
||||||
|
* @return the password (free with g_free), or NULL
|
||||||
|
*/
|
||||||
|
char* mu_util_read_password (const char *prompt)
|
||||||
|
G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Try to 'play' (ie., open with it's associated program) a file. On
|
* Try to 'play' (ie., open with it's associated program) a file. On
|
||||||
* MacOS, the the program 'open' is used for this; on other platforms
|
* MacOS, the the program 'open' is used for this; on other platforms
|
||||||
|
|
Loading…
Reference in New Issue