From a66ce0dd11577b8220083555e5dfdae36103ad27 Mon Sep 17 00:00:00 2001 From: Johan Danielsson Date: Sun, 16 Nov 1997 11:00:01 +0000 Subject: [PATCH] Some cleanup. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@4032 ec53bebd-3082-4978-b11e-865c3cabbd6b --- kadmin/util.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/kadmin/util.c b/kadmin/util.c index 178c1f020..d137af62e 100644 --- a/kadmin/util.c +++ b/kadmin/util.c @@ -101,9 +101,10 @@ str2attr(const char *str, krb5_flags orig) } void -get_response(const char *def, char *buf, size_t len) +get_response(const char *prompt, const char *def, char *buf, size_t len) { char *p; + printf("%s [%s]:", prompt, def); fgets(buf, len, stdin); p = strchr(buf, '\n'); if(p) *p = 0; @@ -112,27 +113,29 @@ get_response(const char *def, char *buf, size_t len) buf[len-1] = 0; } +unsigned +get_deltat(const char *prompt, const char *def) +{ + char buf[128]; + get_response(prompt, def, buf, sizeof(buf)); + return str2deltat(buf); +} + int edit_entry(kadm5_principal_ent_t ent, int *mask) { - char buf[1024]; - char resp[1024]; - + char buf[1024], resp[1024]; + deltat2str(ent->max_life, buf, sizeof(buf)); - printf("Max ticket life [%s]:", buf); - get_response(buf, resp, sizeof(resp)); - ent->max_life = str2deltat(resp); + ent->max_life = get_deltat("Max ticket life", buf); *mask |= KADM5_MAX_LIFE; deltat2str(ent->max_renewable_life, buf, sizeof(buf)); - printf("Max renewable life [%s]:", buf); - get_response(buf, resp, sizeof(resp)); - ent->max_renewable_life = str2deltat(resp); + ent->max_renewable_life = get_deltat("Max renewable life", buf); *mask |= KADM5_MAX_RLIFE; attr2str(ent->attributes, buf, sizeof(buf)); - printf("Attributes [%s]:", buf); - get_response(buf, resp, sizeof(resp)); + get_response("Attributes", buf, resp, sizeof(resp)); ent->attributes = str2attr(resp, ent->attributes); *mask |= KADM5_ATTRIBUTES; }