⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 um_main.h

📁 hammerOS(了解的人就知道了)的一个板块Manage的源代码
💻 H
字号:
/***********************************************************
                          um_main.h  
                             -------------------
description     : user management included by other modules  
begin          : Wed April 25 2001
copyright       : (C) 2001 Beijing Harbour Networks Ltd.
email          : chenb@harbournetworks.com

*************************************************************/

#ifndef _UM_MAIN_H_
#define _UM_MAIN_H_ 1 


#ifdef _cplusplus
extern"C"{
#endif

#include "../mn_set.h"

#ifdef _MN_HAVE_USERMANAGE_

enum um_user_role_type { 
  NORMAL_USER, 
  ADMIN_USER 
};

/****************************************
check user name see if it's legal 
*****************************************/
int 
um_check_name_legal(char *name, char **errmsg,unsigned short lan_type);



/****************************************
check password see if it's legal 
return 1 if ok
return 0 if illegal and details in  errmsg;
errmsg is a pointer to a const string needn't be free.

*****************************************/



int
um_check_pass_legal(unsigned char *pass, char **errmsg, unsigned short pass_type,unsigned short lan_type);



/****************************************
check username and password to validate login 
return 1 if normal user 
return 2 if admin user

return 0 if failed and details in  errmsg;
errmsg is a pointer to a const string can't be free.

*****************************************/
int um_validate_login(char *user_name,unsigned char *passwd, char **errmsg,unsigned short lan_type);




/****************************************
check username and password to validate enable 
return 1 if success
return 0 if password incorrect

return -1 if user do not have admin permit ;

errmsg is a pointer to a const string can't be free.
*****************************************/
int um_validate_enable(char *user_name, unsigned char *passwd, char **errmsg,unsigned short lan_type);


/******************************************************
  validate a user name to see if the user is exist in user database
*****************************************************/
int um_validate_user_exists(char *username);



/****************************************
get first user's username
username is a pointer to real username , can't be free
return 1 if success
return 0 if failed and details in  errmsg;
errmsg is a pointer to a const string can't be free.
*****************************************/
int um_get_first_user_name(char **user_name,char **errmsg,unsigned short lan_type);



/****************************************
get next user's username
prev_username is previouse user name,
username is a pointer to real username , can't be free
if return username is NULL then it's the last user.
return 1 if success
return 0 if failed and details in  errmsg;
errmsg is a pointer to a const string can't be free.
*****************************************/
int um_get_next_user_name(char *prev_user_name, char **user_name, char **errmsg,unsigned short lan_type);



/**************************************************
Add a user to user db
return 1 if success
return 0 if failed , and details in errmsg;
errmsg is a pointer to a const string can't be free.

*****************************************************/
int um_add_user(char *user_name,unsigned char *login_pass,char **errmsg,unsigned short lan_type);



/**************************************************
Delete a user from user db
return 1 if success
return 0 if failed , and details in errmsg;
errmsg is a pointer to a const string can't be free.

*****************************************************/
int um_del_user(char *user_name,char **errmsg,unsigned short lan_type);



/**************************************************
get a user's user role  
return 1 if success
return 0 if failed , and details in errmsg;
errmsg is a pointer to a const string can't be free.

*****************************************************/
int um_get_user_role(char *user_name, enum um_user_role_type *user_role, char **errmsg,unsigned short lan_type);



/**************************************************
set a user's user role 
if set to admin user , enable_pass must be legal
if set to normal user , enable_pass arg can be NULL.
return 1 if success
return 0 if failed , and details in errmsg;
errmsg is a pointer to a const string can't be free.

*****************************************************/
int um_set_user_role(char *user_name,enum um_user_role_type user_role, unsigned char *enable_pass, char **errmsg,unsigned short lan_type);




/**************************************************
get a user's login password
return 1 if success
return 0 if failed , and details in errmsg;
return login_pass is a pointer to real password , can't be free.
errmsg is a pointer to a const string can't be free.

*****************************************************/
int um_get_login_pass(char *user_name, unsigned char **login_pass, char **errmsg,unsigned short lan_type);



/**************************************************
set a user's login password
return 1 if success
return 0 if failed , and details in errmsg;
errmsg is a pointer to a const string can't be free.

*****************************************************/
int um_set_login_pass(char *user_name, unsigned char *pass, char **errmsg,unsigned short lan_type);




/**************************************************
get a user's enable password
return 1 if success
return 0 if failed , and details in errmsg;
return login_pass is a pointer to real password , can't be free.
errmsg is a pointer to a const string can't be free.

*****************************************************/
int um_get_enable_pass(char *user_name, unsigned char **enable_pass,char **errmsg,unsigned short lan_type);



/**************************************************
set a user's enable password
return 1 if success
return 0 if failed , and details in errmsg;
errmsg is a pointer to a const string can't be free.
*****************************************************/
int um_set_enable_pass(char *user_name, unsigned char *pass, char **errmsg,unsigned short lan_type);







/*********************************
Init user database struct return 1 if success 0 if failed 
***********************************/
int um_init_user_db(char **errmsg);




/*****************************************
check if there is at least one user in user db
if true , return 1
if false , try create default user , if success , return 1 , if failt return 0
*************************************/
int um_check_user_db(char **errmsg);




/******************************
init user manage 
************************/
int  um_main_init(void);


#endif

#ifdef _cplusplus
}
#endif

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -