标志打印机驱动

  • 标志打印机驱动已关闭评论
  • A+
所属分类:打印机驱动安装
摘要

节这是一个标准的打印机驱动,可以实现打印机和计算机之间的通信。/**PrinterdriverforOS**Author:JohnDoe*Date:June12,2020*/#include#include#include#include#include#include#include#includestaticintprinte

远程装驱动

这是一个标准的打印机驱动,可以实现打印机和计算机之间的通信。

/*
* Printer driver for OS
*
* Author: John Doe
* Date: June 12, 2020
*/

#include
#include
#include
#include
#include
#include
#include
#include

static int printer_fd = -1;

// open a connection to the printer
int printer_open(void)
{
// open the device file for the printer
printer_fd = open("/dev/printer", O_RDWR);
if (printer_fd < 0) { perror("Error opening printer"); return -1; } return 0; } // close the connection to the printer void printer_close(void) { close(printer_fd); printer_fd = -1; } // send a command to the printer int printer_command(int cmd, void *data, int len) { int ret; // check if the printer is open if (printer_fd < 0) return -1; // initialize the command structure struct printer_command pc; pc.cmd = cmd; pc.len = len; pc.data = data; // submit the command to the printer ret = ioctl(printer_fd, PRINTER_COMMAND, &pc); if (ret < 0) { perror("Error sending command to printer"); return -1; } return 0; } // write a set of data to the printer int printer_write(void *data, int len) { int ret; // check if the printer is open if (printer_fd < 0) return -1; // write the data to the printer ret = write(printer_fd, data, len); if (ret < 0) { perror("Error writing to printer"); return -1; } return 0; } // read a set of data from the printer int printer_read(void *data, int len) { int ret; // check if the printer is open if (printer_fd < 0) return -1; // read the data from the printer ret = read(printer_fd, data, len); if (ret < 0) { perror("Error reading from printer"); return -1; } return 0; }

  • 在线微信客服
  • 加18915735256 在线装驱动
  • weinxin
  • 我的微信公众号
  • 我的微信公众号扫一扫
  • weinxin