/* 
 * test-storage
 * 
 */

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


int main(int argc, char **argv) {
	
	if (argc != 3) {
		printf("Parametros invalidos. Exemplo: test-storage Users.dat Titles.dat\n");
		return -1;
	}
	
	if (auth_new(argv[1]) != 0) {
		printf("Erro: Ficheiro invalido.\n");
		return -1;
	}

	if (storage_new(argv[2]) != 0) {
		printf("Erro: Ficheiro invalido.\n");
		return -1;
	}
	
	storage_dump();
	storage_give("M1");
	storage_dump();
	storage_give("P1");
	storage_dump();
	storage_give("M3");
	storage_dump();
	storage_give("F7");
	storage_dump();
	storage_give("F8");
	storage_dump();

	storage_search("U1", "P1", "M3");
	storage_search("U1", "P1", "M1");
	storage_search("U2", "P2", "M3");
	storage_search("U1", "P1", "M1");

	storage_dump();
	storage_give("M3");
	storage_dump();
	storage_search("U1", "P1", "M3");
	storage_dump();
	storage_cancel("U1", "M3");
	storage_dump();
	storage_search("U1", "P1", "M3");
	storage_dump();
	storage_take("U1", "M3");
	storage_dump();
	storage_release("U1", "M3", 0);
	storage_dump();
	
	return 0;
}
