File:
[ELWIX - Embedded LightWeight unIX -] /
libaitcfg /
example /
Attic /
atest_pwd.c
Revision
1.2:
download - view:
text,
annotated -
select for diffs -
revision graph
Wed Sep 19 15:22:31 2012 UTC (12 years, 1 month ago) by
misho
Branches:
MAIN
CVS tags:
cfg7_7,
cfg7_6,
cfg7_5,
cfg7_4,
cfg7_3,
cfg7_2,
cfg7_1,
cfg7_0,
cfg6_1,
HEAD,
CFG7_6,
CFG7_5,
CFG7_4,
CFG7_3,
CFG7_2,
CFG7_1,
CFG7_0,
CFG6_1,
CFG6_0
version 6.0
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <aitpwd.h>
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;
}
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>