#include <X11/Xlib.h>
#include <X11/xpm.h>

#include <err.h>
#include <string.h>

int
main(int argc, char *argv[0])
{
	Display *d;
	char *fname = argc > 1 ? argv[1] : "poc.xpm";
	char **data;
	XpmImage img;
	XpmInfo info;

	if ((d = XOpenDisplay(NULL)) == NULL)
		err(1, "failed to open display");

	memset(&info, 0, sizeof(info));
	info.valuemask |= XpmReturnExtensions;
	if (XpmReadFileToXpmImage(fname, &img, &info) != XpmSuccess)
		err(1, "failed to parse image");

	if (XpmCreateDataFromXpmImage(&data, &img, &info) != XpmSuccess)
		err(1, "failed to create data");

	return 0;
}