Main Page   Modules   File List  

session.h

00001 /*
00002     LibCGI - A library to make CGI programs using C
00003     Copyright (C) 2001 Rafael Steil
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Lesser General Public
00007     License as published by the Free Software Foundation; either
00008     version 2.1 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Lesser General Public License for more details.
00014 
00015     You should have received a copy of the GNU Lesser General Public
00016     License along with this library; if not, write to the Free Software
00017     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 
00019     You can contact the author by e-mail: rafael@insanecorp.com
00020 */
00021 
00022 #ifndef _SESSION_H
00023 #define _SESSION_H      1
00024 
00025 #ifdef __cplusplus
00026 extern "C" {
00027 #endif
00028 
00029 #ifndef SESSION_FILE_PREFIX
00030 #define SESSION_FILE_PREFIX "cgisess_"
00031 #endif
00032 
00033 // Just for compatibility with older versions of libcgi
00034 #define session_var(name) cgi_session_var(name)
00035 #define session_destroy() cgi_session_destroy()
00036 #define session_register_var(name, value) cgi_session_register_var(name, value)
00037 #define session_alter_var(name, value) cgi_session_alter_var(name, value)
00038 #define session_var_exists(name) cgi_session_var_exists(name)
00039 #define session_unregister_var(name) cgi_session_unregister_var(name)
00040 #define session_start() cgi_session_start()
00041 
00042 char SESSION_SAVE_PATH[255] = "/tmp/";
00043 char SESSION_COOKIE_NAME[50] = "CGISID";
00044 #define cgi_session_cookie_name(cookie_name) strncpy(SESSION_COOKIE_NAME, cookie_name, 49)
00045 #define cgi_session_save_path(path) strncpy(SESSION_SAVE_PATH, path, 254)
00046 
00047 #define cgi_session_var(var_name) List_item(var_name, sess_list_start)
00048 
00049 // General purpose session functions
00050 extern int sess_initialized;
00051 extern int session_lasterror;
00052 
00053 extern formvars *sess_list_start;
00054 
00055 // We can use this variable to get the error message from a ( possible ) session error
00056 // Use it togheter with session_lasterror
00057 // i.e: printf("Session error: %s<br>", session_error_message[session_last_error]);
00058 const char *session_error_message[] = {
00059         "Session not initialized",
00060         "Session file not initialized",
00061         "Headers already been sent",
00062         "Session already started",
00063         "Failed to create session file",
00064         "Failed to remove session file",
00065         "Failed to destroy the session",
00066         "Failed to remove session value from list",
00067         "Session variable already registered",
00068         "Session variable not registered",
00069         "Failed to open session file for manipulation"
00070 };
00071 
00072 // stores last session error that was occured
00073 extern int session_lasterror;
00074                                                                                         
00075 extern int cgi_session_destroy();
00076 extern int cgi_session_register_var(const char *name, const char *value);
00077 extern int cgi_session_alter_var(const char *name, const char *new_value);
00078 extern int cgi_session_var_exists(const char *name);
00079 extern int cgi_session_unregister_var(char *name);
00080 extern int cgi_session_start();
00081 
00082 #ifdef __cplusplus
00083 }
00084 #endif
00085 
00086 #endif // _SESSION_H

Generated on Thu Dec 26 22:12:30 2002 for LibCGI by doxygen1.3-rc2