--- libaitcfg/example/Attic/atest_pwd.c 2012/09/18 08:06:01 1.1 +++ libaitcfg/example/Attic/atest_pwd.c 2012/09/19 15:22:31 1.2 @@ -0,0 +1,51 @@ +#include +#include +#include +#include + + +static int +compfunc(void *r, void *a) +{ + if (r && strstr(r, a)) + return 1; + + return 0; +} + +int main(int argc, char **argv) +{ + struct tagAcctDB *h; + const char piuk[100] = "Oho BOHO .................................... xxx !\n"; + char buf[101]; + long long ret = 0; + + h = pwd_openAcct(argv[1], argv[2] ? atoi(argv[2]) : 0, argv[3] ? atoi(argv[3]) : 0, 100, 1); + if (!h) { + printf("%s: #%d - %s\n", __func__, pwd_GetErrno(), pwd_GetError()); + return 1; + } + + if ((ret = pwd_findAcct(h, 4, 9, compfunc, "BOHO .")) == -1) { + printf("%s: #%d - %s\n", __func__, pwd_GetErrno(), pwd_GetError()); + return 2; + } else + if (ret) + ret--; + printf("at position %lld", ret); + + if (pwd_readAcct(h, (unsigned int) ret, (void*) buf, 100) == -1) { + printf("%s: #%d - %s\n", __func__, pwd_GetErrno(), pwd_GetError()); + return 2; + } else + printf("READ:: %s\n", buf); + /* + if (pwd_writeAcct(h, 19, (void*) piuk) == -1) { + printf("%s: #%d - %s\n", __func__, pwd_GetErrno(), pwd_GetError()); + return 2; + } + */ + + pwd_closeAcct(&h); + return 0; +}