Full sweep of all Clang warnings, plus some bug fixes for incorrect memcpy usage.

git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@11558 a1ca3aef-8c08-0410-bb20-df032aa958be
Esse commit está contido em:
msweet
2014-02-06 18:33:34 +00:00
commit 7e86f2f686
144 arquivos alterados com 2848 adições e 4848 exclusões
+10 -10
Ver Arquivo
@@ -1,18 +1,18 @@
/*
* "$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_
@@ -313,7 +313,7 @@ extern int backendGetDeviceID(int fd, char *device_id,
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);
+15 -33
Ver Arquivo
@@ -1,33 +1,17 @@
/*
* "$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.
*/
/*
@@ -138,7 +122,7 @@ static void client_callback(AvahiClient *client,
#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,
@@ -837,8 +821,8 @@ exec_backend(char **argv) /* I - Command-line arguments */
* '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"))
@@ -1115,7 +1099,7 @@ query_callback(
datanext = data + datalen;
for (ptr = key; data < datanext && *data != '='; data ++)
*ptr++ = *data;
*ptr++ = (char)*data;
*ptr = '\0';
if (data < datanext && *data == '=')
@@ -1143,8 +1127,7 @@ query_callback(
*/
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") ||
@@ -1250,7 +1233,7 @@ query_callback(
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;
}
@@ -1259,8 +1242,7 @@ query_callback(
}
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])
+11 -19
Ver Arquivo
@@ -1,24 +1,18 @@
/*
* "$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.
*/
/*
@@ -372,7 +366,7 @@ int /* O - 0 on success, -1 on failure */
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 */
@@ -381,9 +375,7 @@ backendGetMakeModel(
*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...
+42 -58
Ver Arquivo
@@ -3,7 +3,7 @@
*
* 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
@@ -79,7 +79,7 @@ typedef struct _cups_monitor_s /**** Monitoring data ****/
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 */
{
@@ -785,7 +785,7 @@ main(int argc, /* I - Number of command-line args */
break;
}
sleep(delay);
sleep((unsigned)delay);
delay = _cupsNextDelay(delay, &prev_delay);
}
@@ -831,15 +831,16 @@ main(int argc, /* I - Number of command-line args */
*/
#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
{
@@ -854,9 +855,7 @@ main(int argc, /* I - Number of command-line args */
*/
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);
@@ -905,7 +904,7 @@ main(int argc, /* I - Number of command-line args */
report_printer_state(supported);
sleep(delay);
sleep((unsigned)delay);
delay = _cupsNextDelay(delay, &prev_delay);
}
@@ -1019,7 +1018,7 @@ main(int argc, /* I - Number of command-line args */
report_printer_state(supported);
sleep(delay);
sleep((unsigned)delay);
delay = _cupsNextDelay(delay, &prev_delay);
@@ -1308,7 +1307,7 @@ main(int argc, /* I - Number of command-line args */
_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);
@@ -1506,7 +1505,7 @@ main(int argc, /* I - Number of command-line args */
else
{
fd = 0;
http_status = cupsWriteRequestData(http, buffer, bytes);
http_status = cupsWriteRequestData(http, buffer, (size_t)bytes);
}
while (http_status == HTTP_CONTINUE &&
@@ -1532,7 +1531,7 @@ main(int argc, /* I - Number of command-line args */
{
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;
}
@@ -1668,8 +1667,7 @@ main(int argc, /* I - Number of command-line args */
*/
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);
@@ -1702,7 +1700,7 @@ main(int argc, /* I - Number of command-line args */
if (num_files == 0)
{
fd = 0;
http_status = cupsWriteRequestData(http, buffer, bytes);
http_status = cupsWriteRequestData(http, buffer, (size_t)bytes);
}
else
{
@@ -1721,7 +1719,7 @@ main(int argc, /* I - Number of command-line args */
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
@@ -1880,8 +1878,7 @@ main(int argc, /* I - Number of command-line args */
*/
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);
@@ -2006,7 +2003,7 @@ main(int argc, /* I - Number of command-line args */
* Wait before polling again...
*/
sleep(delay);
sleep((unsigned)delay);
delay = _cupsNextDelay(delay, &prev_delay);
}
@@ -2140,8 +2137,7 @@ cancel_job(http_t *http, /* I - HTTP connection */
_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);
@@ -2186,8 +2182,7 @@ check_printer_state(
*/
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);
@@ -2290,8 +2285,7 @@ monitor_printer(
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);
@@ -2353,7 +2347,7 @@ monitor_printer(
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))
@@ -2440,7 +2434,7 @@ monitor_printer(
* Sleep for N seconds...
*/
sleep(delay);
sleep((unsigned)delay);
delay = _cupsNextDelay(delay, &prev_delay);
}
@@ -2507,9 +2501,8 @@ new_request(
* 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),
@@ -2576,8 +2569,7 @@ new_request(
(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)
@@ -2656,8 +2648,7 @@ new_request(
}
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"))
@@ -3078,16 +3069,14 @@ report_attr(ipp_attribute_t *attr) /* I - Attribute */
{
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;
@@ -3338,12 +3327,12 @@ run_as_user(char *argv[], /* I - Command-line arguments */
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",
@@ -3389,7 +3378,7 @@ run_as_user(char *argv[], /* I - Command-line arguments */
if (response)
{
status = xpc_dictionary_get_int64(response, "status");
status = (int)xpc_dictionary_get_int64(response, "status");
if (status == SIGTERM || status == SIGKILL || status == SIGPIPE)
{
@@ -3588,8 +3577,7 @@ update_reasons(ipp_attribute_t *attr, /* I - printer-state-reasons or NULL */
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 = ",";
@@ -3602,8 +3590,7 @@ update_reasons(ipp_attribute_t *attr, /* I - printer-state-reasons or NULL */
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 = ",";
}
@@ -3621,8 +3608,7 @@ update_reasons(ipp_attribute_t *attr, /* I - printer-state-reasons or NULL */
{
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 = ",";
@@ -3642,8 +3628,7 @@ update_reasons(ipp_attribute_t *attr, /* I - printer-state-reasons or NULL */
{
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 = ",";
@@ -3659,8 +3644,7 @@ update_reasons(ipp_attribute_t *attr, /* I - printer-state-reasons or NULL */
{
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 = ",";
}
+30 -30
Ver Arquivo
@@ -84,7 +84,7 @@ static int lpd_queue(const char *hostname, http_addrlist_t *addrlist,
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 */
@@ -472,7 +472,7 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
_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);
@@ -583,7 +583,7 @@ lpd_command(int fd, /* I - Socket connection to LPD host */
{
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 */
@@ -608,9 +608,9 @@ lpd_command(int fd, /* I - Socket connection to LPD host */
* 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);
@@ -625,7 +625,7 @@ lpd_command(int fd, /* I - Socket connection to LPD host */
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);
@@ -671,7 +671,7 @@ lpd_queue(const char *hostname, /* I - Host to connect to */
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
@@ -773,7 +773,7 @@ lpd_queue(const char *hostname, /* I - Host to connect to */
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;
@@ -837,7 +837,7 @@ lpd_queue(const char *hostname, /* I - Host to connect to */
break;
}
sleep(delay);
sleep((unsigned)delay);
if (delay < 30)
delay += 5;
@@ -958,7 +958,7 @@ lpd_queue(const char *hostname, /* I - Host to connect to */
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);
@@ -967,13 +967,13 @@ lpd_queue(const char *hostname, /* I - Host to connect to */
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);
@@ -1003,9 +1003,9 @@ lpd_queue(const char *hostname, /* I - Host to connect to */
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");
}
@@ -1015,7 +1015,7 @@ lpd_queue(const char *hostname, /* I - Host to connect to */
{
_cupsLangPrintFilter(stderr, "WARNING",
_("The printer did not respond."));
status = errno;
status = (char)errno;
}
}
@@ -1065,7 +1065,7 @@ lpd_queue(const char *hostname, /* I - Host to connect to */
_("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;
@@ -1078,11 +1078,11 @@ lpd_queue(const char *hostname, /* I - Host to connect to */
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
{
@@ -1136,9 +1136,9 @@ lpd_queue(const char *hostname, /* I - Host to connect to */
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
@@ -1147,7 +1147,7 @@ lpd_queue(const char *hostname, /* I - Host to connect to */
{
_cupsLangPrintFilter(stderr, "WARNING",
_("The printer did not respond."));
status = errno;
status = (char)errno;
}
}
@@ -1197,32 +1197,32 @@ lpd_queue(const char *hostname, /* I - Host to connect to */
* '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);
}
+22 -31
Ver Arquivo
@@ -3,7 +3,7 @@
*
* 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
@@ -91,7 +91,7 @@ backendNetworkSideCB(
case CUPS_SC_CMD_GET_BIDI :
status = CUPS_SC_STATUS_OK;
data[0] = use_bc;
data[0] = (char)use_bc;
datalen = 1;
break;
@@ -130,13 +130,13 @@ backendNetworkSideCB(
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;
}
@@ -159,7 +159,7 @@ backendNetworkSideCB(
{
if (_cupsSNMPRead(snmp_fd, &packet, 1.0))
{
int i; /* Looping var */
size_t i; /* Looping var */
if (!_cupsSNMPOIDToString(packet.object_name, data, sizeof(data)))
@@ -174,26 +174,22 @@ backendNetworkSideCB(
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);
@@ -202,8 +198,8 @@ backendNetworkSideCB(
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 :
@@ -211,32 +207,27 @@ backendNetworkSideCB(
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';
+4 -4
Ver Arquivo
@@ -3,7 +3,7 @@
*
* 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
@@ -102,7 +102,7 @@ backendDrainOutput(int print_fd, /* I - Print file descriptor */
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...
@@ -282,7 +282,7 @@ backendRunLoop(
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)
{
@@ -339,7 +339,7 @@ backendRunLoop(
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...
+21 -28
Ver Arquivo
@@ -1,24 +1,17 @@
/*
* "$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.
*/
/*
@@ -329,9 +322,9 @@ backendSNMPSupplies(
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);
@@ -585,7 +578,7 @@ backend_init_supplies(
{
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;
@@ -680,7 +673,7 @@ backend_init_supplies(
if (num_supplies > 0)
cupsFileWrite(cachefile, (char *)supplies,
num_supplies * sizeof(backend_supplies_t));
(size_t)num_supplies * sizeof(backend_supplies_t));
cupsFileClose(cachefile);
}
@@ -708,7 +701,7 @@ backend_init_supplies(
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);
@@ -756,9 +749,9 @@ backend_init_supplies(
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);
@@ -1062,9 +1055,9 @@ utf16_to_utf8(
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;
@@ -1075,13 +1068,13 @@ utf16_to_utf8(
* 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)
{
@@ -1098,7 +1091,7 @@ utf16_to_utf8(
*ptr = '\0';
cupsUTF32ToUTF8(dst, temp, dstsize);
cupsUTF32ToUTF8(dst, temp, (int)dstsize);
}
+11 -37
Ver Arquivo
@@ -1,44 +1,18 @@
/*
* "$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.
*/
/*
@@ -753,7 +727,7 @@ probe_device(snmp_cache_t *device) /* I - Device */
* 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;
}
@@ -1346,7 +1320,7 @@ try_connect(http_addr_t *addr, /* I - Socket address */
alarm(1);
status = connect(fd, (void *)addr, httpAddrLength(addr));
status = connect(fd, (void *)addr, (socklen_t)httpAddrLength(addr));
close(fd);
alarm(0);
+6 -6
Ver Arquivo
@@ -3,7 +3,7 @@
*
* 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
@@ -41,7 +41,7 @@
* Local functions...
*/
static int wait_bc(int device_fd, int secs);
static ssize_t wait_bc(int device_fd, int secs);
/*
@@ -380,7 +380,7 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
break;
}
sleep(delay);
sleep((unsigned)delay);
if (delay < 30)
delay += 5;
@@ -410,7 +410,7 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
tbytes = 0;
if (bytes > 0)
tbytes += write(device_fd, buffer, bytes);
tbytes += write(device_fd, buffer, (size_t)bytes);
while (copies > 0 && tbytes >= 0)
{
@@ -476,7 +476,7 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
* '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 */
{
@@ -506,7 +506,7 @@ wait_bc(int device_fd, /* I - Socket */
{
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);
+17 -21
Ver Arquivo
@@ -1,25 +1,18 @@
/*
* "$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.
*/
/*
@@ -97,7 +90,7 @@ main(int argc, /* I - Number of command-line args */
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__
@@ -311,7 +304,7 @@ main(int argc, /* I - Number of command-line args */
*/
if ((bytes = cupsBackChannelRead(buffer, sizeof(buffer), 0)) > 0)
write(2, buffer, bytes);
write(2, buffer, (size_t)bytes);
/*
* Throttle output to ~100hz...
@@ -339,7 +332,7 @@ main(int argc, /* I - Number of command-line args */
*/
while ((bytes = cupsBackChannelRead(buffer, sizeof(buffer), 5.0)) > 0)
write(2, buffer, bytes);
write(2, buffer, (size_t)bytes);
exit(0);
}
@@ -414,7 +407,7 @@ main(int argc, /* I - Number of command-line args */
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);
@@ -668,7 +661,10 @@ walk_cb(const char *oid, /* I - OID */
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';
+13 -12
Ver Arquivo
@@ -1,7 +1,7 @@
/*
* "$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
@@ -283,10 +283,10 @@ static void status_timer_cb(CFRunLoopTimerRef timer, void *info);
#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);
@@ -680,7 +680,7 @@ print_device(const char *uri, /* I - Device URI */
if (g.print_bytes)
{
bytes = g.print_bytes;
bytes = (UInt32)g.print_bytes;
iostatus = (*g.classdriver)->WritePipe(g.classdriver, (UInt8*)print_ptr, &bytes, 0);
/*
@@ -702,7 +702,7 @@ print_device(const char *uri, /* I - Device URI */
{
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);
}
@@ -722,7 +722,7 @@ print_device(const char *uri, /* I - Device URI */
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);
}
@@ -1010,7 +1010,7 @@ sidechannel_thread(void *reference)
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,
@@ -1026,7 +1026,7 @@ sidechannel_thread(void *reference)
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';
@@ -1229,7 +1229,7 @@ static Boolean find_device_cb(void *refcon,
if (obj != 0x0)
{
CFStringRef idString = NULL;
UInt32 location = -1;
UInt32 location = ~0U;
UInt8 interfaceNum = 0;
copy_devicestring(obj, &idString, &location, &interfaceNum);
@@ -1869,7 +1869,7 @@ static void parse_options(char *options,
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);
}
}
@@ -1932,6 +1932,7 @@ static void run_legacy_backend(int argc,
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
@@ -2015,7 +2016,7 @@ static void run_legacy_backend(int argc,
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;
@@ -2303,7 +2304,7 @@ static void get_device_id(cups_sc_status_t *status,
if (deviceIDString)
{
CFStringGetCString(deviceIDString, data, *datalen, kCFStringEncodingUTF8);
*datalen = strlen(data);
*datalen = (int)strlen(data);
CFRelease(deviceIDString);
}
*status = CUPS_SC_STATUS_OK;
+11 -19
Ver Arquivo
@@ -1,24 +1,16 @@
/*
* "$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/".
*/
/*
@@ -32,7 +24,7 @@
* 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 *);
@@ -158,9 +150,9 @@ main(int argc, /* I - Number of command-line arguments */
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);
+2 -7
Ver Arquivo
@@ -3,7 +3,7 @@
*
* "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
@@ -17,10 +17,6 @@
* Include necessary headers...
*/
/*
* Include necessary headers...
*/
#include <cups/cups-private.h>
@@ -187,7 +183,6 @@ main(int argc, /* I - Number of command-line arguments */
httpClose(http);
usage();
break;
}
}
else if (isdigit(argv[i][0] & 255))
@@ -255,7 +250,7 @@ main(int argc, /* I - Number of command-line arguments */
if (i && interval)
{
fflush(stdout);
sleep(interval);
sleep((unsigned)interval);
}
else
break;
+9 -13
Ver Arquivo
@@ -1,20 +1,16 @@
/*
* "$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/".
*/
/*
@@ -406,7 +402,7 @@ main(int argc, /* I - Number of command-line arguments */
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)
{
+2 -14
Ver Arquivo
@@ -3,7 +3,7 @@
#
# 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
@@ -42,8 +42,7 @@ CGIS = \
printers.cgi
LIBTARGETS = \
libcupscgi.a \
$(LIBCUPSCGI) \
websearch
$(LIBCUPSCGI)
UNITTARGETS = \
testcgi \
@@ -347,17 +346,6 @@ testtemplate: testtemplate.o ../Makedefs libcupscgi.a ../cups/$(LIBCUPSSTATIC)
$(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...
#
+22 -42
Ver Arquivo
@@ -1,37 +1,16 @@
/*
* "$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/".
*/
/*
@@ -89,8 +68,7 @@ static double get_points(double number, const char *uval);
*/
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 */
@@ -1172,7 +1150,7 @@ do_am_printer(http_t *http, /* I - HTTP connection */
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 */
@@ -1194,7 +1172,7 @@ do_am_printer(http_t *http, /* I - HTTP connection */
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);
@@ -1211,8 +1189,10 @@ do_am_printer(http_t *http, /* I - HTTP connection */
}
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
@@ -1380,7 +1360,7 @@ do_am_printer(http_t *http, /* I - HTTP connection */
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"));
@@ -1881,7 +1861,7 @@ do_config_server(http_t *http) /* I - HTTP connection */
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')
@@ -2006,9 +1986,9 @@ do_config_server(http_t *http) /* I - HTTP connection */
* 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);
}
@@ -2025,7 +2005,7 @@ do_config_server(http_t *http) /* I - HTTP connection */
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;
@@ -2035,7 +2015,7 @@ do_config_server(http_t *http) /* I - HTTP connection */
if (ch == '\\' || ch == '\"')
{
*bufptr++ = '\\';
*bufptr++ = ch;
*bufptr++ = (char)ch;
}
else if (ch == '\n')
{
@@ -2048,7 +2028,7 @@ do_config_server(http_t *http) /* I - HTTP connection */
*bufptr++ = 't';
}
else if (ch >= ' ')
*bufptr++ = ch;
*bufptr++ = (char)ch;
}
*bufptr = '\0';
@@ -3882,7 +3862,7 @@ do_set_sharing(http_t *http) /* I - HTTP connection */
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...
+9 -17
Ver Arquivo
@@ -1,23 +1,16 @@
/*
* "$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/".
*/
/*
@@ -42,8 +35,7 @@ static void show_class(http_t *http, const char *printer);
*/
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 */
+13 -31
Ver Arquivo
@@ -1,34 +1,16 @@
/*
* "$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/".
*/
/*
@@ -346,7 +328,7 @@ helpLoadIndex(const char *hifile, /* I - Index filename */
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 ++;
@@ -1019,14 +1001,14 @@ help_load_file(
*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)
{
@@ -1179,7 +1161,7 @@ help_load_file(
for (text = ptr, ptr ++; *ptr && isalnum(*ptr & 255); ptr ++);
wordlen = ptr - text;
wordlen = (int)(ptr - text);
memcpy(temp, text, wordlen);
temp[wordlen] = '\0';
@@ -1206,7 +1188,7 @@ help_load_file(
cupsFileClose(fp);
if (node)
node->length = offset - node->offset;
node->length = (size_t)(offset - node->offset);
return (0);
}
+22 -37
Ver Arquivo
@@ -1,31 +1,16 @@
/*
* "$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/".
*/
/*
@@ -65,7 +50,7 @@ cgiGetAttributes(ipp_t *request, /* I - IPP request */
{
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] = '_';
@@ -107,7 +92,7 @@ cgiGetAttributes(ipp_t *request, /* I - IPP request */
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...
@@ -123,7 +108,7 @@ cgiGetAttributes(ipp_t *request, /* I - IPP request */
if (ch == '_')
*nameptr++ = '-';
else
*nameptr++ = ch;
*nameptr++ = (char)ch;
}
*nameptr = '\0';
@@ -1039,7 +1024,7 @@ cgiSetIPPObjectVars(
*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);
@@ -1177,7 +1162,7 @@ cgiSetIPPObjectVars(
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);
@@ -1192,30 +1177,30 @@ cgiSetIPPObjectVars(
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 ?
@@ -1238,13 +1223,13 @@ cgiSetIPPObjectVars(
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;
}
@@ -1256,7 +1241,7 @@ cgiSetIPPObjectVars(
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 :
+9 -15
Ver Arquivo
@@ -1,21 +1,16 @@
/*
* "$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/".
*/
/*
@@ -37,8 +32,7 @@ static void do_job_op(http_t *http, int job_id, ipp_op_t op);
*/
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 */
+9 -17
Ver Arquivo
@@ -1,23 +1,16 @@
/*
* "$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/".
*/
/*
@@ -43,8 +36,7 @@ static void show_printer(http_t *http, const char *printer);
*/
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 */
+12 -18
Ver Arquivo
@@ -1,22 +1,16 @@
/*
* "$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/".
*/
/*
@@ -38,12 +32,12 @@ cgiCompileSearch(const char *query) /* I - Query string */
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 */
@@ -139,7 +133,7 @@ cgiCompileSearch(const char *query) /* I - Query string */
for (qend = qptr + 1; *qend && !isspace(*qend); qend ++);
}
wlen = qend - qptr;
wlen = (size_t)(qend - qptr);
/*
* Look for logic words: AND, OR
@@ -174,7 +168,7 @@ cgiCompileSearch(const char *query) /* I - Query string */
* 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);
+17 -28
Ver Arquivo
@@ -1,27 +1,16 @@
/*
* "$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"
@@ -266,7 +255,7 @@ cgi_copy(FILE *out, /* I - Output file */
else if (s > name && ch == '?')
break;
else if (s < (name + sizeof(name) - 1))
*s++ = ch;
*s++ = (char)ch;
*s = '\0';
@@ -443,7 +432,7 @@ cgi_copy(FILE *out, /* I - Output file */
* {name~refex?true:false} Regex match
*/
op = ch;
op = (char)ch;
if (ch == '?')
{
@@ -486,7 +475,7 @@ cgi_copy(FILE *out, /* I - Output file */
innerptr = innername;
while ((ch = getc(in)) != EOF && ch != '}')
if (innerptr < (innername + sizeof(innername) - 1))
*innerptr++ = ch;
*innerptr++ = (char)ch;
*innerptr = '\0';
if (innername[0] == '#')
@@ -498,26 +487,26 @@ cgi_copy(FILE *out, /* I - Output file */
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';
+9 -15
Ver Arquivo
@@ -1,21 +1,16 @@
/*
* "$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/".
*/
/*
@@ -30,8 +25,7 @@
*/
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...
+36 -65
Ver Arquivo
@@ -1,49 +1,20 @@
/*
* "$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*/
@@ -417,7 +388,7 @@ cgiSetArray(const char *name, /* I - Name of variable */
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;
@@ -495,7 +466,7 @@ cgiSetSize(const char *name, /* I - Name of variable */
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;
@@ -581,7 +552,7 @@ cgi_add_variable(const char *name, /* I - Variable name */
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;
@@ -592,7 +563,7 @@ cgi_add_variable(const char *name, /* I - Variable name */
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);
@@ -632,7 +603,7 @@ cgi_find_variable(const char *name) /* I - Name of variable */
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));
}
@@ -769,8 +740,8 @@ cgi_initialize_multipart(
*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));
@@ -835,15 +806,15 @@ cgi_initialize_multipart(
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...
@@ -860,7 +831,7 @@ cgi_initialize_multipart(
*/
if (ptr > line)
write(fd, line, ptr - line);
write(fd, line, (size_t)(ptr - line));
close(fd);
}
@@ -877,9 +848,9 @@ cgi_initialize_multipart(
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;
@@ -979,12 +950,12 @@ cgi_initialize_multipart(
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...");
@@ -1001,7 +972,7 @@ cgi_initialize_post(void)
* 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)
@@ -1011,8 +982,8 @@ cgi_initialize_post(void)
* 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)
{
@@ -1126,7 +1097,7 @@ cgi_initialize_string(const char *data) /* I - Form data string */
ch = *data - '0';
if (ch > 9)
ch -= 7;
*s = ch << 4;
*s = (char)(ch << 4);
data ++;
ch = *data - '0';
@@ -1264,7 +1235,7 @@ cgi_sort_variables(void)
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
-116
Ver Arquivo
@@ -1,116 +0,0 @@
/*
* "$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$".
*/
+11 -11
Ver Arquivo
@@ -154,20 +154,20 @@ if test -n "$GCC"; then
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
+10 -21
Ver Arquivo
@@ -1,29 +1,18 @@
/*
* "$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.
*/
/*
@@ -319,7 +308,7 @@ cupsAdminCreateWindowsPPD(
}
}
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",
+27 -60
Ver Arquivo
@@ -1,50 +1,18 @@
/*
* "$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.
*/
/*
@@ -423,7 +391,7 @@ cupsArrayDup(cups_array_t *a) /* I - Array */
* 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);
@@ -451,7 +419,7 @@ cupsArrayDup(cups_array_t *a) /* I - Array */
* 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;
@@ -794,7 +762,7 @@ cupsArrayNew3(cups_array_func_t f, /* I - Comparison function or @code NULL@ fo
{
a->hashfunc = h;
a->hashsize = hsize;
a->hash = malloc(hsize * sizeof(int));
a->hash = malloc((size_t)hsize * sizeof(int));
if (!a->hash)
{
@@ -802,7 +770,7 @@ cupsArrayNew3(cups_array_func_t f, /* I - Comparison function or @code NULL@ fo
return (NULL);
}
memset(a->hash, -1, hsize * sizeof(int));
memset(a->hash, -1, (size_t)hsize * sizeof(int));
}
a->copyfunc = cf;
@@ -918,9 +886,9 @@ int /* O - 1 on success, 0 on failure */
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 */
/*
@@ -952,7 +920,7 @@ cupsArrayRemove(cups_array_t *a, /* I - Array */
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 --;
@@ -1053,9 +1021,9 @@ cups_array_add(cups_array_t *a, /* I - Array */
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));
@@ -1079,7 +1047,7 @@ cups_array_add(cups_array_t *a, /* I - Array */
if (a->alloc_elements == 0)
{
count = 16;
temp = malloc(count * sizeof(void *));
temp = malloc((size_t)count * sizeof(void *));
}
else
{
@@ -1088,10 +1056,10 @@ cups_array_add(cups_array_t *a, /* I - Array */
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)
{
@@ -1181,7 +1149,7 @@ cups_array_add(cups_array_t *a, /* I - Array */
*/
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 ++;
@@ -1190,11 +1158,11 @@ cups_array_add(cups_array_t *a, /* I - Array */
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)
@@ -1213,8 +1181,7 @@ cups_array_add(cups_array_t *a, /* I - Array */
#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");
+16 -27
Ver Arquivo
@@ -1,32 +1,21 @@
/*
* "$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.
*/
/*
@@ -453,13 +442,13 @@ _cupsSetNegotiateAuthString(
* 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);
@@ -467,7 +456,7 @@ _cupsSetNegotiateAuthString(
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);
}
+10 -16
Ver Arquivo
@@ -1,24 +1,18 @@
/*
* "$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.
*/
/*
@@ -169,7 +163,7 @@ cupsBackChannelWrite(
*/
buffer += count;
total += count;
total += (size_t)count;
}
}
+12 -26
Ver Arquivo
@@ -1,34 +1,20 @@
/*
* "$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.
*/
/*
@@ -193,7 +179,7 @@ cupsResolveConflicts(
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 */
@@ -886,7 +872,7 @@ ppd_load_constraints(ppd_file_t *ppd) /* I - PPD file */
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 "
+23 -30
Ver Arquivo
@@ -1,24 +1,17 @@
/*
* "$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.
*/
/*
@@ -92,7 +85,7 @@ debug_thread_id(void)
* '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 */
@@ -108,7 +101,7 @@ debug_vsnprintf(char *buffer, /* O - Output buffer */
*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)
@@ -149,7 +142,7 @@ debug_vsnprintf(char *buffer, /* O - Output buffer */
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
@@ -181,7 +174,7 @@ debug_vsnprintf(char *buffer, /* O - Output buffer */
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
@@ -236,7 +229,7 @@ debug_vsnprintf(char *buffer, /* O - Output buffer */
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));
@@ -258,7 +251,7 @@ debug_vsnprintf(char *buffer, /* O - Output buffer */
case 'o' :
case 'u' :
case 'x' :
if ((width + 2) > sizeof(temp))
if ((size_t)(width + 2) > sizeof(temp))
break;
# ifdef HAVE_LONG_LONG
@@ -281,7 +274,7 @@ debug_vsnprintf(char *buffer, /* O - Output buffer */
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 *));
@@ -301,7 +294,7 @@ debug_vsnprintf(char *buffer, /* O - Output buffer */
if (bufptr)
{
if (width <= 1)
*bufptr++ = va_arg(ap, int);
*bufptr++ = (char)va_arg(ap, int);
else
{
if ((bufptr + width) > bufend)
@@ -382,7 +375,7 @@ debug_vsnprintf(char *buffer, /* O - Output buffer */
break;
case 'n' : /* Output number of chars so far */
*(va_arg(ap, int *)) = bytes;
*(va_arg(ap, int *)) = (int)bytes;
break;
}
}
@@ -418,7 +411,7 @@ _cups_debug_printf(const char *format, /* I - Printf-style format string */
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 */
@@ -471,7 +464,7 @@ _cups_debug_printf(const char *format, /* I - Printf-style format string */
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;
@@ -487,7 +480,7 @@ _cups_debug_printf(const char *format, /* I - Printf-style format string */
*/
_cupsMutexLock(&debug_log_mutex);
write(_cups_debug_fd, buffer, bytes);
write(_cups_debug_fd, buffer, (size_t)bytes);
_cupsMutexUnlock(&debug_log_mutex);
}
@@ -501,7 +494,7 @@ _cups_debug_puts(const char *s) /* I - String to output */
{
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 */
@@ -551,7 +544,7 @@ _cups_debug_puts(const char *s) /* I - String to output */
(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;
@@ -567,7 +560,7 @@ _cups_debug_puts(const char *s) /* I - String to output */
*/
_cupsMutexLock(&debug_log_mutex);
write(_cups_debug_fd, buffer, bytes);
write(_cups_debug_fd, buffer, (size_t)bytes);
_cupsMutexUnlock(&debug_log_mutex);
}
+15 -17
Ver Arquivo
@@ -1,25 +1,17 @@
/*
* "$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.
*/
/*
@@ -45,6 +37,12 @@ cupsCancelDestJob(http_t *http, /* I - Connection to destination */
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);
}
@@ -344,7 +342,7 @@ cupsStartDestDocument(
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);
+9 -21
Ver Arquivo
@@ -1,28 +1,17 @@
/*
* "$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.
*/
/*
@@ -356,8 +345,7 @@ cups_scan_strings(char *buffer) /* I - Start of string */
* 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
+12 -52
Ver Arquivo
@@ -1,55 +1,17 @@
/*
* "$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.
*/
/*
@@ -328,7 +290,7 @@ cupsCopyDestConflicts(
*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 */
@@ -669,7 +631,7 @@ cupsCopyDestInfo(
version = 11;
else if (status == IPP_STATUS_ERROR_BUSY)
{
sleep(delay);
sleep((unsigned)delay);
delay = _cupsNextDelay(delay, &prev_delay);
}
@@ -1166,7 +1128,7 @@ cupsGetDestMediaDefault(
* Fall back to the first matching media size...
*/
return (cupsGetDestMediaByIndex(http, dest, dinfo, flags, 0, size));
return (cupsGetDestMediaByIndex(http, dest, dinfo, 0, flags, size));
}
@@ -2246,9 +2208,7 @@ cups_update_ready(http_t *http, /* I - Connection to destination */
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);
+24 -95
Ver Arquivo
@@ -1,85 +1,18 @@
/*
* "$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.
*/
/*
@@ -334,7 +267,7 @@ cupsAddDest(const char *name, /* I - Destination name */
* 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)
{
@@ -672,7 +605,7 @@ cupsConnectDest(
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);
@@ -842,8 +775,7 @@ cupsCopyDest(cups_dest_t *dest,
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;
@@ -1330,7 +1262,7 @@ _cupsGetDestResource(
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);
@@ -1457,10 +1389,8 @@ _cupsGetDests(http_t *http, /* I - Connection to server or
}
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);
}
/*
@@ -1705,10 +1635,10 @@ cupsGetDests2(http_t *http, /* I - Connection to server or @code CUPS_HTTP_
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;
}
@@ -1979,10 +1909,10 @@ cupsRemoveDest(const char *name, /* I - Destination name */
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);
}
@@ -2316,7 +2246,7 @@ _cupsUserDefault(char *name, /* I - Name buffer */
if ((locprinter = _cupsAppleCopyDefaultPrinter()) != NULL)
{
CFStringGetCString(locprinter, name, namesize, kCFStringEncodingUTF8);
CFStringGetCString(locprinter, name, (CFIndex)namesize, kCFStringEncodingUTF8);
CFRelease(locprinter);
}
else
@@ -2524,7 +2454,7 @@ cups_add_dest(const char *name, /* I - Name of destination */
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);
@@ -2551,8 +2481,7 @@ cups_add_dest(const char *name, /* I - Name of destination */
*/
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) ++;
@@ -3157,7 +3086,7 @@ cups_dnssd_query_cb(
txtnext = txt + txtlen;
for (ptr = key; txt < txtnext && *txt != '='; txt ++)
*ptr++ = *txt;
*ptr++ = (char)*txt;
*ptr = '\0';
if (txt < txtnext && *txt == '=')
@@ -3242,7 +3171,7 @@ cups_dnssd_query_cb(
*/
saw_printer_type = 1;
type = strtol(value, NULL, 0);
type = (cups_ptype_t)strtol(value, NULL, 0);
}
else if (!saw_printer_type)
{
+13 -30
Ver Arquivo
@@ -1,37 +1,20 @@
/*
* "$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.
*/
/*
@@ -121,13 +104,13 @@ ppdCollect2(ppd_file_t *ppd, /* I - PPD file data */
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);
@@ -358,7 +341,7 @@ ppdEmitFd(ppd_file_t *ppd, /* I - PPD file record */
break;
}
buflength -= bytes;
buflength -= (size_t)bytes;
bufptr += bytes;
}
+14 -22
Ver Arquivo
@@ -1,26 +1,18 @@
/*
* "$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.
*/
/*
@@ -674,7 +666,7 @@ cupsEncodeOptions2(
* 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));
@@ -716,12 +708,12 @@ cupsEncodeOptions2(
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;
}
@@ -738,10 +730,10 @@ cupsEncodeOptions2(
* 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;
+50 -51
Ver Arquivo
@@ -8,7 +8,7 @@
* 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
@@ -286,7 +286,6 @@ _cupsFileCheckFilter(
switch (result)
{
default :
case _CUPS_FILE_CHECK_OK :
prefix = "DEBUG2";
break;
@@ -370,7 +369,7 @@ cupsFileClose(cups_file_t *fp) /* I - CUPS file */
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;
@@ -388,14 +387,14 @@ cupsFileClose(cups_file_t *fp) /* I - CUPS file */
* 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;
@@ -609,10 +608,10 @@ cupsFileFlush(cups_file_t *fp) /* I - CUPS file */
{
#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);
@@ -883,7 +882,7 @@ cupsFileGetLine(cups_file_t *fp, /* I - File to read from */
DEBUG_printf(("4cupsFileGetLine: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos));
return (ptr - buf);
return ((size_t)(ptr - buf));
}
@@ -958,7 +957,7 @@ cupsFileGets(cups_file_t *fp, /* I - CUPS file */
break;
}
else
*ptr++ = ch;
*ptr++ = (char)ch;
}
*ptr = '\0';
@@ -1213,10 +1212,10 @@ cupsFileOpenFd(int fd, /* I - File descriptor */
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;
@@ -1341,11 +1340,11 @@ cupsFilePrintf(cups_file_t *fp, /* I - CUPS file */
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);
@@ -1354,14 +1353,14 @@ cupsFilePrintf(cups_file_t *fp, /* I - CUPS file */
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)
@@ -1372,20 +1371,20 @@ cupsFilePrintf(cups_file_t *fp, /* I - CUPS file */
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);
}
}
@@ -1416,7 +1415,7 @@ cupsFilePutChar(cups_file_t *fp, /* I - CUPS file */
char ch; /* Output character */
ch = c;
ch = (char)c;
if (send(fp->fd, &ch, 1, 0) < 1)
return (-1);
@@ -1431,7 +1430,7 @@ cupsFilePutChar(cups_file_t *fp, /* I - CUPS file */
if (cupsFileFlush(fp))
return (-1);
*(fp->ptr) ++ = c;
*(fp->ptr) ++ = (char)c;
}
fp->pos ++;
@@ -1478,7 +1477,7 @@ cupsFilePutConf(cups_file_t *fp, /* I - CUPS file */
* 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;
@@ -1529,18 +1528,18 @@ cupsFilePuts(cups_file_t *fp, /* I - CUPS file */
* 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)
@@ -1551,20 +1550,20 @@ cupsFilePuts(cups_file_t *fp, /* I - CUPS file */
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);
}
}
@@ -1630,8 +1629,8 @@ cupsFileRead(cups_file_t *fp, /* I - CUPS file */
* Update the counts for the last read...
*/
bytes -= count;
total += count;
bytes -= (size_t)count;
total += (size_t)count;
buf += count;
}
@@ -2103,14 +2102,14 @@ cups_compress(cups_file_t *fp, /* I - CUPS file */
* 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)
{
@@ -2121,9 +2120,9 @@ cups_compress(cups_file_t *fp, /* I - CUPS file */
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;
@@ -2133,7 +2132,7 @@ cups_compress(cups_file_t *fp, /* I - CUPS file */
deflate(&(fp->stream), Z_NO_FLUSH);
}
return (bytes);
return ((ssize_t)bytes);
}
#endif /* HAVE_LIBZ */
@@ -2324,7 +2323,7 @@ cups_fill(cups_file_t *fp) /* I - CUPS file */
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);
@@ -2353,7 +2352,7 @@ cups_fill(cups_file_t *fp) /* I - CUPS file */
return (-1);
fp->stream.next_in = fp->cbuf;
fp->stream.avail_in = bytes;
fp->stream.avail_in = (uInt)bytes;
}
/*
@@ -2367,7 +2366,7 @@ cups_fill(cups_file_t *fp) /* I - CUPS file */
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)
{
@@ -2379,7 +2378,7 @@ cups_fill(cups_file_t *fp) /* I - CUPS file */
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...
@@ -2415,7 +2414,7 @@ cups_fill(cups_file_t *fp) /* I - CUPS 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...
@@ -2656,8 +2655,8 @@ cups_write(cups_file_t *fp, /* I - CUPS file */
* Update the counts for the last write call...
*/
bytes -= count;
total += count;
bytes -= (size_t)count;
total += (size_t)count;
buf += count;
}
+14 -21
Ver Arquivo
@@ -1,25 +1,18 @@
/*
* "$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.
*/
/*
@@ -49,7 +42,7 @@ cupsGetFd(http_t *http, /* I - Connection to server or @code CUPS_HTTP_DEFA
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];
@@ -174,7 +167,7 @@ cupsGetFd(http_t *http, /* I - Connection to server or @code CUPS_HTTP_DEFA
*/
while ((bytes = httpRead2(http, buffer, sizeof(buffer))) > 0)
write(fd, buffer, bytes);
write(fd, buffer, (size_t)bytes);
}
else
{
@@ -273,8 +266,8 @@ cupsPutFd(http_t *http, /* I - Connection to server or @code CUPS_HTTP_DEFA
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 */
@@ -362,7 +355,7 @@ cupsPutFd(http_t *http, /* I - Connection to server or @code CUPS_HTTP_DEFA
break;
}
else
httpWrite2(http, buffer, bytes);
httpWrite2(http, buffer, (size_t)bytes);
}
if (status == HTTP_STATUS_CONTINUE)
+8 -11
Ver Arquivo
@@ -3,7 +3,7 @@
*
* 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
@@ -137,8 +137,7 @@ httpAddrLength(const http_addr_t *addr) /* I - Address */
#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)
@@ -216,7 +215,7 @@ httpAddrListen(http_addr_t *addr, /* I - Address to bind to */
* 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...
@@ -230,7 +229,7 @@ httpAddrListen(http_addr_t *addr, /* I - Address to bind to */
{
_httpAddrSetPort(addr, port);
status = bind(fd, (struct sockaddr *)addr, httpAddrLength(addr));
status = bind(fd, (struct sockaddr *)addr, (socklen_t)httpAddrLength(addr));
}
if (status)
@@ -388,8 +387,7 @@ httpAddrLookup(
* 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)
{
@@ -544,8 +542,7 @@ httpAddrString(const http_addr_t *addr, /* I - Address to convert */
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
@@ -720,7 +717,7 @@ httpGetHostByName(const char *name) /* I - Hostname or IP address */
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;
@@ -820,7 +817,7 @@ httpGetHostname(http_t *http, /* I - HTTP connection or 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, '.'))
+2 -3
Ver Arquivo
@@ -3,7 +3,7 @@
*
* 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
@@ -178,8 +178,7 @@ httpAddrConnect2(
* 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)),
+87 -28
Ver Arquivo
@@ -3,7 +3,7 @@
*
* 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
@@ -472,7 +472,7 @@ httpAssembleURIf(
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);
@@ -520,7 +520,7 @@ httpAssembleUUID(const char *server, /* I - Server name */
(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);
/*
@@ -576,10 +576,10 @@ httpDecode64_2(char *out, /* I - String to write to */
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 */
/*
@@ -608,11 +608,11 @@ httpDecode64_2(char *out, /* I - String to write to */
*/
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 == '/')
@@ -630,21 +630,21 @@ httpDecode64_2(char *out, /* I - String to write to */
{
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 :
@@ -1234,7 +1234,7 @@ httpSeparateURI(
return (HTTP_URI_STATUS_BAD_PORT);
}
*port = strtol(uri + 1, (char **)&uri, 10);
*port = (int)strtol(uri + 1, (char **)&uri, 10);
if (*uri != '/' && *uri)
{
@@ -1433,6 +1433,70 @@ httpStatus(http_status_t status) /* I - HTTP status code */
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
/*
@@ -1559,7 +1623,7 @@ _httpResolveURI(
# 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
@@ -1638,7 +1702,7 @@ _httpResolveURI(
# ifdef HAVE_DNSSD
if (DNSServiceCreateConnection(&ref) == kDNSServiceErr_NoError)
{
int myinterface = kDNSServiceInterfaceIndexAny;
uint32_t myinterface = kDNSServiceInterfaceIndexAny;
/* Lookup on any interface */
if (!strcmp(scheme, "ippusb"))
@@ -1678,7 +1742,7 @@ _httpResolveURI(
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);
@@ -1943,7 +2007,7 @@ http_copy_decode(char *dst, /* O - Destination buffer */
else
quoted |= *src - '0';
*ptr++ = quoted;
*ptr++ = (char)quoted;
}
else
{
@@ -2171,9 +2235,7 @@ http_resolve_cb(
{
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)
{
@@ -2204,12 +2266,9 @@ http_resolve_cb(
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));
}
+65 -73
Ver Arquivo
@@ -3,7 +3,7 @@
*
* 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
@@ -705,11 +705,11 @@ httpFlush(http_t *http) /* I - HTTP connection */
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)
{
@@ -719,15 +719,15 @@ httpFlushWrite(http_t *http) /* I - HTTP connection */
}
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);
}
@@ -1123,7 +1123,7 @@ httpGetLength2(http_t *http) /* I - HTTP connection */
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);
}
@@ -1139,7 +1139,7 @@ httpGetReady(http_t *http) /* I - HTTP connection */
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));
@@ -1162,7 +1162,7 @@ httpGetReady(http_t *http) /* I - HTTP connection */
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);
}
@@ -1175,12 +1175,12 @@ httpGets(char *line, /* I - Line to read into */
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));
@@ -1229,10 +1229,9 @@ httpGets(char *line, /* I - Line to read into */
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)
{
@@ -1292,7 +1291,7 @@ httpGets(char *line, /* I - Line to read into */
* Yup, update the amount used...
*/
http->used += bytes;
http->used += (int)bytes;
}
/*
@@ -1757,13 +1756,13 @@ httpPeek(http_t *http, /* I - HTTP connection */
}
}
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));
@@ -1773,7 +1772,7 @@ httpPeek(http_t *http, /* I - HTTP connection */
http_debug_hex("httpPeek", http->buffer, (int)bytes);
#endif /* DEBUG */
http->used = bytes;
http->used = (int)bytes;
}
}
@@ -1795,11 +1794,11 @@ httpPeek(http_t *http, /* I - HTTP connection */
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));
@@ -1824,7 +1823,7 @@ httpPeek(http_t *http, /* I - HTTP connection */
}
stream.next_out = (Bytef *)buffer;
stream.avail_out = length;
stream.avail_out = (uInt)length;
zerr = inflate(&stream, Z_SYNC_FLUSH);
inflateEnd(&stream);
@@ -1833,15 +1832,14 @@ httpPeek(http_t *http, /* I - HTTP connection */
{
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 "
@@ -1913,7 +1911,7 @@ httpPrintf(http_t *http, /* I - HTTP connection */
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 */
@@ -1924,10 +1922,10 @@ httpPrintf(http_t *http, /* I - HTTP connection */
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)
@@ -1938,7 +1936,7 @@ httpPrintf(http_t *http, /* I - HTTP connection */
return (-1);
}
return (http_write(http, buf, bytes));
return ((int)http_write(http, buf, (size_t)bytes));
}
}
@@ -1970,7 +1968,7 @@ httpRead(http_t *http, /* I - HTTP connection */
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));
}
@@ -2023,21 +2021,20 @@ httpRead2(http_t *http, /* I - HTTP connection */
(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,
@@ -2048,7 +2045,7 @@ httpRead2(http_t *http, /* I - HTTP connection */
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)
@@ -2065,16 +2062,12 @@ httpRead2(http_t *http, /* I - HTTP connection */
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;
@@ -2087,7 +2080,7 @@ httpRead2(http_t *http, /* I - HTTP connection */
"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)
@@ -2534,10 +2527,10 @@ httpSetAuthString(http_t *http, /* I - HTTP connection */
* 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);
@@ -3288,7 +3281,7 @@ httpWrite(http_t *http, /* I - HTTP connection */
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));
}
@@ -3342,13 +3335,13 @@ httpWrite2(http_t *http, /* I - HTTP connection */
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)
{
@@ -3363,15 +3356,15 @@ httpWrite2(http_t *http, /* I - HTTP connection */
}
}
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));
@@ -3379,8 +3372,7 @@ httpWrite2(http_t *http, /* I - HTTP connection */
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...
@@ -3403,9 +3395,9 @@ httpWrite2(http_t *http, /* I - HTTP connection */
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));
@@ -3700,11 +3692,11 @@ http_content_coding_finish(
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);
}
@@ -3996,7 +3988,7 @@ http_debug_hex(const char *prefix, /* I - Prefix for line */
if (ch < ' ' || ch >= 127)
ch = '.';
*ptr++ = ch;
*ptr++ = (char)ch;
}
*ptr = '\0';
@@ -4042,7 +4034,7 @@ http_read(http_t *http, /* I - HTTP connection */
{
#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);
@@ -4142,9 +4134,9 @@ http_read_buffered(http_t *http, /* I - HTTP connection */
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));
@@ -4462,7 +4454,7 @@ http_set_length(http_t *http) /* I - Connection */
http->data_remaining = remaining;
if (remaining <= INT_MAX)
http->_data_remaining = remaining;
http->_data_remaining = (int)remaining;
else
http->_data_remaining = INT_MAX;
}
@@ -4683,7 +4675,7 @@ http_write(http_t *http, /* I - HTTP connection */
#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);
@@ -4737,11 +4729,11 @@ http_write(http_t *http, /* I - HTTP connection */
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));
+3 -3
Ver Arquivo
@@ -3,7 +3,7 @@
*
* 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
@@ -633,8 +633,8 @@ extern const char *httpResolveHostname(http_t *http, char *buffer, size_t bufsiz
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...
+9 -9
Ver Arquivo
@@ -1,18 +1,18 @@
/*
* "$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_
+10 -11
Ver Arquivo
@@ -3,7 +3,7 @@
*
* 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
@@ -683,7 +683,7 @@ ippAttributeString(
{
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",
@@ -752,8 +752,7 @@ ippAttributeString(
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;
@@ -804,7 +803,7 @@ ippAttributeString(
else if (bufend)
*bufend = '\0';
return (bufptr - buffer);
return ((size_t)(bufptr - buffer));
}
@@ -1845,7 +1844,7 @@ ippEnumValue(const char *attrname, /* I - Attribute name */
*/
if (isdigit(*enumstring & 255))
return (strtol(enumstring, NULL, 0));
return ((int)strtol(enumstring, NULL, 0));
/*
* Otherwise look up the string...
@@ -1972,7 +1971,7 @@ ippErrorString(ipp_status_t error) /* I - Error status */
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 ++)
@@ -2049,7 +2048,7 @@ ippOpString(ipp_op_t op) /* I - Operation ID */
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))
@@ -2161,7 +2160,7 @@ ippTagString(ipp_tag_t tag) /* I - Tag value */
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 ++)
@@ -2230,7 +2229,7 @@ ipp_col_string(ipp_t *col, /* I - Collection attribute */
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));
}
@@ -2246,7 +2245,7 @@ ipp_col_string(ipp_t *col, /* I - Collection attribute */
*bufptr = '}';
bufptr ++;
return (bufptr - buffer);
return ((size_t)(bufptr - buffer));
}
+138 -244
Ver Arquivo
@@ -1,124 +1,18 @@
/*
* "$Id$"
*
* Internet Printing Protocol functions for CUPS.
* Internet Printing Protocol functions 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/".
*
* 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.
* This file is subject to the Apple OS-Developed Software exception.
*/
/*
@@ -656,7 +550,7 @@ ippAddOctetString(ipp_t *ipp, /* I - IPP message */
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);
@@ -1232,7 +1126,7 @@ ippAddStringfv(ipp_t *ipp, /* I - IPP message */
if (!s)
s = "(null)";
bytes = strlen(s);
bytes = (ssize_t)strlen(s);
strlcpy(buffer, s, sizeof(buffer));
}
else
@@ -1818,7 +1712,7 @@ ippCopyAttribute(
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);
@@ -2744,8 +2638,8 @@ ippNew(void)
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;
}
@@ -3304,7 +3198,7 @@ ippReadIO(void *src, /* I - Data source */
* 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);
@@ -3405,7 +3299,7 @@ ippReadIO(void *src, /* I - Data source */
return (IPP_STATE_ERROR);
}
value->boolean = buffer[0];
value->boolean = (char)buffer[0];
break;
case IPP_TAG_NOVALUE :
@@ -3436,7 +3330,7 @@ ippReadIO(void *src, /* I - Data source */
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);
@@ -3537,7 +3431,7 @@ ippReadIO(void *src, /* I - Data source */
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.");
@@ -3559,8 +3453,7 @@ ippReadIO(void *src, /* I - Data source */
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);
@@ -3662,7 +3555,7 @@ ippReadIO(void *src, /* I - Data source */
_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);
@@ -3698,7 +3591,7 @@ ippReadIO(void *src, /* I - Data source */
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");
@@ -3706,7 +3599,7 @@ ippReadIO(void *src, /* I - Data source */
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);
@@ -3777,7 +3670,7 @@ ippSetBoolean(ipp_t *ipp, /* I - IPP message */
*/
if ((value = ipp_set_value(ipp, attr, element)) != NULL)
value->boolean = boolvalue;
value->boolean = (char)boolvalue;
return (value != NULL);
}
@@ -4072,7 +3965,7 @@ ippSetOctetString(
{
void *temp; /* Temporary data pointer */
if ((temp = malloc(datalen)) != NULL)
if ((temp = malloc((size_t)datalen)) != NULL)
{
memcpy(temp, data, datalen);
@@ -4470,7 +4363,7 @@ ippSetStringfv(ipp_t *ipp, /* I - IPP message */
if (!s)
s = "(null)";
bytes = strlen(s);
bytes = (ssize_t)strlen(s);
strlcpy(buffer, s, sizeof(buffer));
}
else
@@ -4751,8 +4644,8 @@ ippSetVersion(ipp_t *ipp, /* I - IPP message */
* 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);
}
@@ -4790,13 +4683,13 @@ ippTimeToDate(time_t t) /* I - UNIX time value */
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;
@@ -5561,12 +5454,12 @@ ippWriteIO(void *dst, /* I - Destination */
*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",
@@ -5574,7 +5467,7 @@ ippWriteIO(void *dst, /* I - Destination */
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);
@@ -5627,7 +5520,7 @@ ippWriteIO(void *dst, /* I - Destination */
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;
@@ -5672,16 +5565,16 @@ ippWriteIO(void *dst, /* I - Destination */
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;
}
@@ -5715,21 +5608,21 @@ ippWriteIO(void *dst, /* I - Destination */
*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;
@@ -5760,7 +5653,7 @@ ippWriteIO(void *dst, /* I - Destination */
{
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...");
@@ -5778,7 +5671,7 @@ ippWriteIO(void *dst, /* I - Destination */
* values with a zero-length name...
*/
*bufptr++ = attr->value_tag;
*bufptr++ = (ipp_uchar_t)attr->value_tag;
*bufptr++ = 0;
*bufptr++ = 0;
}
@@ -5792,10 +5685,10 @@ ippWriteIO(void *dst, /* I - Destination */
*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;
@@ -5806,7 +5699,7 @@ ippWriteIO(void *dst, /* I - Destination */
{
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...");
@@ -5824,7 +5717,7 @@ ippWriteIO(void *dst, /* I - Destination */
* values with a zero-length name...
*/
*bufptr++ = attr->value_tag;
*bufptr++ = (ipp_uchar_t)attr->value_tag;
*bufptr++ = 0;
*bufptr++ = 0;
}
@@ -5837,7 +5730,7 @@ ippWriteIO(void *dst, /* I - Destination */
*bufptr++ = 0;
*bufptr++ = 1;
*bufptr++ = value->boolean;
*bufptr++ = (ipp_uchar_t)value->boolean;
}
break;
@@ -5867,7 +5760,7 @@ ippWriteIO(void *dst, /* I - Destination */
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...");
@@ -5878,7 +5771,7 @@ ippWriteIO(void *dst, /* I - Destination */
bufptr = buffer;
}
*bufptr++ = attr->value_tag;
*bufptr++ = (ipp_uchar_t)attr->value_tag;
*bufptr++ = 0;
*bufptr++ = 0;
}
@@ -5900,7 +5793,7 @@ ippWriteIO(void *dst, /* I - Destination */
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...");
@@ -5921,8 +5814,8 @@ ippWriteIO(void *dst, /* I - Destination */
* 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)
{
@@ -5939,7 +5832,7 @@ ippWriteIO(void *dst, /* I - Destination */
{
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...");
@@ -5957,7 +5850,7 @@ ippWriteIO(void *dst, /* I - Destination */
* values with a zero-length name...
*/
*bufptr++ = attr->value_tag;
*bufptr++ = (ipp_uchar_t)attr->value_tag;
*bufptr++ = 0;
*bufptr++ = 0;
}
@@ -5984,7 +5877,7 @@ ippWriteIO(void *dst, /* I - Destination */
{
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...");
@@ -6002,7 +5895,7 @@ ippWriteIO(void *dst, /* I - Destination */
* values with a zero-length name...
*/
*bufptr++ = attr->value_tag;
*bufptr++ = (ipp_uchar_t)attr->value_tag;
*bufptr++ = 0;
*bufptr++ = 0;
}
@@ -6018,15 +5911,15 @@ ippWriteIO(void *dst, /* I - Destination */
*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;
@@ -6037,7 +5930,7 @@ ippWriteIO(void *dst, /* I - Destination */
{
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...");
@@ -6055,7 +5948,7 @@ ippWriteIO(void *dst, /* I - Destination */
* values with a zero-length name...
*/
*bufptr++ = attr->value_tag;
*bufptr++ = (ipp_uchar_t)attr->value_tag;
*bufptr++ = 0;
*bufptr++ = 0;
}
@@ -6070,14 +5963,14 @@ ippWriteIO(void *dst, /* I - Destination */
*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;
@@ -6096,7 +5989,7 @@ ippWriteIO(void *dst, /* I - Destination */
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...");
@@ -6107,7 +6000,7 @@ ippWriteIO(void *dst, /* I - Destination */
bufptr = buffer;
}
*bufptr++ = attr->value_tag;
*bufptr++ = (ipp_uchar_t)attr->value_tag;
*bufptr++ = 0;
*bufptr++ = 0;
}
@@ -6140,7 +6033,7 @@ ippWriteIO(void *dst, /* I - Destination */
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...");
@@ -6152,8 +6045,8 @@ ippWriteIO(void *dst, /* I - Destination */
}
/* 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)
@@ -6161,8 +6054,8 @@ ippWriteIO(void *dst, /* I - Destination */
else
n = 0;
*bufptr++ = n >> 8;
*bufptr++ = n;
*bufptr++ = (ipp_uchar_t)(n >> 8);
*bufptr++ = (ipp_uchar_t)n;
/* Language */
if (n > 0)
@@ -6177,8 +6070,8 @@ ippWriteIO(void *dst, /* I - Destination */
else
n = 0;
*bufptr++ = n >> 8;
*bufptr++ = n;
*bufptr++ = (ipp_uchar_t)(n >> 8);
*bufptr++ = (ipp_uchar_t)n;
/* Text */
if (n > 0)
@@ -6203,7 +6096,7 @@ ippWriteIO(void *dst, /* I - Destination */
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...");
@@ -6221,7 +6114,7 @@ ippWriteIO(void *dst, /* I - Destination */
* values with a zero-length name...
*/
*bufptr++ = attr->value_tag;
*bufptr++ = (ipp_uchar_t)attr->value_tag;
*bufptr++ = 0;
*bufptr++ = 0;
}
@@ -6233,7 +6126,7 @@ ippWriteIO(void *dst, /* I - Destination */
*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...");
@@ -6273,7 +6166,7 @@ ippWriteIO(void *dst, /* I - Destination */
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...");
@@ -6284,7 +6177,7 @@ ippWriteIO(void *dst, /* I - Destination */
bufptr = buffer;
}
*bufptr++ = attr->value_tag;
*bufptr++ = (ipp_uchar_t)attr->value_tag;
*bufptr++ = 0;
*bufptr++ = 0;
}
@@ -6308,7 +6201,7 @@ ippWriteIO(void *dst, /* I - Destination */
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...");
@@ -6320,8 +6213,8 @@ ippWriteIO(void *dst, /* I - Destination */
}
/* Length of unknown value */
*bufptr++ = n >> 8;
*bufptr++ = n;
*bufptr++ = (ipp_uchar_t)(n >> 8);
*bufptr++ = (ipp_uchar_t)n;
/* Value */
if (n > 0)
@@ -6339,7 +6232,7 @@ ippWriteIO(void *dst, /* I - Destination */
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);
@@ -6381,7 +6274,7 @@ ippWriteIO(void *dst, /* I - Destination */
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);
@@ -6440,7 +6333,7 @@ ipp_add_attr(ipp_t *ipp, /* I - IPP message */
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)
{
@@ -6572,7 +6465,7 @@ ipp_free_values(ipp_attribute_t *attr, /* I - Attribute to free values from */
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;
}
@@ -6604,7 +6497,7 @@ ipp_get_code(const char *value, /* I - Locale/charset string */
if (*value == '_')
*bufptr++ = '-';
else
*bufptr++ = _cups_tolower(*value);
*bufptr++ = (char)_cups_tolower(*value);
*bufptr = '\0';
@@ -6695,12 +6588,15 @@ ipp_length(ipp_t *ipp, /* I - IPP message or collection */
"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 */
@@ -6718,11 +6614,11 @@ ipp_length(ipp_t *ipp, /* I - IPP message or collection */
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 :
@@ -6741,20 +6637,21 @@ ipp_length(ipp_t *ipp, /* I - IPP message or collection */
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;
@@ -6779,7 +6676,7 @@ ipp_length(ipp_t *ipp, /* I - IPP message or collection */
for (i = 0, value = attr->values;
i < attr->num_values;
i ++, value ++)
bytes += value->unknown.length;
bytes += (size_t)value->unknown.length;
break;
}
}
@@ -6809,8 +6706,8 @@ ipp_read_http(http_t *http, /* I - Client connection */
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)",
@@ -6824,8 +6721,7 @@ ipp_read_http(http_t *http, /* I - Client connection */
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;
@@ -6847,7 +6743,7 @@ ipp_read_http(http_t *http, /* I - Client connection */
}
}
if ((bytes = httpRead2(http, (char *)buffer, length - tbytes)) < 0)
if ((bytes = httpRead2(http, (char *)buffer, length - (size_t)tbytes)) < 0)
{
#ifdef WIN32
break;
@@ -6869,7 +6765,7 @@ ipp_read_http(http_t *http, /* I - Client connection */
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);
}
@@ -6968,8 +6864,7 @@ ipp_set_value(ipp_t *ipp, /* IO - IPP message */
* 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.");
@@ -6980,8 +6875,7 @@ ipp_set_value(ipp_t *ipp, /* IO - IPP message */
* 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)
{
+7
Ver Arquivo
@@ -67,6 +67,13 @@ extern "C" {
# 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...
+23 -34
Ver Arquivo
@@ -1,27 +1,18 @@
/*
* "$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.
*/
/*
@@ -39,7 +30,7 @@ void
_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 */
@@ -81,7 +72,7 @@ _cupsLangPrintError(const char *prefix, /* I - Non-localized message prefix */
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));
@@ -95,7 +86,7 @@ _cupsLangPrintError(const char *prefix, /* I - Non-localized message prefix */
cg->lang_default->encoding);
if (bytes > 0)
fwrite(output, 1, bytes, stderr);
fwrite(output, 1, (size_t)bytes, stderr);
}
@@ -110,7 +101,7 @@ _cupsLangPrintFilter(
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 */
@@ -152,9 +143,9 @@ _cupsLangPrintFilter(
*/
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);
}
@@ -167,7 +158,7 @@ _cupsLangPrintf(FILE *fp, /* I - File to write to */
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 */
@@ -209,9 +200,9 @@ _cupsLangPrintf(FILE *fp, /* I - File to write to */
*/
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);
}
@@ -223,7 +214,7 @@ int /* O - Number of bytes written */
_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 */
@@ -248,18 +239,16 @@ _cupsLangPuts(FILE *fp, /* I - File to write to */
(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);
}
@@ -301,7 +290,7 @@ _cupsSetLocale(char *argv[]) /* IO - Command-line arguments */
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));
+22 -48
Ver Arquivo
@@ -1,43 +1,18 @@
/*
* "$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.
*/
/*
@@ -227,8 +202,8 @@ _cupsAppleLanguage(const char *locale, /* I - Locale ID */
*/
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;
}
@@ -253,7 +228,7 @@ _cupsAppleLanguage(const char *locale, /* I - Locale ID */
if ((langid = CFLocaleCreateCanonicalLanguageIdentifierFromString(
kCFAllocatorDefault, localeid)) != NULL)
{
CFStringGetCString(langid, language, langsize, kCFStringEncodingASCII);
CFStringGetCString(langid, language, (CFIndex)langsize, kCFStringEncodingASCII);
CFRelease(langid);
}
@@ -278,8 +253,8 @@ const char * /* O - Character encoding */
_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]));
@@ -608,7 +583,7 @@ cupsLangGet(const char *language) /* I - Language or locale */
if (*language == '_' || *language == '-' || *language == '.')
break;
else if (ptr < (langname + sizeof(langname) - 1))
*ptr++ = tolower(*language & 255);
*ptr++ = (char)tolower(*language & 255);
*ptr = '\0';
@@ -622,7 +597,7 @@ cupsLangGet(const char *language) /* I - Language or locale */
if (*language == '.')
break;
else if (ptr < (country + sizeof(country) - 1))
*ptr++ = toupper(*language & 255);
*ptr++ = (char)toupper(*language & 255);
*ptr = '\0';
}
@@ -635,7 +610,7 @@ cupsLangGet(const char *language) /* I - Language or locale */
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';
}
@@ -846,8 +821,8 @@ _cupsMessageLoad(const char *filename, /* I - Message catalog to load */
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));
@@ -978,11 +953,10 @@ _cupsMessageLoad(const char *filename, /* I - Message catalog to load */
* 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);
@@ -1351,7 +1325,7 @@ appleMessageLoad(const char *locale) /* I - Locale ID */
url = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault,
(UInt8 *)filename,
strlen(filename), false);
(CFIndex)strlen(filename), false);
if (url)
{
stream = CFReadStreamCreateWithFile(kCFAllocatorDefault, url);
+22 -37
Ver Arquivo
@@ -1,42 +1,27 @@
/*
* "$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.
*/
/*
@@ -263,8 +248,8 @@ ppdLocalizeIPPReason(
*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 */
/*
@@ -405,9 +390,9 @@ ppdLocalizeIPPReason(
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 == '+')
@@ -644,8 +629,8 @@ _ppdGetLanguages(ppd_file_t *ppd) /* I - PPD file */
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 ++)
+13 -32
Ver Arquivo
@@ -1,39 +1,20 @@
/*
* "$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.
*/
/*
@@ -143,7 +124,7 @@ cupsMarkOptions(
* 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';
@@ -195,7 +176,7 @@ cupsMarkOptions(
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)
@@ -316,7 +297,7 @@ cupsMarkOptions(
if (!isdigit(*ptr & 255))
break;
if ((j = strtol(ptr, &ptr, 10)) < 3)
if ((j = (int)strtol(ptr, &ptr, 10)) < 3)
break;
/*
+2 -2
Ver Arquivo
@@ -3,7 +3,7 @@
*
* 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.
*
@@ -291,7 +291,7 @@ _cupsMD5Append(_cups_md5_state_t *pms, const unsigned char *data, int nbytes)
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]++;
+13 -26
Ver Arquivo
@@ -1,29 +1,18 @@
/*
* "$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.
*/
/*
@@ -99,10 +88,9 @@ cupsAddOption(const char *name, /* I - Name of option */
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);
@@ -114,8 +102,7 @@ cupsAddOption(const char *name, /* I - Name of option */
{
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;
@@ -487,7 +474,7 @@ cupsRemoveOption(
_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));
}
/*
+23 -58
Ver Arquivo
@@ -1,49 +1,17 @@
/*
* "$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.
*/
/*
@@ -290,7 +258,7 @@ _ppdCacheCreateWithFile(
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));
@@ -340,7 +308,7 @@ _ppdCacheCreateWithFile(
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));
@@ -428,7 +396,7 @@ _ppdCacheCreateWithFile(
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));
@@ -477,7 +445,7 @@ _ppdCacheCreateWithFile(
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));
@@ -553,7 +521,7 @@ _ppdCacheCreateWithFile(
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));
@@ -714,7 +682,7 @@ _ppdCacheCreateWithPPD(ppd_file_t *ppd) /* I - PPD file */
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));
@@ -891,8 +859,7 @@ _ppdCacheCreateWithPPD(ppd_file_t *ppd) /* I - PPD file */
{
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));
@@ -953,8 +920,7 @@ _ppdCacheCreateWithPPD(ppd_file_t *ppd) /* I - PPD file */
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));
@@ -1018,8 +984,7 @@ _ppdCacheCreateWithPPD(ppd_file_t *ppd) /* I - PPD file */
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));
@@ -1202,7 +1167,7 @@ _ppdCacheCreateWithPPD(ppd_file_t *ppd) /* I - PPD file */
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)
{
@@ -1371,7 +1336,7 @@ _ppdCacheCreateWithPPD(ppd_file_t *ppd) /* I - PPD file */
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);
@@ -1611,7 +1576,7 @@ _ppdCacheGetFinishingOptions(
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)
{
@@ -2694,14 +2659,14 @@ pwg_ppdize_name(const char *ipp, /* I - IPP keyword */
*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++;
@@ -2728,7 +2693,7 @@ pwg_unppdize_name(const char *ppd, /* I - PPD keyword */
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
+16 -16
Ver Arquivo
@@ -1,27 +1,27 @@
/*
* "$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_
+32 -80
Ver Arquivo
@@ -1,61 +1,27 @@
/*
* "$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.
*/
/*
@@ -70,14 +36,6 @@
* 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 */
@@ -872,8 +830,7 @@ _ppdOpen(
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)
{
@@ -907,7 +864,7 @@ _ppdOpen(
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)
{
@@ -937,8 +894,7 @@ _ppdOpen(
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)
{
@@ -1173,7 +1129,7 @@ _ppdOpen(
}
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;
@@ -1697,8 +1653,7 @@ _ppdOpen(
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)
{
@@ -2282,7 +2237,7 @@ ppd_add_attr(ppd_file_t *ppd, /* I - PPD file data */
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);
@@ -2334,8 +2289,7 @@ ppd_add_choice(ppd_option_t *option, /* I - Option */
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);
@@ -2365,7 +2319,7 @@ ppd_add_size(ppd_file_t *ppd, /* I - PPD file */
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);
@@ -2454,9 +2408,9 @@ ppd_decode(char *string) /* I - String to decode */
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 ++;
@@ -2464,9 +2418,9 @@ ppd_decode(char *string) /* I - String to decode */
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 ++;
@@ -2687,8 +2641,7 @@ ppd_get_group(ppd_file_t *ppd, /* I - PPD file */
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)
{
@@ -2736,8 +2689,7 @@ ppd_get_option(ppd_group_t *group, /* I - Group */
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);
@@ -2917,7 +2869,7 @@ ppd_read(cups_file_t *fp, /* I - File to read from */
* Any other character...
*/
*lineptr++ = ch;
*lineptr++ = (char)ch;
col ++;
if (col > (PPD_MAX_LINE - 1))
@@ -3370,7 +3322,7 @@ ppd_update_filters(ppd_file_t *ppd,/* I - PPD file */
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)
{
+10 -29
Ver Arquivo
@@ -1,36 +1,17 @@
/*
* "$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.
*/
/*
@@ -376,10 +357,10 @@ pwgFormatSizeName(char *keyword, /* I - Keyword buffer */
*/
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);
/*
+16 -32
Ver Arquivo
@@ -1,34 +1,18 @@
/*
* "$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.
*/
/*
@@ -129,7 +113,7 @@ cupsDoIORequest(http_t *http, /* I - Connection to server or @code CUPS_HTTP
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 */
@@ -205,7 +189,7 @@ cupsDoIORequest(http_t *http, /* I - Connection to server or @code CUPS_HTTP
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);
@@ -249,9 +233,9 @@ cupsDoIORequest(http_t *http, /* I - Connection to server or @code CUPS_HTTP
#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;
}
@@ -283,8 +267,8 @@ cupsDoIORequest(http_t *http, /* I - Connection to server or @code CUPS_HTTP
* 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;
}
@@ -943,7 +927,7 @@ cupsWriteRequestData(
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...
+15 -15
Ver Arquivo
@@ -3,7 +3,7 @@
*
* 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
@@ -107,7 +107,7 @@ cupsSideChannelRead(
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
@@ -138,7 +138,7 @@ cupsSideChannelRead(
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))
;
@@ -201,7 +201,7 @@ cupsSideChannelRead(
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);
@@ -355,7 +355,7 @@ cupsSideChannelSNMPGet(
* 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)
@@ -414,8 +414,8 @@ cupsSideChannelSNMPWalk(
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 */
@@ -439,7 +439,7 @@ cupsSideChannelSNMPWalk(
*/
current_oid = oid;
oidlen = (int)strlen(oid);
oidlen = strlen(oid);
last_oid[0] = '\0';
do
@@ -486,7 +486,7 @@ cupsSideChannelSNMPWalk(
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;
@@ -532,7 +532,7 @@ cupsSideChannelWrite(
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() */
@@ -562,7 +562,7 @@ cupsSideChannelWrite(
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() */
@@ -595,13 +595,13 @@ cupsSideChannelWrite(
* 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;
@@ -611,7 +611,7 @@ cupsSideChannelWrite(
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);
+12 -12
Ver Arquivo
@@ -1,18 +1,18 @@
/*
* "$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_
@@ -66,14 +66,14 @@ typedef struct cups_snmp_string_s /**** String value ****/
{
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 */
@@ -88,7 +88,7 @@ typedef struct cups_snmp_s /**** SNMP data packet ****/
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];
+66 -75
Ver Arquivo
@@ -3,7 +3,7 @@
*
* 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
@@ -38,16 +38,16 @@ static int asn1_encode_snmp(unsigned char *buffer, size_t len,
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,
@@ -60,10 +60,10 @@ static void asn1_set_oid(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);
@@ -348,7 +348,7 @@ _cupsSNMPRead(int fd, /* I - SNMP socket file descriptor */
{
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 */
@@ -434,9 +434,9 @@ _cupsSNMPRead(int fd, /* I - SNMP socket file descriptor */
* 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));
@@ -557,7 +557,7 @@ _cupsSNMPWalk(int fd, /* I - SNMP socket */
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 */
@@ -650,7 +650,7 @@ _cupsSNMPWrite(
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 */
@@ -706,7 +706,7 @@ _cupsSNMPWrite(
return (0);
}
asn1_debug("DEBUG: OUT ", buffer, bytes, 0);
asn1_debug("DEBUG: OUT ", buffer, (size_t)bytes, 0);
/*
* Send the message...
@@ -716,8 +716,7 @@ _cupsSNMPWrite(
_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);
}
@@ -731,14 +730,14 @@ asn1_debug(const char *prefix, /* I - Prefix string */
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 */
@@ -751,15 +750,15 @@ asn1_debug(const char *prefix, /* I - Prefix string */
* 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]);
@@ -779,7 +778,7 @@ asn1_debug(const char *prefix, /* I - Prefix string */
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
@@ -800,7 +799,7 @@ asn1_debug(const char *prefix, /* I - Prefix string */
* 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)
@@ -870,7 +869,7 @@ asn1_debug(const char *prefix, /* I - Prefix string */
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;
@@ -929,7 +928,7 @@ asn1_decode_snmp(unsigned char *buffer, /* I - Buffer */
{
unsigned char *bufptr, /* Pointer into the data */
*bufend; /* End of data */
int length; /* Length of value */
unsigned length; /* Length of value */
/*
@@ -962,7 +961,7 @@ asn1_decode_snmp(unsigned char *buffer, /* I - Buffer */
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)
@@ -973,7 +972,7 @@ asn1_decode_snmp(unsigned char *buffer, /* I - Buffer */
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"));
@@ -1009,7 +1008,7 @@ asn1_decode_snmp(unsigned char *buffer, /* I - Buffer */
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 &&
@@ -1053,12 +1052,12 @@ asn1_decode_snmp(unsigned char *buffer, /* I - Buffer */
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 :
@@ -1086,7 +1085,7 @@ asn1_encode_snmp(unsigned char *buffer, /* I - Buffer */
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 */
@@ -1133,17 +1132,17 @@ asn1_encode_snmp(unsigned char *buffer, /* I - Buffer */
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);
@@ -1169,7 +1168,7 @@ asn1_encode_snmp(unsigned char *buffer, /* I - Buffer */
*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);
@@ -1215,7 +1214,7 @@ asn1_encode_snmp(unsigned char *buffer, /* I - Buffer */
break;
}
return (bufptr - buffer);
return ((int)(bufptr - buffer));
}
@@ -1227,7 +1226,7 @@ static int /* O - Integer value */
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 */
@@ -1290,7 +1289,7 @@ static int /* O - Number of OIDs */
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 */
{
@@ -1332,7 +1331,7 @@ asn1_get_oid(
*oidptr = -1;
return (oidptr - oid);
return ((int)(oidptr - oid));
}
@@ -1374,22 +1373,14 @@ static char * /* O - String */
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 > (unsigned)(bufend - *buffer))
length = (unsigned)(bufend - *buffer);
if (length < 0)
{
/*
* Disallow negative lengths!
*/
*string = '\0';
}
else if (length < strsize)
if (length < strsize)
{
/*
* String is smaller than the buffer...
@@ -1413,7 +1404,7 @@ asn1_get_string(
if (length > 0)
(*buffer) += length;
return (length < 0 ? NULL : string);
return (string);
}
@@ -1453,40 +1444,40 @@ asn1_set_integer(unsigned char **buffer,/* IO - Pointer in buffer */
{
**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) ++;
}
}
@@ -1504,21 +1495,21 @@ asn1_set_length(unsigned char **buffer, /* IO - Pointer in 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) ++;
}
}
@@ -1592,7 +1583,7 @@ asn1_set_packed(unsigned char **buffer, /* IO - Pointer in 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)
@@ -1611,8 +1602,8 @@ asn1_size_integer(int integer) /* I - Integer value */
* 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);
@@ -1628,10 +1619,10 @@ asn1_size_length(int length) /* I - Length value */
* 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)
@@ -1651,7 +1642,7 @@ asn1_size_oid(const int *oid) /* I - OID value */
* 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)
+13 -30
Ver Arquivo
@@ -1,35 +1,18 @@
/*
* "$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.
*/
/*
@@ -436,7 +419,7 @@ _cupsStrScand(const char *buf, /* I - Pointer to number */
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))
@@ -546,7 +529,7 @@ _cupsStrStatistics(size_t *alloc_bytes, /* O - Allocated bytes */
*/
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;
}
@@ -702,7 +685,7 @@ _cups_strlcat(char *dst, /* O - Destination string */
if (srclen > size)
srclen = size;
memcpy(dst + dstlen, src, srclen);
memmove(dst + dstlen, src, srclen);
dst[dstlen + srclen] = '\0';
return (dstlen + srclen);
@@ -738,7 +721,7 @@ _cups_strlcpy(char *dst, /* O - Destination string */
if (srclen > size)
srclen = size;
memcpy(dst, src, srclen);
memmove(dst, src, srclen);
dst[srclen] = '\0';
return (srclen);
+11 -18
Ver Arquivo
@@ -1,24 +1,18 @@
/*
* "$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.
*/
/*
@@ -44,8 +38,7 @@ static int load_words(const char *filename, cups_array_t *array);
*/
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 */
@@ -296,7 +289,7 @@ main(int argc, /* I - Number of command-line arguments */
{
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' ||
+13 -17
Ver Arquivo
@@ -1,23 +1,18 @@
/*
* "$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.
*/
/*
@@ -227,15 +222,14 @@ main(int argc, /* I - Number of command-line arguments */
{
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);
@@ -532,6 +526,8 @@ enum_cb(void *user_data, /* I - User data (unused) */
cups_option_t *option; /* Current option */
(void)user_data;
if (flags & CUPS_DEST_FLAGS_REMOVED)
printf("Removed '%s':\n", dest->name);
else
+26 -34
Ver Arquivo
@@ -1,25 +1,18 @@
/*
* "$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.
*/
/*
@@ -266,8 +259,8 @@ random_tests(void)
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 */
@@ -298,10 +291,10 @@ random_tests(void)
* 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);
@@ -319,7 +312,7 @@ random_tests(void)
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;
}
@@ -336,10 +329,10 @@ random_tests(void)
* 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);
@@ -372,11 +365,9 @@ random_tests(void)
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...
@@ -390,7 +381,7 @@ random_tests(void)
* contents...
*/
expected = sizeof(buffer) * record;
expected = (ssize_t)sizeof(buffer) * record;
if ((pos = cupsFileSeek(fp, expected)) != expected)
{
@@ -454,6 +445,7 @@ read_write_tests(int compression) /* I - Use compression? */
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 */
@@ -472,7 +464,7 @@ read_write_tests(int compression) /* I - Use compression? */
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)
@@ -673,7 +665,7 @@ read_write_tests(int compression) /* I - Use compression? */
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 ||
@@ -700,7 +692,7 @@ read_write_tests(int compression) /* I - Use compression? */
fputs("cupsFileGetChar(): ", stdout);
for (i = 0; i < 256; i ++)
for (i = 0, byte = 0; i < 256; i ++)
if ((byte = cupsFileGetChar(fp)) != i)
break;
@@ -723,15 +715,15 @@ read_write_tests(int compression) /* I - Use compression? */
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);
+5 -5
Ver Arquivo
@@ -3,7 +3,7 @@
*
* 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
@@ -35,8 +35,8 @@ typedef struct uri_test_s /**** URI test cases ****/
*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;
@@ -109,7 +109,7 @@ static uri_test_t uri_tests[] = /* URI test data */
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 },
@@ -807,7 +807,7 @@ main(int argc, /* I - Number of command-line arguments */
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);
+22 -27
Ver Arquivo
@@ -1,23 +1,18 @@
/*
* "$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.
*/
/*
@@ -285,14 +280,14 @@ main(int argc, /* I - Argument Count */
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);
@@ -336,14 +331,14 @@ main(int argc, /* I - Argument Count */
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);
@@ -382,14 +377,14 @@ main(int argc, /* I - Argument Count */
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);
@@ -429,14 +424,14 @@ main(int argc, /* I - Argument Count */
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);
@@ -476,14 +471,14 @@ main(int argc, /* I - Argument Count */
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);
@@ -522,14 +517,14 @@ main(int argc, /* I - Argument Count */
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);
@@ -553,7 +548,7 @@ main(int argc, /* I - Argument Count */
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);
+25 -33
Ver Arquivo
@@ -1,26 +1,18 @@
/*
* "$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.
*/
/*
@@ -55,7 +47,7 @@ typedef struct _ippdata_t
* Local globals...
*/
ipp_uchar_t collection[] = /* Collection buffer */
static ipp_uchar_t collection[] = /* Collection buffer */
{
0x01, 0x01, /* IPP version */
0x00, 0x02, /* Print-Job operation */
@@ -205,7 +197,7 @@ ipp_uchar_t collection[] = /* Collection buffer */
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 */
@@ -236,7 +228,7 @@ ipp_uchar_t mixed[] = /* Mixed value buffer */
* 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);
@@ -259,9 +251,9 @@ main(int argc, /* I - Number of command-line arguments */
*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 */
@@ -322,7 +314,7 @@ main(int argc, /* I - Number of command-line arguments */
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
@@ -362,7 +354,7 @@ main(int argc, /* I - Number of command-line arguments */
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;
@@ -403,7 +395,7 @@ main(int argc, /* I - Number of command-line arguments */
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;
}
@@ -587,7 +579,7 @@ main(int argc, /* I - Number of command-line arguments */
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;
}
@@ -673,7 +665,7 @@ main(int argc, /* I - Number of command-line arguments */
* Read IPP files...
*/
for (i = 1; i < argc; i ++)
for (i = 1; i < (size_t)argc; i ++)
{
if ((fp = cupsFileOpen(argv[i], "r")) == NULL)
{
@@ -713,10 +705,10 @@ main(int argc, /* I - Number of command-line arguments */
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 */
/*
@@ -731,7 +723,7 @@ hex_dump(const char *title, /* I - Title */
* Show the offset...
*/
printf(" %04x ", i);
printf(" %04x ", (unsigned)i);
/*
* Then up to 16 bytes in hex...
@@ -984,7 +976,7 @@ read_cb(_ippdata_t *data, /* I - Data */
* Return the number of bytes read...
*/
return (count);
return ((ssize_t)count);
}
@@ -1014,7 +1006,7 @@ write_cb(_ippdata_t *data, /* I - Data */
* Return the number of bytes written...
*/
return (count);
return ((ssize_t)count);
}
+22 -25
Ver Arquivo
@@ -1,22 +1,18 @@
/*
* "$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.
*/
/*
@@ -394,10 +390,10 @@ main(int argc, /* I - Number of command-line arguments */
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 ++;
@@ -483,7 +479,8 @@ main(int argc, /* I - Number of command-line arguments */
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);
@@ -772,8 +769,8 @@ main(int argc, /* I - Number of command-line arguments */
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,
@@ -794,8 +791,8 @@ main(int argc, /* I - Number of command-line arguments */
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,
@@ -816,8 +813,8 @@ main(int argc, /* I - Number of command-line arguments */
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,
@@ -838,8 +835,8 @@ main(int argc, /* I - Number of command-line arguments */
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,
+10 -17
Ver Arquivo
@@ -1,24 +1,17 @@
/*
* "$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.
*/
/*
@@ -132,8 +125,8 @@ static void
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;
+8 -8
Ver Arquivo
@@ -1,15 +1,15 @@
/*
* "$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_
@@ -39,7 +39,7 @@ typedef pthread_rwlock_t _cups_rwlock_t;
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)
+10 -12
Ver Arquivo
@@ -3,7 +3,7 @@
*
* 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
@@ -350,8 +350,7 @@ httpCopyCredentials(
secCert = SecTrustGetCertificateAtIndex(peerTrust, i);
if ((data = SecCertificateCopyData(secCert)))
{
httpAddCredential(*credentials, CFDataGetBytePtr(data),
CFDataGetLength(data));
httpAddCredential(*credentials, CFDataGetBytePtr(data), (size_t)CFDataGetLength(data));
CFRelease(data);
}
}
@@ -390,8 +389,7 @@ _httpCreateCredentials(
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)
@@ -912,13 +910,13 @@ http_cdsa_read(
}
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
@@ -960,13 +958,13 @@ http_cdsa_write(
}
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
@@ -1027,7 +1025,7 @@ http_tls_read(http_t *http, /* I - HTTP connection */
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)
@@ -1345,7 +1343,7 @@ http_tls_start(http_t *http) /* I - HTTP connection */
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),
@@ -1480,7 +1478,7 @@ http_tls_write(http_t *http, /* I - HTTP connection */
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)
{
+22 -30
Ver Arquivo
@@ -1,26 +1,18 @@
/*
* "$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.
*/
/*
@@ -141,11 +133,11 @@ cupsCharsetToUTF8(
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';
@@ -174,7 +166,7 @@ cupsCharsetToUTF8(
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';
@@ -262,7 +254,7 @@ cupsUTF8ToCharset(
ch = ((ch & 0x1f) << 6) | (*src++ & 0x3f);
if (ch < maxch)
*destptr++ = ch;
*destptr++ = (char)ch;
else
*destptr++ = '?';
}
@@ -270,7 +262,7 @@ cupsUTF8ToCharset(
(ch & 0xf8) == 0xf0)
*destptr++ = '?';
else if (!(ch & 0x80))
*destptr++ = ch;
*destptr++ = (char)ch;
}
*destptr = '\0';
@@ -299,7 +291,7 @@ cupsUTF8ToCharset(
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';
@@ -404,7 +396,7 @@ cupsUTF8ToUTF32(
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)...
@@ -436,7 +428,7 @@ cupsUTF8ToUTF32(
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)
@@ -446,7 +438,7 @@ cupsUTF8ToUTF32(
return (-1);
}
ch32 = (ch32 << 6) | (next & 0x3f);
ch32 = (ch32 << 6) | (cups_utf32_t)(next & 0x3f);
/*
* Check for non-shortest form (invalid UTF-8)...
@@ -478,7 +470,7 @@ cupsUTF8ToUTF32(
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)
@@ -488,7 +480,7 @@ cupsUTF8ToUTF32(
return (-1);
}
ch32 = (ch32 << 6) | (next & 0x3f);
ch32 = (ch32 << 6) | (cups_utf32_t)(next & 0x3f);
next = *src++;
if ((next & 0xc0) != 0x80)
@@ -498,7 +490,7 @@ cupsUTF8ToUTF32(
return (-1);
}
ch32 = (ch32 << 6) | (next & 0x3f);
ch32 = (ch32 << 6) | (cups_utf32_t)(next & 0x3f);
/*
* Check for non-shortest form (invalid UTF-8)...
+2 -2
Ver Arquivo
@@ -3,7 +3,7 @@
*
* 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
@@ -678,7 +678,7 @@ _cupsGetPassword(const char *prompt) /* I - Prompt string */
}
noecho = original;
noecho.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
noecho.c_lflag &= (tcflag_t)~(ICANON | ECHO | ECHOE | ISIG);
if (tcsetattr(tty, TCSAFLUSH, &noecho))
{
+14 -50
Ver Arquivo
@@ -1,54 +1,18 @@
/*
* "$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.
*/
/*
@@ -382,7 +346,7 @@ cupsGetClasses(char ***classes) /* O - Classes */
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)
{
@@ -748,7 +712,7 @@ cupsGetJobs2(http_t *http, /* I - Connection to server or @code CUPS_HTTP_D
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)
{
@@ -1242,7 +1206,7 @@ cupsGetPrinters(char ***printers) /* O - Printers */
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)
{
@@ -1510,7 +1474,7 @@ cupsPrintFiles2(
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);
@@ -1601,7 +1565,7 @@ cupsStartDocument(
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...
+8 -21
Ver Arquivo
@@ -1,26 +1,15 @@
/*
* "$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/".
*/
/*
@@ -309,9 +298,7 @@ auto_configure(ppd_file_t *ppd, /* I - PPD file */
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 ...
+10 -21
Ver Arquivo
@@ -1,29 +1,18 @@
/*
* "$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.
*/
/*
@@ -481,7 +470,7 @@ WriteTextComment(const char *name, /* I - Comment name ("Title", etc.) */
*/
printf("%%%%%s: (", name);
len = 5 + strlen(name);
len = 5 + (int)strlen(name);
while (*value)
{
+15 -25
Ver Arquivo
@@ -1,27 +1,18 @@
/*
* "$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.
*/
/*
@@ -62,7 +53,7 @@ _cupsRasterAddError(const char *f, /* I - Printf-style error message */
/* 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);
@@ -74,10 +65,10 @@ _cupsRasterAddError(const char *f, /* I - Printf-style error message */
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...
@@ -87,7 +78,7 @@ _cupsRasterAddError(const char *f, /* I - Printf-style error message */
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);
@@ -110,7 +101,7 @@ _cupsRasterAddError(const char *f, /* I - Printf-style error message */
* 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;
}
@@ -167,8 +158,7 @@ cupsRasterErrorString(void)
* 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 */
+11 -15
Ver Arquivo
@@ -1,22 +1,18 @@
/*
* "$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.
*/
/*
@@ -36,7 +32,7 @@ main(int argc, /* I - Number of command-line arguments */
{
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 */
@@ -84,7 +80,7 @@ main(int argc, /* I - Number of command-line arguments */
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"),
+13 -14
Ver Arquivo
@@ -379,9 +379,9 @@ cupsRasterInterpretPPD(
* 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)
@@ -933,7 +933,7 @@ push_stack(_cups_ps_stack_t *st, /* I - Stack */
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);
@@ -994,12 +994,12 @@ roll_stack(_cups_ps_stack_t *st, /* I - Stack */
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
{
@@ -1007,13 +1007,12 @@ roll_stack(_cups_ps_stack_t *st, /* I - Stack */
* 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);
@@ -1132,7 +1131,7 @@ scan_ps(_cups_ps_stack_t *st, /* I - Stack */
ch = (ch << 3) + *cur - '0';
}
*valptr++ = ch;
*valptr++ = (char)ch;
}
else if (*cur == '\r')
{
@@ -1209,7 +1208,7 @@ scan_ps(_cups_ps_stack_t *st, /* I - Stack */
ch |= tolower(*cur) - 'a' + 10;
}
*valptr++ = ch;
*valptr++ = (char)ch;
}
if (*cur != '>')
+87 -117
Ver Arquivo
@@ -1,51 +1,18 @@
/*
* "$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.
*/
/*
@@ -236,7 +203,7 @@ main(int argc, /* I - Number of command-line args */
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 */
@@ -306,7 +273,7 @@ main(int argc, /* I - Number of command-line args */
* 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);
@@ -355,13 +322,13 @@ main(int argc, /* I - Number of command-line args */
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;
}
@@ -511,11 +478,11 @@ check_range(pstops_doc_t *doc, /* I - Document information */
{
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 == '-')
{
@@ -523,7 +490,7 @@ check_range(pstops_doc_t *doc, /* I - Document information */
if (!isdigit(*range & 255))
upper = 65535;
else
upper = strtol(range, (char **)&range, 10);
upper = (int)strtol(range, (char **)&range, 10);
}
else
upper = lower;
@@ -569,14 +536,14 @@ copy_bytes(cups_file_t *fp, /* I - File to read from */
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);
}
}
@@ -741,13 +708,13 @@ copy_comments(cups_file_t *fp, /* I - File to read from */
}
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;
}
@@ -860,9 +827,9 @@ copy_dsc(cups_file_t *fp, /* I - File to read from */
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;
}
@@ -905,7 +872,7 @@ copy_dsc(cups_file_t *fp, /* I - File to read from */
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))
@@ -929,7 +896,7 @@ copy_dsc(cups_file_t *fp, /* I - File to read from */
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);
}
/*
@@ -1006,7 +973,7 @@ copy_dsc(cups_file_t *fp, /* I - File to read from */
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);
}
/*
@@ -1041,7 +1008,7 @@ copy_dsc(cups_file_t *fp, /* I - File to read from */
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);
@@ -1079,11 +1046,13 @@ copy_non_dsc(cups_file_t *fp, /* I - File to read from */
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...
@@ -1175,17 +1144,17 @@ copy_non_dsc(cups_file_t *fp, /* I - File to read from */
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");
@@ -1367,7 +1336,7 @@ copy_page(cups_file_t *fp, /* I - File to read from */
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))
{
@@ -1400,24 +1369,24 @@ copy_page(cups_file_t *fp, /* I - File to read from */
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;
}
@@ -1550,7 +1519,7 @@ copy_page(cups_file_t *fp, /* I - File to read from */
{
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;
@@ -1582,7 +1551,7 @@ copy_page(cups_file_t *fp, /* I - File to read from */
break;
if (!feature || (doc->number_up == 1 && !doc->fit_to_page))
doc_write(doc, line, linelen);
doc_write(doc, line, (size_t)linelen);
}
/*
@@ -1590,7 +1559,7 @@ copy_page(cups_file_t *fp, /* I - File to read from */
*/
if (linelen > 0 && !strncmp(line, "%%EndPageSetup", 14))
linelen = cupsFileGetLine(fp, line, linesize);
linelen = (ssize_t)cupsFileGetLine(fp, line, linesize);
}
if (first_page)
@@ -1639,14 +1608,14 @@ copy_page(cups_file_t *fp, /* I - File to read from */
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 --;
}
@@ -1661,16 +1630,16 @@ copy_page(cups_file_t *fp, /* I - File to read from */
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)
{
@@ -1679,15 +1648,15 @@ copy_page(cups_file_t *fp, /* I - File to read from */
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...
@@ -1695,7 +1664,7 @@ copy_page(cups_file_t *fp, /* I - File to read from */
end_nup(doc, number);
pageinfo->length = cupsFileTell(doc->temp) - pageinfo->offset;
pageinfo->length = (ssize_t)(cupsFileTell(doc->temp) - pageinfo->offset);
return (linelen);
}
@@ -1721,9 +1690,9 @@ copy_prolog(cups_file_t *fp, /* I - File to read from */
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;
}
@@ -1733,18 +1702,18 @@ copy_prolog(cups_file_t *fp, /* I - File to read from */
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);
}
@@ -1779,9 +1748,9 @@ copy_setup(cups_file_t *fp, /* I - File to read from */
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;
}
@@ -1808,14 +1777,14 @@ copy_setup(cups_file_t *fp, /* I - File to read from */
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);
}
@@ -1852,6 +1821,8 @@ copy_trailer(cups_file_t *fp, /* I - File to read from */
* Write the trailer comments...
*/
(void)ppd;
puts("%%Trailer");
while (linelen > 0)
@@ -1861,9 +1832,9 @@ copy_trailer(cups_file_t *fp, /* I - File to read from */
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);
@@ -2045,21 +2016,21 @@ doc_printf(pstops_doc_t *doc, /* I - Document information */
{
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);
}
@@ -2705,7 +2676,7 @@ skip_page(cups_file_t *fp, /* I - File to read from */
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)))
@@ -2724,17 +2695,16 @@ skip_page(cups_file_t *fp, /* I - File to read from */
* 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)
{
@@ -2764,15 +2734,15 @@ start_nup(pstops_doc_t *doc, /* I - Document information */
{
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)
@@ -2793,8 +2763,8 @@ start_nup(pstops_doc_t *doc, /* I - Document information */
{
bboxx = 0;
bboxy = 0;
bboxw = PageWidth;
bboxl = PageLength;
bboxw = (int)PageWidth;
bboxl = (int)PageLength;
}
fprintf(stderr, "DEBUG: pagew = %.1f, pagel = %.1f\n", pagew, pagel);
@@ -3125,7 +3095,7 @@ start_nup(pstops_doc_t *doc, /* I - Document information */
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;
@@ -3365,7 +3335,7 @@ write_options(
{
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 */
+71 -98
Ver Arquivo
@@ -1,44 +1,20 @@
/*
* "$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.
*/
/*
@@ -62,7 +38,7 @@ struct _cups_raster_s /**** Raster stream data ****/
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 */
@@ -81,15 +57,15 @@ struct _cups_raster_s /**** Raster stream data ****/
* 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);
@@ -244,8 +220,7 @@ cupsRasterOpenIO(
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));
@@ -335,13 +310,13 @@ cupsRasterReadPixels(cups_raster_t *r, /* I - Raster stream */
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 ||
@@ -409,7 +384,7 @@ cupsRasterReadPixels(cups_raster_t *r, /* I - Raster stream */
ptr = r->pixels;
temp = ptr;
bytes = cupsBytesPerLine;
bytes = (ssize_t)cupsBytesPerLine;
while (bytes > 0)
{
@@ -426,10 +401,10 @@ cupsRasterReadPixels(cups_raster_t *r, /* I - Raster stream */
* 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);
@@ -444,8 +419,8 @@ cupsRasterReadPixels(cups_raster_t *r, /* I - Raster stream */
*/
count = (byte + 1) * r->bpp;
if (count > bytes)
count = bytes;
if (count > (unsigned)bytes)
count = (unsigned)bytes;
if (count < r->bpp)
break;
@@ -475,7 +450,7 @@ cupsRasterReadPixels(cups_raster_t *r, /* I - Raster stream */
r->header.cupsBitsPerPixel == 12 ||
r->header.cupsBitsPerPixel == 16) &&
r->swapped)
cups_swap(ptr, bytes);
cups_swap(ptr, (size_t)bytes);
/*
* Update pointers...
@@ -483,14 +458,14 @@ cupsRasterReadPixels(cups_raster_t *r, /* I - Raster stream */
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;
}
@@ -508,7 +483,7 @@ cupsRasterReadPixels(cups_raster_t *r, /* I - Raster stream */
*/
if ((unsigned)(bytes = (int)(r->pend - r->pcurrent)) > remaining)
bytes = remaining;
bytes = (ssize_t)remaining;
memcpy(p, r->pcurrent, bytes);
r->pcurrent += bytes;
@@ -521,7 +496,7 @@ cupsRasterReadPixels(cups_raster_t *r, /* I - Raster stream */
}
}
remaining -= bytes;
remaining -= (unsigned)bytes;
p += bytes;
}
@@ -755,7 +730,7 @@ cupsRasterWritePixels(cups_raster_t *r, /* I - Raster stream */
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 */
@@ -817,24 +792,24 @@ cupsRasterWritePixels(cups_raster_t *r, /* I - Raster stream */
* 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)
{
@@ -842,7 +817,7 @@ cupsRasterWritePixels(cups_raster_t *r, /* I - Raster stream */
* 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);
@@ -873,7 +848,7 @@ cupsRasterWritePixels(cups_raster_t *r, /* I - Raster stream */
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)
@@ -913,7 +888,7 @@ cupsRasterWritePixels(cups_raster_t *r, /* I - Raster stream */
r->remaining --;
if (r->remaining == 0)
return (cups_raster_write(r, r->pixels));
return ((unsigned)cups_raster_write(r, r->pixels));
}
}
}
@@ -930,7 +905,7 @@ static unsigned /* O - 1 on success, 0 on fail */
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)
@@ -951,7 +926,7 @@ cups_raster_read_header(
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);
/*
@@ -996,20 +971,20 @@ cups_raster_read_header(
* '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));
@@ -1019,7 +994,7 @@ cups_raster_io(cups_raster_t *r, /* I - Raster stream */
return (-1);
}
return ((int)total);
return (total);
}
@@ -1027,17 +1002,17 @@ cups_raster_io(cups_raster_t *r, /* I - Raster stream */
* '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));
@@ -1046,20 +1021,19 @@ cups_raster_read(cups_raster_t *r, /* I - Raster stream */
* 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);
@@ -1067,7 +1041,7 @@ cups_raster_read(cups_raster_t *r, /* I - Raster stream */
r->buffer = rptr;
r->bufptr = rptr + offset;
r->bufend = rptr + end;
r->bufsize = count;
r->bufsize = (size_t)count;
}
/*
@@ -1075,13 +1049,12 @@ cups_raster_read(cups_raster_t *r, /* I - Raster stream */
*/
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)
{
@@ -1104,7 +1077,7 @@ cups_raster_read(cups_raster_t *r, /* I - Raster stream */
* 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);
@@ -1290,7 +1263,7 @@ cups_raster_update(cups_raster_t *r) /* I - Raster stream */
* '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 */
@@ -1300,7 +1273,7 @@ cups_raster_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 */
@@ -1333,7 +1306,7 @@ cups_raster_write(
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...
@@ -1364,7 +1337,7 @@ cups_raster_write(
if (memcmp(ptr, ptr + bpp, bpp))
break;
*wptr++ = count - 1;
*wptr++ = (unsigned char)(count - 1);
for (count = bpp; count > 0; count --)
*wptr++ = *ptr++;
}
@@ -1384,7 +1357,7 @@ cups_raster_write(
ptr += bpp;
}
*wptr++ = 257 - count;
*wptr++ = (unsigned char)(257 - count);
count *= bpp;
memcpy(wptr, start, count);
@@ -1392,7 +1365,7 @@ cups_raster_write(
}
}
return (cups_raster_io(r, r->buffer, (int)(wptr - r->buffer)));
return (cups_raster_io(r, r->buffer, (size_t)(wptr - r->buffer)));
}
@@ -1428,7 +1401,7 @@ cups_read_fd(void *ctx, /* I - File descriptor as pointer */
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 */
+13 -20
Ver Arquivo
@@ -1,25 +1,18 @@
/*
* "$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.
*/
/*
@@ -181,7 +174,7 @@ get_time(void)
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];
@@ -263,8 +256,8 @@ static void
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];
@@ -295,7 +288,7 @@ write_test(int fd, /* I - File descriptor to write to */
break;
}
data[y][x] = CUPS_RAND();
data[y][x] = (unsigned char)CUPS_RAND();
}
}
+54 -69
Ver Arquivo
@@ -1,28 +1,18 @@
/*
* "$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.
*/
/*
@@ -66,17 +56,17 @@ unsigned char *Planes[6], /* Output buffers */
*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 */
/*
@@ -89,8 +79,8 @@ void EndPage(const cups_page_header2_t *header);
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);
@@ -125,8 +115,8 @@ StartPage(
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 */
/*
@@ -223,15 +213,14 @@ StartPage(
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;
@@ -296,8 +285,7 @@ StartPage(
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);
@@ -398,11 +386,11 @@ CancelJob(int sig) /* I - Signal */
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 */
@@ -509,7 +497,7 @@ CompressData(const unsigned char *line, /* I - Data to compress */
count ++;
}
*comp_ptr++ = 257 - count;
*comp_ptr++ = (unsigned char)(257 - count);
*comp_ptr++ = *line_ptr++;
}
else
@@ -530,7 +518,7 @@ CompressData(const unsigned char *line, /* I - Data to compress */
count ++;
}
*comp_ptr++ = count - 1;
*comp_ptr++ = (unsigned char)(count - 1);
memcpy(comp_ptr, start, count);
comp_ptr += count;
@@ -572,12 +560,12 @@ CompressData(const unsigned char *line, /* I - Data to compress */
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
{
@@ -587,15 +575,15 @@ CompressData(const unsigned char *line, /* I - Data to compress */
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);
}
@@ -610,11 +598,11 @@ OutputLine(
{
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;
@@ -724,10 +712,9 @@ OutputLine(
}
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...
@@ -744,7 +731,7 @@ OutputLine(
*/
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;
/*
@@ -754,14 +741,13 @@ OutputLine(
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 ++;
@@ -778,8 +764,8 @@ OutputRows(
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 */
@@ -788,8 +774,7 @@ OutputRows(
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...
@@ -867,7 +852,7 @@ OutputRows(
break;
}
n = (unsigned)dot_count / DotBytes;
n = dot_count / DotBytes;
putchar(n & 255);
putchar(n / 256);
@@ -958,7 +943,7 @@ main(int argc, /* I - Number of command-line arguments */
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 */
@@ -1090,9 +1075,9 @@ main(int argc, /* I - Number of command-line arguments */
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);
}
+51 -62
Ver Arquivo
@@ -1,29 +1,18 @@
/*
* "$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.
*/
/*
@@ -47,10 +36,10 @@
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? */
@@ -65,7 +54,7 @@ void EndPage(void);
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);
@@ -93,7 +82,7 @@ void
StartPage(ppd_file_t *ppd, /* I - PPD file */
cups_page_header2_t *header) /* I - Page header */
{
int plane; /* Looping var */
unsigned plane; /* Looping var */
/*
@@ -287,33 +276,33 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */
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 */
@@ -321,7 +310,7 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */
}
else
{
printf("\033*t%dR", header->HWResolution[0]);
printf("\033*t%uR", header->HWResolution[0]);
/* Set resolution */
if (header->cupsColorSpace == CUPS_CSPACE_KCMY)
@@ -341,8 +330,8 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */
* 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 */
@@ -356,7 +345,7 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */
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 */
@@ -463,15 +452,15 @@ CancelJob(int sig) /* I - Signal */
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)
@@ -501,7 +490,7 @@ CompressData(unsigned char *line, /* I - Data to compress */
count < 256;
count ++);
comp_ptr[0] = count - 1;
comp_ptr[0] = (unsigned char)(count - 1);
comp_ptr[1] = line_ptr[0];
}
@@ -546,7 +535,7 @@ CompressData(unsigned char *line, /* I - Data to compress */
count ++;
}
*comp_ptr++ = 257 - count;
*comp_ptr++ = (unsigned char)(257 - count);
*comp_ptr++ = *line_ptr++;
}
else
@@ -567,7 +556,7 @@ CompressData(unsigned char *line, /* I - Data to compress */
count ++;
}
*comp_ptr++ = count - 1;
*comp_ptr++ = (unsigned char)(count - 1);
memcpy(comp_ptr, start, count);
comp_ptr += count;
@@ -584,7 +573,7 @@ CompressData(unsigned char *line, /* I - Data to compress */
*/
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);
}
@@ -595,7 +584,7 @@ CompressData(unsigned char *line, /* I - Data to compress */
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 */
@@ -644,15 +633,15 @@ OutputLine(cups_page_header2_t *header) /* I - Page header */
{
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;
@@ -683,7 +672,7 @@ main(int argc, /* I - Number of command-line arguments */
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 */
@@ -814,9 +803,9 @@ main(int argc, /* I - Number of command-line arguments */
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);
}
+56 -64
Ver Arquivo
@@ -1,29 +1,18 @@
/*
* "$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.
*/
/*
@@ -78,10 +67,10 @@
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 */
@@ -93,9 +82,9 @@ void Setup(ppd_file_t *ppd);
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);
/*
@@ -169,7 +158,7 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */
cups_page_header2_t *header) /* I - Page header */
{
ppd_choice_t *choice; /* Marked choice */
int length; /* Actual label length */
unsigned length; /* Actual label length */
/*
@@ -289,7 +278,7 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */
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);
@@ -302,13 +291,13 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */
*/
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 :
@@ -317,13 +306,13 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */
*/
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);
@@ -344,8 +333,8 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */
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 :
@@ -391,14 +380,15 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */
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 */
@@ -409,11 +399,11 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */
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)
{
@@ -424,14 +414,14 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */
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);
}
}
}
@@ -440,12 +430,12 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */
* 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 */
@@ -741,17 +731,19 @@ CancelJob(int sig) /* I - Signal */
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 :
@@ -908,14 +900,14 @@ OutputLine(ppd_file_t *ppd, /* I - PPD file */
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 */
@@ -945,7 +937,7 @@ PCLCompress(unsigned char *line, /* I - Line to compress */
offset = 0;
if ((count = line_end - line_ptr) > 8)
if ((count = (unsigned)(line_end - line_ptr)) > 8)
count = 8;
line_ptr += count;
@@ -966,7 +958,7 @@ PCLCompress(unsigned char *line, /* I - Line to compress */
if (line_ptr == line_end)
break;
offset = line_ptr - start;
offset = (unsigned)(line_ptr - start);
/*
* Find up to 8 non-matching bytes...
@@ -995,7 +987,7 @@ PCLCompress(unsigned char *line, /* I - Line to compress */
* Output multi-byte offset...
*/
*comp_ptr++ = ((count - 1) << 5) | 31;
*comp_ptr++ = (unsigned char)(((count - 1) << 5) | 31);
offset -= 31;
while (offset >= 255)
@@ -1004,7 +996,7 @@ PCLCompress(unsigned char *line, /* I - Line to compress */
offset -= 255;
}
*comp_ptr++ = offset;
*comp_ptr++ = (unsigned char)offset;
}
else
{
@@ -1012,7 +1004,7 @@ PCLCompress(unsigned char *line, /* I - Line to compress */
* Output single-byte offset...
*/
*comp_ptr++ = ((count - 1) << 5) | offset;
*comp_ptr++ = (unsigned char)(((count - 1) << 5) | offset);
}
memcpy(comp_ptr, start, count);
@@ -1024,7 +1016,7 @@ PCLCompress(unsigned char *line, /* I - Line to compress */
*/
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...
@@ -1040,8 +1032,8 @@ PCLCompress(unsigned char *line, /* I - Line to compress */
*/
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)
{
@@ -1062,7 +1054,7 @@ ZPLCompress(char repeat_char, /* I - Character to repeat */
if (repeat_count >= 20)
{
putchar('f' + repeat_count / 20);
putchar((int)('f' + repeat_count / 20));
repeat_count %= 20;
}
@@ -1071,14 +1063,14 @@ ZPLCompress(char repeat_char, /* I - Character to repeat */
*/
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);
}
@@ -1093,7 +1085,7 @@ main(int argc, /* I - Number of command-line arguments */
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 */
@@ -1235,9 +1227,9 @@ main(int argc, /* I - Number of command-line arguments */
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);
}
+21 -29
Ver Arquivo
@@ -1,21 +1,17 @@
/*
* "$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.
*/
/*
@@ -41,9 +37,9 @@ main(int argc, /* I - Number of command-line args */
*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 */
@@ -101,14 +97,10 @@ main(int argc, /* I - Number of command-line args */
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 */
@@ -199,7 +191,7 @@ main(int argc, /* I - Number of command-line args */
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;
@@ -270,7 +262,7 @@ main(int argc, /* I - Number of command-line args */
{
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 -
@@ -286,7 +278,7 @@ main(int argc, /* I - Number of command-line args */
else
{
outheader.cupsInteger[1] = 1; /* CrossFeedTransform */
outheader.cupsInteger[2] = -1;/* FeedTransform */
outheader.cupsInteger[2] = ~0U;/* FeedTransform */
outheader.cupsInteger[3] = page_left;
/* ImageBoxLeft */
@@ -302,8 +294,8 @@ main(int argc, /* I - Number of command-line args */
{
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;
@@ -334,8 +326,8 @@ main(int argc, /* I - Number of command-line args */
{
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;
+25 -35
Ver Arquivo
@@ -1,27 +1,18 @@
/*
* "$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.
*/
/*
@@ -29,6 +20,7 @@
*/
#include <cups/raster-private.h>
#include <math.h>
/*
@@ -172,13 +164,12 @@ static cups_page_header2_t setpagedevice_header =
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 */
@@ -519,7 +510,7 @@ do_ras_file(const char *filename) /* I - Filename */
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 */
@@ -610,7 +601,7 @@ do_raster_tests(cups_mode_t mode) /* O - Write mode */
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))
@@ -636,7 +627,7 @@ do_raster_tests(cups_mode_t mode) /* O - Write mode */
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))
@@ -1020,22 +1011,21 @@ print_changes(
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],
@@ -1048,7 +1038,7 @@ print_changes(
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]);
+10 -24
Ver Arquivo
@@ -1,23 +1,23 @@
#
# "$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
#
@@ -196,20 +196,6 @@ strings2po: strings2po.o
$(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...
#
+9 -13
Ver Arquivo
@@ -1,15 +1,15 @@
/*
* "$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:
*
@@ -18,10 +18,6 @@
* Compile with:
*
* gcc -o po2strings po2strings.c `cups-config --libs`
*
* Contents:
*
* main() - Convert .po file to .strings.
*/
#include <cups/cups-private.h>
@@ -71,7 +67,7 @@ main(int argc, /* I - Number of command-line args */
*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? */
@@ -215,7 +211,7 @@ main(int argc, /* I - Number of command-line args */
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)
+9 -7
Ver Arquivo
@@ -3,6 +3,14 @@
*
* 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
@@ -10,12 +18,6 @@
* 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>
@@ -116,7 +118,7 @@ read_strings(FILE *strings, /* I - .strings file */
char *bufptr; /* Pointer into buffer */
while (fgets(buffer, bufsize, strings))
while (fgets(buffer, (int)bufsize, strings))
{
if (buffer[0] != '\"')
continue;
-439
Ver Arquivo
@@ -1,439 +0,0 @@
/*
* "$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, "&lt;", 4))
{
*bufptr = '<';
_cups_strcpy(bufptr + 1, bufptr + 4);
}
else if (!strncmp(bufptr, "&gt;", 4))
{
*bufptr = '>';
_cups_strcpy(bufptr + 1, bufptr + 4);
}
else if (!strncmp(bufptr, "&amp;", 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$".
*/
+19 -26
Ver Arquivo
@@ -1,24 +1,18 @@
/*
* "$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.
*/
/*
@@ -34,7 +28,7 @@
*/
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);
/*
@@ -151,7 +145,7 @@ main(int argc, /* I - Number of command-line args */
if (psgets(line, &linelen, fp) == NULL)
break;
}
while (pswrite(line, linelen, stdout) > 0);
while (pswrite(line, linelen) > 0);
fflush(stdout);
}
@@ -184,7 +178,7 @@ psgets(char *buf, /* I - Buffer to read into */
bufptr = buf;
ch = EOF;
while ((bufptr - buf) < len)
while ((size_t)(bufptr - buf) < len)
{
if ((ch = getc(fp)) == EOF)
break;
@@ -209,7 +203,7 @@ psgets(char *buf, /* I - Buffer to read into */
else if (ch == '\n')
break;
else
*bufptr++ = ch;
*bufptr++ = (char)ch;
}
/*
@@ -218,8 +212,8 @@ psgets(char *buf, /* I - Buffer to read into */
if (ch == '\n' || ch == '\r')
{
if ((bufptr - buf) < len)
*bufptr++ = ch;
if ((size_t)(bufptr - buf) < len)
*bufptr++ = (char)ch;
else
ungetc(ch, fp);
}
@@ -229,7 +223,7 @@ psgets(char *buf, /* I - Buffer to read into */
*/
*bufptr = '\0';
*bytes = bufptr - buf;
*bytes = (size_t)(bufptr - buf);
if (ch == EOF && bufptr == buf)
return (NULL);
@@ -242,10 +236,9 @@ psgets(char *buf, /* I - Buffer to read into */
* '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 */
@@ -283,7 +276,7 @@ pswrite(const char *buf, /* I - Buffer to write */
break;
}
return (bytes);
return ((ssize_t)bytes);
}
+19 -26
Ver Arquivo
@@ -1,24 +1,18 @@
/*
* "$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.
*/
/*
@@ -34,7 +28,7 @@
*/
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);
/*
@@ -135,7 +129,7 @@ main(int argc, /* I - Number of command-line args */
* 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)
@@ -173,7 +167,7 @@ psgets(char *buf, /* I - Buffer to read into */
bufptr = buf;
ch = EOF;
while ((bufptr - buf) < len)
while ((size_t)(bufptr - buf) < len)
{
if ((ch = getc(fp)) == EOF)
break;
@@ -198,7 +192,7 @@ psgets(char *buf, /* I - Buffer to read into */
else if (ch == '\n')
break;
else
*bufptr++ = ch;
*bufptr++ = (char)ch;
}
/*
@@ -207,8 +201,8 @@ psgets(char *buf, /* I - Buffer to read into */
if (ch == '\n' || ch == '\r')
{
if ((bufptr - buf) < len)
*bufptr++ = ch;
if ((size_t)(bufptr - buf) < len)
*bufptr++ = (char)ch;
else
ungetc(ch, fp);
}
@@ -218,7 +212,7 @@ psgets(char *buf, /* I - Buffer to read into */
*/
*bufptr = '\0';
*bytes = bufptr - buf;
*bytes = (size_t)(bufptr - buf);
if (ch == EOF && bufptr == buf)
return (NULL);
@@ -231,10 +225,9 @@ psgets(char *buf, /* I - Buffer to read into */
* '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 */
@@ -273,7 +266,7 @@ pswrite(const char *buf, /* I - Buffer to write */
break;
}
return (bytes);
return ((ssize_t)bytes);
}
+11 -20
Ver Arquivo
@@ -1,25 +1,16 @@
//
// "$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/".
//
//
@@ -48,7 +39,7 @@ ppdcArray::ppdcArray(ppdcArray *a)
// 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();
@@ -98,7 +89,7 @@ ppdcArray::add(ppdcShared *d)
alloc += 10;
temp = new ppdcShared *[alloc];
memcpy(temp, data, count * sizeof(ppdcShared *));
memcpy(temp, data, (size_t)count * sizeof(ppdcShared *));
delete[] data;
data = temp;
@@ -159,7 +150,7 @@ ppdcArray::remove(ppdcShared *d) // I - Data element
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 *));
}
+24 -37
Ver Arquivo
@@ -1,29 +1,16 @@
//
// "$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/".
//
//
@@ -817,7 +804,7 @@ put_utf8(int ch, // I - Unicode character
if (ptr >= end)
return (-1);
*ptr++ = ch;
*ptr++ = (char)ch;
}
else if (ch < 0x800)
{
@@ -825,8 +812,8 @@ put_utf8(int ch, // I - Unicode character
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)
{
@@ -834,9 +821,9 @@ put_utf8(int ch, // I - Unicode character
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
{
@@ -844,10 +831,10 @@ put_utf8(int ch, // I - Unicode character
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);
@@ -868,8 +855,8 @@ put_utf16(cups_file_t *fp, // I - File to write to
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);
@@ -879,10 +866,10 @@ put_utf16(cups_file_t *fp, // I - File to write to
// 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);

Alguns arquivos não foram exibidos porque demasiados arquivos foram alterados neste diff Mostrar Mais