users.c

Go to the documentation of this file.
00001 #include <stdio.h>
00002 #include <string.h>
00003 #include <libxml/xmlmemory.h>
00004 #include <libxml/parser.h>
00005 #include <glib.h>
00006 
00007 #include "lpbot.h"
00008 
00018 int parseUser(xmlDoc *doc, xmlNode *cur)
00019 {
00020         xmlChar *key;
00021         cur = cur->xmlChildrenNode;
00022         lp_user *user = g_new0(lp_user, 1);
00023 
00024 
00025         while (cur)
00026         {
00027                 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
00028                 if ((!xmlStrcmp(cur->name, (const xmlChar *)"login")))
00029                         user->login = strdup((char*)key);
00030                 else if ((!xmlStrcmp(cur->name, (const xmlChar *)"pass")))
00031                         user->pass = strdup((char*)key);
00032                 else if ((!xmlStrcmp(cur->name, (const xmlChar *)"email")))
00033                         user->email = strdup((char*)key);
00034                 else if ((!xmlStrcmp(cur->name, (const xmlChar *)"right_db")))
00035                 {
00036                         if(atoi((char*)key))
00037                                 user->rights |= LP_RIGHT_DB;
00038                 }
00039                 else if ((!xmlStrcmp(cur->name, (const xmlChar *)"right_op")))
00040                 {
00041                         if(atoi((char*)key))
00042                                 user->rights |= LP_RIGHT_OP;
00043                 }
00044                 xmlFree(key);
00045                 cur = cur->next;
00046         }
00047         config->users = g_list_append(config->users, user);
00048         return(0);
00049 }
00053 void lp_user_free(lp_user *usr)
00054 {
00055         free(usr->login);
00056         free(usr->email);
00057         free(usr->pass);
00058 }
00059 /* @} */

Generated on Mon May 19 15:36:55 2008 for lpbot by  doxygen 1.5.4