From 6c5d28e7d64367ce02b2004513a1c35a77c0814a Mon Sep 17 00:00:00 2001 From: pk910 Date: Wed, 3 Aug 2011 14:46:00 +0200 Subject: [PATCH] give the possibility to pass an error message to the user --- iauth.h | 1 + iauth_query.c | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) 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); -- 2.20.1