Annotation of libaitcfg/example/atest_pwd.c, revision 1.2
1.2 ! misho 1: #include <stdio.h>
! 2: #include <stdlib.h>
! 3: #include <string.h>
! 4: #include <aitpwd.h>
! 5:
! 6:
! 7: static int
! 8: compfunc(void *r, void *a)
! 9: {
! 10: if (r && strstr(r, a))
! 11: return 1;
! 12:
! 13: return 0;
! 14: }
! 15:
! 16: int main(int argc, char **argv)
! 17: {
! 18: struct tagAcctDB *h;
! 19: const char piuk[100] = "Oho BOHO .................................... xxx !\n";
! 20: char buf[101];
! 21: long long ret = 0;
! 22:
! 23: h = pwd_openAcct(argv[1], argv[2] ? atoi(argv[2]) : 0, argv[3] ? atoi(argv[3]) : 0, 100, 1);
! 24: if (!h) {
! 25: printf("%s: #%d - %s\n", __func__, pwd_GetErrno(), pwd_GetError());
! 26: return 1;
! 27: }
! 28:
! 29: if ((ret = pwd_findAcct(h, 4, 9, compfunc, "BOHO .")) == -1) {
! 30: printf("%s: #%d - %s\n", __func__, pwd_GetErrno(), pwd_GetError());
! 31: return 2;
! 32: } else
! 33: if (ret)
! 34: ret--;
! 35: printf("at position %lld", ret);
! 36:
! 37: if (pwd_readAcct(h, (unsigned int) ret, (void*) buf, 100) == -1) {
! 38: printf("%s: #%d - %s\n", __func__, pwd_GetErrno(), pwd_GetError());
! 39: return 2;
! 40: } else
! 41: printf("READ:: %s\n", buf);
! 42: /*
! 43: if (pwd_writeAcct(h, 19, (void*) piuk) == -1) {
! 44: printf("%s: #%d - %s\n", __func__, pwd_GetErrno(), pwd_GetError());
! 45: return 2;
! 46: }
! 47: */
! 48:
! 49: pwd_closeAcct(&h);
! 50: return 0;
! 51: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>