diff --git a/src/server/user_mgr.h b/src/server/user_mgr.h --- a/src/server/user_mgr.h +++ b/src/server/user_mgr.h @@ -27,13 +27,63 @@ struct user { - char *username; - int render_power; - int last_job; + 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); -int restart_From_XML_backup(); -int backup_list_XML(); #endif