# include <poll.h>
#endif /* _WIN32 */
+#ifndef O_BINARY
+# define O_BINARY 0 /* Windows "binary file" nonsense */
+#endif /* !O_BINARY */
+
#ifdef HAVE_MDNSRESPONDER
# include <dns_sd.h>
#elif defined(HAVE_AVAHI)
snprintf(fname, fnamesize, "%s/%d-%s.%s", directory, job->id, name, ext);
- return (open(fname, O_WRONLY | O_CREAT | O_TRUNC, 0666));
+ return (open(fname, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666));
}
if (!strcmp(scheme, "file"))
{
- if ((infile = open(resource, O_RDONLY)) < 0)
+ if ((infile = open(resource, O_RDONLY | O_BINARY)) < 0)
{
respond_ipp(client, IPP_STATUS_ERROR_DOCUMENT_ACCESS, "Unable to access URI: %s", strerror(errno));
char buffer[4096]; /* Copy buffer */
ssize_t bytes; /* Bytes */
- if (!stat(client->printer->strings, &fileinfo) && (fd = open(client->printer->strings, O_RDONLY)) >= 0)
+ if (!stat(client->printer->strings, &fileinfo) && (fd = open(client->printer->strings, O_RDONLY | O_BINARY)) >= 0)
{
if (!respond_http(client, HTTP_STATUS_OK, NULL, "text/strings", (size_t)fileinfo.st_size))
{
char buffer[4096]; /* Copy buffer */
ssize_t bytes; /* Bytes */
- if (!stat(client->printer->icons[1], &fileinfo) && (fd = open(client->printer->icons[1], O_RDONLY)) >= 0)
+ if (!stat(client->printer->icons[1], &fileinfo) && (fd = open(client->printer->icons[1], O_RDONLY | O_BINARY)) >= 0)
{
if (!respond_http(client, HTTP_STATUS_OK, NULL, "image/png", (size_t)fileinfo.st_size))
{
char buffer[4096]; /* Copy buffer */
ssize_t bytes; /* Bytes */
- if (!stat(client->printer->icons[2], &fileinfo) && (fd = open(client->printer->icons[2], O_RDONLY)) >= 0)
+ if (!stat(client->printer->icons[2], &fileinfo) && (fd = open(client->printer->icons[2], O_RDONLY | O_BINARY)) >= 0)
{
if (!respond_http(client, HTTP_STATUS_OK, NULL, "image/png", (size_t)fileinfo.st_size))
{
char buffer[4096]; /* Copy buffer */
ssize_t bytes; /* Bytes */
- if (!stat(client->printer->icons[0], &fileinfo) && (fd = open(client->printer->icons[0], O_RDONLY)) >= 0)
+ if (!stat(client->printer->icons[0], &fileinfo) && (fd = open(client->printer->icons[0], O_RDONLY | O_BINARY)) >= 0)
{
if (!respond_http(client, HTTP_STATUS_OK, NULL, "image/png", (size_t)fileinfo.st_size))
{
{
if (errno == ENOENT)
{
- if ((mystdout = open(resource, O_WRONLY | O_CREAT | O_TRUNC, 0666)) >= 0)
+ if ((mystdout = open(resource, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666)) >= 0)
fprintf(stderr, "[Job %d] Saving print command output to \"%s\".\n", job->id, resource);
else
fprintf(stderr, "[Job %d] Unable to create \"%s\": %s\n", job->id, resource, strerror(errno));
}
else if (!S_ISREG(fileinfo.st_mode))
{
- if ((mystdout = open(resource, O_WRONLY | O_CREAT | O_TRUNC, 0666)) >= 0)
+ if ((mystdout = open(resource, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666)) >= 0)
fprintf(stderr, "[Job %d] Saving print command output to \"%s\".\n", job->id, resource);
else
fprintf(stderr, "[Job %d] Unable to create \"%s\": %s\n", job->id, resource, strerror(errno));
}
- else if ((mystdout = open(resource, O_WRONLY)) >= 0)
+ else if ((mystdout = open(resource, O_WRONLY | O_BINARY)) >= 0)
fprintf(stderr, "[Job %d] Saving print command output to \"%s\".\n", job->id, resource);
else
fprintf(stderr, "[Job %d] Unable to open \"%s\": %s\n", job->id, resource, strerror(errno));
}
if (mystdout < 0)
- mystdout = open("/dev/null", O_WRONLY);
+ mystdout = open("/dev/null", O_WRONLY | O_BINARY);
if (pipe(mypipe))
{