/* Copyright 2010 Nathan Phillip Brink, Ethan Zonca, Matthew Orlando This file is a part of DistRen. DistRen is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. DistRen is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with DistRen. If not, see . */ /* * Stores, keeps track of, retrieves information concerning, * and backs up to XML DistRen's userdb system */ #ifndef _DISTREN_USER_MGR_H #define _DISTREN_USER_MGR_H struct user { char *username; char *pass; int render_power; int last_job; }; typedef struct user *user_t; struct user_mgr; typedef struct user_mgr *user_mgr_t; /** * \brief Allocate and initialize a user_mgr. * * \param userfile The path to where and XML file with user * information may be found and where the users file should be save * to when new users are added. * \return The new user_mgr or NULL on error. */ user_mgr_t user_mgr_init(const char *userfile); /** * \brief Find a user by username. * * \param user_mgr The user_mgr... * \param username The username to search for. * \return The user if it is in user_mgr or NULL. */ user_t user_find(user_mgr_t user_mgr, const char *username); /** * \brief Add a user to the user_mgr. * * \param username The user's username (which is local in scope to this server). * \param pass The user's plaintext password (insecurity is sooo much easier ;-) ). * \return 0 on success, 1 on failure (attempt to insert duplicate user, etc.). */ int user_add(user_mgr_t user_mgr, const char *username, const char *pass); /** * \brief Delete a user. * * The user handle passed to this function is no longer valid after * this function is called. * * \param user The user's handle as retrieved via user_find(). * \return 0 on success, 1 on failure (user does not exist, inconsistency, etc.) */ int user_delete(user_mgr_t user_mgr, user_t user); /** * \brief Write out the XML file listing all of the users local to this server. * * \param filename The file to write the userlist to or NULL if you * want to write to the same filename you loaded the usre_mgr from. */ int user_mgr_save(user_mgr_t user_mgr, const char *filename); #endif