Linux program to read the status of the PC parallel port

#include <stdio.h>
#include <asm/io.h>
#define LPT 0x378
#define LPT_STAT (LPT+1)


main()
{
	unsigned char status;

	/* Get OS permission to access printer port */
	if (ioperm(LPT,4,1))
	{
		perror("ioperm");
		exit(1);
	}

	/* Read status from printer port, and print to screen */
	status = inb(LPT_STAT);
	printf("status = 0x%02x\n",status);
}
To compile:
    gcc -o status status.c -O2
To run (must be superuser):
    ./status