misc: Clean up some of the problems compiling for Windows with mingw
Major remaining tasks: * Forcing Non-blocking I/O * dynamic library loading (eg dlopen or ltdl) * Final linkingmaster
parent
81ec3d7c6a
commit
a42576e326
|
@ -457,9 +457,9 @@ enum {
|
|||
S_FINISHED,
|
||||
};
|
||||
|
||||
static int fancy_memcmp(const uint8_t *buf_a, const int16_t *buf_b, uint len)
|
||||
static int fancy_memcmp(const uint8_t *buf_a, const int16_t *buf_b, uint16_t len)
|
||||
{
|
||||
uint i;
|
||||
uint16_t i;
|
||||
|
||||
for (i = 0 ; i < len ; i++) {
|
||||
if (buf_b[i] == -1)
|
||||
|
|
|
@ -304,12 +304,14 @@ int send_data(struct libusb_device_handle *dev, uint8_t endp,
|
|||
}
|
||||
|
||||
/* More stuff */
|
||||
#ifndef _WIN32
|
||||
static void sigterm_handler(int signum) {
|
||||
UNUSED(signum);
|
||||
|
||||
terminate = 1;
|
||||
INFO("Job Cancelled");
|
||||
}
|
||||
#endif
|
||||
|
||||
static char *sanitize_string(char *str) {
|
||||
int len = strlen(str);
|
||||
|
@ -1062,7 +1064,9 @@ static int handle_input(struct dyesub_backend *backend, void *backend_ctx,
|
|||
char *fname, char *uri, char *type)
|
||||
{
|
||||
int ret = CUPS_BACKEND_OK;
|
||||
#ifndef _WIN32
|
||||
int i;
|
||||
#endif
|
||||
const void *job;
|
||||
int data_fd = fileno(stdin);
|
||||
int read_page = 0, print_page = 0;
|
||||
|
@ -1091,6 +1095,7 @@ static int handle_input(struct dyesub_backend *backend, void *backend_ctx,
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
/* Ensure we're using BLOCKING I/O */
|
||||
i = fcntl(data_fd, F_GETFL, 0);
|
||||
if (i < 0) {
|
||||
|
@ -1109,6 +1114,7 @@ static int handle_input(struct dyesub_backend *backend, void *backend_ctx,
|
|||
/* Ignore SIGPIPE */
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
signal(SIGTERM, sigterm_handler);
|
||||
#endif
|
||||
|
||||
/* Time for the main processing loop */
|
||||
INFO("Printing started (%d copies)\n", ncopies);
|
||||
|
|
|
@ -36,11 +36,20 @@
|
|||
#include <fcntl.h>
|
||||
|
||||
#include <libusb.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <winsock.h>
|
||||
#else
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
#ifndef __BACKEND_COMMON_H
|
||||
#define __BACKEND_COMMON_H
|
||||
|
||||
#ifdef ERROR
|
||||
#undef ERROR
|
||||
#endif
|
||||
|
||||
#define STR_LEN_MAX 64
|
||||
#define STATE( ... ) do { if (!quiet) fprintf(stderr, "STATE: " __VA_ARGS__ ); } while(0)
|
||||
#define ATTR( ... ) do { if (!quiet) fprintf(stderr, "ATTR: " __VA_ARGS__ ); } while(0)
|
||||
|
@ -58,25 +67,25 @@
|
|||
#define le16_to_cpu(__x) __x
|
||||
#define be16_to_cpu(__x) ntohs(__x)
|
||||
#define be32_to_cpu(__x) ntohl(__x)
|
||||
#define be64_to_cpu(__x) ((__uint64_t)( \
|
||||
(((__uint64_t)(__x) & (__uint64_t)0x00000000000000ffULL) << 56) | \
|
||||
(((__uint64_t)(__x) & (__uint64_t)0x000000000000ff00ULL) << 40) | \
|
||||
(((__uint64_t)(__x) & (__uint64_t)0x0000000000ff0000ULL) << 24) | \
|
||||
(((__uint64_t)(__x) & (__uint64_t)0x00000000ff000000ULL) << 8) | \
|
||||
(((__uint64_t)(__x) & (__uint64_t)0x000000ff00000000ULL) >> 8) | \
|
||||
(((__uint64_t)(__x) & (__uint64_t)0x0000ff0000000000ULL) >> 24) | \
|
||||
(((__uint64_t)(__x) & (__uint64_t)0x00ff000000000000ULL) >> 40) | \
|
||||
(((__uint64_t)(__x) & (__uint64_t)0xff00000000000000ULL) >> 56)))
|
||||
#define be64_to_cpu(__x) ((uint64_t)( \
|
||||
(((uint64_t)(__x) & (uint64_t)0x00000000000000ffULL) << 56) | \
|
||||
(((uint64_t)(__x) & (uint64_t)0x000000000000ff00ULL) << 40) | \
|
||||
(((uint64_t)(__x) & (uint64_t)0x0000000000ff0000ULL) << 24) | \
|
||||
(((uint64_t)(__x) & (uint64_t)0x00000000ff000000ULL) << 8) | \
|
||||
(((uint64_t)(__x) & (uint64_t)0x000000ff00000000ULL) >> 8) | \
|
||||
(((uint64_t)(__x) & (uint64_t)0x0000ff0000000000ULL) >> 24) | \
|
||||
(((uint64_t)(__x) & (uint64_t)0x00ff000000000000ULL) >> 40) | \
|
||||
(((uint64_t)(__x) & (uint64_t)0xff00000000000000ULL) >> 56)))
|
||||
#else
|
||||
#define le64_to_cpu(__x) ((__uint64_t)( \
|
||||
(((__uint64_t)(__x) & (__uint64_t)0x00000000000000ffULL) << 56) | \
|
||||
(((__uint64_t)(__x) & (__uint64_t)0x000000000000ff00ULL) << 40) | \
|
||||
(((__uint64_t)(__x) & (__uint64_t)0x0000000000ff0000ULL) << 24) | \
|
||||
(((__uint64_t)(__x) & (__uint64_t)0x00000000ff000000ULL) << 8) | \
|
||||
(((__uint64_t)(__x) & (__uint64_t)0x000000ff00000000ULL) >> 8) | \
|
||||
(((__uint64_t)(__x) & (__uint64_t)0x0000ff0000000000ULL) >> 24) | \
|
||||
(((__uint64_t)(__x) & (__uint64_t)0x00ff000000000000ULL) >> 40) | \
|
||||
(((__uint64_t)(__x) & (__uint64_t)0xff00000000000000ULL) >> 56)))
|
||||
#define le64_to_cpu(__x) ((uint64_t)( \
|
||||
(((uint64_t)(__x) & (uint64_t)0x00000000000000ffULL) << 56) | \
|
||||
(((uint64_t)(__x) & (uint64_t)0x000000000000ff00ULL) << 40) | \
|
||||
(((uint64_t)(__x) & (uint64_t)0x0000000000ff0000ULL) << 24) | \
|
||||
(((uint64_t)(__x) & (uint64_t)0x00000000ff000000ULL) << 8) | \
|
||||
(((uint64_t)(__x) & (uint64_t)0x000000ff00000000ULL) >> 8) | \
|
||||
(((uint64_t)(__x) & (uint64_t)0x0000ff0000000000ULL) >> 24) | \
|
||||
(((uint64_t)(__x) & (uint64_t)0x00ff000000000000ULL) >> 40) | \
|
||||
(((uint64_t)(__x) & (uint64_t)0xff00000000000000ULL) >> 56)))
|
||||
#define le32_to_cpu(x) \
|
||||
({ \
|
||||
uint32_t __x = (x); \
|
||||
|
|
|
@ -192,7 +192,9 @@ struct dnpds40_cmd {
|
|||
#define MULTICUT_S_8x10_75 26
|
||||
#define MULTICUT_S_8x4X3 28 // different than roll type.
|
||||
|
||||
#ifndef min
|
||||
#define min(__x, __y) ((__x) < (__y)) ? __x : __y
|
||||
#endif
|
||||
|
||||
/* Legacy spool file support */
|
||||
static int legacy_cw01_read_parse(struct dnpds40_printjob *job, int data_fd, int read_data);
|
||||
|
|
|
@ -867,7 +867,7 @@ const char *sinfonia_error_str(uint8_t v) {
|
|||
return "Main Communication Timeout";
|
||||
case ERROR_MAINT_NEEDED:
|
||||
return "Maintenance Needed";
|
||||
case ERROR_BAD_COMMAND:
|
||||
case ERROR_INAPP_COMMAND:
|
||||
return "Inappropriate Command";
|
||||
case ERROR_PRINTER:
|
||||
return "Printer Error";
|
||||
|
|
|
@ -143,7 +143,7 @@ struct sinfonia_error_item {
|
|||
#define ERROR_MAIN_APP_INACTIVE 0x02
|
||||
#define ERROR_COMMS_TIMEOUT 0x03
|
||||
#define ERROR_MAINT_NEEDED 0x04
|
||||
#define ERROR_BAD_COMMAND 0x05
|
||||
#define ERROR_INAPP_COMMAND 0x05
|
||||
#define ERROR_PRINTER 0x11
|
||||
#define ERROR_BUFFER_FULL 0x21
|
||||
|
||||
|
|
Loading…
Reference in New Issue