]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Add a function to look a user up by IP address
authorFrederic Marchal <fmarchal@users.sourceforge.net>
Thu, 6 Jun 2013 09:55:56 +0000 (11:55 +0200)
committerFrederic Marchal <fmarchal@users.sourceforge.net>
Thu, 6 Jun 2013 09:55:56 +0000 (11:55 +0200)
The function is currently unused but I might have had some use for it so I
left it in the code.

include/defs.h
userinfo.c

index 9431913a69ad0d06312378cfc6f021a67db54ce9..58195e3ff7482b6ae449c50d2936b3295060991d 100755 (executable)
@@ -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);
index 24b038f15553cfd41cf30c45df138aabc1375c3c..c535ceed4ec02cf4af68e615800c546702242722 100644 (file)
@@ -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 ; i<group->nusers ; i++)
+                       if (strcmp(ip,group->list[i].ip)==0)
+                               return(group->list+i);
+       }
+       return(NULL);
+}
+
 /*!
 Start the scanning of the user list.