version 1.1.2.1, 2012/09/18 08:06:01
|
version 1.1.2.4, 2012/09/19 12:04:44
|
Line 7
|
Line 7
|
|
|
int main() |
int main() |
{ |
{ |
passwd_t ddd = NULL, db = NULL; | pwd_root_t ddd, db; |
| struct tagUser *u; |
char str[256]; |
char str[256]; |
int ret = 0; |
int ret = 0; |
|
|
if (LoadPasswd("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 |
// count elements |
printf("attr=%d Count of array %d w/ NULL \n", ALL, pwd_FindAttribute(db, ALL, NULL)); | u = (const struct tagUser *) cfg_findPasswdBy(&db, PWD_CRIT_UID, 0); |
printf("attr=%d Count of array %d w/o NULL \n", ALL, pwd_FindAttribute(db, ALL, "")); | 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\n", ALL, pwd_FindAttribute(db, ALL, "user_l")); | 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 |
// find by attributes |
printf("attr=%d Count of array %d w/ NULL \n", Username, pwd_FindAttribute(db, Username, NULL)); | printf("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("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("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("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("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("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("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("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("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 NULL \n", Home, pwd_FindAttribute(db, Home, NULL)); |
/* unit end find */ |
/* unit end find */ |
|
|
|
#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 99 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; |
} |
} |