#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <locale.h>
#include <libps/pslib-mp.h>

void * my_malloc(PSDoc *p, size_t size, const char *caller) {
	void *a;
	a = (void *) malloc(size);
//	printf("Allocating %d bytes at 0x%X (%s)\n", size, a, caller);
	return(a);
}   

void * my_realloc(PSDoc *p, void *mem, size_t size, const char *caller) {
	return((void *) realloc(mem, size));
} 
  
void my_free(PSDoc *p, void *mem) {
//	printf("Freeing memory at 0x%X\n", mem);
	free(mem);
}


int main() {
	PSDoc *psdoc;
	int antiqua;
	float boxwidth, boxheight, baseline, colsep, leftmargin;
	float fontsize;
	int boxed;

	boxwidth = 100;
	boxheight = 630;
	baseline = 100;
	colsep = 20;
	leftmargin = 100;
	boxed = 0;
	fontsize = 10.0;

	PS_boot();
	psdoc = PS_new2(NULL, my_malloc, my_realloc, my_free, NULL);
	PS_open_file(psdoc, "polish.ps");
	PS_set_info(psdoc, "Creator", __FILE__);
	PS_set_info(psdoc, "Author", "Uwe Steinmann");
	PS_set_info(psdoc, "Title", "Polish letters");
	PS_set_info(psdoc, "Keywords", "polish, latin2, iso-8859-1");
	PS_set_info(psdoc, "BoundingBox", "0 0 596 842");

	PS_set_parameter(psdoc, "inputencoding", "ISO-8859-2");
	PS_set_parameter(psdoc, "warning", "true");

	antiqua = PS_findfont(psdoc, "plr10", "", 1);

	PS_begin_page(psdoc, 596, 842);

	PS_setfont(psdoc, antiqua, 10.0);
	PS_set_value(psdoc, "leading", 15.0);
	PS_show_xy(psdoc, "±æê³ñó¶¼¿ ¡ÆÊ£ÑÓ¦¬¯", leftmargin, 100);
	PS_show_xy(psdoc, "><=!abc~_-", leftmargin, 200);

	PS_end_page(psdoc);
	PS_deletefont(psdoc, antiqua);
	PS_close(psdoc);
	PS_delete(psdoc);
	PS_shutdown();
	exit(0);
}
