2017-11-05 68 views

답변

0
int fd = open("/dev/lp0", O_RDWR); 
if (fd < 0) 
{ 
    printf("can't open lp0\n"); 
} 
else 
{ 
    int status = 0; 
    if (ioctl(fd, LPGETSTATUS, &status) == 0) 
    { 

     fprintf(stderr, "DEBUG: LPGETSTATUS returned a port status of %02X...\n", status); 
      if (status & LP_NOPA) 
     { 
      RET = T; 
      fputs("WARNING: Media tray empty!\n", stderr); 
     } 
     else if (status & LP_ERR) 
     { 
      RET = F; 
      fputs("WARNING: Printer fault!\n", stderr); 

     } 
     else if (status & LP_OFFL) 
     { 
      RET = F; 
      fputs("WARNING: Printer off-line.\n", stderr); 
     } 
    close(fd); 

} }

을 통해 얻는 방법