--- libaitcfg/example/test_pwd.c 2012/09/19 11:53:52 1.1.2.3 +++ libaitcfg/example/test_pwd.c 2012/09/19 12:04:44 1.1.2.4 @@ -8,6 +8,7 @@ int main() { pwd_root_t ddd, db; + struct tagUser *u; char str[256]; int ret = 0; @@ -16,25 +17,29 @@ int main() return 1; } -#if 0 /* unit test find */ // count elements - printf("attr=%d Count of array %d w/ NULL \n", ALL, pwd_FindAttribute(db, ALL, NULL)); - printf("attr=%d Count of array %d w/o NULL \n", ALL, pwd_FindAttribute(db, ALL, "")); - printf("attr=%d Count of array %d\n", ALL, pwd_FindAttribute(db, ALL, "user_l")); + u = (const struct tagUser *) cfg_findPasswdBy(&db, PWD_CRIT_UID, 0); + printf("cfg_findPasswdBy %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 = (const struct tagUser *) cfg_findPasswdBy(&db, PWD_CRIT_UID, 444); + printf("cfg_findPasswdBy %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)); + /* // find by attributes - printf("attr=%d Count of array %d w/ NULL \n", Username, pwd_FindAttribute(db, Username, NULL)); - printf("attr=%d Count of array %d w/o NULL \n", Username, pwd_FindAttribute(db, Username, "")); - printf("attr=%d Count of array %d 'user_l' \n", Username, pwd_FindAttribute(db, Username, "user_l")); - 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)); + printf("Count of array %d w/ NULL \n", Username, pwd_FindAttribute(db, Username, NULL)); + printf("Count of array %d w/o NULL \n", Username, pwd_FindAttribute(db, Username, "")); + printf("Count of array %d 'user_l' \n", Username, pwd_FindAttribute(db, Username, "user_l")); + printf("Count of array %d 'a' \n", Username, pwd_FindAttribute(db, Username, "a")); + printf("Count of array %d 'class4e' \n", Class, pwd_FindAttribute(db, Class, "class4e")); + printf("Count of array %d 'clas' \n", Class, pwd_FindAttribute(db, Class, "clas")); + printf("Count of array %d 'ii' \n", Home, pwd_FindAttribute(db, Home, "ii")); + printf("Count of array %d 'i' \n", Home, pwd_FindAttribute(db, Home, "i")); + printf("Count of array %d '' \n", Home, pwd_FindAttribute(db, Home, "")); + printf("Count of array %d NULL \n", Home, pwd_FindAttribute(db, Home, NULL)); /* unit end find */ +#if 0 /* unit test set */ 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)); @@ -96,6 +101,6 @@ int main() } #endif - UnloadPasswd(&db); + cfgUnloadPasswd(&db); return 0; }