/*
* "$Id$"
*
- * Backend support definitions for CUPS.
+ * Backend support definitions for CUPS.
*
- * Copyright 2007-2012 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products, all rights reserved.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * "LICENSE" which should have been included with this file. If this
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * "LICENSE" which should have been included with this file. If this
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
#ifndef _CUPS_BACKEND_PRIVATE_H_
int uri_size);
extern int backendGetMakeModel(const char *device_id,
char *make_model,
- int make_model_size);
+ size_t make_model_size);
extern int backendNetworkSideCB(int print_fd, int device_fd,
int snmp_fd, http_addr_t *addr,
int use_bc);
/*
* "$Id$"
*
- * DNS-SD discovery backend for CUPS.
+ * DNS-SD discovery backend for CUPS.
*
- * Copyright 2008-2012 by Apple Inc.
+ * Copyright 2008-2014 by Apple Inc.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * "LICENSE" which should have been included with this file. If this
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * "LICENSE" which should have been included with this file. If this
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * main() - Browse for printers.
- * browse_callback() - Browse devices.
- * browse_local_callback() - Browse local devices.
- * client_callback() - Avahi client callback function.
- * compare_devices() - Compare two devices.
- * exec_backend() - Execute the backend that corresponds to the
- * resolved service name.
- * device_type() - Get DNS-SD type enumeration from string.
- * get_device() - Create or update a device.
- * query_callback() - Process query data.
- * find_device() - Find a device from its name and domain.
- * sigterm_handler() - Handle termination signals.
- * unquote() - Unquote a name string.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
#endif /* HAVE_AVAHI */
static int compare_devices(cups_device_t *a, cups_device_t *b);
-static void exec_backend(char **argv);
+static void exec_backend(char **argv) __attribute__((noreturn));
static cups_device_t *get_device(cups_array_t *devices,
const char *serviceName,
const char *regtype,
* 'device_type()' - Get DNS-SD type enumeration from string.
*/
-static int
-device_type(const char *regtype)
+static cups_devtype_t /* O - Device type */
+device_type(const char *regtype) /* I - Service registration type */
{
#ifdef HAVE_AVAHI
if (!strcmp(regtype, "_ipp._tcp"))
datanext = data + datalen;
for (ptr = key; data < datanext && *data != '='; data ++)
- *ptr++ = *data;
+ *ptr++ = (char)*data;
*ptr = '\0';
if (data < datanext && *data == '=')
*/
ptr = device_id + strlen(device_id);
- snprintf(ptr, sizeof(device_id) - (ptr - device_id), "%s:%s;",
- key + 4, value);
+ snprintf(ptr, sizeof(device_id) - (size_t)(ptr - device_id), "%s:%s;", key + 4, value);
}
if (!_cups_strcasecmp(key, "usb_MFG") || !_cups_strcasecmp(key, "usb_MANU") ||
while (isalnum(*ptr & 255) || *ptr == '-' || *ptr == '.')
{
if (isalnum(*ptr & 255) && valptr < (value + sizeof(value) - 1))
- *valptr++ = toupper(*ptr++ & 255);
+ *valptr++ = (char)toupper(*ptr++ & 255);
else
break;
}
}
ptr = device_id + strlen(device_id);
- snprintf(ptr, sizeof(device_id) - (ptr - device_id), "CMD:%s;",
- value + 1);
+ snprintf(ptr, sizeof(device_id) - (size_t)(ptr - device_id), "CMD:%s;", value + 1);
}
if (device_id[0])
/*
* "$Id$"
*
- * IEEE-1284 support functions for CUPS.
+ * IEEE-1284 support functions for CUPS.
*
- * Copyright 2007-2011 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products, all rights reserved.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * "LICENSE" which should have been included with this file. If this
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * "LICENSE" which should have been included with this file. If this
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * backendGetDeviceID() - Get the IEEE-1284 device ID string and
- * corresponding URI.
- * backendGetMakeModel() - Get the make and model string from the device ID.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
backendGetMakeModel(
const char *device_id, /* O - 1284 device ID */
char *make_model, /* O - Make/model */
- int make_model_size) /* I - Size of buffer */
+ size_t make_model_size) /* I - Size of buffer */
{
int num_values; /* Number of keys and values */
cups_option_t *values; /* Keys and values */
*des; /* Description string */
- DEBUG_printf(("backendGetMakeModel(device_id=\"%s\", "
- "make_model=%p, make_model_size=%d)\n", device_id,
- make_model, make_model_size));
+ DEBUG_printf(("backendGetMakeModel(device_id=\"%s\", make_model=%p, make_model_size=" CUPS_LLFMT ")\n", device_id, make_model, CUPS_LLCAST make_model_size));
/*
* Range check input...
*
* IPP backend for CUPS.
*
- * Copyright 2007-2013 by Apple Inc.
+ * Copyright 2007-2014 by Apple Inc.
* Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
static const char *auth_info_required;
/* New auth-info-required value */
#if defined(HAVE_GSSAPI) && defined(HAVE_XPC)
-static int child_pid = 0; /* Child process ID */
+static pid_t child_pid = 0; /* Child process ID */
#endif /* HAVE_GSSAPI && HAVE_XPC */
static const char * const jattrs[] = /* Job attributes we want */
{
break;
}
- sleep(delay);
+ sleep((unsigned)delay);
delay = _cupsNextDelay(delay, &prev_delay);
}
*/
#ifdef HAVE_LIBZ
- compression_sup = NULL;
+ compression_sup = NULL;
#endif /* HAVE_LIBZ */
- copies_sup = NULL;
- cups_version = NULL;
- format_sup = NULL;
- media_col_sup = NULL;
- supported = NULL;
- operations_sup = NULL;
- doc_handling_sup = NULL;
+ copies_sup = NULL;
+ cups_version = NULL;
+ format_sup = NULL;
+ media_col_sup = NULL;
+ supported = NULL;
+ operations_sup = NULL;
+ doc_handling_sup = NULL;
+ print_color_mode_sup = NULL;
do
{
*/
request = ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES);
- request->request.op.version[0] = version / 10;
- request->request.op.version[1] = version % 10;
-
+ ippSetVersion(request, version / 10, version % 10);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
NULL, uri);
report_printer_state(supported);
- sleep(delay);
+ sleep((unsigned)delay);
delay = _cupsNextDelay(delay, &prev_delay);
}
report_printer_state(supported);
- sleep(delay);
+ sleep((unsigned)delay);
delay = _cupsNextDelay(delay, &prev_delay);
_cupsLangPrintFilter(stderr, "INFO", _("Copying print data."));
- if ((compatsize = write(fd, buffer, bytes)) < 0)
+ if ((compatsize = write(fd, buffer, (size_t)bytes)) < 0)
{
perror("DEBUG: Unable to write temporary file");
return (CUPS_BACKEND_FAILED);
else
{
fd = 0;
- http_status = cupsWriteRequestData(http, buffer, bytes);
+ http_status = cupsWriteRequestData(http, buffer, (size_t)bytes);
}
while (http_status == HTTP_CONTINUE &&
{
fprintf(stderr, "DEBUG: Read %d bytes...\n", (int)bytes);
- if ((http_status = cupsWriteRequestData(http, buffer, bytes))
+ if ((http_status = cupsWriteRequestData(http, buffer, (size_t)bytes))
!= HTTP_CONTINUE)
break;
}
*/
request = ippNewRequest(IPP_SEND_DOCUMENT);
- request->request.op.version[0] = version / 10;
- request->request.op.version[1] = version % 10;
+ ippSetVersion(request, version / 10, version % 10);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
NULL, uri);
if (num_files == 0)
{
fd = 0;
- http_status = cupsWriteRequestData(http, buffer, bytes);
+ http_status = cupsWriteRequestData(http, buffer, (size_t)bytes);
}
else
{
while (!job_canceled && http_status == HTTP_CONTINUE &&
(bytes = read(fd, buffer, sizeof(buffer))) > 0)
{
- if ((http_status = cupsWriteRequestData(http, buffer, bytes))
+ if ((http_status = cupsWriteRequestData(http, buffer, (size_t)bytes))
!= HTTP_CONTINUE)
break;
else
*/
request = ippNewRequest(IPP_GET_JOB_ATTRIBUTES);
- request->request.op.version[0] = version / 10;
- request->request.op.version[1] = version % 10;
+ ippSetVersion(request, version / 10, version % 10);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
NULL, uri);
* Wait before polling again...
*/
- sleep(delay);
+ sleep((unsigned)delay);
delay = _cupsNextDelay(delay, &prev_delay);
}
_cupsLangPrintFilter(stderr, "INFO", _("Canceling print job."));
request = ippNewRequest(IPP_CANCEL_JOB);
- request->request.op.version[0] = version / 10;
- request->request.op.version[1] = version % 10;
+ ippSetVersion(request, version / 10, version % 10);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
NULL, uri);
*/
request = ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES);
- request->request.op.version[0] = version / 10;
- request->request.op.version[1] = version % 10;
+ ippSetVersion(request, version / 10, version % 10);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
NULL, uri);
job_op = (monitor->job_id > 0 && monitor->get_job_attrs) ?
IPP_GET_JOB_ATTRIBUTES : IPP_GET_JOBS;
request = ippNewRequest(job_op);
- request->request.op.version[0] = monitor->version / 10;
- request->request.op.version[1] = monitor->version % 10;
+ ippSetVersion(request, monitor->version / 10, monitor->version % 10);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
NULL, monitor->uri);
job_name = attr->values[0].string.text;
else if (!strcmp(attr->name, "job-state") &&
attr->value_tag == IPP_TAG_ENUM)
- job_state = attr->values[0].integer;
+ job_state = (ipp_jstate_t)attr->values[0].integer;
else if (!strcmp(attr->name, "job-originating-user-name") &&
(attr->value_tag == IPP_TAG_NAME ||
attr->value_tag == IPP_TAG_NAMELANG))
* Sleep for N seconds...
*/
- sleep(delay);
+ sleep((unsigned)delay);
delay = _cupsNextDelay(delay, &prev_delay);
}
* Create the IPP request...
*/
- request = ippNewRequest(op);
- request->request.op.version[0] = version / 10;
- request->request.op.version[1] = version % 10;
+ request = ippNewRequest(op);
+ ippSetVersion(request, version / 10, version % 10);
fprintf(stderr, "DEBUG: %s IPP/%d.%d\n",
ippOpString(request->request.op.operation_id),
(keyword = cupsGetOption("job-password", num_options,
options)) != NULL)
{
- ippAddOctetString(request, IPP_TAG_OPERATION, "job-password",
- keyword, strlen(keyword));
+ ippAddOctetString(request, IPP_TAG_OPERATION, "job-password", keyword, (int)strlen(keyword));
if ((keyword = cupsGetOption("job-password-encryption", num_options,
options)) == NULL)
}
break;
case IPP_TAG_STRING :
- ippAddOctetString(request, IPP_TAG_JOB, mandatory, keyword,
- strlen(keyword));
+ ippAddOctetString(request, IPP_TAG_JOB, mandatory, keyword, (int)strlen(keyword));
break;
default :
if (!strcmp(mandatory, "print-color-mode") && !strcmp(keyword, "monochrome"))
{
case IPP_TAG_INTEGER :
case IPP_TAG_ENUM :
- snprintf(valptr, sizeof(value) - (valptr - value), "%d",
- attr->values[i].integer);
+ snprintf(valptr, sizeof(value) - (size_t)(valptr - value), "%d", attr->values[i].integer);
valptr += strlen(valptr);
break;
case IPP_TAG_TEXT :
case IPP_TAG_NAME :
case IPP_TAG_KEYWORD :
- quote_string(attr->values[i].string.text, valptr,
- value + sizeof(value) - valptr);
+ quote_string(attr->values[i].string.text, valptr, (size_t)(value + sizeof(value) - valptr));
valptr += strlen(valptr);
break;
if (response)
{
- child_pid = xpc_dictionary_get_int64(response, "child-pid");
+ child_pid = (pid_t)xpc_dictionary_get_int64(response, "child-pid");
xpc_release(response);
if (child_pid)
- fprintf(stderr, "DEBUG: Child PID=%d.\n", child_pid);
+ fprintf(stderr, "DEBUG: Child PID=%d.\n", (int)child_pid);
else
{
_cupsLangPrintFilter(stderr, "ERROR",
if (response)
{
- status = xpc_dictionary_get_int64(response, "status");
+ status = (int)xpc_dictionary_get_int64(response, "status");
if (status == SIGTERM || status == SIGKILL || status == SIGPIPE)
{
temp = (char *)cupsArrayNext(state_reasons))
if (!strncmp(temp, "cups-remote-", 12))
{
- snprintf(remptr, sizeof(rem) - (remptr - rem), "%s%s", remprefix,
- temp);
+ snprintf(remptr, sizeof(rem) - (size_t)(remptr - rem), "%s%s", remprefix, temp);
remptr += strlen(remptr);
remprefix = ",";
cupsArrayAdd(state_reasons, reason);
- snprintf(addptr, sizeof(add) - (addptr - add), "%s%s", addprefix,
- reason);
+ snprintf(addptr, sizeof(add) - (size_t)(addptr - add), "%s%s", addprefix, reason);
addptr += strlen(addptr);
addprefix = ",";
}
{
if (cupsArrayFind(state_reasons, reason))
{
- snprintf(remptr, sizeof(rem) - (remptr - rem), "%s%s", remprefix,
- reason);
+ snprintf(remptr, sizeof(rem) - (size_t)(remptr - rem), "%s%s", remprefix, reason);
remptr += strlen(remptr);
remprefix = ",";
{
if (strncmp(reason, "cups-", 5) && !cupsArrayFind(new_reasons, reason))
{
- snprintf(remptr, sizeof(rem) - (remptr - rem), "%s%s", remprefix,
- reason);
+ snprintf(remptr, sizeof(rem) - (size_t)(remptr - rem), "%s%s", remprefix, reason);
remptr += strlen(remptr);
remprefix = ",";
{
cupsArrayAdd(state_reasons, reason);
- snprintf(addptr, sizeof(add) - (addptr - add), "%s%s", addprefix,
- reason);
+ snprintf(addptr, sizeof(add) - (size_t)(addptr - add), "%s%s", addprefix, reason);
addptr += strlen(addptr);
addprefix = ",";
}
int copies, int banner, int format, int order,
int reserve, int manual_copies, int timeout,
int contimeout, const char *orighost);
-static int lpd_write(int lpd_fd, char *buffer, int length);
+static ssize_t lpd_write(int lpd_fd, char *buffer, size_t length);
#ifndef HAVE_RRESVPORT_AF
static int rresvport_af(int *port, int family);
#endif /* !HAVE_RRESVPORT_AF */
_cupsLangPrintFilter(stderr, "INFO", _("Copying print data."));
if (bytes > 0)
- write(fd, buffer, bytes);
+ write(fd, buffer, (size_t)bytes);
backendRunLoop(-1, fd, snmp_fd, &(addrlist->addr), 0, 0,
backendNetworkSideCB);
{
va_list ap; /* Argument pointer */
char buf[1024]; /* Output buffer */
- int bytes; /* Number of bytes to output */
+ ssize_t bytes; /* Number of bytes to output */
char status; /* Status from command */
* Send the command...
*/
- fprintf(stderr, "DEBUG: Sending command string (%d bytes)...\n", bytes);
+ fprintf(stderr, "DEBUG: Sending command string (" CUPS_LLFMT " bytes)...\n", CUPS_LLCAST bytes);
- if (lpd_write(fd, buf, bytes) < bytes)
+ if (lpd_write(fd, buf, (size_t)bytes) < bytes)
{
perror("DEBUG: Unable to send LPD command");
return (-1);
if (recv(fd, &status, 1, 0) < 1)
{
_cupsLangPrintFilter(stderr, "WARNING", _("The printer did not respond."));
- status = errno;
+ status = (char)errno;
}
fprintf(stderr, "DEBUG: lpd_command returning %d\n", status);
int have_supplies; /* Printer supports supply levels? */
int copy; /* Copies written */
time_t start_time; /* Time of first connect */
- size_t nbytes; /* Number of bytes written */
+ ssize_t nbytes; /* Number of bytes written */
off_t tbytes; /* Total bytes written */
char buffer[32768]; /* Output buffer */
#ifdef WIN32
return (CUPS_BACKEND_FAILED);
}
- if (!connect(fd, &(addr->addr.addr), httpAddrLength(&(addr->addr))))
+ if (!connect(fd, &(addr->addr.addr), (socklen_t)httpAddrLength(&(addr->addr))))
break;
error = errno;
break;
}
- sleep(delay);
+ sleep((unsigned)delay);
if (delay < 30)
delay += 5;
if (banner)
{
- snprintf(cptr, sizeof(control) - (cptr - control),
+ snprintf(cptr, sizeof(control) - (size_t)(cptr - control),
"C%.31s\n" /* RFC 1179, Section 7.2 - class name <= 31 chars */
"L%s\n",
localhost, user);
while (copies > 0)
{
- snprintf(cptr, sizeof(control) - (cptr - control), "%cdfA%03d%.15s\n",
+ snprintf(cptr, sizeof(control) - (size_t)(cptr - control), "%cdfA%03d%.15s\n",
format, (int)getpid() % 1000, localhost);
cptr += strlen(cptr);
copies --;
}
- snprintf(cptr, sizeof(control) - (cptr - control),
+ snprintf(cptr, sizeof(control) - (size_t)(cptr - control),
"UdfA%03d%.15s\n"
"N%.131s\n", /* RFC 1179, Section 7.2 - sourcefile name <= 131 chars */
(int)getpid() % 1000, localhost, title);
fprintf(stderr, "DEBUG: Sending control file (%u bytes)\n",
(unsigned)strlen(control));
- if (lpd_write(fd, control, strlen(control) + 1) < (strlen(control) + 1))
+ if ((size_t)lpd_write(fd, control, strlen(control) + 1) < (strlen(control) + 1))
{
- status = errno;
+ status = (char)errno;
perror("DEBUG: Unable to write control file");
}
{
_cupsLangPrintFilter(stderr, "WARNING",
_("The printer did not respond."));
- status = errno;
+ status = (char)errno;
}
}
_("Spooling job, %.0f%% complete."),
100.0 * tbytes / filestats.st_size);
- if (lpd_write(fd, buffer, nbytes) < nbytes)
+ if (lpd_write(fd, buffer, (size_t)nbytes) < nbytes)
{
perror("DEBUG: Unable to send print file to printer");
break;
if (mode == MODE_STANDARD)
{
if (tbytes < filestats.st_size)
- status = errno;
+ status = (char)errno;
else if (lpd_write(fd, "", 1) < 1)
{
perror("DEBUG: Unable to send trailing nul to printer");
- status = errno;
+ status = (char)errno;
}
else
{
fprintf(stderr, "DEBUG: Sending control file (%lu bytes)\n",
(unsigned long)strlen(control));
- if (lpd_write(fd, control, strlen(control) + 1) < (strlen(control) + 1))
+ if ((size_t)lpd_write(fd, control, strlen(control) + 1) < (strlen(control) + 1))
{
- status = errno;
+ status = (char)errno;
perror("DEBUG: Unable to write control file");
}
else
{
_cupsLangPrintFilter(stderr, "WARNING",
_("The printer did not respond."));
- status = errno;
+ status = (char)errno;
}
}
* 'lpd_write()' - Write a buffer of data to an LPD server.
*/
-static int /* O - Number of bytes written or -1 on error */
-lpd_write(int lpd_fd, /* I - LPD socket */
- char *buffer, /* I - Buffer to write */
- int length) /* I - Number of bytes to write */
+static ssize_t /* O - Number of bytes written or -1 on error */
+lpd_write(int lpd_fd, /* I - LPD socket */
+ char *buffer, /* I - Buffer to write */
+ size_t length) /* I - Number of bytes to write */
{
- int bytes, /* Number of bytes written */
- total; /* Total number of bytes written */
+ ssize_t bytes, /* Number of bytes written */
+ total; /* Total number of bytes written */
if (abort_job)
return (-1);
total = 0;
- while ((bytes = send(lpd_fd, buffer, length - total, 0)) >= 0)
+ while ((bytes = send(lpd_fd, buffer, length - (size_t)total, 0)) >= 0)
{
total += bytes;
buffer += bytes;
- if (total == length)
+ if ((size_t)total == length)
break;
}
if (bytes < 0)
return (-1);
else
- return (length);
+ return (total);
}
*
* Common backend network APIs for CUPS.
*
- * Copyright 2007-2011 by Apple Inc.
+ * Copyright 2007-2014 by Apple Inc.
* Copyright 2006-2007 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
case CUPS_SC_CMD_GET_BIDI :
status = CUPS_SC_STATUS_OK;
- data[0] = use_bc;
+ data[0] = (char)use_bc;
datalen = 1;
break;
for (dataptr = data + strlen(data) + 1;
count > 0 && dataptr < (data + sizeof(data) - 1);
count --, dataptr += strlen(dataptr))
- strlcpy(dataptr, snmp_value, sizeof(data) - (dataptr - data));
+ strlcpy(dataptr, snmp_value, sizeof(data) - (size_t)(dataptr - data));
fprintf(stderr, "DEBUG: Returning %s %s\n", data,
data + strlen(data) + 1);
status = CUPS_SC_STATUS_OK;
- datalen = dataptr - data;
+ datalen = (int)(dataptr - data);
break;
}
{
if (_cupsSNMPRead(snmp_fd, &packet, 1.0))
{
- int i; /* Looping var */
+ size_t i; /* Looping var */
if (!_cupsSNMPOIDToString(packet.object_name, data, sizeof(data)))
switch (packet.object_type)
{
case CUPS_ASN1_BOOLEAN :
- snprintf(dataptr, sizeof(data) - (dataptr - data), "%d",
- packet.object_value.boolean);
- datalen += (int)strlen(dataptr);
+ snprintf(dataptr, sizeof(data) - (size_t)(dataptr - data), "%d", packet.object_value.boolean);
+ datalen += strlen(dataptr);
break;
case CUPS_ASN1_INTEGER :
- snprintf(dataptr, sizeof(data) - (dataptr - data), "%d",
+ snprintf(dataptr, sizeof(data) - (size_t)(dataptr - data), "%d",
packet.object_value.integer);
- datalen += (int)strlen(dataptr);
+ datalen += strlen(dataptr);
break;
case CUPS_ASN1_BIT_STRING :
case CUPS_ASN1_OCTET_STRING :
- if (packet.object_value.string.num_bytes < 0)
- i = 0;
- else if (packet.object_value.string.num_bytes <
- (sizeof(data) - (dataptr - data)))
+ if (packet.object_value.string.num_bytes < (sizeof(data) - (size_t)(dataptr - data)))
i = packet.object_value.string.num_bytes;
else
- i = (int)(sizeof(data) - (dataptr - data));
+ i = sizeof(data) - (size_t)(dataptr - data);
memcpy(dataptr, packet.object_value.string.bytes, i);
case CUPS_ASN1_OID :
_cupsSNMPOIDToString(packet.object_value.oid, dataptr,
- sizeof(data) - (dataptr - data));
- datalen += (int)strlen(dataptr);
+ sizeof(data) - (size_t)(dataptr - data));
+ datalen += strlen(dataptr);
break;
case CUPS_ASN1_HEX_STRING :
i < packet.object_value.string.num_bytes &&
dataptr < (data + sizeof(data) - 3);
i ++, dataptr += 2)
- sprintf(dataptr, "%02X",
- packet.object_value.string.bytes[i]);
- datalen += (int)strlen(dataptr);
+ sprintf(dataptr, "%02X", packet.object_value.string.bytes[i]);
+ datalen += strlen(dataptr);
break;
case CUPS_ASN1_COUNTER :
- snprintf(dataptr, sizeof(data) - (dataptr - data), "%d",
- packet.object_value.counter);
- datalen += (int)strlen(dataptr);
+ snprintf(dataptr, sizeof(data) - (size_t)(dataptr - data), "%u", packet.object_value.counter);
+ datalen += strlen(dataptr);
break;
case CUPS_ASN1_GAUGE :
- snprintf(dataptr, sizeof(data) - (dataptr - data), "%u",
- packet.object_value.gauge);
- datalen += (int)strlen(dataptr);
+ snprintf(dataptr, sizeof(data) - (size_t)(dataptr - data), "%u", packet.object_value.gauge);
+ datalen += strlen(dataptr);
break;
case CUPS_ASN1_TIMETICKS :
- snprintf(dataptr, sizeof(data) - (dataptr - data), "%u",
- packet.object_value.timeticks);
- datalen += (int)strlen(dataptr);
+ snprintf(dataptr, sizeof(data) - (size_t)(dataptr - data), "%u", packet.object_value.timeticks);
+ datalen += strlen(dataptr);
break;
default :
- fprintf(stderr, "DEBUG: Unknown OID value type %02X!\n",
- packet.object_type);
+ fprintf(stderr, "DEBUG: Unknown OID value type %02X.\n", packet.object_type);
case CUPS_ASN1_NULL_VALUE :
dataptr[0] = '\0';
*
* Common run loop APIs for CUPS backends.
*
- * Copyright 2007-2013 by Apple Inc.
+ * Copyright 2007-2014 by Apple Inc.
* Copyright 2006-2007 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
for (print_ptr = print_buffer; print_bytes > 0;)
{
- if ((bytes = write(device_fd, print_ptr, print_bytes)) < 0)
+ if ((bytes = write(device_fd, print_ptr, (size_t)print_bytes)) < 0)
{
/*
* Write error - bail if we don't see an error we can retry...
fprintf(stderr,
"DEBUG: Received " CUPS_LLFMT " bytes of back-channel data\n",
CUPS_LLCAST bc_bytes);
- cupsBackChannelWrite(bc_buffer, bc_bytes, 1.0);
+ cupsBackChannelWrite(bc_buffer, (size_t)bc_bytes, 1.0);
}
else if (bc_bytes < 0 && errno != EAGAIN && errno != EINTR)
{
if (print_bytes && FD_ISSET(device_fd, &output))
{
- if ((bytes = write(device_fd, print_ptr, print_bytes)) < 0)
+ if ((bytes = write(device_fd, print_ptr, (size_t)print_bytes)) < 0)
{
/*
* Write error - bail if we don't see an error we can retry...
/*
* "$Id$"
*
- * SNMP supplies functions for CUPS.
+ * SNMP supplies functions for CUPS.
*
- * Copyright 2008-2013 by Apple Inc.
+ * Copyright 2008-2014 by Apple Inc.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * "LICENSE" which should have been included with this file. If this
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * "LICENSE" which should have been included with this file. If this
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * backendSNMPSupplies() - Get the current supplies for a device.
- * backend_init_supplies() - Initialize the supplies list.
- * backend_walk_cb() - Interpret the supply value responses.
- * utf16_to_utf8() - Convert UTF-16 text to UTF-8.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
if ((supplies[i].max_capacity > 0 || (quirks & CUPS_SNMP_CAPACITY)) &&
supplies[i].level >= 0)
- snprintf(ptr, sizeof(value) - (ptr - value), "%d", percent);
+ snprintf(ptr, sizeof(value) - (size_t)(ptr - value), "%d", percent);
else
- strlcpy(ptr, "-1", sizeof(value) - (ptr - value));
+ strlcpy(ptr, "-1", sizeof(value) - (size_t)(ptr - value));
}
fprintf(stderr, "ATTR: marker-levels=%s\n", value);
{
if (!strcmp(description, value))
cupsFileRead(cachefile, (char *)supplies,
- num_supplies * sizeof(backend_supplies_t));
+ (size_t)num_supplies * sizeof(backend_supplies_t));
else
{
num_supplies = -1;
if (num_supplies > 0)
cupsFileWrite(cachefile, (char *)supplies,
- num_supplies * sizeof(backend_supplies_t));
+ (size_t)num_supplies * sizeof(backend_supplies_t));
cupsFileClose(cachefile);
}
if (i)
*ptr++ = ',';
- strlcpy(ptr, supplies[i].color, sizeof(value) - (ptr - value));
+ strlcpy(ptr, supplies[i].color, sizeof(value) - (size_t)(ptr - value));
}
fprintf(stderr, "ATTR: marker-colors=%s\n", value);
type = supplies[i].type;
if (type < CUPS_TC_other || type > CUPS_TC_covers)
- strlcpy(ptr, "unknown", sizeof(value) - (ptr - value));
+ strlcpy(ptr, "unknown", sizeof(value) - (size_t)(ptr - value));
else
- strlcpy(ptr, types[type - CUPS_TC_other], sizeof(value) - (ptr - value));
+ strlcpy(ptr, types[type - CUPS_TC_other], sizeof(value) - (size_t)(ptr - value));
}
fprintf(stderr, "ATTR: marker-types=%s\n", value);
for (ptr = temp; srcsize >= 2;)
{
if (le)
- ch = src[0] | (src[1] << 8);
+ ch = (cups_utf32_t)(src[0] | (src[1] << 8));
else
- ch = (src[0] << 8) | src[1];
+ ch = (cups_utf32_t)((src[0] << 8) | src[1]);
src += 2;
srcsize -= 2;
* Multi-word UTF-16 char...
*/
- int lch; /* Lower word */
+ cups_utf32_t lch; /* Lower word */
if (le)
- lch = src[0] | (src[1] << 8);
+ lch = (cups_utf32_t)(src[0] | (src[1] << 8));
else
- lch = (src[0] << 8) | src[1];
+ lch = (cups_utf32_t)((src[0] << 8) | src[1]);
if (lch >= 0xdc00 && lch <= 0xdfff)
{
*ptr = '\0';
- cupsUTF32ToUTF8(dst, temp, dstsize);
+ cupsUTF32ToUTF8(dst, temp, (int)dstsize);
}
/*
* "$Id$"
*
- * SNMP discovery backend for CUPS.
+ * SNMP discovery backend for CUPS.
*
- * Copyright 2007-2012 by Apple Inc.
- * Copyright 2006-2007 by Easy Software Products, all rights reserved.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 2006-2007 by Easy Software Products, all rights reserved.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * "LICENSE" which should have been included with this file. If this
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * "LICENSE" which should have been included with this file. If this
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * main() - Discover printers via SNMP.
- * add_array() - Add a string to an array.
- * add_cache() - Add a cached device...
- * add_device_uri() - Add a device URI to the cache.
- * alarm_handler() - Handle alarm signals...
- * compare_cache() - Compare two cache entries.
- * debug_printf() - Display some debugging information.
- * fix_make_model() - Fix common problems in the make-and-model
- * string.
- * free_array() - Free an array of strings.
- * free_cache() - Free the array of cached devices.
- * get_interface_addresses() - Get the broadcast address(es) associated with
- * an interface.
- * list_device() - List a device we found...
- * password_cb() - Handle authentication requests.
- * probe_device() - Probe a device to discover whether it is a
- * printer.
- * read_snmp_conf() - Read the snmp.conf file.
- * read_snmp_response() - Read and parse a SNMP response...
- * run_time() - Return the total running time...
- * scan_devices() - Scan for devices using SNMP.
- * try_connect() - Try connecting on a port...
- * update_cache() - Update a cached device...
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
* Insert hostname/address...
*/
- strlcpy(uriptr, device->addrname, sizeof(uri) - (uriptr - uri));
+ strlcpy(uriptr, device->addrname, sizeof(uri) - (size_t)(uriptr - uri));
uriptr += strlen(uriptr);
format += 2;
}
alarm(1);
- status = connect(fd, (void *)addr, httpAddrLength(addr));
+ status = connect(fd, (void *)addr, (socklen_t)httpAddrLength(addr));
close(fd);
alarm(0);
*
* AppSocket backend for CUPS.
*
- * Copyright 2007-2013 by Apple Inc.
+ * Copyright 2007-2014 by Apple Inc.
* Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
* Local functions...
*/
-static int wait_bc(int device_fd, int secs);
+static ssize_t wait_bc(int device_fd, int secs);
/*
break;
}
- sleep(delay);
+ sleep((unsigned)delay);
if (delay < 30)
delay += 5;
tbytes = 0;
if (bytes > 0)
- tbytes += write(device_fd, buffer, bytes);
+ tbytes += write(device_fd, buffer, (size_t)bytes);
while (copies > 0 && tbytes >= 0)
{
* 'wait_bc()' - Wait for back-channel data...
*/
-static int /* O - # bytes read or -1 on error */
+static ssize_t /* O - # bytes read or -1 on error */
wait_bc(int device_fd, /* I - Socket */
int secs) /* I - Seconds to wait */
{
{
fprintf(stderr, "DEBUG: Received %d bytes of back-channel data\n",
(int)bytes);
- cupsBackChannelWrite(buffer, bytes, 1.0);
+ cupsBackChannelWrite(buffer, (size_t)bytes, 1.0);
}
return (bytes);
/*
* "$Id$"
*
- * Backend test program for CUPS.
+ * Backend test program for CUPS.
*
- * Copyright 2007-2012 by Apple Inc.
- * Copyright 1997-2005 by Easy Software Products, all rights reserved.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2005 by Easy Software Products, all rights reserved.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * "LICENSE" which should have been included with this file. If this
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * "LICENSE" which should have been included with this file. If this
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * main() - Run the named backend.
- * sigterm_handler() - Flag when we get SIGTERM.
- * usage() - Show usage information.
- * walk_cb() - Show results of cupsSideChannelSNMPWalk...
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
if (getcwd(libpath, sizeof(libpath)) &&
(ptr = strrchr(libpath, '/')) != NULL && !strcmp(ptr, "/backend"))
{
- strlcpy(ptr, "/cups", sizeof(libpath) - (ptr - libpath));
+ strlcpy(ptr, "/cups", sizeof(libpath) - (size_t)(ptr - libpath));
if (!access(libpath, 0))
{
#ifdef __APPLE__
*/
if ((bytes = cupsBackChannelRead(buffer, sizeof(buffer), 0)) > 0)
- write(2, buffer, bytes);
+ write(2, buffer, (size_t)bytes);
/*
* Throttle output to ~100hz...
*/
while ((bytes = cupsBackChannelRead(buffer, sizeof(buffer), 5.0)) > 0)
- write(2, buffer, bytes);
+ write(2, buffer, (size_t)bytes);
exit(0);
}
while ((bytes = cupsBackChannelRead(buffer, sizeof(buffer),
timeout)) > 0)
{
- write(2, buffer, bytes);
+ write(2, buffer, (size_t)bytes);
timeout = 5.0;
}
write(2, "\nDEBUG: END\n", 12);
void *context) /* I - Context (unused) */
{
char temp[80];
- if (datalen > (sizeof(temp) - 1))
+
+ (void)context;
+
+ if ((size_t)datalen > (sizeof(temp) - 1))
{
memcpy(temp, data, sizeof(temp) - 1);
temp[sizeof(temp) - 1] = '\0';
/*
* "$Id$"
*
- * Copyright 2005-2013 Apple Inc. All rights reserved.
+ * Copyright 2005-2014 Apple Inc. All rights reserved.
*
* IMPORTANT: This Apple software is supplied to you by Apple Computer,
* Inc. ("Apple") in consideration of your agreement to the following
#if defined(__i386__) || defined(__x86_64__)
static pid_t child_pid; /* Child PID */
-static void run_legacy_backend(int argc, char *argv[], int fd); /* Starts child backend process running as a ppc executable */
+static void run_legacy_backend(int argc, char *argv[], int fd) __attribute__((noreturn)); /* Starts child backend process running as a ppc executable */
#endif /* __i386__ || __x86_64__ */
static void sigterm_handler(int sig); /* SIGTERM handler */
-static void sigquit_handler(int sig, siginfo_t *si, void *unused);
+static void sigquit_handler(int sig, siginfo_t *si, void *unused) __attribute__((noreturn));
#ifdef PARSE_PS_ERRORS
static const char *next_line (const char *buffer);
if (g.print_bytes)
{
- bytes = g.print_bytes;
+ bytes = (UInt32)g.print_bytes;
iostatus = (*g.classdriver)->WritePipe(g.classdriver, (UInt8*)print_ptr, &bytes, 0);
/*
{
fputs("DEBUG: Got USB pipe stalled during write\n", stderr);
- bytes = g.print_bytes;
+ bytes = (UInt32)g.print_bytes;
iostatus = (*g.classdriver)->WritePipe(g.classdriver, (UInt8*)print_ptr, &bytes, 0);
}
sleep(5);
#endif /* DEBUG_WRITES */
- bytes = g.print_bytes;
+ bytes = (UInt32)g.print_bytes;
iostatus = (*g.classdriver)->WritePipe(g.classdriver, (UInt8*)print_ptr, &bytes, 0);
}
fputs("DEBUG: CUPS_SC_CMD_GET_BIDI received from driver...\n",
stderr);
- data[0] = g.bidi_flag;
+ data[0] = (char)g.bidi_flag;
cupsSideChannelWrite(command, CUPS_SC_STATUS_OK, data, 1, 1.0);
fprintf(stderr,
get_device_id(&status, data, &datalen);
cupsSideChannelWrite(command, CUPS_SC_STATUS_OK, data, datalen, 1.0);
- if (datalen < sizeof(data))
+ if ((size_t)datalen < sizeof(data))
data[datalen] = '\0';
else
data[sizeof(data) - 1] = '\0';
if (obj != 0x0)
{
CFStringRef idString = NULL;
- UInt32 location = -1;
+ UInt32 location = ~0U;
UInt8 interfaceNum = 0;
copy_devicestring(obj, &idString, &location, &interfaceNum);
else if (!_cups_strcasecmp(name, "serial"))
strlcpy(serial, value, serial_size);
else if (!_cups_strcasecmp(name, "location") && location)
- *location = strtol(value, NULL, 16);
+ *location = (UInt32)strtoul(value, NULL, 16);
}
}
char *my_argv[32];
char *usb_legacy_status;
+
/*
* If we're running as x86_64 or i386 and couldn't load the class driver
* (because it's ppc or i386), then try to re-exec ourselves in ppc or i386
cups_serverbin = CUPS_SERVERBIN;
snprintf(usbpath, sizeof(usbpath), "%s/backend/usb", cups_serverbin);
- for (i = 0; i < argc && i < (sizeof(my_argv) / sizeof(my_argv[0])) - 1; i ++)
+ for (i = 0; i < argc && i < (int)(sizeof(my_argv) / sizeof(my_argv[0])) - 1; i ++)
my_argv[i] = argv[i];
my_argv[i] = NULL;
if (deviceIDString)
{
CFStringGetCString(deviceIDString, data, *datalen, kCFStringEncodingUTF8);
- *datalen = strlen(data);
+ *datalen = (int)strlen(data);
CFRelease(deviceIDString);
}
*status = CUPS_SC_STATUS_OK;
/*
* "$Id$"
*
- * "lpc" command for CUPS.
+ * "lpc" command for CUPS.
*
- * Copyright 2007-2012 by Apple Inc.
- * Copyright 1997-2006 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2006 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
- *
- * Contents:
- *
- * main() - Parse options and commands.
- * compare_strings() - Compare two command-line strings.
- * do_command() - Do an lpc command...
- * show_help() - Show help messages.
- * show_status() - Show printers.
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*/
/*
* Local functions...
*/
-static int compare_strings(const char *, const char *, int);
+static int compare_strings(const char *, const char *, size_t);
static void do_command(http_t *, const char *, const char *);
static void show_help(const char *);
static void show_status(http_t *, const char *);
static int /* O - -1 or 1 = no match, 0 = match */
compare_strings(const char *s, /* I - Command-line string */
const char *t, /* I - Option string */
- int tmin) /* I - Minimum number of unique chars in option */
+ size_t tmin) /* I - Minimum number of unique chars in option */
{
- int slen; /* Length of command-line string */
+ size_t slen; /* Length of command-line string */
slen = strlen(s);
*
* "lpq" command for CUPS.
*
- * Copyright 2007-2013 by Apple Inc.
+ * Copyright 2007-2014 by Apple Inc.
* Copyright 1997-2006 by Easy Software Products.
*
* These coded instructions, statements, and computer programs are the
* Include necessary headers...
*/
-/*
- * Include necessary headers...
- */
-
#include <cups/cups-private.h>
httpClose(http);
usage();
- break;
}
}
else if (isdigit(argv[i][0] & 255))
if (i && interval)
{
fflush(stdout);
- sleep(interval);
+ sleep((unsigned)interval);
}
else
break;
/*
* "$Id$"
*
- * "lpr" command for CUPS.
+ * "lpr" command for CUPS.
*
- * Copyright 2007-2013 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2007 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
- *
- * Contents:
- *
- * main() - Parse options and send files for printing.
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*/
/*
while (status == HTTP_CONTINUE &&
(bytes = read(0, buffer, sizeof(buffer))) > 0)
- status = cupsWriteRequestData(CUPS_HTTP_DEFAULT, buffer, bytes);
+ status = cupsWriteRequestData(CUPS_HTTP_DEFAULT, buffer, (size_t)bytes);
if (status != HTTP_CONTINUE)
{
#
# CGI makefile for CUPS.
#
-# Copyright 2007-2013 by Apple Inc.
+# Copyright 2007-2014 by Apple Inc.
# Copyright 1997-2006 by Easy Software Products.
#
# These coded instructions, statements, and computer programs are the
printers.cgi
LIBTARGETS = \
libcupscgi.a \
- $(LIBCUPSCGI) \
- websearch
+ $(LIBCUPSCGI)
UNITTARGETS = \
testcgi \
$(COMMONLIBS) $(SSLLIBS) $(DNSSDLIBS) $(LIBZ) $(LIBGSSAPI)
-#
-# websearch
-#
-
-websearch: websearch.o ../Makedefs libcupscgi.a ../cups/$(LIBCUPSSTATIC)
- echo Linking $@...
- $(CC) $(ARCHFLAGS) $(LDFLAGS) -o $@ websearch.o libcupscgi.a \
- ../cups/$(LIBCUPSSTATIC) $(COMMONLIBS) $(SSLLIBS) $(DNSSDLIBS) \
- $(LIBZ) $(LIBGSSAPI)
-
-
#
# Dependencies...
#
/*
* "$Id$"
*
- * Administration CGI for CUPS.
+ * Administration CGI for CUPS.
*
- * Copyright 2007-2012 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2007 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
- *
- * Contents:
- *
- * main() - Main entry for CGI.
- * choose_device_cb() - Add a device to the device selection page.
- * do_add_rss_subscription() - Add a RSS subscription.
- * do_am_class() - Add or modify a class.
- * do_am_printer() - Add or modify a printer.
- * do_cancel_subscription() - Cancel a subscription.
- * do_config_server() - Configure server settings.
- * do_delete_class() - Delete a class.
- * do_delete_printer() - Delete a printer.
- * do_export() - Export printers to Samba.
- * do_list_printers() - List available printers.
- * do_menu() - Show the main menu.
- * do_set_allowed_users() - Set the allowed/denied users for a queue.
- * do_set_default() - Set the server default printer/class.
- * do_set_options() - Configure the default options for a queue.
- * do_set_sharing() - Set printer-is-shared value.
- * get_option_value() - Return the value of an option.
- * get_points() - Get a value in points.
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*/
/*
*/
int /* O - Exit status */
-main(int argc, /* I - Number of command-line arguments */
- char *argv[]) /* I - Command-line arguments */
+main(void)
{
http_t *http; /* Connection to the server */
const char *op; /* Operation name */
char filename[1024]; /* PPD filename */
ppd_file_t *ppd; /* PPD information */
char buffer[1024]; /* Buffer */
- int bytes; /* Number of bytes */
+ ssize_t bytes; /* Number of bytes */
http_status_t get_status; /* Status of GET */
else if ((fd = cupsTempFd(filename, sizeof(filename))) >= 0)
{
while ((bytes = httpRead2(http, buffer, sizeof(buffer))) > 0)
- write(fd, buffer, bytes);
+ write(fd, buffer, (size_t)bytes);
close(fd);
}
else
{
+ int linenum; /* Line number */
+
fprintf(stderr, "ERROR: Unable to open PPD file %s: %s\n",
- filename, ppdErrorString(ppdLastError(&bytes)));
+ filename, ppdErrorString(ppdLastError(&linenum)));
}
}
else
if ((uriptr = strchr(uri, '?')) == NULL)
uriptr = uri + strlen(uri);
- snprintf(uriptr, sizeof(uri) - (uriptr - uri),
+ snprintf(uriptr, sizeof(uri) - (size_t)(uriptr - uri),
"?baud=%s+bits=%s+parity=%s+flow=%s",
cgiGetVariable("BAUDRATE"), cgiGetVariable("BITS"),
cgiGetVariable("PARITY"), cgiGetVariable("FLOW"));
if ((end = strstr(start, "\n")) == NULL)
end = start + strlen(start);
- cupsFileWrite(temp, start, end - start);
+ cupsFileWrite(temp, start, (size_t)(end - start));
cupsFilePutChar(temp, '\n');
if (*end == '\r')
* Allocate memory and load the file into a string buffer...
*/
- if ((buffer = calloc(1, info.st_size + 1)) != NULL)
+ if ((buffer = calloc(1, (size_t)info.st_size + 1)) != NULL)
{
- cupsFileRead(cupsd, buffer, info.st_size);
+ cupsFileRead(cupsd, buffer, (size_t)info.st_size);
cgiSetVariable("CUPSDCONF", buffer);
free(buffer);
}
if (!stat(filename, &info) && info.st_size < (1024 * 1024) &&
(cupsd = cupsFileOpen(filename, "r")) != NULL)
{
- if ((buffer = calloc(1, 2 * info.st_size + 1)) != NULL)
+ if ((buffer = calloc(1, 2 * (size_t)info.st_size + 1)) != NULL)
{
bufend = buffer + 2 * info.st_size - 1;
if (ch == '\\' || ch == '\"')
{
*bufptr++ = '\\';
- *bufptr++ = ch;
+ *bufptr++ = (char)ch;
}
else if (ch == '\n')
{
*bufptr++ = 't';
}
else if (ch >= ' ')
- *bufptr++ = ch;
+ *bufptr++ = (char)ch;
}
*bufptr = '\0';
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
NULL, uri);
- ippAddBoolean(request, IPP_TAG_OPERATION, "printer-is-shared", atoi(shared));
+ ippAddBoolean(request, IPP_TAG_OPERATION, "printer-is-shared", (char)atoi(shared));
/*
* Do the request and get back a response...
/*
* "$Id$"
*
- * Class status CGI for CUPS.
+ * Class status CGI for CUPS.
*
- * Copyright 2007-2012 by Apple Inc.
- * Copyright 1997-2006 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2006 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
- *
- * Contents:
- *
- * main() - Main entry for CGI.
- * do_class_op() - Do a class operation.
- * show_all_classes() - Show all classes...
- * show_class() - Show a single class.
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*/
/*
*/
int /* O - Exit status */
-main(int argc, /* I - Number of command-line arguments */
- char *argv[]) /* I - Command-line arguments */
+main(void)
{
const char *pclass; /* Class name */
const char *user; /* Username */
/*
* "$Id$"
*
- * Online help index routines for CUPS.
+ * Online help index routines for CUPS.
*
- * Copyright 2007-2012 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2007 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
- *
- * Contents:
- *
- * helpDeleteIndex() - Delete an index, freeing all memory used.
- * helpFindNode() - Find a node in an index.
- * helpLoadIndex() - Load a help index from disk.
- * helpSaveIndex() - Save a help index to disk.
- * helpSearchIndex() - Search an index.
- * help_add_word() - Add a word to a node.
- * help_compile_search() - Convert a search string into a regular expression.
- * help_delete_node() - Free all memory used by a node.
- * help_delete_word() - Free all memory used by a word.
- * help_load_directory() - Load a directory of files into an index.
- * help_load_file() - Load a HTML files into an index.
- * help_new_node() - Create a new node and add it to an index.
- * help_sort_nodes_by_name() - Sort nodes by section, filename, and anchor.
- * help_sort_nodes_by_score() - Sort nodes by score and text.
- * help_sort_words() - Sort words alphabetically.
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*/
/*
mtime = strtol(ptr, &ptr, 10);
offset = strtoll(ptr, &ptr, 10);
- length = strtoll(ptr, &ptr, 10);
+ length = (size_t)strtoll(ptr, &ptr, 10);
while (isspace(*ptr & 255))
ptr ++;
*ptr++ = ' ';
- if (!cupsFileGets(fp, ptr, sizeof(line) - (ptr - line) - 1))
+ if (!cupsFileGets(fp, ptr, sizeof(line) - (size_t)(ptr - line) - 1))
break;
}
*ptr = '\0';
if (node)
- node->length = offset - node->offset;
+ node->length = (size_t)(offset - node->offset);
if (!*text)
{
for (text = ptr, ptr ++; *ptr && isalnum(*ptr & 255); ptr ++);
- wordlen = ptr - text;
+ wordlen = (int)(ptr - text);
memcpy(temp, text, wordlen);
temp[wordlen] = '\0';
cupsFileClose(fp);
if (node)
- node->length = offset - node->offset;
+ node->length = (size_t)(offset - node->offset);
return (0);
}
/*
* "$Id$"
*
- * CGI <-> IPP variable routines for CUPS.
+ * CGI <-> IPP variable routines for CUPS.
*
- * Copyright 2007-2012 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2007 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
- *
- * Contents:
- *
- * cgiGetAttributes() - Get the list of attributes that are needed by the
- * template file.
- * cgiGetIPPObjects() - Get the objects in an IPP response.
- * cgiMoveJobs() - Move one or more jobs.
- * cgiPrintCommand() - Print a CUPS command job.
- * cgiPrintTestPage() - Print a test page.
- * cgiRewriteURL() - Rewrite a printer URI into a web browser URL...
- * cgiSetIPPObjectVars() - Set CGI variables from an IPP object.
- * cgiSetIPPVars() - Set CGI variables from an IPP response.
- * cgiShowIPPError() - Show the last IPP error message.
- * cgiShowJobs() - Show print jobs.
- * cgiText() - Return localized text.
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*/
/*
{
for (i = 0; lang[i] && i < 15; i ++)
if (isalnum(lang[i] & 255))
- locale[i] = tolower(lang[i]);
+ locale[i] = (char)tolower(lang[i]);
else
locale[i] = '_';
while ((ch = getc(in)) != EOF)
if (ch == '\\')
getc(in);
- else if (ch == '{' && num_attrs < (sizeof(attrs) / sizeof(attrs[0])))
+ else if (ch == '{' && num_attrs < (int)(sizeof(attrs) / sizeof(attrs[0])))
{
/*
* Grab the name...
if (ch == '_')
*nameptr++ = '-';
else
- *nameptr++ = ch;
+ *nameptr++ = (char)ch;
}
*nameptr = '\0';
*valptr++ = ' ';
}
- remaining = sizeof(value) - (valptr - value);
+ remaining = sizeof(value) - (size_t)(valptr - value);
if (!strcmp(attr->values[i].string.text, "printer-stopped"))
strlcpy(valptr, _("Printer Paused"), remaining);
for (i = 0; i < attr->num_values; i ++)
{
if (i)
- strlcat(valptr, ", ", sizeof(value) - (valptr - value));
+ strlcat(valptr, ", ", sizeof(value) - (size_t)(valptr - value));
valptr += strlen(valptr);
t = (time_t)attr->values[i].integer;
date = localtime(&t);
- strftime(valptr, sizeof(value) - (valptr - value), "%c", date);
+ strftime(valptr, sizeof(value) - (size_t)(valptr - value), "%c", date);
}
else
- snprintf(valptr, sizeof(value) - (valptr - value),
+ snprintf(valptr, sizeof(value) - (size_t)(valptr - value),
"%d", attr->values[i].integer);
break;
case IPP_TAG_BOOLEAN :
- snprintf(valptr, sizeof(value) - (valptr - value),
+ snprintf(valptr, sizeof(value) - (size_t)(valptr - value),
"%d", attr->values[i].boolean);
break;
case IPP_TAG_NOVALUE :
- strlcat(valptr, "novalue", sizeof(value) - (valptr - value));
+ strlcat(valptr, "novalue", sizeof(value) - (size_t)(valptr - value));
break;
case IPP_TAG_RANGE :
- snprintf(valptr, sizeof(value) - (valptr - value),
+ snprintf(valptr, sizeof(value) - (size_t)(valptr - value),
"%d-%d", attr->values[i].range.lower,
attr->values[i].range.upper);
break;
case IPP_TAG_RESOLUTION :
- snprintf(valptr, sizeof(value) - (valptr - value),
+ snprintf(valptr, sizeof(value) - (size_t)(valptr - value),
"%dx%d%s", attr->values[i].resolution.xres,
attr->values[i].resolution.yres,
attr->values[i].resolution.units == IPP_RES_PER_INCH ?
cgiRewriteURL(attr->values[i].string.text, url,
sizeof(url), NULL);
- snprintf(valptr, sizeof(value) - (valptr - value),
+ snprintf(valptr, sizeof(value) - (size_t)(valptr - value),
"<A HREF=\"%s\">%s</A>", url,
strrchr(attr->values[i].string.text, '/') + 1);
}
else
cgiRewriteURL(attr->values[i].string.text, valptr,
- sizeof(value) - (valptr - value), NULL);
+ (int)(sizeof(value) - (size_t)(valptr - value)), NULL);
break;
}
case IPP_TAG_LANGUAGE :
case IPP_TAG_MIMETYPE :
strlcat(valptr, attr->values[i].string.text,
- sizeof(value) - (valptr - value));
+ sizeof(value) - (size_t)(valptr - value));
break;
case IPP_TAG_BEGIN_COLLECTION :
/*
* "$Id$"
*
- * Job status CGI for CUPS.
+ * Job status CGI for CUPS.
*
- * Copyright 2007-2012 by Apple Inc.
- * Copyright 1997-2006 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2006 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
- *
- * Contents:
- *
- * main() - Main entry for CGI.
- * do_job_op() - Do a job operation.
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*/
/*
*/
int /* O - Exit status */
-main(int argc, /* I - Number of command-line arguments */
- char *argv[]) /* I - Command-line arguments */
+main(void)
{
http_t *http; /* Connection to the server */
const char *op; /* Operation name */
/*
* "$Id$"
*
- * Printer status CGI for CUPS.
+ * Printer status CGI for CUPS.
*
- * Copyright 2007-2012 by Apple Inc.
- * Copyright 1997-2006 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2006 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
- *
- * Contents:
- *
- * main() - Main entry for CGI.
- * do_printer_op() - Do a printer operation.
- * show_all_printers() - Show all printers...
- * show_printer() - Show a single printer.
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*/
/*
*/
int /* O - Exit status */
-main(int argc, /* I - Number of command-line arguments */
- char *argv[]) /* I - Command-line arguments */
+main(void)
{
const char *printer; /* Printer name */
const char *user; /* Username */
/*
* "$Id$"
*
- * Search routines for CUPS.
+ * Search routines for CUPS.
*
- * Copyright 2007-2012 by Apple Inc.
- * Copyright 1997-2006 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2006 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
- *
- * Contents:
- *
- * cgiCompileSearch() - Compile a search string.
- * cgiDoSearch() - Do a search of some text.
- * cgiFreeSearch() - Free a compiled search context.
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*/
/*
char *s, /* Regular expression string */
*sptr, /* Pointer into RE string */
*sword; /* Pointer to start of word */
- int slen; /* Allocated size of RE string */
+ size_t slen; /* Allocated size of RE string */
const char *qptr, /* Pointer into query string */
*qend; /* End of current word */
const char *prefix; /* Prefix to add to next word */
int quoted; /* Word is quoted */
- int wlen; /* Word length */
+ size_t wlen; /* Word length */
char *lword; /* Last word in query */
for (qend = qptr + 1; *qend && !isspace(*qend); qend ++);
}
- wlen = qend - qptr;
+ wlen = (size_t)(qend - qptr);
/*
* Look for logic words: AND, OR
* string + RE overhead...
*/
- wlen = (sptr - s) + 2 * 4 * wlen + 2 * strlen(prefix) + 11;
+ wlen = (size_t)(sptr - s) + 2 * 4 * wlen + 2 * strlen(prefix) + 11;
if (lword)
wlen += strlen(lword);
/*
* "$Id$"
*
- * CGI template function.
+ * CGI template function.
*
- * Copyright 2007-2011 by Apple Inc.
- * Copyright 1997-2006 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2006 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
- *
- * Contents:
- *
- * cgiCopyTemplateFile() - Copy a template file and replace all the
- * '{variable}' strings with the variable value.
- * cgiCopyTemplateLang() - Copy a template file using a language...
- * cgiGetTemplateDir() - Get the templates directory...
- * cgiSetServerVersion() - Set the server name and CUPS version...
- * cgi_copy() - Copy the template file, substituting as needed...
- * cgi_puts() - Put a string to the output file, quoting as
- * needed...
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*/
#include "cgi-private.h"
else if (s > name && ch == '?')
break;
else if (s < (name + sizeof(name) - 1))
- *s++ = ch;
+ *s++ = (char)ch;
*s = '\0';
* {name~refex?true:false} Regex match
*/
- op = ch;
+ op = (char)ch;
if (ch == '?')
{
innerptr = innername;
while ((ch = getc(in)) != EOF && ch != '}')
if (innerptr < (innername + sizeof(innername) - 1))
- *innerptr++ = ch;
+ *innerptr++ = (char)ch;
*innerptr = '\0';
if (innername[0] == '#')
if ((innerval = cgiGetArray(innername, atoi(innerptr) - 1)) == NULL)
*s = '\0';
else
- strlcpy(s, innerval, sizeof(compare) - (s - compare));
+ strlcpy(s, innerval, sizeof(compare) - (size_t)(s - compare));
}
else if (innername[0] == '?')
{
if ((innerval = cgiGetArray(innername + 1, element)) == NULL)
*s = '\0';
else
- strlcpy(s, innerval, sizeof(compare) - (s - compare));
+ strlcpy(s, innerval, sizeof(compare) - (size_t)(s - compare));
}
else if ((innerval = cgiGetArray(innername, element)) == NULL)
- snprintf(s, sizeof(compare) - (s - compare), "{%s}", innername);
+ snprintf(s, sizeof(compare) - (size_t)(s - compare), "{%s}", innername);
else
- strlcpy(s, innerval, sizeof(compare) - (s - compare));
+ strlcpy(s, innerval, sizeof(compare) - (size_t)(s - compare));
s += strlen(s);
}
else if (ch == '\\')
- *s++ = getc(in);
+ *s++ = (char)getc(in);
else
- *s++ = ch;
+ *s++ = (char)ch;
*s = '\0';
/*
* "$Id$"
*
- * CGI test program for CUPS.
+ * CGI test program for CUPS.
*
- * Copyright 2007-2011 by Apple Inc.
- * Copyright 1997-2005 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2005 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
- *
- * Contents:
- *
- * main() - Test the help index code.
- * list_nodes() - List nodes in an array...
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*/
/*
*/
int /* O - Exit status */
-main(int argc, /* I - Number of command-line arguments */
- char *argv[]) /* I - Command-line arguments */
+main(void)
{
/*
* Test file upload/multi-part submissions...
/*
* "$Id$"
*
- * CGI form variable and array functions for CUPS.
+ * CGI form variable and array functions for CUPS.
*
- * Copyright 2007-2011 by Apple Inc.
- * Copyright 1997-2005 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2005 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
- *
- * Contents:
- *
- * cgiCheckVariables() - Check for the presence of "required"
- * variables.
- * cgiClearVariables() - Clear all form variables.
- * cgiGetArray() - Get an element from a form array.
- * cgiGetCookie() - Get a cookie value.
- * cgiGetFile() - Get the file (if any) that was submitted in
- * the form.
- * cgiGetSize() - Get the size of a form array value.
- * cgiGetVariable() - Get a CGI variable from the database.
- * cgiInitialize() - Initialize the CGI variable "database".
- * cgiIsPOST() - Determine whether this page was POSTed.
- * cgiSetArray() - Set array element N to the specified string.
- * cgiSetCookie() - Set a cookie value.
- * cgiSetSize() - Set the array size.
- * cgiSetVariable() - Set a CGI variable in the database.
- * cgi_add_variable() - Add a form variable.
- * cgi_compare_variables() - Compare two variables.
- * cgi_find_variable() - Find a variable.
- * cgi_initialize_cookies() - Initialize cookies.
- * cgi_initialize_get() - Initialize form variables using the GET
- * method.
- * cgi_initialize_multipart() - Initialize variables and file using the POST
- * method.
- * cgi_initialize_post() - Initialize variables using the POST method.
- * cgi_initialize_string() - Initialize form variables from a string.
- * cgi_passwd() - Catch authentication requests and notify the
- * server.
- * cgi_set_sid() - Set the CUPS session ID.
- * cgi_sort_variables() - Sort all form variables for faster lookup.
- * cgi_unlink_file() - Remove the uploaded form.
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
+ */
+
+/*
+ * Include necessary headers...
*/
/*#define DEBUG*/
const char **temp; /* Temporary pointer */
temp = (const char **)realloc((void *)(var->values),
- sizeof(char *) * (element + 16));
+ sizeof(char *) * (size_t)(element + 16));
if (!temp)
return;
const char **temp; /* Temporary pointer */
temp = (const char **)realloc((void *)(var->values),
- sizeof(char *) * (size + 16));
+ sizeof(char *) * (size_t)(size + 16));
if (!temp)
return;
if (form_alloc == 0)
temp_vars = malloc(sizeof(_cgi_var_t) * 16);
else
- temp_vars = realloc(form_vars, (form_alloc + 16) * sizeof(_cgi_var_t));
+ temp_vars = realloc(form_vars, (size_t)(form_alloc + 16) * sizeof(_cgi_var_t));
if (!temp_vars)
return;
var = form_vars + form_count;
- if ((var->values = calloc(element + 1, sizeof(char *))) == NULL)
+ if ((var->values = calloc((size_t)element + 1, sizeof(char *))) == NULL)
return;
var->name = _cupsStrAlloc(name);
key.name = name;
- return ((_cgi_var_t *)bsearch(&key, form_vars, form_count, sizeof(_cgi_var_t),
+ return ((_cgi_var_t *)bsearch(&key, form_vars, (size_t)form_count, sizeof(_cgi_var_t),
(int (*)(const void *, const void *))cgi_compare_variables));
}
*ptr, /* Pointer into name/filename */
*end; /* End of buffer */
int ch, /* Character from file */
- fd, /* Temporary file descriptor */
- blen; /* Length of boundary string */
+ fd; /* Temporary file descriptor */
+ size_t blen; /* Length of boundary string */
DEBUG_printf(("cgi_initialize_multipart(boundary=\"%s\")\n", boundary));
while ((ch = getchar()) != EOF)
{
- *ptr++ = ch;
+ *ptr++ = (char)ch;
- if ((ptr - line) >= blen && !memcmp(ptr - blen, bstring, blen))
+ if ((size_t)(ptr - line) >= blen && !memcmp(ptr - blen, bstring, blen))
{
ptr -= blen;
break;
}
- if ((ptr - line - blen) >= 8192)
+ if ((ptr - line - (int)blen) >= 8192)
{
/*
* Write out the first 8k of the buffer...
*/
if (ptr > line)
- write(fd, line, ptr - line);
+ write(fd, line, (size_t)(ptr - line));
close(fd);
}
while ((ch = getchar()) != EOF)
{
if (ptr < end)
- *ptr++ = ch;
+ *ptr++ = (char)ch;
- if ((ptr - line) >= blen && !memcmp(ptr - blen, bstring, blen))
+ if ((size_t)(ptr - line) >= blen && !memcmp(ptr - blen, bstring, blen))
{
ptr -= blen;
break;
static int /* O - 1 if form data was read */
cgi_initialize_post(void)
{
- char *content_length, /* Length of input data (string) */
- *data; /* Pointer to form data string */
- int length, /* Length of input data */
- nbytes, /* Number of bytes read this read() */
- tbytes, /* Total number of bytes read */
- status; /* Return status */
+ char *content_length, /* Length of input data (string) */
+ *data; /* Pointer to form data string */
+ size_t length, /* Length of input data */
+ tbytes; /* Total number of bytes read */
+ ssize_t nbytes; /* Number of bytes read this read() */
+ int status; /* Return status */
DEBUG_puts("cgi_initialize_post: Initializing variables using POST method...");
* Get the length of the input stream and allocate a buffer for it...
*/
- length = atoi(content_length);
+ length = (size_t)strtol(content_length, NULL, 10);
data = malloc(length + 1);
if (data == NULL)
* Read the data into the buffer...
*/
- for (tbytes = 0; tbytes < length; tbytes += nbytes)
- if ((nbytes = read(0, data + tbytes, length - tbytes)) < 0)
+ for (tbytes = 0; tbytes < length; tbytes += (size_t)nbytes)
+ if ((nbytes = read(0, data + tbytes, (size_t)(length - tbytes))) < 0)
{
if (errno != EAGAIN)
{
ch = *data - '0';
if (ch > 9)
ch -= 7;
- *s = ch << 4;
+ *s = (char)(ch << 4);
data ++;
ch = *data - '0';
if (form_count < 2)
return;
- qsort(form_vars, form_count, sizeof(_cgi_var_t),
+ qsort(form_vars, (size_t)form_count, sizeof(_cgi_var_t),
(int (*)(const void *, const void *))cgi_compare_variables);
#ifdef DEBUG
+++ /dev/null
-/*
- * "$Id$"
- *
- * Web search program for www.cups.org.
- *
- * Copyright 2007-2009 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products.
- *
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
- *
- * Usage:
- *
- * websearch directory "search string"
- *
- * Contents:
- *
- * main() - Search a directory of help files.
- * list_nodes() - List matching nodes.
- */
-
-/*
- * Include necessary headers...
- */
-
-#include "cgi.h"
-
-
-/*
- * Local functions...
- */
-
-static void list_nodes(help_index_t *hi, const char *title,
- cups_array_t *nodes);
-
-
-/*
- * 'main()' - Test the help index code.
- */
-
-int /* O - Exit status */
-main(int argc, /* I - Number of command-line args */
- char *argv[]) /* I - Command-line arguments */
-{
- help_index_t *hi, /* Help index */
- *search; /* Search index */
- char indexname[1024]; /* Name of index file */
-
-
- if (argc != 3)
- {
- puts("Usage: websearch directory \"search terms\"");
- return (1);
- }
-
- /*
- * Load the help index...
- */
-
- snprintf(indexname, sizeof(indexname), "%s/.index", argv[1]);
- hi = helpLoadIndex(indexname, argv[1]);
-
- /*
- * Do any searches...
- */
-
- search = helpSearchIndex(hi, argv[2], NULL, NULL);
-
- if (search)
- list_nodes(hi, argv[1], search->sorted);
-
- /*
- * Return with no errors...
- */
-
- return (0);
-}
-
-
-/*
- * 'list_nodes()' - List nodes in an array...
- */
-
-static void
-list_nodes(help_index_t *hi, /* I - Help index */
- const char *title, /* I - Title string */
- cups_array_t *nodes) /* I - Nodes */
-{
- help_node_t *node, /* Current node */
- *file; /* File node */
-
-
- printf("%d\n", cupsArrayCount(nodes));
- for (node = (help_node_t *)cupsArrayFirst(nodes);
- node;
- node = (help_node_t *)cupsArrayNext(nodes))
- {
- if (node->anchor)
- {
- file = helpFindNode(hi, node->filename, NULL);
- printf("%d|%s#%s|%s|%s\n", node->score, node->filename, node->anchor,
- node->text, file ? file->text : node->filename);
- }
- else
- printf("%d|%s|%s|%s\n", node->score, node->filename, node->text,
- node->text);
- }
-}
-
-
-/*
- * End of "$Id$".
- */
if test "x$with_optim" = x; then
# Add useful warning options for tracking down problems...
- OPTIM="-Wall -Wno-format-y2k -Wunused $OPTIM"
+ OPTIM="-Wall -Wno-format-y2k -Wsign-conversion -Wunused $OPTIM"
+
+ AC_MSG_CHECKING(if GCC supports -Wno-tautological-compare)
+ OLDCFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -Werror -Wno-tautological-compare"
+ AC_TRY_COMPILE(,,
+ [OPTIM="$OPTIM -Wno-tautological-compare"
+ AC_MSG_RESULT(yes)],
+ AC_MSG_RESULT(no))
+ CFLAGS="$OLDCFLAGS"
# Additional warning options for development testing...
if test -d .svn; then
- OPTIM="-Wshadow -Werror $OPTIM"
- else
- AC_MSG_CHECKING(if GCC supports -Wno-tautological-compare)
- OLDCFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS -Werror -Wno-tautological-compare"
- AC_TRY_COMPILE(,,
- [OPTIM="$OPTIM -Wno-tautological-compare"
- AC_MSG_RESULT(yes)],
- AC_MSG_RESULT(no))
- CFLAGS="$OLDCFLAGS"
+ OPTIM="-Werror $OPTIM"
fi
fi
/*
* "$Id$"
*
- * Administration utility API definitions for CUPS.
+ * Administration utility API definitions for CUPS.
*
- * Copyright 2007-2013 by Apple Inc.
- * Copyright 2001-2007 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 2001-2007 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * cupsAdminCreateWindowsPPD() - Create the Windows PPD file for a printer.
- * cupsAdminExportSamba() - Export a printer to Samba.
- * cupsAdminGetServerSettings() - Get settings from the server.
- * cupsAdminSetServerSettings() - Set settings on the server.
- * do_samba_command() - Do a SAMBA command.
- * get_cupsd_conf() - Get the current cupsd.conf file.
- * invalidate_cupsd_cache() - Invalidate the cached cupsd.conf settings.
- * write_option() - Write a CUPS option to a PPD file.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
}
}
- snprintf(ptr + 1, sizeof(line) - (ptr - line + 1),
+ snprintf(ptr + 1, sizeof(line) - (size_t)(ptr - line + 1),
"%%cupsJobTicket: %s=%s\n\"\n*End", option, choice);
cupsFilePrintf(dstfp, "*%% Changed for CUPS Windows Driver...\n%s\n",
/*
* "$Id$"
*
- * Sorted array routines for CUPS.
+ * Sorted array routines for CUPS.
*
- * Copyright 2007-2012 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2007 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * cupsArrayAdd() - Add an element to the array.
- * _cupsArrayAddStrings() - Add zero or more comma-delimited strings to an
- * array.
- * cupsArrayClear() - Clear the array.
- * cupsArrayCount() - Get the number of elements in the array.
- * cupsArrayCurrent() - Return the current element in the array.
- * cupsArrayDelete() - Free all memory used by the array.
- * cupsArrayDup() - Duplicate the array.
- * cupsArrayFind() - Find an element in the array.
- * cupsArrayFirst() - Get the first element in the array.
- * cupsArrayGetIndex() - Get the index of the current element.
- * cupsArrayGetInsert() - Get the index of the last inserted element.
- * cupsArrayIndex() - Get the N-th element in the array.
- * cupsArrayInsert() - Insert an element in the array.
- * cupsArrayLast() - Get the last element in the array.
- * cupsArrayNew() - Create a new array.
- * cupsArrayNew2() - Create a new array with hash.
- * cupsArrayNew3() - Create a new array with hash and/or free function.
- * _cupsArrayNewStrings() - Create a new array of comma-delimited strings.
- * cupsArrayNext() - Get the next element in the array.
- * cupsArrayPrev() - Get the previous element in the array.
- * cupsArrayRemove() - Remove an element from the array.
- * cupsArrayRestore() - Reset the current element to the last @link
- * cupsArraySave@.
- * cupsArraySave() - Mark the current element for a later @link
- * cupsArrayRestore@.
- * cupsArrayUserData() - Return the user data for an array.
- * cups_array_add() - Insert or append an element to the array.
- * cups_array_find() - Find an element in the array.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
* Allocate memory for the elements...
*/
- da->elements = malloc(a->num_elements * sizeof(void *));
+ da->elements = malloc((size_t)a->num_elements * sizeof(void *));
if (!da->elements)
{
free(da);
* Just copy raw pointers...
*/
- memcpy(da->elements, a->elements, a->num_elements * sizeof(void *));
+ memcpy(da->elements, a->elements, (size_t)a->num_elements * sizeof(void *));
}
da->num_elements = a->num_elements;
{
a->hashfunc = h;
a->hashsize = hsize;
- a->hash = malloc(hsize * sizeof(int));
+ a->hash = malloc((size_t)hsize * sizeof(int));
if (!a->hash)
{
return (NULL);
}
- memset(a->hash, -1, hsize * sizeof(int));
+ memset(a->hash, -1, (size_t)hsize * sizeof(int));
}
a->copyfunc = cf;
cupsArrayRemove(cups_array_t *a, /* I - Array */
void *e) /* I - Element */
{
- int i, /* Looping var */
- current, /* Current element */
- diff; /* Difference */
+ ssize_t i, /* Looping var */
+ current; /* Current element */
+ int diff; /* Difference */
/*
if (current < a->num_elements)
memmove(a->elements + current, a->elements + current + 1,
- (a->num_elements - current) * sizeof(void *));
+ (size_t)(a->num_elements - current) * sizeof(void *));
if (current <= a->current)
a->current --;
void *e, /* I - Element to add */
int insert) /* I - 1 = insert, 0 = append */
{
- int i, /* Looping var */
- current, /* Current element */
- diff; /* Comparison with current element */
+ int i, /* Looping var */
+ current; /* Current element */
+ int diff; /* Comparison with current element */
DEBUG_printf(("7cups_array_add(a=%p, e=%p, insert=%d)", a, e, insert));
if (a->alloc_elements == 0)
{
count = 16;
- temp = malloc(count * sizeof(void *));
+ temp = malloc((size_t)count * sizeof(void *));
}
else
{
else
count = a->alloc_elements + 1024;
- temp = realloc(a->elements, count * sizeof(void *));
+ temp = realloc(a->elements, (size_t)count * sizeof(void *));
}
- DEBUG_printf(("9cups_array_add: count=%d", count));
+ DEBUG_printf(("9cups_array_add: count=" CUPS_LLFMT, CUPS_LLCAST count));
if (!temp)
{
*/
memmove(a->elements + current + 1, a->elements + current,
- (a->num_elements - current) * sizeof(void *));
+ (size_t)(a->num_elements - current) * sizeof(void *));
if (a->current >= current)
a->current ++;
if (a->saved[i] >= current)
a->saved[i] ++;
- DEBUG_printf(("9cups_array_add: insert element at index %d...", current));
+ DEBUG_printf(("9cups_array_add: insert element at index " CUPS_LLFMT, CUPS_LLCAST current));
}
#ifdef DEBUG
else
- DEBUG_printf(("9cups_array_add: append element at %d...", current));
+ DEBUG_printf(("9cups_array_add: append element at " CUPS_LLFMT, CUPS_LLCAST current));
#endif /* DEBUG */
if (a->copyfunc)
#ifdef DEBUG
for (current = 0; current < a->num_elements; current ++)
- DEBUG_printf(("9cups_array_add: a->elements[%d]=%p", current,
- a->elements[current]));
+ DEBUG_printf(("9cups_array_add: a->elements[" CUPS_LLFMT "]=%p", CUPS_LLCAST current, a->elements[current]));
#endif /* DEBUG */
DEBUG_puts("9cups_array_add: returning 1");
/*
* "$Id$"
*
- * Authentication functions for CUPS.
+ * Authentication functions for CUPS.
*
- * Copyright 2007-2013 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2007 by Easy Software Products.
*
- * This file contains Kerberos support code, copyright 2006 by
- * Jelmer Vernooij.
+ * This file contains Kerberos support code, copyright 2006 by
+ * Jelmer Vernooij.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * cupsDoAuthentication() - Authenticate a request.
- * _cupsSetNegotiateAuthString() - Set the Kerberos authentication string.
- * cups_gss_acquire() - Kerberos credentials callback.
- * cups_gss_getname() - Get CUPS service credentials for
- * authentication.
- * cups_gss_printf() - Show debug error messages from GSSAPI.
- * cups_local_auth() - Get the local authorization certificate if
- * available/applicable.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
* arbitrarily large credentials...
*/
- int authsize = 10 + /* "Negotiate " */
- output_token.length * 4 / 3 + 1 + /* Base64 */
- 1; /* nul */
+ int authsize = 10 + /* "Negotiate " */
+ (int)output_token.length * 4 / 3 + 1 + 1;
+ /* Base64 + nul */
httpSetAuthString(http, NULL, NULL);
- if ((http->authstring = malloc(authsize)) == NULL)
+ if ((http->authstring = malloc((size_t)authsize)) == NULL)
{
http->authstring = http->_authstring;
authsize = sizeof(http->_authstring);
strlcpy(http->authstring, "Negotiate ", authsize);
httpEncode64_2(http->authstring + 10, authsize - 10, output_token.value,
- output_token.length);
+ (int)output_token.length);
gss_release_buffer(&minor_status, &output_token);
}
/*
* "$Id$"
*
- * Backchannel functions for CUPS.
+ * Backchannel functions for CUPS.
*
- * Copyright 2007-2012 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2007 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * cupsBackChannelRead() - Read data from the backchannel.
- * cupsBackChannelWrite() - Write data to the backchannel.
- * cups_setup() - Setup select()
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
*/
buffer += count;
- total += count;
+ total += (size_t)count;
}
}
/*
* "$Id$"
*
- * Option marking routines for CUPS.
+ * Option marking routines for CUPS.
*
- * Copyright 2007-2012 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products, all rights reserved.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * PostScript is a trademark of Adobe Systems, Inc.
+ * PostScript is a trademark of Adobe Systems, Inc.
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * cupsGetConflicts() - Get a list of conflicting options in a marked
- * PPD.
- * cupsResolveConflicts() - Resolve conflicts in a marked PPD.
- * ppdConflicts() - Check to see if there are any conflicts among
- * the marked option choices.
- * ppdInstallableConflict() - Test whether an option choice conflicts with an
- * installable option.
- * ppd_is_installable() - Determine whether an option is in the
- * InstallableOptions group.
- * ppd_load_constraints() - Load constraints from a PPD file.
- * ppd_test_constraints() - See if any constraints are active.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
tries, /* Number of tries */
num_newopts; /* Number of new options */
cups_option_t *newopts; /* New options */
- cups_array_t *active, /* Active constraints */
+ cups_array_t *active = NULL, /* Active constraints */
*pass, /* Resolvers for this pass */
*resolvers, /* Resolvers we have used */
*test; /* Test array for conflicts */
return;
}
- if ((constptr = calloc(i, sizeof(_ppd_cups_uiconst_t))) == NULL)
+ if ((constptr = calloc((size_t)i, sizeof(_ppd_cups_uiconst_t))) == NULL)
{
free(consts);
DEBUG_puts("8ppd_load_constraints: Unable to allocate memory for "
/*
* "$Id$"
*
- * Debugging functions for CUPS.
+ * Debugging functions for CUPS.
*
- * Copyright 2008-2012 by Apple Inc.
+ * Copyright 2008-2014 by Apple Inc.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * debug_vsnprintf() - Format a string into a fixed size buffer.
- * _cups_debug_printf() - Write a formatted line to the log.
- * _cups_debug_puts() - Write a single line to the log.
- * _cups_debug_set() - Enable or disable debug logging.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
* 'debug_vsnprintf()' - Format a string into a fixed size buffer.
*/
-static int /* O - Number of bytes formatted */
+static ssize_t /* O - Number of bytes formatted */
debug_vsnprintf(char *buffer, /* O - Output buffer */
size_t bufsize, /* O - Size of output buffer */
const char *format, /* I - printf-style format string */
*tptr, /* Pointer into temporary format */
temp[1024]; /* Buffer for formatted numbers */
char *s; /* Pointer to string */
- int bytes; /* Total number of bytes needed */
+ ssize_t bytes; /* Total number of bytes needed */
if (!buffer || bufsize < 2 || !format)
format ++;
width = va_arg(ap, int);
- snprintf(tptr, sizeof(tformat) - (tptr - tformat), "%d", width);
+ snprintf(tptr, sizeof(tformat) - (size_t)(tptr - tformat), "%d", width);
tptr += strlen(tptr);
}
else
format ++;
prec = va_arg(ap, int);
- snprintf(tptr, sizeof(tformat) - (tptr - tformat), "%d", prec);
+ snprintf(tptr, sizeof(tformat) - (size_t)(tptr - tformat), "%d", prec);
tptr += strlen(tptr);
}
else
case 'e' :
case 'f' :
case 'g' :
- if ((width + 2) > sizeof(temp))
+ if ((size_t)(width + 2) > sizeof(temp))
break;
sprintf(temp, tformat, va_arg(ap, double));
case 'o' :
case 'u' :
case 'x' :
- if ((width + 2) > sizeof(temp))
+ if ((size_t)(width + 2) > sizeof(temp))
break;
# ifdef HAVE_LONG_LONG
break;
case 'p' : /* Pointer value */
- if ((width + 2) > sizeof(temp))
+ if ((size_t)(width + 2) > sizeof(temp))
break;
sprintf(temp, tformat, va_arg(ap, void *));
if (bufptr)
{
if (width <= 1)
- *bufptr++ = va_arg(ap, int);
+ *bufptr++ = (char)va_arg(ap, int);
else
{
if ((bufptr + width) > bufend)
break;
case 'n' : /* Output number of chars so far */
- *(va_arg(ap, int *)) = bytes;
+ *(va_arg(ap, int *)) = (int)bytes;
break;
}
}
va_list ap; /* Pointer to arguments */
struct timeval curtime; /* Current time */
char buffer[2048]; /* Output buffer */
- size_t bytes; /* Number of bytes in buffer */
+ ssize_t bytes; /* Number of bytes in buffer */
int level; /* Log level in message */
bytes = debug_vsnprintf(buffer + 19, sizeof(buffer) - 20, format, ap) + 19;
va_end(ap);
- if (bytes >= (sizeof(buffer) - 1))
+ if ((size_t)bytes >= (sizeof(buffer) - 1))
{
buffer[sizeof(buffer) - 2] = '\n';
bytes = sizeof(buffer) - 1;
*/
_cupsMutexLock(&debug_log_mutex);
- write(_cups_debug_fd, buffer, bytes);
+ write(_cups_debug_fd, buffer, (size_t)bytes);
_cupsMutexUnlock(&debug_log_mutex);
}
{
struct timeval curtime; /* Current time */
char buffer[2048]; /* Output buffer */
- size_t bytes; /* Number of bytes in buffer */
+ ssize_t bytes; /* Number of bytes in buffer */
int level; /* Log level in message */
(int)(curtime.tv_sec % 60), (int)(curtime.tv_usec / 1000),
s);
- if (bytes >= (sizeof(buffer) - 1))
+ if ((size_t)bytes >= (sizeof(buffer) - 1))
{
buffer[sizeof(buffer) - 2] = '\n';
bytes = sizeof(buffer) - 1;
*/
_cupsMutexLock(&debug_log_mutex);
- write(_cups_debug_fd, buffer, bytes);
+ write(_cups_debug_fd, buffer, (size_t)bytes);
_cupsMutexUnlock(&debug_log_mutex);
}
/*
* "$Id$"
*
- * Destination job support for CUPS.
+ * Destination job support for CUPS.
*
- * Copyright 2012-2013 by Apple Inc.
+ * Copyright 2012-2014 by Apple Inc.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * cupsCancelDestJob() - Cancel a job on a destination.
- * cupsCloseDestJob() - Close a job and start printing.
- * cupsCreateDestJob() - Create a job on a destination.
- * cupsFinishDestDocument() - Finish the current document.
- * cupsStartDestDocument() - Start a new document.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
cups_dest_t *dest, /* I - Destination */
int job_id) /* I - Job ID */
{
+ /* TODO: Needs to be implemented! */
+ /* Probably also needs to be revved to accept cups_dinfo_t... */
+ (void)http;
+ (void)dest;
+ (void)job_id;
+
return (IPP_STATUS_ERROR_NOT_FOUND);
}
if (format)
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_MIMETYPE,
"document-format", NULL, format);
- ippAddBoolean(request, IPP_TAG_OPERATION, "last-document", last_document);
+ ippAddBoolean(request, IPP_TAG_OPERATION, "last-document", (char)last_document);
cupsEncodeOptions2(request, num_options, options, IPP_TAG_OPERATION);
cupsEncodeOptions2(request, num_options, options, IPP_TAG_DOCUMENT);
/*
* "$Id$"
*
- * Destination localization support for CUPS.
+ * Destination localization support for CUPS.
*
- * Copyright 2012-2013 by Apple Inc.
+ * Copyright 2012-2014 by Apple Inc.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * cupsLocalizeDestOption() - Get the localized string for a destination
- * option.
- * cupsLocalizeDestValue() - Get the localized string for a destination
- * option+value pair.
- * cups_create_localizations() - Create the localizations array for a
- * destination.
- * cups_read_strings() - Read a pair of strings from a .strings file.
- * cups_scan_strings() - Scan a quoted string.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
* Decode \nnn octal escape...
*/
- *bufptr = ((((bufptr[1] - '0') << 3) | (bufptr[2] - '0')) << 3) |
- (bufptr[3] - '0');
+ *bufptr = (char)(((((bufptr[1] - '0') << 3) | (bufptr[2] - '0')) << 3) | (bufptr[3] - '0'));
_cups_strcpy(bufptr + 1, bufptr + 4);
}
else
/*
* "$Id$"
*
- * Destination option/media support for CUPS.
+ * Destination option/media support for CUPS.
*
- * Copyright 2012-2013 by Apple Inc.
+ * Copyright 2012-2014 by Apple Inc.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * cupsCheckDestSupported() - Check that the option and value are supported
- * by the destination.
- * cupsCopyDestConflicts() - Get conflicts and resolutions for a new
- * option/value pair.
- * cupsCopyDestInfo() - Get the supported values/capabilities for the
- * destination.
- * cupsFindDestDefault() - Find the default value(s) for the given
- * option.
- * cupsFindDestReady() - Find the default value(s) for the given
- * option.
- * cupsFindDestSupported() - Find the default value(s) for the given
- * option.
- * cupsFreeDestInfo() - Free destination information obtained using
- * @link cupsCopyDestInfo@.
- * cupsGetDestMediaByIndex() - Get a media name, dimension, and margins for a
- * specific size.
- * cupsGetDestMediaByName() - Get media names, dimensions, and margins.
- * cupsGetDestMediaBySize() - Get media names, dimensions, and margins.
- * cupsGetDestMediaCount() - Get the number of sizes supported by a
- * destination.
- * cupsGetDestMediaDefault() - Get the default size for a destination.
- * cups_add_dconstres() - Add a constraint or resolver to an array.
- * cups_compare_dconstres() - Compare to resolver entries.
- * cups_compare_media_db() - Compare two media entries.
- * cups_copy_media_db() - Copy a media entry.
- * cups_create_cached() - Create the media selection cache.
- * cups_create_constraints() - Create the constraints and resolvers arrays.
- * cups_create_defaults() - Create the -default option array.
- * cups_create_media_db() - Create the media database.
- * cups_free_media_cb() - Free a media entry.
- * cups_get_media_db() - Lookup the media entry for a given size.
- * cups_is_close_media_db() - Compare two media entries to see if they are
- * close to the same size.
- * cups_test_constraints() - Test constraints.
- * cups_update_ready() - Update xxx-ready attributes for the printer.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
*myres = NULL, /* My resolved options */
*myoption, /* My current option */
*option; /* Current option */
- cups_array_t *active, /* Active conflicts */
+ cups_array_t *active = NULL, /* Active conflicts */
*pass = NULL, /* Resolvers for this pass */
*resolvers = NULL, /* Resolvers we have used */
*test; /* Test array for conflicts */
version = 11;
else if (status == IPP_STATUS_ERROR_BUSY)
{
- sleep(delay);
+ sleep((unsigned)delay);
delay = _cupsNextDelay(delay, &prev_delay);
}
* Fall back to the first matching media size...
*/
- return (cupsGetDestMediaByIndex(http, dest, dinfo, flags, 0, size));
+ return (cupsGetDestMediaByIndex(http, dest, dinfo, 0, flags, size));
}
dinfo->uri);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name",
NULL, cupsUser());
- ippAddStrings(request, IPP_TAG_OPERATION,
- IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST, "requested-attributes",
- (int)(sizeof(pattrs) / sizeof(pattrs[0])), NULL, pattrs);
+ ippAddStrings(request, IPP_TAG_OPERATION, IPP_CONST_TAG(IPP_TAG_KEYWORD), "requested-attributes", (int)(sizeof(pattrs) / sizeof(pattrs[0])), NULL, pattrs);
dinfo->ready_attrs = cupsDoRequest(http, request, dinfo->resource);
/*
* "$Id$"
*
- * User-defined destination (and option) support for CUPS.
+ * User-defined destination (and option) support for CUPS.
*
- * Copyright 2007-2013 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2007 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * cupsAddDest() - Add a destination to the list of
- * destinations.
- * _cupsAppleCopyDefaultPaperID() - Get the default paper ID.
- * _cupsAppleCopyDefaultPrinter() - Get the default printer at this location.
- * _cupsAppleGetUseLastPrinter() - Get whether to use the last used printer.
- * _cupsAppleSetDefaultPaperID() - Set the default paper id.
- * _cupsAppleSetDefaultPrinter() - Set the default printer for this
- * location.
- * _cupsAppleSetUseLastPrinter() - Set whether to use the last used printer.
- * cupsConnectDest() - Connect to the server for a destination.
- * cupsConnectDestBlock() - Connect to the server for a destination.
- * cupsCopyDest() - Copy a destination.
- * cupsEnumDests() - Enumerate available destinations with a
- * callback function.
- * cupsEnumDestsBlock() - Enumerate available destinations with a
- * block.
- * cupsFreeDests() - Free the memory used by the list of
- * destinations.
- * cupsGetDest() - Get the named destination from the list.
- * _cupsGetDestResource() - Get the resource path and URI for a
- * destination.
- * _cupsGetDests() - Get destinations from a server.
- * cupsGetDests() - Get the list of destinations from the
- * default server.
- * cupsGetDests2() - Get the list of destinations from the
- * specified server.
- * cupsGetNamedDest() - Get options for the named destination.
- * cupsRemoveDest() - Remove a destination from the destination
- * list.
- * cupsSetDefaultDest() - Set the default destination.
- * cupsSetDests() - Save the list of destinations for the
- * default server.
- * cupsSetDests2() - Save the list of destinations for the
- * specified server.
- * _cupsUserDefault() - Get the user default printer from
- * environment variables and location
- * information.
- * appleCopyLocations() - Copy the location history array.
- * appleCopyNetwork() - Get the network ID for the current
- * location.
- * appleGetPaperSize() - Get the default paper size.
- * appleGetPrinter() - Get a printer from the history array.
- * cups_add_dest() - Add a destination to the array.
- * cups_block_cb() - Enumeration callback for block API.
- * cups_compare_dests() - Compare two destinations.
- * cups_dnssd_browse_cb() - Browse for printers.
- * cups_dnssd_browse_cb() - Browse for printers.
- * cups_dnssd_client_cb() - Avahi client callback function.
- * cups_dnssd_compare_device() - Compare two devices.
- * cups_dnssd_free_device() - Free the memory used by a device.
- * cups_dnssd_get_device() - Lookup a device and create it as needed.
- * cups_dnssd_local_cb() - Browse for local printers.
- * cups_dnssd_poll_cb() - Wait for input on the specified file
- * descriptors.
- * cups_dnssd_query_cb() - Process query data.
- * cups_dnssd_resolve() - Resolve a Bonjour printer URI.
- * cups_dnssd_resolve_cb() - See if we should continue resolving.
- * cups_dnssd_unquote() - Unquote a name string.
- * cups_find_dest() - Find a destination using a binary search.
- * cups_get_default() - Get the default destination from an
- * lpoptions file.
- * cups_get_dests() - Get destinations from a file.
- * cups_make_string() - Make a comma-separated string of values
- * from an IPP attribute.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
* Copy options from parent...
*/
- dest->options = calloc(sizeof(cups_option_t), parent->num_options);
+ dest->options = calloc(sizeof(cups_option_t), (size_t)parent->num_options);
if (dest->options)
{
if (httpSeparateURI(HTTP_URI_CODING_ALL, uri, scheme, sizeof(scheme),
userpass, sizeof(userpass), hostname, sizeof(hostname),
- &port, resource, resourcesize) < HTTP_URI_STATUS_OK)
+ &port, resource, (int)resourcesize) < HTTP_URI_STATUS_OK)
{
_cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Bad printer URI."), 1);
if (new_dest)
{
- if ((new_dest->options = calloc(sizeof(cups_option_t),
- dest->num_options)) == NULL)
+ if ((new_dest->options = calloc(sizeof(cups_option_t), (size_t)dest->num_options)) == NULL)
return (cupsRemoveDest(dest->name, dest->instance, num_dests, dests));
new_dest->num_options = dest->num_options;
if (httpSeparateURI(HTTP_URI_CODING_ALL, uri, scheme, sizeof(scheme),
userpass, sizeof(userpass), hostname, sizeof(hostname),
- &port, resource, resourcesize) < HTTP_URI_STATUS_OK)
+ &port, resource, (int)resourcesize) < HTTP_URI_STATUS_OK)
{
_cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Bad printer URI."), 1);
}
else if (mask)
{
- ippAddInteger(request, IPP_TAG_OPERATION, IPP_TAG_ENUM, "printer-type",
- type);
- ippAddInteger(request, IPP_TAG_OPERATION, IPP_TAG_ENUM, "printer-type-mask",
- mask);
+ ippAddInteger(request, IPP_TAG_OPERATION, IPP_TAG_ENUM, "printer-type", (int)type);
+ ippAddInteger(request, IPP_TAG_OPERATION, IPP_TAG_ENUM, "printer-type-mask", (int)mask);
}
/*
if (num_dests > 0)
{
num_reals = num_dests;
- reals = calloc(num_reals, sizeof(cups_dest_t));
+ reals = calloc((size_t)num_reals, sizeof(cups_dest_t));
if (reals)
- memcpy(reals, *dests, num_reals * sizeof(cups_dest_t));
+ memcpy(reals, *dests, (size_t)num_reals * sizeof(cups_dest_t));
else
num_reals = 0;
}
num_dests --;
- i = dest - *dests;
+ i = (int)(dest - *dests);
if (i < num_dests)
- memmove(dest, dest + 1, (num_dests - i) * sizeof(cups_dest_t));
+ memmove(dest, dest + 1, (size_t)(num_dests - i) * sizeof(cups_dest_t));
return (num_dests);
}
if ((locprinter = _cupsAppleCopyDefaultPrinter()) != NULL)
{
- CFStringGetCString(locprinter, name, namesize, kCFStringEncodingUTF8);
+ CFStringGetCString(locprinter, name, (CFIndex)namesize, kCFStringEncodingUTF8);
CFRelease(locprinter);
}
else
if (*num_dests == 0)
dest = malloc(sizeof(cups_dest_t));
else
- dest = realloc(*dests, sizeof(cups_dest_t) * (*num_dests + 1));
+ dest = realloc(*dests, sizeof(cups_dest_t) * (size_t)(*num_dests + 1));
if (!dest)
return (NULL);
*/
if (insert < *num_dests)
- memmove(*dests + insert + 1, *dests + insert,
- (*num_dests - insert) * sizeof(cups_dest_t));
+ memmove(*dests + insert + 1, *dests + insert, (size_t)(*num_dests - insert) * sizeof(cups_dest_t));
(*num_dests) ++;
txtnext = txt + txtlen;
for (ptr = key; txt < txtnext && *txt != '='; txt ++)
- *ptr++ = *txt;
+ *ptr++ = (char)*txt;
*ptr = '\0';
if (txt < txtnext && *txt == '=')
*/
saw_printer_type = 1;
- type = strtol(value, NULL, 0);
+ type = (cups_ptype_t)strtol(value, NULL, 0);
}
else if (!saw_printer_type)
{
/*
* "$Id$"
*
- * PPD code emission routines for CUPS.
+ * PPD code emission routines for CUPS.
*
- * Copyright 2007-2012 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products, all rights reserved.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * PostScript is a trademark of Adobe Systems, Inc.
+ * PostScript is a trademark of Adobe Systems, Inc.
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * ppdCollect() - Collect all marked options that reside in the
- * specified section.
- * ppdCollect2() - Collect all marked options that reside in the
- * specified section and minimum order.
- * ppdEmit() - Emit code for marked options to a file.
- * ppdEmitAfterOrder() - Emit a subset of the code for marked options to a
- * file.
- * ppdEmitFd() - Emit code for marked options to a file.
- * ppdEmitJCL() - Emit code for JCL options to a file.
- * ppdEmitJCLEnd() - Emit JCLEnd code to a file.
- * ppdEmitString() - Get a string containing the code for marked
- * options.
- * ppd_compare_cparams() - Compare the order of two custom parameters.
- * ppd_handle_media() - Handle media selection...
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
count = 0;
if ((collect = calloc(sizeof(ppd_choice_t *),
- cupsArrayCount(ppd->marked))) == NULL)
+ (size_t)cupsArrayCount(ppd->marked))) == NULL)
{
*choices = NULL;
return (0);
}
- if ((orders = calloc(sizeof(float), cupsArrayCount(ppd->marked))) == NULL)
+ if ((orders = calloc(sizeof(float), (size_t)cupsArrayCount(ppd->marked))) == NULL)
{
*choices = NULL;
free(collect);
break;
}
- buflength -= bytes;
+ buflength -= (size_t)bytes;
bufptr += bytes;
}
/*
* "$Id$"
*
- * Option encoding routines for CUPS.
+ * Option encoding routines for CUPS.
*
- * Copyright 2007-2013 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2007 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * cupsEncodeOptions() - Encode printer options into IPP attributes.
- * cupsEncodeOptions2() - Encode printer options into IPP attributes for
- * a group.
- * _ippFindOption() - Find the attribute information for an option.
- * compare_ipp_options() - Compare two IPP options.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
* Integer/enumeration value...
*/
- attr->values[j].integer = strtol(val, &s, 10);
+ attr->values[j].integer = (int)strtol(val, &s, 10);
DEBUG_printf(("2cupsEncodeOptions2: Added integer option value "
"%d...", attr->values[j].integer));
s = val;
}
else
- attr->values[j].range.lower = strtol(val, &s, 10);
+ attr->values[j].range.lower = (int)strtol(val, &s, 10);
if (*s == '-')
{
if (s[1])
- attr->values[j].range.upper = strtol(s + 1, NULL, 10);
+ attr->values[j].range.upper = (int)strtol(s + 1, NULL, 10);
else
attr->values[j].range.upper = 2147483647;
}
* Resolution...
*/
- attr->values[j].resolution.xres = strtol(val, &s, 10);
+ attr->values[j].resolution.xres = (int)strtol(val, &s, 10);
if (*s == 'x')
- attr->values[j].resolution.yres = strtol(s + 1, &s, 10);
+ attr->values[j].resolution.yres = (int)strtol(s + 1, &s, 10);
else
attr->values[j].resolution.yres = attr->values[j].resolution.xres;
* our own file functions allows us to provide transparent support of
* gzip'd print files, PPD files, etc.
*
- * Copyright 2007-2013 by Apple Inc.
+ * Copyright 2007-2014 by Apple Inc.
* Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
switch (result)
{
- default :
case _CUPS_FILE_CHECK_OK :
prefix = "DEBUG2";
break;
if (fp->stream.next_out > fp->cbuf)
{
if (cups_write(fp, (char *)fp->cbuf,
- fp->stream.next_out - fp->cbuf) < 0)
+ (size_t)(fp->stream.next_out - fp->cbuf)) < 0)
status = -1;
fp->stream.next_out = fp->cbuf;
* Write the CRC and length...
*/
- trailer[0] = fp->crc;
- trailer[1] = fp->crc >> 8;
- trailer[2] = fp->crc >> 16;
- trailer[3] = fp->crc >> 24;
- trailer[4] = fp->pos;
- trailer[5] = fp->pos >> 8;
- trailer[6] = fp->pos >> 16;
- trailer[7] = fp->pos >> 24;
+ trailer[0] = (unsigned char)fp->crc;
+ trailer[1] = (unsigned char)(fp->crc >> 8);
+ trailer[2] = (unsigned char)(fp->crc >> 16);
+ trailer[3] = (unsigned char)(fp->crc >> 24);
+ trailer[4] = (unsigned char)fp->pos;
+ trailer[5] = (unsigned char)(fp->pos >> 8);
+ trailer[6] = (unsigned char)(fp->pos >> 16);
+ trailer[7] = (unsigned char)(fp->pos >> 24);
if (cups_write(fp, (char *)trailer, 8) < 0)
status = -1;
{
#ifdef HAVE_LIBZ
if (fp->compressed)
- bytes = cups_compress(fp, fp->buf, bytes);
+ bytes = cups_compress(fp, fp->buf, (size_t)bytes);
else
#endif /* HAVE_LIBZ */
- bytes = cups_write(fp, fp->buf, bytes);
+ bytes = cups_write(fp, fp->buf, (size_t)bytes);
if (bytes < 0)
return (-1);
DEBUG_printf(("4cupsFileGetLine: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos));
- return (ptr - buf);
+ return ((size_t)(ptr - buf));
}
break;
}
else
- *ptr++ = ch;
+ *ptr++ = (char)ch;
}
*ptr = '\0';
header[1] = 0x8b;
header[2] = Z_DEFLATED;
header[3] = 0;
- header[4] = curtime;
- header[5] = curtime >> 8;
- header[6] = curtime >> 16;
- header[7] = curtime >> 24;
+ header[4] = (unsigned char)curtime;
+ header[5] = (unsigned char)(curtime >> 8);
+ header[6] = (unsigned char)(curtime >> 16);
+ header[7] = (unsigned char)(curtime >> 24);
header[8] = 0;
header[9] = 0x03;
if (bytes > 65535)
return (-1);
- if ((temp = realloc(fp->printf_buffer, bytes + 1)) == NULL)
+ if ((temp = realloc(fp->printf_buffer, (size_t)(bytes + 1))) == NULL)
return (-1);
fp->printf_buffer = temp;
- fp->printf_size = bytes + 1;
+ fp->printf_size = (size_t)(bytes + 1);
va_start(ap, format);
bytes = vsnprintf(fp->printf_buffer, fp->printf_size, format, ap);
if (fp->mode == 's')
{
- if (cups_write(fp, fp->printf_buffer, bytes) < 0)
+ if (cups_write(fp, fp->printf_buffer, (size_t)bytes) < 0)
return (-1);
fp->pos += bytes;
DEBUG_printf(("4cupsFilePrintf: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos));
- return (bytes);
+ return ((int)bytes);
}
if ((fp->ptr + bytes) > fp->end)
DEBUG_printf(("4cupsFilePrintf: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos));
- if (bytes > sizeof(fp->buf))
+ if ((size_t)bytes > sizeof(fp->buf))
{
#ifdef HAVE_LIBZ
if (fp->compressed)
- return (cups_compress(fp, fp->printf_buffer, bytes));
+ return ((int)cups_compress(fp, fp->printf_buffer, (size_t)bytes));
else
#endif /* HAVE_LIBZ */
- return (cups_write(fp, fp->printf_buffer, bytes));
+ return ((int)cups_write(fp, fp->printf_buffer, (size_t)bytes));
}
else
{
memcpy(fp->ptr, fp->printf_buffer, bytes);
fp->ptr += bytes;
- return (bytes);
+ return ((int)bytes);
}
}
char ch; /* Output character */
- ch = c;
+ ch = (char)c;
if (send(fp->fd, &ch, 1, 0) < 1)
return (-1);
if (cupsFileFlush(fp))
return (-1);
- *(fp->ptr) ++ = c;
+ *(fp->ptr) ++ = (char)c;
}
fp->pos ++;
* Need to quote the first # in the info string...
*/
- if ((temp = cupsFileWrite(fp, value, ptr - value)) < 0)
+ if ((temp = cupsFileWrite(fp, value, (size_t)(ptr - value))) < 0)
return (-1);
bytes += temp;
* Write the string...
*/
- bytes = (int)strlen(s);
+ bytes = (ssize_t)strlen(s);
if (fp->mode == 's')
{
- if (cups_write(fp, s, bytes) < 0)
+ if (cups_write(fp, s, (size_t)bytes) < 0)
return (-1);
fp->pos += bytes;
DEBUG_printf(("4cupsFilePuts: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos));
- return (bytes);
+ return ((int)bytes);
}
if ((fp->ptr + bytes) > fp->end)
DEBUG_printf(("4cupsFilePuts: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos));
- if (bytes > sizeof(fp->buf))
+ if ((size_t)bytes > sizeof(fp->buf))
{
#ifdef HAVE_LIBZ
if (fp->compressed)
- return (cups_compress(fp, s, bytes));
+ return ((int)cups_compress(fp, s, (size_t)bytes));
else
#endif /* HAVE_LIBZ */
- return (cups_write(fp, s, bytes));
+ return ((int)cups_write(fp, s, (size_t)bytes));
}
else
{
memcpy(fp->ptr, s, bytes);
fp->ptr += bytes;
- return (bytes);
+ return ((int)bytes);
}
}
* Update the counts for the last read...
*/
- bytes -= count;
- total += count;
+ bytes -= (size_t)count;
+ total += (size_t)count;
buf += count;
}
* Update the CRC...
*/
- fp->crc = crc32(fp->crc, (const Bytef *)buf, bytes);
+ fp->crc = crc32(fp->crc, (const Bytef *)buf, (uInt)bytes);
/*
* Deflate the bytes...
*/
fp->stream.next_in = (Bytef *)buf;
- fp->stream.avail_in = bytes;
+ fp->stream.avail_in = (uInt)bytes;
while (fp->stream.avail_in > 0)
{
DEBUG_printf(("9cups_compress: avail_in=%d, avail_out=%d",
fp->stream.avail_in, fp->stream.avail_out));
- if (fp->stream.avail_out < (int)(sizeof(fp->cbuf) / 8))
+ if (fp->stream.avail_out < (uInt)(sizeof(fp->cbuf) / 8))
{
- if (cups_write(fp, (char *)fp->cbuf, fp->stream.next_out - fp->cbuf) < 0)
+ if (cups_write(fp, (char *)fp->cbuf, (size_t)(fp->stream.next_out - fp->cbuf)) < 0)
return (-1);
fp->stream.next_out = fp->cbuf;
deflate(&(fp->stream), Z_NO_FLUSH);
}
- return (bytes);
+ return ((ssize_t)bytes);
}
#endif /* HAVE_LIBZ */
fp->stream.opaque = (voidpf)0;
fp->stream.next_in = (Bytef *)fp->cbuf;
fp->stream.next_out = NULL;
- fp->stream.avail_in = bytes;
+ fp->stream.avail_in = (uInt)bytes;
fp->stream.avail_out = 0;
fp->crc = crc32(0L, Z_NULL, 0);
return (-1);
fp->stream.next_in = fp->cbuf;
- fp->stream.avail_in = bytes;
+ fp->stream.avail_in = (uInt)bytes;
}
/*
if (fp->stream.next_out > (Bytef *)fp->buf)
fp->crc = crc32(fp->crc, (Bytef *)fp->buf,
- fp->stream.next_out - (Bytef *)fp->buf);
+ (uInt)(fp->stream.next_out - (Bytef *)fp->buf));
if (status == Z_STREAM_END)
{
uLong tcrc; /* Trailer CRC */
- if (read(fp->fd, trailer, sizeof(trailer)) < sizeof(trailer))
+ if (read(fp->fd, trailer, sizeof(trailer)) < (ssize_t)sizeof(trailer))
{
/*
* Can't get it, so mark end-of-file...
}
}
- bytes = sizeof(fp->buf) - fp->stream.avail_out;
+ bytes = (ssize_t)sizeof(fp->buf) - (ssize_t)fp->stream.avail_out;
/*
* Return the decompressed data...
* Update the counts for the last write call...
*/
- bytes -= count;
- total += count;
+ bytes -= (size_t)count;
+ total += (size_t)count;
buf += count;
}
/*
* "$Id$"
*
- * Get/put file functions for CUPS.
+ * Get/put file functions for CUPS.
*
- * Copyright 2007-2013 by Apple Inc.
- * Copyright 1997-2006 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2006 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * cupsGetFd() - Get a file from the server.
- * cupsGetFile() - Get a file from the server.
- * cupsPutFd() - Put a file on the server.
- * cupsPutFile() - Put a file on the server.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
const char *resource, /* I - Resource name */
int fd) /* I - File descriptor */
{
- int bytes; /* Number of bytes read */
+ ssize_t bytes; /* Number of bytes read */
char buffer[8192]; /* Buffer for file */
http_status_t status; /* HTTP status from server */
char if_modified_since[HTTP_MAX_VALUE];
*/
while ((bytes = httpRead2(http, buffer, sizeof(buffer))) > 0)
- write(fd, buffer, bytes);
+ write(fd, buffer, (size_t)bytes);
}
else
{
const char *resource, /* I - Resource name */
int fd) /* I - File descriptor */
{
- int bytes, /* Number of bytes read */
- retries; /* Number of retries */
+ ssize_t bytes; /* Number of bytes read */
+ int retries; /* Number of retries */
char buffer[8192]; /* Buffer for file */
http_status_t status; /* HTTP status from server */
break;
}
else
- httpWrite2(http, buffer, bytes);
+ httpWrite2(http, buffer, (size_t)bytes);
}
if (status == HTTP_STATUS_CONTINUE)
*
* HTTP address routines for CUPS.
*
- * Copyright 2007-2013 by Apple Inc.
+ * Copyright 2007-2014 by Apple Inc.
* Copyright 1997-2006 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
#endif /* AF_INET6 */
#ifdef AF_LOCAL
if (addr->addr.sa_family == AF_LOCAL)
- return (offsetof(struct sockaddr_un, sun_path) +
- strlen(addr->un.sun_path) + 1);
+ return ((int)(offsetof(struct sockaddr_un, sun_path) + strlen(addr->un.sun_path) + 1));
else
#endif /* AF_LOCAL */
if (addr->addr.sa_family == AF_INET)
* Bind the domain socket...
*/
- status = bind(fd, (struct sockaddr *)addr, httpAddrLength(addr));
+ status = bind(fd, (struct sockaddr *)addr, (socklen_t)httpAddrLength(addr));
/*
* Restore the umask and fix permissions...
{
_httpAddrSetPort(addr, port);
- status = bind(fd, (struct sockaddr *)addr, httpAddrLength(addr));
+ status = bind(fd, (struct sockaddr *)addr, (socklen_t)httpAddrLength(addr));
}
if (status)
* do...
*/
- int error = getnameinfo(&addr->addr, httpAddrLength(addr), name, namelen,
- NULL, 0, 0);
+ int error = getnameinfo(&addr->addr, (socklen_t)httpAddrLength(addr), name, (socklen_t)namelen, NULL, 0, 0);
if (error)
{
temps[64]; /* Temporary string for address */
# ifdef HAVE_GETNAMEINFO
- if (getnameinfo(&addr->addr, httpAddrLength(addr), temps, sizeof(temps),
- NULL, 0, NI_NUMERICHOST))
+ if (getnameinfo(&addr->addr, (socklen_t)httpAddrLength(addr), temps, sizeof(temps), NULL, 0, NI_NUMERICHOST))
{
/*
* If we get an error back, then the address type is not supported
cg->hostent.h_name = (char *)name;
cg->hostent.h_aliases = NULL;
cg->hostent.h_addrtype = AF_LOCAL;
- cg->hostent.h_length = strlen(name) + 1;
+ cg->hostent.h_length = (int)strlen(name) + 1;
cg->hostent.h_addr_list = cg->ip_ptrs;
cg->ip_ptrs[0] = (char *)name;
cg->ip_ptrs[1] = NULL;
if (!s || slen <= 1)
return (NULL);
- if (gethostname(s, slen) < 0)
+ if (gethostname(s, (size_t)slen) < 0)
strlcpy(s, "localhost", slen);
if (!strchr(s, '.'))
*
* HTTP address list routines for CUPS.
*
- * Copyright 2007-2013 by Apple Inc.
+ * Copyright 2007-2014 by Apple Inc.
* Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
* Then connect...
*/
- if (!connect(*sock, &(addrlist->addr.addr),
- httpAddrLength(&(addrlist->addr))))
+ if (!connect(*sock, &(addrlist->addr.addr), (socklen_t)httpAddrLength(&(addrlist->addr))))
{
DEBUG_printf(("1httpAddrConnect2: Connected to %s:%d...",
httpAddrString(&(addrlist->addr), temp, sizeof(temp)),
*
* HTTP support routines for CUPS.
*
- * Copyright 2007-2013 by Apple Inc.
+ * Copyright 2007-2014 by Apple Inc.
* Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
bytes = vsnprintf(resource, sizeof(resource), resourcef, ap);
va_end(ap);
- if (bytes >= sizeof(resource))
+ if ((size_t)bytes >= sizeof(resource))
{
*uri = '\0';
return (HTTP_URI_STATUS_OVERFLOW);
(unsigned)CUPS_RAND() & 0xffff, (unsigned)CUPS_RAND() & 0xffff);
_cupsMD5Init(&md5state);
- _cupsMD5Append(&md5state, (unsigned char *)data, strlen(data));
+ _cupsMD5Append(&md5state, (unsigned char *)data, (int)strlen(data));
_cupsMD5Finish(&md5state, md5sum);
/*
int *outlen, /* IO - Size of output string */
const char *in) /* I - String to read from */
{
- int pos, /* Bit position */
- base64; /* Value of this character */
- char *outptr, /* Output pointer */
- *outend; /* End of output buffer */
+ int pos; /* Bit position */
+ unsigned base64; /* Value of this character */
+ char *outptr, /* Output pointer */
+ *outend; /* End of output buffer */
/*
*/
if (*in >= 'A' && *in <= 'Z')
- base64 = *in - 'A';
+ base64 = (unsigned)(*in - 'A');
else if (*in >= 'a' && *in <= 'z')
- base64 = *in - 'a' + 26;
+ base64 = (unsigned)(*in - 'a' + 26);
else if (*in >= '0' && *in <= '9')
- base64 = *in - '0' + 52;
+ base64 = (unsigned)(*in - '0' + 52);
else if (*in == '+')
base64 = 62;
else if (*in == '/')
{
case 0 :
if (outptr < outend)
- *outptr = base64 << 2;
+ *outptr = (char)(base64 << 2);
pos ++;
break;
case 1 :
if (outptr < outend)
- *outptr++ |= (base64 >> 4) & 3;
+ *outptr++ |= (char)((base64 >> 4) & 3);
if (outptr < outend)
- *outptr = (base64 << 4) & 255;
+ *outptr = (char)((base64 << 4) & 255);
pos ++;
break;
case 2 :
if (outptr < outend)
- *outptr++ |= (base64 >> 2) & 15;
+ *outptr++ |= (char)((base64 >> 2) & 15);
if (outptr < outend)
- *outptr = (base64 << 6) & 255;
+ *outptr = (char)((base64 << 6) & 255);
pos ++;
break;
case 3 :
return (HTTP_URI_STATUS_BAD_PORT);
}
- *port = strtol(uri + 1, (char **)&uri, 10);
+ *port = (int)strtol(uri + 1, (char **)&uri, 10);
if (*uri != '/' && *uri)
{
return (_httpStatus(cg->lang_default, status));
}
+/*
+ * 'httpURIStatusString()' - Return a string describing a URI status code.
+ *
+ * @since CUPS 2.0@
+ */
+
+const char * /* O - Localized status string */
+httpURIStatusString(
+ http_uri_status_t status) /* I - URI status code */
+{
+ const char *s; /* Status string */
+ _cups_globals_t *cg = _cupsGlobals(); /* Global data */
+
+
+ if (!cg->lang_default)
+ cg->lang_default = cupsLangDefault();
+
+ switch (status)
+ {
+ case HTTP_URI_STATUS_OVERFLOW :
+ s = _("URI too large");
+ break;
+ case HTTP_URI_STATUS_BAD_ARGUMENTS :
+ s = _("Bad arguments to function");
+ break;
+ case HTTP_URI_STATUS_BAD_RESOURCE :
+ s = _("Bad resource in URI");
+ break;
+ case HTTP_URI_STATUS_BAD_PORT :
+ s = _("Bad port number in URI");
+ break;
+ case HTTP_URI_STATUS_BAD_HOSTNAME :
+ s = _("Bad hostname/address in URI");
+ break;
+ case HTTP_URI_STATUS_BAD_USERNAME :
+ s = _("Bad username in URI");
+ break;
+ case HTTP_URI_STATUS_BAD_SCHEME :
+ s = _("Bad scheme in URI");
+ break;
+ case HTTP_URI_STATUS_BAD_URI :
+ s = _("Bad/empty URI");
+ break;
+ case HTTP_URI_STATUS_OK :
+ s = _("OK");
+ break;
+ case HTTP_URI_STATUS_MISSING_SCHEME :
+ s = _("Missing scheme in URI");
+ break;
+ case HTTP_URI_STATUS_UNKNOWN_SCHEME :
+ s = _("Unknown scheme in URI");
+ break;
+ case HTTP_URI_STATUS_MISSING_RESOURCE :
+ s = _("Missing resource in URI");
+ break;
+
+ default:
+ s = _("Unknown");
+ break;
+ }
+
+ return (_cupsLangString(cg->lang_default, s));
+}
+
#ifndef HAVE_HSTRERROR
/*
# pragma comment(lib, "dnssd.lib")
# endif /* WIN32 */
DNSServiceRef ref, /* DNS-SD master service reference */
- domainref, /* DNS-SD service reference for domain */
+ domainref = NULL,/* DNS-SD service reference for domain */
localref; /* DNS-SD service reference for .local */
int domainsent = 0; /* Send the domain resolve? */
# ifdef HAVE_POLL
# ifdef HAVE_DNSSD
if (DNSServiceCreateConnection(&ref) == kDNSServiceErr_NoError)
{
- int myinterface = kDNSServiceInterfaceIndexAny;
+ uint32_t myinterface = kDNSServiceInterfaceIndexAny;
/* Lookup on any interface */
if (!strcmp(scheme, "ippusb"))
polldata.fd = DNSServiceRefSockFD(ref);
polldata.events = POLLIN;
- fds = poll(&polldata, 1, 1000 * timeout);
+ fds = poll(&polldata, 1, (int)(1000 * timeout));
# else /* select() */
FD_ZERO(&input_set);
else
quoted |= *src - '0';
- *ptr++ = quoted;
+ *ptr++ = (char)quoted;
}
else
{
{
for (addr = addrlist; addr; addr = addr->next)
{
- int error = getnameinfo(&(addr->addr.addr),
- httpAddrLength(&(addr->addr)),
- fqdn, sizeof(fqdn), NULL, 0, NI_NAMEREQD);
+ int error = getnameinfo(&(addr->addr.addr), (socklen_t)httpAddrLength(&(addr->addr)), fqdn, sizeof(fqdn), NULL, 0, NI_NAMEREQD);
if (!error)
{
if ((!strcmp(scheme, "ipp") || !strcmp(scheme, "ipps")) &&
!strcmp(uribuf->resource, "/cups"))
- httpAssembleURIf(HTTP_URI_CODING_ALL, uribuf->buffer, uribuf->bufsize,
- scheme, NULL, hostTarget, ntohs(port), "%s?snmp=false",
- resource);
+ httpAssembleURIf(HTTP_URI_CODING_ALL, uribuf->buffer, (int)uribuf->bufsize, scheme, NULL, hostTarget, ntohs(port), "%s?snmp=false", resource);
else
- httpAssembleURI(HTTP_URI_CODING_ALL, uribuf->buffer, uribuf->bufsize,
- scheme, NULL, hostTarget, ntohs(port), resource);
+ httpAssembleURI(HTTP_URI_CODING_ALL, uribuf->buffer, (int)uribuf->bufsize, scheme, NULL, hostTarget, ntohs(port), resource);
DEBUG_printf(("8http_resolve_cb: Resolved URI is \"%s\"...", uribuf->buffer));
}
*
* HTTP routines for CUPS.
*
- * Copyright 2007-2013 by Apple Inc.
+ * Copyright 2007-2014 by Apple Inc.
* Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
* This file contains Kerberos support code, copyright 2006 by
int /* O - Bytes written or -1 on error */
httpFlushWrite(http_t *http) /* I - HTTP connection */
{
- int bytes; /* Bytes written */
+ ssize_t bytes; /* Bytes written */
DEBUG_printf(("httpFlushWrite(http=%p) data_encoding=%d", http,
- http ? http->data_encoding : -1));
+ http ? http->data_encoding : 100));
if (!http || !http->wused)
{
}
if (http->data_encoding == HTTP_ENCODING_CHUNKED)
- bytes = http_write_chunk(http, http->wbuffer, http->wused);
+ bytes = http_write_chunk(http, http->wbuffer, (size_t)http->wused);
else
- bytes = http_write(http, http->wbuffer, http->wused);
+ bytes = http_write(http, http->wbuffer, (size_t)http->wused);
http->wused = 0;
- DEBUG_printf(("1httpFlushWrite: Returning %d, errno=%d.", bytes, errno));
+ DEBUG_printf(("1httpFlushWrite: Returning %d, errno=%d.", (int)bytes, errno));
- return (bytes);
+ return ((int)bytes);
}
size_t /* O - Number of bytes buffered */
httpGetPending(http_t *http) /* I - HTTP connection */
{
- return (http ? http->wused : 0);
+ return (http ? (size_t)http->wused : 0);
}
if (!http)
return (0);
else if (http->used > 0)
- return (http->used);
+ return ((size_t)http->used);
#ifdef HAVE_SSL
else if (http->tls)
return (http_tls_pending(http));
size_t /* O - Remaining bytes */
httpGetRemaining(http_t *http) /* I - HTTP connection */
{
- return (http ? http->data_remaining : 0);
+ return (http ? (size_t)http->data_remaining : 0);
}
int length, /* I - Max length of buffer */
http_t *http) /* I - HTTP connection */
{
- char *lineptr, /* Pointer into line */
- *lineend, /* End of line */
- *bufptr, /* Pointer into input buffer */
- *bufend; /* Pointer to end of buffer */
- int bytes, /* Number of bytes read */
- eol; /* End-of-line? */
+ char *lineptr, /* Pointer into line */
+ *lineend, /* End of line */
+ *bufptr, /* Pointer into input buffer */
+ *bufend; /* Pointer to end of buffer */
+ ssize_t bytes; /* Number of bytes read */
+ int eol; /* End-of-line? */
DEBUG_printf(("2httpGets(line=%p, length=%d, http=%p)", line, length, http));
return (NULL);
}
- bytes = http_read(http, http->buffer + http->used,
- HTTP_MAX_BUFFER - http->used);
+ bytes = http_read(http, http->buffer + http->used, (size_t)(HTTP_MAX_BUFFER - http->used));
- DEBUG_printf(("4httpGets: read %d bytes.", bytes));
+ DEBUG_printf(("4httpGets: read " CUPS_LLFMT " bytes.", CUPS_LLCAST bytes));
if (bytes < 0)
{
* Yup, update the amount used...
*/
- http->used += bytes;
+ http->used += (int)bytes;
}
/*
}
}
- if (http->data_remaining > sizeof(http->buffer))
+ if ((size_t)http->data_remaining > sizeof(http->buffer))
buflen = sizeof(http->buffer);
else
- buflen = http->data_remaining;
+ buflen = (ssize_t)http->data_remaining;
DEBUG_printf(("2httpPeek: Reading %d bytes into buffer.", (int)buflen));
- bytes = http_read(http, http->buffer, buflen);
+ bytes = http_read(http, http->buffer, (size_t)buflen);
DEBUG_printf(("2httpPeek: Read " CUPS_LLFMT " bytes into buffer.",
CUPS_LLCAST bytes));
http_debug_hex("httpPeek", http->buffer, (int)bytes);
#endif /* DEBUG */
- http->used = bytes;
+ http->used = (int)bytes;
}
}
http->stream.next_in = http->dbuffer;
- if (buflen > http->data_remaining)
- buflen = http->data_remaining;
+ if (buflen > (size_t)http->data_remaining)
+ buflen = (size_t)http->data_remaining;
- if (buflen > http->used)
- buflen = http->used;
+ if (buflen > (size_t)http->used)
+ buflen = (size_t)http->used;
DEBUG_printf(("1httpPeek: Copying %d more bytes of data into "
"decompression buffer.", (int)buflen));
}
stream.next_out = (Bytef *)buffer;
- stream.avail_out = length;
+ stream.avail_out = (uInt)length;
zerr = inflate(&stream, Z_SYNC_FLUSH);
inflateEnd(&stream);
{
DEBUG_printf(("2httpPeek: zerr=%d", zerr));
#ifdef DEBUG
- http_debug_hex("2httpPeek", (char *)http->dbuffer,
- http->stream.avail_in);
+ http_debug_hex("2httpPeek", (char *)http->dbuffer, (int)http->stream.avail_in);
#endif /* DEBUG */
http->error = EIO;
return (-1);
}
- bytes = length - http->stream.avail_out;
+ bytes = (ssize_t)(length - http->stream.avail_out);
# else
DEBUG_puts("2httpPeek: No inflateCopy on this platform, httpPeek does not "
const char *format, /* I - printf-style format string */
...) /* I - Additional args as needed */
{
- int bytes; /* Number of bytes to write */
+ ssize_t bytes; /* Number of bytes to write */
char buf[16384]; /* Buffer for formatted string */
va_list ap; /* Variable argument pointer */
bytes = vsnprintf(buf, sizeof(buf), format, ap);
va_end(ap);
- DEBUG_printf(("3httpPrintf: (%d bytes) %s", bytes, buf));
+ DEBUG_printf(("3httpPrintf: (" CUPS_LLFMT " bytes) %s", CUPS_LLCAST bytes, buf));
if (http->data_encoding == HTTP_ENCODING_FIELDS)
- return (httpWrite2(http, buf, bytes));
+ return ((int)httpWrite2(http, buf, (size_t)bytes));
else
{
if (http->wused)
return (-1);
}
- return (http_write(http, buf, bytes));
+ return ((int)http_write(http, buf, (size_t)bytes));
}
}
char *buffer, /* I - Buffer for data */
int length) /* I - Maximum number of bytes */
{
- return ((int)httpRead2(http, buffer, length));
+ return ((int)httpRead2(http, buffer, (size_t)length));
}
(int)http->stream.avail_in, (int)length));
http->stream.next_out = (Bytef *)buffer;
- http->stream.avail_out = length;
+ http->stream.avail_out = (uInt)length;
if ((zerr = inflate(&(http->stream), Z_SYNC_FLUSH)) < Z_OK)
{
DEBUG_printf(("2httpRead2: zerr=%d", zerr));
#ifdef DEBUG
- http_debug_hex("2httpRead2", (char *)http->dbuffer,
- http->stream.avail_in);
+ http_debug_hex("2httpRead2", (char *)http->dbuffer, (int)http->stream.avail_in);
#endif /* DEBUG */
http->error = EIO;
return (-1);
}
- bytes = length - http->stream.avail_out;
+ bytes = (ssize_t)(length - http->stream.avail_out);
DEBUG_printf(("2httpRead2: avail_in=%d, avail_out=%d, bytes=%d",
http->stream.avail_in, http->stream.avail_out,
if (bytes == 0)
{
- ssize_t buflen = HTTP_MAX_BUFFER - http->stream.avail_in;
+ ssize_t buflen = HTTP_MAX_BUFFER - (ssize_t)http->stream.avail_in;
/* Additional bytes for buffer */
if (buflen > 0)
if (http->data_remaining > 0)
{
if (buflen > http->data_remaining)
- buflen = http->data_remaining;
+ buflen = (ssize_t)http->data_remaining;
- bytes = http_read_buffered(http,
- (char *)http->dbuffer +
- http->stream.avail_in, buflen);
+ bytes = http_read_buffered(http, (char *)http->dbuffer + http->stream.avail_in, (size_t)buflen);
}
else if (http->data_encoding == HTTP_ENCODING_CHUNKED)
- bytes = http_read_chunk(http,
- (char *)http->dbuffer +
- http->stream.avail_in, buflen);
+ bytes = http_read_chunk(http, (char *)http->dbuffer + http->stream.avail_in, (size_t)buflen);
else
bytes = 0;
"decompression buffer.", CUPS_LLCAST bytes));
http->data_remaining -= bytes;
- http->stream.avail_in += bytes;
+ http->stream.avail_in += (uInt)bytes;
if (http->data_remaining <= 0 &&
http->data_encoding == HTTP_ENCODING_CHUNKED)
* Set the current authorization string...
*/
- int len = (int)strlen(scheme) + (data ? (int)strlen(data) + 1 : 0) + 1;
+ size_t len = strlen(scheme) + (data ? strlen(data) + 1 : 0) + 1;
char *temp;
- if (len > (int)sizeof(http->_authstring))
+ if (len > sizeof(http->_authstring))
{
if ((temp = malloc(len)) == NULL)
len = sizeof(http->_authstring);
const char *buffer, /* I - Buffer for data */
int length) /* I - Number of bytes to write */
{
- return ((int)httpWrite2(http, buffer, length));
+ return ((int)httpWrite2(http, buffer, (size_t)length));
}
else
{
http->stream.next_in = (Bytef *)buffer;
- http->stream.avail_in = length;
+ http->stream.avail_in = (uInt)length;
http->stream.next_out = (Bytef *)http->wbuffer + http->wused;
- http->stream.avail_out = sizeof(http->wbuffer) - http->wused;
+ http->stream.avail_out = (uInt)(sizeof(http->wbuffer) - (size_t)http->wused);
while (deflate(&(http->stream), Z_NO_FLUSH) == Z_OK)
{
- http->wused = sizeof(http->wbuffer) - http->stream.avail_out;
+ http->wused = (int)(sizeof(http->wbuffer) - (size_t)http->stream.avail_out);
if (http->stream.avail_out == 0)
{
}
}
- http->wused = sizeof(http->wbuffer) - http->stream.avail_out;
- bytes = length;
+ http->wused = (int)(sizeof(http->wbuffer) - (size_t)http->stream.avail_out);
+ bytes = (ssize_t)length;
}
}
else
#endif /* HAVE_LIBZ */
if (length > 0)
{
- if (http->wused && (length + http->wused) > sizeof(http->wbuffer))
+ if (http->wused && (length + (size_t)http->wused) > sizeof(http->wbuffer))
{
DEBUG_printf(("2httpWrite2: Flushing buffer (wused=%d, length="
CUPS_LLFMT ")", http->wused, CUPS_LLCAST length));
httpFlushWrite(http);
}
- if ((length + http->wused) <= sizeof(http->wbuffer) &&
- length < sizeof(http->wbuffer))
+ if ((length + (size_t)http->wused) <= sizeof(http->wbuffer) && length < sizeof(http->wbuffer))
{
/*
* Write to buffer...
CUPS_LLCAST length));
if (http->data_encoding == HTTP_ENCODING_CHUNKED)
- bytes = (ssize_t)http_write_chunk(http, buffer, (int)length);
+ bytes = (ssize_t)http_write_chunk(http, buffer, length);
else
- bytes = (ssize_t)http_write(http, buffer, (int)length);
+ bytes = (ssize_t)http_write(http, buffer, length);
DEBUG_printf(("2httpWrite2: Wrote " CUPS_LLFMT " bytes...",
CUPS_LLCAST bytes));
do
{
http->stream.next_out = (Bytef *)http->wbuffer + http->wused;
- http->stream.avail_out = sizeof(http->wbuffer) - http->wused;
+ http->stream.avail_out = (uInt)(sizeof(http->wbuffer) - (size_t)http->wused);
zerr = deflate(&(http->stream), Z_FINISH);
- http->wused = sizeof(http->wbuffer) - http->stream.avail_out;
+ http->wused = (int)(sizeof(http->wbuffer) - (size_t)http->stream.avail_out);
if (http->wused == sizeof(http->wbuffer))
httpFlushWrite(http);
}
if (ch < ' ' || ch >= 127)
ch = '.';
- *ptr++ = ch;
+ *ptr++ = (char)ch;
}
*ptr = '\0';
{
#ifdef HAVE_SSL
if (http->tls)
- bytes = http_tls_read(http, buffer, length);
+ bytes = http_tls_read(http, buffer, (int)length);
else
#endif /* HAVE_SSL */
bytes = recv(http->fd, buffer, length, 0);
if (http->used > 0)
{
if (length > (size_t)http->used)
- bytes = (size_t)http->used;
+ bytes = (ssize_t)http->used;
else
- bytes = length;
+ bytes = (ssize_t)length;
DEBUG_printf(("2http_read: Grabbing %d bytes from input buffer.",
(int)bytes));
http->data_remaining = remaining;
if (remaining <= INT_MAX)
- http->_data_remaining = remaining;
+ http->_data_remaining = (int)remaining;
else
http->_data_remaining = INT_MAX;
}
#ifdef HAVE_SSL
if (http->tls)
- bytes = http_tls_write(http, buffer, length);
+ bytes = http_tls_write(http, buffer, (int)length);
else
#endif /* HAVE_SSL */
bytes = send(http->fd, buffer, length, 0);
buffer += bytes;
tbytes += bytes;
- length -= bytes;
+ length -= (size_t)bytes;
}
#ifdef DEBUG
- http_debug_hex("http_write", buffer - tbytes, tbytes);
+ http_debug_hex("http_write", buffer - tbytes, (int)tbytes);
#endif /* DEBUG */
DEBUG_printf(("3http_write: Returning " CUPS_LLFMT ".", CUPS_LLCAST tbytes));
*
* Hyper-Text Transport Protocol definitions for CUPS.
*
- * Copyright 2007-2013 by Apple Inc.
+ * Copyright 2007-2014 by Apple Inc.
* Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
extern int httpSaveCredentials(const char *path, cups_array_t *credentials, const char *common_name) _CUPS_API_2_0;
extern void httpSetKeepAlive(http_t *http, http_keepalive_t keep_alive) _CUPS_API_2_0;
extern void httpShutdown(http_t *http) _CUPS_API_2_0;
-extern const char *httpStateString(http_state_t state);
-
+extern const char *httpStateString(http_state_t state) _CUPS_API_2_0;
+extern const char *httpURIStatusString(http_uri_status_t status) _CUPS_API_2_0;
/*
* C++ magic...
/*
* "$Id$"
*
- * Private IPP definitions for CUPS.
+ * Private IPP definitions for CUPS.
*
- * Copyright 2007-2012 by Apple Inc.
- * Copyright 1997-2006 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2006 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
#ifndef _CUPS_IPP_PRIVATE_H_
*
* Internet Printing Protocol support functions for CUPS.
*
- * Copyright 2007-2013 by Apple Inc.
+ * Copyright 2007-2014 by Apple Inc.
* Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
{
unsigned year; /* Year */
- year = (val->date[0] << 8) + val->date[1];
+ year = ((unsigned)val->date[0] << 8) + (unsigned)val->date[1];
if (val->date[9] == 0 && val->date[10] == 0)
snprintf(temp, sizeof(temp), "%04u-%02u-%02uT%02u:%02u:%02uZ",
case IPP_TAG_BEGIN_COLLECTION :
if (buffer && bufptr < bufend)
- bufptr += ipp_col_string(val->collection, bufptr,
- bufend - bufptr + 1);
+ bufptr += ipp_col_string(val->collection, bufptr, (size_t)(bufend - bufptr + 1));
else
bufptr += ipp_col_string(val->collection, NULL, 0);
break;
else if (bufend)
*bufend = '\0';
- return (bufptr - buffer);
+ return ((size_t)(bufptr - buffer));
}
*/
if (isdigit(*enumstring & 255))
- return (strtol(enumstring, NULL, 0));
+ return ((int)strtol(enumstring, NULL, 0));
/*
* Otherwise look up the string...
ipp_status_t /* O - IPP status code */
ippErrorValue(const char *name) /* I - Name */
{
- int i;
+ size_t i; /* Looping var */
for (i = 0; i < (sizeof(ipp_status_oks) / sizeof(ipp_status_oks[0])); i ++)
ipp_op_t /* O - Operation ID */
ippOpValue(const char *name) /* I - Textual name */
{
- int i;
+ size_t i; /* Looping var */
if (!strncmp(name, "0x", 2))
ipp_tag_t /* O - Tag value */
ippTagValue(const char *name) /* I - Tag name */
{
- int i; /* Looping var */
+ size_t i; /* Looping var */
for (i = 0; i < (sizeof(ipp_tag_names) / sizeof(ipp_tag_names[0])); i ++)
bufptr += strlen(attr->name) + 1;
if (buffer && bufptr < bufend)
- bufptr += ippAttributeString(attr, bufptr, bufend - bufptr + 1);
+ bufptr += ippAttributeString(attr, bufptr, (size_t)(bufend - bufptr + 1));
else
bufptr += ippAttributeString(attr, temp, sizeof(temp));
}
*bufptr = '}';
bufptr ++;
- return (bufptr - buffer);
+ return ((size_t)(bufptr - buffer));
}
/*
* "$Id$"
*
- * Internet Printing Protocol functions for CUPS.
- *
- * Copyright 2007-2013 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products, all rights reserved.
- *
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
- *
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * _cupsBufferGet() - Get a read/write buffer.
- * _cupsBufferRelease() - Release a read/write buffer.
- * ippAddBoolean() - Add a boolean attribute to an IPP message.
- * ippAddBooleans() - Add an array of boolean values.
- * ippAddCollection() - Add a collection value.
- * ippAddCollections() - Add an array of collection values.
- * ippAddDate() - Add a date attribute to an IPP message.
- * ippAddInteger() - Add a integer attribute to an IPP message.
- * ippAddIntegers() - Add an array of integer values.
- * ippAddOctetString() - Add an octetString value to an IPP message.
- * ippAddOutOfBand() - Add an out-of-band value to an IPP message.
- * ippAddRange() - Add a range of values to an IPP message.
- * ippAddRanges() - Add ranges of values to an IPP message.
- * ippAddResolution() - Add a resolution value to an IPP message.
- * ippAddResolutions() - Add resolution values to an IPP message.
- * ippAddSeparator() - Add a group separator to an IPP message.
- * ippAddString() - Add a language-encoded string to an IPP message.
- * ippAddStringf() - Add a formatted string to an IPP message.
- * ippAddStringfv() - Add a formatted string to an IPP message.
- * ippAddStrings() - Add language-encoded strings to an IPP message.
- * ippContainsInteger() - Determine whether an attribute contains the
- * specified value or is within the list of ranges.
- * ippContainsString() - Determine whether an attribute contains the
- * specified string value.
- * ippCopyAttribute() - Copy an attribute.
- * ippCopyAttributes() - Copy attributes from one IPP message to another.
- * ippDateToTime() - Convert from RFC 1903 Date/Time format to UNIX
- * time in seconds.
- * ippDelete() - Delete an IPP message.
- * ippDeleteAttribute() - Delete a single attribute in an IPP message.
- * ippDeleteValues() - Delete values in an attribute.
- * ippFindAttribute() - Find a named attribute in a request.
- * ippFindNextAttribute() - Find the next named attribute in a request.
- * ippFirstAttribute() - Return the first attribute in the message.
- * ippGetBoolean() - Get a boolean value for an attribute.
- * ippGetCollection() - Get a collection value for an attribute.
- * ippGetCount() - Get the number of values in an attribute.
- * ippGetDate() - Get a date value for an attribute.
- * ippGetGroupTag() - Get the group associated with an attribute.
- * ippGetInteger() - Get the integer/enum value for an attribute.
- * ippGetName() - Get the attribute name.
- * ippGetOctetString() - Get an octetString value from an IPP attribute.
- * ippGetOperation() - Get the operation ID in an IPP message.
- * ippGetRange() - Get a rangeOfInteger value from an attribute.
- * ippGetRequestId() - Get the request ID from an IPP message.
- * ippGetResolution() - Get a resolution value for an attribute.
- * ippGetState() - Get the IPP message state.
- * ippGetStatusCode() - Get the status code from an IPP response or
- * event message.
- * ippGetString() - Get the string and optionally the language code
- * for an attribute.
- * ippGetValueTag() - Get the value tag for an attribute.
- * ippGetVersion() - Get the major and minor version number from an
- * IPP message.
- * ippLength() - Compute the length of an IPP message.
- * ippNextAttribute() - Return the next attribute in the message.
- * ippNew() - Allocate a new IPP message.
- * ippNewRequest() - Allocate a new IPP request message.
- * ippNewResponse() - Allocate a new IPP response message.
- * ippRead() - Read data for an IPP message from a HTTP
- * connection.
- * ippReadFile() - Read data for an IPP message from a file.
- * ippReadIO() - Read data for an IPP message.
- * ippSetBoolean() - Set a boolean value in an attribute.
- * ippSetCollection() - Set a collection value in an attribute.
- * ippSetDate() - Set a date value in an attribute.
- * ippSetGroupTag() - Set the group tag of an attribute.
- * ippSetInteger() - Set an integer or enum value in an attribute.
- * ippSetName() - Set the name of an attribute.
- * ippSetOctetString() - Set an octetString value in an IPP attribute.
- * ippSetOperation() - Set the operation ID in an IPP request message.
- * ippSetRange() - Set a rangeOfInteger value in an attribute.
- * ippSetRequestId() - Set the request ID in an IPP message.
- * ippSetResolution() - Set a resolution value in an attribute.
- * ippSetState() - Set the current state of the IPP message.
- * ippSetStatusCode() - Set the status code in an IPP response or event
- * message.
- * ippSetString() - Set a string value in an attribute.
- * ippSetStringf() - Set a formatted string value of an attribute.
- * ippSetStringf() - Set a formatted string value of an attribute.
- * ippSetValueTag() - Set the value tag of an attribute.
- * ippSetVersion() - Set the version number in an IPP message.
- * ippTimeToDate() - Convert from UNIX time to RFC 1903 format.
- * ippValidateAttribute() - Validate the contents of an attribute.
- * ippValidateAttributes() - Validate all attributes in an IPP message.
- * ippWrite() - Write data for an IPP message to a HTTP
- * connection.
- * ippWriteFile() - Write data for an IPP message to a file.
- * ippWriteIO() - Write data for an IPP message.
- * ipp_add_attr() - Add a new attribute to the message.
- * ipp_free_values() - Free attribute values.
- * ipp_get_code() - Convert a C locale/charset name into an IPP
- * language/charset code.
- * ipp_lang_code() - Convert a C locale name into an IPP language
- * code.
- * ipp_length() - Compute the length of an IPP message or
- * collection value.
- * ipp_read_http() - Semi-blocking read on a HTTP connection...
- * ipp_read_file() - Read IPP data from a file.
- * ipp_set_error() - Set a formatted, localized error string.
- * ipp_set_value() - Get the value element from an attribute,
- * expanding it as needed.
- * ipp_write_file() - Write IPP data to a file.
+ * Internet Printing Protocol functions for CUPS.
+ *
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2007 by Easy Software Products, all rights reserved.
+ *
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
+ *
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
if (data)
{
- if ((attr->values[0].unknown.data = malloc(datalen)) == NULL)
+ if ((attr->values[0].unknown.data = malloc((size_t)datalen)) == NULL)
{
ippDeleteAttribute(ipp, attr);
return (NULL);
if (!s)
s = "(null)";
- bytes = strlen(s);
+ bytes = (ssize_t)strlen(s);
strlcpy(buffer, s, sizeof(buffer));
}
else
if (dstval->unknown.length > 0)
{
- if ((dstval->unknown.data = malloc(dstval->unknown.length)) == NULL)
+ if ((dstval->unknown.data = malloc((size_t)dstval->unknown.length)) == NULL)
dstval->unknown.length = 0;
else
memcpy(dstval->unknown.data, srcval->unknown.data, dstval->unknown.length);
if (cg->server_version == 0)
_cupsSetDefaults();
- temp->request.any.version[0] = cg->server_version / 10;
- temp->request.any.version[1] = cg->server_version % 10;
+ temp->request.any.version[0] = (ipp_uchar_t)(cg->server_version / 10);
+ temp->request.any.version[1] = (ipp_uchar_t)(cg->server_version % 10);
temp->use = 1;
}
* New attribute; read the name and add it...
*/
- if ((*cb)(src, buffer, n) < n)
+ if ((*cb)(src, buffer, (size_t)n) < n)
{
DEBUG_puts("1ippReadIO: unable to read name.");
_cupsBufferRelease((char *)buffer);
return (IPP_STATE_ERROR);
}
- value->boolean = buffer[0];
+ value->boolean = (char)buffer[0];
break;
case IPP_TAG_NOVALUE :
case IPP_TAG_MIMETYPE :
if (n > 0)
{
- if ((*cb)(src, buffer, n) < n)
+ if ((*cb)(src, buffer, (size_t)n) < n)
{
DEBUG_puts("1ippReadIO: unable to read string value.");
_cupsBufferRelease((char *)buffer);
return (IPP_STATE_ERROR);
}
- if ((*cb)(src, buffer, n) < n)
+ if ((*cb)(src, buffer, (size_t)n) < n)
{
DEBUG_puts("1ippReadIO: Unable to read string w/language "
"value.");
n = (bufptr[0] << 8) | bufptr[1];
- if ((bufptr + 2 + n) >= (buffer + IPP_BUF_SIZE) ||
- n >= sizeof(string))
+ if ((bufptr + 2 + n) >= (buffer + IPP_BUF_SIZE) || n >= (int)sizeof(string))
{
_cupsSetError(IPP_STATUS_ERROR_INTERNAL,
_("IPP language length overflows value."), 1);
_cupsBufferRelease((char *)buffer);
return (IPP_STATE_ERROR);
}
- else if ((*cb)(src, buffer, n) < n)
+ else if ((*cb)(src, buffer, (size_t)n) < n)
{
DEBUG_puts("1ippReadIO: Unable to read member name value.");
_cupsBufferRelease((char *)buffer);
if (n > 0)
{
- if ((value->unknown.data = malloc(n)) == NULL)
+ if ((value->unknown.data = malloc((size_t)n)) == NULL)
{
_cupsSetHTTPError(HTTP_STATUS_ERROR);
DEBUG_puts("1ippReadIO: Unable to allocate value");
return (IPP_STATE_ERROR);
}
- if ((*cb)(src, value->unknown.data, n) < n)
+ if ((*cb)(src, value->unknown.data, (size_t)n) < n)
{
DEBUG_puts("1ippReadIO: Unable to read unsupported value.");
_cupsBufferRelease((char *)buffer);
*/
if ((value = ipp_set_value(ipp, attr, element)) != NULL)
- value->boolean = boolvalue;
+ value->boolean = (char)boolvalue;
return (value != NULL);
}
{
void *temp; /* Temporary data pointer */
- if ((temp = malloc(datalen)) != NULL)
+ if ((temp = malloc((size_t)datalen)) != NULL)
{
memcpy(temp, data, datalen);
if (!s)
s = "(null)";
- bytes = strlen(s);
+ bytes = (ssize_t)strlen(s);
strlcpy(buffer, s, sizeof(buffer));
}
else
* Set the version number...
*/
- ipp->request.any.version[0] = major;
- ipp->request.any.version[1] = minor;
+ ipp->request.any.version[0] = (ipp_uchar_t)major;
+ ipp->request.any.version[1] = (ipp_uchar_t)minor;
return (1);
}
unixdate = gmtime(&t);
unixdate->tm_year += 1900;
- date[0] = unixdate->tm_year >> 8;
- date[1] = unixdate->tm_year;
- date[2] = unixdate->tm_mon + 1;
- date[3] = unixdate->tm_mday;
- date[4] = unixdate->tm_hour;
- date[5] = unixdate->tm_min;
- date[6] = unixdate->tm_sec;
+ date[0] = (ipp_uchar_t)(unixdate->tm_year >> 8);
+ date[1] = (ipp_uchar_t)(unixdate->tm_year);
+ date[2] = (ipp_uchar_t)(unixdate->tm_mon + 1);
+ date[3] = (ipp_uchar_t)unixdate->tm_mday;
+ date[4] = (ipp_uchar_t)unixdate->tm_hour;
+ date[5] = (ipp_uchar_t)unixdate->tm_min;
+ date[6] = (ipp_uchar_t)unixdate->tm_sec;
date[7] = 0;
date[8] = '+';
date[9] = 0;
*bufptr++ = ipp->request.any.version[0];
*bufptr++ = ipp->request.any.version[1];
- *bufptr++ = ipp->request.any.op_status >> 8;
- *bufptr++ = ipp->request.any.op_status;
- *bufptr++ = ipp->request.any.request_id >> 24;
- *bufptr++ = ipp->request.any.request_id >> 16;
- *bufptr++ = ipp->request.any.request_id >> 8;
- *bufptr++ = ipp->request.any.request_id;
+ *bufptr++ = (ipp_uchar_t)(ipp->request.any.op_status >> 8);
+ *bufptr++ = (ipp_uchar_t)ipp->request.any.op_status;
+ *bufptr++ = (ipp_uchar_t)(ipp->request.any.request_id >> 24);
+ *bufptr++ = (ipp_uchar_t)(ipp->request.any.request_id >> 16);
+ *bufptr++ = (ipp_uchar_t)(ipp->request.any.request_id >> 8);
+ *bufptr++ = (ipp_uchar_t)ipp->request.any.request_id;
DEBUG_printf(("2ippWriteIO: version=%d.%d", buffer[0], buffer[1]));
DEBUG_printf(("2ippWriteIO: op_status=%04x",
DEBUG_printf(("2ippWriteIO: request_id=%d",
ipp->request.any.request_id));
- if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
+ if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
{
DEBUG_puts("1ippWriteIO: Could not write IPP header...");
_cupsBufferRelease((char *)buffer);
DEBUG_printf(("2ippWriteIO: wrote group tag=%x(%s)",
attr->group_tag, ippTagString(attr->group_tag)));
- *bufptr++ = attr->group_tag;
+ *bufptr++ = (ipp_uchar_t)attr->group_tag;
}
else if (attr->group_tag == IPP_TAG_ZERO)
continue;
if (attr->value_tag > 0xff)
{
*bufptr++ = IPP_TAG_EXTENSION;
- *bufptr++ = attr->value_tag >> 24;
- *bufptr++ = attr->value_tag >> 16;
- *bufptr++ = attr->value_tag >> 8;
- *bufptr++ = attr->value_tag;
+ *bufptr++ = (ipp_uchar_t)(attr->value_tag >> 24);
+ *bufptr++ = (ipp_uchar_t)(attr->value_tag >> 16);
+ *bufptr++ = (ipp_uchar_t)(attr->value_tag >> 8);
+ *bufptr++ = (ipp_uchar_t)attr->value_tag;
}
else
- *bufptr++ = attr->value_tag;
+ *bufptr++ = (ipp_uchar_t)attr->value_tag;
- *bufptr++ = n >> 8;
- *bufptr++ = n;
+ *bufptr++ = (ipp_uchar_t)(n >> 8);
+ *bufptr++ = (ipp_uchar_t)n;
memcpy(bufptr, attr->name, n);
bufptr += n;
}
*bufptr++ = IPP_TAG_MEMBERNAME;
*bufptr++ = 0;
*bufptr++ = 0;
- *bufptr++ = n >> 8;
- *bufptr++ = n;
+ *bufptr++ = (ipp_uchar_t)(n >> 8);
+ *bufptr++ = (ipp_uchar_t)n;
memcpy(bufptr, attr->name, n);
bufptr += n;
if (attr->value_tag > 0xff)
{
*bufptr++ = IPP_TAG_EXTENSION;
- *bufptr++ = attr->value_tag >> 24;
- *bufptr++ = attr->value_tag >> 16;
- *bufptr++ = attr->value_tag >> 8;
- *bufptr++ = attr->value_tag;
+ *bufptr++ = (ipp_uchar_t)(attr->value_tag >> 24);
+ *bufptr++ = (ipp_uchar_t)(attr->value_tag >> 16);
+ *bufptr++ = (ipp_uchar_t)(attr->value_tag >> 8);
+ *bufptr++ = (ipp_uchar_t)attr->value_tag;
}
else
- *bufptr++ = attr->value_tag;
+ *bufptr++ = (ipp_uchar_t)attr->value_tag;
*bufptr++ = 0;
*bufptr++ = 0;
{
if ((IPP_BUF_SIZE - (bufptr - buffer)) < 9)
{
- if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
+ if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
{
DEBUG_puts("1ippWriteIO: Could not write IPP "
"attribute...");
* values with a zero-length name...
*/
- *bufptr++ = attr->value_tag;
+ *bufptr++ = (ipp_uchar_t)attr->value_tag;
*bufptr++ = 0;
*bufptr++ = 0;
}
*bufptr++ = 0;
*bufptr++ = 4;
- *bufptr++ = value->integer >> 24;
- *bufptr++ = value->integer >> 16;
- *bufptr++ = value->integer >> 8;
- *bufptr++ = value->integer;
+ *bufptr++ = (ipp_uchar_t)(value->integer >> 24);
+ *bufptr++ = (ipp_uchar_t)(value->integer >> 16);
+ *bufptr++ = (ipp_uchar_t)(value->integer >> 8);
+ *bufptr++ = (ipp_uchar_t)value->integer;
}
break;
{
if ((IPP_BUF_SIZE - (bufptr - buffer)) < 6)
{
- if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
+ if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
{
DEBUG_puts("1ippWriteIO: Could not write IPP "
"attribute...");
* values with a zero-length name...
*/
- *bufptr++ = attr->value_tag;
+ *bufptr++ = (ipp_uchar_t)attr->value_tag;
*bufptr++ = 0;
*bufptr++ = 0;
}
*bufptr++ = 0;
*bufptr++ = 1;
- *bufptr++ = value->boolean;
+ *bufptr++ = (ipp_uchar_t)value->boolean;
}
break;
if ((IPP_BUF_SIZE - (bufptr - buffer)) < 3)
{
- if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
+ if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
{
DEBUG_puts("1ippWriteIO: Could not write IPP "
"attribute...");
bufptr = buffer;
}
- *bufptr++ = attr->value_tag;
+ *bufptr++ = (ipp_uchar_t)attr->value_tag;
*bufptr++ = 0;
*bufptr++ = 0;
}
if ((int)(IPP_BUF_SIZE - (bufptr - buffer)) < (n + 2))
{
- if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
+ if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
{
DEBUG_puts("1ippWriteIO: Could not write IPP "
"attribute...");
* Put the 2-byte length and string characters in the buffer.
*/
- *bufptr++ = n >> 8;
- *bufptr++ = n;
+ *bufptr++ = (ipp_uchar_t)(n >> 8);
+ *bufptr++ = (ipp_uchar_t)n;
if (n > 0)
{
{
if ((IPP_BUF_SIZE - (bufptr - buffer)) < 16)
{
- if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
+ if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
{
DEBUG_puts("1ippWriteIO: Could not write IPP "
"attribute...");
* values with a zero-length name...
*/
- *bufptr++ = attr->value_tag;
+ *bufptr++ = (ipp_uchar_t)attr->value_tag;
*bufptr++ = 0;
*bufptr++ = 0;
}
{
if ((IPP_BUF_SIZE - (bufptr - buffer)) < 14)
{
- if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
+ if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
{
DEBUG_puts("1ippWriteIO: Could not write IPP "
"attribute...");
* values with a zero-length name...
*/
- *bufptr++ = attr->value_tag;
+ *bufptr++ = (ipp_uchar_t)attr->value_tag;
*bufptr++ = 0;
*bufptr++ = 0;
}
*bufptr++ = 0;
*bufptr++ = 9;
- *bufptr++ = value->resolution.xres >> 24;
- *bufptr++ = value->resolution.xres >> 16;
- *bufptr++ = value->resolution.xres >> 8;
- *bufptr++ = value->resolution.xres;
- *bufptr++ = value->resolution.yres >> 24;
- *bufptr++ = value->resolution.yres >> 16;
- *bufptr++ = value->resolution.yres >> 8;
- *bufptr++ = value->resolution.yres;
- *bufptr++ = value->resolution.units;
+ *bufptr++ = (ipp_uchar_t)(value->resolution.xres >> 24);
+ *bufptr++ = (ipp_uchar_t)(value->resolution.xres >> 16);
+ *bufptr++ = (ipp_uchar_t)(value->resolution.xres >> 8);
+ *bufptr++ = (ipp_uchar_t)value->resolution.xres;
+ *bufptr++ = (ipp_uchar_t)(value->resolution.yres >> 24);
+ *bufptr++ = (ipp_uchar_t)(value->resolution.yres >> 16);
+ *bufptr++ = (ipp_uchar_t)(value->resolution.yres >> 8);
+ *bufptr++ = (ipp_uchar_t)value->resolution.yres;
+ *bufptr++ = (ipp_uchar_t)value->resolution.units;
}
break;
{
if ((IPP_BUF_SIZE - (bufptr - buffer)) < 13)
{
- if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
+ if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
{
DEBUG_puts("1ippWriteIO: Could not write IPP "
"attribute...");
* values with a zero-length name...
*/
- *bufptr++ = attr->value_tag;
+ *bufptr++ = (ipp_uchar_t)attr->value_tag;
*bufptr++ = 0;
*bufptr++ = 0;
}
*bufptr++ = 0;
*bufptr++ = 8;
- *bufptr++ = value->range.lower >> 24;
- *bufptr++ = value->range.lower >> 16;
- *bufptr++ = value->range.lower >> 8;
- *bufptr++ = value->range.lower;
- *bufptr++ = value->range.upper >> 24;
- *bufptr++ = value->range.upper >> 16;
- *bufptr++ = value->range.upper >> 8;
- *bufptr++ = value->range.upper;
+ *bufptr++ = (ipp_uchar_t)(value->range.lower >> 24);
+ *bufptr++ = (ipp_uchar_t)(value->range.lower >> 16);
+ *bufptr++ = (ipp_uchar_t)(value->range.lower >> 8);
+ *bufptr++ = (ipp_uchar_t)value->range.lower;
+ *bufptr++ = (ipp_uchar_t)(value->range.upper >> 24);
+ *bufptr++ = (ipp_uchar_t)(value->range.upper >> 16);
+ *bufptr++ = (ipp_uchar_t)(value->range.upper >> 8);
+ *bufptr++ = (ipp_uchar_t)value->range.upper;
}
break;
if ((IPP_BUF_SIZE - (bufptr - buffer)) < 3)
{
- if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
+ if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
{
DEBUG_puts("1ippWriteIO: Could not write IPP "
"attribute...");
bufptr = buffer;
}
- *bufptr++ = attr->value_tag;
+ *bufptr++ = (ipp_uchar_t)attr->value_tag;
*bufptr++ = 0;
*bufptr++ = 0;
}
if ((int)(IPP_BUF_SIZE - (bufptr - buffer)) < (n + 2))
{
- if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
+ if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
{
DEBUG_puts("1ippWriteIO: Could not write IPP "
"attribute...");
}
/* Length of entire value */
- *bufptr++ = n >> 8;
- *bufptr++ = n;
+ *bufptr++ = (ipp_uchar_t)(n >> 8);
+ *bufptr++ = (ipp_uchar_t)n;
/* Length of language */
if (value->string.language != NULL)
else
n = 0;
- *bufptr++ = n >> 8;
- *bufptr++ = n;
+ *bufptr++ = (ipp_uchar_t)(n >> 8);
+ *bufptr++ = (ipp_uchar_t)n;
/* Language */
if (n > 0)
else
n = 0;
- *bufptr++ = n >> 8;
- *bufptr++ = n;
+ *bufptr++ = (ipp_uchar_t)(n >> 8);
+ *bufptr++ = (ipp_uchar_t)n;
/* Text */
if (n > 0)
if ((IPP_BUF_SIZE - (bufptr - buffer)) < 5)
{
- if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
+ if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
{
DEBUG_puts("1ippWriteIO: Could not write IPP "
"attribute...");
* values with a zero-length name...
*/
- *bufptr++ = attr->value_tag;
+ *bufptr++ = (ipp_uchar_t)attr->value_tag;
*bufptr++ = 0;
*bufptr++ = 0;
}
*bufptr++ = 0;
*bufptr++ = 0;
- if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
+ if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
{
DEBUG_puts("1ippWriteIO: Could not write IPP "
"attribute...");
if ((IPP_BUF_SIZE - (bufptr - buffer)) < 3)
{
- if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
+ if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
{
DEBUG_puts("1ippWriteIO: Could not write IPP "
"attribute...");
bufptr = buffer;
}
- *bufptr++ = attr->value_tag;
+ *bufptr++ = (ipp_uchar_t)attr->value_tag;
*bufptr++ = 0;
*bufptr++ = 0;
}
if ((int)(IPP_BUF_SIZE - (bufptr - buffer)) < (n + 2))
{
- if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
+ if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
{
DEBUG_puts("1ippWriteIO: Could not write IPP "
"attribute...");
}
/* Length of unknown value */
- *bufptr++ = n >> 8;
- *bufptr++ = n;
+ *bufptr++ = (ipp_uchar_t)(n >> 8);
+ *bufptr++ = (ipp_uchar_t)n;
/* Value */
if (n > 0)
if (bufptr > buffer)
{
- if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
+ if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
{
DEBUG_puts("1ippWriteIO: Could not write IPP attribute...");
_cupsBufferRelease((char *)buffer);
n = 5;
}
- if ((*cb)(dst, buffer, n) < 0)
+ if ((*cb)(dst, buffer, (size_t)n) < 0)
{
DEBUG_puts("1ippWriteIO: Could not write IPP end-tag...");
_cupsBufferRelease((char *)buffer);
alloc_values = (num_values + IPP_MAX_VALUES - 1) & ~(IPP_MAX_VALUES - 1);
attr = calloc(sizeof(ipp_attribute_t) +
- (alloc_values - 1) * sizeof(_ipp_value_t), 1);
+ (size_t)(alloc_values - 1) * sizeof(_ipp_value_t), 1);
if (attr)
{
if ((element + count) < attr->num_values)
memmove(attr->values + element, attr->values + element + count,
- (attr->num_values - count - element) * sizeof(_ipp_value_t));
+ (size_t)(attr->num_values - count - element) * sizeof(_ipp_value_t));
attr->num_values -= count;
}
if (*value == '_')
*bufptr++ = '-';
else
- *bufptr++ = _cups_tolower(*value);
+ *bufptr++ = (char)_cups_tolower(*value);
*bufptr = '\0';
"bytes=" CUPS_LLFMT, attr->name, attr->num_values, CUPS_LLCAST bytes));
if (attr->value_tag < IPP_TAG_EXTENSION)
- bytes += attr->num_values; /* Value tag for each value */
+ bytes += (size_t)attr->num_values;/* Value tag for each value */
else
- bytes += 5 * attr->num_values; /* Value tag for each value */
- bytes += 2 * attr->num_values; /* Name lengths */
- bytes += (int)strlen(attr->name); /* Name */
- bytes += 2 * attr->num_values; /* Value lengths */
+ bytes += (size_t)(5 * attr->num_values);
+ /* Value tag for each value */
+ bytes += (size_t)(2 * attr->num_values);
+ /* Name lengths */
+ bytes += strlen(attr->name); /* Name */
+ bytes += (size_t)(2 * attr->num_values);
+ /* Value lengths */
if (collection)
bytes += 5; /* Add membername overhead */
case IPP_TAG_INTEGER :
case IPP_TAG_ENUM :
- bytes += 4 * attr->num_values;
+ bytes += (size_t)(4 * attr->num_values);
break;
case IPP_TAG_BOOLEAN :
- bytes += attr->num_values;
+ bytes += (size_t)attr->num_values;
break;
case IPP_TAG_TEXT :
break;
case IPP_TAG_DATE :
- bytes += 11 * attr->num_values;
+ bytes += (size_t)(11 * attr->num_values);
break;
case IPP_TAG_RESOLUTION :
- bytes += 9 * attr->num_values;
+ bytes += (size_t)(9 * attr->num_values);
break;
case IPP_TAG_RANGE :
- bytes += 8 * attr->num_values;
+ bytes += (size_t)(8 * attr->num_values);
break;
case IPP_TAG_TEXTLANG :
case IPP_TAG_NAMELANG :
- bytes += 4 * attr->num_values;/* Charset + text length */
+ bytes += (size_t)(4 * attr->num_values);
+ /* Charset + text length */
for (i = 0, value = attr->values;
i < attr->num_values;
for (i = 0, value = attr->values;
i < attr->num_values;
i ++, value ++)
- bytes += value->unknown.length;
+ bytes += (size_t)value->unknown.length;
break;
}
}
ipp_uchar_t *buffer, /* O - Buffer for data */
size_t length) /* I - Total length */
{
- int tbytes, /* Total bytes read */
- bytes; /* Bytes read this pass */
+ ssize_t tbytes, /* Total bytes read */
+ bytes; /* Bytes read this pass */
DEBUG_printf(("7ipp_read_http(http=%p, buffer=%p, length=%d)",
tbytes < (int)length;
tbytes += bytes, buffer += bytes)
{
- DEBUG_printf(("9ipp_read_http: tbytes=%d, http->state=%d", tbytes,
- http->state));
+ DEBUG_printf(("9ipp_read_http: tbytes=" CUPS_LLFMT ", http->state=%d", CUPS_LLCAST tbytes, http->state));
if (http->state == HTTP_STATE_WAITING)
break;
}
}
- if ((bytes = httpRead2(http, (char *)buffer, length - tbytes)) < 0)
+ if ((bytes = httpRead2(http, (char *)buffer, length - (size_t)tbytes)) < 0)
{
#ifdef WIN32
break;
if (tbytes == 0 && bytes < 0)
tbytes = -1;
- DEBUG_printf(("8ipp_read_http: Returning %d bytes", tbytes));
+ DEBUG_printf(("8ipp_read_http: Returning " CUPS_LLFMT " bytes", CUPS_LLCAST tbytes));
return (tbytes);
}
* Reallocate memory...
*/
- if ((temp = realloc(temp, sizeof(ipp_attribute_t) +
- (alloc_values - 1) * sizeof(_ipp_value_t))) == NULL)
+ if ((temp = realloc(temp, sizeof(ipp_attribute_t) + (size_t)(alloc_values - 1) * sizeof(_ipp_value_t))) == NULL)
{
_cupsSetHTTPError(HTTP_STATUS_ERROR);
DEBUG_puts("4ipp_set_value: Unable to resize attribute.");
* Zero the new memory...
*/
- memset(temp->values + temp->num_values, 0,
- (alloc_values - temp->num_values) * sizeof(_ipp_value_t));
+ memset(temp->values + temp->num_values, 0, (size_t)(alloc_values - temp->num_values) * sizeof(_ipp_value_t));
if (temp != *attr)
{
# define IPP_MAX_URISCHEME 64 /* Maximum length of uriScheme values w/nul */
# define IPP_MAX_VALUES 8 /* Power-of-2 allocation increment */
+/*
+ * Macro to flag a text string attribute as "const" (static storage) vs.
+ * allocated.
+ */
+
+# define IPP_CONST_TAG(x) (ipp_tag_t)(IPP_TAG_CUPS_CONST | (x))
+
/*
* Types and structures...
/*
* "$Id$"
*
- * Localized printf/puts functions for CUPS.
+ * Localized printf/puts functions for CUPS.
*
- * Copyright 2007-2012 by Apple Inc.
- * Copyright 2002-2007 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 2002-2007 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * _cupsLangPrintError() - Print a message followed by a standard error.
- * _cupsLangPrintFilter() - Print a formatted filter message string to a file.
- * _cupsLangPrintf() - Print a formatted message string to a file.
- * _cupsLangPuts() - Print a static message string to a file.
- * _cupsSetLocale() - Set the current locale and transcode the
- * command-line.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
_cupsLangPrintError(const char *prefix, /* I - Non-localized message prefix */
const char *message)/* I - Message */
{
- int bytes; /* Number of bytes formatted */
+ ssize_t bytes; /* Number of bytes formatted */
int last_errno; /* Last error */
char buffer[2048], /* Message buffer */
*bufptr, /* Pointer into buffer */
else
bufptr = buffer;
- snprintf(bufptr, sizeof(buffer) - (bufptr - buffer),
+ snprintf(bufptr, sizeof(buffer) - (size_t)(bufptr - buffer),
/* TRANSLATORS: Message is "subject: error" */
_cupsLangString(cg->lang_default, _("%s: %s")),
_cupsLangString(cg->lang_default, message), strerror(last_errno));
cg->lang_default->encoding);
if (bytes > 0)
- fwrite(output, 1, bytes, stderr);
+ fwrite(output, 1, (size_t)bytes, stderr);
}
const char *message, /* I - Message string to use */
...) /* I - Additional arguments as needed */
{
- int bytes; /* Number of bytes formatted */
+ ssize_t bytes; /* Number of bytes formatted */
char temp[2048], /* Temporary format buffer */
buffer[2048], /* Message buffer */
output[8192]; /* Output buffer */
*/
if (bytes > 0)
- return ((int)fwrite(output, 1, bytes, fp));
+ return ((int)fwrite(output, 1, (size_t)bytes, fp));
else
- return (bytes);
+ return ((int)bytes);
}
const char *message, /* I - Message string to use */
...) /* I - Additional arguments as needed */
{
- int bytes; /* Number of bytes formatted */
+ ssize_t bytes; /* Number of bytes formatted */
char buffer[2048], /* Message buffer */
output[8192]; /* Output buffer */
va_list ap; /* Pointer to additional arguments */
*/
if (bytes > 0)
- return ((int)fwrite(output, 1, bytes, fp));
+ return ((int)fwrite(output, 1, (size_t)bytes, fp));
else
- return (bytes);
+ return ((int)bytes);
}
_cupsLangPuts(FILE *fp, /* I - File to write to */
const char *message) /* I - Message string to use */
{
- int bytes; /* Number of bytes formatted */
+ ssize_t bytes; /* Number of bytes formatted */
char output[8192]; /* Message buffer */
_cups_globals_t *cg; /* Global data */
(cups_utf8_t *)_cupsLangString(cg->lang_default,
message),
sizeof(output) - 4, cg->lang_default->encoding);
- bytes += cupsUTF8ToCharset(output + bytes, (cups_utf8_t *)"\n",
- sizeof(output) - bytes,
- cg->lang_default->encoding);
+ bytes += cupsUTF8ToCharset(output + bytes, (cups_utf8_t *)"\n", (int)(sizeof(output) - (size_t)bytes), cg->lang_default->encoding);
/*
* Write the string and return the number of bytes written...
*/
if (bytes > 0)
- return ((int)fwrite(output, 1, bytes, fp));
+ return ((int)fwrite(output, 1, (size_t)bytes, fp));
else
- return (bytes);
+ return ((int)bytes);
}
if ((charset = strchr(new_lc_time, '.')) == NULL)
charset = new_lc_time + strlen(new_lc_time);
- strlcpy(charset, ".UTF-8", sizeof(new_lc_time) - (charset - new_lc_time));
+ strlcpy(charset, ".UTF-8", sizeof(new_lc_time) - (size_t)(charset - new_lc_time));
}
else
strlcpy(new_lc_time, "C", sizeof(new_lc_time));
/*
* "$Id$"
*
- * I18N/language support for CUPS.
+ * I18N/language support for CUPS.
*
- * Copyright 2007-2012 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2007 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * _cupsAppleLanguage() - Get the Apple language identifier associated with
- * a locale ID.
- * _cupsEncodingName() - Return the character encoding name string for the
- * given encoding enumeration.
- * cupsLangDefault() - Return the default language.
- * cupsLangEncoding() - Return the character encoding (us-ascii, etc.)
- * for the given language.
- * cupsLangFlush() - Flush all language data out of the cache.
- * cupsLangFree() - Free language data.
- * cupsLangGet() - Get a language.
- * _cupsLangString() - Get a message string.
- * _cupsMessageFree() - Free a messages array.
- * _cupsMessageLoad() - Load a .po file into a messages array.
- * _cupsMessageLookup() - Lookup a message string.
- * _cupsMessageNew() - Make a new message catalog array.
- * appleLangDefault() - Get the default locale string.
- * appleMessageLoad() - Load a message catalog from a localizable bundle.
- * cups_cache_lookup() - Lookup a language in the cache...
- * cups_message_compare() - Compare two messages.
- * cups_message_free() - Free a message.
- * cups_message_load() - Load the message catalog for a language.
- * cups_unquote() - Unquote characters in strings...
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
*/
language[2] = '_';
- language[3] = toupper(language[3] & 255);
- language[4] = toupper(language[4] & 255);
+ language[3] = (char)toupper(language[3] & 255);
+ language[4] = (char)toupper(language[4] & 255);
}
break;
}
if ((langid = CFLocaleCreateCanonicalLanguageIdentifierFromString(
kCFAllocatorDefault, localeid)) != NULL)
{
- CFStringGetCString(langid, language, langsize, kCFStringEncodingASCII);
+ CFStringGetCString(langid, language, (CFIndex)langsize, kCFStringEncodingASCII);
CFRelease(langid);
}
_cupsEncodingName(
cups_encoding_t encoding) /* I - Encoding value */
{
- if (encoding < 0 ||
- encoding >= (sizeof(lang_encodings) / sizeof(const char *)))
+ if (encoding < CUPS_US_ASCII ||
+ encoding >= (cups_encoding_t)(sizeof(lang_encodings) / sizeof(lang_encodings[0])))
{
DEBUG_printf(("1_cupsEncodingName(encoding=%d) = out of range (\"%s\")",
encoding, lang_encodings[0]));
if (*language == '_' || *language == '-' || *language == '.')
break;
else if (ptr < (langname + sizeof(langname) - 1))
- *ptr++ = tolower(*language & 255);
+ *ptr++ = (char)tolower(*language & 255);
*ptr = '\0';
if (*language == '.')
break;
else if (ptr < (country + sizeof(country) - 1))
- *ptr++ = toupper(*language & 255);
+ *ptr++ = (char)toupper(*language & 255);
*ptr = '\0';
}
for (language ++, ptr = charset; *language; language ++)
if (_cups_isalnum(*language) && ptr < (charset + sizeof(charset) - 1))
- *ptr++ = toupper(*language & 255);
+ *ptr++ = (char)toupper(*language & 255);
*ptr = '\0';
}
char s[4096], /* String buffer */
*ptr, /* Pointer into buffer */
*temp; /* New string */
- int length; /* Length of combined strings */
- size_t ptrlen; /* Length of string */
+ size_t length, /* Length of combined strings */
+ ptrlen; /* Length of string */
DEBUG_printf(("4_cupsMessageLoad(filename=\"%s\")", filename));
* Append to current string...
*/
- length = (int)strlen(m->str ? m->str : m->id);
+ length = strlen(m->str ? m->str : m->id);
ptrlen = strlen(ptr);
- if ((temp = realloc(m->str ? m->str : m->id,
- length + ptrlen + 1)) == NULL)
+ if ((temp = realloc(m->str ? m->str : m->id, length + ptrlen + 1)) == NULL)
{
if (m->str)
free(m->str);
url = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault,
(UInt8 *)filename,
- strlen(filename), false);
+ (CFIndex)strlen(filename), false);
if (url)
{
stream = CFReadStreamCreateWithFile(kCFAllocatorDefault, url);
/*
* "$Id$"
*
- * PPD localization routines for CUPS.
+ * PPD localization routines for CUPS.
*
- * Copyright 2007-2012 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products, all rights reserved.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * PostScript is a trademark of Adobe Systems, Inc.
+ * PostScript is a trademark of Adobe Systems, Inc.
*
- * This code and any derivative of it may be used and distributed
- * freely under the terms of the GNU General Public License when
- * used with GNU Ghostscript or its derivatives. Use of the code
- * (or any derivative of it) with software other than GNU
- * GhostScript (or its derivatives) is governed by the CUPS license
- * agreement.
+ * This code and any derivative of it may be used and distributed
+ * freely under the terms of the GNU General Public License when
+ * used with GNU Ghostscript or its derivatives. Use of the code
+ * (or any derivative of it) with software other than GNU
+ * GhostScript (or its derivatives) is governed by the CUPS license
+ * agreement.
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * ppdLocalize() - Localize the PPD file to the current locale.
- * ppdLocalizeAttr() - Localize an attribute.
- * ppdLocalizeIPPReason() - Get the localized version of a cupsIPPReason
- * attribute.
- * ppdLocalizeMarkerName() - Get the localized version of a marker-names
- * attribute value.
- * _ppdFreeLanguages() - Free an array of languages from _ppdGetLanguages.
- * _ppdGetLanguages() - Get an array of languages from a PPD file.
- * _ppdHashName() - Generate a hash value for a device or profile
- * name.
- * _ppdLocalizedAttr() - Find a localized attribute.
- * ppd_ll_CC() - Get the current locale names.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
*bufptr, /* Pointer into buffer */
*bufend, /* Pointer to end of buffer */
*valptr; /* Pointer into value */
- int ch, /* Hex-encoded character */
- schemelen; /* Length of scheme name */
+ int ch; /* Hex-encoded character */
+ size_t schemelen; /* Length of scheme name */
/*
valptr ++;
if (isdigit(*valptr & 255))
- *bufptr++ = ch | (*valptr - '0');
+ *bufptr++ = (char)(ch | (*valptr - '0'));
else
- *bufptr++ = ch | (tolower(*valptr) - 'a' + 10);
+ *bufptr++ = (char)(ch | (tolower(*valptr) - 'a' + 10));
valptr ++;
}
else if (*valptr == '+')
unsigned /* O - Hash value */
_ppdHashName(const char *name) /* I - Name to hash */
{
- int mult; /* Multiplier */
- unsigned hash = 0; /* Hash value */
+ unsigned mult, /* Multiplier */
+ hash = 0; /* Hash value */
for (mult = 1; *name && mult <= 128; mult ++, name ++)
/*
* "$Id$"
*
- * Option marking routines for CUPS.
+ * Option marking routines for CUPS.
*
- * Copyright 2007-2012 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products, all rights reserved.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * PostScript is a trademark of Adobe Systems, Inc.
+ * PostScript is a trademark of Adobe Systems, Inc.
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * cupsMarkOptions() - Mark command-line options in a PPD file.
- * ppdFindChoice() - Return a pointer to an option choice.
- * ppdFindMarkedChoice() - Return the marked choice for the specified option.
- * ppdFindOption() - Return a pointer to the specified option.
- * ppdIsMarked() - Check to see if an option is marked.
- * ppdMarkDefaults() - Mark all default options in the PPD file.
- * ppdMarkOption() - Mark an option in a PPD file and return the number
- * of conflicts.
- * ppdFirstOption() - Return the first option in the PPD file.
- * ppdNextOption() - Return the next option in the PPD file.
- * _ppdParseOptions() - Parse options from a PPD file.
- * ppd_debug_marked() - Output the marked array to stdout...
- * ppd_defaults() - Set the defaults for this group and all sub-groups.
- * ppd_mark_choices() - Mark one or more option choices from a string.
- * ppd_mark_option() - Quickly mark an option without checking for
- * conflicts.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
* Extract the sub-option from the string...
*/
- for (ptr = s; *val && *val != ',' && (ptr - s) < (sizeof(s) - 1);)
+ for (ptr = s; *val && *val != ',' && (size_t)(ptr - s) < (sizeof(s) - 1);)
*ptr++ = *val++;
*ptr++ = '\0';
if (print_quality)
{
- pwg_pq = atoi(print_quality) - IPP_QUALITY_DRAFT;
+ pwg_pq = (_pwg_print_quality_t)(atoi(print_quality) - IPP_QUALITY_DRAFT);
if (pwg_pq < _PWG_PRINT_QUALITY_DRAFT)
pwg_pq = _PWG_PRINT_QUALITY_DRAFT;
else if (pwg_pq > _PWG_PRINT_QUALITY_HIGH)
if (!isdigit(*ptr & 255))
break;
- if ((j = strtol(ptr, &ptr, 10)) < 3)
+ if ((j = (int)strtol(ptr, &ptr, 10)) < 3)
break;
/*
*
* Private MD5 implementation for CUPS.
*
- * Copyright 2007-2013 by Apple Inc.
+ * Copyright 2007-2014 by Apple Inc.
* Copyright 2005 by Easy Software Products
* Copyright (C) 1999 Aladdin Enterprises. All rights reserved.
*
return;
/* Update the message length. */
- pms->count[1] += nbytes >> 29;
+ pms->count[1] += (unsigned)nbytes >> 29;
pms->count[0] += nbits;
if (pms->count[0] < nbits)
pms->count[1]++;
/*
* "$Id$"
*
- * Option routines for CUPS.
+ * Option routines for CUPS.
*
- * Copyright 2007-2012 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2007 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * cupsAddOption() - Add an option to an option array.
- * cupsFreeOptions() - Free all memory used by options.
- * cupsGetOption() - Get an option value.
- * cupsParseOptions() - Parse options from a command-line argument.
- * cupsRemoveOption() - Remove an option from an option array.
- * _cupsGet1284Values() - Get 1284 device ID keys and values.
- * cups_compare_options() - Compare two options.
- * cups_find_option() - Find an option using a binary search.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
if (num_options == 0)
temp = (cups_option_t *)malloc(sizeof(cups_option_t));
else
- temp = (cups_option_t *)realloc(*options, sizeof(cups_option_t) *
- (num_options + 1));
+ temp = (cups_option_t *)realloc(*options, sizeof(cups_option_t) * (size_t)(num_options + 1));
- if (temp == NULL)
+ if (!temp)
{
DEBUG_puts("3cupsAddOption: Unable to expand option array, returning 0");
return (0);
{
DEBUG_printf(("4cupsAddOption: Shifting %d options...",
(int)(num_options - insert)));
- memmove(temp + insert + 1, temp + insert,
- (num_options - insert) * sizeof(cups_option_t));
+ memmove(temp + insert + 1, temp + insert, (size_t)(num_options - insert) * sizeof(cups_option_t));
}
temp += insert;
_cupsStrFree(option->value);
if (i > 0)
- memmove(option, option + 1, i * sizeof(cups_option_t));
+ memmove(option, option + 1, (size_t)i * sizeof(cups_option_t));
}
/*
/*
* "$Id$"
*
- * PPD cache implementation for CUPS.
+ * PPD cache implementation for CUPS.
*
- * Copyright 2010-2013 by Apple Inc.
+ * Copyright 2010-2014 by Apple Inc.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * _ppdCacheCreateWithFile() - Create PPD cache and mapping data from a
- * written file.
- * _ppdCacheCreateWithPPD() - Create PWG mapping data from a PPD file.
- * _ppdCacheDestroy() - Free all memory used for PWG mapping data.
- * _ppdCacheGetBin() - Get the PWG output-bin keyword associated with
- * a PPD OutputBin.
- * _ppdCacheGetInputSlot() - Get the PPD InputSlot associated with the job
- * attributes or a keyword string.
- * _ppdCacheGetMediaType() - Get the PPD MediaType associated with the job
- * attributes or a keyword string.
- * _ppdCacheGetOutputBin() - Get the PPD OutputBin associated with the
- * keyword string.
- * _ppdCacheGetPageSize() - Get the PPD PageSize associated with the job
- * attributes or a keyword string.
- * _ppdCacheGetSize() - Get the PWG size associated with a PPD
- * PageSize.
- * _ppdCacheGetSource() - Get the PWG media-source associated with a PPD
- * InputSlot.
- * _ppdCacheGetType() - Get the PWG media-type associated with a PPD
- * MediaType.
- * _ppdCacheWriteFile() - Write PWG mapping data to a file.
- * _pwgInputSlotForSource() - Get the InputSlot name for the given PWG
- * media-source.
- * _pwgMediaTypeForType() - Get the MediaType name for the given PWG
- * media-type.
- * _pwgPageSizeForMedia() - Get the PageSize name for the given media.
- * pwg_ppdize_name() - Convert an IPP keyword to a PPD keyword.
- * pwg_unppdize_name() - Convert a PPD keyword to a lowercase IPP
- * keyword.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
goto create_error;
}
- if ((pc->bins = calloc(num_bins, sizeof(pwg_map_t))) == NULL)
+ if ((pc->bins = calloc((size_t)num_bins, sizeof(pwg_map_t))) == NULL)
{
DEBUG_printf(("_ppdCacheCreateWithFile: Unable to allocate %d bins.",
num_sizes));
if (num_sizes > 0)
{
- if ((pc->sizes = calloc(num_sizes, sizeof(pwg_size_t))) == NULL)
+ if ((pc->sizes = calloc((size_t)num_sizes, sizeof(pwg_size_t))) == NULL)
{
DEBUG_printf(("_ppdCacheCreateWithFile: Unable to allocate %d sizes.",
num_sizes));
goto create_error;
}
- if ((pc->sources = calloc(num_sources, sizeof(pwg_map_t))) == NULL)
+ if ((pc->sources = calloc((size_t)num_sources, sizeof(pwg_map_t))) == NULL)
{
DEBUG_printf(("_ppdCacheCreateWithFile: Unable to allocate %d sources.",
num_sources));
goto create_error;
}
- if ((pc->types = calloc(num_types, sizeof(pwg_map_t))) == NULL)
+ if ((pc->types = calloc((size_t)num_types, sizeof(pwg_map_t))) == NULL)
{
DEBUG_printf(("_ppdCacheCreateWithFile: Unable to allocate %d types.",
num_types));
if ((finishings = calloc(1, sizeof(_pwg_finishings_t))) == NULL)
goto create_error;
- finishings->value = strtol(value, &valueptr, 10);
+ finishings->value = (ipp_finishings_t)strtol(value, &valueptr, 10);
finishings->num_options = cupsParseOptions(valueptr, 0,
&(finishings->options));
if (ppd->num_sizes > 0)
{
- if ((pc->sizes = calloc(ppd->num_sizes, sizeof(pwg_size_t))) == NULL)
+ if ((pc->sizes = calloc((size_t)ppd->num_sizes, sizeof(pwg_size_t))) == NULL)
{
DEBUG_printf(("_ppdCacheCreateWithPPD: Unable to allocate %d "
"pwg_size_t's.", ppd->num_sizes));
{
pc->source_option = _cupsStrAlloc(input_slot->keyword);
- if ((pc->sources = calloc(input_slot->num_choices,
- sizeof(pwg_map_t))) == NULL)
+ if ((pc->sources = calloc((size_t)input_slot->num_choices, sizeof(pwg_map_t))) == NULL)
{
DEBUG_printf(("_ppdCacheCreateWithPPD: Unable to allocate %d "
"pwg_map_t's for InputSlot.", input_slot->num_choices));
if ((media_type = ppdFindOption(ppd, "MediaType")) != NULL)
{
- if ((pc->types = calloc(media_type->num_choices,
- sizeof(pwg_map_t))) == NULL)
+ if ((pc->types = calloc((size_t)media_type->num_choices, sizeof(pwg_map_t))) == NULL)
{
DEBUG_printf(("_ppdCacheCreateWithPPD: Unable to allocate %d "
"pwg_map_t's for MediaType.", media_type->num_choices));
if ((output_bin = ppdFindOption(ppd, "OutputBin")) != NULL)
{
- if ((pc->bins = calloc(output_bin->num_choices,
- sizeof(pwg_map_t))) == NULL)
+ if ((pc->bins = calloc((size_t)output_bin->num_choices, sizeof(pwg_map_t))) == NULL)
{
DEBUG_printf(("_ppdCacheCreateWithPPD: Unable to allocate %d "
"pwg_map_t's for OutputBin.", output_bin->num_choices));
num_options = pc->num_presets[_PWG_PRINT_COLOR_MODE_COLOR]
[pwg_print_quality];
- options = calloc(sizeof(cups_option_t), num_options);
+ options = calloc(sizeof(cups_option_t), (size_t)num_options);
if (options)
{
if ((finishings = calloc(1, sizeof(_pwg_finishings_t))) == NULL)
goto create_error;
- finishings->value = atoi(ppd_attr->spec);
+ finishings->value = (ipp_finishings_t)atoi(ppd_attr->spec);
finishings->num_options = _ppdParseOptions(ppd_attr->value, 0,
&(finishings->options),
_PPD_PARSE_OPTIONS);
for (i = 0; i < num_values; i ++)
{
- key.value = ippGetInteger(attr, i);
+ key.value = (ipp_finishings_t)ippGetInteger(attr, i);
if ((f = cupsArrayFind(pc->finishings, &key)) != NULL)
{
*end; /* End of name buffer */
- *name = toupper(*ipp++);
+ *name = (char)toupper(*ipp++);
for (ptr = name + 1, end = name + namesize - 1; *ipp && ptr < end;)
{
if (*ipp == '-' && _cups_isalpha(ipp[1]))
{
ipp ++;
- *ptr++ = toupper(*ipp++ & 255);
+ *ptr++ = (char)toupper(*ipp++ & 255);
}
else
*ptr++ = *ipp++;
for (ptr = name, end = name + namesize - 1; *ppd && ptr < end; ppd ++)
{
if (_cups_isalnum(*ppd) || *ppd == '-')
- *ptr++ = tolower(*ppd & 255);
+ *ptr++ = (char)tolower(*ppd & 255);
else if (strchr(dashchars, *ppd))
*ptr++ = '-';
else
/*
* "$Id$"
*
- * Private PPD definitions for CUPS.
+ * Private PPD definitions for CUPS.
*
- * Copyright 2007-2013 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products, all rights reserved.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * PostScript is a trademark of Adobe Systems, Inc.
+ * PostScript is a trademark of Adobe Systems, Inc.
*
- * This code and any derivative of it may be used and distributed
- * freely under the terms of the GNU General Public License when
- * used with GNU Ghostscript or its derivatives. Use of the code
- * (or any derivative of it) with software other than GNU
- * GhostScript (or its derivatives) is governed by the CUPS license
- * agreement.
+ * This code and any derivative of it may be used and distributed
+ * freely under the terms of the GNU General Public License when
+ * used with GNU Ghostscript or its derivatives. Use of the code
+ * (or any derivative of it) with software other than GNU
+ * GhostScript (or its derivatives) is governed by the CUPS license
+ * agreement.
*
- * This file is subject to the Apple OS-Developed Software exception.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
#ifndef _CUPS_PPD_PRIVATE_H_
/*
* "$Id$"
*
- * PPD file routines for CUPS.
+ * PPD file routines for CUPS.
*
- * Copyright 2007-2012 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products, all rights reserved.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * PostScript is a trademark of Adobe Systems, Inc.
+ * PostScript is a trademark of Adobe Systems, Inc.
*
- * This code and any derivative of it may be used and distributed
- * freely under the terms of the GNU General Public License when
- * used with GNU Ghostscript or its derivatives. Use of the code
- * (or any derivative of it) with software other than GNU
- * GhostScript (or its derivatives) is governed by the CUPS license
- * agreement.
+ * This code and any derivative of it may be used and distributed
+ * freely under the terms of the GNU General Public License when
+ * used with GNU Ghostscript or its derivatives. Use of the code
+ * (or any derivative of it) with software other than GNU
+ * GhostScript (or its derivatives) is governed by the CUPS license
+ * agreement.
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * ppdClose() - Free all memory used by the PPD file.
- * ppdErrorString() - Returns the text assocated with a status.
- * _ppdGetEncoding() - Get the CUPS encoding value for the given
- * LanguageEncoding.
- * ppdLastError() - Return the status from the last ppdOpen*().
- * ppdOpen() - Read a PPD file into memory.
- * _ppdOpen() - Read a PPD file into memory.
- * ppdOpen2() - Read a PPD file into memory.
- * ppdOpenFd() - Read a PPD file into memory.
- * _ppdOpenFile() - Read a PPD file into memory.
- * ppdOpenFile() - Read a PPD file into memory.
- * ppdSetConformance() - Set the conformance level for PPD files.
- * ppd_add_attr() - Add an attribute to the PPD data.
- * ppd_add_choice() - Add a choice to an option.
- * ppd_add_size() - Add a page size.
- * ppd_compare_attrs() - Compare two attributes.
- * ppd_compare_choices() - Compare two choices...
- * ppd_compare_coptions() - Compare two custom options.
- * ppd_compare_options() - Compare two options.
- * ppd_decode() - Decode a string value...
- * ppd_free_filters() - Free the filters array.
- * ppd_free_group() - Free a single UI group.
- * ppd_free_option() - Free a single option.
- * ppd_get_coption() - Get a custom option record.
- * ppd_get_cparam() - Get a custom parameter record.
- * ppd_get_group() - Find or create the named group as needed.
- * ppd_get_option() - Find or create the named option as needed.
- * ppd_hash_option() - Generate a hash of the option name...
- * ppd_read() - Read a line from a PPD file, skipping comment
- * lines as necessary.
- * ppd_update_filters() - Update the filters array as needed.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
* Definitions...
*/
-#if defined(WIN32) || defined(__EMX__)
-# define READ_BINARY "rb" /* Open a binary file for reading */
-# define WRITE_BINARY "wb" /* Open a binary file for writing */
-#else
-# define READ_BINARY "r" /* Open a binary file for reading */
-# define WRITE_BINARY "w" /* Open a binary file for writing */
-#endif /* WIN32 || __EMX__ */
-
#define ppd_free(p) if (p) free(p) /* Safe free macro */
#define PPD_KEYWORD 1 /* Line contained a keyword */
if (ppd->num_profiles == 0)
profile = malloc(sizeof(ppd_profile_t));
else
- profile = realloc(ppd->profiles, sizeof(ppd_profile_t) *
- (ppd->num_profiles + 1));
+ profile = realloc(ppd->profiles, sizeof(ppd_profile_t) * (size_t)(ppd->num_profiles + 1));
if (!profile)
{
if (ppd->num_filters == 0)
filter = malloc(sizeof(char *));
else
- filter = realloc(ppd->filters, sizeof(char *) * (ppd->num_filters + 1));
+ filter = realloc(ppd->filters, sizeof(char *) * (size_t)(ppd->num_filters + 1));
if (filter == NULL)
{
if (ppd->num_fonts == 0)
tempfonts = (char **)malloc(sizeof(char *));
else
- tempfonts = (char **)realloc(ppd->fonts,
- sizeof(char *) * (ppd->num_fonts + 1));
+ tempfonts = (char **)realloc(ppd->fonts, sizeof(char *) * (size_t)(ppd->num_fonts + 1));
if (tempfonts == NULL)
{
}
ppd->num_emulations = count;
- if ((ppd->emulations = calloc(count, sizeof(ppd_emul_t))) == NULL)
+ if ((ppd->emulations = calloc((size_t)count, sizeof(ppd_emul_t))) == NULL)
{
cg->ppd_status = PPD_ALLOC_ERROR;
if (ppd->num_consts == 0)
constraint = calloc(2, sizeof(ppd_const_t));
else
- constraint = realloc(ppd->consts,
- (ppd->num_consts + 2) * sizeof(ppd_const_t));
+ constraint = realloc(ppd->consts, (size_t)(ppd->num_consts + 2) * sizeof(ppd_const_t));
if (constraint == NULL)
{
if (ppd->num_attrs == 0)
ptr = malloc(sizeof(ppd_attr_t *));
else
- ptr = realloc(ppd->attrs, (ppd->num_attrs + 1) * sizeof(ppd_attr_t *));
+ ptr = realloc(ppd->attrs, (size_t)(ppd->num_attrs + 1) * sizeof(ppd_attr_t *));
if (ptr == NULL)
return (NULL);
if (option->num_choices == 0)
choice = malloc(sizeof(ppd_choice_t));
else
- choice = realloc(option->choices,
- sizeof(ppd_choice_t) * (option->num_choices + 1));
+ choice = realloc(option->choices, sizeof(ppd_choice_t) * (size_t)(option->num_choices + 1));
if (choice == NULL)
return (NULL);
if (ppd->num_sizes == 0)
size = malloc(sizeof(ppd_size_t));
else
- size = realloc(ppd->sizes, sizeof(ppd_size_t) * (ppd->num_sizes + 1));
+ size = realloc(ppd->sizes, sizeof(ppd_size_t) * (size_t)(ppd->num_sizes + 1));
if (size == NULL)
return (NULL);
while (isxdigit(*inptr & 255))
{
if (_cups_isalpha(*inptr))
- *outptr = (tolower(*inptr) - 'a' + 10) << 4;
+ *outptr = (char)((tolower(*inptr) - 'a' + 10) << 4);
else
- *outptr = (*inptr - '0') << 4;
+ *outptr = (char)((*inptr - '0') << 4);
inptr ++;
break;
if (_cups_isalpha(*inptr))
- *outptr |= tolower(*inptr) - 'a' + 10;
+ *outptr |= (char)(tolower(*inptr) - 'a' + 10);
else
- *outptr |= *inptr - '0';
+ *outptr |= (char)(*inptr - '0');
inptr ++;
outptr ++;
if (ppd->num_groups == 0)
group = malloc(sizeof(ppd_group_t));
else
- group = realloc(ppd->groups,
- (ppd->num_groups + 1) * sizeof(ppd_group_t));
+ group = realloc(ppd->groups, (size_t)(ppd->num_groups + 1) * sizeof(ppd_group_t));
if (group == NULL)
{
if (group->num_options == 0)
option = malloc(sizeof(ppd_option_t));
else
- option = realloc(group->options,
- (group->num_options + 1) * sizeof(ppd_option_t));
+ option = realloc(group->options, (size_t)(group->num_options + 1) * sizeof(ppd_option_t));
if (option == NULL)
return (NULL);
* Any other character...
*/
- *lineptr++ = ch;
+ *lineptr++ = (char)ch;
col ++;
if (col > (PPD_MAX_LINE - 1))
if (ppd->num_filters == 0)
filter = malloc(sizeof(char *));
else
- filter = realloc(ppd->filters, sizeof(char *) * (ppd->num_filters + 1));
+ filter = realloc(ppd->filters, sizeof(char *) * (size_t)(ppd->num_filters + 1));
if (filter == NULL)
{
/*
* "$Id$"
*
- * PWG media name API implementation for CUPS.
+ * PWG media name API implementation for CUPS.
*
- * Copyright 2009-2013 by Apple Inc.
+ * Copyright 2009-2014 by Apple Inc.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * pwgFormatSizeName() - Generate a PWG self-describing media size name.
- * pwgInitSize() - Initialize a pwg_size_t structure using IPP Job
- * Template attributes.
- * pwgMediaForLegacy() - Find a PWG media size by ISO/IPP legacy name.
- * pwgMediaForPPD() - Find a PWG media size by Adobe PPD name.
- * pwgMediaForPWG() - Find a PWG media size by 5101.1 self-describing
- * name.
- * pwgMediaForSize() - Get the PWG media size for the given
- * dimensions.
- * _pwgMediaTable() - Return the internal media size table.
- * pwg_compare_legacy() - Compare two sizes using the legacy names.
- * pwg_compare_ppd() - Compare two sizes using the PPD names.
- * pwg_compare_pwg() - Compare two sizes using the PWG names.
- * pwg_format_inches() - Convert and format PWG units as inches.
- * pwg_format_millimeters() - Convert and format PWG units as millimeters.
- * pwg_scan_measurement() - Scan a measurement in inches or millimeters.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
*/
uptr = usize;
- (*format)(uptr, sizeof(usize) - (uptr - usize), width);
+ (*format)(uptr, sizeof(usize) - (size_t)(uptr - usize), width);
uptr += strlen(uptr);
*uptr++ = 'x';
- (*format)(uptr, sizeof(usize) - (uptr - usize), length);
+ (*format)(uptr, sizeof(usize) - (size_t)(uptr - usize), length);
uptr += strlen(uptr);
/*
/*
* "$Id$"
*
- * IPP utilities for CUPS.
+ * IPP utilities for CUPS.
*
- * Copyright 2007-2013 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2007 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * cupsDoFileRequest() - Do an IPP request with a file.
- * cupsDoIORequest() - Do an IPP request with file descriptors.
- * cupsDoRequest() - Do an IPP request.
- * cupsGetResponse() - Get a response to an IPP request.
- * cupsLastError() - Return the last IPP status code.
- * cupsLastErrorString() - Return the last IPP status-message.
- * _cupsNextDelay() - Return the next retry delay value.
- * cupsReadResponseData() - Read additional data after the IPP response.
- * cupsSendRequest() - Send an IPP request.
- * cupsWriteRequestData() - Write additional data after an IPP request.
- * _cupsConnect() - Get the default server connection...
- * _cupsSetError() - Set the last IPP status code and status-message.
- * _cupsSetHTTPError() - Set the last error using the HTTP status.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
size_t length = 0; /* Content-Length value */
http_status_t status; /* Status of HTTP request */
struct stat fileinfo; /* File information */
- int bytes; /* Number of bytes read/written */
+ ssize_t bytes; /* Number of bytes read/written */
char buffer[32768]; /* Output buffer */
length = 0; /* Chunk when piping */
else
#endif /* !WIN32 */
- length = ippLength(request) + fileinfo.st_size;
+ length = ippLength(request) + (size_t)fileinfo.st_size;
}
else
length = ippLength(request);
#endif /* WIN32 */
lseek(infile, 0, SEEK_SET);
- while ((bytes = (int)read(infile, buffer, sizeof(buffer))) > 0)
+ while ((bytes = read(infile, buffer, sizeof(buffer))) > 0)
{
- if ((status = cupsWriteRequestData(http, buffer, bytes))
+ if ((status = cupsWriteRequestData(http, buffer, (size_t)bytes))
!= HTTP_STATUS_CONTINUE)
break;
}
* Write trailing data to file...
*/
- while ((bytes = (int)httpRead2(http, buffer, sizeof(buffer))) > 0)
- if (write(outfile, buffer, bytes) < bytes)
+ while ((bytes = httpRead2(http, buffer, sizeof(buffer))) > 0)
+ if (write(outfile, buffer, (size_t)bytes) < bytes)
break;
}
if (length >= HTTP_MAX_BUFFER ||
http->wused < wused ||
- (wused > 0 && http->wused == length))
+ (wused > 0 && (size_t)http->wused == length))
{
/*
* We've written something to the server, so check for response data...
*
* Side-channel API code for CUPS.
*
- * Copyright 2007-2013 by Apple Inc.
+ * Copyright 2007-2014 by Apple Inc.
* Copyright 2006 by Easy Software Products.
*
* These coded instructions, statements, and computer programs are the
double timeout) /* I - Timeout in seconds */
{
char *buffer; /* Message buffer */
- int bytes; /* Bytes read */
+ ssize_t bytes; /* Bytes read */
int templen; /* Data length from message */
int nfds; /* Number of file descriptors */
#ifdef HAVE_POLL
pfd.events = POLLIN;
while ((nfds = poll(&pfd, 1,
- timeout < 0.0 ? -1 : (long)(timeout * 1000))) < 0 &&
+ timeout < 0.0 ? -1 : (int)(timeout * 1000))) < 0 &&
(errno == EINTR || errno == EAGAIN))
;
if (bytes < 4)
{
- DEBUG_printf(("1cupsSideChannelRead: Short read of %d bytes", bytes));
+ DEBUG_printf(("1cupsSideChannelRead: Short read of " CUPS_LLFMT " bytes", CUPS_LLCAST bytes));
_cupsBufferRelease(buffer);
* Parse the response of the form "oid\0value"...
*/
- real_oidlen = strlen(real_data) + 1;
+ real_oidlen = (int)strlen(real_data) + 1;
real_datalen -= real_oidlen;
if ((real_datalen + 1) > *datalen)
cups_sc_status_t status; /* Status of command */
cups_sc_command_t rcommand; /* Response command */
char *real_data; /* Real data buffer for response */
- int real_datalen, /* Real length of data buffer */
- real_oidlen, /* Length of returned OID string */
+ int real_datalen; /* Real length of data buffer */
+ size_t real_oidlen, /* Length of returned OID string */
oidlen; /* Length of first OID */
const char *current_oid; /* Current OID */
char last_oid[2048]; /* Last OID */
*/
current_oid = oid;
- oidlen = (int)strlen(oid);
+ oidlen = strlen(oid);
last_oid[0] = '\0';
do
return (CUPS_SC_STATUS_OK);
}
- if (real_datalen < sizeof(real_data))
+ if ((size_t)real_datalen < sizeof(real_data))
real_data[real_datalen] = '\0';
real_oidlen = strlen(real_data) + 1;
double timeout) /* I - Timeout in seconds */
{
char *buffer; /* Message buffer */
- int bytes; /* Bytes written */
+ ssize_t bytes; /* Bytes written */
#ifdef HAVE_POLL
struct pollfd pfd; /* Poll structure for poll() */
#else /* select() */
if (poll(&pfd, 1, -1) < 1)
return (-1);
}
- else if (poll(&pfd, 1, (long)(timeout * 1000)) < 1)
+ else if (poll(&pfd, 1, (int)(timeout * 1000)) < 1)
return (-1);
#else /* select() */
* 4-N Data
*/
- if ((buffer = _cupsBufferGet(datalen + 4)) == NULL)
+ if ((buffer = _cupsBufferGet((size_t)datalen + 4)) == NULL)
return (-1);
buffer[0] = command;
buffer[1] = status;
- buffer[2] = datalen >> 8;
- buffer[3] = datalen & 255;
+ buffer[2] = (char)(datalen >> 8);
+ buffer[3] = (char)(datalen & 255);
bytes = 4;
bytes += datalen;
}
- while (write(CUPS_SC_FD, buffer, bytes) < 0)
+ while (write(CUPS_SC_FD, buffer, (size_t)bytes) < 0)
if (errno != EINTR && errno != EAGAIN)
{
_cupsBufferRelease(buffer);
/*
* "$Id$"
*
- * Private SNMP definitions for CUPS.
+ * Private SNMP definitions for CUPS.
*
- * Copyright 2007-2012 by Apple Inc.
- * Copyright 2006-2007 by Easy Software Products, all rights reserved.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 2006-2007 by Easy Software Products, all rights reserved.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * "LICENSE" which should have been included with this file. If this
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * "LICENSE" which should have been included with this file. If this
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
#ifndef _CUPS_SNMP_PRIVATE_H_
{
unsigned char bytes[CUPS_SNMP_MAX_STRING];
/* Bytes in string */
- int num_bytes; /* Number of bytes */
+ unsigned num_bytes; /* Number of bytes */
} cups_snmp_string_t;
union cups_snmp_value_u /**** Object value ****/
{
int boolean; /* Boolean value */
int integer; /* Integer value */
- unsigned counter; /* Counter value */
+ int counter; /* Counter value */
unsigned gauge; /* Gauge value */
unsigned timeticks; /* Timeticks value */
int oid[CUPS_SNMP_MAX_OID]; /* OID value */
char community[CUPS_SNMP_MAX_COMMUNITY];
/* Community name */
cups_asn1_t request_type; /* Request type */
- int request_id; /* request-id value */
+ unsigned request_id; /* request-id value */
int error_status; /* error-status value */
int error_index; /* error-index value */
int object_name[CUPS_SNMP_MAX_OID];
*
* SNMP functions for CUPS.
*
- * Copyright 2007-2013 by Apple Inc.
+ * Copyright 2007-2014 by Apple Inc.
* Copyright 2006-2007 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
cups_snmp_t *packet);
static int asn1_get_integer(unsigned char **buffer,
unsigned char *bufend,
- int length);
+ unsigned length);
static int asn1_get_oid(unsigned char **buffer,
unsigned char *bufend,
- int length, int *oid, int oidsize);
+ unsigned length, int *oid, int oidsize);
static int asn1_get_packed(unsigned char **buffer,
unsigned char *bufend);
static char *asn1_get_string(unsigned char **buffer,
unsigned char *bufend,
- int length, char *string,
- int strsize);
+ unsigned length, char *string,
+ size_t strsize);
static unsigned asn1_get_length(unsigned char **buffer,
unsigned char *bufend);
static int asn1_get_type(unsigned char **buffer,
const int *oid);
static void asn1_set_packed(unsigned char **buffer,
int integer);
-static int asn1_size_integer(int integer);
-static int asn1_size_length(int length);
-static int asn1_size_oid(const int *oid);
-static int asn1_size_packed(int integer);
+static unsigned asn1_size_integer(int integer);
+static unsigned asn1_size_length(unsigned length);
+static unsigned asn1_size_oid(const int *oid);
+static unsigned asn1_size_packed(int integer);
static void snmp_set_error(cups_snmp_t *packet,
const char *message);
{
unsigned char buffer[CUPS_SNMP_MAX_PACKET];
/* Data packet */
- int bytes; /* Number of bytes received */
+ ssize_t bytes; /* Number of bytes received */
socklen_t addrlen; /* Source address length */
http_addr_t address; /* Source address */
* Look for the response status code in the SNMP message header...
*/
- asn1_debug("DEBUG: IN ", buffer, bytes, 0);
+ asn1_debug("DEBUG: IN ", buffer, (size_t)bytes, 0);
- asn1_decode_snmp(buffer, bytes, packet);
+ asn1_decode_snmp(buffer, (size_t)bytes, packet);
memcpy(&(packet->address), &address, sizeof(packet->address));
void *data) /* I - User data pointer that is passed to the callback function */
{
int count = 0; /* Number of OIDs found */
- int request_id = 0; /* Current request ID */
+ unsigned request_id = 0; /* Current request ID */
cups_snmp_t packet; /* Current response packet */
int lastoid[CUPS_SNMP_MAX_OID];
/* Last OID we got */
cups_snmp_t packet; /* SNMP message packet */
unsigned char buffer[CUPS_SNMP_MAX_PACKET];
/* SNMP message buffer */
- int bytes; /* Size of message */
+ ssize_t bytes; /* Size of message */
http_addr_t temp; /* Copy of address */
return (0);
}
- asn1_debug("DEBUG: OUT ", buffer, bytes, 0);
+ asn1_debug("DEBUG: OUT ", buffer, (size_t)bytes, 0);
/*
* Send the message...
_httpAddrSetPort(&temp, CUPS_SNMP_PORT);
- return (sendto(fd, buffer, bytes, 0, (void *)&temp,
- httpAddrLength(&temp)) == bytes);
+ return (sendto(fd, buffer, (size_t)bytes, 0, (void *)&temp, (socklen_t)httpAddrLength(&temp)) == bytes);
}
size_t len, /* I - Length of buffer */
int indent) /* I - Indentation */
{
- int i; /* Looping var */
+ size_t i; /* Looping var */
unsigned char *bufend; /* End of buffer */
int integer; /* Number value */
int oid[CUPS_SNMP_MAX_OID]; /* OID value */
char string[CUPS_SNMP_MAX_STRING];
/* String value */
unsigned char value_type; /* Type of value */
- int value_length; /* Length of value */
+ unsigned value_length; /* Length of value */
_cups_globals_t *cg = _cupsGlobals(); /* Global data */
* Do a hex dump of the packet...
*/
- int j;
+ size_t j;
fprintf(stderr, "%sHex Dump (%d bytes):\n", prefix, (int)len);
- for (i = 0; i < (int)len; i += 16)
+ for (i = 0; i < len; i += 16)
{
- fprintf(stderr, "%s%04x:", prefix, i);
+ fprintf(stderr, "%s%04x:", prefix, (unsigned)i);
- for (j = 0; j < 16 && (i + j) < (int)len; j ++)
+ for (j = 0; j < 16 && (i + j) < len; j ++)
{
if (j && !(j & 3))
fprintf(stderr, " %02x", buffer[i + j]);
fputs(" ", stderr);
- for (j = 0; j < 16 && (i + j) < (int)len; j ++)
+ for (j = 0; j < 16 && (i + j) < len; j ++)
if (buffer[i + j] < ' ' || buffer[i + j] >= 0x7f)
putc('.', stderr);
else
* Get value type...
*/
- value_type = asn1_get_type(&buffer, bufend);
+ value_type = (unsigned char)asn1_get_type(&buffer, bufend);
value_length = asn1_get_length(&buffer, bufend);
switch (value_type)
fprintf(stderr, "%s%*sOID %d bytes ", prefix, indent, "",
value_length);
- for (i = 0; i < integer; i ++)
+ for (i = 0; i < (unsigned)integer; i ++)
fprintf(stderr, ".%d", oid[i]);
putc('\n', stderr);
break;
{
unsigned char *bufptr, /* Pointer into the data */
*bufend; /* End of data */
- int length; /* Length of value */
+ unsigned length; /* Length of value */
/*
asn1_get_string(&bufptr, bufend, length, packet->community,
sizeof(packet->community));
- if ((packet->request_type = asn1_get_type(&bufptr, bufend))
+ if ((packet->request_type = (cups_asn1_t)asn1_get_type(&bufptr, bufend))
!= CUPS_ASN1_GET_RESPONSE)
snmp_set_error(packet, _("Packet does not contain a Get-Response-PDU"));
else if (asn1_get_length(&bufptr, bufend) == 0)
snmp_set_error(packet, _("request-id uses indefinite length"));
else
{
- packet->request_id = asn1_get_integer(&bufptr, bufend, length);
+ packet->request_id = (unsigned)asn1_get_integer(&bufptr, bufend, length);
if (asn1_get_type(&bufptr, bufend) != CUPS_ASN1_INTEGER)
snmp_set_error(packet, _("No error-status"));
asn1_get_oid(&bufptr, bufend, length, packet->object_name,
CUPS_SNMP_MAX_OID);
- packet->object_type = asn1_get_type(&bufptr, bufend);
+ packet->object_type = (cups_asn1_t)asn1_get_type(&bufptr, bufend);
if ((length = asn1_get_length(&bufptr, bufend)) == 0 &&
packet->object_type != CUPS_ASN1_NULL_VALUE &&
case CUPS_ASN1_GAUGE :
packet->object_value.gauge =
- asn1_get_integer(&bufptr, bufend, length);
+ (unsigned)asn1_get_integer(&bufptr, bufend, length);
break;
case CUPS_ASN1_TIMETICKS :
packet->object_value.timeticks =
- asn1_get_integer(&bufptr, bufend, length);
+ (unsigned)asn1_get_integer(&bufptr, bufend, length);
break;
default :
cups_snmp_t *packet) /* I - SNMP packet */
{
unsigned char *bufptr; /* Pointer into buffer */
- int total, /* Total length */
+ unsigned total, /* Total length */
msglen, /* Length of entire message */
commlen, /* Length of community string */
reqlen, /* Length of request */
varlen = 1 + asn1_size_length(namelen) + namelen +
1 + asn1_size_length(valuelen) + valuelen;
listlen = 1 + asn1_size_length(varlen) + varlen;
- reqlen = 2 + asn1_size_integer(packet->request_id) +
+ reqlen = 2 + asn1_size_integer((int)packet->request_id) +
2 + asn1_size_integer(packet->error_status) +
2 + asn1_size_integer(packet->error_index) +
1 + asn1_size_length(listlen) + listlen;
- commlen = strlen(packet->community);
+ commlen = (unsigned)strlen(packet->community);
msglen = 2 + asn1_size_integer(packet->version) +
1 + asn1_size_length(commlen) + commlen +
1 + asn1_size_length(reqlen) + reqlen;
total = 1 + asn1_size_length(msglen) + msglen;
- if (total > (int)bufsize)
+ if (total > bufsize)
{
packet->error = "Message too large for buffer";
return (-1);
*bufptr++ = packet->request_type; /* Get-Request-PDU/Get-Next-Request-PDU */
asn1_set_length(&bufptr, reqlen);
- asn1_set_integer(&bufptr, packet->request_id);
+ asn1_set_integer(&bufptr, (int)packet->request_id);
asn1_set_integer(&bufptr, packet->error_status);
break;
}
- return (bufptr - buffer);
+ return ((int)(bufptr - buffer));
}
asn1_get_integer(
unsigned char **buffer, /* IO - Pointer in buffer */
unsigned char *bufend, /* I - End of buffer */
- int length) /* I - Length of value */
+ unsigned length) /* I - Length of value */
{
int value; /* Integer value */
asn1_get_oid(
unsigned char **buffer, /* IO - Pointer in buffer */
unsigned char *bufend, /* I - End of buffer */
- int length, /* I - Length of value */
+ unsigned length, /* I - Length of value */
int *oid, /* I - OID buffer */
int oidsize) /* I - Size of OID buffer */
{
*oidptr = -1;
- return (oidptr - oid);
+ return ((int)(oidptr - oid));
}
asn1_get_string(
unsigned char **buffer, /* IO - Pointer in buffer */
unsigned char *bufend, /* I - End of buffer */
- int length, /* I - Value length */
+ unsigned length, /* I - Value length */
char *string, /* I - String buffer */
- int strsize) /* I - String buffer size */
+ size_t strsize) /* I - String buffer size */
{
- if (length > (bufend - *buffer))
- length = bufend - *buffer;
-
- if (length < 0)
- {
- /*
- * Disallow negative lengths!
- */
+ if (length > (unsigned)(bufend - *buffer))
+ length = (unsigned)(bufend - *buffer);
- *string = '\0';
- }
- else if (length < strsize)
+ if (length < strsize)
{
/*
* String is smaller than the buffer...
if (length > 0)
(*buffer) += length;
- return (length < 0 ? NULL : string);
+ return (string);
}
{
**buffer = 4;
(*buffer) ++;
- **buffer = integer >> 24;
+ **buffer = (unsigned char)(integer >> 24);
(*buffer) ++;
- **buffer = integer >> 16;
+ **buffer = (unsigned char)(integer >> 16);
(*buffer) ++;
- **buffer = integer >> 8;
+ **buffer = (unsigned char)(integer >> 8);
(*buffer) ++;
- **buffer = integer;
+ **buffer = (unsigned char)integer;
(*buffer) ++;
}
else if (integer > 0x7fff || integer < -0x8000)
{
**buffer = 3;
(*buffer) ++;
- **buffer = integer >> 16;
+ **buffer = (unsigned char)(integer >> 16);
(*buffer) ++;
- **buffer = integer >> 8;
+ **buffer = (unsigned char)(integer >> 8);
(*buffer) ++;
- **buffer = integer;
+ **buffer = (unsigned char)integer;
(*buffer) ++;
}
else if (integer > 0x7f || integer < -0x80)
{
**buffer = 2;
(*buffer) ++;
- **buffer = integer >> 8;
+ **buffer = (unsigned char)(integer >> 8);
(*buffer) ++;
- **buffer = integer;
+ **buffer = (unsigned char)integer;
(*buffer) ++;
}
else
{
**buffer = 1;
(*buffer) ++;
- **buffer = integer;
+ **buffer = (unsigned char)integer;
(*buffer) ++;
}
}
{
**buffer = 0x82; /* 2-byte length */
(*buffer) ++;
- **buffer = length >> 8;
+ **buffer = (unsigned char)(length >> 8);
(*buffer) ++;
- **buffer = length;
+ **buffer = (unsigned char)length;
(*buffer) ++;
}
else if (length > 127)
{
**buffer = 0x81; /* 1-byte length */
(*buffer) ++;
- **buffer = length;
+ **buffer = (unsigned char)length;
(*buffer) ++;
}
else
{
- **buffer = length; /* Length */
+ **buffer = (unsigned char)length; /* Length */
(*buffer) ++;
}
}
* integer value.
*/
-static int /* O - Size in bytes */
+static unsigned /* O - Size in bytes */
asn1_size_integer(int integer) /* I - Integer value */
{
if (integer > 0x7fffff || integer < -0x800000)
* length value.
*/
-static int /* O - Size in bytes */
-asn1_size_length(int length) /* I - Length value */
+static unsigned /* O - Size in bytes */
+asn1_size_length(unsigned length) /* I - Length value */
{
if (length > 0xff)
return (3);
* OID value.
*/
-static int /* O - Size in bytes */
+static unsigned /* O - Size in bytes */
asn1_size_oid(const int *oid) /* I - OID value */
{
- int length; /* Length of value */
+ unsigned length; /* Length of value */
if (oid[1] < 0)
* packed integer value.
*/
-static int /* O - Size in bytes */
+static unsigned /* O - Size in bytes */
asn1_size_packed(int integer) /* I - Integer value */
{
if (integer > 0xfffffff)
/*
* "$Id$"
*
- * String functions for CUPS.
+ * String functions for CUPS.
*
- * Copyright 2007-2012 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2007 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * _cupsStrAlloc() - Allocate/reference a string.
- * _cupsStrFlush() - Flush the string pool.
- * _cupsStrFormatd() - Format a floating-point number.
- * _cupsStrFree() - Free/dereference a string.
- * _cupsStrRetain() - Increment the reference count of a string.
- * _cupsStrScand() - Scan a string for a floating-point number.
- * _cupsStrStatistics() - Return allocation statistics for string pool.
- * _cups_strcpy() - Copy a string allowing for overlapping strings.
- * _cups_strdup() - Duplicate a string.
- * _cups_strcasecmp() - Do a case-insensitive comparison.
- * _cups_strncasecmp() - Do a case-insensitive comparison on up to N chars.
- * _cups_strlcat() - Safely concatenate two strings.
- * _cups_strlcpy() - Safely copy two strings.
- * compare_sp_items() - Compare two string pool items...
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
if (loc && loc->decimal_point)
{
- strlcpy(tempptr, loc->decimal_point, sizeof(temp) - (tempptr - temp));
+ strlcpy(tempptr, loc->decimal_point, sizeof(temp) - (size_t)(tempptr - temp));
tempptr += strlen(tempptr);
}
else if (tempptr < (temp + sizeof(temp) - 1))
*/
count += item->ref_count;
- len = (strlen(item->str) + 8) & ~7;
+ len = (strlen(item->str) + 8) & (size_t)~7;
abytes += sizeof(_cups_sp_item_t) + len;
tbytes += item->ref_count * len;
}
if (srclen > size)
srclen = size;
- memcpy(dst + dstlen, src, srclen);
+ memmove(dst + dstlen, src, srclen);
dst[dstlen + srclen] = '\0';
return (dstlen + srclen);
if (srclen > size)
srclen = size;
- memcpy(dst, src, srclen);
+ memmove(dst, src, srclen);
dst[srclen] = '\0';
return (srclen);
/*
* "$Id$"
*
- * Array test program for CUPS.
+ * Array test program for CUPS.
*
- * Copyright 2007-2012 by Apple Inc.
- * Copyright 1997-2006 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2006 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * main() - Main entry.
- * get_seconds() - Get the current time in seconds...
- * load_words() - Load words from a file.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
*/
int /* O - Exit status */
-main(int argc, /* I - Number of command-line arguments */
- char *argv[]) /* I - Command-line arguments */
+main(void)
{
int i; /* Looping var */
cups_array_t *array, /* Test array */
{
while ((dent = cupsDirRead(dir)) != NULL)
{
- i = strlen(dent->filename) - 2;
+ i = (int)strlen(dent->filename) - 2;
if (i > 0 && dent->filename[i] == '.' &&
(dent->filename[i + 1] == 'c' ||
/*
* "$Id$"
*
- * CUPS API test program for CUPS.
+ * CUPS API test program for CUPS.
*
- * Copyright 2007-2013 by Apple Inc.
- * Copyright 2007 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 2007 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * main() - Main entry.
- * dests_equal() - Determine whether two destinations are equal.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
{
printf("Writing %d bytes...\n", (int)bytes);
- if (cupsWriteRequestData(CUPS_HTTP_DEFAULT, buffer,
- bytes) != HTTP_STATUS_CONTINUE)
+ if (cupsWriteRequestData(CUPS_HTTP_DEFAULT, buffer, (size_t)bytes) != HTTP_STATUS_CONTINUE)
{
puts("Unable to write bytes!");
return (1);
}
if (interval > 0)
- sleep(interval);
+ sleep((unsigned)interval);
}
cupsFileClose(fp);
cups_option_t *option; /* Current option */
+ (void)user_data;
+
if (flags & CUPS_DEST_FLAGS_REMOVED)
printf("Removed '%s':\n", dest->name);
else
/*
* "$Id$"
*
- * File test program for CUPS.
+ * File test program for CUPS.
*
- * Copyright 2007-2011 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2007 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * main() - Main entry.
- * count_lines() - Count the number of lines in a file.
- * random_tests() - Do random access tests.
- * read_write_tests() - Perform read/write tests.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
count, /* Number of records read */
record, /* Current record */
num_records; /* Number of records */
- ssize_t pos, /* Position in file */
- expected; /* Expected position in file */
+ off_t pos; /* Position in file */
+ ssize_t expected; /* Expected position in file */
cups_file_t *fp; /* File */
char buffer[512]; /* Data buffer */
* cupsFileTell()
*/
- expected = 256 * sizeof(buffer) * pass;
+ expected = 256 * (ssize_t)sizeof(buffer) * pass;
fputs("cupsFileTell(): ", stdout);
- if ((pos = cupsFileTell(fp)) != expected)
+ if ((pos = cupsFileTell(fp)) != (off_t)expected)
{
printf("FAIL (" CUPS_LLFMT " instead of " CUPS_LLFMT ")\n",
CUPS_LLCAST pos, CUPS_LLCAST expected);
for (record = 0; record < 256; record ++)
{
memset(buffer, record, sizeof(buffer));
- if (cupsFileWrite(fp, buffer, sizeof(buffer)) < sizeof(buffer))
+ if (cupsFileWrite(fp, buffer, sizeof(buffer)) < (ssize_t)sizeof(buffer))
break;
}
* cupsFileTell()
*/
- expected += 256 * sizeof(buffer);
+ expected += 256 * (ssize_t)sizeof(buffer);
fputs("cupsFileTell(): ", stdout);
- if ((pos = cupsFileTell(fp)) != expected)
+ if ((pos = cupsFileTell(fp)) != (off_t)expected)
{
printf("FAIL (" CUPS_LLFMT " instead of " CUPS_LLFMT ")\n",
CUPS_LLCAST pos, CUPS_LLCAST expected);
fputs("cupsFileSeek(), cupsFileRead(): ", stdout);
- for (num_records = (pass + 1) * 256, count = (pass + 1) * 256,
- record = CUPS_RAND() % num_records;
+ for (num_records = (pass + 1) * 256, count = (pass + 1) * 256, record = ((int)CUPS_RAND() & 65535) % num_records;
count > 0;
- count --, record = (record + (CUPS_RAND() & 31) - 16 + num_records) %
- num_records)
+ count --, record = (record + ((int)CUPS_RAND() & 31) - 16 + num_records) % num_records)
{
/*
* The last record is always the first...
* contents...
*/
- expected = sizeof(buffer) * record;
+ expected = (ssize_t)sizeof(buffer) * record;
if ((pos = cupsFileSeek(fp, expected)) != expected)
{
unsigned char readbuf[8192], /* Read buffer */
writebuf[8192]; /* Write buffer */
int byte; /* Byte from file */
+ ssize_t bytes; /* Number of bytes read/written */
off_t length; /* Length of file */
static const char *partial_line = "partial line";
/* Partial line */
CUPS_SRAND((unsigned)time(NULL));
for (i = 0; i < (int)sizeof(writebuf); i ++)
- writebuf[i] = CUPS_RAND();
+ writebuf[i] = (unsigned char)CUPS_RAND();
/*
* cupsFileOpen(write)
fputs("cupsFileGetConf(): ", stdout);
- for (i = 0; i < 1000; i ++)
+ for (i = 0, value = NULL; i < 1000; i ++)
if (!cupsFileGetConf(fp, line, sizeof(line), &value, &linenum))
break;
else if (_cups_strcasecmp(line, "TestLine") || !value || atoi(value) != i ||
fputs("cupsFileGetChar(): ", stdout);
- for (i = 0; i < 256; i ++)
+ for (i = 0, byte = 0; i < 256; i ++)
if ((byte = cupsFileGetChar(fp)) != i)
break;
fputs("cupsFileRead(): ", stdout);
- for (i = 0; i < 10000; i ++)
- if ((byte = cupsFileRead(fp, (char *)readbuf, sizeof(readbuf))) < 0)
+ for (i = 0, bytes = 0; i < 10000; i ++)
+ if ((bytes = cupsFileRead(fp, (char *)readbuf, sizeof(readbuf))) < 0)
break;
else if (memcmp(readbuf, writebuf, sizeof(readbuf)))
break;
if (i >= 10000)
puts("PASS");
- else if (byte > 0)
+ else if (bytes > 0)
{
printf("FAIL (Pass %d, ", i);
*
* HTTP test program for CUPS.
*
- * Copyright 2007-2013 by Apple Inc.
+ * Copyright 2007-2014 by Apple Inc.
* Copyright 1997-2006 by Easy Software Products.
*
* These coded instructions, statements, and computer programs are the
*hostname, /* Hostname string */
*resource; /* Resource string */
int port, /* Port number */
- assemble_port, /* Port number for httpAssembleURI() */
- assemble_coding;/* Coding for httpAssembleURI() */
+ assemble_port; /* Port number for httpAssembleURI() */
+ http_uri_coding_t assemble_coding;/* Coding for httpAssembleURI() */
} uri_test_t;
HTTP_URI_CODING_MOST },
{ HTTP_URI_STATUS_OK, "ipp://username:password@[fe80::200:1234:5678:9abc%25eth0]:999/ipp",
"ipp", "username:password", "fe80::200:1234:5678:9abc%eth0", "/ipp", 999, 999,
- HTTP_URI_CODING_MOST | HTTP_URI_CODING_RFC6874 },
+ (http_uri_coding_t)(HTTP_URI_CODING_MOST | HTTP_URI_CODING_RFC6874) },
{ HTTP_URI_STATUS_OK, "http://server/admin?DEVICE_URI=usb://HP/Photosmart%25202600%2520series?serial=MY53OK70V10400",
"http", "", "server", "/admin?DEVICE_URI=usb://HP/Photosmart%25202600%2520series?serial=MY53OK70V10400", 80, 0,
HTTP_URI_CODING_MOST },
while ((bytes = httpRead2(http, buffer, sizeof(buffer))) > 0)
{
total += bytes;
- fwrite(buffer, bytes, 1, out);
+ fwrite(buffer, (size_t)bytes, 1, out);
if (out != stdout)
{
current = time(NULL);
/*
* "$Id$"
*
- * Internationalization test for CUPS.
+ * Internationalization test for CUPS.
*
- * Copyright 2007-2012 by Apple Inc.
- * Copyright 1997-2006 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2006 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * main() - Main entry for internationalization test module.
- * print_utf8() - Print UTF-8 string with (optional) message.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
strlcpy(legsrc, legdest, sizeof(legsrc));
len = cupsCharsetToUTF8(utf8dest, legsrc, 1024, CUPS_ISO8859_1);
- if (len != strlen((char *)utf8latin))
+ if ((size_t)len != strlen((char *)utf8latin))
{
printf("FAIL (len=%d, expected %d)\n", len, (int)strlen((char *)utf8latin));
print_utf8(" utf8latin", utf8latin);
print_utf8(" utf8dest", utf8dest);
errors ++;
}
- else if (memcmp(utf8latin, utf8dest, len))
+ else if (memcmp(utf8latin, utf8dest, (size_t)len))
{
puts("FAIL (results do not match)");
print_utf8(" utf8latin", utf8latin);
strlcpy(legsrc, legdest, sizeof(legsrc));
len = cupsCharsetToUTF8(utf8dest, legsrc, 1024, CUPS_ISO8859_7);
- if (len != strlen((char *)utf8greek))
+ if ((size_t)len != strlen((char *)utf8greek))
{
printf("FAIL (len=%d, expected %d)\n", len, (int)strlen((char *)utf8greek));
print_utf8(" utf8greek", utf8greek);
print_utf8(" utf8dest", utf8dest);
errors ++;
}
- else if (memcmp(utf8greek, utf8dest, len))
+ else if (memcmp(utf8greek, utf8dest, (size_t)len))
{
puts("FAIL (results do not match)");
print_utf8(" utf8greek", utf8greek);
strlcpy(legsrc, legdest, sizeof(legsrc));
len = cupsCharsetToUTF8(utf8dest, legsrc, 1024, CUPS_WINDOWS_932);
- if (len != strlen((char *)utf8japan))
+ if ((size_t)len != strlen((char *)utf8japan))
{
printf("FAIL (len=%d, expected %d)\n", len, (int)strlen((char *)utf8japan));
print_utf8(" utf8japan", utf8japan);
print_utf8(" utf8dest", utf8dest);
errors ++;
}
- else if (memcmp(utf8japan, utf8dest, len))
+ else if (memcmp(utf8japan, utf8dest, (size_t)len))
{
puts("FAIL (results do not match)");
print_utf8(" utf8japan", utf8japan);
strlcpy(legsrc, legdest, sizeof(legsrc));
len = cupsCharsetToUTF8(utf8dest, legsrc, 1024, CUPS_EUC_JP);
- if (len != strlen((char *)utf8japan))
+ if ((size_t)len != strlen((char *)utf8japan))
{
printf("FAIL (len=%d, expected %d)\n", len, (int)strlen((char *)utf8japan));
print_utf8(" utf8japan", utf8japan);
print_utf8(" utf8dest", utf8dest);
errors ++;
}
- else if (memcmp(utf8japan, utf8dest, len))
+ else if (memcmp(utf8japan, utf8dest, (size_t)len))
{
puts("FAIL (results do not match)");
print_utf8(" utf8japan", utf8japan);
strlcpy(legsrc, legdest, sizeof(legsrc));
len = cupsCharsetToUTF8(utf8dest, legsrc, 1024, CUPS_WINDOWS_950);
- if (len != strlen((char *)utf8taiwan))
+ if ((size_t)len != strlen((char *)utf8taiwan))
{
printf("FAIL (len=%d, expected %d)\n", len, (int)strlen((char *)utf8taiwan));
print_utf8(" utf8taiwan", utf8taiwan);
print_utf8(" utf8dest", utf8dest);
errors ++;
}
- else if (memcmp(utf8taiwan, utf8dest, len))
+ else if (memcmp(utf8taiwan, utf8dest, (size_t)len))
{
puts("FAIL (results do not match)");
print_utf8(" utf8taiwan", utf8taiwan);
strlcpy(legsrc, legdest, sizeof(legsrc));
len = cupsCharsetToUTF8(utf8dest, legsrc, 1024, CUPS_EUC_TW);
- if (len != strlen((char *)utf8taiwan))
+ if ((size_t)len != strlen((char *)utf8taiwan))
{
printf("FAIL (len=%d, expected %d)\n", len, (int)strlen((char *)utf8taiwan));
print_utf8(" utf8taiwan", utf8taiwan);
print_utf8(" utf8dest", utf8dest);
errors ++;
}
- else if (memcmp(utf8taiwan, utf8dest, len))
+ else if (memcmp(utf8taiwan, utf8dest, (size_t)len))
{
puts("FAIL (results do not match)");
print_utf8(" utf8taiwan", utf8taiwan);
print_utf8(" utf8good ", utf8good);
print_utf32(" utf32dest", utf32dest);
}
- memcpy (utf32src, utf32dest, (len + 1) * sizeof(cups_utf32_t));
+ memcpy(utf32src, utf32dest, (len + 1) * sizeof(cups_utf32_t));
len = cupsUTF32ToUTF8(utf8dest, utf32src, 1024);
if (len < 0)
return (1);
/*
* "$Id$"
*
- * IPP test program for CUPS.
+ * IPP test program for CUPS.
*
- * Copyright 2007-2013 by Apple Inc.
- * Copyright 1997-2005 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2005 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * main() - Main entry.
- * hex_dump() - Produce a hex dump of a buffer.
- * print_attributes() - Print the attributes in a request...
- * read_cb() - Read data from a buffer.
- * write_cb() - Write data into a buffer.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
* Local globals...
*/
-ipp_uchar_t collection[] = /* Collection buffer */
+static ipp_uchar_t collection[] = /* Collection buffer */
{
0x01, 0x01, /* IPP version */
0x00, 0x02, /* Print-Job operation */
IPP_TAG_END /* end tag */
};
-ipp_uchar_t mixed[] = /* Mixed value buffer */
+static ipp_uchar_t mixed[] = /* Mixed value buffer */
{
0x01, 0x01, /* IPP version */
0x00, 0x02, /* Print-Job operation */
* Local functions...
*/
-void hex_dump(const char *title, ipp_uchar_t *buffer, int bytes);
+void hex_dump(const char *title, ipp_uchar_t *buffer, size_t bytes);
void print_attributes(ipp_t *ipp, int indent);
ssize_t read_cb(_ippdata_t *data, ipp_uchar_t *buffer, size_t bytes);
ssize_t write_cb(_ippdata_t *data, ipp_uchar_t *buffer, size_t bytes);
*media_size, /* media-size attribute */
*attr; /* Other attribute */
ipp_state_t state; /* State */
- int length; /* Length of data */
+ size_t length; /* Length of data */
cups_file_t *fp; /* File pointer */
- int i; /* Looping var */
+ size_t i; /* Looping var */
int status; /* Status of tests (0 = success, 1 = fail) */
#ifdef DEBUG
const char *name; /* Option name */
if (length != sizeof(collection))
{
printf("FAIL - wrong ippLength(), %d instead of %d bytes!\n",
- length, (int)sizeof(collection));
+ (int)length, (int)sizeof(collection));
status = 1;
}
else
if (data.wbuffer[i] != collection[i])
break;
- printf("FAIL - output does not match baseline at 0x%04x!\n", i);
+ printf("FAIL - output does not match baseline at 0x%04x!\n", (unsigned)i);
hex_dump("Bytes Written", data.wbuffer, data.wused);
hex_dump("Baseline", collection, sizeof(collection));
status = 1;
else if (length != sizeof(collection))
{
printf("FAIL - wrong ippLength(), %d instead of %d bytes!\n",
- length, (int)sizeof(collection));
+ (int)length, (int)sizeof(collection));
print_attributes(request, 8);
status = 1;
}
else if (length != (sizeof(mixed) + 4))
{
printf("FAIL - wrong ippLength(), %d instead of %d bytes!\n",
- length, (int)sizeof(mixed) + 4);
+ (int)length, (int)sizeof(mixed) + 4);
print_attributes(request, 8);
status = 1;
}
* Read IPP files...
*/
- for (i = 1; i < argc; i ++)
+ for (i = 1; i < (size_t)argc; i ++)
{
if ((fp = cupsFileOpen(argv[i], "r")) == NULL)
{
void
hex_dump(const char *title, /* I - Title */
ipp_uchar_t *buffer, /* I - Buffer to dump */
- int bytes) /* I - Number of bytes */
+ size_t bytes) /* I - Number of bytes */
{
- int i, j; /* Looping vars */
- int ch; /* Current ASCII char */
+ size_t i, j; /* Looping vars */
+ int ch; /* Current ASCII char */
/*
* Show the offset...
*/
- printf(" %04x ", i);
+ printf(" %04x ", (unsigned)i);
/*
* Then up to 16 bytes in hex...
* Return the number of bytes read...
*/
- return (count);
+ return ((ssize_t)count);
}
* Return the number of bytes written...
*/
- return (count);
+ return ((ssize_t)count);
}
/*
* "$Id$"
*
- * PPD test program for CUPS.
+ * PPD test program for CUPS.
*
- * Copyright 2007-2013 by Apple Inc.
- * Copyright 1997-2006 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2006 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * main() - Main entry.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
fputs("ppdPageSizeLimits: ", stdout);
if (ppdPageSizeLimits(ppd, &minsize, &maxsize))
{
- if (minsize.width != 36 || minsize.length != 36 ||
- maxsize.width != 1080 || maxsize.length != 86400)
+ if (fabs(minsize.width - 36.0) > 0.001 || fabs(minsize.length - 36.0) > 0.001 ||
+ fabs(maxsize.width - 1080.0) > 0.001 || fabs(maxsize.length - 86400.0) > 0.001)
{
- printf("FAIL (got min=%.0fx%.0f, max=%.0fx%.0f, "
+ printf("FAIL (got min=%.3fx%.3f, max=%.3fx%.3f, "
"expected min=36x36, max=1080x86400)\n", minsize.width,
minsize.length, maxsize.width, maxsize.length);
status ++;
size = ppdPageSize(ppd, NULL);
if (!size || strcmp(size->name, "Custom") ||
- size->width != 576 || size->length != 720)
+ fabs(size->width - 576.0) > 0.001 ||
+ fabs(size->length - 720.0) > 0.001)
{
printf("FAIL (%s - %gx%g)\n", size ? size->name : "unknown",
size ? size->width : 0.0, size ? size->length : 0.0);
fputs("ppdPageSizeLimits(default): ", stdout);
if (ppdPageSizeLimits(ppd, &minsize, &maxsize))
{
- if (minsize.width != 36 || minsize.length != 36 ||
- maxsize.width != 1080 || maxsize.length != 86400)
+ if (fabs(minsize.width - 36.0) > 0.001 || fabs(minsize.length - 36.0) > 0.001 ||
+ fabs(maxsize.width - 1080.0) > 0.001 || fabs(maxsize.length - 86400.0) > 0.001)
{
printf("FAIL (got min=%.0fx%.0f, max=%.0fx%.0f, "
"expected min=36x36, max=1080x86400)\n", minsize.width,
fputs("ppdPageSizeLimits(InputSlot=Manual): ", stdout);
if (ppdPageSizeLimits(ppd, &minsize, &maxsize))
{
- if (minsize.width != 100 || minsize.length != 100 ||
- maxsize.width != 1000 || maxsize.length != 1000)
+ if (fabs(minsize.width - 100.0) > 0.001 || fabs(minsize.length - 100.0) > 0.001 ||
+ fabs(maxsize.width - 1000.0) > 0.001 || fabs(maxsize.length - 1000.0) > 0.001)
{
printf("FAIL (got min=%.0fx%.0f, max=%.0fx%.0f, "
"expected min=100x100, max=1000x1000)\n", minsize.width,
fputs("ppdPageSizeLimits(Quality=Photo): ", stdout);
if (ppdPageSizeLimits(ppd, &minsize, &maxsize))
{
- if (minsize.width != 200 || minsize.length != 200 ||
- maxsize.width != 1000 || maxsize.length != 1000)
+ if (fabs(minsize.width - 200.0) > 0.001 || fabs(minsize.length - 200.0) > 0.001 ||
+ fabs(maxsize.width - 1000.0) > 0.001 || fabs(maxsize.length - 1000.0) > 0.001)
{
printf("FAIL (got min=%.0fx%.0f, max=%.0fx%.0f, "
"expected min=200x200, max=1000x1000)\n", minsize.width,
fputs("ppdPageSizeLimits(Quality=Photo): ", stdout);
if (ppdPageSizeLimits(ppd, &minsize, &maxsize))
{
- if (minsize.width != 300 || minsize.length != 300 ||
- maxsize.width != 1080 || maxsize.length != 86400)
+ if (fabs(minsize.width - 300.0) > 0.001 || fabs(minsize.length - 300.0) > 0.001 ||
+ fabs(maxsize.width - 1080.0) > 0.001 || fabs(maxsize.length - 86400.0) > 0.001)
{
printf("FAIL (got min=%.0fx%.0f, max=%.0fx%.0f, "
"expected min=300x300, max=1080x86400)\n", minsize.width,
/*
* "$Id$"
*
- * SNMP test program for CUPS.
+ * SNMP test program for CUPS.
*
- * Copyright 2008-2010 by Apple Inc.
+ * Copyright 2008-2014 by Apple Inc.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * main() - Main entry.
- * scan_oid() - Scan an OID value.
- * show_oid() - Show the specified OID.
- * usage() - Show program usage and exit.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
print_packet(cups_snmp_t *packet, /* I - SNMP response packet */
void *data) /* I - User data pointer (not used) */
{
- int i; /* Looping var */
- char temp[1024]; /* Temporary OID string */
+ unsigned i; /* Looping var */
+ char temp[1024]; /* Temporary OID string */
(void)data;
/*
* "$Id$"
*
- * Private threading definitions for CUPS.
+ * Private threading definitions for CUPS.
*
- * Copyright 2009-2012 by Apple Inc.
+ * Copyright 2009-2014 by Apple Inc.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*/
#ifndef _CUPS_THREAD_PRIVATE_H_
typedef pthread_key_t _cups_threadkey_t;
# define _CUPS_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
# define _CUPS_RWLOCK_INITIALIZER PTHREAD_RWLOCK_INITIALIZER
-# define _CUPS_THREADKEY_INITIALIZER -1
+# define _CUPS_THREADKEY_INITIALIZER 0
# define _cupsThreadGetData(k) pthread_getspecific(k)
# define _cupsThreadSetData(k,p) pthread_setspecific(k,p)
*
* TLS support code for CUPS on OS X.
*
- * Copyright 2007-2013 by Apple Inc.
+ * Copyright 2007-2014 by Apple Inc.
* Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
secCert = SecTrustGetCertificateAtIndex(peerTrust, i);
if ((data = SecCertificateCopyData(secCert)))
{
- httpAddCredential(*credentials, CFDataGetBytePtr(data),
- CFDataGetLength(data));
+ httpAddCredential(*credentials, CFDataGetBytePtr(data), (size_t)CFDataGetLength(data));
CFRelease(data);
}
}
credential;
credential = (http_credential_t *)cupsArrayNext(credentials))
{
- if ((data = CFDataCreate(kCFAllocatorDefault, credential->data,
- credential->datalen)))
+ if ((data = CFDataCreate(kCFAllocatorDefault, credential->data, (CFIndex)credential->datalen)))
{
if ((secCert = SecCertificateCreateWithData(kCFAllocatorDefault, data))
!= NULL)
}
while (bytes == -1 && (errno == EINTR || errno == EAGAIN));
- if (bytes == *dataLength)
+ if ((size_t)bytes == *dataLength)
{
result = 0;
}
else if (bytes > 0)
{
- *dataLength = bytes;
+ *dataLength = (size_t)bytes;
result = errSSLWouldBlock;
}
else
}
while (bytes == -1 && (errno == EINTR || errno == EAGAIN));
- if (bytes == *dataLength)
+ if ((size_t)bytes == *dataLength)
{
result = 0;
}
else if (bytes >= 0)
{
- *dataLength = bytes;
+ *dataLength = (size_t)bytes;
result = errSSLWouldBlock;
}
else
size_t processed; /* Number of bytes processed */
- error = SSLRead(http->tls, buf, len, &processed);
+ error = SSLRead(http->tls, buf, (size_t)len, &processed);
DEBUG_printf(("6http_tls_read: error=%d, processed=%d", (int)error,
(int)processed));
switch (error)
if ((credential = malloc(sizeof(*credential))) != NULL)
{
- credential->datalen = CFDataGetLength(data);
+ credential->datalen = (size_t)CFDataGetLength(data);
if ((credential->data = malloc(credential->datalen)))
{
memcpy((void *)credential->data, CFDataGetBytePtr(data),
DEBUG_printf(("2http_tls_write(http=%p, buf=%p, len=%d)", http, buf, len));
- error = SSLWrite(http->tls, buf, len, &processed);
+ error = SSLWrite(http->tls, buf, (size_t)len, &processed);
switch (error)
{
/*
* "$Id$"
*
- * Transcoding support for CUPS.
+ * Transcoding support for CUPS.
*
- * Copyright 2007-2010 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2007 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * _cupsCharmapFlush() - Flush all character set maps out of cache.
- * cupsCharsetToUTF8() - Convert legacy character set to UTF-8.
- * cupsUTF8ToCharset() - Convert UTF-8 to legacy character set.
- * cupsUTF8ToUTF32() - Convert UTF-8 to UTF-32.
- * cupsUTF32ToUTF8() - Convert UTF-32 to UTF-8.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
if (ch & 128)
{
- *destptr++ = 0xc0 | (ch >> 6);
- *destptr++ = 0x80 | (ch & 0x3f);
+ *destptr++ = (cups_utf8_t)(0xc0 | (ch >> 6));
+ *destptr++ = (cups_utf8_t)(0x80 | (ch & 0x3f));
}
else
- *destptr++ = ch;
+ *destptr++ = (cups_utf8_t)ch;
}
*destptr = '\0';
char *altdestptr = (char *)dest; /* Silence bogus GCC type-punned */
srclen = strlen(src);
- outBytesLeft = maxout - 1;
+ outBytesLeft = (size_t)maxout - 1;
iconv(map_to_utf8, (char **)&src, &srclen, &altdestptr, &outBytesLeft);
*altdestptr = '\0';
ch = ((ch & 0x1f) << 6) | (*src++ & 0x3f);
if (ch < maxch)
- *destptr++ = ch;
+ *destptr++ = (char)ch;
else
*destptr++ = '?';
}
(ch & 0xf8) == 0xf0)
*destptr++ = '?';
else if (!(ch & 0x80))
- *destptr++ = ch;
+ *destptr++ = (char)ch;
}
*destptr = '\0';
char *altsrc = (char *)src; /* Silence bogus GCC type-punned */
srclen = strlen((char *)src);
- outBytesLeft = maxout - 1;
+ outBytesLeft = (size_t)maxout - 1;
iconv(map_from_utf8, &altsrc, &srclen, &destptr, &outBytesLeft);
*destptr = '\0';
return (-1);
}
- ch32 = ((ch & 0x1f) << 6) | (next & 0x3f);
+ ch32 = (cups_utf32_t)((ch & 0x1f) << 6) | (cups_utf32_t)(next & 0x3f);
/*
* Check for non-shortest form (invalid UTF-8)...
return (-1);
}
- ch32 = ((ch & 0x0f) << 6) | (next & 0x3f);
+ ch32 = (cups_utf32_t)((ch & 0x0f) << 6) | (cups_utf32_t)(next & 0x3f);
next = *src++;
if ((next & 0xc0) != 0x80)
return (-1);
}
- ch32 = (ch32 << 6) | (next & 0x3f);
+ ch32 = (ch32 << 6) | (cups_utf32_t)(next & 0x3f);
/*
* Check for non-shortest form (invalid UTF-8)...
return (-1);
}
- ch32 = ((ch & 0x07) << 6) | (next & 0x3f);
+ ch32 = (cups_utf32_t)((ch & 0x07) << 6) | (cups_utf32_t)(next & 0x3f);
next = *src++;
if ((next & 0xc0) != 0x80)
return (-1);
}
- ch32 = (ch32 << 6) | (next & 0x3f);
+ ch32 = (ch32 << 6) | (cups_utf32_t)(next & 0x3f);
next = *src++;
if ((next & 0xc0) != 0x80)
return (-1);
}
- ch32 = (ch32 << 6) | (next & 0x3f);
+ ch32 = (ch32 << 6) | (cups_utf32_t)(next & 0x3f);
/*
* Check for non-shortest form (invalid UTF-8)...
*
* User, system, and password routines for CUPS.
*
- * Copyright 2007-2013 by Apple Inc.
+ * Copyright 2007-2014 by Apple Inc.
* Copyright 1997-2006 by Easy Software Products.
*
* These coded instructions, statements, and computer programs are the
}
noecho = original;
- noecho.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
+ noecho.c_lflag &= (tcflag_t)~(ICANON | ECHO | ECHOE | ISIG);
if (tcsetattr(tty, TCSAFLUSH, &noecho))
{
/*
* "$Id$"
*
- * Printing utilities for CUPS.
+ * Printing utilities for CUPS.
*
- * Copyright 2007-2013 by Apple Inc.
- * Copyright 1997-2006 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2006 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * cupsCancelJob() - Cancel a print job on the default server.
- * cupsCancelJob2() - Cancel or purge a print job.
- * cupsCreateJob() - Create an empty job for streaming.
- * cupsFinishDocument() - Finish sending a document.
- * cupsFreeJobs() - Free memory used by job data.
- * cupsGetClasses() - Get a list of printer classes from the default
- * server.
- * cupsGetDefault() - Get the default printer or class for the default
- * server.
- * cupsGetDefault2() - Get the default printer or class for the specified
- * server.
- * cupsGetJobs() - Get the jobs from the default server.
- * cupsGetJobs2() - Get the jobs from the specified server.
- * cupsGetPPD() - Get the PPD file for a printer on the default
- * server.
- * cupsGetPPD2() - Get the PPD file for a printer from the specified
- * server.
- * cupsGetPPD3() - Get the PPD file for a printer on the specified
- * server if it has changed.
- * cupsGetPrinters() - Get a list of printers from the default server.
- * cupsGetServerPPD() - Get an available PPD file from the server.
- * cupsPrintFile() - Print a file to a printer or class on the default
- * server.
- * cupsPrintFile2() - Print a file to a printer or class on the
- * specified server.
- * cupsPrintFiles() - Print one or more files to a printer or class on
- * the default server.
- * cupsPrintFiles2() - Print one or more files to a printer or class on
- * the specified server.
- * cupsStartDocument() - Add a document to a job created with
- * cupsCreateJob().
- * cups_get_printer_uri() - Get the printer-uri-supported attribute for the
- * first printer in a class.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
if (n == 0)
temp = malloc(sizeof(char *));
else
- temp = realloc(*classes, sizeof(char *) * (n + 1));
+ temp = realloc(*classes, sizeof(char *) * (size_t)(n + 1));
if (temp == NULL)
{
if (n == 0)
temp = malloc(sizeof(cups_job_t));
else
- temp = realloc(*jobs, sizeof(cups_job_t) * (n + 1));
+ temp = realloc(*jobs, sizeof(cups_job_t) * (size_t)(n + 1));
if (!temp)
{
if (n == 0)
temp = malloc(sizeof(char *));
else
- temp = realloc(*printers, sizeof(char *) * (n + 1));
+ temp = realloc(*printers, sizeof(char *) * (size_t)(n + 1));
if (temp == NULL)
{
while (status == HTTP_STATUS_CONTINUE &&
(bytes = cupsFileRead(fp, buffer, sizeof(buffer))) > 0)
- status = cupsWriteRequestData(http, buffer, bytes);
+ status = cupsWriteRequestData(http, buffer, (size_t)bytes);
cupsFileClose(fp);
if (format)
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_MIMETYPE,
"document-format", NULL, format);
- ippAddBoolean(request, IPP_TAG_OPERATION, "last-document", last_document);
+ ippAddBoolean(request, IPP_TAG_OPERATION, "last-document", (char)last_document);
/*
* Send and delete the request, then return the status...
/*
* "$Id$"
*
- * PostScript command filter for CUPS.
+ * PostScript command filter for CUPS.
*
- * Copyright 2008-2012 by Apple Inc.
+ * Copyright 2008-2014 by Apple Inc.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
- *
- *
- * Contents:
- *
- * main() - Process a CUPS command file.
- * auto_configure() - Automatically configure the printer using
- * PostScript query commands and/or SNMP lookups.
- * begin_ps() - Send the standard PostScript prolog.
- * end_ps() - Send the standard PostScript trailer.
- * print_self_test_page() - Print a self-test page.
- * report_levels() - Report supply levels.
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*/
/*
bufptr = buffer;
buffer[0] = '\0';
- while ((bytes = cupsBackChannelRead(bufptr,
- sizeof(buffer) - (bufptr - buffer) - 1,
- 10.0)) > 0)
+ while ((bytes = cupsBackChannelRead(bufptr, sizeof(buffer) - (size_t)(bufptr - buffer) - 1, 10.0)) > 0)
{
/*
* No newline at the end? Go on reading ...
/*
* "$Id$"
*
- * Common filter routines for CUPS.
+ * Common filter routines for CUPS.
*
- * Copyright 2007-2011 by Apple Inc.
- * Copyright 1997-2006 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2006 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * SetCommonOptions() - Set common filter options for media size,
- * etc.
- * UpdatePageVars() - Update the page variables for the orientation.
- * WriteComment() - Write a DSC comment.
- * WriteCommon() - Write common procedures...
- * WriteLabelProlog() - Write the prolog with the classification
- * and page label.
- * WriteLabels() - Write the actual page labels.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
*/
printf("%%%%%s: (", name);
- len = 5 + strlen(name);
+ len = 5 + (int)strlen(name);
while (*value)
{
/*
* "$Id$"
*
- * Raster error handling for CUPS.
+ * Raster error handling for CUPS.
*
- * Copyright 2007-2012 by Apple Inc.
- * Copyright 2007 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 2007 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * _cupsRasterAddError() - Add an error message to the error buffer.
- * _cupsRasterClearError() - Clear the error buffer.
- * cupsRasterErrorString() - Return the last error from a raster function.
- * get_error_buffer() - Return a pointer to thread local storage.
- * raster_init() - Initialize error buffer once.
- * raster_destructor() - Free memory allocated by get_error_buffer().
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
/* Error buffer */
va_list ap; /* Pointer to additional arguments */
char s[2048]; /* Message string */
- size_t bytes; /* Bytes in message string */
+ ssize_t bytes; /* Bytes in message string */
va_start(ap, f);
bytes ++;
- if (bytes >= sizeof(s))
+ if ((size_t)bytes >= sizeof(s))
return;
- if (bytes > (size_t)(buf->end - buf->current))
+ if (bytes > (ssize_t)(buf->end - buf->current))
{
/*
* Allocate more memory...
size_t size; /* Size of buffer */
- size = buf->end - buf->start + 2 * bytes + 1024;
+ size = (size_t)(buf->end - buf->start + 2 * bytes + 1024);
if (buf->start)
temp = realloc(buf->start, size);
* Append the message to the end of the current string...
*/
- memcpy(buf->current, s, bytes);
+ memcpy(buf->current, s, (size_t)bytes);
buf->current += bytes - 1;
}
* Local globals...
*/
-static pthread_key_t raster_key = -1;
- /* Thread local storage key */
+static pthread_key_t raster_key = 0; /* Thread local storage key */
static pthread_once_t raster_key_once = PTHREAD_ONCE_INIT;
/* One-time initialization object */
/*
* "$Id$"
*
- * GZIP/raw pre-filter for CUPS.
+ * GZIP/raw pre-filter for CUPS.
*
- * Copyright 2007-2012 by Apple Inc.
- * Copyright 1993-2007 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1993-2007 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * main() - Copy (and uncompress) files to stdout.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
{
cups_file_t *fp; /* File */
char buffer[8192]; /* Data buffer */
- int bytes; /* Number of bytes read/written */
+ ssize_t bytes; /* Number of bytes read/written */
int copies; /* Number of copies */
cupsFileRewind(fp);
while ((bytes = cupsFileRead(fp, buffer, sizeof(buffer))) > 0)
- if (write(1, buffer, bytes) < bytes)
+ if (write(1, buffer, (size_t)bytes) < bytes)
{
_cupsLangPrintFilter(stderr, "ERROR",
_("Unable to write uncompressed print data: %s"),
* Compute the bitmap parameters...
*/
- h->cupsWidth = (int)((right - left) * h->cupsBorderlessScalingFactor *
+ h->cupsWidth = (unsigned)((right - left) * h->cupsBorderlessScalingFactor *
h->HWResolution[0] / 72.0f + 0.5f);
- h->cupsHeight = (int)((top - bottom) * h->cupsBorderlessScalingFactor *
+ h->cupsHeight = (unsigned)((top - bottom) * h->cupsBorderlessScalingFactor *
h->HWResolution[1] / 72.0f + 0.5f);
switch (h->cupsColorSpace)
st->alloc_objs += 32;
- if ((temp = realloc(st->objs, st->alloc_objs *
+ if ((temp = realloc(st->objs, (size_t)st->alloc_objs *
sizeof(_cups_ps_obj_t))) == NULL)
return (NULL);
s = -s;
- if ((temp = calloc(s, sizeof(_cups_ps_obj_t))) == NULL)
+ if ((temp = calloc((size_t)s, sizeof(_cups_ps_obj_t))) == NULL)
return (-1);
- memcpy(temp, st->objs + n, s * sizeof(_cups_ps_obj_t));
- memmove(st->objs + n, st->objs + n + s, (c - s) * sizeof(_cups_ps_obj_t));
- memcpy(st->objs + n + c - s, temp, s * sizeof(_cups_ps_obj_t));
+ memcpy(temp, st->objs + n, (size_t)s * sizeof(_cups_ps_obj_t));
+ memmove(st->objs + n, st->objs + n + s, (size_t)(c - s) * sizeof(_cups_ps_obj_t));
+ memcpy(st->objs + n + c - s, temp, (size_t)s * sizeof(_cups_ps_obj_t));
}
else
{
* Shift up...
*/
- if ((temp = calloc(s, sizeof(_cups_ps_obj_t))) == NULL)
+ if ((temp = calloc((size_t)s, sizeof(_cups_ps_obj_t))) == NULL)
return (-1);
- memcpy(temp, st->objs + n + c - s, s * sizeof(_cups_ps_obj_t));
- memmove(st->objs + n + s, st->objs + n,
- (c - s) * sizeof(_cups_ps_obj_t));
- memcpy(st->objs + n, temp, s * sizeof(_cups_ps_obj_t));
+ memcpy(temp, st->objs + n + c - s, (size_t)s * sizeof(_cups_ps_obj_t));
+ memmove(st->objs + n + s, st->objs + n, (size_t)(c - s) * sizeof(_cups_ps_obj_t));
+ memcpy(st->objs + n, temp, (size_t)s * sizeof(_cups_ps_obj_t));
}
free(temp);
ch = (ch << 3) + *cur - '0';
}
- *valptr++ = ch;
+ *valptr++ = (char)ch;
}
else if (*cur == '\r')
{
ch |= tolower(*cur) - 'a' + 10;
}
- *valptr++ = ch;
+ *valptr++ = (char)ch;
}
if (*cur != '>')
/*
* "$Id$"
*
- * PostScript filter for CUPS.
+ * PostScript filter for CUPS.
*
- * Copyright 2007-2012 by Apple Inc.
- * Copyright 1993-2007 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1993-2007 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * main() - Main entry.
- * add_page() - Add a page to the pages array.
- * cancel_job() - Flag the job as canceled.
- * check_range() - Check to see if the current page is selected for
- * printing.
- * copy_bytes() - Copy bytes from the input file to stdout.
- * copy_comments() - Copy all of the comments section.
- * copy_dsc() - Copy a DSC-conforming document.
- * copy_non_dsc() - Copy a document that does not conform to the DSC.
- * copy_page() - Copy a page description.
- * copy_prolog() - Copy the document prolog section.
- * copy_setup() - Copy the document setup section.
- * copy_trailer() - Copy the document trailer.
- * do_prolog() - Send the necessary document prolog commands.
- * do_setup() - Send the necessary document setup commands.
- * doc_printf() - Send a formatted string to stdout and/or the temp
- * file.
- * doc_puts() - Send a nul-terminated string to stdout and/or the
- * temp file.
- * doc_write() - Send data to stdout and/or the temp file.
- * end_nup() - End processing for N-up printing.
- * include_feature() - Include a printer option/feature command.
- * parse_text() - Parse a text value in a comment.
- * set_pstops_options() - Set pstops options.
- * skip_page() - Skip past a page that won't be printed.
- * start_nup() - Start processing for N-up printing.
- * write_label_prolog() - Write the prolog with the classification and page
- * label.
- * write_labels() - Write the actual page labels.
- * write_options() - Write options provided via %%IncludeFeature.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
int num_options; /* Number of print options */
cups_option_t *options; /* Print options */
char line[8192]; /* Line buffer */
- size_t len; /* Length of line buffer */
+ ssize_t len; /* Length of line buffer */
#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
struct sigaction action; /* Actions for POSIX signals */
#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
* Read the first line to see if we have DSC comments...
*/
- if ((len = cupsFileGetLine(fp, line, sizeof(line))) == 0)
+ if ((len = (ssize_t)cupsFileGetLine(fp, line, sizeof(line))) == 0)
{
fputs("DEBUG: The print file is empty.\n", stderr);
return (1);
fputs("DEBUG: Skipping PJL header...\n", stderr);
while (strstr(line, "ENTER LANGUAGE") == NULL && strncmp(line, "%!", 2))
- if ((len = cupsFileGetLine(fp, line, sizeof(line))) == 0)
+ if ((len = (ssize_t)cupsFileGetLine(fp, line, sizeof(line))) == 0)
break;
if (!strncmp(line, "%!", 2))
break;
- if ((len = cupsFileGetLine(fp, line, sizeof(line))) == 0)
+ if ((len = (ssize_t)cupsFileGetLine(fp, line, sizeof(line))) == 0)
break;
}
{
lower = 1;
range ++;
- upper = strtol(range, (char **)&range, 10);
+ upper = (int)strtol(range, (char **)&range, 10);
}
else
{
- lower = strtol(range, (char **)&range, 10);
+ lower = (int)strtol(range, (char **)&range, 10);
if (*range == '-')
{
if (!isdigit(*range & 255))
upper = 65535;
else
- upper = strtol(range, (char **)&range, 10);
+ upper = (int)strtol(range, (char **)&range, 10);
}
else
upper = lower;
if (nleft > sizeof(buffer) || length == 0)
nbytes = sizeof(buffer);
else
- nbytes = nleft;
+ nbytes = (ssize_t)nleft;
- if ((nbytes = cupsFileRead(fp, buffer, nbytes)) < 1)
+ if ((nbytes = cupsFileRead(fp, buffer, (size_t)nbytes)) < 1)
return;
- nleft -= nbytes;
+ nleft -= (size_t)nbytes;
- fwrite(buffer, 1, nbytes, stdout);
+ fwrite(buffer, 1, (size_t)nbytes, stdout);
}
}
}
else if (!strcmp(line, "%%EndComments"))
{
- linelen = cupsFileGetLine(fp, line, linesize);
+ linelen = (ssize_t)cupsFileGetLine(fp, line, linesize);
break;
}
else if (strncmp(line, "%!", 2) && strncmp(line, "%cups", 5))
doc_printf(doc, "%s\n", line);
- if ((linelen = cupsFileGetLine(fp, line, linesize)) == 0)
+ if ((linelen = (ssize_t)cupsFileGetLine(fp, line, linesize)) == 0)
break;
}
while (strncmp(line, "%%Page:", 7) && strncmp(line, "%%Trailer", 9))
{
- doc_write(doc, line, linelen);
+ doc_write(doc, line, (size_t)linelen);
- if ((linelen = cupsFileGetLine(fp, line, linesize)) == 0)
+ if ((linelen = (ssize_t)cupsFileGetLine(fp, line, linesize)) == 0)
break;
}
doc_puts(doc, "showpage\n");
end_nup(doc, doc->number_up);
- pageinfo->length = cupsFileTell(doc->temp) - pageinfo->offset;
+ pageinfo->length = (ssize_t)(cupsFileTell(doc->temp) - pageinfo->offset);
}
if (doc->slow_duplex && (doc->page & 1))
doc_puts(doc, "showpage\n");
end_nup(doc, doc->number_up);
- pageinfo->length = cupsFileTell(doc->temp) - pageinfo->offset;
+ pageinfo->length = (ssize_t)(cupsFileTell(doc->temp) - pageinfo->offset);
}
/*
if (!number)
{
pageinfo = (pstops_page_t *)cupsArrayFirst(doc->pages);
- copy_bytes(doc->temp, 0, pageinfo->offset);
+ copy_bytes(doc->temp, 0, (size_t)pageinfo->offset);
}
/*
pageinfo->bounding_box[2], pageinfo->bounding_box[3]);
}
- copy_bytes(doc->temp, pageinfo->offset, pageinfo->length);
+ copy_bytes(doc->temp, pageinfo->offset, (size_t)pageinfo->length);
pageinfo = doc->slow_order ? (pstops_page_t *)cupsArrayPrev(doc->pages) :
(pstops_page_t *)cupsArrayNext(doc->pages);
ssize_t linelen, /* I - Length of initial line */
size_t linesize) /* I - Size of line buffer */
{
- int copy; /* Current copy */
- char buffer[8192]; /* Copy buffer */
- int bytes; /* Number of bytes copied */
+ int copy; /* Current copy */
+ char buffer[8192]; /* Copy buffer */
+ ssize_t bytes; /* Number of bytes copied */
+ (void)linesize;
+
/*
* First let the user know that they are attempting to print a file
* that may not print correctly...
puts("%%EndPageSetup");
puts("%%BeginDocument: nondsc");
- fwrite(line, linelen, 1, stdout);
+ fwrite(line, (size_t)linelen, 1, stdout);
if (doc->temp)
- cupsFileWrite(doc->temp, line, linelen);
+ cupsFileWrite(doc->temp, line, (size_t)linelen);
while ((bytes = cupsFileRead(fp, buffer, sizeof(buffer))) > 0)
{
- fwrite(buffer, 1, bytes, stdout);
+ fwrite(buffer, 1, (size_t)bytes, stdout);
if (doc->temp)
- cupsFileWrite(doc->temp, buffer, bytes);
+ cupsFileWrite(doc->temp, buffer, (size_t)bytes);
}
puts("%%EndDocument");
memcpy(bounding_box, doc->bounding_box, sizeof(bounding_box));
- while ((linelen = cupsFileGetLine(fp, line, linesize)) > 0)
+ while ((linelen = (ssize_t)cupsFileGetLine(fp, line, linesize)) > 0)
{
if (!strncmp(line, "%%PageBoundingBox:", 18))
{
switch (Orientation)
{
case 1 : /* Landscape */
- bounding_box[0] = PageLength - temp_bbox[3];
+ bounding_box[0] = (int)(PageLength - temp_bbox[3]);
bounding_box[1] = temp_bbox[0];
- bounding_box[2] = PageLength - temp_bbox[1];
+ bounding_box[2] = (int)(PageLength - temp_bbox[1]);
bounding_box[3] = temp_bbox[2];
break;
case 2 : /* Reverse Portrait */
- bounding_box[0] = PageWidth - temp_bbox[2];
- bounding_box[1] = PageLength - temp_bbox[3];
- bounding_box[2] = PageWidth - temp_bbox[0];
- bounding_box[3] = PageLength - temp_bbox[1];
+ bounding_box[0] = (int)(PageWidth - temp_bbox[2]);
+ bounding_box[1] = (int)(PageLength - temp_bbox[3]);
+ bounding_box[2] = (int)(PageWidth - temp_bbox[0]);
+ bounding_box[3] = (int)(PageLength - temp_bbox[1]);
break;
case 3 : /* Reverse Landscape */
bounding_box[0] = temp_bbox[1];
- bounding_box[1] = PageWidth - temp_bbox[2];
+ bounding_box[1] = (int)(PageWidth - temp_bbox[2]);
bounding_box[2] = temp_bbox[3];
- bounding_box[3] = PageWidth - temp_bbox[0];
+ bounding_box[3] = (int)(PageWidth - temp_bbox[0]);
break;
}
{
int feature = 0; /* In a Begin/EndFeature block? */
- while ((linelen = cupsFileGetLine(fp, line, linesize)) > 0)
+ while ((linelen = (ssize_t)cupsFileGetLine(fp, line, linesize)) > 0)
{
if (!strncmp(line, "%%EndPageSetup", 14))
break;
break;
if (!feature || (doc->number_up == 1 && !doc->fit_to_page))
- doc_write(doc, line, linelen);
+ doc_write(doc, line, (size_t)linelen);
}
/*
*/
if (linelen > 0 && !strncmp(line, "%%EndPageSetup", 14))
- linelen = cupsFileGetLine(fp, line, linesize);
+ linelen = (ssize_t)cupsFileGetLine(fp, line, linesize);
}
if (first_page)
else if (!strncmp(line, "%%BeginDocument", 15) ||
!strncmp(line, "%ADO_BeginApplication", 21))
{
- doc_write(doc, line, linelen);
+ doc_write(doc, line, (size_t)linelen);
level ++;
}
else if ((!strncmp(line, "%%EndDocument", 13) ||
!strncmp(line, "%ADO_EndApplication", 19)) && level > 0)
{
- doc_write(doc, line, linelen);
+ doc_write(doc, line, (size_t)linelen);
level --;
}
int bytes; /* Bytes of data */
- doc_write(doc, line, linelen);
+ doc_write(doc, line, (size_t)linelen);
bytes = atoi(strchr(line, ':') + 1);
while (bytes > 0)
{
- if (bytes > linesize)
+ if ((size_t)bytes > linesize)
linelen = cupsFileRead(fp, line, linesize);
else
- linelen = cupsFileRead(fp, line, bytes);
+ linelen = cupsFileRead(fp, line, (size_t)bytes);
if (linelen < 1)
{
return (0);
}
- doc_write(doc, line, linelen);
+ doc_write(doc, line, (size_t)linelen);
bytes -= linelen;
}
}
else
- doc_write(doc, line, linelen);
+ doc_write(doc, line, (size_t)linelen);
}
- while ((linelen = cupsFileGetLine(fp, line, linesize)) > 0);
+ while ((linelen = (ssize_t)cupsFileGetLine(fp, line, linesize)) > 0);
/*
* Finish up this page and return...
end_nup(doc, number);
- pageinfo->length = cupsFileTell(doc->temp) - pageinfo->offset;
+ pageinfo->length = (ssize_t)(cupsFileTell(doc->temp) - pageinfo->offset);
return (linelen);
}
if (!strncmp(line, "%%BeginSetup", 12) || !strncmp(line, "%%Page:", 7))
break;
- doc_write(doc, line, linelen);
+ doc_write(doc, line, (size_t)linelen);
- if ((linelen = cupsFileGetLine(fp, line, linesize)) == 0)
+ if ((linelen = (ssize_t)cupsFileGetLine(fp, line, linesize)) == 0)
break;
}
if (!strncmp(line, "%%BeginProlog", 13))
{
- while ((linelen = cupsFileGetLine(fp, line, linesize)) > 0)
+ while ((linelen = (ssize_t)cupsFileGetLine(fp, line, linesize)) > 0)
{
if (!strncmp(line, "%%EndProlog", 11) ||
!strncmp(line, "%%BeginSetup", 12) ||
!strncmp(line, "%%Page:", 7))
break;
- doc_write(doc, line, linelen);
+ doc_write(doc, line, (size_t)linelen);
}
if (!strncmp(line, "%%EndProlog", 11))
- linelen = cupsFileGetLine(fp, line, linesize);
+ linelen = (ssize_t)cupsFileGetLine(fp, line, linesize);
else
fputs("DEBUG: The %%EndProlog comment is missing.\n", stderr);
}
if (!strncmp(line, "%%Page:", 7))
break;
- doc_write(doc, line, linelen);
+ doc_write(doc, line, (size_t)linelen);
- if ((linelen = cupsFileGetLine(fp, line, linesize)) == 0)
+ if ((linelen = (ssize_t)cupsFileGetLine(fp, line, linesize)) == 0)
break;
}
num_options = include_feature(ppd, line, num_options, &options);
}
else if (strncmp(line, "%%BeginSetup", 12))
- doc_write(doc, line, linelen);
+ doc_write(doc, line, (size_t)linelen);
- if ((linelen = cupsFileGetLine(fp, line, linesize)) == 0)
+ if ((linelen = (ssize_t)cupsFileGetLine(fp, line, linesize)) == 0)
break;
}
if (!strncmp(line, "%%EndSetup", 10))
- linelen = cupsFileGetLine(fp, line, linesize);
+ linelen = (ssize_t)cupsFileGetLine(fp, line, linesize);
else
fputs("DEBUG: The %%EndSetup comment is missing.\n", stderr);
}
* Write the trailer comments...
*/
+ (void)ppd;
+
puts("%%Trailer");
while (linelen > 0)
else if (strncmp(line, "%%Trailer", 9) &&
strncmp(line, "%%Pages:", 8) &&
strncmp(line, "%%BoundingBox:", 14))
- fwrite(line, 1, linelen, stdout);
+ fwrite(line, 1, (size_t)linelen, stdout);
- linelen = cupsFileGetLine(fp, line, linesize);
+ linelen = (ssize_t)cupsFileGetLine(fp, line, linesize);
}
fprintf(stderr, "DEBUG: Wrote %d pages...\n", number);
{
va_list ap; /* Pointer to arguments */
char buffer[1024]; /* Output buffer */
- size_t bytes; /* Number of bytes to write */
+ ssize_t bytes; /* Number of bytes to write */
va_start(ap, format);
bytes = vsnprintf(buffer, sizeof(buffer), format, ap);
va_end(ap);
- if (bytes > sizeof(buffer))
+ if ((size_t)bytes > sizeof(buffer))
{
_cupsLangPrintFilter(stderr, "ERROR",
_("Buffer overflow detected, aborting."));
exit(1);
}
- doc_write(doc, buffer, bytes);
+ doc_write(doc, buffer, (size_t)bytes);
}
level = 0;
- while ((linelen = cupsFileGetLine(fp, line, linesize)) > 0)
+ while ((linelen = (ssize_t)cupsFileGetLine(fp, line, linesize)) > 0)
{
if (level == 0 &&
(!strncmp(line, "%%Page:", 7) || !strncmp(line, "%%Trailer", 9)))
* Skip binary data...
*/
- int bytes; /* Bytes of data */
-
+ ssize_t bytes; /* Bytes of data */
bytes = atoi(strchr(line, ':') + 1);
while (bytes > 0)
{
- if (bytes > linesize)
- linelen = cupsFileRead(fp, line, linesize);
+ if ((size_t)bytes > linesize)
+ linelen = (ssize_t)cupsFileRead(fp, line, linesize);
else
- linelen = cupsFileRead(fp, line, bytes);
+ linelen = (ssize_t)cupsFileRead(fp, line, (size_t)bytes);
if (linelen < 1)
{
{
int pos; /* Position on page */
int x, y; /* Relative position of subpage */
- float w, l, /* Width and length of subpage */
+ double w, l, /* Width and length of subpage */
tx, ty; /* Translation values for subpage */
- float pagew, /* Printable width of page */
+ double pagew, /* Printable width of page */
pagel; /* Printable height of page */
int bboxx, /* BoundingBox X origin */
bboxy, /* BoundingBox Y origin */
bboxw, /* BoundingBox width */
bboxl; /* BoundingBox height */
- float margin = 0; /* Current margin for border */
+ double margin = 0; /* Current margin for border */
if (doc->number_up > 1)
{
bboxx = 0;
bboxy = 0;
- bboxw = PageWidth;
- bboxl = PageLength;
+ bboxw = (int)PageWidth;
+ bboxl = (int)PageLength;
}
fprintf(stderr, "DEBUG: pagew = %.1f, pagel = %.1f\n", pagew, pagel);
if (doc->page_border && show_border)
{
int rects; /* Number of border rectangles */
- float fscale; /* Scaling value for points */
+ double fscale; /* Scaling value for points */
rects = (doc->page_border & PSTOPS_BORDERDOUBLE) ? 2 : 1;
{
int i; /* Looping var */
ppd_option_t *option; /* PPD option */
- int min_order; /* Minimum OrderDependency value */
+ float min_order; /* Minimum OrderDependency value */
char *doc_setup, /* DocumentSetup commands to send */
*any_setup; /* AnySetup commands to send */
/*
* "$Id$"
*
- * Raster file routines for CUPS.
+ * Raster file routines for CUPS.
*
- * Copyright 2007-2012 by Apple Inc.
- * Copyright 1997-2006 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2006 by Easy Software Products.
*
- * This file is part of the CUPS Imaging library.
+ * This file is part of the CUPS Imaging library.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * cupsRasterClose() - Close a raster stream.
- * cupsRasterOpen() - Open a raster stream using a file descriptor.
- * cupsRasterOpenIO() - Open a raster stream using a callback function.
- * cupsRasterReadHeader() - Read a raster page header and store it in a
- * version 1 page header structure.
- * cupsRasterReadHeader2() - Read a raster page header and store it in a
- * version 2 page header structure.
- * cupsRasterReadPixels() - Read raster pixels.
- * cupsRasterWriteHeader() - Write a raster page header from a version 1
- * page header structure.
- * cupsRasterWriteHeader2() - Write a raster page header from a version 2
- * page header structure.
- * cupsRasterWritePixels() - Write raster pixels.
- * cups_raster_read_header() - Read a raster page header.
- * cups_raster_read() - Read through the raster buffer.
- * cups_raster_update() - Update the raster header and row count for the
- * current page.
- * cups_raster_write() - Write a row of compressed raster data...
- * cups_read_fd() - Read bytes from a file.
- * cups_swap() - Swap bytes in raster data...
- * cups_write_fd() - Write bytes to a file.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
cups_raster_iocb_t iocb; /* IO callback */
cups_mode_t mode; /* Read/write mode */
cups_page_header2_t header; /* Raster header for current page */
- int count, /* Current row run-length count */
+ unsigned count, /* Current row run-length count */
remaining, /* Remaining rows in page image */
bpp; /* Bytes per pixel/color */
unsigned char *pixels, /* Pixels for current row */
* Local functions...
*/
-static int cups_raster_io(cups_raster_t *r, unsigned char *buf, int bytes);
+static ssize_t cups_raster_io(cups_raster_t *r, unsigned char *buf, size_t bytes);
static unsigned cups_raster_read_header(cups_raster_t *r);
-static int cups_raster_read(cups_raster_t *r, unsigned char *buf,
- int bytes);
+static ssize_t cups_raster_read(cups_raster_t *r, unsigned char *buf,
+ size_t bytes);
static void cups_raster_update(cups_raster_t *r);
-static int cups_raster_write(cups_raster_t *r,
+static ssize_t cups_raster_write(cups_raster_t *r,
const unsigned char *pixels);
static ssize_t cups_read_fd(void *ctx, unsigned char *buf, size_t bytes);
-static void cups_swap(unsigned char *buf, int bytes);
+static void cups_swap(unsigned char *buf, size_t bytes);
static ssize_t cups_write_fd(void *ctx, unsigned char *buf, size_t bytes);
break;
}
- if (cups_raster_io(r, (unsigned char *)&(r->sync), sizeof(r->sync))
- < sizeof(r->sync))
+ if (cups_raster_io(r, (unsigned char *)&(r->sync), sizeof(r->sync)) < (ssize_t)sizeof(r->sync))
{
_cupsRasterAddError("Unable to write raster stream header: %s\n",
strerror(errno));
unsigned char *p, /* I - Pointer to pixel buffer */
unsigned len) /* I - Number of bytes to read */
{
- int bytes; /* Bytes read */
+ ssize_t bytes; /* Bytes read */
unsigned cupsBytesPerLine; /* cupsBytesPerLine value */
unsigned remaining; /* Bytes remaining */
unsigned char *ptr, /* Pointer to read buffer */
byte, /* Byte from file */
*temp; /* Pointer into buffer */
- int count; /* Repetition count */
+ unsigned count; /* Repetition count */
if (r == NULL || r->mode != CUPS_RASTER_READ || r->remaining == 0 ||
ptr = r->pixels;
temp = ptr;
- bytes = cupsBytesPerLine;
+ bytes = (ssize_t)cupsBytesPerLine;
while (bytes > 0)
{
* Copy N literal pixels...
*/
- count = (257 - byte) * r->bpp;
+ count = (unsigned)(257 - byte) * r->bpp;
- if (count > bytes)
- count = bytes;
+ if (count > (unsigned)bytes)
+ count = (unsigned)bytes;
if (!cups_raster_read(r, temp, count))
return (0);
*/
count = (byte + 1) * r->bpp;
- if (count > bytes)
- count = bytes;
+ if (count > (unsigned)bytes)
+ count = (unsigned)bytes;
if (count < r->bpp)
break;
r->header.cupsBitsPerPixel == 12 ||
r->header.cupsBitsPerPixel == 16) &&
r->swapped)
- cups_swap(ptr, bytes);
+ cups_swap(ptr, (size_t)bytes);
/*
* Update pointers...
if (remaining >= cupsBytesPerLine)
{
- bytes = cupsBytesPerLine;
+ bytes = (ssize_t)cupsBytesPerLine;
r->pcurrent = r->pixels;
r->count --;
r->remaining --;
}
else
{
- bytes = remaining;
+ bytes = (ssize_t)remaining;
r->pcurrent = r->pixels + bytes;
}
*/
if ((unsigned)(bytes = (int)(r->pend - r->pcurrent)) > remaining)
- bytes = remaining;
+ bytes = (ssize_t)remaining;
memcpy(p, r->pcurrent, bytes);
r->pcurrent += bytes;
}
}
- remaining -= bytes;
+ remaining -= (unsigned)bytes;
p += bytes;
}
unsigned char *p, /* I - Bytes to write */
unsigned len)/* I - Number of bytes to write */
{
- int bytes; /* Bytes read */
+ ssize_t bytes; /* Bytes read */
unsigned remaining; /* Bytes remaining */
* Write the byte-swapped buffer...
*/
- return (cups_raster_io(r, r->buffer, len));
+ return ((unsigned)cups_raster_io(r, r->buffer, len));
}
else
- return (cups_raster_io(r, p, len));
+ return ((unsigned)cups_raster_io(r, p, len));
}
/*
* Otherwise, compress each line...
*/
- for (remaining = len; remaining > 0; remaining -= bytes, p += bytes)
+ for (remaining = len; remaining > 0; remaining -= (unsigned)bytes, p += bytes)
{
/*
* Figure out the number of remaining bytes on the current line...
*/
- if ((bytes = remaining) > (int)(r->pend - r->pcurrent))
- bytes = (int)(r->pend - r->pcurrent);
+ if ((bytes = (ssize_t)remaining) > (ssize_t)(r->pend - r->pcurrent))
+ bytes = (ssize_t)(r->pend - r->pcurrent);
if (r->count > 0)
{
* Check to see if this line is the same as the previous line...
*/
- if (memcmp(p, r->pcurrent, bytes))
+ if (memcmp(p, r->pcurrent, (size_t)bytes))
{
if (!cups_raster_write(r, r->pixels))
return (0);
r->remaining --;
if (r->remaining == 0)
- return (cups_raster_write(r, r->pixels));
+ return ((unsigned)cups_raster_write(r, r->pixels));
else if (r->count == 256)
{
if (cups_raster_write(r, r->pixels) == 0)
r->remaining --;
if (r->remaining == 0)
- return (cups_raster_write(r, r->pixels));
+ return ((unsigned)cups_raster_write(r, r->pixels));
}
}
}
cups_raster_read_header(
cups_raster_t *r) /* I - Raster stream */
{
- int len; /* Length for read/swap */
+ size_t len; /* Length for read/swap */
if (r == NULL || r->mode != CUPS_RASTER_READ)
memset(&(r->header), 0, sizeof(r->header));
- if (cups_raster_read(r, (unsigned char *)&(r->header), len) < len)
+ if (cups_raster_read(r, (unsigned char *)&(r->header), len) < (ssize_t)len)
return (0);
/*
* 'cups_raster_io()' - Read/write bytes from a context, handling interruptions.
*/
-static int /* O - Bytes read or -1 */
+static ssize_t /* O - Bytes read/write or -1 */
cups_raster_io(cups_raster_t *r, /* I - Raster stream */
- unsigned char *buf, /* I - Buffer for read/write */
- int bytes) /* I - Number of bytes to read/write */
+ unsigned char *buf, /* I - Buffer for read/write */
+ size_t bytes) /* I - Number of bytes to read/write */
{
- ssize_t count; /* Number of bytes read/written */
- size_t total; /* Total bytes read/written */
+ ssize_t count, /* Number of bytes read/written */
+ total; /* Total bytes read/written */
- DEBUG_printf(("4cups_raster_io(r=%p, buf=%p, bytes=%d)", r, buf, bytes));
+ DEBUG_printf(("4cups_raster_io(r=%p, buf=%p, bytes=" CUPS_LLFMT ")", r, buf, CUPS_LLCAST bytes));
- for (total = 0; total < (size_t)bytes; total += count, buf += count)
+ for (total = 0; total < (ssize_t)bytes; total += count, buf += count)
{
- count = (*r->iocb)(r->ctx, buf, bytes - total);
+ count = (*r->iocb)(r->ctx, buf, bytes - (size_t)total);
DEBUG_printf(("5cups_raster_io: count=%d, total=%d", (int)count,
(int)total));
return (-1);
}
- return ((int)total);
+ return (total);
}
* 'cups_raster_read()' - Read through the raster buffer.
*/
-static int /* O - Number of bytes read */
+static ssize_t /* O - Number of bytes read */
cups_raster_read(cups_raster_t *r, /* I - Raster stream */
unsigned char *buf, /* I - Buffer */
- int bytes) /* I - Number of bytes to read */
+ size_t bytes) /* I - Number of bytes to read */
{
- int count, /* Number of bytes read */
+ ssize_t count, /* Number of bytes read */
remaining, /* Remaining bytes in buffer */
total; /* Total bytes read */
- DEBUG_printf(("cups_raster_read(r=%p, buf=%p, bytes=%d)\n", r, buf, bytes));
+ DEBUG_printf(("cups_raster_read(r=%p, buf=%p, bytes=" CUPS_LLFMT ")\n", r, buf, CUPS_LLCAST bytes));
if (!r->compressed)
return (cups_raster_io(r, buf, bytes));
* Allocate a read buffer as needed...
*/
- count = 2 * r->header.cupsBytesPerLine;
+ count = (ssize_t)(2 * r->header.cupsBytesPerLine);
if ((size_t)count > r->bufsize)
{
- int offset = (int)(r->bufptr - r->buffer);
+ ssize_t offset = r->bufptr - r->buffer;
/* Offset to current start of buffer */
- int end = (int)(r->bufend - r->buffer);
- /* Offset to current end of buffer */
+ ssize_t end = r->bufend - r->buffer;/* Offset to current end of buffer */
unsigned char *rptr; /* Pointer in read buffer */
if (r->buffer)
- rptr = realloc(r->buffer, count);
+ rptr = realloc(r->buffer, (size_t)count);
else
- rptr = malloc(count);
+ rptr = malloc((size_t)count);
if (!rptr)
return (0);
r->buffer = rptr;
r->bufptr = rptr + offset;
r->bufend = rptr + end;
- r->bufsize = count;
+ r->bufsize = (size_t)count;
}
/*
*/
for (total = 0, remaining = (int)(r->bufend - r->bufptr);
- total < bytes;
+ total < (ssize_t)bytes;
total += count, buf += count)
{
- count = bytes - total;
+ count = (ssize_t)bytes - total;
- DEBUG_printf(("count=%d, remaining=%d, buf=%p, bufptr=%p, bufend=%p...\n",
- count, remaining, buf, r->bufptr, r->bufend));
+ DEBUG_printf(("count=" CUPS_LLFMT ", remaining=" CUPS_LLFMT ", buf=%p, bufptr=%p, bufend=%p...\n", CUPS_LLCAST count, CUPS_LLCAST remaining, buf, r->bufptr, r->bufend));
if (remaining == 0)
{
* Read directly into "buf"...
*/
- count = (*r->iocb)(r->ctx, buf, count);
+ count = (*r->iocb)(r->ctx, buf, (size_t)count);
if (count <= 0)
return (0);
* 'cups_raster_write()' - Write a row of compressed raster data...
*/
-static int /* O - Number of bytes written */
+static ssize_t /* O - Number of bytes written */
cups_raster_write(
cups_raster_t *r, /* I - Raster stream */
const unsigned char *pixels) /* I - Pixel data to write */
*pend, /* End of raster buffer */
*plast; /* Pointer to last pixel */
unsigned char *wptr; /* Pointer into write buffer */
- int bpp, /* Bytes per pixel */
+ unsigned bpp, /* Bytes per pixel */
count; /* Count */
pend = pixels + r->header.cupsBytesPerLine;
plast = pend - bpp;
wptr = r->buffer;
- *wptr++ = r->count - 1;
+ *wptr++ = (unsigned char)(r->count - 1);
/*
* Write using a modified PackBits compression...
if (memcmp(ptr, ptr + bpp, bpp))
break;
- *wptr++ = count - 1;
+ *wptr++ = (unsigned char)(count - 1);
for (count = bpp; count > 0; count --)
*wptr++ = *ptr++;
}
ptr += bpp;
}
- *wptr++ = 257 - count;
+ *wptr++ = (unsigned char)(257 - count);
count *= bpp;
memcpy(wptr, start, count);
}
}
- return (cups_raster_io(r, r->buffer, (int)(wptr - r->buffer)));
+ return (cups_raster_io(r, r->buffer, (size_t)(wptr - r->buffer)));
}
static void
cups_swap(unsigned char *buf, /* I - Buffer to swap */
- int bytes) /* I - Number of bytes to swap */
+ size_t bytes) /* I - Number of bytes to swap */
{
unsigned char even, odd; /* Temporary variables */
/*
* "$Id$"
*
- * Raster benchmark program for CUPS.
+ * Raster benchmark program for CUPS.
*
- * Copyright 2007-2011 by Apple Inc.
- * Copyright 1997-2006 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2006 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * main() - Benchmark the raster read/write functions.
- * compute_median() - Compute the median time for a test.
- * read_test() - Benchmark the raster read functions.
- * write_test() - Benchmark the raster write functions.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
static void
read_test(int fd) /* I - File descriptor to read from */
{
- int y; /* Looping var */
+ unsigned y; /* Looping var */
cups_raster_t *r; /* Raster stream */
cups_page_header2_t header; /* Page header */
unsigned char buffer[8 * TEST_WIDTH];
write_test(int fd, /* I - File descriptor to write to */
cups_mode_t mode) /* I - Write mode */
{
- int page, x, y; /* Looping vars */
- int count; /* Number of bytes to set */
+ unsigned page, x, y; /* Looping vars */
+ unsigned count; /* Number of bytes to set */
cups_raster_t *r; /* Raster stream */
cups_page_header2_t header; /* Page header */
unsigned char data[32][8 * TEST_WIDTH];
break;
}
- data[y][x] = CUPS_RAND();
+ data[y][x] = (unsigned char)CUPS_RAND();
}
}
/*
* "$Id$"
*
- * EPSON ESC/P and ESC/P2 filter for CUPS.
+ * EPSON ESC/P and ESC/P2 filter for CUPS.
*
- * Copyright 2007-2012 by Apple Inc.
- * Copyright 1993-2007 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1993-2007 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * Setup() - Prepare the printer for printing.
- * StartPage() - Start a page of graphics.
- * EndPage() - Finish a page of graphics.
- * Shutdown() - Shutdown the printer.
- * CompressData() - Compress a line of graphics.
- * OutputLine() - Output a line of graphics.
- * main() - Main entry and processing of driver.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
*CompBuffer, /* Compression buffer */
*LineBuffers[2]; /* Line bitmap buffers */
int Model, /* Model number */
- NumPlanes, /* Number of color planes */
+ EjectPage, /* Eject the page when done? */
+ Shingling, /* Shingle output? */
+ Canceled; /* Has the current job been canceled? */
+unsigned NumPlanes, /* Number of color planes */
Feed, /* Number of lines to skip */
- EjectPage; /* Eject the page when done? */
-int DotBit, /* Bit in buffers */
+ DotBit, /* Bit in buffers */
DotBytes, /* # bytes in a dot column */
DotColumns, /* # columns in 1/60 inch */
LineCount, /* # of lines processed */
EvenOffset, /* Offset into 'even' buffers */
- OddOffset, /* Offset into 'odd' buffers */
- Shingling, /* Shingle output? */
- Canceled; /* Has the current job been canceled? */
+ OddOffset; /* Offset into 'odd' buffers */
/*
void Shutdown(void);
void CancelJob(int sig);
-void CompressData(const unsigned char *line, int length, int plane,
- int type, int xstep, int ystep);
+void CompressData(const unsigned char *line, unsigned length, unsigned plane,
+ unsigned type, unsigned xstep, unsigned ystep);
void OutputLine(const cups_page_header2_t *header);
void OutputRows(const cups_page_header2_t *header, int row);
const ppd_file_t *ppd, /* I - PPD file */
const cups_page_header2_t *header) /* I - Page header */
{
- int n, t; /* Numbers */
- int plane; /* Looping var */
+ int n, t; /* Numbers */
+ unsigned plane; /* Looping var */
/*
putchar(0x05);
}
- n = header->PageSize[1] * header->HWResolution[1] / 72.0;
+ n = (int)(header->PageSize[1] * header->HWResolution[1] / 72.0);
pwrite("\033(C\002\000", 5); /* Page length */
putchar(n);
putchar(n >> 8);
if (ppd)
- t = (ppd->sizes[1].length - ppd->sizes[1].top) *
- header->HWResolution[1] / 72.0;
+ t = (int)((ppd->sizes[1].length - ppd->sizes[1].top) * header->HWResolution[1] / 72.0);
else
t = 0;
if (DotBytes)
{
- if ((LineBuffers[0] = calloc(DotBytes,
- header->cupsWidth * (Shingling + 1))) == NULL)
+ if ((LineBuffers[0] = calloc((size_t)DotBytes, header->cupsWidth * (size_t)(Shingling + 1))) == NULL)
{
fputs("ERROR: Unable to allocate memory\n", stderr);
exit(1);
void
CompressData(const unsigned char *line, /* I - Data to compress */
- int length,/* I - Number of bytes */
- int plane, /* I - Color plane */
- int type, /* I - Type of compression */
- int xstep, /* I - X resolution */
- int ystep) /* I - Y resolution */
+ unsigned length,/* I - Number of bytes */
+ unsigned plane, /* I - Color plane */
+ unsigned type, /* I - Type of compression */
+ unsigned xstep, /* I - X resolution */
+ unsigned ystep) /* I - Y resolution */
{
const unsigned char *line_ptr, /* Current byte pointer */
*line_end, /* End-of-line byte pointer */
count ++;
}
- *comp_ptr++ = 257 - count;
+ *comp_ptr++ = (unsigned char)(257 - count);
*comp_ptr++ = *line_ptr++;
}
else
count ++;
}
- *comp_ptr++ = count - 1;
+ *comp_ptr++ = (unsigned char)(count - 1);
memcpy(comp_ptr, start, count);
comp_ptr += count;
length *= 8;
printf("\033."); /* Raster graphics */
- putchar(type);
- putchar(ystep);
- putchar(xstep);
+ putchar((int)type);
+ putchar((int)ystep);
+ putchar((int)xstep);
putchar(1);
- putchar(length);
- putchar(length >> 8);
+ putchar((int)length);
+ putchar((int)(length >> 8));
}
else
{
printf("\033i");
putchar(ctable[plane]);
- putchar(type);
+ putchar((int)type);
putchar(1);
- putchar(length & 255);
- putchar(length >> 8);
+ putchar((int)length);
+ putchar((int)(length >> 8));
putchar(1);
putchar(0);
}
- pwrite(line_ptr, line_end - line_ptr);
+ pwrite(line_ptr, (size_t)(line_end - line_ptr));
fflush(stdout);
}
{
if (header->cupsRowCount)
{
- int width;
+ unsigned width;
unsigned char *tempptr,
*evenptr,
*oddptr;
- register int x;
+ unsigned int x;
unsigned char bit;
const unsigned char *pixel;
unsigned char *temp;
}
else
{
- int plane; /* Current plane */
- int bytes; /* Bytes per plane */
- int xstep, ystep; /* X & Y resolutions */
-
+ unsigned plane; /* Current plane */
+ unsigned bytes; /* Bytes per plane */
+ unsigned xstep, ystep; /* X & Y resolutions */
/*
* Write a single line of bitmap data as needed...
*/
if (!Planes[plane][0] &&
- memcmp(Planes[plane], Planes[plane] + 1, bytes - 1) == 0)
+ memcmp(Planes[plane], Planes[plane] + 1, (size_t)bytes - 1) == 0)
continue;
/*
if (Feed > 0)
{
pwrite("\033(v\002\000", 5); /* Relative vertical position */
- putchar(Feed);
- putchar(Feed >> 8);
+ putchar((int)Feed);
+ putchar((int)(Feed >> 8));
Feed = 0;
}
- CompressData(Planes[plane], bytes, plane, header->cupsCompression, xstep,
- ystep);
+ CompressData(Planes[plane], bytes, plane, header->cupsCompression, xstep, ystep);
}
Feed ++;
const cups_page_header2_t *header, /* I - Page image header */
int row) /* I - Row number (0 or 1) */
{
- unsigned i, n; /* Looping vars */
- int dot_count, /* Number of bytes to print */
+ unsigned i, n, /* Looping vars */
+ dot_count, /* Number of bytes to print */
dot_min; /* Minimum number of bytes */
unsigned char *dot_ptr, /* Pointer to print data */
*ptr; /* Current data */
dot_min = DotBytes * DotColumns;
if (LineBuffers[row][0] != 0 ||
- memcmp(LineBuffers[row], LineBuffers[row] + 1,
- header->cupsWidth * DotBytes - 1))
+ memcmp(LineBuffers[row], LineBuffers[row] + 1, header->cupsWidth * DotBytes - 1))
{
/*
* Skip leading space...
break;
}
- n = (unsigned)dot_count / DotBytes;
+ n = dot_count / DotBytes;
putchar(n & 255);
putchar(n / 256);
cups_page_header2_t header; /* Page header from file */
ppd_file_t *ppd; /* PPD file */
int page; /* Current page */
- int y; /* Current line */
+ unsigned y; /* Current line */
#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
struct sigaction action; /* Actions for POSIX signals */
#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
if ((y & 127) == 0)
{
_cupsLangPrintFilter(stderr, "INFO",
- _("Printing page %d, %d%% complete."),
+ _("Printing page %d, %u%% complete."),
page, 100 * y / header.cupsHeight);
- fprintf(stderr, "ATTR: job-media-progress=%d\n",
+ fprintf(stderr, "ATTR: job-media-progress=%u\n",
100 * y / header.cupsHeight);
}
/*
* "$Id$"
*
- * Hewlett-Packard Page Control Language filter for CUPS.
+ * Hewlett-Packard Page Control Language filter for CUPS.
*
- * Copyright 2007-2012 by Apple Inc.
- * Copyright 1993-2007 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1993-2007 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * Setup() - Prepare the printer for printing.
- * StartPage() - Start a page of graphics.
- * EndPage() - Finish a page of graphics.
- * Shutdown() - Shutdown the printer.
- * CancelJob() - Cancel the current job...
- * CompressData() - Compress a line of graphics.
- * OutputLine() - Output a line of graphics.
- * main() - Main entry and processing of driver.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
unsigned char *Planes[4], /* Output buffers */
*CompBuffer, /* Compression buffer */
*BitBuffer; /* Buffer for output bits */
-int NumPlanes, /* Number of color planes */
+unsigned NumPlanes, /* Number of color planes */
ColorBits, /* Number of bits per color */
- Feed, /* Number of lines to skip */
- Duplex, /* Current duplex mode */
+ Feed; /* Number of lines to skip */
+int Duplex, /* Current duplex mode */
Page, /* Current page number */
Canceled; /* Has the current job been canceled? */
void Shutdown(void);
void CancelJob(int sig);
-void CompressData(unsigned char *line, int length, int plane, int type);
+void CompressData(unsigned char *line, unsigned length, unsigned plane, unsigned type);
void OutputLine(cups_page_header2_t *header);
StartPage(ppd_file_t *ppd, /* I - PPD file */
cups_page_header2_t *header) /* I - Page header */
{
- int plane; /* Looping var */
+ unsigned plane; /* Looping var */
/*
printf("\033*g26W");
putchar(2); /* Format 2 */
- putchar(NumPlanes); /* Output planes */
+ putchar((int)NumPlanes); /* Output planes */
- putchar(header->HWResolution[0] >> 8); /* Black resolution */
- putchar(header->HWResolution[0]);
- putchar(header->HWResolution[1] >> 8);
- putchar(header->HWResolution[1]);
+ putchar((int)(header->HWResolution[0] >> 8));/* Black resolution */
+ putchar((int)header->HWResolution[0]);
+ putchar((int)(header->HWResolution[1] >> 8));
+ putchar((int)header->HWResolution[1]);
putchar(0);
putchar(1 << ColorBits); /* # of black levels */
- putchar(header->HWResolution[0] >> 8); /* Cyan resolution */
- putchar(header->HWResolution[0]);
- putchar(header->HWResolution[1] >> 8);
- putchar(header->HWResolution[1]);
+ putchar((int)(header->HWResolution[0] >> 8));/* Cyan resolution */
+ putchar((int)header->HWResolution[0]);
+ putchar((int)(header->HWResolution[1] >> 8));
+ putchar((int)header->HWResolution[1]);
putchar(0);
putchar(1 << ColorBits); /* # of cyan levels */
- putchar(header->HWResolution[0] >> 8); /* Magenta resolution */
- putchar(header->HWResolution[0]);
- putchar(header->HWResolution[1] >> 8);
- putchar(header->HWResolution[1]);
+ putchar((int)(header->HWResolution[0] >> 8));/* Magenta resolution */
+ putchar((int)header->HWResolution[0]);
+ putchar((int)(header->HWResolution[1] >> 8));
+ putchar((int)header->HWResolution[1]);
putchar(0);
putchar(1 << ColorBits); /* # of magenta levels */
- putchar(header->HWResolution[0] >> 8); /* Yellow resolution */
- putchar(header->HWResolution[0]);
- putchar(header->HWResolution[1] >> 8);
- putchar(header->HWResolution[1]);
+ putchar((int)(header->HWResolution[0] >> 8));/* Yellow resolution */
+ putchar((int)header->HWResolution[0]);
+ putchar((int)(header->HWResolution[1] >> 8));
+ putchar((int)header->HWResolution[1]);
putchar(0);
putchar(1 << ColorBits); /* # of yellow levels */
}
else
{
- printf("\033*t%dR", header->HWResolution[0]);
+ printf("\033*t%uR", header->HWResolution[0]);
/* Set resolution */
if (header->cupsColorSpace == CUPS_CSPACE_KCMY)
* Set size and position of graphics...
*/
- printf("\033*r%dS", header->cupsWidth); /* Set width */
- printf("\033*r%dT", header->cupsHeight); /* Set height */
+ printf("\033*r%uS", header->cupsWidth); /* Set width */
+ printf("\033*r%uT", header->cupsHeight); /* Set height */
printf("\033&a0H"); /* Set horizontal position */
printf("\033*r1A"); /* Start graphics */
if (header->cupsCompression)
- printf("\033*b%dM", /* Set compression */
+ printf("\033*b%uM", /* Set compression */
header->cupsCompression);
Feed = 0; /* No blank lines yet */
void
CompressData(unsigned char *line, /* I - Data to compress */
- int length, /* I - Number of bytes */
- int plane, /* I - Color plane */
- int type) /* I - Type of compression */
+ unsigned length, /* I - Number of bytes */
+ unsigned plane, /* I - Color plane */
+ unsigned type) /* I - Type of compression */
{
unsigned char *line_ptr, /* Current byte pointer */
*line_end, /* End-of-line byte pointer */
*comp_ptr, /* Pointer into compression buffer */
*start; /* Start of compression sequence */
- int count; /* Count of bytes for output */
+ unsigned count; /* Count of bytes for output */
switch (type)
count < 256;
count ++);
- comp_ptr[0] = count - 1;
+ comp_ptr[0] = (unsigned char)(count - 1);
comp_ptr[1] = line_ptr[0];
}
count ++;
}
- *comp_ptr++ = 257 - count;
+ *comp_ptr++ = (unsigned char)(257 - count);
*comp_ptr++ = *line_ptr++;
}
else
count ++;
}
- *comp_ptr++ = count - 1;
+ *comp_ptr++ = (unsigned char)(count - 1);
memcpy(comp_ptr, start, count);
comp_ptr += count;
*/
printf("\033*b%d%c", (int)(line_end - line_ptr), plane);
- fwrite(line_ptr, line_end - line_ptr, 1, stdout);
+ fwrite(line_ptr, (size_t)(line_end - line_ptr), 1, stdout);
}
void
OutputLine(cups_page_header2_t *header) /* I - Page header */
{
- int plane, /* Current plane */
+ unsigned plane, /* Current plane */
bytes, /* Bytes to write */
count; /* Bytes to convert */
unsigned char bit, /* Current plane data */
{
bit = plane_ptr[0];
- bit0 = ((bit & 64) << 1) | ((bit & 16) << 2) | ((bit & 4) << 3) | ((bit & 1) << 4);
- bit1 = (bit & 128) | ((bit & 32) << 1) | ((bit & 8) << 2) | ((bit & 2) << 3);
+ bit0 = (unsigned char)(((bit & 64) << 1) | ((bit & 16) << 2) | ((bit & 4) << 3) | ((bit & 1) << 4));
+ bit1 = (unsigned char)((bit & 128) | ((bit & 32) << 1) | ((bit & 8) << 2) | ((bit & 2) << 3));
if (count > 1)
{
bit = plane_ptr[1];
- bit0 |= (bit & 1) | ((bit & 4) >> 1) | ((bit & 16) >> 2) | ((bit & 64) >> 3);
- bit1 |= ((bit & 2) >> 1) | ((bit & 8) >> 2) | ((bit & 32) >> 3) | ((bit & 128) >> 4);
+ bit0 |= (unsigned char)((bit & 1) | ((bit & 4) >> 1) | ((bit & 16) >> 2) | ((bit & 64) >> 3));
+ bit1 |= (unsigned char)(((bit & 2) >> 1) | ((bit & 8) >> 2) | ((bit & 32) >> 3) | ((bit & 128) >> 4));
}
bit_ptr[0] = bit0;
int fd; /* File descriptor */
cups_raster_t *ras; /* Raster stream for printing */
cups_page_header2_t header; /* Page header from file */
- int y; /* Current line */
+ unsigned y; /* Current line */
ppd_file_t *ppd; /* PPD file */
#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
struct sigaction action; /* Actions for POSIX signals */
if ((y & 127) == 0)
{
_cupsLangPrintFilter(stderr, "INFO",
- _("Printing page %d, %d%% complete."),
+ _("Printing page %d, %u%% complete."),
Page, 100 * y / header.cupsHeight);
- fprintf(stderr, "ATTR: job-media-progress=%d\n",
+ fprintf(stderr, "ATTR: job-media-progress=%u\n",
100 * y / header.cupsHeight);
}
/*
* "$Id$"
*
- * Label printer filter for CUPS.
+ * Label printer filter for CUPS.
*
- * Copyright 2007-2012 by Apple Inc.
- * Copyright 2001-2007 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 2001-2007 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * Setup() - Prepare the printer for printing.
- * StartPage() - Start a page of graphics.
- * EndPage() - Finish a page of graphics.
- * CancelJob() - Cancel the current job...
- * OutputLine() - Output a line of graphics.
- * PCLCompress() - Output a PCL (mode 3) compressed line.
- * ZPLCompress() - Output a run-length compression sequence.
- * main() - Main entry and processing of driver.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
unsigned char *Buffer; /* Output buffer */
unsigned char *CompBuffer; /* Compression buffer */
unsigned char *LastBuffer; /* Last buffer */
+unsigned Feed; /* Number of lines to skip */
int LastSet; /* Number of repeat characters */
int ModelNumber, /* cupsModelNumber attribute */
Page, /* Current page */
- Feed, /* Number of lines to skip */
Canceled; /* Non-zero if job is canceled */
void StartPage(ppd_file_t *ppd, cups_page_header2_t *header);
void EndPage(ppd_file_t *ppd, cups_page_header2_t *header);
void CancelJob(int sig);
-void OutputLine(ppd_file_t *ppd, cups_page_header2_t *header, int y);
-void PCLCompress(unsigned char *line, int length);
-void ZPLCompress(char repeat_char, int repeat_count);
+void OutputLine(ppd_file_t *ppd, cups_page_header2_t *header, unsigned y);
+void PCLCompress(unsigned char *line, unsigned length);
+void ZPLCompress(unsigned char repeat_char, unsigned repeat_count);
/*
cups_page_header2_t *header) /* I - Page header */
{
ppd_choice_t *choice; /* Marked choice */
- int length; /* Actual label length */
+ unsigned length; /* Actual label length */
/*
if ((choice = ppdFindMarkedChoice(ppd, "zePrintRate")) != NULL &&
strcmp(choice->choice, "Default"))
{
- float val = atof(choice->choice);
+ double val = atof(choice->choice);
if (val >= 3.0)
printf("S%.0f\n", val);
*/
if (header->cupsCompression > 0 && header->cupsCompression <= 100)
- printf("D%d\n", 15 * header->cupsCompression / 100);
+ printf("D%u\n", 15 * header->cupsCompression / 100);
/*
* Set label size...
*/
- printf("q%d\n", (header->cupsWidth + 7) & ~7);
+ printf("q%u\n", (header->cupsWidth + 7) & ~7U);
break;
case ZEBRA_ZPL :
*/
if (header->cupsCompression > 0 && header->cupsCompression <= 100)
- printf("~SD%02d\n", 30 * header->cupsCompression / 100);
+ printf("~SD%02u\n", 30 * header->cupsCompression / 100);
/*
* Start bitmap graphics...
*/
- printf("~DGR:CUPS.GRF,%d,%d,\n",
+ printf("~DGR:CUPS.GRF,%u,%u,\n",
header->cupsHeight * header->cupsBytesPerLine,
header->cupsBytesPerLine);
printf("! 0 %u %u %u %u\r\n", header->HWResolution[0],
header->HWResolution[1], header->cupsHeight,
header->NumCopies);
- printf("PAGE-WIDTH %d\r\n", header->cupsWidth);
- printf("PAGE-HEIGHT %d\r\n", header->cupsWidth);
+ printf("PAGE-WIDTH %u\r\n", header->cupsWidth);
+ printf("PAGE-HEIGHT %u\r\n", header->cupsWidth);
break;
case INTELLITECH_PCL :
break;
default : /* Custom size */
- printf("\033!f%dZ", header->PageSize[1] * 300 / 72);
+ printf("\033!f%uZ", header->PageSize[1] * 300 / 72);
break;
}
- printf("\033&l%dP", /* Set page length */
+ printf("\033&l%uP", /* Set page length */
header->PageSize[1] / 12);
printf("\033&l0E"); /* Set top margin to 0 */
- printf("\033&l%dX", header->NumCopies);
+ if (header->NumCopies)
+ printf("\033&l%uX", header->NumCopies);
/* Set number copies */
printf("\033&l0L"); /* Turn off perforation skip */
if (Page == 1)
{
if (header->cupsRowFeed) /* inPrintRate */
- printf("\033!p%dS", header->cupsRowFeed);
+ printf("\033!p%uS", header->cupsRowFeed);
- if (header->cupsCompression != ~0)
+ if (header->cupsCompression != ~0U)
/* inPrintDensity */
- printf("\033&d%dA", 30 * header->cupsCompression / 100 - 15);
+ printf("\033&d%uA", 30 * header->cupsCompression / 100 - 15);
if ((choice = ppdFindMarkedChoice(ppd, "inPrintMode")) != NULL)
{
fputs("\033!p1M", stdout);
if (header->cupsRowCount) /* inTearInterval */
- printf("\033!n%dT", header->cupsRowCount);
+ printf("\033!n%uT", header->cupsRowCount);
}
else
{
fputs("\033!p2M", stdout);
if (header->cupsRowStep) /* inCutInterval */
- printf("\033!n%dC", header->cupsRowStep);
+ printf("\033!n%uC", header->cupsRowStep);
}
}
}
* Setup graphics...
*/
- printf("\033*t%dR", header->HWResolution[0]);
+ printf("\033*t%uR", header->HWResolution[0]);
/* Set resolution */
- printf("\033*r%dS", header->cupsWidth);
+ printf("\033*r%uS", header->cupsWidth);
/* Set width */
- printf("\033*r%dT", header->cupsHeight);
+ printf("\033*r%uT", header->cupsHeight);
/* Set height */
printf("\033&a0H"); /* Set horizontal position */
void
OutputLine(ppd_file_t *ppd, /* I - PPD file */
cups_page_header2_t *header, /* I - Page header */
- int y) /* I - Line number */
+ unsigned y) /* I - Line number */
{
- int i; /* Looping var */
+ unsigned i; /* Looping var */
unsigned char *ptr; /* Pointer into buffer */
unsigned char *compptr; /* Pointer into compression buffer */
- char repeat_char; /* Repeated character */
- int repeat_count; /* Number of repeated characters */
- static const char *hex = "0123456789ABCDEF";
+ unsigned char repeat_char; /* Repeated character */
+ unsigned repeat_count; /* Number of repeated characters */
+ static const unsigned char *hex = (const unsigned char *)"0123456789ABCDEF";
/* Hex digits */
+ (void)ppd;
+
switch (ModelNumber)
{
case DYMO_3x0 :
void
PCLCompress(unsigned char *line, /* I - Line to compress */
- int length) /* I - Length of line */
+ unsigned length) /* I - Length of line */
{
unsigned char *line_ptr, /* Current byte pointer */
*line_end, /* End-of-line byte pointer */
*comp_ptr, /* Pointer into compression buffer */
*start, /* Start of compression sequence */
*seed; /* Seed buffer pointer */
- int count, /* Count of bytes for output */
+ unsigned count, /* Count of bytes for output */
offset; /* Offset of bytes for output */
offset = 0;
- if ((count = line_end - line_ptr) > 8)
+ if ((count = (unsigned)(line_end - line_ptr)) > 8)
count = 8;
line_ptr += count;
if (line_ptr == line_end)
break;
- offset = line_ptr - start;
+ offset = (unsigned)(line_ptr - start);
/*
* Find up to 8 non-matching bytes...
* Output multi-byte offset...
*/
- *comp_ptr++ = ((count - 1) << 5) | 31;
+ *comp_ptr++ = (unsigned char)(((count - 1) << 5) | 31);
offset -= 31;
while (offset >= 255)
offset -= 255;
}
- *comp_ptr++ = offset;
+ *comp_ptr++ = (unsigned char)offset;
}
else
{
* Output single-byte offset...
*/
- *comp_ptr++ = ((count - 1) << 5) | offset;
+ *comp_ptr++ = (unsigned char)(((count - 1) << 5) | offset);
}
memcpy(comp_ptr, start, count);
*/
printf("\033*b%dW", (int)(comp_ptr - CompBuffer));
- fwrite(CompBuffer, comp_ptr - CompBuffer, 1, stdout);
+ fwrite(CompBuffer, (size_t)(comp_ptr - CompBuffer), 1, stdout);
/*
* Save this line as a "seed" buffer for the next...
*/
void
-ZPLCompress(char repeat_char, /* I - Character to repeat */
- int repeat_count) /* I - Number of repeated characters */
+ZPLCompress(unsigned char repeat_char, /* I - Character to repeat */
+ unsigned repeat_count) /* I - Number of repeated characters */
{
if (repeat_count > 1)
{
if (repeat_count >= 20)
{
- putchar('f' + repeat_count / 20);
+ putchar((int)('f' + repeat_count / 20));
repeat_count %= 20;
}
*/
if (repeat_count > 0)
- putchar('F' + repeat_count);
+ putchar((int)('F' + repeat_count));
}
/*
* Then the character to be repeated...
*/
- putchar(repeat_char);
+ putchar((int)repeat_char);
}
int fd; /* File descriptor */
cups_raster_t *ras; /* Raster stream for printing */
cups_page_header2_t header; /* Page header from file */
- int y; /* Current line */
+ unsigned y; /* Current line */
ppd_file_t *ppd; /* PPD file */
int num_options; /* Number of options */
cups_option_t *options; /* Options */
if ((y & 15) == 0)
{
_cupsLangPrintFilter(stderr, "INFO",
- _("Printing page %d, %d%% complete."),
+ _("Printing page %d, %u%% complete."),
Page, 100 * y / header.cupsHeight);
- fprintf(stderr, "ATTR: job-media-progress=%d\n",
+ fprintf(stderr, "ATTR: job-media-progress=%u\n",
100 * y / header.cupsHeight);
}
/*
* "$Id$"
*
- * CUPS raster to PWG raster format filter for CUPS.
+ * CUPS raster to PWG raster format filter for CUPS.
*
- * Copyright 2011 Apple Inc.
+ * Copyright 2011, 2014 Apple Inc.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright law.
- * Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright law.
+ * Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * main() - Main entry for filter.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
*outras; /* Output raster stream */
cups_page_header2_t inheader, /* Input raster page header */
outheader; /* Output raster page header */
- int y; /* Current line */
+ unsigned y; /* Current line */
unsigned char *line; /* Line buffer */
- int page = 0, /* Current page */
+ unsigned page = 0, /* Current page */
page_width, /* Actual page width */
page_height, /* Actual page height */
page_top, /* Top margin */
fprintf(stderr, "PAGE: %d %d\n", page, inheader.NumCopies);
- page_width = (int)(inheader.cupsPageSize[0] * inheader.HWResolution[0] /
- 72.0);
- page_height = (int)(inheader.cupsPageSize[1] * inheader.HWResolution[1] /
- 72.0);
- page_left = (int)(inheader.cupsImagingBBox[0] *
- inheader.HWResolution[0] / 72.0);
- page_bottom = (int)(inheader.cupsImagingBBox[1] *
- inheader.HWResolution[1] / 72.0);
+ page_width = (unsigned)(inheader.cupsPageSize[0] * inheader.HWResolution[0] / 72.0);
+ page_height = (unsigned)(inheader.cupsPageSize[1] * inheader.HWResolution[1] / 72.0);
+ page_left = (unsigned)(inheader.cupsImagingBBox[0] * inheader.HWResolution[0] / 72.0);
+ page_bottom = (unsigned)(inheader.cupsImagingBBox[1] * inheader.HWResolution[1] / 72.0);
page_top = page_height - page_bottom - inheader.cupsHeight;
linesize = (page_width * inheader.cupsBitsPerPixel + 7) / 8;
lineoffset = page_left * inheader.cupsBitsPerPixel / 8; /* Round down */
if ((val = cupsGetOption("print-quality", num_options, options)) != NULL)
{
- int quality = atoi(val); /* print-quality value */
+ unsigned quality = (unsigned)atoi(val); /* print-quality value */
if (quality >= IPP_QUALITY_DRAFT && quality <= IPP_QUALITY_HIGH)
outheader.cupsInteger[8] = quality;
{
if (inheader.Tumble)
{
- outheader.cupsInteger[1] = -1;/* CrossFeedTransform */
+ outheader.cupsInteger[1] = ~0U;/* CrossFeedTransform */
outheader.cupsInteger[2] = 1; /* FeedTransform */
outheader.cupsInteger[3] = page_width - page_left -
else
{
outheader.cupsInteger[1] = 1; /* CrossFeedTransform */
- outheader.cupsInteger[2] = -1;/* FeedTransform */
+ outheader.cupsInteger[2] = ~0U;/* FeedTransform */
outheader.cupsInteger[3] = page_left;
/* ImageBoxLeft */
{
if (inheader.Tumble)
{
- outheader.cupsInteger[1] = -1;/* CrossFeedTransform */
- outheader.cupsInteger[2] = -1;/* FeedTransform */
+ outheader.cupsInteger[1] = ~0U;/* CrossFeedTransform */
+ outheader.cupsInteger[2] = ~0U;/* FeedTransform */
outheader.cupsInteger[3] = page_width - page_left -
inheader.cupsWidth;
{
if (inheader.Tumble)
{
- outheader.cupsInteger[1] = -1;/* CrossFeedTransform */
- outheader.cupsInteger[2] = -1;/* FeedTransform */
+ outheader.cupsInteger[1] = ~0U;/* CrossFeedTransform */
+ outheader.cupsInteger[2] = ~0U;/* FeedTransform */
outheader.cupsInteger[3] = page_width - page_left -
inheader.cupsWidth;
/*
* "$Id$"
*
- * Raster test program routines for CUPS.
+ * Raster test program routines for CUPS.
*
- * Copyright 2007-2011 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2007 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * main() - Test the raster functions.
- * do_ppd_tests() - Test the default option commands in a PPD file.
- * do_ps_tests() - Test standard PostScript commands.
- * do_ras_file() - Test reading of a raster file.
- * do_raster_tests() - Test reading and writing of raster data.
- * print_changes() - Print differences in the page header.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
*/
#include <cups/raster-private.h>
+#include <math.h>
/*
1, /* cupsRowFeed */
1, /* cupsRowStep */
0, /* cupsNumColors */
- 1.001, /* cupsBorderlessScalingFactor */
- { 612.0, 792.1 }, /* cupsPageSize */
- { 0.0, 0.0, 0.0, 0.0 }, /* cupsImagingBBox */
+ 1.001f, /* cupsBorderlessScalingFactor */
+ { 612.0f, 792.1f }, /* cupsPageSize */
+ { 0.0f, 0.0f, 0.0f, 0.0f }, /* cupsImagingBBox */
{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 },
/* cupsInteger[16] */
- { 1.1, 2.1, 3.1, 4.1, 5.1, 6.1, 7.1, 8.1, 9.1, 10.1, 11.1, 12.1, 13.1,
- 14.1, 15.1, 16.1 }, /* cupsReal[16] */
+ { 1.1f, 2.1f, 3.1f, 4.1f, 5.1f, 6.1f, 7.1f, 8.1f, 9.1f, 10.1f, 11.1f, 12.1f, 13.1f, 14.1f, 15.1f, 16.1f }, /* cupsReal[16] */
{ "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13",
"14", "15", "16" }, /* cupsString[16] */
"Marker Type", /* cupsMarkerType */
static int /* O - Number of errors */
do_raster_tests(cups_mode_t mode) /* O - Write mode */
{
- int page, x, y; /* Looping vars */
+ unsigned page, x, y; /* Looping vars */
FILE *fp; /* Raster file */
cups_raster_t *r; /* Raster stream */
cups_page_header2_t header, /* Page header */
else
{
for (x = 0; x < header.cupsBytesPerLine; x ++)
- data[x] = x;
+ data[x] = (unsigned char)x;
for (y = 0; y < 64; y ++)
if (!cupsRasterWritePixels(r, data, header.cupsBytesPerLine))
else
{
for (x = 0; x < header.cupsBytesPerLine; x ++)
- data[x] = x / 4;
+ data[x] = (unsigned char)(x / 4);
for (y = 0; y < 64; y ++)
if (!cupsRasterWritePixels(r, data, header.cupsBytesPerLine))
printf(" cupsNumColors %d, expected %d\n", header->cupsNumColors,
expected->cupsNumColors);
- if (header->cupsBorderlessScalingFactor !=
- expected->cupsBorderlessScalingFactor)
+ if (fabs(header->cupsBorderlessScalingFactor - expected->cupsBorderlessScalingFactor) > 0.001)
printf(" cupsBorderlessScalingFactor %g, expected %g\n",
header->cupsBorderlessScalingFactor,
expected->cupsBorderlessScalingFactor);
- if (header->cupsPageSize[0] != expected->cupsPageSize[0] ||
- header->cupsPageSize[1] != expected->cupsPageSize[1])
+ if (fabs(header->cupsPageSize[0] - expected->cupsPageSize[0]) > 0.001 ||
+ fabs(header->cupsPageSize[1] - expected->cupsPageSize[1]) > 0.001)
printf(" cupsPageSize [%g %g], expected [%g %g]\n",
header->cupsPageSize[0], header->cupsPageSize[1],
expected->cupsPageSize[0], expected->cupsPageSize[1]);
- if (header->cupsImagingBBox[0] != expected->cupsImagingBBox[0] ||
- header->cupsImagingBBox[1] != expected->cupsImagingBBox[1] ||
- header->cupsImagingBBox[2] != expected->cupsImagingBBox[2] ||
- header->cupsImagingBBox[3] != expected->cupsImagingBBox[3])
+ if (fabs(header->cupsImagingBBox[0] - expected->cupsImagingBBox[0]) > 0.001 ||
+ fabs(header->cupsImagingBBox[1] - expected->cupsImagingBBox[1]) > 0.001 ||
+ fabs(header->cupsImagingBBox[2] - expected->cupsImagingBBox[2]) > 0.001 ||
+ fabs(header->cupsImagingBBox[3] - expected->cupsImagingBBox[3]) > 0.001)
printf(" cupsImagingBBox [%g %g %g %g], expected [%g %g %g %g]\n",
header->cupsImagingBBox[0], header->cupsImagingBBox[1],
header->cupsImagingBBox[2], header->cupsImagingBBox[3],
expected->cupsInteger[i]);
for (i = 0; i < 16; i ++)
- if (header->cupsReal[i] != expected->cupsReal[i])
+ if (fabs(header->cupsReal[i] - expected->cupsReal[i]) > 0.001)
printf(" cupsReal%d %g, expected %g\n", i, header->cupsReal[i],
expected->cupsReal[i]);
#
# "$Id$"
#
-# Locale file makefile for CUPS.
+# Locale file makefile for CUPS.
#
-# Copyright 2007-2012 by Apple Inc.
-# Copyright 1993-2007 by Easy Software Products.
+# Copyright 2007-2014 by Apple Inc.
+# Copyright 1993-2007 by Easy Software Products.
#
-# These coded instructions, statements, and computer programs are the
-# property of Apple Inc. and are protected by Federal copyright
-# law. Distribution and use rights are outlined in the file "LICENSE.txt"
-# which should have been included with this file. If this file is
-# file is missing or damaged, see the license at "http://www.cups.org/".
+# These coded instructions, statements, and computer programs are the
+# property of Apple Inc. and are protected by Federal copyright
+# law. Distribution and use rights are outlined in the file "LICENSE.txt"
+# which should have been included with this file. If this file is
+# file is missing or damaged, see the license at "http://www.cups.org/".
#
include ../Makedefs
-OBJS = checkpo.o po2strings.o strings2po.o translate.o
-TARGETS = checkpo po2strings strings2po translate
+OBJS = checkpo.o po2strings.o strings2po.o
+TARGETS = checkpo po2strings strings2po
#
$(CC) $(ARCHFLAGS) $(LDFLAGS) -o strings2po strings2po.o
-#
-# translate - A simple utility which uses Google to translate the cups.pot
-# file to one of several languages.
-#
-# translate outfile language
-#
-
-translate: translate.o ../cups/$(LIBCUPSSTATIC)
- echo Linking $<...
- $(CC) $(ARCHFLAGS) $(LDFLAGS) -o translate translate.o \
- ../cups/$(LIBCUPSSTATIC) $(LIBGSSAPI) $(SSLLIBS) $(DNSSDLIBS) \
- $(COMMONLIBS) $(LIBZ)
-
-
#
# Dependencies...
#
/*
* "$Id$"
*
- * Convert a GNU gettext .po file to an Apple .strings file.
+ * Convert a GNU gettext .po file to an Apple .strings file.
*
- * Copyright 2007-2012 by Apple Inc.
+ * Copyright 2007-2014 by Apple Inc.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
* Usage:
*
* Compile with:
*
* gcc -o po2strings po2strings.c `cups-config --libs`
- *
- * Contents:
- *
- * main() - Convert .po file to .strings.
*/
#include <cups/cups-private.h>
*temp, /* New string */
*msgid, /* msgid string */
*msgstr; /* msgstr string */
- int length; /* Length of combined strings */
+ size_t length; /* Length of combined strings */
int use_msgid; /* Use msgid strings for msgstr? */
size_t ptrlen = strlen(ptr); /* Length of string */
- length = (int)strlen(msgstr ? msgstr : msgid);
+ length = strlen(msgstr ? msgstr : msgid);
if ((temp = realloc(msgstr ? msgstr : msgid,
length + ptrlen + 1)) == NULL)
*
* Convert Apple .strings file (UTF-16 BE text file) to GNU gettext .po files.
*
+ * Copyright 2007-2014 by Apple Inc.
+ *
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
+ *
* Usage:
*
* strings2po filename.strings filename.po
* Compile with:
*
* gcc -o strings2po strings2po.c
- *
- * Contents:
- *
- * main() - Convert .strings file to .po.
- * read_strings() - Read a line from a .strings file.
- * write_po() - Write a line to the .po file.
*/
#include <stdio.h>
char *bufptr; /* Pointer into buffer */
- while (fgets(buffer, bufsize, strings))
+ while (fgets(buffer, (int)bufsize, strings))
{
if (buffer[0] != '\"')
continue;
+++ /dev/null
-/*
- * "$Id$"
- *
- * HTTP-based translation program for CUPS.
- *
- * This program uses Google to translate the CUPS template (cups.pot) to
- * several different languages. The translation isn't perfect, but it's
- * a start (better than working from scratch.)
- *
- * Copyright 2007-2010 by Apple Inc.
- * Copyright 1997-2006 by Easy Software Products.
- *
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
- *
- * Contents:
- *
- * main() - Main entry.
- * save_messages() - Save messages to a .po file.
- * translate_messages() - Translate messages using Google.
- * write_string() - Write a quoted string to a file.
- */
-
-/*
- * Include necessary headers...
- */
-
-#include <cups/cups-private.h>
-#include <unistd.h>
-
-
-/*
- * Local functions...
- */
-
-int save_messages(cups_array_t *cat, const char *filename);
-int translate_messages(cups_array_t *cat, const char *lang);
-int write_string(cups_file_t *fp, const char *s);
-
-
-/*
- * 'main()' - Main entry.
- */
-
-int /* O - Exit status */
-main(int argc, /* I - Number of command-line arguments */
- char *argv[]) /* I - Command-line arguments */
-{
- cups_array_t *cat; /* Message catalog */
-
-
- if (argc != 3)
- {
- fputs("Usage: translate cups_language.po language\n", stderr);
- return (1);
- }
-
- if (access(argv[1], 0))
- cat = _cupsMessageLoad("cups.pot", 1);
- else
- cat = _cupsMessageLoad(argv[1], 1);
-
- if (!cat)
- {
- puts("Unable to load message catalog.");
- return (1);
- }
-
- if (!translate_messages(cat, argv[2]))
- {
- puts("Unable to translate message catalog.");
- return (1);
- }
-
- if (!save_messages(cat, argv[1]))
- {
- puts("Unable to save message catalog.");
- return (1);
- }
-
- return (0);
-}
-
-
-/*
- * 'save_messages()' - Save messages to a .po file.
- */
-
-int /* O - 1 on success, 0 on error */
-save_messages(cups_array_t *cat, /* I - Message catalog */
- const char *filename) /* I - File to save to */
-{
- _cups_message_t *m; /* Current message */
- cups_file_t *fp; /* File pointer */
-
-
- /*
- * Open the message catalog...
- */
-
- if ((fp = cupsFileOpen(filename, "w")) == NULL)
- return (0);
-
- /*
- * Save the messages to a file...
- */
-
- for (m = (_cups_message_t *)cupsArrayFirst(cat);
- m;
- m = (_cups_message_t *)cupsArrayNext(cat))
- {
- if (cupsFilePuts(fp, "msgid \"") < 0)
- break;
-
- if (!write_string(fp, m->id))
- break;
-
- if (cupsFilePuts(fp, "\"\nmsgstr \"") < 0)
- break;
-
- if (m->str)
- {
- if (!write_string(fp, m->str))
- break;
- }
-
- if (cupsFilePuts(fp, "\"\n") < 0)
- break;
- }
-
- cupsFileClose(fp);
-
- return (!m);
-}
-
-
-/*
- * 'translate_messages()' - Translate messages using Google.
- */
-
-int /* O - 1 on success, 0 on error */
-translate_messages(cups_array_t *cat, /* I - Message catalog */
- const char *lang) /* I - Output language... */
-{
- /*
- * Google provides a simple translation/language tool for translating
- * from one language to another. It is far from perfect, however it
- * can be used to get a basic translation done or update an existing
- * translation when no other resources are available.
- *
- * Translation requests are sent as HTTP POSTs to
- * "http://translate.google.com/translate_t" with the following form
- * variables:
- *
- * Name Description Value
- * -------- ---------------------------------- ----------------
- * hl Help language? "en"
- * ie Input encoding "UTF8"
- * langpair Language pair "en|" + language
- * oe Output encoding "UTF8"
- * text Text to translate translation string
- */
-
- int ret; /* Return value */
- _cups_message_t *m; /* Current message */
- int tries; /* Number of tries... */
- http_t *http; /* HTTP connection */
- http_status_t status; /* Status of POST request */
- char *idptr, /* Pointer into msgid */
- buffer[65536], /* Input/output buffer */
- *bufptr, /* Pointer into buffer */
- *bufend, /* Pointer to end of buffer */
- length[16]; /* Content length */
- int bytes; /* Number of bytes read */
-
-
- /*
- * Connect to translate.google.com...
- */
-
- puts("Connecting to translate.google.com...");
-
- if ((http = httpConnect("translate.google.com", 80)) == NULL)
- {
- perror("Unable to connect to translate.google.com");
- return (0);
- }
-
- /*
- * Scan the current messages, requesting a translation of any untranslated
- * messages...
- */
-
- for (m = (_cups_message_t *)cupsArrayFirst(cat), ret = 1;
- m;
- m = (_cups_message_t *)cupsArrayNext(cat))
- {
- /*
- * Skip messages that are already translated...
- */
-
- if (m->str && m->str[0])
- continue;
-
- /*
- * Encode the form data into the buffer...
- */
-
- snprintf(buffer, sizeof(buffer),
- "hl=en&ie=UTF8&langpair=en|%s&oe=UTF8&text=", lang);
- bufptr = buffer + strlen(buffer);
- bufend = buffer + sizeof(buffer) - 5;
-
- for (idptr = m->id; *idptr && bufptr < bufend; idptr ++)
- if (*idptr == ' ')
- *bufptr++ = '+';
- else if (*idptr < ' ' || *idptr == '%')
- {
- sprintf(bufptr, "%%%02X", *idptr & 255);
- bufptr += 3;
- }
- else if (*idptr != '&')
- *bufptr++ = *idptr;
-
- *bufptr++ = '&';
- *bufptr = '\0';
-
- sprintf(length, "%d", (int)(bufptr - buffer));
-
- /*
- * Send the request...
- */
-
- printf("\"%s\" = ", m->id);
- fflush(stdout);
-
- tries = 0;
-
- do
- {
- httpClearFields(http);
- httpSetField(http, HTTP_FIELD_CONTENT_TYPE,
- "application/x-www-form-urlencoded");
- httpSetField(http, HTTP_FIELD_CONTENT_LENGTH, length);
-
- if (httpPost(http, "/translate_t"))
- {
- httpReconnect(http);
- httpPost(http, "/translate_t");
- }
-
- httpWrite2(http, buffer, bufptr - buffer);
-
- while ((status = httpUpdate(http)) == HTTP_CONTINUE);
-
- if (status != HTTP_OK && status != HTTP_ERROR)
- httpFlush(http);
-
- tries ++;
- }
- while (status == HTTP_ERROR && tries < 10);
-
- if (status == HTTP_OK)
- {
- /*
- * OK, read the translation back...
- */
-
- bufptr = buffer;
- bufend = buffer + sizeof(buffer) - 1;
-
- while ((bytes = httpRead2(http, bufptr, bufend - bufptr)) > 0)
- bufptr += bytes;
-
- if (bytes < 0)
- {
- /*
- * Read error, abort!
- */
-
- puts("READ ERROR!");
- ret = 0;
- break;
- }
-
- *bufptr = '\0';
-
- /*
- * Find the div containing translation
- */
-
- if ((bufptr = strstr(buffer, "<div id=result_box")) == NULL)
- {
- /*
- * No textarea, abort!
- */
-
- puts("NO div id=result_box!");
- ret = 0;
- break;
- }
-
- if ((bufptr = strchr(bufptr, '>')) == NULL)
- {
- /*
- * textarea doesn't end, abort!
- */
-
- puts("DIV SHORT DATA!");
- ret = 0;
- break;
- }
-
- bufptr ++;
-
- if ((bufend = strstr(bufptr, "</div>")) == NULL)
- {
- /*
- * textarea doesn't close, abort!
- */
-
- puts("/DIV SHORT DATA!");
- ret = 0;
- break;
- }
-
- *bufend = '\0';
-
- /*
- * Copy the translation...
- */
-
- m->str = strdup(bufptr);
-
- /*
- * Convert character entities to regular chars...
- */
-
- for (bufptr = strchr(m->str, '&');
- bufptr;
- bufptr = strchr(bufptr + 1, '&'))
- {
- if (!strncmp(bufptr, "<", 4))
- {
- *bufptr = '<';
- _cups_strcpy(bufptr + 1, bufptr + 4);
- }
- else if (!strncmp(bufptr, ">", 4))
- {
- *bufptr = '>';
- _cups_strcpy(bufptr + 1, bufptr + 4);
- }
- else if (!strncmp(bufptr, "&", 5))
- _cups_strcpy(bufptr + 1, bufptr + 5);
- }
-
- printf("\"%s\"\n", m->str);
- }
- else if (status == HTTP_ERROR)
- {
- printf("NETWORK ERROR (%s)!\n", strerror(httpError(http)));
- ret = 0;
- break;
- }
- else
- {
- printf("HTTP ERROR %d!\n", status);
- ret = 0;
- break;
- }
- }
-
- httpClose(http);
-
- return (ret);
-}
-
-
-/*
- * 'write_string()' - Write a quoted string to a file.
- */
-
-int /* O - 1 on success, 0 on failure */
-write_string(cups_file_t *fp, /* I - File to write to */
- const char *s) /* I - String */
-{
- while (*s)
- {
- switch (*s)
- {
- case '\n' :
- if (cupsFilePuts(fp, "\\n") < 0)
- return (0);
- break;
-
- case '\r' :
- if (cupsFilePuts(fp, "\\r") < 0)
- return (0);
- break;
-
- case '\t' :
- if (cupsFilePuts(fp, "\\t") < 0)
- return (0);
- break;
-
- case '\\' :
- if (cupsFilePuts(fp, "\\\\") < 0)
- return (0);
- break;
-
- case '\"' :
- if (cupsFilePuts(fp, "\\\"") < 0)
- return (0);
- break;
-
- default :
- if ((*s & 255) < ' ')
- {
- if (cupsFilePrintf(fp, "\\%o", *s) < 0)
- return (0);
- }
- else if (cupsFilePutChar(fp, *s) < 0)
- return (0);
- break;
- }
-
- s ++;
- }
-
- return (1);
-}
-
-
-/*
- * End of "$Id$".
- */
/*
* "$Id$"
*
- * TBCP port monitor for CUPS.
+ * TBCP port monitor for CUPS.
*
- * Copyright 2007-2010 by Apple Inc.
- * Copyright 1993-2006 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1993-2006 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * main() - Main entry...
- * psgets() - Get a line from a file.
- * pswrite() - Write data from a file.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
*/
static char *psgets(char *buf, size_t *bytes, FILE *fp);
-static size_t pswrite(const char *buf, size_t bytes, FILE *fp);
+static ssize_t pswrite(const char *buf, size_t bytes);
/*
if (psgets(line, &linelen, fp) == NULL)
break;
}
- while (pswrite(line, linelen, stdout) > 0);
+ while (pswrite(line, linelen) > 0);
fflush(stdout);
}
bufptr = buf;
ch = EOF;
- while ((bufptr - buf) < len)
+ while ((size_t)(bufptr - buf) < len)
{
if ((ch = getc(fp)) == EOF)
break;
else if (ch == '\n')
break;
else
- *bufptr++ = ch;
+ *bufptr++ = (char)ch;
}
/*
if (ch == '\n' || ch == '\r')
{
- if ((bufptr - buf) < len)
- *bufptr++ = ch;
+ if ((size_t)(bufptr - buf) < len)
+ *bufptr++ = (char)ch;
else
ungetc(ch, fp);
}
*/
*bufptr = '\0';
- *bytes = bufptr - buf;
+ *bytes = (size_t)(bufptr - buf);
if (ch == EOF && bufptr == buf)
return (NULL);
* 'pswrite()' - Write data from a file.
*/
-static size_t /* O - Number of bytes written */
+static ssize_t /* O - Number of bytes written */
pswrite(const char *buf, /* I - Buffer to write */
- size_t bytes, /* I - Bytes to write */
- FILE *fp) /* I - File to write to */
+ size_t bytes) /* I - Bytes to write */
{
size_t count; /* Remaining bytes */
break;
}
- return (bytes);
+ return ((ssize_t)bytes);
}
/*
* "$Id$"
*
- * TBCP port monitor for CUPS.
+ * TBCP port monitor for CUPS.
*
- * Copyright 2007-2012 by Apple Inc.
- * Copyright 1993-2006 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1993-2006 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * main() - Main entry...
- * psgets() - Get a line from a file.
- * pswrite() - Write data from a file.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
*/
static char *psgets(char *buf, size_t *bytes, FILE *fp);
-static size_t pswrite(const char *buf, size_t bytes, FILE *fp);
+static ssize_t pswrite(const char *buf, size_t bytes);
/*
* Loop until we see end-of-file...
*/
- while (pswrite(line, linelen, stdout) > 0)
+ while (pswrite(line, linelen) > 0)
{
linelen = sizeof(line);
if (psgets(line, &linelen, fp) == NULL)
bufptr = buf;
ch = EOF;
- while ((bufptr - buf) < len)
+ while ((size_t)(bufptr - buf) < len)
{
if ((ch = getc(fp)) == EOF)
break;
else if (ch == '\n')
break;
else
- *bufptr++ = ch;
+ *bufptr++ = (char)ch;
}
/*
if (ch == '\n' || ch == '\r')
{
- if ((bufptr - buf) < len)
- *bufptr++ = ch;
+ if ((size_t)(bufptr - buf) < len)
+ *bufptr++ = (char)ch;
else
ungetc(ch, fp);
}
*/
*bufptr = '\0';
- *bytes = bufptr - buf;
+ *bytes = (size_t)(bufptr - buf);
if (ch == EOF && bufptr == buf)
return (NULL);
* 'pswrite()' - Write data from a file.
*/
-static size_t /* O - Number of bytes written */
+static ssize_t /* O - Number of bytes written */
pswrite(const char *buf, /* I - Buffer to write */
- size_t bytes, /* I - Bytes to write */
- FILE *fp) /* I - File to write to */
+ size_t bytes) /* I - Bytes to write */
{
size_t count; /* Remaining bytes */
break;
}
- return (bytes);
+ return ((ssize_t)bytes);
}
//
// "$Id$"
//
-// Array class for the CUPS PPD Compiler.
+// Array class for the CUPS PPD Compiler.
//
-// Copyright 2007-2009 by Apple Inc.
-// Copyright 2002-2005 by Easy Software Products.
+// Copyright 2007-2014 by Apple Inc.
+// Copyright 2002-2005 by Easy Software Products.
//
-// These coded instructions, statements, and computer programs are the
-// property of Apple Inc. and are protected by Federal copyright
-// law. Distribution and use rights are outlined in the file "LICENSE.txt"
-// which should have been included with this file. If this file is
-// file is missing or damaged, see the license at "http://www.cups.org/".
-//
-// Contents:
-//
-// ppdcArray::ppdcArray() - Create a new array.
-// ppdcArray::~ppdcArray() - Destroy an array.
-// ppdcArray::add() - Add an element to an array.
-// ppdcArray::first() - Return the first element in the array.
-// ppdcArray::next() - Return the next element in the array.
-// ppdcArray::remove() - Remove an element from the array.
+// These coded instructions, statements, and computer programs are the
+// property of Apple Inc. and are protected by Federal copyright
+// law. Distribution and use rights are outlined in the file "LICENSE.txt"
+// which should have been included with this file. If this file is
+// file is missing or damaged, see the license at "http://www.cups.org/".
//
//
// Make a copy of the array...
data = new ppdcShared *[count];
- memcpy(data, a->data, count * sizeof(ppdcShared *));
+ memcpy(data, a->data, (size_t)count * sizeof(ppdcShared *));
for (int i = 0; i < count; i ++)
data[i]->retain();
alloc += 10;
temp = new ppdcShared *[alloc];
- memcpy(temp, data, count * sizeof(ppdcShared *));
+ memcpy(temp, data, (size_t)count * sizeof(ppdcShared *));
delete[] data;
data = temp;
d->release();
if (i < count)
- memmove(data + i, data + i + 1, (count - i) * sizeof(ppdcShared *));
+ memmove(data + i, data + i + 1, (size_t)(count - i) * sizeof(ppdcShared *));
}
//
// "$Id$"
//
-// Shared message catalog class for the CUPS PPD Compiler.
+// Shared message catalog class for the CUPS PPD Compiler.
//
-// Copyright 2007-2012 by Apple Inc.
-// Copyright 2002-2006 by Easy Software Products.
+// Copyright 2007-2014 by Apple Inc.
+// Copyright 2002-2006 by Easy Software Products.
//
-// These coded instructions, statements, and computer programs are the
-// property of Apple Inc. and are protected by Federal copyright
-// law. Distribution and use rights are outlined in the file "LICENSE.txt"
-// which should have been included with this file. If this file is
-// file is missing or damaged, see the license at "http://www.cups.org/".
-//
-// Contents:
-//
-// ppdcCatalog::ppdcCatalog() - Create a shared message catalog.
-// ppdcCatalog::~ppdcCatalog() - Destroy a shared message catalog.
-// ppdcCatalog::add_message() - Add a new message.
-// ppdcCatalog::find_message() - Find a message in a catalog...
-// ppdcCatalog::load_messages() - Load messages from a .po file.
-// ppdcCatalog::save_messages() - Save the messages to a .po file.
-// get_utf8() - Get a UTF-8 character.
-// get_utf16() - Get a UTF-16 character...
-// put_utf8() - Add a UTF-8 character to a string.
-// put_utf16() - Write a UTF-16 character to a file.
+// These coded instructions, statements, and computer programs are the
+// property of Apple Inc. and are protected by Federal copyright
+// law. Distribution and use rights are outlined in the file "LICENSE.txt"
+// which should have been included with this file. If this file is
+// file is missing or damaged, see the license at "http://www.cups.org/".
//
//
if (ptr >= end)
return (-1);
- *ptr++ = ch;
+ *ptr++ = (char)ch;
}
else if (ch < 0x800)
{
if ((ptr + 1) >= end)
return (-1);
- *ptr++ = 0xc0 | (ch >> 6);
- *ptr++ = 0x80 | (ch & 0x3f);
+ *ptr++ = (char)(0xc0 | (ch >> 6));
+ *ptr++ = (char)(0x80 | (ch & 0x3f));
}
else if (ch < 0x10000)
{
if ((ptr + 2) >= end)
return (-1);
- *ptr++ = 0xe0 | (ch >> 12);
- *ptr++ = 0x80 | ((ch >> 6) & 0x3f);
- *ptr++ = 0x80 | (ch & 0x3f);
+ *ptr++ = (char)(0xe0 | (ch >> 12));
+ *ptr++ = (char)(0x80 | ((ch >> 6) & 0x3f));
+ *ptr++ = (char)(0x80 | (ch & 0x3f));
}
else
{
if ((ptr + 3) >= end)
return (-1);
- *ptr++ = 0xf0 | (ch >> 18);
- *ptr++ = 0x80 | ((ch >> 12) & 0x3f);
- *ptr++ = 0x80 | ((ch >> 6) & 0x3f);
- *ptr++ = 0x80 | (ch & 0x3f);
+ *ptr++ = (char)(0xf0 | (ch >> 18));
+ *ptr++ = (char)(0x80 | ((ch >> 12) & 0x3f));
+ *ptr++ = (char)(0x80 | ((ch >> 6) & 0x3f));
+ *ptr++ = (char)(0x80 | (ch & 0x3f));
}
return (0);
if (ch < 0x10000)
{
// One-word UTF-16 big-endian...
- buffer[0] = ch >> 8;
- buffer[1] = ch;
+ buffer[0] = (unsigned char)(ch >> 8);
+ buffer[1] = (unsigned char)ch;
if (cupsFileWrite(fp, (char *)buffer, 2) == 2)
return (0);
// Two-word UTF-16 big-endian...
ch -= 0x10000;
- buffer[0] = 0xd8 | (ch >> 18);
- buffer[1] = ch >> 10;
- buffer[2] = 0xdc | ((ch >> 8) & 0x03);
- buffer[3] = ch;
+ buffer[0] = (unsigned char)(0xd8 | (ch >> 18));
+ buffer[1] = (unsigned char)(ch >> 10);
+ buffer[2] = (unsigned char)(0xdc | ((ch >> 8) & 0x03));
+ buffer[3] = (unsigned char)ch;
if (cupsFileWrite(fp, (char *)buffer, 4) == 4)
return (0);
//
// "$Id$"
//
-// PPD file compiler definitions for the CUPS PPD Compiler.
+// PPD file compiler definitions for the CUPS PPD Compiler.
//
-// Copyright 2007-2011 by Apple Inc.
-// Copyright 2002-2006 by Easy Software Products.
+// Copyright 2007-2014 by Apple Inc.
+// Copyright 2002-2006 by Easy Software Products.
//
-// These coded instructions, statements, and computer programs are the
-// property of Apple Inc. and are protected by Federal copyright
-// law. Distribution and use rights are outlined in the file "LICENSE.txt"
-// which should have been included with this file. If this file is
-// file is missing or damaged, see the license at "http://www.cups.org/".
-//
-// Contents:
-//
-// ppdcDriver::ppdcDriver() - Create a new printer driver.
-// ppdcDriver::~ppdcDriver() - Destroy a printer driver.
-// ppdcDriver::find_attr() - Find an attribute.
-// ppdcDriver::find_group() - Find a group.
-// ppdcDriver::find_option() - Find an option.
-// ppdcDriver::find_option_group() - Find an option and its group.
-// ppdcDriver::set_custom_size_code() - Set the custom page size code.
-// ppdcDriver::set_default_font() - Set the default font name.
-// ppdcDriver::set_default_size() - Set the default size name.
-// ppdcDriver::set_file_name() - Set the full filename.
-// ppdcDriver::set_manufacturer() - Set the manufacturer name.
-// ppdcDriver::set_model_name() - Set the model name.
-// ppdcDriver::set_pc_file_name() - Set the PC filename.
-// ppdcDriver::set_version() - Set the version string.
-// ppdcDriver::write_ppd_file() - Write a PPD file...
+// These coded instructions, statements, and computer programs are the
+// property of Apple Inc. and are protected by Federal copyright
+// law. Distribution and use rights are outlined in the file "LICENSE.txt"
+// which should have been included with this file. If this file is
+// file is missing or damaged, see the license at "http://www.cups.org/".
//
//
fn->status == PPDC_FONT_ROM ? "ROM" : "Disk", lf);
cupsFilePrintf(fp, "*%% End of %s, %05d bytes.%s", pc_file_name->value,
- (int)(cupsFileTell(fp) + 25 + strlen(pc_file_name->value)),
+ (int)((size_t)cupsFileTell(fp) + 25 + strlen(pc_file_name->value)),
lf);
if (delete_cat)
//
// "$Id$"
//
-// Source class for the CUPS PPD Compiler.
-//
-// Copyright 2007-2013 by Apple Inc.
-// Copyright 2002-2007 by Easy Software Products.
-//
-// These coded instructions, statements, and computer programs are the
-// property of Apple Inc. and are protected by Federal copyright
-// law. Distribution and use rights are outlined in the file "LICENSE.txt"
-// which should have been included with this file. If this file is
-// file is missing or damaged, see the license at "http://www.cups.org/".
-//
-// Contents:
-//
-// ppdcSource::ppdcSource() - Load a driver source file.
-// ppdcSource::~ppdcSource() - Free a driver source file.
-// ppdcSource::add_include() - Add an include directory.
-// ppdcSource::find_driver() - Find a driver.
-// ppdcSource::find_include() - Find an include file.
-// ppdcSource::find_po() - Find a message catalog for the given
-// locale.
-// ppdcSource::find_size() - Find a media size.
-// ppdcSource::find_variable() - Find a variable.
-// ppdcSource::get_attr() - Get an attribute.
-// ppdcSource::get_boolean() - Get a boolean value.
-// ppdcSource::get_choice() - Get a choice.
-// ppdcSource::get_color_model() - Get an old-style color model option.
-// ppdcSource::get_color_order() - Get an old-style color order value.
-// ppdcSource::get_color_profile() - Get a color profile definition.
-// ppdcSource::get_color_space() - Get an old-style colorspace value.
-// ppdcSource::get_constraint() - Get a constraint.
-// ppdcSource::get_custom_size() - Get a custom media size definition from
-// a file.
-// ppdcSource::get_duplex() - Get a duplex option.
-// ppdcSource::get_filter() - Get a filter.
-// ppdcSource::get_float() - Get a single floating-point number.
-// ppdcSource::get_font() - Get a font definition.
-// ppdcSource::get_generic() - Get a generic old-style option.
-// ppdcSource::get_group() - Get an option group.
-// ppdcSource::get_installable() - Get an installable option.
-// ppdcSource::get_integer() - Get an integer value from a file.
-// ppdcSource::get_measurement() - Get a measurement value.
-// ppdcSource::get_option() - Get an option definition.
-// ppdcSource::get_po() - Get a message catalog.
-// ppdcSource::get_resolution() - Get an old-style resolution option.
-// ppdcSource::get_simple_profile() - Get a simple color profile definition.
-// ppdcSource::get_size() - Get a media size definition from a file.
-// ppdcSource::get_token() - Get a token from a file.
-// ppdcSource::get_variable() - Get a variable definition.
-// ppdcSource::quotef() - Write a formatted, quoted string...
-// ppdcSource::read_file() - Read a driver source file.
-// ppdcSource::scan_file() - Scan a driver source file.
-// ppdcSource::set_variable() - Set a variable.
-// ppdcSource::write_file() - Write the current source data to a file.
+// Source class for the CUPS PPD Compiler.
+//
+// Copyright 2007-2014 by Apple Inc.
+// Copyright 2002-2007 by Easy Software Products.
+//
+// These coded instructions, statements, and computer programs are the
+// property of Apple Inc. and are protected by Federal copyright
+// law. Distribution and use rights are outlined in the file "LICENSE.txt"
+// which should have been included with this file. If this file is
+// file is missing or damaged, see the license at "http://www.cups.org/".
//
//
{
// Check for the local file relative to the current directory...
if (base && *base && f[0] != '/')
- snprintf(n, nlen, "%s/%s", base, f);
+ snprintf(n, (size_t)nlen, "%s/%s", base, f);
else
- strlcpy(n, f, nlen);
+ strlcpy(n, f, (size_t)nlen);
if (!access(n, 0))
return (n);
{
for (dir = (ppdcString *)includes->first(); dir; dir = (ppdcString *)includes->next())
{
- snprintf(n, nlen, "%s/%s", dir->value, f);
+ snprintf(n, (size_t)nlen, "%s/%s", dir->value, f);
if (!access(n, 0))
return (n);
}
// Search the standard include directories...
_cups_globals_t *cg = _cupsGlobals(); // Global data
- snprintf(n, nlen, "%s/ppdc/%s", cg->cups_datadir, f);
+ snprintf(n, (size_t)nlen, "%s/ppdc/%s", cg->cups_datadir, f);
if (!access(n, 0))
return (n);
- snprintf(n, nlen, "%s/po/%s", cg->cups_datadir, f);
+ snprintf(n, (size_t)nlen, "%s/po/%s", cg->cups_datadir, f);
if (!access(n, 0))
return (n);
else
if (color_order >= 0)
{
- snprintf(commptr, sizeof(command) - (commptr - command),
+ snprintf(commptr, sizeof(command) - (size_t)(commptr - command),
"/cupsColorOrder %d", color_order);
commptr += strlen(commptr);
}
if (color_space >= 0)
{
- snprintf(commptr, sizeof(command) - (commptr - command),
+ snprintf(commptr, sizeof(command) - (size_t)(commptr - command),
"/cupsColorSpace %d", color_space);
commptr += strlen(commptr);
}
if (compression >= 0)
{
- snprintf(commptr, sizeof(command) - (commptr - command),
+ snprintf(commptr, sizeof(command) - (size_t)(commptr - command),
"/cupsCompression %d", compression);
commptr += strlen(commptr);
}
- snprintf(commptr, sizeof(command) - (commptr - command), ">>setpagedevice");
+ snprintf(commptr, sizeof(command) - (size_t)(commptr - command), ">>setpagedevice");
// Return the new choice...
return (new ppdcChoice(name, text, command));
if (!isalnum(ch) && ch != '_')
break;
else if (nameptr < (name + sizeof(name) - 1))
- *nameptr++ = fp->get();
+ *nameptr++ = (char)fp->get();
}
if (nameptr == name)
{
// $$ = $
if (bufptr < bufend)
- *bufptr++ = fp->get();
+ *bufptr++ = (char)fp->get();
}
else
{
var = find_variable(name);
if (var)
{
- strlcpy(bufptr, var->value->value, bufend - bufptr + 1);
+ strlcpy(bufptr, var->value->value, (size_t)(bufend - bufptr + 1));
bufptr += strlen(bufptr);
}
else
_("ppdc: Undefined variable (%s) on line %d of "
"%s."), name, fp->line, fp->filename);
- snprintf(bufptr, bufend - bufptr + 1, "$%s", name);
+ snprintf(bufptr, (size_t)(bufend - bufptr + 1), "$%s", name);
bufptr += strlen(bufptr);
}
}
empty = 0;
if (bufptr < bufend)
- *bufptr++ = ch;
+ *bufptr++ = (char)ch;
}
}
else if (ch == '\'' || ch == '\"')
{
// Insert the opposing quote char...
if (bufptr < bufend)
- *bufptr++ = ch;
+ *bufptr++ = (char)ch;
}
else
{
startline = fp->line;
if (bufptr < bufend)
- *bufptr++ = ch;
+ *bufptr++ = (char)ch;
}
else if ((ch == ')' && quote == '(') || (ch == '>' && quote == '<'))
{
quote = 0;
if (bufptr < bufend)
- *bufptr++ = ch;
+ *bufptr++ = (char)ch;
}
else if (ch == '\\')
{
break;
if (bufptr < bufend)
- *bufptr++ = ch;
+ *bufptr++ = (char)ch;
}
else if (bufptr < bufend)
{
empty = 0;
- *bufptr++ = ch;
+ *bufptr++ = (char)ch;
if ((ch == '{' || ch == '}') && !quote)
break;
else
{
*bufptr = '\0';
-// puts(buffer);
return (buffer);
}
}
if ((format - bufformat + 1) > (int)sizeof(tformat))
break;
- memcpy(tformat, bufformat, format - bufformat);
+ memcpy(tformat, bufformat, (size_t)(format - bufformat));
tformat[format - bufformat] = '\0';
bytes += cupsFilePrintf(fp, tformat, va_arg(ap, double));
if ((format - bufformat + 1) > (int)sizeof(tformat))
break;
- memcpy(tformat, bufformat, format - bufformat);
+ memcpy(tformat, bufformat, (size_t)(format - bufformat));
tformat[format - bufformat] = '\0';
# ifdef HAVE_LONG_LONG
if ((format - bufformat + 1) > (int)sizeof(tformat))
break;
- memcpy(tformat, bufformat, format - bufformat);
+ memcpy(tformat, bufformat, (size_t)(format - bufformat));
tformat[format - bufformat] = '\0';
bytes += cupsFilePrintf(fp, tformat, va_arg(ap, void *));
}
else
{
- cupsFileWrite(fp, va_arg(ap, char *), width);
+ cupsFileWrite(fp, va_arg(ap, char *), (size_t)width);
bytes += width;
}
break;
if ((s = va_arg(ap, char *)) == NULL)
s = (char *)"(nil)";
- slen = strlen(s);
+ slen = (int)strlen(s);
if (slen > width && prec != width)
width = slen;
for (j = 0;
outname[j] && j < (int)(sizeof(pcfilename) - 1);
j ++)
- pcfilename[j] = tolower(outname[j] & 255);
+ pcfilename[j] = (char)tolower(outname[j] & 255);
pcfilename[j] = '\0';
}
//
// "$Id$"
//
-// PPD file merge utility for the CUPS PPD Compiler.
+// PPD file merge utility for the CUPS PPD Compiler.
//
-// Copyright 2007-2011 by Apple Inc.
-// Copyright 2002-2007 by Easy Software Products.
+// Copyright 2007-2014 by Apple Inc.
+// Copyright 2002-2007 by Easy Software Products.
//
-// These coded instructions, statements, and computer programs are the
-// property of Apple Inc. and are protected by Federal copyright
-// law. Distribution and use rights are outlined in the file "LICENSE.txt"
-// which should have been included with this file. If this file is
-// file is missing or damaged, see the license at "http://www.cups.org/".
-//
-// Contents:
-//
-// main() - Main entry for the PPD merge utility.
-// ppd_locale() - Return the locale associated with a PPD file.
-// usage() - Show usage and exit.
+// These coded instructions, statements, and computer programs are the
+// property of Apple Inc. and are protected by Federal copyright
+// law. Distribution and use rights are outlined in the file "LICENSE.txt"
+// which should have been included with this file. If this file is
+// file is missing or damaged, see the license at "http://www.cups.org/".
//
//
static const char * // O - Locale string
ppd_locale(ppd_file_t *ppd) // I - PPD file
{
- int i, // Looping var
- vlen; // Length of LanguageVersion string
+ int i; // Looping var
+ size_t vlen; // Length of LanguageVersion string
static char locale[255]; // Locale string
static struct // LanguageVersion translation table
{
* Decode the authorization string to get the input token...
*/
- len = strlen(authorization);
- input_token.value = malloc(len);
+ len = (int)strlen(authorization);
+ input_token.value = malloc((size_t)len);
input_token.value = httpDecode64_2(input_token.value, &len,
authorization);
- input_token.length = len;
+ input_token.length = (size_t)len;
/*
* Accept the input token to get the authorization info...
cupsdCheckAccess(
unsigned ip[4], /* I - Client address */
const char *name, /* I - Client hostname */
- int namelen, /* I - Length of hostname */
+ size_t namelen, /* I - Length of hostname */
cupsd_location_t *loc) /* I - Location to check */
{
int allow; /* 1 if allowed, 0 otherwise */
int /* O - 1 if mask matches, 0 otherwise */
cupsdCheckAuth(unsigned ip[4], /* I - Client address */
const char *name, /* I - Client hostname */
- int name_len, /* I - Length of hostname */
+ size_t name_len, /* I - Length of hostname */
cups_array_t *masks) /* I - Masks */
{
int i; /* Looping var */
*uriptr; /* Pointer into URI */
cupsd_location_t *loc, /* Current location */
*best; /* Best match for location so far */
- int bestlen; /* Length of best match */
+ size_t bestlen; /* Length of best match */
int limit; /* Limit field */
static const int limits[] = /* Map http_status_t to CUPSD_AUTH_LIMIT_xyz */
{
/* Client hostname */
unsigned address[4]; /* Authorization address */
cupsd_location_t *best; /* Best match for location so far */
- int hostlen; /* Length of hostname */
+ size_t hostlen; /* Length of hostname */
char *name, /* Current username */
username[256], /* Username to authorize */
ownername[256], /* Owner name to authorize */
* Allocate memory for the responses...
*/
- if ((replies = malloc(sizeof(struct pam_response) * num_msg)) == NULL)
+ if ((replies = malloc(sizeof(struct pam_response) * (size_t)num_msg)) == NULL)
return (PAM_CONV_ERR);
/*
*
* Authorization definitions for the CUPS scheduler.
*
- * Copyright 2007-2013 by Apple Inc.
+ * Copyright 2007-2014 by Apple Inc.
* Copyright 1997-2006 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
typedef struct
{
- int length; /* Length of name */
+ size_t length; /* Length of name */
char *name; /* Name string */
} cupsd_namemask_t;
typedef struct
{
char *location; /* Location of resource */
+ size_t length; /* Length of location string */
ipp_op_t op; /* IPP operation */
int limit, /* Limit for these types of requests */
- length, /* Length of location string */
order_type, /* Allow or Deny */
type, /* Type of authentication */
level, /* Access level required */
extern void cupsdAddName(cupsd_location_t *loc, char *name);
extern int cupsdAddNameMask(cups_array_t **masks, char *name);
extern void cupsdAuthorize(cupsd_client_t *con);
-extern int cupsdCheckAccess(unsigned ip[4], const char *name,
- int namelen, cupsd_location_t *loc);
-extern int cupsdCheckAuth(unsigned ip[4], const char *name, int namelen,
- cups_array_t *masks);
+extern int cupsdCheckAccess(unsigned ip[4], const char *name, size_t namelen, cupsd_location_t *loc);
+extern int cupsdCheckAuth(unsigned ip[4], const char *name, size_t namelen, cups_array_t *masks);
extern int cupsdCheckGroup(const char *username,
struct passwd *user,
const char *groupname);
/*
* "$Id$"
*
- * Authentication certificate routines for the CUPS scheduler.
+ * Authentication certificate routines for the CUPS scheduler.
*
- * Copyright 2007-2012 by Apple Inc.
- * Copyright 1997-2006 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2006 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
- *
- * Contents:
- *
- * cupsdAddCert() - Add a certificate.
- * cupsdDeleteCert() - Delete a single certificate.
- * cupsdDeleteAllCerts() - Delete all certificates...
- * cupsdFindCert() - Find a certificate.
- * cupsdInitCerts() - Initialize the certificate "system" and root
- * certificate.
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*/
/*
/*
* "$Id$"
*
- * Printer class routines for the CUPS scheduler.
+ * Printer class routines for the CUPS scheduler.
*
- * Copyright 2007-2011 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products, all rights reserved.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
- *
- * Contents:
- *
- * cupsdAddClass() - Add a class to the system.
- * cupsdAddPrinterToClass() - Add a printer to a class...
- * cupsdDeletePrinterFromClass() - Delete a printer from a class.
- * cupsdDeletePrinterFromClasses() - Delete a printer from all classes.
- * cupsdFindAvailablePrinter() - Find an available printer in a class.
- * cupsdFindClass() - Find the named class.
- * cupsdLoadAllClasses() - Load classes from the classes.conf file.
- * cupsdSaveAllClasses() - Save classes to the classes.conf file.
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*/
/*
if (c->num_printers == 0)
temp = malloc(sizeof(cupsd_printer_t *));
else
- temp = realloc(c->printers, sizeof(cupsd_printer_t *) * (c->num_printers + 1));
+ temp = realloc(c->printers, sizeof(cupsd_printer_t *) * (size_t)(c->num_printers + 1));
if (temp == NULL)
{
c->num_printers --;
if (i < c->num_printers)
memmove(c->printers + i, c->printers + i + 1,
- (c->num_printers - i) * sizeof(cupsd_printer_t *));
+ (size_t)(c->num_printers - i) * sizeof(cupsd_printer_t *));
}
else
return (0);
httpSetField(con->http, HTTP_FIELD_LAST_MODIFIED,
httpGetDateString(filestats.st_mtime));
- httpSetLength(con->http, filestats.st_size);
+ httpSetLength(con->http, (size_t)filestats.st_size);
if (!cupsdSendHeader(con, HTTP_STATUS_OK, line, CUPSD_AUTH_NONE))
{
{
con->bytes += bytes;
- if (write(con->file, line, bytes) < bytes)
+ if (write(con->file, line, (size_t)bytes) < bytes)
{
cupsdLogClient(con, CUPSD_LOG_ERROR,
"Unable to write %d bytes to \"%s\": %s", bytes,
{
con->bytes += bytes;
- if (write(con->file, line, bytes) < bytes)
+ if (write(con->file, line, (size_t)bytes) < bytes)
{
cupsdLogClient(con, CUPSD_LOG_ERROR,
"Unable to write %d bytes to \"%s\": %s",
size_t auth_size; /* Size of remaining buffer */
auth_key = auth_str + strlen(auth_str);
- auth_size = sizeof(auth_str) - (auth_key - auth_str);
+ auth_size = sizeof(auth_str) - (size_t)(auth_key - auth_str);
for (name = (char *)cupsArrayFirst(con->best->names);
name;
CUPS_LLCAST httpGetLength2(con->http));
}
else if ((bytes = read(con->file, con->header + con->header_used,
- sizeof(con->header) - con->header_used)) > 0)
+ sizeof(con->header) - (size_t)con->header_used)) > 0)
{
con->header_used += bytes;
if (con->header_used > 0)
{
- if (httpWrite2(con->http, con->header, con->header_used) < 0)
+ if (httpWrite2(con->http, con->header, (size_t)con->header_used) < 0)
{
cupsdLogClient(con, CUPSD_LOG_DEBUG, "Closing for error %d (%s)",
httpError(con->http), strerror(httpError(con->http)));
*/
while ((bytes = cupsFileRead(in, buffer, sizeof(buffer))) > 0)
- if (cupsFileWrite(out, buffer, bytes) < bytes)
+ if (cupsFileWrite(out, buffer, (size_t)bytes) < bytes)
{
cupsdLogClient(con, CUPSD_LOG_ERROR,
"Unable to copy to config file \"%s\": %s",
*/
if (commptr[1] >= '0' && commptr[1] <= '9')
- *commptr = (commptr[1] - '0') << 4;
+ *commptr = (char)((commptr[1] - '0') << 4);
else
- *commptr = (tolower(commptr[1]) - 'a' + 10) << 4;
+ *commptr = (char)((tolower(commptr[1]) - 'a' + 10) << 4);
if (commptr[2] >= '0' && commptr[2] <= '9')
*commptr |= commptr[2] - '0';
httpClearFields(con->http);
- httpSetLength(con->http, filestats->st_size);
+ httpSetLength(con->http, (size_t)filestats->st_size);
httpSetField(con->http, HTTP_FIELD_LAST_MODIFIED,
httpGetDateString(filestats->st_mtime));
/*
* "$Id$"
*
- * Color management routines for the CUPS scheduler.
+ * Color management routines for the CUPS scheduler.
*
- * Copyright 2007-2013 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products, all rights reserved.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * Original DBUS/colord code is Copyright 2011 Red Hat, Inc.
+ * Original DBUS/colord code is Copyright 2011 Red Hat, Inc.
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * Contents:
- *
- * cupsdRegisterColor() - Register vendor color profiles in a PPD
- * file.
- * cupsdStartColor() - Initialize color management.
- * cupsdStopColor() - Shutdown color management.
- * cupsdUnregisterColor() - Unregister vendor color profiles in a PPD
- * file.
- * apple_init_profile() - Initialize a color profile.
- * apple_register_profiles() - Register color profiles for a printer.
- * apple_unregister_profiles() - Remove color profiles for the specified
- * printer.
- * colord_create_device() - Create a device and register profiles.
- * colord_create_profile() - Create a color profile for a printer.
- * colord_delete_device() - Delete a device
- * colord_device_add_profile() - Assign a profile to a device.
- * colord_dict_add_strings() - Add two strings to a dictionary.
- * colord_find_device() - Finds a device
- * colord_get_qualifier_format() - Get the qualifier format.
- * colord_register_printer() - Register profiles for a printer.
- * colord_unregister_printer() - Unregister profiles for a printer.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
if (iccfile && *iccfile)
{
- url = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault,
- (const UInt8 *)iccfile,
- strlen(iccfile), false);
+ url = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, (const UInt8 *)iccfile, (CFIndex)strlen(iccfile), false);
if (url)
{
CUPSD_VARTYPE_TIME, /* Time interval option */
CUPSD_VARTYPE_STRING, /* String option */
CUPSD_VARTYPE_BOOLEAN, /* Boolean option */
- CUPSD_VARTYPE_PATHNAME /* File/directory name option */
+ CUPSD_VARTYPE_PATHNAME, /* File/directory name option */
+ CUPSD_VARTYPE_PERM /* File/directory permissions */
} cupsd_vartype_t;
typedef struct
{
{ "AccessLog", &AccessLog, CUPSD_VARTYPE_STRING },
{ "CacheDir", &CacheDir, CUPSD_VARTYPE_STRING },
- { "ConfigFilePerm", &ConfigFilePerm, CUPSD_VARTYPE_INTEGER },
+ { "ConfigFilePerm", &ConfigFilePerm, CUPSD_VARTYPE_PERM },
{ "DataDir", &DataDir, CUPSD_VARTYPE_STRING },
{ "DocumentRoot", &DocumentRoot, CUPSD_VARTYPE_STRING },
{ "ErrorLog", &ErrorLog, CUPSD_VARTYPE_STRING },
{ "FileDevice", &FileDevice, CUPSD_VARTYPE_BOOLEAN },
{ "FontPath", &FontPath, CUPSD_VARTYPE_STRING },
- { "LogFilePerm", &LogFilePerm, CUPSD_VARTYPE_INTEGER },
+ { "LogFilePerm", &LogFilePerm, CUPSD_VARTYPE_PERM },
{ "LPDConfigFile", &LPDConfigFile, CUPSD_VARTYPE_STRING },
{ "PageLog", &PageLog, CUPSD_VARTYPE_STRING },
{ "Printcap", &Printcap, CUPSD_VARTYPE_STRING },
cupsdCheckPermissions(
const char *filename, /* I - File/directory name */
const char *suffix, /* I - Additional file/directory name */
- int mode, /* I - Permissions */
- int user, /* I - Owner */
- int group, /* I - Group */
+ mode_t mode, /* I - Permissions */
+ uid_t user, /* I - Owner */
+ gid_t group, /* I - Group */
int is_dir, /* I - 1 = directory, 0 = file */
int create_dir) /* I - 1 = create directory, -1 = create w/o logging, 0 = not */
{
if (!mimeType(MimeDatabase, "application", "octet-stream"))
NumMimeTypes ++;
- if ((MimeTypes = calloc(NumMimeTypes, sizeof(const char *))) == NULL)
+ if ((MimeTypes = calloc((size_t)NumMimeTypes, sizeof(const char *))) == NULL)
{
cupsdLogMessage(CUPSD_LOG_ERROR,
"Unable to allocate memory for %d MIME types.",
}
break;
+ case CUPSD_VARTYPE_PERM :
+ if (!value)
+ {
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Missing permissions value for %s on line %d of %s.",
+ line, linenum, filename);
+ return (0);
+ }
+ else if (!isdigit(*value & 255))
+ {
+ /* TODO: Add chmod UGO syntax support */
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Bad permissions value for %s on line %d of %s.",
+ line, linenum, filename);
+ return (0);
+ }
+ else
+ {
+ int n = strtol(value, NULL, 8);
+ /* Permissions value */
+
+ if (n < 0)
+ {
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Bad negative permissions value for %s on line %d of "
+ "%s.", line, linenum, filename);
+ return (0);
+ }
+ else
+ {
+ *((mode_t *)var->ptr) = (mode_t)n;
+ }
+ }
+ break;
+
case CUPSD_VARTYPE_TIME :
if (!value)
{
*/
if (isdigit(value[0]))
- Group = atoi(value);
+ Group = (gid_t)atoi(value);
else
{
endgrent();
return (0);
}
else
- User = atoi(value);
+ User = (uid_t)atoi(value);
}
else
{
/*
* "$Id$"
*
- * Configuration file definitions for the CUPS scheduler.
+ * Configuration file definitions for the CUPS scheduler.
*
- * Copyright 2007-2013 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products, all rights reserved.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*/
/* Remote root user */
*Classification VALUE(NULL);
/* Classification of system */
-VAR uid_t User VALUE(1);
+VAR uid_t User VALUE(1),
/* User ID for server */
+ RunUser VALUE(0);
+ /* User to run as, used for files */
VAR gid_t Group VALUE(0);
/* Group ID for server */
VAR cupsd_accesslog_t AccessLogLevel VALUE(CUPSD_ACCESSLOG_ACTIONS);
/* Access log level */
VAR int ClassifyOverride VALUE(0),
/* Allow overrides? */
- ConfigFilePerm VALUE(0640),
- /* Permissions for config files */
LogDebugHistory VALUE(200),
/* Amount of automatic debug history */
FatalErrors VALUE(CUPSD_FATAL_CONFIG),
/* Which errors are fatal? */
StrictConformance VALUE(FALSE),
/* Require strict IPP conformance? */
- SyncOnClose VALUE(FALSE),
+ SyncOnClose VALUE(FALSE);
/* Call fsync() when closing files? */
- LogFilePerm VALUE(0644);
+VAR mode_t ConfigFilePerm VALUE(0640U),
+ /* Permissions for config files */
+ LogFilePerm VALUE(0644U);
/* Permissions for log files */
VAR cupsd_loglevel_t LogLevel VALUE(CUPSD_LOG_WARN);
/* Error log level */
/* Timeout before reload from SIGHUP */
RootCertDuration VALUE(300),
/* Root certificate update interval */
- RunUser VALUE(0),
- /* User to run as, used for files */
PrintcapFormat VALUE(PRINTCAP_BSD),
/* Format of printcap file? */
DefaultShared VALUE(TRUE),
extern void cupsdAddAlias(cups_array_t *aliases, const char *name);
extern int cupsdCheckLogFile(cups_file_t **lf, const char *logname);
extern int cupsdCheckPermissions(const char *filename,
- const char *suffix, int mode,
- int user, int group, int is_dir,
+ const char *suffix, mode_t mode,
+ uid_t user, gid_t group, int is_dir,
int create_dir);
extern int cupsdCheckProgram(const char *filename, cupsd_printer_t *p);
extern int cupsdDefaultAuthType(void);
extern void cupsdLogFCMessage(void *context, _cups_fc_result_t result,
const char *message);
#ifdef HAVE_GSSAPI
-extern int cupsdLogGSSMessage(int level, int major_status,
- int minor_status,
+extern int cupsdLogGSSMessage(int level, OM_uint32 major_status,
+ OM_uint32 minor_status,
const char *message, ...);
#endif /* HAVE_GSSAPI */
extern int cupsdLogJob(cupsd_job_t *job, int level, const char *message,
/*
* "$Id$"
*
- * Device scanning mini-daemon for CUPS.
+ * Device scanning mini-daemon for CUPS.
*
- * Copyright 2007-2011 by Apple Inc.
- * Copyright 1997-2006 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2006 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
- *
- * Contents:
- *
- * main() - Scan for devices and return an IPP response.
- * add_device() - Add a new device to the list.
- * compare_devices() - Compare device names to eliminate duplicates.
- * get_current_time() - Get the current time as a double value in seconds.
- * get_device() - Get a device from a backend.
- * process_children() - Process all dead children...
- * sigchld_handler() - Handle 'child' signals from old processes.
- * start_backend() - Run a backend to gather the available devices.
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*/
/*
static struct pollfd backend_fds[MAX_BACKENDS];
/* Array for poll() */
static cups_array_t *devices; /* Array of devices */
-static int normal_user; /* Normal user ID */
+static uid_t normal_user; /* Normal user ID */
static int device_limit; /* Maximum number of devices */
static int send_class, /* Send device-class attribute? */
send_info, /* Send device-info attribute? */
return (1);
}
- normal_user = atoi(argv[4]);
+ normal_user = (uid_t)atoi(argv[4]);
if (normal_user <= 0)
{
fprintf(stderr, "ERROR: [cups-deviced] Bad user %d!\n", normal_user);
timeout = (int)(1000 * (end_time - current_time));
- if (poll(backend_fds, num_backends, timeout) > 0)
+ if (poll(backend_fds, (nfds_t)num_backends, timeout) > 0)
{
for (i = 0; i < num_backends; i ++)
if (backend_fds[i].revents && backends[i].pipe)
break;
}
}
- while (bpipe->ptr &&
- memchr(bpipe->ptr, '\n', bpipe->end - bpipe->ptr));
+ while (bpipe->ptr && memchr(bpipe->ptr, '\n', (size_t)(bpipe->end - bpipe->ptr)));
}
}
/*
* "$Id$"
*
- * PPD/driver support for CUPS.
+ * PPD/driver support for CUPS.
*
- * This program handles listing and installing static PPD files, PPD files
- * created from driver information files, and dynamically generated PPD files
- * using driver helper programs.
+ * This program handles listing and installing static PPD files, PPD files
+ * created from driver information files, and dynamically generated PPD files
+ * using driver helper programs.
*
- * Copyright 2007-2012 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2007 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
- *
- * Contents:
- *
- * main() - Scan for drivers and return an IPP response.
- * add_ppd() - Add a PPD file.
- * cat_drv() - Generate a PPD from a driver info file.
- * cat_ppd() - Copy a PPD file to stdout.
- * copy_static() - Copy a static PPD file to stdout.
- * cat_tar() - Copy an archived PPD file to stdout.
- * compare_inodes() - Compare two inodes.
- * compare_matches() - Compare PPD match scores for sorting.
- * compare_names() - Compare PPD filenames for sorting.
- * compare_ppds() - Compare PPD file make and model names for sorting.
- * dump_ppds_dat() - Dump the contents of the ppds.dat file.
- * free_array() - Free an array of strings.
- * get_file() - Get the filename associated with a request.
- * list_ppds() - List PPD files.
- * load_drv() - Load the PPDs from a driver information file.
- * load_drivers() - Load driver-generated PPD files.
- * load_ppd() - Load a PPD file.
- * load_ppds() - Load PPD files recursively.
- * load_ppds_dat() - Load the ppds.dat file.
- * load_tar() - Load archived PPD files.
- * read_tar() - Read a file header from an archive.
- * regex_device_id() - Compile a regular expression based on the 1284 device
- * ID.
- * regex_string() - Construct a regular expression to compare a simple
- * string.
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*/
/*
ppd->found = 1;
ppd->record.mtime = mtime;
- ppd->record.size = size;
+ ppd->record.size = (off_t)size;
ppd->record.model_number = model_number;
ppd->record.type = type;
if ((size_t)(bytes = (curinfo.st_size - total)) > sizeof(buffer))
bytes = sizeof(buffer);
- if ((bytes = cupsFileRead(fp, buffer, bytes)) < 0)
+ if ((bytes = cupsFileRead(fp, buffer, (size_t)bytes)) < 0)
{
if (errno == EINTR || errno == EAGAIN)
{
break;
}
}
- else if (bytes > 0 && fwrite(buffer, bytes, 1, stdout) != 1)
+ else if (bytes > 0 && fwrite(buffer, (size_t)bytes, 1, stdout) != 1)
break;
}
*type_str; /* ppd-type option */
int model_number, /* ppd-model-number value */
type, /* ppd-type value */
- make_and_model_len, /* Length of ppd-make-and-model */
- product_len, /* Length of ppd-product */
send_device_id, /* Send ppd-device-id? */
send_make, /* Send ppd-make? */
send_make_and_model, /* Send ppd-make-and-model? */
send_psversion, /* Send ppd-psversion? */
send_type, /* Send ppd-type? */
sent_header; /* Sent the IPP header? */
+ size_t make_and_model_len, /* Length of ppd-make-and-model */
+ product_len; /* Length of ppd-product */
regex_t *device_id_re, /* Regular expression for matching device ID */
*make_and_model_re; /* Regular expression for matching make and model */
regmatch_t re_matches[6]; /* Regular expression matches */
// See how much of the make-and-model string we matched...
if (re_matches[0].rm_so == 0)
{
- if (re_matches[0].rm_eo == make_and_model_len)
+ if ((size_t)re_matches[0].rm_eo == make_and_model_len)
ppd->matches += 3; // Exact match
else
ppd->matches += 2; // Prefix match
* Add a dummy entry for the file...
*/
- add_ppd(name, name, "", "", "", "", "", "", mtime, size, 0,
- PPD_TYPE_DRV, "drv");
+ add_ppd(name, name, "", "", "", "", "", "", mtime, (size_t)size, 0, PPD_TYPE_DRV, "drv");
ChangedPPD = 1;
/*
if (!strcmp(product->name->value, "Product"))
{
if (!products_found)
- ppd = add_ppd(name, uri, "en", d->manufacturer->value, make_model,
- device_id ? device_id->value->value : "",
- product->value->value,
- ps_version ? ps_version->value->value : "(3010) 0",
- mtime, size, d->model_number, type, "drv");
+ ppd = add_ppd(name, uri, "en", d->manufacturer->value, make_model, device_id ? device_id->value->value : "", product->value->value,
+ ps_version ? ps_version->value->value : "(3010) 0", mtime, (size_t)size, d->model_number, type, "drv");
else if (products_found < PPD_MAX_PROD)
- strlcpy(ppd->record.products[products_found], product->value->value,
- sizeof(ppd->record.products[0]));
+ strlcpy(ppd->record.products[products_found], product->value->value, sizeof(ppd->record.products[0]));
else
break;
}
if (!products_found)
- add_ppd(name, uri, "en", d->manufacturer->value, make_model,
- device_id ? device_id->value->value : "",
- d->model_name->value,
- ps_version ? ps_version->value->value : "(3010) 0",
- mtime, size, d->model_number, type, "drv");
+ add_ppd(name, uri, "en", d->manufacturer->value, make_model, device_id ? device_id->value->value : "", d->model_name->value, ps_version ? ps_version->value->value : "(3010) 0", mtime, (size_t)size, d->model_number, type, "drv");
}
src->release();
scheme_end = scheme + strlen(scheme) - 1;
if ((scheme_end > scheme && *scheme_end == '*' &&
- !strncmp(scheme, dent->filename, scheme_end - scheme)) ||
+ !strncmp(scheme, dent->filename, (size_t)(scheme_end - scheme))) ||
!strcmp(scheme, dent->filename))
{
fputs("DEBUG: [cups-driverd] Yes, exclude!\n", stderr);
scheme_end = scheme + strlen(scheme) - 1;
if ((scheme_end > scheme && *scheme_end == '*' &&
- !strncmp(scheme, dent->filename, scheme_end - scheme)) ||
+ !strncmp(scheme, dent->filename, (size_t)(scheme_end - scheme))) ||
!strcmp(scheme, dent->filename))
{
fputs("DEBUG: [cups-driverd] Yes, include!\n", stderr);
fprintf(stderr, "DEBUG2: [cups-driverd] Adding ppd \"%s\"...\n", name);
- ppd = add_ppd(name, name, lang_version, manufacturer, make_model,
- device_id, (char *)cupsArrayFirst(products),
- (char *)cupsArrayFirst(psversions),
- fileinfo->st_mtime, fileinfo->st_size,
- model_number, type, scheme);
+ ppd = add_ppd(name, name, lang_version, manufacturer, make_model, device_id, (char *)cupsArrayFirst(products), (char *)cupsArrayFirst(psversions), fileinfo->st_mtime, (size_t)fileinfo->st_size, model_number, type, scheme);
if (!ppd)
return;
unsigned ppdsync; /* Sync word */
int num_ppds; /* Number of PPDs */
- if (cupsFileRead(fp, (char *)&ppdsync, sizeof(ppdsync))
- == sizeof(ppdsync) &&
+ if (cupsFileRead(fp, (char *)&ppdsync, sizeof(ppdsync)) == sizeof(ppdsync) &&
ppdsync == PPD_SYNC &&
!stat(filename, &fileinfo) &&
- ((fileinfo.st_size - sizeof(ppdsync)) % sizeof(ppd_rec_t)) == 0 &&
- (num_ppds = (fileinfo.st_size - sizeof(ppdsync)) /
- sizeof(ppd_rec_t)) > 0)
+ (((size_t)fileinfo.st_size - sizeof(ppdsync)) % sizeof(ppd_rec_t)) == 0 &&
+ (num_ppds = ((size_t)fileinfo.st_size - sizeof(ppdsync)) / sizeof(ppd_rec_t)) > 0)
{
/*
* We have a ppds.dat file, so read it!
(void)filename;
- add_ppd(name, name, "", "", "", "", "", "", mtime, size, 0,
- PPD_TYPE_ARCHIVE, "file");
+ add_ppd(name, name, "", "", "", "", "", "", mtime, (size_t)size, 0, PPD_TYPE_ARCHIVE, "file");
ChangedPPD = 1;
/*
/*
* "$Id$"
*
- * Line Printer Daemon interface for CUPS.
+ * Line Printer Daemon interface for CUPS.
*
- * Copyright 2007-2012 by Apple Inc.
- * Copyright 1997-2006 by Easy Software Products, all rights reserved.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2006 by Easy Software Products, all rights reserved.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
- *
- * Contents:
- *
- * main() - Process an incoming LPD request...
- * create_job() - Create a new print job.
- * get_printer() - Get the named printer and its options.
- * print_file() - Add a file to the current job.
- * recv_print_job() - Receive a print job from the client.
- * remove_jobs() - Cancel one or more jobs.
- * send_state() - Send the queue state.
- * smart_gets() - Get a line of text, removing the trailing CR and/or LF.
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*/
/*
syslog(LOG_INFO, "Receive print job for %s", dest);
/* recv_print_job() sends initial status byte */
- status = recv_print_job(dest, num_defaults, defaults);
+ status = (char)recv_print_job(dest, num_defaults, defaults);
break;
case 0x03 : /* Send queue state (short) */
syslog(LOG_INFO, "Send queue state (short) for %s %s", dest, list);
/* no status byte for this command */
- status = send_state(dest, list, 0);
+ status = (char)send_state(dest, list, 0);
break;
case 0x04 : /* Send queue state (long) */
syslog(LOG_INFO, "Send queue state (long) for %s %s", dest, list);
/* no status byte for this command */
- status = send_state(dest, list, 1);
+ status = (char)send_state(dest, list, 1);
break;
case 0x05 : /* Remove jobs */
syslog(LOG_INFO, "Remove jobs %s on %s by %s", list, dest, agent);
- status = remove_jobs(dest, agent, list);
+ status = (char)remove_jobs(dest, agent, list);
}
else
status = 1;
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_MIMETYPE,
"document-format", NULL, format);
- ippAddBoolean(request, IPP_TAG_OPERATION, "last-document", last);
+ ippAddBoolean(request, IPP_TAG_OPERATION, "last-document", (char)last);
/*
* Do the request...
int fd; /* Temporary file */
FILE *fp; /* File pointer */
char filename[1024]; /* Temporary filename */
- int bytes; /* Bytes received */
+ ssize_t bytes; /* Bytes received */
+ size_t total; /* Total bytes */
char line[256], /* Line from file/stdin */
command, /* Command from line */
*count, /* Number of bytes */
* Copy the data or control file from the client...
*/
- for (i = atoi(count); i > 0; i -= bytes)
+ for (total = (size_t)strtoll(count, NULL, 10); total > 0; total -= (size_t)bytes)
{
- if (i > sizeof(line))
- bytes = sizeof(line);
+ if (total > sizeof(line))
+ bytes = (ssize_t)sizeof(line);
else
- bytes = i;
+ bytes = (ssize_t)total;
- if ((bytes = fread(line, 1, bytes, stdin)) > 0)
- bytes = write(fd, line, bytes);
+ if ((bytes = (ssize_t)fread(line, 1, (size_t)bytes, stdin)) > 0)
+ bytes = write(fd, line, (size_t)bytes);
if (bytes < 1)
{
break;
}
else if (ptr < end)
- *ptr++ = ch;
+ *ptr++ = (char)ch;
}
*ptr = '\0';
/*
* "$Id$"
*
- * Filtering program for CUPS.
+ * Filtering program for CUPS.
*
- * Copyright 2007-2013 by Apple Inc.
- * Copyright 1997-2006 by Easy Software Products, all rights reserved.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2006 by Easy Software Products, all rights reserved.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
- *
- * Contents:
- *
- * main() - Main entry for the test program.
- * add_printer_filter() - Add a single filters from a PPD file.
- * add_printer_filters() - Add filters from a PPD file.
- * check_cb() - Callback function for _cupsFileCheck.
- * compare_pids() - Compare two filter PIDs...
- * escape_options() - Convert an options array to a string.
- * exec_filter() - Execute a single filter.
- * exec_filters() - Execute filters for the given file and options.
- * get_job_file() - Get the specified job file.
- * open_pipe() - Create a pipe which is closed on exec.
- * read_cupsd_conf() - Read the cupsd.conf file to get the filter
- * settings.
- * set_string() - Copy and set a string.
- * sighandler() - Signal catcher for when we print from stdin...
- * usage() - Show program usage...
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*/
/*
{
char *ptr; /* Pointer into maxsize(nnnn) program */
- maxsize = strtoll(program + 8, &ptr, 10);
+ maxsize = (size_t)strtoll(program + 8, &ptr, 10);
if (*ptr != ')')
{
{
int i; /* Looping var */
cups_option_t *option; /* Current option */
- int bytes; /* Number of bytes needed */
+ size_t bytes; /* Number of bytes needed */
char *s, /* Option string */
*sptr, /* Pointer into string */
*vptr; /* Pointer into value */
if (sptr > s)
*sptr++ = ' ';
- strlcpy(sptr, option->name, bytes - (sptr - s));
+ strlcpy(sptr, option->name, bytes - (size_t)(sptr - s));
sptr += strlen(sptr);
*sptr++ = '=';
/*
* "$Id$"
*
- * Directory services routines for the CUPS scheduler.
+ * Directory services routines for the CUPS scheduler.
*
- * Copyright 2007-2013 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products, all rights reserved.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
- *
- * Contents:
- *
- * cupsdDeregisterPrinter() - Stop sending broadcast information for a local
- * printer and remove any pending references to
- * remote printers.
- * cupsdRegisterPrinter() - Start sending broadcast information for a
- * printer or update the broadcast contents.
- * cupsdStartBrowsing() - Start sending and receiving broadcast
- * information.
- * cupsdStopBrowsing() - Stop sending and receiving broadcast
- * information.
- * cupsdUpdateDNSSDName() - Update the computer name we use for
- * browsing...
- * dnssdAddAlias() - Add a DNS-SD alias name.
- * dnssdBuildTxtRecord() - Build a TXT record from printer info.
- * dnssdDeregisterInstance() - Deregister a DNS-SD service instance.
- * dnssdDeregisterPrinter() - Deregister all services for a printer.
- * dnssdErrorString() - Return an error string for an error code.
- * dnssdRegisterCallback() - Free a TXT record.
- * dnssdRegisterCallback() - DNSServiceRegister callback.
- * dnssdRegisterInstance() - Register an instance of a printer service.
- * dnssdRegisterPrinter() - Start sending broadcast information for a
- * printer or update the broadcast contents.
- * dnssdStop() - Stop all DNS-SD registrations.
- * dnssdUpdate() - Handle DNS-SD queries.
- * get_auth_info_required() - Get the auth-info-required value to advertise.
- * get_hostconfig() - Get an /etc/hostconfig service setting.
- * update_lpd() - Update the LPD configuration as needed.
- * update_smb() - Update the SMB configuration as needed.
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*/
/*
if (i)
*bufptr++ = ',';
- strlcpy(bufptr, p->auth_info_required[i], bufsize - (bufptr - buffer));
+ strlcpy(bufptr, p->auth_info_required[i], bufsize - (size_t)(bufptr - buffer));
bufptr += strlen(bufptr);
}
struct stat fileinfo; /* File information */
if (!fstat(con->file, &fileinfo))
- length += fileinfo.st_size;
+ length += (size_t)fileinfo.st_size;
}
cupsdLogMessage(CUPSD_LOG_DEBUG,
else
{
compressions = (int *)realloc(job->compressions,
- (job->num_files + 1) * sizeof(int));
+ (size_t)(job->num_files + 1) * sizeof(int));
filetypes = (mime_type_t **)realloc(job->filetypes,
- (job->num_files + 1) *
+ (size_t)(job->num_files + 1) *
sizeof(mime_type_t *));
}
*/
attrname[2] = '_';
- attrname[3] = toupper(attrname[3] & 255);
- attrname[4] = toupper(attrname[4] & 255);
+ attrname[3] = (char)toupper(attrname[3] & 255);
+ attrname[4] = (char)toupper(attrname[4] & 255);
}
snprintf(filename, sizeof(filename), "%s/banners/%s/%s", DataDir,
if (!isalpha(ch & 255) && ch != '-' && ch != '?')
break;
else if (s < (attrname + sizeof(attrname) - 1))
- *s++ = ch;
+ *s++ = (char)ch;
else
break;
*/
while ((bytes = cupsFileRead(src, buffer, sizeof(buffer))) > 0)
- if (cupsFileWrite(dst, buffer, bytes) < bytes)
+ if (cupsFileWrite(dst, buffer, (size_t)bytes) < bytes)
{
cupsFileClose(src);
cupsFileClose(dst);
if ((bytes = read(temppipe[0], buffer, sizeof(buffer))) > 0)
{
- if (write(tempfd, buffer, bytes) < bytes)
+ if (write(tempfd, buffer, (size_t)bytes) < bytes)
break;
total += bytes;
}
if (!ra || cupsArrayFind(ra, "printer-is-accepting-jobs"))
- ippAddBoolean(con->response, IPP_TAG_PRINTER, "printer-is-accepting-jobs",
- printer->accepting);
+ ippAddBoolean(con->response, IPP_TAG_PRINTER, "printer-is-accepting-jobs", (char)printer->accepting);
if (!ra || cupsArrayFind(ra, "printer-is-shared"))
- ippAddBoolean(con->response, IPP_TAG_PRINTER, "printer-is-shared",
- printer->shared);
+ ippAddBoolean(con->response, IPP_TAG_PRINTER, "printer-is-shared", (char)printer->shared);
if (!ra || cupsArrayFind(ra, "printer-more-info"))
{
if (!ra || cupsArrayFind(ra, "printer-type"))
{
- int type; /* printer-type value */
+ cups_ptype_t type; /* printer-type value */
/*
* Add the CUPS-specific printer-type attribute...
if (!printer->shared)
type |= CUPS_PRINTER_NOT_SHARED;
- ippAddInteger(con->response, IPP_TAG_PRINTER, IPP_TAG_ENUM, "printer-type",
- type);
+ ippAddInteger(con->response, IPP_TAG_PRINTER, IPP_TAG_ENUM, "printer-type", (int)type);
}
if (!ra || cupsArrayFind(ra, "printer-up-time"))
int limit; /* Max number of printers to return */
int count; /* Number of printers that match */
cupsd_printer_t *printer; /* Current printer pointer */
- int printer_type, /* printer-type attribute */
+ cups_ptype_t printer_type, /* printer-type attribute */
printer_mask; /* printer-type-mask attribute */
char *location; /* Location string */
const char *username; /* Current user */
if ((attr = ippFindAttribute(con->request, "printer-type",
IPP_TAG_ENUM)) != NULL)
- printer_type = attr->values[0].integer;
+ printer_type = (cups_ptype_t)attr->values[0].integer;
else
- printer_type = 0;
+ printer_type = (cups_ptype_t)0;
if ((attr = ippFindAttribute(con->request, "printer-type-mask",
IPP_TAG_ENUM)) != NULL)
- printer_mask = attr->values[0].integer;
+ printer_mask = (cups_ptype_t)attr->values[0].integer;
else
- printer_mask = 0;
+ printer_mask = (cups_ptype_t)0;
local = httpAddrLocalhost(&(con->clientaddr));
{
if (strcmp(dest->auth_info_required[i], "negotiate"))
{
- httpEncode64_2(line, sizeof(line), auth_info->values[i].string.text,
- strlen(auth_info->values[i].string.text));
+ httpEncode64_2(line, sizeof(line), auth_info->values[i].string.text, (int)strlen(auth_info->values[i].string.text));
cupsFilePutConf(fp, dest->auth_info_required[i], line);
}
else
* Allow fallback to username+password for Kerberized queues...
*/
- httpEncode64_2(line, sizeof(line), auth_info->values[0].string.text,
- strlen(auth_info->values[0].string.text));
+ httpEncode64_2(line, sizeof(line), auth_info->values[0].string.text, (int)strlen(auth_info->values[0].string.text));
cupsFilePutConf(fp, "username", line);
cupsdSetStringf(job->auth_env + 0, "AUTH_USERNAME=%s",
auth_info->values[0].string.text);
- httpEncode64_2(line, sizeof(line), auth_info->values[1].string.text,
- strlen(auth_info->values[1].string.text));
+ httpEncode64_2(line, sizeof(line), auth_info->values[1].string.text, (int)strlen(auth_info->values[1].string.text));
cupsFilePutConf(fp, "password", line);
cupsdSetStringf(job->auth_env + 1, "AUTH_PASSWORD=%s",
* Write the authenticated username...
*/
- httpEncode64_2(line, sizeof(line), con->username, strlen(con->username));
+ httpEncode64_2(line, sizeof(line), con->username, (int)strlen(con->username));
cupsFilePutConf(fp, "username", line);
cupsdSetStringf(job->auth_env + 0, "AUTH_USERNAME=%s", con->username);
* Write the authenticated password...
*/
- httpEncode64_2(line, sizeof(line), con->password, strlen(con->password));
+ httpEncode64_2(line, sizeof(line), con->password, (int)strlen(con->password));
cupsFilePutConf(fp, "password", line);
cupsdSetStringf(job->auth_env + 1, "AUTH_PASSWORD=%s", con->password);
{
cupsdLogJob(job, CUPSD_LOG_DEBUG, "Setting job-state to %d",
attr->values[0].integer);
- cupsdSetJobState(job, attr->values[0].integer,
- CUPSD_JOB_DEFAULT,
- "Job state changed by \"%s\"", username);
+ cupsdSetJobState(job, (ipp_jstate_t)attr->values[0].integer, CUPSD_JOB_DEFAULT, "Job state changed by \"%s\"", username);
check_jobs = 1;
}
break;
{
int i; /* Looping var */
ipp_attribute_t *attr; /* Current attribute */
- int namelen; /* Length of attribute name */
+ size_t namelen; /* Length of attribute name */
char name[256], /* New attribute name */
value[256]; /* String version of integer attrs */
*
* Job management routines for the CUPS scheduler.
*
- * Copyright 2007-2013 by Apple Inc.
+ * Copyright 2007-2014 by Apple Inc.
* Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
if (stat(filename, &fileinfo))
fileinfo.st_size = 0;
- filters = mimeFilter2(MimeDatabase, job->filetypes[job->current_file],
- fileinfo.st_size, job->printer->filetype,
- &(job->cost));
+ filters = mimeFilter2(MimeDatabase, job->filetypes[job->current_file], (size_t)fileinfo.st_size, job->printer->filetype, &(job->cost));
if (!filters)
{
else
argc = 7;
- if ((argv = calloc(argc + 1, sizeof(char *))) == NULL)
+ if ((argv = calloc((size_t)argc + 1, sizeof(char *))) == NULL)
{
cupsdLogMessage(CUPSD_LOG_DEBUG, "Unable to allocate argument array - %s",
strerror(errno));
{
if (i)
*psrptr++ = ',';
- strlcpy(psrptr, job->printer->reasons[i],
- psrlen - (psrptr - printer_state_reasons));
+ strlcpy(psrptr, job->printer->reasons[i], psrlen - (size_t)(psrptr - printer_state_reasons));
psrptr += strlen(psrptr);
}
}
{
if (job->num_files == 0)
{
- compressions = (int *)calloc(fileid, sizeof(int));
- filetypes = (mime_type_t **)calloc(fileid, sizeof(mime_type_t *));
+ compressions = (int *)calloc((size_t)fileid, sizeof(int));
+ filetypes = (mime_type_t **)calloc((size_t)fileid, sizeof(mime_type_t *));
}
else
{
- compressions = (int *)realloc(job->compressions,
- sizeof(int) * fileid);
- filetypes = (mime_type_t **)realloc(job->filetypes,
- sizeof(mime_type_t *) *
- fileid);
+ compressions = (int *)realloc(job->compressions, sizeof(int) * (size_t)fileid);
+ filetypes = (mime_type_t **)realloc(job->filetypes, sizeof(mime_type_t *) * (size_t)fileid);
}
if (compressions)
snprintf(temp, sizeof(temp), "[Job %d] printer-state-reasons=", job->id);
ptr = temp + strlen(temp);
if (printer->num_reasons == 0)
- strlcpy(ptr, "none", sizeof(temp) - (ptr - temp));
+ strlcpy(ptr, "none", sizeof(temp) - (size_t)(ptr - temp));
else
{
for (i = 0;
if (i)
*ptr++ = ',';
- strlcpy(ptr, printer->reasons[i], sizeof(temp) - (ptr - temp));
+ strlcpy(ptr, printer->reasons[i], sizeof(temp) - (size_t)(ptr - temp));
ptr += strlen(ptr);
}
}
*/
if (optptr > options)
- strlcat(optptr, " ", optlength - (optptr - options));
+ strlcat(optptr, " ", optlength - (size_t)(optptr - options));
if (attr->value_tag != IPP_TAG_BOOLEAN)
{
- strlcat(optptr, attr->name, optlength - (optptr - options));
- strlcat(optptr, "=", optlength - (optptr - options));
+ strlcat(optptr, attr->name, optlength - (size_t)(optptr - options));
+ strlcat(optptr, "=", optlength - (size_t)(optptr - options));
}
for (i = 0; i < attr->num_values; i ++)
{
if (i)
- strlcat(optptr, ",", optlength - (optptr - options));
+ strlcat(optptr, ",", optlength - (size_t)(optptr - options));
optptr += strlen(optptr);
{
case IPP_TAG_INTEGER :
case IPP_TAG_ENUM :
- snprintf(optptr, optlength - (optptr - options),
+ snprintf(optptr, optlength - (size_t)(optptr - options),
"%d", attr->values[i].integer);
break;
case IPP_TAG_BOOLEAN :
if (!attr->values[i].boolean)
- strlcat(optptr, "no", optlength - (optptr - options));
+ strlcat(optptr, "no", optlength - (size_t)(optptr - options));
- strlcat(optptr, attr->name,
- optlength - (optptr - options));
+ strlcat(optptr, attr->name, optlength - (size_t)(optptr - options));
break;
case IPP_TAG_RANGE :
if (attr->values[i].range.lower == attr->values[i].range.upper)
- snprintf(optptr, optlength - (optptr - options) - 1,
+ snprintf(optptr, optlength - (size_t)(optptr - options) - 1,
"%d", attr->values[i].range.lower);
else
- snprintf(optptr, optlength - (optptr - options) - 1,
+ snprintf(optptr, optlength - (size_t)(optptr - options) - 1,
"%d-%d", attr->values[i].range.lower,
attr->values[i].range.upper);
break;
case IPP_TAG_RESOLUTION :
- snprintf(optptr, optlength - (optptr - options) - 1,
+ snprintf(optptr, optlength - (size_t)(optptr - options) - 1,
"%dx%d%s", attr->values[i].resolution.xres,
attr->values[i].resolution.yres,
attr->values[i].resolution.units == IPP_RES_PER_INCH ?
for (i = num_pwgppds, pwgppd = pwgppds; i > 0; i --, pwgppd ++)
{
*optptr++ = ' ';
- strlcpy(optptr, pwgppd->name, optlength - (optptr - options));
+ strlcpy(optptr, pwgppd->name, optlength - (size_t)(optptr - options));
optptr += strlen(optptr);
*optptr++ = '=';
- strlcpy(optptr, pwgppd->value, optlength - (optptr - options));
+ strlcpy(optptr, pwgppd->value, optlength - (size_t)(optptr - options));
optptr += strlen(optptr);
}
*/
bytes ++; /* " " separator */
- bytes += attr->num_values; /* "," separators */
+ bytes += (size_t)attr->num_values; /* "," separators */
/*
* Boolean attributes appear as "foo,nofoo,foo,nofoo", while
if (attr->value_tag != IPP_TAG_BOOLEAN)
bytes += strlen(attr->name);
else
- bytes += attr->num_values * strlen(attr->name);
+ bytes += (size_t)attr->num_values * strlen(attr->name);
/*
* Now add the size required for each value in the attribute...
* Minimum value of a signed integer is -2147483647, or 11 digits.
*/
- bytes += attr->num_values * 11;
+ bytes += (size_t)attr->num_values * 11;
break;
case IPP_TAG_BOOLEAN :
* 23 characters max.
*/
- bytes += attr->num_values * 23;
+ bytes += (size_t)attr->num_values * 23;
break;
case IPP_TAG_RESOLUTION :
* suffixed by the units, or 26 characters max.
*/
- bytes += attr->num_values * 26;
+ bytes += (size_t)attr->num_values * 26;
break;
case IPP_TAG_STRING :
continue;
}
- job->filetypes = calloc(job->num_files, sizeof(mime_type_t *));
- job->compressions = calloc(job->num_files, sizeof(int));
+ job->filetypes = calloc((size_t)job->num_files, sizeof(mime_type_t *));
+ job->compressions = calloc((size_t)job->num_files, sizeof(int));
if (!job->filetypes || !job->compressions)
{
*
* Log file routines for the CUPS scheduler.
*
- * Copyright 2007-2013 by Apple Inc.
+ * Copyright 2007-2014 by Apple Inc.
* Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
static _cups_mutex_t log_mutex = _CUPS_MUTEX_INITIALIZER;
/* Mutex for logging */
-static int log_linesize = 0; /* Size of line for output file */
+static size_t log_linesize = 0; /* Size of line for output file */
static char *log_line = NULL; /* Line for output file */
#ifdef HAVE_VSYSLOG
* Insert the server name...
*/
- strlcpy(ptr, ServerName, sizeof(filename) - (ptr - filename));
+ strlcpy(ptr, ServerName, sizeof(filename) - (size_t)(ptr - filename));
ptr += strlen(ptr);
}
else
* the log file permissions as a basis...
*/
- int log_dir_perm = 0300 | LogFilePerm;
+ mode_t log_dir_perm = (mode_t)(0300 | LogFilePerm);
/* LogFilePerm + owner write/search */
if (log_dir_perm & 0040)
log_dir_perm |= 0010; /* Add group search */
if (log_dir_perm & 0004)
log_dir_perm |= 0001; /* Add other search */
- cupsdCheckPermissions(CUPS_LOGDIR, NULL, log_dir_perm, RunUser, Group,
- 1, -1);
+ cupsdCheckPermissions(CUPS_LOGDIR, NULL, log_dir_perm, RunUser, Group, 1, -1);
*lf = cupsFileOpen(filename, "a");
}
int /* O - 1 on success, 0 on error */
cupsdLogGSSMessage(
int level, /* I - Log level */
- int major_status, /* I - Major GSSAPI status */
- int minor_status, /* I - Minor GSSAPI status */
+ OM_uint32 major_status, /* I - Major GSSAPI status */
+ OM_uint32 minor_status, /* I - Minor GSSAPI status */
const char *message, /* I - printf-style message string */
...) /* I - Additional args as needed */
{
break;
case 'p' : /* Printer name */
- strlcpy(bufptr, job->printer->name,
- sizeof(buffer) - (bufptr - buffer));
+ strlcpy(bufptr, job->printer->name, sizeof(buffer) - (size_t)(bufptr - buffer));
bufptr += strlen(bufptr);
break;
case 'j' : /* Job ID */
- snprintf(bufptr, sizeof(buffer) - (bufptr - buffer), "%d", job->id);
+ snprintf(bufptr, sizeof(buffer) - (size_t)(bufptr - buffer), "%d", job->id);
bufptr += strlen(bufptr);
break;
case 'u' : /* Username */
- strlcpy(bufptr, job->username ? job->username : "-",
- sizeof(buffer) - (bufptr - buffer));
+ strlcpy(bufptr, job->username ? job->username : "-", sizeof(buffer) - (size_t)(bufptr - buffer));
bufptr += strlen(bufptr);
break;
case 'T' : /* Date and time */
- strlcpy(bufptr, cupsdGetDateTime(NULL, LogTimeFormat),
- sizeof(buffer) - (bufptr - buffer));
+ strlcpy(bufptr, cupsdGetDateTime(NULL, LogTimeFormat), sizeof(buffer) - (size_t)(bufptr - buffer));
bufptr += strlen(bufptr);
break;
case 'P' : /* Page number */
- strlcpy(bufptr, number, sizeof(buffer) - (bufptr - buffer));
+ strlcpy(bufptr, number, sizeof(buffer) - (size_t)(bufptr - buffer));
bufptr += strlen(bufptr);
break;
case 'C' : /* Number of copies */
- snprintf(bufptr, sizeof(buffer) - (bufptr - buffer), "%d", copies);
+ snprintf(bufptr, sizeof(buffer) - (size_t)(bufptr - buffer), "%d", copies);
bufptr += strlen(bufptr);
break;
case '{' : /* {attribute} */
- if ((nameend = strchr(format, '}')) != NULL &&
- (nameend - format - 2) < (sizeof(name) - 1))
+ if ((nameend = strchr(format, '}')) != NULL && (size_t)(nameend - format - 2) < (sizeof(name) - 1))
{
/*
* Pull the name from inside the brackets...
{
case IPP_TAG_INTEGER :
case IPP_TAG_ENUM :
- snprintf(bufptr, sizeof(buffer) - (bufptr - buffer),
- "%d", attr->values[i].integer);
+ snprintf(bufptr, sizeof(buffer) - (size_t)(bufptr - buffer), "%d", attr->values[i].integer);
bufptr += strlen(bufptr);
break;
case IPP_TAG_BOOLEAN :
- snprintf(bufptr, sizeof(buffer) - (bufptr - buffer),
- "%d", attr->values[i].boolean);
+ snprintf(bufptr, sizeof(buffer) - (size_t)(bufptr - buffer), "%d", attr->values[i].boolean);
bufptr += strlen(bufptr);
break;
case IPP_TAG_CHARSET :
case IPP_TAG_LANGUAGE :
case IPP_TAG_MIMETYPE :
- strlcpy(bufptr, attr->values[i].string.text,
- sizeof(buffer) - (bufptr - buffer));
+ strlcpy(bufptr, attr->values[i].string.text, sizeof(buffer) - (size_t)(bufptr - buffer));
bufptr += strlen(bufptr);
break;
default :
- strlcpy(bufptr, "???",
- sizeof(buffer) - (bufptr - buffer));
+ strlcpy(bufptr, "???", sizeof(buffer) - (size_t)(bufptr - buffer));
bufptr += strlen(bufptr);
break;
}
format_log_line(const char *message, /* I - Printf-style format string */
va_list ap) /* I - Argument list */
{
- int len; /* Length of formatted line */
+ ssize_t len; /* Length of formatted line */
/*
* Resize the buffer as needed...
*/
- if (len >= log_linesize && log_linesize < 65536)
+ if ((size_t)len >= log_linesize && log_linesize < 65536)
{
char *temp; /* Temporary string pointer */
else if (len > 65536)
len = 65536;
- temp = realloc(log_line, len);
+ temp = realloc(log_line, (size_t)len);
if (temp)
{
log_line = temp;
- log_linesize = len;
+ log_linesize = (size_t)len;
return (0);
}
*
* Main loop for the CUPS scheduler.
*
- * Copyright 2007-2013 by Apple Inc.
+ * Copyright 2007-2014 by Apple Inc.
* Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
return (1);
}
- strlcpy(slash, "/cups-files.conf", len - (slash - filename));
+ strlcpy(slash, "/cups-files.conf", len - (size_t)(slash - filename));
cupsdSetString(&CupsFilesFile, filename);
free(filename);
}
#endif /* RLIM_INFINITY */
MaxFDs = limit.rlim_max;
- limit.rlim_cur = MaxFDs;
+ limit.rlim_cur = (rlim_t)MaxFDs;
setrlimit(RLIMIT_NOFILE, &limit);
/*
* "$Id$"
*
- * MIME database file routines for CUPS.
+ * MIME database file routines for CUPS.
*
- * Copyright 2007-2013 by Apple Inc.
- * Copyright 1997-2006 by Easy Software Products, all rights reserved.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2006 by Easy Software Products, all rights reserved.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
- *
- * Contents:
- *
- * mimeDelete() - Delete (free) a MIME database.
- * mimeDeleteFilter() - Delete a filter from the MIME database.
- * mimeDeleteType() - Delete a type from the MIME database.
- * _mimeError() - Show an error message.
- * mimeFirstFilter() - Get the first filter in the MIME database.
- * mimeFirstType() - Get the first type in the MIME database.
- * mimeLoad() - Create a new MIME database from disk.
- * mimeLoadFilters() - Load filter definitions from disk.
- * mimeLoadTypes() - Load type definitions from disk.
- * mimeNew() - Create a new, empty MIME database.
- * mimeNextFilter() - Get the next filter in the MIME database.
- * mimeNextType() - Get the next type in the MIME database.
- * mimeNumFilters() - Get the number of filters in a MIME database.
- * mimeNumTypes() - Get the number of types in a MIME database.
- * mimeSetErrorCallback() - Set the callback for error messages.
- * mime_add_fcache() - Add a filter to the filter cache.
- * mime_compare_fcache() - Compare two filter cache entries.
- * mime_delete_fcache() - Free all memory used by the filter cache.
- * mime_delete_rules() - Free all memory for the given rule tree.
- * mime_load_convs() - Load a xyz.convs file.
- * mime_load_types() - Load a xyz.types file.
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*/
/*
while (*lineptr != '/' && *lineptr != '\n' && *lineptr != '\0' &&
(temp - super + 1) < MIME_MAX_SUPER)
- *temp++ = tolower(*lineptr++ & 255);
+ *temp++ = (char)tolower(*lineptr++ & 255);
*temp = '\0';
while (*lineptr != ' ' && *lineptr != '\t' && *lineptr != '\n' &&
*lineptr != '\0' && (temp - type + 1) < MIME_MAX_TYPE)
- *temp++ = tolower(*lineptr++ & 255);
+ *temp++ = (char)tolower(*lineptr++ & 255);
*temp = '\0';
while (*lineptr != '/' && *lineptr != '\n' && *lineptr != '\0' &&
(temp - super + 1) < MIME_MAX_SUPER)
- *temp++ = tolower(*lineptr++ & 255);
+ *temp++ = (char)tolower(*lineptr++ & 255);
*temp = '\0';
while (*lineptr != ' ' && *lineptr != '\t' && *lineptr != '\n' &&
*lineptr != '\0' && (temp - type + 1) < MIME_MAX_TYPE)
- *temp++ = tolower(*lineptr++ & 255);
+ *temp++ = (char)tolower(*lineptr++ & 255);
*temp = '\0';
const char *filename) /* I - Types file to load */
{
cups_file_t *fp; /* Types file */
- int linelen; /* Length of line */
+ size_t linelen; /* Length of line */
char line[32768], /* Input line from file */
*lineptr, /* Current position in line */
super[MIME_MAX_SUPER], /* Super-type name */
while (*lineptr != '/' && *lineptr != '\n' && *lineptr != '\0' &&
(temp - super + 1) < MIME_MAX_SUPER)
- *temp++ = tolower(*lineptr++ & 255);
+ *temp++ = (char)tolower(*lineptr++ & 255);
*temp = '\0';
while (*lineptr != ' ' && *lineptr != '\t' && *lineptr != '\n' &&
*lineptr != '\0' && (temp - type + 1) < MIME_MAX_TYPE)
- *temp++ = tolower(*lineptr++ & 255);
+ *temp++ = (char)tolower(*lineptr++ & 255);
*temp = '\0';
*
* Printer routines for the CUPS scheduler.
*
- * Copyright 2007-2013 by Apple Inc.
+ * Copyright 2007-2014 by Apple Inc.
* Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
else if (!_cups_strcasecmp(line, "Type"))
{
if (value)
- p->type = atoi(value);
+ p->type = (cups_ptype_t)atoi(value);
else
cupsdLogMessage(CUPSD_LOG_ERROR,
"Syntax error on line %d of printers.conf.", linenum);
strcmp(p->auth_info_required[0], "none"))
p->type |= CUPS_PRINTER_AUTHENTICATED;
else
- p->type &= ~CUPS_PRINTER_AUTHENTICATED;
+ p->type &= (cups_ptype_t)~CUPS_PRINTER_AUTHENTICATED;
return (1);
}
if (auth_type != CUPSD_AUTH_NONE)
p->type |= CUPS_PRINTER_AUTHENTICATED;
else
- p->type &= ~CUPS_PRINTER_AUTHENTICATED;
+ p->type &= (cups_ptype_t)~CUPS_PRINTER_AUTHENTICATED;
}
else
- p->type &= ~CUPS_PRINTER_AUTHENTICATED;
+ p->type &= (cups_ptype_t)~CUPS_PRINTER_AUTHENTICATED;
/*
* Create the required IPP attributes for a printer...
if (p->type & CUPS_PRINTER_CLASS)
{
p->raw = 1;
- p->type &= ~CUPS_PRINTER_OPTIONS;
+ p->type &= (cups_ptype_t)~CUPS_PRINTER_OPTIONS;
/*
* Add class-specific attributes...
if (attr != NULL)
attr->values[i].string.text = _cupsStrAlloc(p->printers[i]->name);
- p->type &= ~CUPS_PRINTER_OPTIONS | p->printers[i]->type;
+ p->type &= (cups_ptype_t)~CUPS_PRINTER_OPTIONS | p->printers[i]->type;
}
}
}
_cupsStrFree(p->reasons[i]);
if (i < p->num_reasons)
- memmove(p->reasons + i, p->reasons + i + 1,
- (p->num_reasons - i) * sizeof(char *));
+ memmove(p->reasons + i, p->reasons + i + 1, (size_t)(p->num_reasons - i) * sizeof(char *));
if (!strcmp(reason, "paused") && p->state == IPP_PRINTER_STOPPED)
cupsdSetPrinterState(p, IPP_PRINTER_IDLE, 1);
{
char *ptr; /* Pointer into maxsize(nnnn) program */
- maxsize = strtoll(program + 8, &ptr, 10);
+ maxsize = (size_t)strtoll(program + 8, &ptr, 10);
if (*ptr != ')')
{
cupsdLogMessage(CUPSD_LOG_DEBUG, "load_ppd: Loading %s...", ppd_name);
- p->type &= ~CUPS_PRINTER_OPTIONS;
+ p->type &= (cups_ptype_t)~CUPS_PRINTER_OPTIONS;
p->type |= CUPS_PRINTER_BW;
finishings[0] = IPP_FINISHINGS_NONE;
if (ppd_attr->value && !_cups_strcasecmp(ppd_attr->value, "true"))
p->type |= CUPS_PRINTER_FAX;
- ippAddBoolean(p->ppd_attrs, IPP_TAG_PRINTER, "color-supported",
- ppd->color_device);
+ ippAddBoolean(p->ppd_attrs, IPP_TAG_PRINTER, "color-supported", (char)ppd->color_device);
if (p->pc && p->pc->charge_info_uri)
ippAddString(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_URI,
ippAddString(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
"job-password-encryption-supported", NULL, "none");
ippAddInteger(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER,
- "job-password-supported", strlen(p->pc->password));
+ "job-password-supported", (int)strlen(p->pc->password));
}
if (ppd->throughput)
CGContextRef context; /* The CG context used for resizing */
snprintf(outPath, sizeof(outPath), "%s/%s.png", CacheDir, p->name);
- outUrl = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault,
- (UInt8 *)outPath,
- strlen(outPath),
- FALSE);
- icnsFileUrl = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault,
- (UInt8 *)ppd_attr->value,
- strlen(ppd_attr->value),
- FALSE);
+ outUrl = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, (UInt8 *)outPath, (CFIndex)strlen(outPath), FALSE);
+ icnsFileUrl = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, (UInt8 *)ppd_attr->value, (CFIndex)strlen(ppd_attr->value), FALSE);
if (outUrl && icnsFileUrl)
{
sourceRef = CGImageSourceCreateWithURL(icnsFileUrl, NULL);
if (sourceRef)
{
- for (i = 0; i < CGImageSourceGetCount(sourceRef); i ++)
+ for (i = 0; i < (int)CGImageSourceGetCount(sourceRef); i ++)
{
- imageRef = CGImageSourceCreateImageAtIndex(sourceRef, i, NULL);
+ imageRef = CGImageSourceCreateImageAtIndex(sourceRef, (size_t)i, NULL);
if (!imageRef)
continue;
if (*s == '&')
{
if (s > start)
- cupsFileWrite(fp, start, s - start);
+ cupsFileWrite(fp, start, (size_t)(s - start));
cupsFilePuts(fp, "&");
start = s + 1;
else if (*s == '<')
{
if (s > start)
- cupsFileWrite(fp, start, s - start);
+ cupsFileWrite(fp, start, (size_t)(s - start));
cupsFilePuts(fp, "<");
start = s + 1;
/*
* "$Id$"
*
- * Process management routines for the CUPS scheduler.
+ * Process management routines for the CUPS scheduler.
*
- * Copyright 2007-2012 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products, all rights reserved.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
- *
- * Contents:
- *
- * cupsdCreateProfile() - Create an execution profile for a subprocess.
- * cupsdDestroyProfile() - Delete an execution profile.
- * cupsdEndProcess() - End a process.
- * cupsdFinishProcess() - Finish a process and get its name.
- * cupsdStartProcess() - Start a process.
- * compare_procs() - Compare two processes.
- * cupsd_requote() - Make a regular-expression version of a string.
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*/
/*
const char *exec_path = command; /* Command to be exec'd */
char *real_argv[103], /* Real command-line arguments */
cups_exec[1024]; /* Path to "cups-exec" program */
- int user; /* Command UID */
+ uid_t user; /* Command UID */
cupsd_proc_t *proc; /* New process record */
#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
struct sigaction action; /* POSIX signal handler */
if (strchr(".?*()[]^$\\", ch))
*dstptr++ = '\\';
- *dstptr++ = ch;
+ *dstptr++ = (char)ch;
}
*dstptr = '\0';
*
* Select abstraction functions for the CUPS scheduler.
*
- * Copyright 2007-2013 by Apple Inc.
+ * Copyright 2007-2014 by Apple Inc.
* Copyright 2006-2007 by Easy Software Products.
*
* These coded instructions, statements, and computer programs are the
#elif defined(HAVE_KQUEUE)
cupsd_kqueue_fd = kqueue();
cupsd_kqueue_changes = 0;
- cupsd_kqueue_events = calloc(MaxFDs, sizeof(struct kevent));
+ cupsd_kqueue_events = calloc((size_t)MaxFDs, sizeof(struct kevent));
#elif defined(HAVE_POLL)
cupsd_update_pollfds = 0;
/*
* "$Id$"
*
- * Status buffer routines for the CUPS scheduler.
+ * Status buffer routines for the CUPS scheduler.
*
- * Copyright 2007-2012 by Apple Inc.
- * Copyright 1997-2006 by Easy Software Products, all rights reserved.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2006 by Easy Software Products, all rights reserved.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
- *
- * Contents:
- *
- * cupsdStatBufDelete() - Destroy a status buffer.
- * cupsdStatBufNew() - Create a new status buffer.
- * cupsdStatBufUpdate() - Update the status buffer.
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*/
/*
* No, read more data...
*/
- if ((bytes = read(sb->fd, sb->buffer + sb->bufused,
- CUPSD_SB_BUFFER_SIZE - sb->bufused - 1)) > 0)
+ if ((bytes = read(sb->fd, sb->buffer + sb->bufused, (size_t)(CUPSD_SB_BUFFER_SIZE - sb->bufused - 1))) > 0)
{
sb->bufused += bytes;
sb->buffer[sb->bufused] = '\0';
/*
* "$Id$"
*
- * Subscription routines for the CUPS scheduler.
+ * Subscription routines for the CUPS scheduler.
*
- * Copyright 2007-2011 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products, all rights reserved.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
- *
- * Contents:
- *
- * cupsdAddEvent() - Add an event to the global event cache.
- * cupsdAddSubscription() - Add a new subscription object.
- * cupsdDeleteAllSubscriptions() - Delete all subscriptions.
- * cupsdDeleteSubscription() - Delete a subscription object.
- * cupsdEventName() - Return a single event name.
- * cupsdEventValue() - Return the event mask value for a name.
- * cupsdExpireSubscriptions() - Expire old subscription objects.
- * cupsdFindSubscription() - Find a subscription by ID.
- * cupsdLoadAllSubscriptions() - Load all subscriptions from the .conf file.
- * cupsdSaveAllSubscriptions() - Save all subscriptions to the .conf file.
- * cupsdStopAllNotifiers() - Stop all notifier processes.
- * cupsd_compare_subscriptions() - Compare two subscriptions.
- * cupsd_delete_event() - Delete a single event...
- * cupsd_send_dbus() - Send a DBUS notification...
- * cupsd_send_notification() - Send a notification for the specified
- * event.
- * cupsd_start_notifier() - Start a notifier subprocess...
- * cupsd_update_notifier() - Read messages from notifiers.
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*/
/*
(const char * const *)dest->reasons);
ippAddBoolean(temp->attrs, IPP_TAG_EVENT_NOTIFICATION,
- "printer-is-accepting-jobs", dest->accepting);
+ "printer-is-accepting-jobs", (char)dest->accepting);
}
if (job)
if (isxdigit(valueptr[0]) && isxdigit(valueptr[1]))
{
if (isdigit(valueptr[0]))
- sub->user_data[i] = (valueptr[0] - '0') << 4;
+ sub->user_data[i] = (unsigned char)((valueptr[0] - '0') << 4);
else
- sub->user_data[i] = (tolower(valueptr[0]) - 'a' + 10) << 4;
+ sub->user_data[i] = (unsigned char)((tolower(valueptr[0]) - 'a' + 10) << 4);
if (isdigit(valueptr[1]))
sub->user_data[i] |= valueptr[1] - '0';
break;
}
else
- sub->user_data[i] = *valueptr++;
+ sub->user_data[i] = (unsigned char)*valueptr++;
}
if (*valueptr)
/*
* "$Id$"
*
- * cups-lpd test program for CUPS.
+ * cups-lpd test program for CUPS.
*
- * Copyright 2007-2013 by Apple Inc.
- * Copyright 2006 by Easy Software Products, all rights reserved.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 2006 by Easy Software Products, all rights reserved.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
- *
- * Contents:
- *
- * main() - Simulate an LPD client.
- * do_command() - Send the LPD command and wait for a response.
- * print_job() - Submit a file for printing.
- * print_waiting() - Print waiting jobs.
- * remove_job() - Cancel a print job.
- * status_long() - Show the long printer status.
- * status_short() - Show the short printer status.
- * usage() - Show program usage...
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*/
/*
int infd, /* I - Response file descriptor */
const char *command) /* I - Command line to send */
{
- int len; /* Length of command line */
- char status; /* Status byte */
+ size_t len; /* Length of command line */
+ char status; /* Status byte */
printf("COMMAND: %02X %s", command[0], command + 1);
len = strlen(command);
- if (write(outfd, command, len) < len)
+ if ((size_t)write(outfd, command, len) < len)
{
puts(" Write failed!");
return (-1);
struct stat fileinfo; /* File information */
char *jobname; /* Job name */
int sequence; /* Sequence number */
- int bytes; /* Bytes read/written */
+ ssize_t bytes; /* Bytes read/written */
/*
* Send the control file...
*/
- bytes = strlen(control);
+ bytes = (ssize_t)strlen(control);
snprintf(command, sizeof(command), "\002%d cfA%03dlocalhost\n",
- bytes, sequence);
+ (int)bytes, sequence);
if ((status = do_command(outfd, infd, command)) != 0)
{
bytes ++;
- if (write(outfd, control, bytes) < bytes)
+ if (write(outfd, control, (size_t)bytes) < bytes)
{
- printf("CONTROL: Unable to write %d bytes!\n", bytes);
+ printf("CONTROL: Unable to write %d bytes!\n", (int)bytes);
close(fd);
return (-1);
}
- printf("CONTROL: Wrote %d bytes.\n", bytes);
+ printf("CONTROL: Wrote %d bytes.\n", (int)bytes);
if (read(infd, command, 1) < 1)
{
while ((bytes = read(fd, buffer, sizeof(buffer))) > 0)
{
- if (write(outfd, buffer, bytes) < bytes)
+ if (write(outfd, buffer, (size_t)bytes) < bytes)
{
- printf("DATA: Unable to write %d bytes!\n", bytes);
+ printf("DATA: Unable to write %d bytes!\n", (int)bytes);
close(fd);
return (-1);
}
{
char command[1024], /* Command buffer */
buffer[8192]; /* Status buffer */
- int bytes; /* Bytes read/written */
+ ssize_t bytes; /* Bytes read/written */
/*
else
snprintf(command, sizeof(command), "\004%s\n", dest);
- bytes = strlen(command);
+ bytes = (ssize_t)strlen(command);
- if (write(outfd, command, bytes) < bytes)
+ if (write(outfd, command, (size_t)bytes) < bytes)
return (-1);
/*
while ((bytes = read(infd, buffer, sizeof(buffer))) > 0)
{
- fwrite(buffer, 1, bytes, stdout);
+ fwrite(buffer, 1, (size_t)bytes, stdout);
fflush(stdout);
}
{
char command[1024], /* Command buffer */
buffer[8192]; /* Status buffer */
- int bytes; /* Bytes read/written */
+ ssize_t bytes; /* Bytes read/written */
/*
else
snprintf(command, sizeof(command), "\003%s\n", dest);
- bytes = strlen(command);
+ bytes = (ssize_t)strlen(command);
- if (write(outfd, command, bytes) < bytes)
+ if (write(outfd, command, (size_t)bytes) < bytes)
return (-1);
/*
while ((bytes = read(infd, buffer, sizeof(buffer))) > 0)
{
- fwrite(buffer, 1, bytes, stdout);
+ fwrite(buffer, 1, (size_t)bytes, stdout);
fflush(stdout);
}
/*
* "$Id$"
*
- * MIME test program for CUPS.
+ * MIME test program for CUPS.
*
- * Copyright 2007-2013 by Apple Inc.
- * Copyright 1997-2006 by Easy Software Products, all rights reserved.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2006 by Easy Software Products, all rights reserved.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
- *
- * Contents:
- *
- * main() - Main entry for the test program.
- * add_ppd_filter() - Add a printer filter from a PPD.
- * add_ppd_filters() - Add all filters from a PPD.
- * print_rules() - Print the rules for a file type...
- * type_dir() - Show the MIME types for a given directory.
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*/
/*
sscanf(argv[i], "%15[^/]/%255s", super, type);
dst = mimeType(mime, super, type);
- filters = mimeFilter2(mime, src, srcinfo.st_size, dst, &cost);
+ filters = mimeFilter2(mime, src, (size_t)srcinfo.st_size, dst, &cost);
if (!filters)
{
{
char *ptr; /* Pointer into maxsize(nnnn) program */
- maxsize = strtoll(program + 8, &ptr, 10);
+ maxsize = (size_t)strtoll(program + 8, &ptr, 10);
if (*ptr != ')')
{
/*
* "$Id$"
*
- * Scheduler speed test for CUPS.
+ * Scheduler speed test for CUPS.
*
- * Copyright 2007-2010 by Apple Inc.
- * Copyright 1997-2005 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2005 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
- *
- * Contents:
- *
- * main() - Send multiple IPP requests and report on the average response
- * time.
- * do_test() - Run a test on a specific host...
- * usage() - Show program usage...
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*/
/*
if (opstring)
op = ippOpValue(opstring);
else
- op = ops[i % (sizeof(ops) / sizeof(ops[0]))];
+ op = ops[i % (int)(sizeof(ops) / sizeof(ops[0]))];
request = ippNewRequest(op);
/*
* "$Id$"
*
- * Scheduler notification tester for CUPS.
+ * Scheduler notification tester for CUPS.
*
- * Copyright 2007-2012 by Apple Inc.
- * Copyright 2006-2007 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 2006-2007 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
- *
- * Contents:
- *
- * main() - Subscribe to the .
- * print_attributes() - Print the attributes in a request...
- * sigterm_handler() - Flag when the user hits CTRL-C...
- * usage() - Show program usage...
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*/
/*
interval = 5;
ippDelete(response);
- sleep(interval);
+ sleep((unsigned)interval);
}
/*
/*
* "$Id$"
*
- * MIME typing routines for CUPS.
+ * MIME typing routines for CUPS.
*
- * Copyright 2007-2013 by Apple Inc.
- * Copyright 1997-2006 by Easy Software Products, all rights reserved.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2006 by Easy Software Products, all rights reserved.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
- *
- * Contents:
- *
- * mimeAddType() - Add a MIME type to a database.
- * mimeAddTypeRule() - Add a detection rule for a file type.
- * mimeFileType() - Determine the type of a file.
- * mimeType() - Lookup a file type.
- * mime_compare_types() - Compare two MIME super/type names.
- * mime_check_rules() - Check each rule in a list.
- * mime_patmatch() - Pattern matching.
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*/
/*
*/
ptr = name;
- while (isalnum(*rule & 255) && (ptr - name) < (sizeof(name) - 1))
+ while (isalnum(*rule & 255) && (size_t)(ptr - name) < (sizeof(name) - 1))
*ptr++ = *rule++;
*ptr = '\0';
rule ++;
for (num_values = 0;
- num_values < (sizeof(value) / sizeof(value[0]));
+ num_values < (int)(sizeof(value) / sizeof(value[0]));
num_values ++)
{
ptr = value[num_values];
- while ((ptr - value[num_values]) < (sizeof(value[0]) - 1) &&
+ while ((size_t)(ptr - value[num_values]) < (sizeof(value[0]) - 1) &&
*rule != '\0' && *rule != ',' && *rule != ')')
{
if (isspace(*rule & 255))
quote = *rule++;
while (*rule != '\0' && *rule != quote &&
- (ptr - value[num_values]) < (sizeof(value[0]) - 1))
+ (size_t)(ptr - value[num_values]) < (sizeof(value[0]) - 1))
*ptr++ = *rule++;
if (*rule == quote)
rule ++;
while (*rule != '>' && *rule != '\0' &&
- (ptr - value[num_values]) < (sizeof(value[0]) - 1))
+ (size_t)(ptr - value[num_values]) < (sizeof(value[0]) - 1))
{
if (isxdigit(rule[0] & 255) && isxdigit(rule[1] & 255))
{
if (isdigit(*rule))
- *ptr = (*rule++ - '0') << 4;
+ *ptr = (char)((*rule++ - '0') << 4);
else
- *ptr = (tolower(*rule++) - 'a' + 10) << 4;
+ *ptr = (char)((tolower(*rule++) - 'a' + 10) << 4);
if (isdigit(*rule))
*ptr++ |= *rule++ - '0';
*/
snprintf(value[0], sizeof(value[0]), "*.%s", name);
- length[0] = strlen(value[0]);
+ length[0] = (int)strlen(value[0]);
op = MIME_MAGIC_MATCH;
}
if ((temp = calloc(1, sizeof(mime_magic_t))) == NULL)
return (-1);
- temp->invert = invert;
+ temp->invert = (short)invert;
if (current != NULL)
{
temp->parent = current->parent;
*/
current = temp;
- temp->op = op;
+ temp->op = (short)op;
invert = 0;
switch (op)
{
case MIME_MAGIC_MATCH :
- if (length[0] > (sizeof(temp->value.matchv) - 1))
+ if ((size_t)length[0] > (sizeof(temp->value.matchv) - 1))
return (-1);
strlcpy(temp->value.matchv, value[0], sizeof(temp->value.matchv));
break;
case MIME_MAGIC_STRING :
case MIME_MAGIC_ISTRING :
temp->offset = strtol(value[0], NULL, 0);
- if (length[1] > sizeof(temp->value.stringv))
+ if ((size_t)length[1] > sizeof(temp->value.stringv))
return (-1);
temp->length = length[1];
memcpy(temp->value.stringv, value[1], length[1]);
case MIME_MAGIC_CHAR :
temp->offset = strtol(value[0], NULL, 0);
if (length[1] == 1)
- temp->value.charv = value[1][0];
+ temp->value.charv = (unsigned char)value[1][0];
else
temp->value.charv = (unsigned char)strtol(value[1], NULL, 0);
temp->value.intv = (unsigned)strtol(value[1], NULL, 0);
break;
case MIME_MAGIC_LOCALE :
- if (length[0] > (sizeof(temp->value.localev) - 1))
+ if ((size_t)length[0] > (sizeof(temp->value.localev) - 1))
return (-1);
strlcpy(temp->value.localev, value[0], sizeof(temp->value.localev));
case MIME_MAGIC_CONTAINS :
temp->offset = strtol(value[0], NULL, 0);
temp->region = strtol(value[1], NULL, 0);
- if (length[2] > sizeof(temp->value.stringv))
+ if ((size_t)length[2] > sizeof(temp->value.stringv))
return (-1);
temp->length = length[2];
memcpy(temp->value.stringv, value[2], length[2]);
int n; /* Looping var */
int region; /* Region to look at */
int logic, /* Logic to apply */
- result, /* Result of test */
- intv; /* Integer value */
+ result; /* Result of test */
+ unsigned intv; /* Integer value */
short shortv; /* Short value */
unsigned char *bufptr; /* Pointer into buffer */
if ((rules->offset + rules->length) > (fb->offset + fb->length))
result = 0;
else
- result = (memcmp(fb->buffer + rules->offset - fb->offset,
- rules->value.stringv, rules->length) == 0);
+ result = !memcmp(fb->buffer + rules->offset - fb->offset, rules->value.stringv, (size_t)rules->length);
DEBUG_printf(("5mime_check_rules: result=%d", result));
break;
if ((rules->offset + rules->length) > (fb->offset + fb->length))
result = 0;
else
- result = (_cups_strncasecmp((char *)fb->buffer + rules->offset -
- fb->offset,
- rules->value.stringv, rules->length) == 0);
+ result = !_cups_strncasecmp((char *)fb->buffer + rules->offset - fb->offset, rules->value.stringv, (size_t)rules->length);
break;
case MIME_MAGIC_CHAR :
else
{
bufptr = fb->buffer + rules->offset - fb->offset;
- shortv = (bufptr[0] << 8) | bufptr[1];
+ shortv = (short)((bufptr[0] << 8) | bufptr[1]);
result = (shortv == rules->value.shortv);
}
break;
else
{
bufptr = fb->buffer + rules->offset - fb->offset;
- intv = (((((bufptr[0] << 8) | bufptr[1]) << 8) |
- bufptr[2]) << 8) | bufptr[3];
+ intv = (unsigned)((((((bufptr[0] << 8) | bufptr[1]) << 8) | bufptr[2]) << 8) | bufptr[3]);
result = (intv == rules->value.intv);
}
break;
case MIME_MAGIC_LOCALE :
#if defined(WIN32) || defined(__EMX__) || defined(__APPLE__)
- result = (strcmp(rules->value.localev,
- setlocale(LC_ALL, "")) == 0);
+ result = !strcmp(rules->value.localev, setlocale(LC_ALL, ""));
#else
- result = (strcmp(rules->value.localev,
- setlocale(LC_MESSAGES, "")) == 0);
+ result = !strcmp(rules->value.localev, setlocale(LC_MESSAGES, ""));
#endif /* __APPLE__ */
break;
region = fb->length - rules->length;
for (n = 0; n < region; n ++)
- if ((result = (memcmp(fb->buffer + rules->offset - fb->offset + n,
- rules->value.stringv,
- rules->length) == 0)) != 0)
+ if ((result = (memcmp(fb->buffer + rules->offset - fb->offset + n, rules->value.stringv, (size_t)rules->length) == 0)) != 0)
break;
}
break;
/*
* "$Id$"
*
- * Mini-daemon utility functions for CUPS.
+ * Mini-daemon utility functions for CUPS.
*
- * Copyright 2007-2012 by Apple Inc.
- * Copyright 1997-2005 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2005 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
- *
- * Contents:
- *
- * cupsdCompareNames() - Compare two names.
- * cupsdCreateStringsArray() - Create a CUPS array of strings.
- * cupsdExec() - Run a program with the correct environment.
- * cupsdPipeCommand() - Read output from a command.
- * cupsdSendIPPGroup() - Send a group tag.
- * cupsdSendIPPHeader() - Send the IPP response header.
- * cupsdSendIPPInteger() - Send an integer attribute.
- * cupsdSendIPPString() - Send a string attribute.
- * cupsdSendIPPTrailer() - Send the end-of-message tag.
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*/
/*
cupsdPipeCommand(int *pid, /* O - Process ID or 0 on error */
const char *command, /* I - Command to run */
char **argv, /* I - Arguments to pass to command */
- int user) /* I - User to run as or 0 for current */
+ uid_t user) /* I - User to run as or 0 for current */
{
int fd, /* Temporary file descriptor */
fds[2]; /* Pipe file descriptors */
putchar(value_tag);
len = strlen(name);
- putchar(len >> 8);
- putchar(len);
+ putchar((int)(len >> 8));
+ putchar((int)len);
fputs(name, stdout);
putchar(value_tag);
len = strlen(name);
- putchar(len >> 8);
- putchar(len);
+ putchar((int)(len >> 8));
+ putchar((int)len);
fputs(name, stdout);
len = strlen(value);
- putchar(len >> 8);
- putchar(len);
+ putchar((int)(len >> 8));
+ putchar((int)len);
fputs(value, stdout);
}
/*
* "$Id$"
*
- * Mini-daemon utility definitions for CUPS.
+ * Mini-daemon utility definitions for CUPS.
*
- * Copyright 2007-2011 by Apple Inc.
- * Copyright 1997-2005 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2005 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*/
#ifndef _CUPSD_UTIL_H_
extern cups_array_t *cupsdCreateStringsArray(const char *s);
extern int cupsdExec(const char *command, char **argv);
extern cups_file_t *cupsdPipeCommand(int *pid, const char *command,
- char **argv, int user);
+ char **argv, uid_t user);
extern void cupsdSendIPPGroup(ipp_tag_t group_tag);
extern void cupsdSendIPPHeader(ipp_status_t status_code,
int request_id);
char *argv[]) /* I - Command-line arguments */
{
int i, j, k, m, n; /* Looping vars */
- int len; /* Length of option name */
+ size_t len; /* Length of option name */
char *opt; /* Option character */
const char *ptr; /* Pointer into string */
cups_file_t *fp; /* PPD file */
k < group->num_options;
k ++, option ++)
{
- len = (int)strlen(option->keyword);
+ len = strlen(option->keyword);
for (m = 0, group2 = ppd->groups;
m < ppd->num_groups;
n < group2->num_options;
n ++, option2 ++)
if (option != option2 &&
- len < (int)strlen(option2->keyword) &&
+ len < strlen(option2->keyword) &&
!strncmp(option->keyword, option2->keyword, len))
{
_cupsLangPrintf(stdout,
/*
* "$Id$"
*
- * "lp" command for CUPS.
+ * "lp" command for CUPS.
*
- * Copyright 2007-2013 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2007 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
- *
- * Contents:
- *
- * main() - Parse options and send files for printing.
- * restart_job() - Restart a job.
- * set_job_attrs() - Set job attributes.
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*/
/*
while (status == HTTP_CONTINUE &&
(bytes = read(0, buffer, sizeof(buffer))) > 0)
- status = cupsWriteRequestData(CUPS_HTTP_DEFAULT, buffer, bytes);
+ status = cupsWriteRequestData(CUPS_HTTP_DEFAULT, buffer, (size_t)bytes);
if (status != HTTP_CONTINUE)
{
/*
* "$Id$"
*
- * "lpadmin" command for CUPS.
+ * "lpadmin" command for CUPS.
*
- * Copyright 2007-2011 by Apple Inc.
- * Copyright 1997-2006 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2006 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
- *
- * Contents:
- *
- * main() - Parse options and configure the scheduler.
- * add_printer_to_class() - Add a printer to a class.
- * default_printer() - Set the default printing destination.
- * delete_printer() - Delete a printer from the system.
- * delete_printer_from_class() - Delete a printer from a class.
- * delete_printer_option() - Delete a printer option.
- * enable_printer() - Enable a printer.
- * get_printer_type() - Determine the printer type and URI.
- * set_printer_options() - Set the printer options and/or file.
- * validate_name() - Make sure the printer name only contains
- * valid chars.
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*/
/*
* requesting-user-name
*/
- httpAssembleURIf(HTTP_URI_CODING_ALL, uri, urisize, "ipp", NULL, "localhost",
- ippPort(), "/printers/%s", printer);
+ httpAssembleURIf(HTTP_URI_CODING_ALL, uri, (int)urisize, "ipp", NULL, "localhost", ippPort(), "/printers/%s", printer);
request = ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
type = (cups_ptype_t)attr->values[0].integer;
if (type & CUPS_PRINTER_CLASS)
- httpAssembleURIf(HTTP_URI_CODING_ALL, uri, urisize, "ipp", NULL,
- "localhost", ippPort(), "/classes/%s", printer);
+ httpAssembleURIf(HTTP_URI_CODING_ALL, uri, (int)urisize, "ipp", NULL, "localhost", ippPort(), "/classes/%s", printer);
}
else
type = CUPS_PRINTER_LOCAL;
/*
* "$Id$"
*
- * Printer option program for CUPS.
+ * Printer option program for CUPS.
*
- * Copyright 2007-2011 by Apple Inc.
- * Copyright 1997-2006 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2006 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
- *
- * Contents:
- *
- * main() - Main entry.
- * list_group() - List printer-specific options from the PPD group.
- * list_options() - List printer-specific options from the PPD file.
- * usage() - Show program usage and exit.
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*/
/*
num_options --;
if (j < num_options)
- memcpy(options + j, options + j + 1,
- sizeof(cups_option_t) * (num_options - j));
+ memmove(options + j, options + j + 1, sizeof(cups_option_t) * (size_t)(num_options - j));
break;
}
j = dest - dests;
if (j < num_dests)
- memcpy(dest, dest + 1, (num_dests - j) * sizeof(cups_dest_t));
+ memmove(dest, dest + 1, (size_t)(num_dests - j) * sizeof(cups_dest_t));
}
}
*ptr++ = ' ';
if (!options[i].value[0])
- strlcpy(ptr, options[i].name, sizeof(buffer) - (ptr - buffer));
+ strlcpy(ptr, options[i].name, sizeof(buffer) - (size_t)(ptr - buffer));
else if (strchr(options[i].value, ' ') != NULL ||
strchr(options[i].value, '\t') != NULL)
- snprintf(ptr, sizeof(buffer) - (ptr - buffer), "%s=\'%s\'",
- options[i].name, options[i].value);
+ snprintf(ptr, sizeof(buffer) - (size_t)(ptr - buffer), "%s=\'%s\'", options[i].name, options[i].value);
else
- snprintf(ptr, sizeof(buffer) - (ptr - buffer), "%s=%s",
- options[i].name, options[i].value);
+ snprintf(ptr, sizeof(buffer) - (size_t)(ptr - buffer), "%s=%s", options[i].name, options[i].value);
ptr += strlen(ptr);
}
if ((coption = ppdFindCustomOption(ppd, option->keyword)) == NULL ||
cupsArrayCount(coption->params) == 0)
- snprintf(ptr, sizeof(buffer) - (ptr - buffer), " %sCustom",
- choice->marked ? "*" : "");
+ snprintf(ptr, sizeof(buffer) - (size_t)(ptr - buffer), " %sCustom", choice->marked ? "*" : "");
else if (!_cups_strcasecmp(option->keyword, "PageSize") ||
!_cups_strcasecmp(option->keyword, "PageRegion"))
- snprintf(ptr, sizeof(buffer) - (ptr - buffer),
- " %sCustom.WIDTHxHEIGHT", choice->marked ? "*" : "");
+ snprintf(ptr, sizeof(buffer) - (size_t)(ptr - buffer), " %sCustom.WIDTHxHEIGHT", choice->marked ? "*" : "");
else
{
cparam = (ppd_cparam_t *)cupsArrayFirst(coption->params);
if (cupsArrayCount(coption->params) == 1)
- snprintf(ptr, sizeof(buffer) - (ptr - buffer), " %sCustom.%s",
- choice->marked ? "*" : "", types[cparam->type]);
+ snprintf(ptr, sizeof(buffer) - (size_t)(ptr - buffer), " %sCustom.%s", choice->marked ? "*" : "", types[cparam->type]);
else
{
const char *prefix; /* Prefix string */
while (cparam)
{
- snprintf(ptr, sizeof(buffer) - (ptr - buffer), "%s%s=%s", prefix,
- cparam->name, types[cparam->type]);
+ snprintf(ptr, sizeof(buffer) - (size_t)(ptr - buffer), "%s%s=%s", prefix, cparam->name, types[cparam->type]);
cparam = (ppd_cparam_t *)cupsArrayNext(coption->params);
prefix = " ";
ptr += strlen(ptr);
}
if (ptr < (buffer + sizeof(buffer) - 1))
- strlcpy(ptr, "}", sizeof(buffer) - (ptr - buffer));
+ strlcpy(ptr, "}", sizeof(buffer) - (size_t)(ptr - buffer));
}
}
}
else if (choice->marked)
- snprintf(ptr, sizeof(buffer) - (ptr - buffer), " *%s", choice->choice);
+ snprintf(ptr, sizeof(buffer) - (size_t)(ptr - buffer), " *%s", choice->choice);
else
- snprintf(ptr, sizeof(buffer) - (ptr - buffer), " %s", choice->choice);
+ snprintf(ptr, sizeof(buffer) - (size_t)(ptr - buffer), " %s", choice->choice);
ptr += strlen(ptr);
}
*
* "lpstat" command for CUPS.
*
- * Copyright 2007-2013 by Apple Inc.
+ * Copyright 2007-2014 by Apple Inc.
* Copyright 1997-2006 by Easy Software Products.
*
* These coded instructions, statements, and computer programs are the
for (i = 0, aptr = alerts; i < reasons->num_values; i ++)
{
if (i)
- snprintf(aptr, sizeof(alerts) - (aptr - alerts), " %s",
- reasons->values[i].string.text);
+ snprintf(aptr, sizeof(alerts) - (size_t)(aptr - alerts), " %s", reasons->values[i].string.text);
else
- strlcpy(alerts, reasons->values[i].string.text,
- sizeof(alerts));
+ strlcpy(alerts, reasons->values[i].string.text, sizeof(alerts));
aptr += strlen(aptr);
}
jobid = jobattr->values[0].integer;
else if (!strcmp(jobattr->name, "job-state") &&
jobattr->value_tag == IPP_TAG_ENUM)
- jobstate = jobattr->values[0].integer;
+ jobstate = (ipp_jstate_t)jobattr->values[0].integer;
}
if (jobstate != IPP_JOB_PROCESSING)
for (i = 0, aptr = alerts; i < reasons->num_values; i ++)
{
if (i)
- snprintf(aptr, sizeof(alerts) - (aptr - alerts), " %s",
- reasons->values[i].string.text);
+ snprintf(aptr, sizeof(alerts) - (size_t)(aptr - alerts), " %s", reasons->values[i].string.text);
else
- strlcpy(alerts, reasons->values[i].string.text,
- sizeof(alerts));
+ strlcpy(alerts, reasons->values[i].string.text, sizeof(alerts));
aptr += strlen(aptr);
}
for (i = 0, aptr = alerts; i < reasons->num_values; i ++)
{
if (i)
- snprintf(aptr, sizeof(alerts) - (aptr - alerts), " %s",
- reasons->values[i].string.text);
+ snprintf(aptr, sizeof(alerts) - (size_t)(aptr - alerts), " %s", reasons->values[i].string.text);
else
- strlcpy(alerts, reasons->values[i].string.text,
- sizeof(alerts));
+ strlcpy(alerts, reasons->values[i].string.text, sizeof(alerts));
aptr += strlen(aptr);
}
/*
* "$Id$"
*
- * Utility to find IPP printers via Bonjour/DNS-SD and optionally run
- * commands such as IPP and Bonjour conformance tests. This tool is
- * inspired by the UNIX "find" command, thus its name.
+ * Utility to find IPP printers via Bonjour/DNS-SD and optionally run
+ * commands such as IPP and Bonjour conformance tests. This tool is
+ * inspired by the UNIX "find" command, thus its name.
*
- * Copyright 2008-2013 by Apple Inc.
+ * Copyright 2008-2014 by Apple Inc.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * main() - Browse for printers.
- * browse_callback() - Browse devices.
- * browse_local_callback() - Browse local devices.
- * browse_callback() - Browse devices.
- * client_callback() - Avahi client callback function.
- * compare_services() - Compare two devices.
- * dnssd_error_string() - Return an error string for an error code.
- * eval_expr() - Evaluate the expressions against the specified
- * service.
- * exec_program() - Execute a program for a service.
- * get_service() - Create or update a device.
- * get_time() - Get the current time-of-day in seconds.
- * list_service() - List the contents of a service.
- * new_expr() - Create a new expression.
- * poll_callback() - Wait for input on the specified file
- * descriptors.
- * resolve_callback() - Process resolve data.
- * set_service_uri() - Set the URI of the service.
- * show_usage() - Show program usage.
- * show_version() - Show program version.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
"ippfind");
show_usage();
}
- show_usage();
if (!strcmp(argv[i], "1.1"))
ipp_version = 11;
_cupsLangPrintf(stderr, _("%s: Unknown option \"-%c\"."),
"ippfind", *opt);
show_usage();
- break;
}
if (temp)
* Only process "add" data...
*/
+ (void)sdRef;
+ (void)interfaceIndex;
+
if (errorCode != kDNSServiceErr_NoError || !(flags & kDNSServiceFlagsAdd))
return;
* Only process "add" data...
*/
+ (void)sdRef;
+ (void)interfaceIndex;
+
if (errorCode != kDNSServiceErr_NoError || !(flags & kDNSServiceFlagsAdd))
return;
snprintf(txt[i], sizeof(txt[i]), "IPPFIND_TXT_%s=%s", service->txt[i].name,
service->txt[i].value);
for (ptr = txt[i] + 12; *ptr && *ptr != '='; ptr ++)
- *ptr = _cups_toupper(*ptr);
+ *ptr = (char)_cups_toupper(*ptr);
}
for (i = 0, myenvc = 7 + service->num_txt; environ[i]; i ++)
if (strncmp(environ[i], "IPPFIND_", 8))
myenvc ++;
- if ((myenvp = calloc(sizeof(char *), myenvc + 1)) == NULL)
+ if ((myenvp = calloc(sizeof(char *), (size_t)(myenvc + 1))) == NULL)
{
_cupsLangPuts(stderr, _("ippfind: Out of memory."));
exit(IPPFIND_EXIT_MEMORY);
* Allocate and copy command-line arguments...
*/
- if ((myargv = calloc(sizeof(char *), num_args + 1)) == NULL)
+ if ((myargv = calloc(sizeof(char *), (size_t)(num_args + 1))) == NULL)
{
_cupsLangPuts(stderr, _("ippfind: Out of memory."));
exit(IPPFIND_EXIT_MEMORY);
*kptr = '\0';
if (!keyword[0] || !strcmp(keyword, "service_uri"))
- strlcpy(tptr, service->uri, sizeof(temp) - (tptr - temp));
+ strlcpy(tptr, service->uri, sizeof(temp) - (size_t)(tptr - temp));
else if (!strcmp(keyword, "service_domain"))
- strlcpy(tptr, service->domain, sizeof(temp) - (tptr - temp));
+ strlcpy(tptr, service->domain, sizeof(temp) - (size_t)(tptr - temp));
else if (!strcmp(keyword, "service_hostname"))
- strlcpy(tptr, service->host, sizeof(temp) - (tptr - temp));
+ strlcpy(tptr, service->host, sizeof(temp) - (size_t)(tptr - temp));
else if (!strcmp(keyword, "service_name"))
- strlcpy(tptr, service->name, sizeof(temp) - (tptr - temp));
+ strlcpy(tptr, service->name, sizeof(temp) - (size_t)(tptr - temp));
else if (!strcmp(keyword, "service_path"))
- strlcpy(tptr, service->resource, sizeof(temp) - (tptr - temp));
+ strlcpy(tptr, service->resource, sizeof(temp) - (size_t)(tptr - temp));
else if (!strcmp(keyword, "service_port"))
- strlcpy(tptr, port + 20, sizeof(temp) - (tptr - temp));
+ strlcpy(tptr, port + 20, sizeof(temp) - (size_t)(tptr - temp));
else if (!strcmp(keyword, "service_scheme"))
- strlcpy(tptr, scheme + 22, sizeof(temp) - (tptr - temp));
+ strlcpy(tptr, scheme + 22, sizeof(temp) - (size_t)(tptr - temp));
else if (!strncmp(keyword, "txt_", 4))
{
if ((ptr = (char *)cupsGetOption(keyword + 4, service->num_txt,
service->txt)) != NULL)
- strlcpy(tptr, strdup(ptr), sizeof(temp) - (tptr - temp));
+ strlcpy(tptr, strdup(ptr), sizeof(temp) - (size_t)(tptr - temp));
else
*tptr = '\0';
}
if ((attr = ippFindAttribute(response, "printer-state",
IPP_TAG_ENUM)) != NULL)
- pstate = ippGetInteger(attr, 0);
+ pstate = (ipp_pstate_t)ippGetInteger(attr, 0);
else
pstate = IPP_PSTATE_STOPPED;
break;
temp->num_args = num_args;
- temp->args = malloc(num_args * sizeof(char *));
- memcpy(temp->args, args, num_args * sizeof(char *));
+ temp->args = malloc((size_t)num_args * sizeof(char *));
+ memcpy(temp->args, args, (size_t)num_args * sizeof(char *));
}
return (temp);
* Only process "add" data...
*/
- if (errorCode != kDNSServiceErr_NoError)
+ (void)sdRef;
+ (void)flags;
+ (void)interfaceIndex;
+ (void)fullName;
+
+ if (errorCode != kDNSServiceErr_NoError)
{
_cupsLangPrintf(stderr, _("ippfind: Unable to browse or resolve: %s"),
dnssd_error_string(errorCode));
/*
* "$Id$"
*
- * Sample IPP/2.0 server for CUPS.
+ * Sample IPP/2.0 server for CUPS.
*
- * Copyright 2010-2013 by Apple Inc.
+ * Copyright 2010-2014 by Apple Inc.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * main() - Main entry to the sample server.
- * clean_jobs() - Clean out old (completed) jobs.
- * compare_jobs() - Compare two jobs.
- * copy_attributes() - Copy attributes from one request to
- * another.
- * copy_job_attrs() - Copy job attributes to the response.
- * create_client() - Accept a new network connection and create
- * a client object.
- * create_job() - Create a new job object from a Print-Job or
- * Create-Job request.
- * create_listener() - Create a listener socket.
- * create_media_col() - Create a media-col value.
- * create_printer() - Create, register, and listen for
- * connections to a printer object.
- * create_requested_array() - Create an array for requested-attributes.
- * debug_attributes() - Print attributes in a request or response.
- * delete_client() - Close the socket and free all memory used
- * by a client object.
- * delete_job() - Remove from the printer and free all memory
- * used by a job object.
- * delete_printer() - Unregister, close listen sockets, and free
- * all memory used by a printer object.
- * dnssd_callback() - Handle Bonjour registration events.
- * find_job() - Find a job specified in a request.
- * html_escape() - Write a HTML-safe string.
- * html_printf() - Send formatted text to the client, quoting
- * as needed.
- * ipp_cancel_job() - Cancel a job.
- * ipp_create_job() - Create a job object.
- * ipp_get_job_attributes() - Get the attributes for a job object.
- * ipp_get_jobs() - Get a list of job objects.
- * ipp_get_printer_attributes() - Get the attributes for a printer object.
- * ipp_print_job() - Create a job object with an attached
- * document.
- * ipp_print_uri() - Create a job object with a referenced
- * document.
- * ipp_send_document() - Add an attached document to a job object
- * created with Create-Job.
- * ipp_send_uri() - Add a referenced document to a job object
- * created with Create-Job.
- * ipp_validate_job() - Validate job creation attributes.
- * process_client() - Process client requests on a thread.
- * process_http() - Process a HTTP request.
- * process_ipp() - Process an IPP request.
- * process_job() - Process a print job.
- * register_printer() - Register a printer object via Bonjour.
- * respond_http() - Send a HTTP response.
- * respond_ipp() - Send an IPP response.
- * respond_unsupported() - Respond with an unsupported attribute.
- * run_printer() - Run the printer service.
- * usage() - Show program usage.
- * valid_doc_attributes() - Determine whether the document attributes
- * are valid.
- * valid_job_attributes() - Determine whether the job attributes are
- * valid.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
case 'h' : /* -h (show help) */
usage(0);
- break;
case 'i' : /* -i icon.png */
i ++;
default : /* Unknown */
fprintf(stderr, "Unknown option \"-%c\".\n", *opt);
usage(1);
- break;
}
}
else if (!name)
{
case IPP_JSTATE_PENDING :
ippAddString(client->response, IPP_TAG_JOB,
- IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST, "job-state-reasons",
+ IPP_CONST_TAG(IPP_TAG_KEYWORD), "job-state-reasons",
NULL, "none");
break;
case IPP_JSTATE_HELD :
if (job->fd >= 0)
ippAddString(client->response, IPP_TAG_JOB,
- IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST,
+ IPP_CONST_TAG(IPP_TAG_KEYWORD),
"job-state-reasons", NULL, "job-incoming");
else if (ippFindAttribute(job->attrs, "job-hold-until", IPP_TAG_ZERO))
ippAddString(client->response, IPP_TAG_JOB,
- IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST,
+ IPP_CONST_TAG(IPP_TAG_KEYWORD),
"job-state-reasons", NULL, "job-hold-until-specified");
else
ippAddString(client->response, IPP_TAG_JOB,
- IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST,
+ IPP_CONST_TAG(IPP_TAG_KEYWORD),
"job-state-reasons", NULL, "job-data-insufficient");
break;
case IPP_JSTATE_PROCESSING :
if (job->cancel)
ippAddString(client->response, IPP_TAG_JOB,
- IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST,
+ IPP_CONST_TAG(IPP_TAG_KEYWORD),
"job-state-reasons", NULL, "processing-to-stop-point");
else
ippAddString(client->response, IPP_TAG_JOB,
- IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST,
+ IPP_CONST_TAG(IPP_TAG_KEYWORD),
"job-state-reasons", NULL, "job-printing");
break;
case IPP_JSTATE_STOPPED :
ippAddString(client->response, IPP_TAG_JOB,
- IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST, "job-state-reasons",
+ IPP_CONST_TAG(IPP_TAG_KEYWORD), "job-state-reasons",
NULL, "job-stopped");
break;
case IPP_JSTATE_CANCELED :
ippAddString(client->response, IPP_TAG_JOB,
- IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST, "job-state-reasons",
+ IPP_CONST_TAG(IPP_TAG_KEYWORD), "job-state-reasons",
NULL, "job-canceled-by-user");
break;
case IPP_JSTATE_ABORTED :
ippAddString(client->response, IPP_TAG_JOB,
- IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST, "job-state-reasons",
+ IPP_CONST_TAG(IPP_TAG_KEYWORD), "job-state-reasons",
NULL, "aborted-by-system");
break;
case IPP_JSTATE_COMPLETED :
ippAddString(client->response, IPP_TAG_JOB,
- IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST, "job-state-reasons",
+ IPP_CONST_TAG(IPP_TAG_KEYWORD), "job-state-reasons",
NULL, "job-completed-successfully");
break;
}
if (!ra || cupsArrayFind(ra, "time-at-completed"))
ippAddInteger(client->response, IPP_TAG_JOB,
job->completed ? IPP_TAG_INTEGER : IPP_TAG_NOVALUE,
- "time-at-completed", job->completed);
+ "time-at-completed", (int)job->completed);
if (!ra || cupsArrayFind(ra, "time-at-processing"))
ippAddInteger(client->response, IPP_TAG_JOB,
job->processing ? IPP_TAG_INTEGER : IPP_TAG_NOVALUE,
- "time-at-processing", job->processing);
+ "time-at-processing", (int)job->processing);
}
ippSetName(job->attrs, &attr, "job-originating-user-name");
else
attr = ippAddString(job->attrs, IPP_TAG_JOB,
- IPP_TAG_NAME | IPP_TAG_CUPS_CONST,
+ IPP_CONST_TAG(IPP_TAG_NAME),
"job-originating-user-name", NULL, "anonymous");
if (attr)
for (i = 0; i < num_formats; i ++)
{
if (!_cups_strcasecmp(formats[i], "application/pdf"))
- snprintf(ptr, sizeof(device_id) - (ptr - device_id), "%sPDF", prefix);
+ snprintf(ptr, sizeof(device_id) - (size_t)(ptr - device_id), "%sPDF", prefix);
else if (!_cups_strcasecmp(formats[i], "application/postscript"))
- snprintf(ptr, sizeof(device_id) - (ptr - device_id), "%sPS", prefix);
+ snprintf(ptr, sizeof(device_id) - (size_t)(ptr - device_id), "%sPS", prefix);
else if (!_cups_strcasecmp(formats[i], "application/vnd.hp-PCL"))
- snprintf(ptr, sizeof(device_id) - (ptr - device_id), "%sPCL", prefix);
+ snprintf(ptr, sizeof(device_id) - (size_t)(ptr - device_id), "%sPCL", prefix);
else if (!_cups_strcasecmp(formats[i], "image/jpeg"))
- snprintf(ptr, sizeof(device_id) - (ptr - device_id), "%sJPEG", prefix);
+ snprintf(ptr, sizeof(device_id) - (size_t)(ptr - device_id), "%sJPEG", prefix);
else if (!_cups_strcasecmp(formats[i], "image/png"))
- snprintf(ptr, sizeof(device_id) - (ptr - device_id), "%sPNG", prefix);
+ snprintf(ptr, sizeof(device_id) - (size_t)(ptr - device_id), "%sPNG", prefix);
else if (_cups_strcasecmp(formats[i], "application/octet-stream"))
- snprintf(ptr, sizeof(device_id) - (ptr - device_id), "%s%s", prefix,
- formats[i]);
+ snprintf(ptr, sizeof(device_id) - (size_t)(ptr - device_id), "%s%s", prefix, formats[i]);
ptr += strlen(ptr);
prefix = ",";
/* charset-configured */
ippAddString(printer->attrs, IPP_TAG_PRINTER,
- IPP_TAG_CHARSET | IPP_TAG_CUPS_CONST,
+ IPP_CONST_TAG(IPP_TAG_CHARSET),
"charset-configured", NULL, "utf-8");
/* charset-supported */
ippAddStrings(printer->attrs, IPP_TAG_PRINTER,
- IPP_TAG_CHARSET | IPP_TAG_CUPS_CONST,
+ IPP_CONST_TAG(IPP_TAG_CHARSET),
"charset-supported", sizeof(charsets) / sizeof(charsets[0]),
NULL, charsets);
/* compression-supported */
ippAddStrings(printer->attrs, IPP_TAG_PRINTER,
- IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST,
+ IPP_CONST_TAG(IPP_TAG_KEYWORD),
"compression-supported",
(int)(sizeof(compressions) / sizeof(compressions[0])), NULL,
compressions);
/* generated-natural-language-supported */
ippAddString(printer->attrs, IPP_TAG_PRINTER,
- IPP_TAG_LANGUAGE | IPP_TAG_CUPS_CONST,
+ IPP_CONST_TAG(IPP_TAG_LANGUAGE),
"generated-natural-language-supported", NULL, "en");
/* ipp-versions-supported */
ippAddStrings(printer->attrs, IPP_TAG_PRINTER,
- IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST,
+ IPP_CONST_TAG(IPP_TAG_KEYWORD),
"ipp-versions-supported",
sizeof(versions) / sizeof(versions[0]), NULL, versions);
/* job-creation-attributes-supported */
ippAddStrings(printer->attrs, IPP_TAG_PRINTER,
- IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST,
+ IPP_CONST_TAG(IPP_TAG_KEYWORD),
"job-creation-attributes-supported",
sizeof(job_creation) / sizeof(job_creation[0]),
NULL, job_creation);
/* job-sheets-default */
ippAddString(printer->attrs, IPP_TAG_PRINTER,
- IPP_TAG_NAME | IPP_TAG_CUPS_CONST,
+ IPP_CONST_TAG(IPP_TAG_NAME),
"job-sheets-default", NULL, "none");
/* job-sheets-supported */
ippAddString(printer->attrs, IPP_TAG_PRINTER,
- IPP_TAG_NAME | IPP_TAG_CUPS_CONST,
+ IPP_CONST_TAG(IPP_TAG_NAME),
"job-sheets-supported", NULL, "none");
/* media-bottom-margin-supported */
/* media-col-supported */
ippAddStrings(printer->attrs, IPP_TAG_PRINTER,
- IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST,
+ IPP_CONST_TAG(IPP_TAG_KEYWORD),
"media-col-supported",
(int)(sizeof(media_col_supported) /
sizeof(media_col_supported[0])), NULL,
/* media-default */
ippAddString(printer->attrs, IPP_TAG_PRINTER,
- IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST,
+ IPP_CONST_TAG(IPP_TAG_KEYWORD),
"media-default", NULL, media_supported[0]);
/* media-left-margin-supported */
/* media-supported */
ippAddStrings(printer->attrs, IPP_TAG_PRINTER,
- IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST,
+ IPP_CONST_TAG(IPP_TAG_KEYWORD),
"media-supported",
(int)(sizeof(media_supported) / sizeof(media_supported[0])),
NULL, media_supported);
/* media-type-supported */
ippAddStrings(printer->attrs, IPP_TAG_PRINTER,
- IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST,
+ IPP_CONST_TAG(IPP_TAG_KEYWORD),
"media-type-supported",
(int)(sizeof(media_type_supported) /
sizeof(media_type_supported[0])),
/* multiple-document-handling-supported */
ippAddStrings(printer->attrs, IPP_TAG_PRINTER,
- IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST,
+ IPP_CONST_TAG(IPP_TAG_KEYWORD),
"multiple-document-handling-supported",
sizeof(multiple_document_handling) /
sizeof(multiple_document_handling[0]), NULL,
/* natural-language-configured */
ippAddString(printer->attrs, IPP_TAG_PRINTER,
- IPP_TAG_LANGUAGE | IPP_TAG_CUPS_CONST,
+ IPP_CONST_TAG(IPP_TAG_LANGUAGE),
"natural-language-configured", NULL, "en");
/* number-up-default */
/* output-bin-default */
ippAddString(printer->attrs, IPP_TAG_PRINTER,
- IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST,
+ IPP_CONST_TAG(IPP_TAG_KEYWORD),
"output-bin-default", NULL, "face-down");
/* output-bin-supported */
ippAddString(printer->attrs, IPP_TAG_PRINTER,
- IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST,
+ IPP_CONST_TAG(IPP_TAG_KEYWORD),
"output-bin-supported", NULL, "face-down");
/* pages-per-minute */
/* pdl-override-supported */
ippAddString(printer->attrs, IPP_TAG_PRINTER,
- IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST,
+ IPP_CONST_TAG(IPP_TAG_KEYWORD),
"pdl-override-supported", NULL, "attempted");
/* print-quality-default */
/* reference-uri-scheme-supported */
ippAddStrings(printer->attrs, IPP_TAG_PRINTER,
- IPP_TAG_URISCHEME | IPP_TAG_CUPS_CONST,
+ IPP_CONST_TAG(IPP_TAG_URISCHEME),
"reference-uri-schemes-supported",
(int)(sizeof(reference_uri_schemes_supported) /
sizeof(reference_uri_schemes_supported[0])),
/* sides-default */
ippAddString(printer->attrs, IPP_TAG_PRINTER,
- IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST,
+ IPP_CONST_TAG(IPP_TAG_KEYWORD),
"sides-default", NULL, "one-sided");
/* sides-supported */
ippAddStrings(printer->attrs, IPP_TAG_PRINTER,
- IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST,
+ IPP_CONST_TAG(IPP_TAG_KEYWORD),
"sides-supported", duplex ? 3 : 1, NULL, sides_supported);
/* uri-authentication-supported */
ippAddString(printer->attrs, IPP_TAG_PRINTER,
- IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST,
+ IPP_CONST_TAG(IPP_TAG_KEYWORD),
"uri-authentication-supported", NULL, "none");
/* uri-security-supported */
ippAddString(printer->attrs, IPP_TAG_PRINTER,
- IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST,
+ IPP_CONST_TAG(IPP_TAG_KEYWORD),
"uri-security-supported", NULL, "none");
/* which-jobs-supported */
ippAddStrings(printer->attrs, IPP_TAG_PRINTER,
- IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST,
+ IPP_CONST_TAG(IPP_TAG_KEYWORD),
"which-jobs-supported",
sizeof(which_jobs) / sizeof(which_jobs[0]), NULL, which_jobs);
const char *domain, /* I - Domain for service */
_ipp_printer_t *printer) /* I - Printer */
{
+ (void)sdRef;
+ (void)flags;
+ (void)domain;
+
if (errorCode)
{
fprintf(stderr, "DNSServiceRegister for %s failed with error %d.\n",
if (*s == '&' || *s == '<')
{
if (s > start)
- httpWrite2(client->http, start, s - start);
+ httpWrite2(client->http, start, (size_t)(s - start));
if (*s == '&')
httpWrite2(client->http, "&", 5);
}
if (s > start)
- httpWrite2(client->http, start, s - start);
+ httpWrite2(client->http, start, (size_t)(s - start));
}
if (*format == '%')
{
if (format > start)
- httpWrite2(client->http, start, format - start);
+ httpWrite2(client->http, start, (size_t)(format - start));
tptr = tformat;
*tptr++ = *format++;
format ++;
width = va_arg(ap, int);
- snprintf(tptr, sizeof(tformat) - (tptr - tformat), "%d", width);
+ snprintf(tptr, sizeof(tformat) - (size_t)(tptr - tformat), "%d", width);
tptr += strlen(tptr);
}
else
format ++;
prec = va_arg(ap, int);
- snprintf(tptr, sizeof(tformat) - (tptr - tformat), "%d", prec);
+ snprintf(tptr, sizeof(tformat) - (size_t)(tptr - tformat), "%d", prec);
tptr += strlen(tptr);
}
else
case 'e' :
case 'f' :
case 'g' :
- if ((width + 2) > sizeof(temp))
+ if ((size_t)(width + 2) > sizeof(temp))
break;
sprintf(temp, tformat, va_arg(ap, double));
case 'o' :
case 'u' :
case 'x' :
- if ((width + 2) > sizeof(temp))
+ if ((size_t)(width + 2) > sizeof(temp))
break;
# ifdef HAVE_LONG_LONG
break;
case 'p' : /* Pointer value */
- if ((width + 2) > sizeof(temp))
+ if ((size_t)(width + 2) > sizeof(temp))
break;
sprintf(temp, tformat, va_arg(ap, void *));
case 'c' : /* Character or character array */
if (width <= 1)
{
- temp[0] = va_arg(ap, int);
+ temp[0] = (char)va_arg(ap, int);
temp[1] = '\0';
html_escape(client, temp, 1);
}
}
if (format > start)
- httpWrite2(client->http, start, format - start);
+ httpWrite2(client->http, start, (size_t)(format - start));
va_end(ap);
}
{
if (printer->state_reasons == _IPP_PSTATE_NONE)
ippAddString(client->response, IPP_TAG_PRINTER,
- IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST,
+ IPP_CONST_TAG(IPP_TAG_KEYWORD),
"printer-state-reasons", NULL, "none");
else
{
reasons[num_reasons ++] = "toner-low-report";
ippAddStrings(client->response, IPP_TAG_PRINTER,
- IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST,
+ IPP_CONST_TAG(IPP_TAG_KEYWORD),
"printer-state-reasons", num_reasons, NULL, reasons);
}
}
while ((bytes = httpRead2(client->http, buffer, sizeof(buffer))) > 0)
{
- if (write(job->fd, buffer, bytes) < bytes)
+ if (write(job->fd, buffer, (size_t)bytes) < bytes)
{
int error = errno; /* Write error */
if ((bytes = read(infile, buffer, sizeof(buffer))) < 0 &&
(errno == EAGAIN || errno == EINTR))
bytes = 1;
- else if (bytes > 0 && write(job->fd, buffer, bytes) < bytes)
+ else if (bytes > 0 && write(job->fd, buffer, (size_t)bytes) < bytes)
{
int error = errno; /* Write error */
while ((bytes = httpRead2(http, buffer, sizeof(buffer))) > 0)
{
- if (write(job->fd, buffer, bytes) < bytes)
+ if (write(job->fd, buffer, (size_t)bytes) < bytes)
{
int error = errno; /* Write error */
while ((bytes = httpRead2(client->http, buffer, sizeof(buffer))) > 0)
{
- if (write(job->fd, buffer, bytes) < bytes)
+ if (write(job->fd, buffer, (size_t)bytes) < bytes)
{
int error = errno; /* Write error */
if ((bytes = read(infile, buffer, sizeof(buffer))) < 0 &&
(errno == EAGAIN || errno == EINTR))
bytes = 1;
- else if (bytes > 0 && write(job->fd, buffer, bytes) < bytes)
+ else if (bytes > 0 && write(job->fd, buffer, (size_t)bytes) < bytes)
{
int error = errno; /* Write error */
while ((bytes = httpRead2(http, buffer, sizeof(buffer))) > 0)
{
- if (write(job->fd, buffer, bytes) < bytes)
+ if (write(job->fd, buffer, (size_t)bytes) < bytes)
{
int error = errno; /* Write error */
return (respond_http(client, HTTP_STATUS_OK, NULL, "text/html", 0));
else
return (respond_http(client, HTTP_STATUS_NOT_FOUND, NULL, NULL, 0));
- break;
case HTTP_STATE_GET :
if (!strcmp(client->uri, "/icon.png"))
(fd = open(client->printer->icon, O_RDONLY)) >= 0)
{
if (!respond_http(client, HTTP_STATUS_OK, NULL, "image/png",
- fileinfo.st_size))
+ (size_t)fileinfo.st_size))
{
close(fd);
return (0);
}
while ((bytes = read(fd, buffer, sizeof(buffer))) > 0)
- httpWrite2(client->http, buffer, bytes);
+ httpWrite2(client->http, buffer, (size_t)bytes);
httpFlushWrite(client->http);
else
timeout = -1;
- if (poll(polldata, num_fds, timeout) < 0 && errno != EINTR)
+ if (poll(polldata, (nfds_t)num_fds, timeout) < 0 && errno != EINTR)
{
perror("poll() failed");
break;
*
* ipptool command for CUPS.
*
- * Copyright 2007-2013 by Apple Inc.
+ * Copyright 2007-2014 by Apple Inc.
* Copyright 1997-2007 by Easy Software Products.
*
* These coded instructions, statements, and computer programs are the
* Globals...
*/
-_cups_transfer_t Transfer = _CUPS_TRANSFER_AUTO;
+static _cups_transfer_t Transfer = _CUPS_TRANSFER_AUTO;
/* How to transfer requests */
-_cups_output_t Output = _CUPS_OUTPUT_LIST;
+static _cups_output_t Output = _CUPS_OUTPUT_LIST;
/* Output mode */
-int Cancel = 0, /* Cancel test? */
+static int Cancel = 0, /* Cancel test? */
IgnoreErrors = 0, /* Ignore errors? */
StopAfterIncludeError = 0,
/* Stop after include errors? */
PassCount = 0, /* Number of passing tests */
FailCount = 0, /* Number of failing tests */
SkipCount = 0; /* Number of skipped tests */
-char *Password = NULL; /* Password from URI */
-const char * const URIStatusStrings[] = /* URI status strings */
-{
- "URI too large",
- "Bad arguments to function",
- "Bad resource in URI",
- "Bad port number in URI",
- "Bad hostname/address in URI",
- "Bad username in URI",
- "Bad scheme in URI",
- "Bad/empty URI",
- "OK",
- "Missing scheme in URI",
- "Unknown scheme in URI",
- "Missing resource in URI"
-};
+static char *Password = NULL; /* Password from URI */
/*
_cupsLangPrintf(stderr, _("ipptool: Unknown option \"-%c\"."),
*opt);
usage();
- break;
}
}
}
if (uri_status != HTTP_URI_OK)
{
- _cupsLangPrintf(stderr, _("ipptool: Bad URI - %s."),
- URIStatusStrings[uri_status - HTTP_URI_OVERFLOW]);
+ _cupsLangPrintf(stderr, _("ipptool: Bad URI - %s."), httpURIStatusString(uri_status));
return (1);
}
{
while (repeat > 1)
{
- usleep(interval);
+ usleep((useconds_t)interval);
do_tests(&vars, testfile);
repeat --;
}
{
for (;;)
{
- usleep(interval);
+ usleep((useconds_t)interval);
do_tests(&vars, testfile);
}
}
expand_variables(vars, token, temp, sizeof(token));
if ((op = ippOpValue(token)) == (ipp_op_t)-1 &&
- (op = strtol(token, NULL, 0)) == 0)
+ (op = (ipp_op_t)strtol(token, NULL, 0)) == 0)
{
print_fatal_error("Bad OPERATION code \"%s\" on line %d.", token,
linenum);
if (Output == _CUPS_OUTPUT_TEST)
printf(" [%g second delay]\n", delay);
- usleep((int)(1000000.0 * delay));
+ usleep((useconds_t)(1000000.0 * delay));
}
}
else if (!_cups_strcasecmp(token, "ATTR"))
if (!_cups_strcasecmp(token, "true"))
attrptr = ippAddBoolean(request, group, attr, 1);
else
- attrptr = ippAddBoolean(request, group, attr, atoi(token));
+ attrptr = ippAddBoolean(request, group, attr, (char)atoi(token));
break;
case IPP_TAG_INTEGER :
case IPP_TAG_ENUM :
if (!strchr(token, ','))
- attrptr = ippAddInteger(request, group, value, attr,
- strtol(token, &tokenptr, 0));
+ attrptr = ippAddInteger(request, group, value, attr, (int)strtol(token, &tokenptr, 0));
else
{
int values[100], /* Values */
num_values = 1; /* Number of values */
- values[0] = strtol(token, &tokenptr, 10);
+ values[0] = (int)strtol(token, &tokenptr, 10);
while (tokenptr && *tokenptr &&
num_values < (int)(sizeof(values) / sizeof(values[0])))
{
else if (!isdigit(*tokenptr & 255) && *tokenptr != '-')
break;
- values[num_values] = strtol(tokenptr, &tokenptr, 0);
+ values[num_values] = (int)strtol(tokenptr, &tokenptr, 0);
num_values ++;
}
yres; /* Y resolution */
char *ptr; /* Pointer into value */
- xres = yres = strtol(token, (char **)&ptr, 10);
+ xres = yres = (int)strtol(token, (char **)&ptr, 10);
if (ptr > token && xres > 0)
{
if (*ptr == 'x')
- yres = strtol(ptr + 1, (char **)&ptr, 10);
+ yres = (int)strtol(ptr + 1, (char **)&ptr, 10);
}
if (ptr <= token || xres <= 0 || yres <= 0 || !ptr ||
}
if (!_cups_strcasecmp(ptr, "dpi"))
- attrptr = ippAddResolution(request, group, attr, IPP_RES_PER_INCH,
- xres, yres);
+ attrptr = ippAddResolution(request, group, attr, IPP_RES_PER_INCH, xres, yres);
else if (!_cups_strcasecmp(ptr, "dpc") ||
!_cups_strcasecmp(ptr, "dpcm"))
- attrptr = ippAddResolution(request, group, attr, IPP_RES_PER_CM,
- xres, yres);
+ attrptr = ippAddResolution(request, group, attr, IPP_RES_PER_CM, xres, yres);
else
- attrptr = ippAddResolution(request, group, attr, (ipp_res_t)0,
- xres, yres);
+ attrptr = ippAddResolution(request, group, attr, (ipp_res_t)0, xres, yres);
}
break;
break;
case IPP_TAG_STRING :
- attrptr = ippAddOctetString(request, group, attr, token,
- strlen(token));
+ attrptr = ippAddOctetString(request, group, attr, token, (int)strlen(token));
break;
default :
if ((statuses[num_statuses].status = ippErrorValue(token))
== (ipp_status_t)-1 &&
- (statuses[num_statuses].status = strtol(token, NULL, 0)) == 0)
+ (statuses[num_statuses].status = (ipp_status_t)strtol(token, NULL, 0)) == 0)
{
print_fatal_error("Bad STATUS code \"%s\" on line %d.", token,
linenum);
* WITH-VALUE is a POSIX extended regular expression.
*/
- last_expect->with_value = calloc(1, tokenptr - token);
+ last_expect->with_value = calloc(1, (size_t)(tokenptr - token));
last_expect->with_flags |= _CUPS_WITH_REGEX;
if (last_expect->with_value)
TestCount ++;
- request->request.op.version[0] = version / 10;
- request->request.op.version[1] = version % 10;
- request->request.op.operation_id = op;
- request->request.op.request_id = request_id;
+ ippSetVersion(request, version / 10, version % 10);
+ ippSetOperation(request, op);
+ ippSetRequestId(request, request_id);
if (Output == _CUPS_OUTPUT_PLIST)
{
*/
while ((bytes = cupsFileRead(reqfile, buffer, sizeof(buffer))) > 0)
- length += bytes;
+ length += (size_t)bytes;
cupsFileClose(reqfile);
}
if ((reqfile = cupsFileOpen(filename, "r")) != NULL)
{
while (!Cancel &&
- (bytes = cupsFileRead(reqfile, buffer,
- sizeof(buffer))) > 0)
- if ((status = cupsWriteRequestData(http, buffer,
- bytes)) != HTTP_CONTINUE)
+ (bytes = cupsFileRead(reqfile, buffer, sizeof(buffer))) > 0)
+ if ((status = cupsWriteRequestData(http, buffer, (size_t)bytes)) != HTTP_CONTINUE)
break;
cupsFileClose(reqfile);
fflush(stdout);
}
- sleep(repeat_interval);
+ sleep((unsigned)repeat_interval);
repeat_interval = _cupsNextDelay(repeat_interval, &repeat_prev);
if (Output == _CUPS_OUTPUT_TEST)
if (!_cups_strcasecmp(token, "true"))
ippAddBoolean(col, IPP_TAG_ZERO, attr, 1);
else
- ippAddBoolean(col, IPP_TAG_ZERO, attr, atoi(token));
+ ippAddBoolean(col, IPP_TAG_ZERO, attr, (char)atoi(token));
break;
case IPP_TAG_INTEGER :
}
if (!_cups_strcasecmp(units, "dpi"))
- ippAddResolution(col, IPP_TAG_ZERO, attr, xres, yres,
- IPP_RES_PER_INCH);
+ ippAddResolution(col, IPP_TAG_ZERO, attr, IPP_RES_PER_INCH, xres, yres);
else if (!_cups_strcasecmp(units, "dpc") ||
!_cups_strcasecmp(units, "dpcm"))
- ippAddResolution(col, IPP_TAG_ZERO, attr, xres, yres,
- IPP_RES_PER_CM);
+ ippAddResolution(col, IPP_TAG_ZERO, attr, IPP_RES_PER_CM, xres, yres);
else
- ippAddResolution(col, IPP_TAG_ZERO, attr, xres, yres,
- (ipp_res_t)0);
+ ippAddResolution(col, IPP_TAG_ZERO, attr, (ipp_res_t)0, xres, yres);
}
break;
}
break;
case IPP_TAG_STRING :
- ippAddOctetString(col, IPP_TAG_ZERO, attr, token, strlen(token));
+ ippAddOctetString(col, IPP_TAG_ZERO, attr, token, (int)strlen(token));
break;
default :
else
dstptr = dst; /* Should never happen */
- strlcpy(dstptr, src, dstsize - (dstptr - dst));
+ strlcpy(dstptr, src, dstsize - (size_t)(dstptr - dst));
}
return (dst);
if (flags & _CUPS_WITH_HOSTNAME)
{
- if (httpSeparateURI(HTTP_URI_CODING_ALL, ptr, scheme, sizeof(scheme),
- userpass, sizeof(userpass), buffer, bufsize, &port,
- resource, sizeof(resource)) < HTTP_URI_STATUS_OK)
- return ("");
- else
- return (buffer);
+ if (httpSeparateURI(HTTP_URI_CODING_ALL, ptr, scheme, sizeof(scheme), userpass, sizeof(userpass), buffer, (int)bufsize, &port, resource, sizeof(resource)) < HTTP_URI_STATUS_OK)
+ buffer[0] = '\0';
+
+ return (buffer);
}
else if (flags & _CUPS_WITH_RESOURCE)
{
- if (httpSeparateURI(HTTP_URI_CODING_ALL, ptr, scheme, sizeof(scheme),
- userpass, sizeof(userpass), hostname, sizeof(hostname),
- &port, buffer, bufsize) < HTTP_URI_STATUS_OK)
- return ("");
- else
- return (buffer);
+ if (httpSeparateURI(HTTP_URI_CODING_ALL, ptr, scheme, sizeof(scheme), userpass, sizeof(userpass), hostname, sizeof(hostname), &port, buffer, (int)bufsize) < HTTP_URI_STATUS_OK)
+ buffer[0] = '\0';
+
+ return (buffer);
}
else if (flags & _CUPS_WITH_SCHEME)
{
- if (httpSeparateURI(HTTP_URI_CODING_ALL, ptr, buffer, bufsize,
- userpass, sizeof(userpass), hostname, sizeof(hostname),
- &port, resource, sizeof(resource)) < HTTP_URI_STATUS_OK)
- return ("");
- else
- return (buffer);
+ if (httpSeparateURI(HTTP_URI_CODING_ALL, ptr, buffer, (int)bufsize, userpass, sizeof(userpass), hostname, sizeof(hostname), &port, resource, sizeof(resource)) < HTTP_URI_STATUS_OK)
+ buffer[0] = '\0';
+
+ return (buffer);
}
else
return (ptr);
*/
if (bufptr < bufend)
- *bufptr++ = ch;
+ *bufptr++ = (char)ch;
if ((ch = getc(fp)) != EOF && bufptr < bufend)
- *bufptr++ = ch;
+ *bufptr++ = (char)ch;
}
else if (ch == quote)
break;
else if (bufptr < bufend)
- *bufptr++ = ch;
+ *bufptr++ = (char)ch;
}
*bufptr = '\0';
if (isspace(ch) || ch == '#')
break;
else if (bufptr < bufend)
- *bufptr++ = ch;
+ *bufptr++ = (char)ch;
if (ch == '#')
ungetc(ch, fp);
"\"%s\": Bad URI value \"%s\" - %s "
"(RFC 2911 section 4.1.5).", attr->name,
attr->values[i].string.text,
- URIStatusStrings[uri_status -
- HTTP_URI_OVERFLOW]);
+ httpURIStatusString(uri_status));
}
if (strlen(attr->values[i].string.text) > (IPP_MAX_URI - 1))
if (!*valptr)
break;
- intvalue = strtol(valptr, &nextptr, 0);
+ intvalue = (int)strtol(valptr, &nextptr, 0);
if (nextptr == valptr)
break;
valptr = nextptr;
(op == '>' && attr->values[i].integer > intvalue))
{
if (!matchbuf[0])
- snprintf(matchbuf, matchlen, "%d",
- attr->values[i].integer);
+ snprintf(matchbuf, matchlen, "%d", attr->values[i].integer);
valmatch = 1;
break;
if (!*valptr)
break;
- intvalue = strtol(valptr, &nextptr, 0);
+ intvalue = (int)strtol(valptr, &nextptr, 0);
if (nextptr == valptr)
break;
valptr = nextptr;
return(ret);
enlarge(p, p->ssize + len); /* this many unexpected additions */
assert(p->ssize >= p->slen + len);
- (void) memcpy((char *)(p->strip + p->slen),
+ (void) memmove((char *)(p->strip + p->slen),
(char *)(p->strip + start), (size_t)len*sizeof(sop));
p->slen += len;
return(ret);
728FB7F11536167A005426E1 /* libiconv.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 728FB7EF1536167A005426E1 /* libiconv.dylib */; };
728FB7F21536167A005426E1 /* libresolv.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 728FB7F01536167A005426E1 /* libresolv.dylib */; };
72C16CB9137B195D007E4BF4 /* file.c in Sources */ = {isa = PBXBuildFile; fileRef = 72C16CB8137B195D007E4BF4 /* file.c */; };
+ 72CF95E318A13543000FCAE4 /* dest-job.c in Sources */ = {isa = PBXBuildFile; fileRef = 72CF95E018A13543000FCAE4 /* dest-job.c */; };
+ 72CF95E418A13543000FCAE4 /* dest-localization.c in Sources */ = {isa = PBXBuildFile; fileRef = 72CF95E118A13543000FCAE4 /* dest-localization.c */; };
+ 72CF95E518A13543000FCAE4 /* dest-options.c in Sources */ = {isa = PBXBuildFile; fileRef = 72CF95E218A13543000FCAE4 /* dest-options.c */; };
+ 72CF95EC18A19134000FCAE4 /* libcups.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 72220EAE1333047D00FCA411 /* libcups.dylib */; };
+ 72CF95F318A19165000FCAE4 /* ippfind.c in Sources */ = {isa = PBXBuildFile; fileRef = 72CF95F218A19165000FCAE4 /* ippfind.c */; };
72D53A2A15B49110003F877F /* GSS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 72D53A2915B49110003F877F /* GSS.framework */; };
72D53A2D15B4913D003F877F /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 72D53A2C15B4913D003F877F /* IOKit.framework */; };
72D53A2E15B4915B003F877F /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 278C58E8136B64B000836530 /* SystemConfiguration.framework */; };
remoteGlobalIDString = 274FF6891333B1C400317ECB;
remoteInfo = libcups_static;
};
+ 72CF95E818A19134000FCAE4 /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = 72BF96371333042100B1EAD7 /* Project object */;
+ proxyType = 1;
+ remoteGlobalIDString = 72220EAD1333047D00FCA411;
+ remoteInfo = libcups;
+ };
72F75A651336FA30004BB496 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 72BF96371333042100B1EAD7 /* Project object */;
);
runOnlyForDeploymentPostprocessing = 1;
};
+ 72CF95ED18A19134000FCAE4 /* CopyFiles */ = {
+ isa = PBXCopyFilesBuildPhase;
+ buildActionMask = 2147483647;
+ dstPath = /usr/share/man/man1/;
+ dstSubfolderSpec = 0;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 1;
+ };
72F75A501336F950004BB496 /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
728FB7F01536167A005426E1 /* libresolv.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libresolv.dylib; path = /usr/lib/libresolv.dylib; sourceTree = "<absolute>"; };
72A4332F155844CF002E172D /* libcups_static.a */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libcups_static.a; sourceTree = BUILT_PRODUCTS_DIR; };
72C16CB8137B195D007E4BF4 /* file.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = file.c; path = ../scheduler/file.c; sourceTree = SOURCE_ROOT; };
+ 72CF95E018A13543000FCAE4 /* dest-job.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = "dest-job.c"; path = "../cups/dest-job.c"; sourceTree = "<group>"; };
+ 72CF95E118A13543000FCAE4 /* dest-localization.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = "dest-localization.c"; path = "../cups/dest-localization.c"; sourceTree = "<group>"; };
+ 72CF95E218A13543000FCAE4 /* dest-options.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = "dest-options.c"; path = "../cups/dest-options.c"; sourceTree = "<group>"; };
+ 72CF95F118A19134000FCAE4 /* ipptool copy */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "ipptool copy"; sourceTree = BUILT_PRODUCTS_DIR; };
+ 72CF95F218A19165000FCAE4 /* ippfind.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = ippfind.c; path = ../test/ippfind.c; sourceTree = "<group>"; };
72D53A2915B49110003F877F /* GSS.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GSS.framework; path = /System/Library/Frameworks/GSS.framework; sourceTree = "<absolute>"; };
72D53A2C15B4913D003F877F /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = /System/Library/Frameworks/IOKit.framework; sourceTree = "<absolute>"; };
72D53A3315B4925B003F877F /* ApplicationServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ApplicationServices.framework; path = /System/Library/Frameworks/ApplicationServices.framework; sourceTree = "<absolute>"; };
);
runOnlyForDeploymentPostprocessing = 0;
};
+ 72CF95EB18A19134000FCAE4 /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 72CF95EC18A19134000FCAE4 /* libcups.dylib in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
72F75A4F1336F950004BB496 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
274FF68713333B6E00317ECB /* cupsfilter.c */,
2732E08B137A3F5200FAFEF6 /* cupstestdsc.c */,
72F75A5B1336F988004BB496 /* cupstestppd.c */,
+ 72CF95F218A19165000FCAE4 /* ippfind.c */,
726AD701135E8A90002C930D /* ippserver.c */,
276683F91337F7A9000D33D0 /* ipptool.c */,
2732E08C137A3F5200FAFEF6 /* lp.c */,
726AD6F7135E88F0002C930D /* ippserver */,
278C58CB136B640300836530 /* testhttp */,
72A4332F155844CF002E172D /* libcups_static.a */,
+ 72CF95F118A19134000FCAE4 /* ipptool copy */,
);
name = Products;
sourceTree = "<group>";
72220EC21333056300FCA411 /* custom.c */,
72220ED1133305BB00FCA411 /* debug.c */,
72220ED2133305BB00FCA411 /* dest.c */,
+ 72CF95E018A13543000FCAE4 /* dest-job.c */,
+ 72CF95E118A13543000FCAE4 /* dest-localization.c */,
+ 72CF95E218A13543000FCAE4 /* dest-options.c */,
72220ED3133305BB00FCA411 /* dir.c */,
72220ED4133305BB00FCA411 /* dir.h */,
72220ED5133305BB00FCA411 /* emit.c */,
72220EDE133305BB00FCA411 /* http-addr.c */,
72220EDF133305BB00FCA411 /* http-addrlist.c */,
72220EE1133305BB00FCA411 /* http-support.c */,
- 72220EE5133305BB00FCA411 /* ipp-support.c */,
72220EE6133305BB00FCA411 /* ipp.c */,
+ 72220EE5133305BB00FCA411 /* ipp-support.c */,
72220EE8133305BB00FCA411 /* langprintf.c */,
72220EEA133305BB00FCA411 /* language.c */,
72220EEC133305BB00FCA411 /* localize.c */,
productReference = 726AD6F7135E88F0002C930D /* ippserver */;
productType = "com.apple.product-type.tool";
};
+ 72CF95E618A19134000FCAE4 /* ippfind */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 72CF95EE18A19134000FCAE4 /* Build configuration list for PBXNativeTarget "ippfind" */;
+ buildPhases = (
+ 72CF95E918A19134000FCAE4 /* Sources */,
+ 72CF95EB18A19134000FCAE4 /* Frameworks */,
+ 72CF95ED18A19134000FCAE4 /* CopyFiles */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ 72CF95E718A19134000FCAE4 /* PBXTargetDependency */,
+ );
+ name = ippfind;
+ productName = ipptool;
+ productReference = 72CF95F118A19134000FCAE4 /* ipptool copy */;
+ productType = "com.apple.product-type.tool";
+ };
72F75A511336F950004BB496 /* cupstestppd */ = {
isa = PBXNativeTarget;
buildConfigurationList = 72F75A581336F951004BB496 /* Build configuration list for PBXNativeTarget "cupstestppd" */;
72F75A511336F950004BB496 /* cupstestppd */,
724379461333FEA9009631B9 /* dnssd */,
724378FC1333E43E009631B9 /* ipp */,
+ 72CF95E618A19134000FCAE4 /* ippfind */,
726AD6F6135E88F0002C930D /* ippserver */,
276683EF1337F78E000D33D0 /* ipptool */,
724379171333E532009631B9 /* lpd */,
72220F19133305BB00FCA411 /* http-addrlist.c in Sources */,
72220F1B133305BB00FCA411 /* http-support.c in Sources */,
72220F1C133305BB00FCA411 /* http.c in Sources */,
+ 72CF95E518A13543000FCAE4 /* dest-options.c in Sources */,
72220F1F133305BB00FCA411 /* ipp-support.c in Sources */,
72220F20133305BB00FCA411 /* ipp.c in Sources */,
72220F22133305BB00FCA411 /* langprintf.c in Sources */,
72220F3A133305BB00FCA411 /* snprintf.c in Sources */,
72220F3C133305BB00FCA411 /* string.c in Sources */,
72220F3D133305BB00FCA411 /* tempfile.c in Sources */,
+ 72CF95E418A13543000FCAE4 /* dest-localization.c in Sources */,
72220F3F133305BB00FCA411 /* thread.c in Sources */,
72220F40133305BB00FCA411 /* transcode.c in Sources */,
72220F42133305BB00FCA411 /* usersys.c in Sources */,
72220F43133305BB00FCA411 /* util.c in Sources */,
+ 72CF95E318A13543000FCAE4 /* dest-job.c in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
);
runOnlyForDeploymentPostprocessing = 0;
};
+ 72CF95E918A19134000FCAE4 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 72CF95F318A19165000FCAE4 /* ippfind.c in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
72F75A4E1336F950004BB496 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
target = 274FF6891333B1C400317ECB /* libcups_static */;
targetProxy = 726AD705135E8AC5002C930D /* PBXContainerItemProxy */;
};
+ 72CF95E718A19134000FCAE4 /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ target = 72220EAD1333047D00FCA411 /* libcups */;
+ targetProxy = 72CF95E818A19134000FCAE4 /* PBXContainerItemProxy */;
+ };
72F75A661336FA30004BB496 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 72220EAD1333047D00FCA411 /* libcups */;
72BF963C1333042100B1EAD7 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES;
+ CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
GCC_PREPROCESSOR_DEFINITIONS = DEBUG;
+ GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES;
+ GCC_TREAT_WARNINGS_AS_ERRORS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_SHADOW = YES;
+ GCC_WARN_SIGN_COMPARE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_LABEL = YES;
72BF963D1333042100B1EAD7 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES;
+ CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+ GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES;
+ GCC_TREAT_WARNINGS_AS_ERRORS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_SHADOW = YES;
+ GCC_WARN_SIGN_COMPARE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_LABEL = YES;
};
name = Release;
};
+ 72CF95EF18A19134000FCAE4 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ INSTALL_PATH = /usr/bin;
+ PRODUCT_NAME = "ipptool copy";
+ };
+ name = Debug;
+ };
+ 72CF95F018A19134000FCAE4 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ INSTALL_PATH = /usr/bin;
+ PRODUCT_NAME = "ipptool copy";
+ };
+ name = Release;
+ };
72F75A591336F951004BB496 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
+ 72CF95EE18A19134000FCAE4 /* Build configuration list for PBXNativeTarget "ippfind" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 72CF95EF18A19134000FCAE4 /* Debug */,
+ 72CF95F018A19134000FCAE4 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
72F75A581336F951004BB496 /* Build configuration list for PBXNativeTarget "cupstestppd" */ = {
isa = XCConfigurationList;
buildConfigurations = (