#include <clip.h>

SAPDRIVER g_sap;

unsigned char g_data[1024 * 1024];
int g_len;

int
main()
{
	int retval;
	FILE* fp;
	short wbuff[SAPBUFLEN];

	fp = fopen("C:\\Reksio_2001.sap", "rb");
	if(!fp) abort();
	g_len = fread(g_data, 1, sizeof g_data, fp);
	fclose(fp);

	retval = sap_init(&g_sap, g_data, g_len, 0);
	if(retval != 0) DIE();
	for(;;) {
		sap_stream_callback(wbuff, (int)&g_sap);
	}

	printf("%s\n", g_sap.header.author);
	printf("%s\n", g_sap.header.name);
	printf("%s\n", g_sap.header.date);
	printf("%c\n", g_sap.header.type);
	getchar();

	return 0;
}

