diff options
| author | David Sommerseth <dazo@users.sourceforge.net> | 2009-09-04 00:48:52 +0200 |
|---|---|---|
| committer | David Sommerseth <dazo@users.sourceforge.net> | 2009-09-04 00:48:52 +0200 |
| commit | da402ffcbe7e9a616bab83739b7294ce9f5e79c4 (patch) | |
| tree | 8e85cd3f72a1cfa5b1600461b687917423eb2c9d /eurephiadm/client_session.c | |
| parent | 2dcc5b5da4291e0cb4fb9fce6134dc836e92c344 (diff) | |
| download | eurephia-da402ffcbe7e9a616bab83739b7294ce9f5e79c4.tar.gz eurephia-da402ffcbe7e9a616bab83739b7294ce9f5e79c4.tar.xz eurephia-da402ffcbe7e9a616bab83739b7294ce9f5e79c4.zip | |
Added doxygen comments for the main eurephiadm parts
Diffstat (limited to 'eurephiadm/client_session.c')
| -rw-r--r-- | eurephiadm/client_session.c | 52 |
1 files changed, 49 insertions, 3 deletions
diff --git a/eurephiadm/client_session.c b/eurephiadm/client_session.c index dd86cb8..90a99a6 100644 --- a/eurephiadm/client_session.c +++ b/eurephiadm/client_session.c @@ -19,6 +19,15 @@ * */ +/** + * @file client_session.c + * @author David Sommerseth <dazo@users.sourceforge.net> + * @date 2008-12-01 + * + * @brief Functions for working on eurephiaSESSIONs outside the openvpn plug-in + * + */ + #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -37,7 +46,13 @@ #include "client_config.h" - +/** + * Get a file name to a session file. This file can be found in either EUREPHIADM_SESSION + * environment variable, in the users ~/.eurephia or the directory defined by the EUREPHIA_DIR + * environment variable. + * + * @return Returns a full path to the session file on success, otherwise NULL. + */ char *get_session_file() { char *fname = NULL; @@ -51,6 +66,14 @@ char *get_session_file() { return fname; } + +/** + * Reads the session key and does a quick validation of it. + * + * @param ctx eurephiaCTX + * + * @return Returns a string (char *) containing the session key on success, otherwise NULL. + */ char *read_session_file(eurephiaCTX *ctx) { char *sesskey = NULL, *fname = NULL; FILE *sfp = NULL; @@ -74,6 +97,14 @@ char *read_session_file(eurephiaCTX *ctx) { return sesskey; } +/** + * Writes a session key to disk, to keep session logged in over a longer time. + * + * @param ctx eurephiaCTX + * @param sess eurephiaSESSION with session info for the current logged in user. + * + * @return Returns 1 on success, otherwise 0. + */ int write_session_file(eurephiaCTX *ctx, eurephiaSESSION *sess) { struct stat fchk; char *fname = NULL; @@ -98,6 +129,12 @@ int write_session_file(eurephiaCTX *ctx, eurephiaSESSION *sess) { return 1; } + +/** + * Removes the session file, used when logging out or the user is automatically logged out. + * + * @param ctx eurephiaCTX + */ void remove_session_file(eurephiaCTX *ctx) { const char *fname = NULL; @@ -109,6 +146,15 @@ void remove_session_file(eurephiaCTX *ctx) { }; } +/** + * Create a eurephiaSESSION. If session key is given, it will try to load that session back. + * If no session key is given, it will create a brand new user session. + * + * @param ctx eurephiaCTX + * @param sesskey session key, used for loading existing sessions back. + * + * @return Returns a eurephiaSESSION pointer to a session, either new or old. On failure, NULL is returned. + */ eurephiaSESSION *create_session(eurephiaCTX *ctx, const char *sesskey) { eurephiaSESSION *new_sess = NULL; int loop, uniqchk; @@ -167,8 +213,8 @@ eurephiaSESSION *create_session(eurephiaCTX *ctx, const char *sesskey) { if( uniqchk == 0 ) { eurephia_log(ctx, LOG_FATAL, 0, - "Did not manage to create a unique session key after %i attemtps. Aborting.", - loop-1); + "Did not manage to create a unique session key after %i attempts." + " Aborting.", loop-1); free_nullsafe(new_sess->sessionkey); free_nullsafe(new_sess); return NULL; |
