ESAPI-C 1.0
The OWASP Enterprise Security API for C
|
00001 00005 #include <string.h> 00006 00007 #include "user.h" 00008 00009 //void init_user(user *u) { 00010 // if (u) { 00011 // u->id = 0L; 00012 // strcpy(u->name, "UNKNOWN"); 00013 // u->roles = 0; 00014 // u->locked = 0; 00015 // } 00016 //} 00017 00018 // set name to UNKNOWN if set string is null 00019 //char *set_current_user(user *u, const char *s) { 00020 // if (u == 0) { 00021 // return 0; 00022 // } else if (u) { 00023 // if (s) { 00024 // strcpy(u->name, s); 00025 // } else { 00026 // strcpy(u->name, "UNKNOWN"); 00027 // } 00028 // } 00029 // return u->name; 00030 //} 00031 00032 //long get_current_id(user *u) { 00033 // if (u) { 00034 // return u->id; 00035 // } 00036 // return -1; 00037 //} 00038 00039 /* 00040 * Adds the role to the user's list of roles. 00041 * 00042 * @asserts u is not null, role is not null 00043 */ 00044 void add_role(user *u, char *role) { 00045 00046 if (!u->roles) { 00047 } else { 00048 } 00049 00050 } 00051 00052 /* 00053 * Adds the roles to the user's list of roles. 00054 * 00055 * @asserts u is not null, roles is not null 00056 */ 00057 void add_roles(user *u, char **roles) { 00058 if (!u->roles) { 00059 00060 } else { 00061 00062 } 00063 } 00064 00065 /* 00066 * Removes the role passed in from the user's list of roles. 00067 */ 00068 void remove_role(user *u, char *role) { 00069 00070 } 00071 00072 /* 00073 * Checks if the user has the role specified. 00074 */ 00075 int is_user_in_role(user *u, char *role) { 00076 return 0; 00077 } 00078 00079 /* 00080 * Changes the user's password to the password passed in. If the passwords 00081 * don't match, then return fail. 00082 */ 00083 int change_user_password(user *u, char *new_passwd1, char *new_passwd2) { 00084 return 0; 00085 } 00086 00087 /* 00088 * Reset the user's password, and return the new password. 00089 */ 00090 char *reset_password(user *u) { 00091 return 0; 00092 } 00093 00094 /* 00095 * Locks the user. 00096 */ 00097 int lock_user(user *u) { 00098 if (u) { 00099 if (u->locked) { 00100 return 0; 00101 } 00102 u->locked = 1; 00103 return 1; 00104 } 00105 return -1; 00106 } 00107 00108 int unlock_user(user *u) { 00109 if (u) { 00110 if (u->locked == 0) { 00111 return 0; 00112 } 00113 u->locked = 0; 00114 return 1; 00115 } 00116 return -1; 00117 }