/* 
 * test-auth
 * 
 */

#include <stdio.h>
#include <stdlib.h>
#include "auth.h"


int main(int argc, char **argv) {
	
	if (argc != 2) {
		printf("Parametros invalidos. Exemplo: test-auth Users.dat\n");
		return -1;
	}
	
	if (auth_new(argv[1]) != 0) {
		printf("Erro: Ficheiro invalido.\n");
		return -1;
	}
	
	printf("Numero total de utilizadores: %d\n", auth_total_users());
	
	auth_dump();
	
	printf("Login U1 & P1: %d\n", auth_login("U1", "P1"));
	printf("Login U2 & P2: %d\n", auth_login("U2", "P2"));
	printf("Login U2 & P3: %d\n", auth_login("U3", "P3"));
	printf("Login U4 & P1: %d\n", auth_login("U4", "P1"));
	printf("Login U5 & P2: %d\n", auth_login("U5", "P2"));
	printf("Login U6 & P3: %d\n", auth_login("U6", "P3"));
	printf("Login U2 & P3: %d\n", auth_login("U2", "P3"));

	printf("Lookup U1: %d\n", auth_lookup("U1"));
	printf("Lookup U2: %d\n", auth_lookup("U2"));
	printf("Lookup U3: %d\n", auth_lookup("U3"));
	printf("Lookup U4: %d\n", auth_lookup("U4"));
	printf("Lookup U5: %d\n", auth_lookup("U5"));
	printf("Lookup U6: %d\n", auth_lookup("U6"));

	printf("Lookup U6: %d\n", auth_lookup("U6"));
	
	return 0;
}
