From: Frederic Marchal Date: Thu, 6 Jun 2013 09:55:56 +0000 (+0200) Subject: Add a function to look a user up by IP address X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=05fea6e75cf52d5f34bfec9d4e6099849386d32d;p=thirdparty%2Fsarg.git Add a function to look a user up by IP address The function is currently unused but I might have had some use for it so I left it in the code. --- diff --git a/include/defs.h b/include/defs.h index 9431913..58195e3 100755 --- a/include/defs.h +++ b/include/defs.h @@ -295,6 +295,7 @@ void userinfo_free(void); void userinfo_label(struct userinfostruct *uinfo,const char *label); /*@shared@*/struct userinfostruct *userinfo_find_from_file(const char *filename); /*@shared@*/struct userinfostruct *userinfo_find_from_id(const char *id); +/*@shared@*/struct userinfostruct *userinfo_find_from_ip(const char *ip); userscan userinfo_startscan(void); void userinfo_stopscan(userscan uscan); struct userinfostruct *userinfo_advancescan(userscan uscan); diff --git a/userinfo.c b/userinfo.c index 24b038f..c535cee 100644 --- a/userinfo.c +++ b/userinfo.c @@ -216,6 +216,19 @@ struct userinfostruct *userinfo_find_from_id(const char *id) return(NULL); } +struct userinfostruct *userinfo_find_from_ip(const char *ip) +{ + struct usergroupstruct *group; + int i; + + for (group=first_user_group ; group ; group=group->next) { + for (i=0 ; inusers ; i++) + if (strcmp(ip,group->list[i].ip)==0) + return(group->list+i); + } + return(NULL); +} + /*! Start the scanning of the user list.