#include #include #include #include #define BASEPORT 0x378 /* lp1 */ int main(int argc, char * argv[]) { int value = 0; if(!strcmp(argv[1],"on")) value = 4; else if(!strcmp(argv[1],"off")) value = 0; else{ printf("\nUSAGE: magicPlug [on|off]\n\n"); exit(0); } /* Get access to the ports */ if (ioperm(BASEPORT, 3, 1)) {perror("ioperm"); exit(1);} /* Set the data signals (D0-7) of the port to the given value (argv[1]) */ outb(value, BASEPORT); /* We don't need the ports anymore */ if (ioperm(BASEPORT, 3, 0)) {perror("ioperm"); exit(1);} exit(0); }