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 (11 years, 8 months 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

    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>