XML * user_get (const char * username) { char buf[1024]; FILE * file; XML * ret; if (!strcmp (username, "anonymous")) { ret = xml_create ("user"); xml_set (ret, "name", "anonymous"); return (ret); } sprintf (buf, "%s%s.xml", USER_REPOSITORY, username); file = fopen (buf, "r"); if (!file) return NULL; ret = xml_read (file); fclose (file); return (ret); } |
int user_save (XML * user) { char buf[1024]; FILE * file; sprintf (buf, "%s%s.xml", USER_REPOSITORY, xml_attrval (user, "name")); file = fopen (buf, "w+"); if (!file) return 1; xml_write (file, user); fclose (file); return (0); } |
XML * group_get (const char * groupname) { char buf[1024]; FILE * file; XML * ret; sprintf (buf, "%s%s.xml", GROUP_REPOSITORY, groupname); file = fopen (buf, "r"); if (!file) { ret = xml_create ("group"); xml_set (ret, "name", groupname); return (ret); } ret = xml_read (file); fclose (file); return (ret); } |
int group_save (XML * group) { char buf[1024]; FILE * file; sprintf (buf, "%s%s.xml", GROUP_REPOSITORY, xml_attrval (group, "name")); file = fopen (buf, "w+"); if (!file) return 1; xml_write (file, group); fclose (file); return (0); } |
This code and documentation are released under the terms of the GNU license. They are additionally copyright (c) 2000, Vivtek. All rights reserved except those explicitly granted under the terms of the GNU license. |