--- libaitcfg/inc/aitpwd.h 2012/09/19 15:22:32 1.2 +++ libaitcfg/inc/aitpwd.h 2022/09/26 19:46:59 1.7 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: aitpwd.h,v 1.2 2012/09/19 15:22:32 misho Exp $ +* $Id: aitpwd.h,v 1.7 2022/09/26 19:46:59 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -12,7 +12,7 @@ terms: All of the documentation and software included in the ELWIX and AITNET Releases is copyrighted by ELWIX - Sofia/Bulgaria -Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 +Copyright 2004 - 2022 by Michael Pounov . All rights reserved. Redistribution and use in source and binary forms, with or without @@ -49,7 +49,7 @@ SUCH DAMAGE. #include #include -#include +#include #define PWD_CRIT_NAME 0 @@ -69,7 +69,7 @@ struct tagAcctDB { uint64_t db_since; int db_h; /* optional */ -} __packed; +} __attribute__((packed)); /* Search callback function, compare to match argument to record match ... * (return: -1 error, 0 not match or 1 match) @@ -122,11 +122,17 @@ typedef enum { ALL = -1, /* * cfgInitPasswd() - Init password root * - * @pwd = Password root - * return: -1 error or 0 ok + * return: NULL error or !=NULL allocated password root */ -int cfgInitPasswd(pwd_root_t * __restrict pwd); +pwd_root_t *cfgInitPasswd(); /* + * cfgEndPasswd() - Free resources & password root + * + * @ppwd = Password root + * return: none + */ +void cfgEndPasswd(pwd_root_t **ppwd); +/* * cfgLoadPasswd() - Load passwords from file * * @pwdName = Passwords filename @@ -215,7 +221,7 @@ int cfg_unsetPasswd(pwd_root_t * __restrict pwd, int c * cfg_setPasswd() - Set item in password or adding new item if not exists * * @cfg = Password root - * @fields = Meaning continuous field + * @fields = Following parameters are continuous to certain field * @csName = Username * @arg1 = Password * @arg2 = UID @@ -228,7 +234,7 @@ int cfg_unsetPasswd(pwd_root_t * __restrict pwd, int c * @arg9 = Shell * return: 0 nothing changed, -1 error, 1 found and updated item or 2 added new item */ -int cfg_setPasswd(pwd_root_t * __restrict pwd, u_char fields, const char *csName, ...); +int cfg_setPasswd(pwd_root_t * __restrict pwd, passwd_attr_t fields, const char *csName, ...); /* * cfg_getPasswd() - Get item from passwords and return structure from it * @@ -237,7 +243,7 @@ int cfg_setPasswd(pwd_root_t * __restrict pwd, u_char * @arg1 = Username | UID * return: NULL item not found, !=NULL structure found */ -inline const struct tagUser *cfg_getPasswd(pwd_root_t * __restrict pwd, int criteria, ...); +const struct tagUser *cfg_getPasswd(pwd_root_t * __restrict pwd, int criteria, ...); #endif