File:  [ELWIX - Embedded LightWeight unIX -] / libaitcfg / example / Attic / atest_pwd.c
Revision 1.1.2.1: download - view: text, annotated - select for diffs - revision graph
Tue Sep 18 08:06:01 2012 UTC (11 years, 8 months ago) by misho
Branches: cfg5_5
start import UT from libaitpwd

#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>