File: printer-io.h

package info (click to toggle)
libinklevel 0.9.7-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,840 kB
  • sloc: sh: 4,488; ansic: 4,422; python: 44; makefile: 26
file content (51 lines) | stat: -rw-r--r-- 1,214 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/* printer-io.h
 *
 * (c) 2014, 2015, 2018, 2022 Markus Heinz
 *
 * This software is licensed under the terms of the GPL.
 * For details see file COPYING.
 */

#ifndef PRINTER_IO_H
#define PRINTER_IO_H

#include "config.h"

#include <libusb.h>
#include "libusb-utils.h"

#include <stddef.h>
#include <stdint.h>

/* Return codes */

#define PRINTER_SUCCESS 1
#define PRINTER_FAILURE 0

/* Parameter for mode in printer_descriptor */

#define PRINTER_MODE_LIBUSB 1
#define PRINTER_MODE_DEVICE 2

typedef struct printer_descriptor {
  // Defining the connection
  int port; // Type of port
  const char *device_file; // Name of device node
  int portnumber; // instance number of printer port
  int mode; // PRINTER_MODE_LIBUSB or PRINTER_MODE_DEVICE

  // Storing the connection
  int fd; // File descriptor

  usb_printer *printer; // USB printer descriptor
} printer_descriptor;

int open_wrapper(struct printer_descriptor *desc);
int close_wrapper(struct printer_descriptor *desc);

int read_wrapper(struct printer_descriptor *desc, char *buffer, size_t bufsize,
		 int *transfered, int nonblocking);
int write_wrapper(struct printer_descriptor *desc, char *buffer, 
		  size_t bufsize, int *transfered);

#endif