summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2020-01-25 07:15:02 -0500
committerSolomon Peachy <pizza@shaftnet.org>2020-01-25 07:15:02 -0500
commit7030bc952d4c65eae07888fdcbf3bcf429da9f3c (patch)
treee7a36d77fb2ea4c3dd60bbbcb3bcab10c45c8f92
parentf59cda744b2db128ed505eb8edcb9cf714215662 (diff)
downloadselphy_print-7030bc952d4c65eae07888fdcbf3bcf429da9f3c.tar.gz
selphy_print-7030bc952d4c65eae07888fdcbf3bcf429da9f3c.tar.bz2
selphy_print-7030bc952d4c65eae07888fdcbf3bcf429da9f3c.zip
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 linking
-rw-r--r--backend_canonselphy.c4
-rw-r--r--backend_common.c6
-rw-r--r--backend_common.h45
-rw-r--r--backend_dnpds40.c2
-rw-r--r--backend_sinfonia.c2
-rw-r--r--backend_sinfonia.h2
6 files changed, 39 insertions, 22 deletions
diff --git a/backend_canonselphy.c b/backend_canonselphy.c
index d967258..c38ea8a 100644
--- a/backend_canonselphy.c
+++ b/backend_canonselphy.c
@@ -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)
diff --git a/backend_common.c b/backend_common.c
index d3f443c..172b362 100644
--- a/backend_common.c
+++ b/backend_common.c
@@ -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);
diff --git a/backend_common.h b/backend_common.h
index fff2a8f..9d3f2bf 100644
--- a/backend_common.h
+++ b/backend_common.h
@@ -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); \
diff --git a/backend_dnpds40.c b/backend_dnpds40.c
index 57de02f..e6d3ad1 100644
--- a/backend_dnpds40.c
+++ b/backend_dnpds40.c
@@ -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);
diff --git a/backend_sinfonia.c b/backend_sinfonia.c
index c32db03..47ab3a6 100644
--- a/backend_sinfonia.c
+++ b/backend_sinfonia.c
@@ -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";
diff --git a/backend_sinfonia.h b/backend_sinfonia.h
index 4213b86..4b225cd 100644
--- a/backend_sinfonia.h
+++ b/backend_sinfonia.h
@@ -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