mirror of
https://git.familie-radermacher.ch/linux/ptouch-print.git
synced 2025-05-13 23:32:59 +00:00
fix several compile warnings
This commit is contained in:
parent
6b2096cea7
commit
92dd6aa402
@ -1,6 +1,6 @@
|
|||||||
AUTOMAKE_OPTIONS = subdir-objects
|
AUTOMAKE_OPTIONS = subdir-objects
|
||||||
AM_CPPFLAGS= -DLOCALEDIR='"$(localedir)"'
|
AM_CPPFLAGS= -DLOCALEDIR='"$(localedir)"'
|
||||||
AM_CFLAGS=-g -std=c11 -Wall -O3 -I$(top_srcdir)/include
|
AM_CFLAGS=-g -std=c11 -Wall -Wextra -Wunused -O3 -I$(top_srcdir)/include -fPIC
|
||||||
SUBDIRS = po
|
SUBDIRS = po
|
||||||
ACLOCAL_AMFLAGS = -I m4
|
ACLOCAL_AMFLAGS = -I m4
|
||||||
EXTRA_DIST = config.rpath m4/ChangeLog Makefile.old
|
EXTRA_DIST = config.rpath m4/ChangeLog Makefile.old
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
GIT_VERSION=$(git --no-pager describe --tags --dirty |sed 's/\([^-]*-g\)/r\1/;s/-/./g;s/v//g')
|
GIT_VERSION=$(git --no-pager describe --always --tags --dirty |sed 's/\([^-]*-g\)/r\1/;s/-/./g;s/v//g')
|
||||||
echo -ne ${GIT_VERSION}
|
echo -ne ${GIT_VERSION}
|
||||||
|
@ -77,7 +77,7 @@ typedef struct _ptouch_dev *ptouch_dev;
|
|||||||
|
|
||||||
int ptouch_open(ptouch_dev *ptdev);
|
int ptouch_open(ptouch_dev *ptdev);
|
||||||
int ptouch_close(ptouch_dev ptdev);
|
int ptouch_close(ptouch_dev ptdev);
|
||||||
int ptouch_send(ptouch_dev ptdev, uint8_t *data, int len);
|
int ptouch_send(ptouch_dev ptdev, uint8_t *data, size_t len);
|
||||||
int ptouch_init(ptouch_dev ptdev);
|
int ptouch_init(ptouch_dev ptdev);
|
||||||
int ptouch_lf(ptouch_dev ptdev);
|
int ptouch_lf(ptouch_dev ptdev);
|
||||||
int ptouch_ff(ptouch_dev ptdev);
|
int ptouch_ff(ptouch_dev ptdev);
|
||||||
@ -86,4 +86,4 @@ int ptouch_getstatus(ptouch_dev ptdev);
|
|||||||
int ptouch_getmaxwidth(ptouch_dev ptdev);
|
int ptouch_getmaxwidth(ptouch_dev ptdev);
|
||||||
int ptouch_enable_packbits(ptouch_dev ptdev);
|
int ptouch_enable_packbits(ptouch_dev ptdev);
|
||||||
int ptouch_rasterstart(ptouch_dev ptdev);
|
int ptouch_rasterstart(ptouch_dev ptdev);
|
||||||
int ptouch_sendraster(ptouch_dev ptdev, uint8_t *data, int len);
|
int ptouch_sendraster(ptouch_dev ptdev, uint8_t *data, size_t len);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
libptouch - functions to help accessing a brother ptouch
|
libptouch - functions to help accessing a brother ptouch
|
||||||
|
|
||||||
Copyright (C) 2013-2017 Dominic Radermacher <blip@mockmoon-cybernetics.ch>
|
Copyright (C) 2013-2019 Dominic Radermacher <blip@mockmoon-cybernetics.ch>
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it
|
This program is free software; you can redistribute it and/or modify it
|
||||||
under the terms of the GNU General Public License version 3 as
|
under the terms of the GNU General Public License version 3 as
|
||||||
@ -132,19 +132,19 @@ int ptouch_close(ptouch_dev ptdev)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ptouch_send(ptouch_dev ptdev, uint8_t *data, int len)
|
int ptouch_send(ptouch_dev ptdev, uint8_t *data, size_t len)
|
||||||
{
|
{
|
||||||
int r,tx;
|
int r, tx;
|
||||||
|
|
||||||
if (ptdev == NULL) {
|
if ((ptdev == NULL) || (len > 128)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if ((r=libusb_bulk_transfer(ptdev->h, 0x02, data, len, &tx, 0)) != 0) {
|
if ((r=libusb_bulk_transfer(ptdev->h, 0x02, data, (int)len, &tx, 0)) != 0) {
|
||||||
fprintf(stderr, _("write error: %s\n"), libusb_error_name(r));
|
fprintf(stderr, _("write error: %s\n"), libusb_error_name(r));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (tx != len) {
|
if (tx != (int)len) {
|
||||||
fprintf(stderr, _("write error: could send only %i of %i bytes\n"), tx, len);
|
fprintf(stderr, _("write error: could send only %i of %ld bytes\n"), tx, len);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -263,25 +263,24 @@ int ptouch_getmaxwidth(ptouch_dev ptdev)
|
|||||||
return ptdev->tape_width_px;
|
return ptdev->tape_width_px;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ptouch_sendraster(ptouch_dev ptdev, uint8_t *data, int len)
|
int ptouch_sendraster(ptouch_dev ptdev, uint8_t *data, size_t len)
|
||||||
{
|
{
|
||||||
uint8_t buf[70];
|
uint8_t buf[64];
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
if (len > ptdev->devinfo->max_px / 8) {
|
if (len > (size_t)(ptdev->devinfo->max_px / 8)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf[0]=0x47;
|
buf[0]=0x47;
|
||||||
if (ptdev->devinfo->flags & FLAG_RASTER_PACKBITS) {
|
if (ptdev->devinfo->flags & FLAG_RASTER_PACKBITS) {
|
||||||
/* Fake compression by encoding a single uncompressed run */
|
/* Fake compression by encoding a single uncompressed run */
|
||||||
buf[1] = len + 1;
|
buf[1] = (uint8_t)(len + 1);
|
||||||
buf[2] = 0;
|
buf[2] = 0;
|
||||||
buf[3] = len - 1;
|
buf[3] = (uint8_t)(len - 1);
|
||||||
memcpy(buf + 4, data, len);
|
memcpy(buf + 4, data, len);
|
||||||
rc = ptouch_send(ptdev, buf, len + 4);
|
rc = ptouch_send(ptdev, buf, len + 4);
|
||||||
} else {
|
} else {
|
||||||
buf[1] = len;
|
buf[1] = (uint8_t)len;
|
||||||
buf[2] = 0;
|
buf[2] = 0;
|
||||||
memcpy(buf + 3, data, len);
|
memcpy(buf + 3, data, len);
|
||||||
rc = ptouch_send(ptdev, buf, len + 3);
|
rc = ptouch_send(ptdev, buf, len + 3);
|
||||||
|
@ -39,7 +39,10 @@ int find_fontsize(int want_px, char *font, char *text);
|
|||||||
int needed_width(char *text, char *font, int fsz);
|
int needed_width(char *text, char *font, int fsz);
|
||||||
int print_img(ptouch_dev ptdev, gdImage *im);
|
int print_img(ptouch_dev ptdev, gdImage *im);
|
||||||
int write_png(gdImage *im, const char *file);
|
int write_png(gdImage *im, const char *file);
|
||||||
|
gdImage *img_append(gdImage *in_1, gdImage *in_2);
|
||||||
|
gdImage *img_cutmark(int tape_width);
|
||||||
gdImage *render_text(char *font, char *line[], int lines, int tape_width);
|
gdImage *render_text(char *font, char *line[], int lines, int tape_width);
|
||||||
|
void unsupported_printer(ptouch_dev ptdev);
|
||||||
void usage(char *progname);
|
void usage(char *progname);
|
||||||
int parse_args(int argc, char **argv);
|
int parse_args(int argc, char **argv);
|
||||||
|
|
||||||
@ -55,11 +58,14 @@ int fontsize=0;
|
|||||||
|
|
||||||
void rasterline_setpixel(uint8_t rasterline[16], int pixel)
|
void rasterline_setpixel(uint8_t rasterline[16], int pixel)
|
||||||
{
|
{
|
||||||
rasterline[15-(pixel/8)] |= 1<<(pixel%8);
|
if (pixel > 128) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
rasterline[15-(pixel/8)] |= (uint8_t)(1<<(pixel%8));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void unsupported_printer(ptouch_dev ptdev)
|
void unsupported_printer(__attribute__((unused)) ptouch_dev ptdev)
|
||||||
{
|
{
|
||||||
printf(_("your printer unfortunately is not supported by this tool\n"));
|
printf(_("your printer unfortunately is not supported by this tool\n"));
|
||||||
printf(_("the rasterdata a transferred in some other (unknown) format\n"));
|
printf(_("the rasterdata a transferred in some other (unknown) format\n"));
|
||||||
|
Loading…
Reference in New Issue
Block a user