From: pk910 Date: Wed, 3 Aug 2011 12:46:00 +0000 (+0200) Subject: give the possibility to pass an error message to the user X-Git-Url: http://git.pk910.de/?p=iauth.git;a=commitdiff_plain;h=6c5d28e7d64367ce02b2004513a1c35a77c0814a give the possibility to pass an error message to the user --- diff --git a/iauth.h b/iauth.h index 2e0abf6..05d43ed 100644 --- a/iauth.h +++ b/iauth.h @@ -108,6 +108,7 @@ struct iauth_result { char host[IAUTH_DATALEN + 1]; char ip[IAUTH_DATALEN + 1]; char modes[IAUTH_DATALEN + 1]; + char str[600]; }; extern const struct iauth_result *iauth_query(struct iauth_client *cli); extern char iauth_servname[IAUTH_DATALEN + 1]; diff --git a/iauth_query.c b/iauth_query.c index 7c7c714..d0026ff 100644 --- a/iauth_query.c +++ b/iauth_query.c @@ -113,6 +113,18 @@ const struct iauth_result *iauth_query(struct iauth_client *cli) { return NULL; } *arg++ = 0; + if(strcmp(tread, "error") == 0) { + strcpy(res.cclass, "error"); + tread = arg; + if(!(arg = strchr(tread, '%'))) { + close(fds[0]); + return NULL; + } + *arg++ = 0; + + strcpy(res.str, tread); + return &res; + } if(strcmp(tread, "$") == 0 || strlen(tread) > IAUTH_DATALEN) res.cclass[0] = 0; else strcpy(res.cclass, tread); @@ -148,10 +160,11 @@ const struct iauth_result *iauth_query(struct iauth_client *cli) { /* Read modes string. */ tread = arg; - if(!*tread) { + if(!(arg = strchr(tread, '%'))) { close(fds[0]); return NULL; } + *arg++ = 0; if(strcmp(tread, "$") == 0 || strlen(tread) > IAUTH_DATALEN) res.modes[0] = 0; else strcpy(res.modes, tread);