* Write the byte-swapped buffer...
*/
- return ((unsigned)cups_raster_io(r, r->buffer, len));
+ bytes = cups_raster_io(r, r->buffer, len);
}
else
- return ((unsigned)cups_raster_io(r, p, len));
+ bytes = cups_raster_io(r, p, len);
+
+ if (bytes < len)
+ return (0);
+ else
+ return (len);
}
/*
if (memcmp(p, r->pcurrent, (size_t)bytes))
{
- if (!cups_raster_write(r, r->pixels))
+ if (cups_raster_write(r, r->pixels) <= 0)
return (0);
r->count = 0;
r->remaining --;
if (r->remaining == 0)
- return ((unsigned)cups_raster_write(r, r->pixels));
+ {
+ if (cups_raster_write(r, r->pixels) <= 0)
+ return (0);
+ else
+ return (len);
+ }
else if (r->count == 256)
{
- if (cups_raster_write(r, r->pixels) == 0)
+ if (cups_raster_write(r, r->pixels) <= 0)
return (0);
r->count = 0;
r->remaining --;
if (r->remaining == 0)
- return ((unsigned)cups_raster_write(r, r->pixels));
+ {
+ if (cups_raster_write(r, r->pixels) <= 0)
+ return (0);
+ }
}
}
}
{
count = (*r->iocb)(r->ctx, buf, bytes - (size_t)total);
- DEBUG_printf(("6cups_raster_io: count=%d, total=%d", (int)count,
- (int)total));
+ DEBUG_printf(("6cups_raster_io: count=%d, total=%d", (int)count, (int)total));
if (count == 0)
+ {
+ DEBUG_puts("6cups_raster_io: Returning 0.");
return (0);
+ }
else if (count < 0)
+ {
+ DEBUG_puts("6cups_raster_io: Returning -1 on error.");
return (-1);
+ }
#ifdef DEBUG
r->iocount += (size_t)count;
#endif /* DEBUG */
}
+ DEBUG_printf(("6cups_raster_io: Returning " CUPS_LLFMT ".", CUPS_LLCAST total));
+
return (total);
}
*/
count = r->header.cupsBytesPerLine * 2;
- if (count < 3)
- count = 3;
+ if (count < 65536)
+ count = 65536;
if ((size_t)count > r->bufsize)
{
wptr = malloc(count);
if (!wptr)
+ {
+ DEBUG_printf(("4cups_raster_write: Unable to allocate " CUPS_LLFMT " bytes for raster buffer: %s", CUPS_LLCAST count, strerror(errno)));
return (-1);
+ }
r->buffer = wptr;
r->bufsize = count;
}
}
+ DEBUG_printf(("4cups_raster_write: Writing " CUPS_LLFMT " bytes.", CUPS_LLCAST (wptr - r->buffer)));
+
return (cups_raster_io(r, r->buffer, (size_t)(wptr - r->buffer)));
}
while ((count = write(fd, buf, bytes)) < 0)
#endif /* WIN32 */
if (errno != EINTR && errno != EAGAIN)
+ {
+ DEBUG_printf(("4cups_write_fd: %s", strerror(errno)));
return (-1);
+ }
return (count);
}