Diff for /libaitcfg/src/pq.c between versions 1.2 and 1.5

version 1.2, 2012/09/19 15:22:32 version 1.5, 2014/01/29 23:48:34
Line 12  terms: Line 12  terms:
 All of the documentation and software included in the ELWIX and AITNET  All of the documentation and software included in the ELWIX and AITNET
 Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org>  Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org>
   
Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012Copyright 2004 - 2014
         by Michael Pounov <misho@elwix.org>.  All rights reserved.          by Michael Pounov <misho@elwix.org>.  All rights reserved.
   
 Redistribution and use in source and binary forms, with or without  Redistribution and use in source and binary forms, with or without
Line 57  _selectPasswd(pwd_root_t * __restrict pwd, u_int uid,  Line 57  _selectPasswd(pwd_root_t * __restrict pwd, u_int uid, 
                 memset(&fu, 0, sizeof fu);                  memset(&fu, 0, sizeof fu);
   
         if (csName) {          if (csName) {
                io_setlikeVar(&fu.usr_name, string, strlen(csName) + 1, csName);                ait_setlikeVar(&fu.usr_name, string, strlen(csName) + 1, csName);
                 return RB_FIND(tagPWD, pwd, &fu);                  return RB_FIND(tagPWD, pwd, &fu);
         }          }
   
Line 103  cfg_findPasswdBy(pwd_root_t * __restrict pwd, int crit Line 103  cfg_findPasswdBy(pwd_root_t * __restrict pwd, int crit
         SLIST_FOREACH(u, pwd, usr_next)          SLIST_FOREACH(u, pwd, usr_next)
                 switch (criteria) {                  switch (criteria) {
                         case PWD_CRIT_NAME:                          case PWD_CRIT_NAME:
                                if (!io_cmpVar(&u->usr_name, &v)) {                                if (!ait_cmpVar(&u->usr_name, &v)) {
                                         AIT_FREE_VAL(&v);                                          AIT_FREE_VAL(&v);
                                         return u;                                          return u;
                                 }                                  }
Line 187  cfg_unsetPasswd(pwd_root_t * __restrict pwd, int crite Line 187  cfg_unsetPasswd(pwd_root_t * __restrict pwd, int crite
         AIT_FREE_VAL(&u->usr_realm);          AIT_FREE_VAL(&u->usr_realm);
         AIT_FREE_VAL(&u->usr_home);          AIT_FREE_VAL(&u->usr_home);
         AIT_FREE_VAL(&u->usr_shell);          AIT_FREE_VAL(&u->usr_shell);
        io_free(u);        e_free(u);
         return 1;          return 1;
 }  }
   
Line 195  cfg_unsetPasswd(pwd_root_t * __restrict pwd, int crite Line 195  cfg_unsetPasswd(pwd_root_t * __restrict pwd, int crite
  * cfg_setPasswd() - Set item in password or adding new item if not exists   * cfg_setPasswd() - Set item in password or adding new item if not exists
  *   *
  * @cfg = Password root   * @cfg = Password root
 * @fields = Meaning continuous field * @fields = Following parameters are continuous to certain field
  * @csName = Username   * @csName = Username
  * @arg1 = Password   * @arg1 = Password
  * @arg2 = UID   * @arg2 = UID
  * @arg3 = GID   * @arg3 = GID
  * @arg4 = Login class   * @arg4 = Login class
 * @arg5 = Chage date * @arg5 = Change date
  * @arg6 = Expire date   * @arg6 = Expire date
  * @arg7 = Realm   * @arg7 = Realm
  * @arg8 = Home dir   * @arg8 = Home dir
Line 209  cfg_unsetPasswd(pwd_root_t * __restrict pwd, int crite Line 209  cfg_unsetPasswd(pwd_root_t * __restrict pwd, int crite
  * return: 0 nothing changed, -1 error, 1 found and updated item or 2 added new item   * return: 0 nothing changed, -1 error, 1 found and updated item or 2 added new item
  */   */
 int  int
cfg_setPasswd(pwd_root_t * __restrict pwd, u_char fields, const char *csName, ...) cfg_setPasswd(pwd_root_t * __restrict pwd, passwd_attr_t fields, const char *csName, ...) 
 {  {
         struct tagUser *u;          struct tagUser *u;
         register int i;          register int i;
Line 221  cfg_setPasswd(pwd_root_t * __restrict pwd, u_char fiel Line 221  cfg_setPasswd(pwd_root_t * __restrict pwd, u_char fiel
         u = _selectPasswd(pwd, 0, csName);          u = _selectPasswd(pwd, 0, csName);
         if (!u) {          if (!u) {
                 /* adding new element */                  /* adding new element */
                u = io_malloc(sizeof(struct tagUser));                u = e_malloc(sizeof(struct tagUser));
                 if (!u) {                  if (!u) {
                        cfg_SetErr(io_GetErrno(), "%s", io_GetError());                        cfg_SetErr(elwix_GetErrno(), "%s", elwix_GetError());
                         return -1;                          return -1;
                 } else {                  } else {
                         memset(u, 0, sizeof(struct tagUser));                          memset(u, 0, sizeof(struct tagUser));
                        if (fields && fields < PWD_MAX_FIELDS)                        if (fields >= Username && fields <= Shell)
                                u->usr_fields = fields;                                u->usr_fields = (int) fields;
                         else                          else
                                 u->usr_fields = PWD_MAX_FIELDS - 1;                                  u->usr_fields = PWD_MAX_FIELDS - 1;
   
Line 274  cfg_setPasswd(pwd_root_t * __restrict pwd, u_char fiel Line 274  cfg_setPasswd(pwd_root_t * __restrict pwd, u_char fiel
                 va_end(lst);                  va_end(lst);
   
                 AIT_KEY(&u->usr_name) = crcFletcher16(AIT_GET_LIKE(&u->usr_name, u_short*),                   AIT_KEY(&u->usr_name) = crcFletcher16(AIT_GET_LIKE(&u->usr_name, u_short*), 
                                io_align(AIT_LEN(&u->usr_name) - 1, 2) / 2);                                E_ALIGN(AIT_LEN(&u->usr_name) - 1, 2) / 2);
   
                 PWD_LOCK(pwd);                  PWD_LOCK(pwd);
                 RB_INSERT(tagPWD, pwd, u);                  RB_INSERT(tagPWD, pwd, u);
Line 339  cfg_setPasswd(pwd_root_t * __restrict pwd, u_char fiel Line 339  cfg_setPasswd(pwd_root_t * __restrict pwd, u_char fiel
  * @arg1 = Username | UID   * @arg1 = Username | UID
  * return: NULL item not found, !=NULL structure found   * return: NULL item not found, !=NULL structure found
  */   */
inline const struct tagUser *const struct tagUser *
 cfg_getPasswd(pwd_root_t * __restrict pwd, int criteria, ...)  cfg_getPasswd(pwd_root_t * __restrict pwd, int criteria, ...)
 {  {
         struct tagUser *u;          struct tagUser *u;

Removed from v.1.2  
changed lines
  Added in v.1.5


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>