Diff for /libaitcfg/example/test_pwd.c between versions 1.1.2.2 and 1.1.2.6

version 1.1.2.2, 2012/09/19 11:50:02 version 1.1.2.6, 2012/09/19 12:23:12
Line 8 Line 8
 int main()  int main()
 {  {
         pwd_root_t ddd, db;          pwd_root_t ddd, db;
           struct tagUser *u;
         char str[256];          char str[256];
         int ret = 0;          int ret = 0;
   
         if (cfgLoadPasswd("test.pwd", &db)) {          if (cfgLoadPasswd("test.pwd", &db)) {
                printf("Error #%d - %s\n", pwd_GetErrno(), pwd_GetError());                printf("Error #%d - %s\n", cfg_GetErrno(), cfg_GetError());
                 return 1;                  return 1;
         }          }
   
         /* unit test find */          /* unit test find */
        // count elements        u = (struct tagUser *) cfg_findPasswdBy(&db, PWD_CRIT_UID, 0);
        printf("attr=%d Count of array %d w/ NULL \n", ALL, pwd_FindAttribute(db, ALL, NULL));        printf("cfg_findPasswdBy %p UID 0 User=%s %u:%u\n", u, AIT_GET_STR(&u->usr_name), 
        printf("attr=%d Count of array %d w/o NULL \n", ALL, pwd_FindAttribute(db, ALL, ""));                        AIT_GET_U32(&u->usr_uid), AIT_GET_U32(&u->usr_gid));
        printf("attr=%d Count of array %d\n", ALL, pwd_FindAttribute(db, ALL, "user_l"));        u = (struct tagUser *) cfg_findPasswdBy(&db, PWD_CRIT_UID, 444);
        // find by attributes        printf("cfg_findPasswdBy %p UID 444 User=%s %u:%u\n", u, AIT_GET_STR(&u->usr_name), 
        printf("attr=%d Count of array %d w/ NULL \n", Username, pwd_FindAttribute(db, Username, NULL));                        AIT_GET_U32(&u->usr_uid), AIT_GET_U32(&u->usr_gid));
        printf("attr=%d Count of array %d w/o NULL \n", Username, pwd_FindAttribute(db, Username, ""));        u = (struct tagUser *) cfg_findPasswdBy(&db, PWD_CRIT_UID, 99999);
        printf("attr=%d Count of array %d 'user_l' \n", Username, pwd_FindAttribute(db, Username, "user_l"));        printf("cfg_findPasswdBy %p UID 99999\n", u);
        printf("attr=%d Count of array %d 'a' \n", Username, pwd_FindAttribute(db, Username, "a")); 
        printf("attr=%d Count of array %d 'class4e' \n", Class, pwd_FindAttribute(db, Class, "class4e")); 
        printf("attr=%d Count of array %d 'clas' \n", Class, pwd_FindAttribute(db, Class, "clas")); 
        printf("attr=%d Count of array %d 'ii' \n", Home, pwd_FindAttribute(db, Home, "ii")); 
        printf("attr=%d Count of array %d 'i' \n", Home, pwd_FindAttribute(db, Home, "i")); 
        printf("attr=%d Count of array %d '' \n", Home, pwd_FindAttribute(db, Home, "")); 
        printf("attr=%d Count of array %d NULL \n", Home, pwd_FindAttribute(db, Home, NULL)); 
        /* unit end find */ 
   
           u = (struct tagUser *) cfg_findPasswdBy(&db, PWD_CRIT_GID, 0);
           printf("cfg_findPasswdBy %p GID 0 User=%s %u:%u\n", u, AIT_GET_STR(&u->usr_name), 
                           AIT_GET_U32(&u->usr_uid), AIT_GET_U32(&u->usr_gid));
           u = (struct tagUser *) cfg_findPasswdBy(&db, PWD_CRIT_GID, 20);
           printf("cfg_findPasswdBy %p GID 20 User=%s %u:%u\n", u, AIT_GET_STR(&u->usr_name), 
                           AIT_GET_U32(&u->usr_uid), AIT_GET_U32(&u->usr_gid));
           u = (struct tagUser *) cfg_findPasswdBy(&db, PWD_CRIT_GID, 99999);
           printf("cfg_findPasswdBy %p GID 99999\n", u);
   
           u = (struct tagUser *) cfg_findPasswdBy(&db, PWD_CRIT_NAME, "user_l");
           printf("cfg_findPasswdBy %p NAME user_l User=%s %u:%u\n", u, AIT_GET_STR(&u->usr_name), 
                           AIT_GET_U32(&u->usr_uid), AIT_GET_U32(&u->usr_gid));
           u = (struct tagUser *) cfg_findPasswdBy(&db, PWD_CRIT_NAME, "aa");
           printf("cfg_findPasswdBy %p NAME aa User=%s %u:%u\n", u, AIT_GET_STR(&u->usr_name), 
                           AIT_GET_U32(&u->usr_uid), AIT_GET_U32(&u->usr_gid));
           u = (struct tagUser *) cfg_findPasswdBy(&db, PWD_CRIT_NAME, NULL);
           printf("cfg_findPasswdBy %p NAME NULL\n", u);
           u = (struct tagUser *) cfg_findPasswdBy(&db, PWD_CRIT_NAME, "");
           printf("cfg_findPasswdBy %p NAME \"\"\n", u);
   
           /* get */
           u = (struct tagUser *) cfg_getPasswd(&db, PWD_CRIT_UID, 0);
           printf("cfg_getPasswd %p UID 0 User=%s %u:%u\n", u, AIT_GET_STR(&u->usr_name), 
                           AIT_GET_U32(&u->usr_uid), AIT_GET_U32(&u->usr_gid));
           u = (struct tagUser *) cfg_getPasswd(&db, PWD_CRIT_UID, 444);
           printf("cfg_getPasswd %p UID 444 User=%s %u:%u\n", u, AIT_GET_STR(&u->usr_name), 
                           AIT_GET_U32(&u->usr_uid), AIT_GET_U32(&u->usr_gid));
           u = (struct tagUser *) cfg_getPasswd(&db, PWD_CRIT_UID, 99999);
           printf("cfg_getPasswd %p UID 99999\n", u);
   
           u = (struct tagUser *) cfg_getPasswd(&db, PWD_CRIT_NAME, "user_l");
           printf("cfg_getPasswd %p NAME user_l User=%s %u:%u\n", u, AIT_GET_STR(&u->usr_name), 
                           AIT_GET_U32(&u->usr_uid), AIT_GET_U32(&u->usr_gid));
           u = (struct tagUser *) cfg_getPasswd(&db, PWD_CRIT_NAME, "aa");
           printf("cfg_getPasswd %p NAME aa User=%s %u:%u\n", u, AIT_GET_STR(&u->usr_name), 
                           AIT_GET_U32(&u->usr_uid), AIT_GET_U32(&u->usr_gid));
           u = (struct tagUser *) cfg_getPasswd(&db, PWD_CRIT_NAME, NULL);
           printf("cfg_getPasswd %p NAME NULL\n", u);
           u = (struct tagUser *) cfg_getPasswd(&db, PWD_CRIT_NAME, "");
           printf("cfg_getPasswd %p NAME \"\"\n", u);
   
   #if 0
         /* unit test set */          /* unit test set */
         printf("attr=%d set %d NULL\n", ALL, pwd_SetAttribute(&db, ALL, NULL));          printf("attr=%d set %d NULL\n", ALL, pwd_SetAttribute(&db, ALL, NULL));
         printf("attr=%d set %d w/ empty\n", ALL, pwd_SetAttribute(&db, ALL, ddd));          printf("attr=%d set %d w/ empty\n", ALL, pwd_SetAttribute(&db, ALL, ddd));
Line 93  int main() Line 128  int main()
                 printf("Error #%d - %s\n", pwd_GetErrno(), pwd_GetError());                  printf("Error #%d - %s\n", pwd_GetErrno(), pwd_GetError());
                 return 2;                  return 2;
         }          }
   #endif
   
        UnloadPasswd(&db);        cfgUnloadPasswd(&db);
         return 0;          return 0;
 }  }

Removed from v.1.1.2.2  
changed lines
  Added in v.1.1.2.6


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