From 7e86f2f686334cb3db458b4585dfce9c1b712bc4 Mon Sep 17 00:00:00 2001 From: msweet Date: Thu, 6 Feb 2014 18:33:34 +0000 Subject: [PATCH] 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 --- backend/backend-private.h | 20 +- backend/dnssd.c | 48 +-- backend/ieee1284.c | 30 +- backend/ipp.c | 100 +++--- backend/lpd.c | 60 ++-- backend/network.c | 53 ++-- backend/runloop.c | 8 +- backend/snmp-supplies.c | 49 ++- backend/snmp.c | 48 +-- backend/socket.c | 12 +- backend/testbackend.c | 38 ++- backend/usb-darwin.c | 25 +- berkeley/lpc.c | 30 +- berkeley/lpq.c | 9 +- berkeley/lpr.c | 22 +- cgi-bin/Makefile | 16 +- cgi-bin/admin.c | 64 ++-- cgi-bin/classes.c | 26 +- cgi-bin/help-index.c | 44 +-- cgi-bin/ipp-var.c | 59 ++-- cgi-bin/jobs.c | 24 +- cgi-bin/printers.c | 26 +- cgi-bin/search.c | 30 +- cgi-bin/template.c | 45 ++- cgi-bin/testcgi.c | 24 +- cgi-bin/var.c | 101 +++--- cgi-bin/websearch.c | 116 ------- config-scripts/cups-compiler.m4 | 22 +- cups/adminutil.c | 31 +- cups/array.c | 87 ++---- cups/auth.c | 43 +-- cups/backchannel.c | 26 +- cups/conflicts.c | 38 +-- cups/debug.c | 53 ++-- cups/dest-job.c | 32 +- cups/dest-localization.c | 30 +- cups/dest-options.c | 64 +--- cups/dest.c | 119 ++------ cups/emit.c | 43 +-- cups/encode.c | 36 +-- cups/file.c | 101 +++--- cups/getputfile.c | 35 +-- cups/http-addr.c | 19 +- cups/http-addrlist.c | 5 +- cups/http-support.c | 115 +++++-- cups/http.c | 138 ++++----- cups/http.h | 6 +- cups/ipp-private.h | 18 +- cups/ipp-support.c | 21 +- cups/ipp.c | 388 +++++++++-------------- cups/ipp.h | 7 + cups/langprintf.c | 57 ++-- cups/language.c | 70 ++--- cups/localize.c | 59 ++-- cups/mark.c | 45 +-- cups/md5.c | 4 +- cups/options.c | 39 +-- cups/ppd-cache.c | 81 ++--- cups/ppd-private.h | 32 +- cups/ppd.c | 112 ++----- cups/pwg-media.c | 39 +-- cups/request.c | 48 +-- cups/sidechannel.c | 30 +- cups/snmp-private.h | 24 +- cups/snmp.c | 141 ++++----- cups/string.c | 43 +-- cups/testarray.c | 29 +- cups/testcups.c | 30 +- cups/testfile.c | 60 ++-- cups/testhttp.c | 10 +- cups/testi18n.c | 49 ++- cups/testipp.c | 58 ++-- cups/testppd.c | 47 ++- cups/testsnmp.c | 27 +- cups/thread-private.h | 16 +- cups/tls-darwin.c | 22 +- cups/transcode.c | 52 ++-- cups/usersys.c | 4 +- cups/util.c | 64 +--- filter/commandtops.c | 29 +- filter/common.c | 31 +- filter/error.c | 40 +-- filter/gziptoany.c | 26 +- filter/interpret.c | 27 +- filter/pstops.c | 204 ++++++------- filter/raster.c | 169 +++++------ filter/rasterbench.c | 33 +- filter/rastertoepson.c | 123 ++++---- filter/rastertohp.c | 113 ++++--- filter/rastertolabel.c | 120 ++++---- filter/rastertopwg.c | 50 ++- filter/testraster.c | 60 ++-- locale/Makefile | 34 +-- locale/po2strings.c | 22 +- locale/strings2po.c | 16 +- locale/translate.c | 439 --------------------------- monitor/bcp.c | 45 ++- monitor/tbcp.c | 45 ++- ppdc/ppdc-array.cxx | 31 +- ppdc/ppdc-catalog.cxx | 61 ++-- ppdc/ppdc-driver.cxx | 36 +-- ppdc/ppdc-source.cxx | 112 +++---- ppdc/ppdc.cxx | 2 +- ppdc/ppdmerge.cxx | 26 +- scheduler/auth.c | 16 +- scheduler/auth.h | 12 +- scheduler/cert.c | 25 +- scheduler/classes.c | 31 +- scheduler/client.c | 20 +- scheduler/colorman.c | 74 ++--- scheduler/conf.c | 54 +++- scheduler/conf.h | 38 +-- scheduler/cups-deviced.c | 36 +-- scheduler/cups-driverd.cxx | 102 ++----- scheduler/cups-lpd.c | 54 ++-- scheduler/cupsfilter.c | 40 +-- scheduler/dirsvc.c | 48 +-- scheduler/ipp.c | 56 ++-- scheduler/job.c | 65 ++-- scheduler/log.c | 53 ++-- scheduler/main.c | 6 +- scheduler/mime.c | 54 +--- scheduler/printers.c | 44 ++- scheduler/process.c | 30 +- scheduler/select.c | 4 +- scheduler/statbuf.c | 25 +- scheduler/subscriptions.c | 45 +-- scheduler/testlpd.c | 65 ++-- scheduler/testmime.c | 28 +- scheduler/testspeed.c | 25 +- scheduler/testsub.c | 25 +- scheduler/type.c | 82 ++--- scheduler/util.c | 42 +-- scheduler/util.h | 18 +- systemv/cupstestppd.c | 6 +- systemv/lp.c | 24 +- systemv/lpadmin.c | 36 +-- systemv/lpoptions.c | 54 ++-- systemv/lpstat.c | 22 +- test/ippfind.c | 86 +++--- test/ippserver.c | 208 +++++-------- test/ipptool.c | 146 ++++----- vcnet/regex/regcomp.c | 2 +- xcode/CUPS.xcodeproj/project.pbxproj | 115 ++++++- 144 files changed, 2853 insertions(+), 4853 deletions(-) delete mode 100644 cgi-bin/websearch.c delete mode 100644 locale/translate.c diff --git a/backend/backend-private.h b/backend/backend-private.h index 3729bb020..1d211e3ed 100644 --- a/backend/backend-private.h +++ b/backend/backend-private.h @@ -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); diff --git a/backend/dnssd.c b/backend/dnssd.c index 1ac000f37..fad831f7f 100644 --- a/backend/dnssd.c +++ b/backend/dnssd.c @@ -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]) diff --git a/backend/ieee1284.c b/backend/ieee1284.c index bc4b344a6..1b73136bd 100644 --- a/backend/ieee1284.c +++ b/backend/ieee1284.c @@ -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... diff --git a/backend/ipp.c b/backend/ipp.c index 92dd7e06b..c47f44225 100644 --- a/backend/ipp.c +++ b/backend/ipp.c @@ -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 = ","; } diff --git a/backend/lpd.c b/backend/lpd.c index 872fb1cc6..602a516ed 100644 --- a/backend/lpd.c +++ b/backend/lpd.c @@ -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); } diff --git a/backend/network.c b/backend/network.c index 2eadbff77..a09a45dcf 100644 --- a/backend/network.c +++ b/backend/network.c @@ -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'; diff --git a/backend/runloop.c b/backend/runloop.c index 6e717e8cc..2a0ec5f9c 100644 --- a/backend/runloop.c +++ b/backend/runloop.c @@ -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... diff --git a/backend/snmp-supplies.c b/backend/snmp-supplies.c index 0864c2290..7e2142a0b 100644 --- a/backend/snmp-supplies.c +++ b/backend/snmp-supplies.c @@ -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); } diff --git a/backend/snmp.c b/backend/snmp.c index 62fc54327..688997b78 100644 --- a/backend/snmp.c +++ b/backend/snmp.c @@ -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); diff --git a/backend/socket.c b/backend/socket.c index 8b87d8ef9..0c01fbfa7 100644 --- a/backend/socket.c +++ b/backend/socket.c @@ -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); diff --git a/backend/testbackend.c b/backend/testbackend.c index 722859f7f..190e65673 100644 --- a/backend/testbackend.c +++ b/backend/testbackend.c @@ -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'; diff --git a/backend/usb-darwin.c b/backend/usb-darwin.c index c12484268..302ae9816 100644 --- a/backend/usb-darwin.c +++ b/backend/usb-darwin.c @@ -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; diff --git a/berkeley/lpc.c b/berkeley/lpc.c index e8ccb91c0..b2e2e4130 100644 --- a/berkeley/lpc.c +++ b/berkeley/lpc.c @@ -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); diff --git a/berkeley/lpq.c b/berkeley/lpq.c index 595fafdae..323870686 100644 --- a/berkeley/lpq.c +++ b/berkeley/lpq.c @@ -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 @@ -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; diff --git a/berkeley/lpr.c b/berkeley/lpr.c index 4b8957ffe..4bda358d5 100644 --- a/berkeley/lpr.c +++ b/berkeley/lpr.c @@ -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) { diff --git a/cgi-bin/Makefile b/cgi-bin/Makefile index 64b171eaa..42a311a10 100644 --- a/cgi-bin/Makefile +++ b/cgi-bin/Makefile @@ -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... # diff --git a/cgi-bin/admin.c b/cgi-bin/admin.c index 5589c1155..b10180e86 100644 --- a/cgi-bin/admin.c +++ b/cgi-bin/admin.c @@ -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... diff --git a/cgi-bin/classes.c b/cgi-bin/classes.c index 6f2fd58a2..3217bb159 100644 --- a/cgi-bin/classes.c +++ b/cgi-bin/classes.c @@ -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 */ diff --git a/cgi-bin/help-index.c b/cgi-bin/help-index.c index 801f088fd..c63e21cca 100644 --- a/cgi-bin/help-index.c +++ b/cgi-bin/help-index.c @@ -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); } diff --git a/cgi-bin/ipp-var.c b/cgi-bin/ipp-var.c index 38120da08..46fdfab02 100644 --- a/cgi-bin/ipp-var.c +++ b/cgi-bin/ipp-var.c @@ -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), "%s", 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 : diff --git a/cgi-bin/jobs.c b/cgi-bin/jobs.c index e57b0218d..35f913ca3 100644 --- a/cgi-bin/jobs.c +++ b/cgi-bin/jobs.c @@ -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 */ diff --git a/cgi-bin/printers.c b/cgi-bin/printers.c index 37b0f552d..7b9e95556 100644 --- a/cgi-bin/printers.c +++ b/cgi-bin/printers.c @@ -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 */ diff --git a/cgi-bin/search.c b/cgi-bin/search.c index a6abd5978..b475d9600 100644 --- a/cgi-bin/search.c +++ b/cgi-bin/search.c @@ -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); diff --git a/cgi-bin/template.c b/cgi-bin/template.c index cdf1544bb..faa5d598d 100644 --- a/cgi-bin/template.c +++ b/cgi-bin/template.c @@ -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'; diff --git a/cgi-bin/testcgi.c b/cgi-bin/testcgi.c index dfda3d7ea..ca0158298 100644 --- a/cgi-bin/testcgi.c +++ b/cgi-bin/testcgi.c @@ -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... diff --git a/cgi-bin/var.c b/cgi-bin/var.c index 660c8bb3a..90ab8bb52 100644 --- a/cgi-bin/var.c +++ b/cgi-bin/var.c @@ -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 diff --git a/cgi-bin/websearch.c b/cgi-bin/websearch.c deleted file mode 100644 index 351f92db0..000000000 --- a/cgi-bin/websearch.c +++ /dev/null @@ -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$". - */ diff --git a/config-scripts/cups-compiler.m4 b/config-scripts/cups-compiler.m4 index 8d84a4ba3..33c1f47fe 100644 --- a/config-scripts/cups-compiler.m4 +++ b/config-scripts/cups-compiler.m4 @@ -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 diff --git a/cups/adminutil.c b/cups/adminutil.c index a84a5363e..6a50fbea9 100644 --- a/cups/adminutil.c +++ b/cups/adminutil.c @@ -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", diff --git a/cups/array.c b/cups/array.c index 9fbba6205..0f04eab0a 100644 --- a/cups/array.c +++ b/cups/array.c @@ -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"); diff --git a/cups/auth.c b/cups/auth.c index 8efb34b33..f002ea001 100644 --- a/cups/auth.c +++ b/cups/auth.c @@ -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); } diff --git a/cups/backchannel.c b/cups/backchannel.c index 7fa8c97f5..06a6d2308 100644 --- a/cups/backchannel.c +++ b/cups/backchannel.c @@ -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; } } diff --git a/cups/conflicts.c b/cups/conflicts.c index ae048d135..b3bdf529a 100644 --- a/cups/conflicts.c +++ b/cups/conflicts.c @@ -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 " diff --git a/cups/debug.c b/cups/debug.c index 27ade63ca..f1352eeb2 100644 --- a/cups/debug.c +++ b/cups/debug.c @@ -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); } diff --git a/cups/dest-job.c b/cups/dest-job.c index 85009faec..40f041237 100644 --- a/cups/dest-job.c +++ b/cups/dest-job.c @@ -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); diff --git a/cups/dest-localization.c b/cups/dest-localization.c index fefb0f9e2..1bd8324af 100644 --- a/cups/dest-localization.c +++ b/cups/dest-localization.c @@ -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 diff --git a/cups/dest-options.c b/cups/dest-options.c index 4b03189c5..93e1757a4 100644 --- a/cups/dest-options.c +++ b/cups/dest-options.c @@ -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); diff --git a/cups/dest.c b/cups/dest.c index 36481f808..92ce8acd2 100644 --- a/cups/dest.c +++ b/cups/dest.c @@ -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) { diff --git a/cups/emit.c b/cups/emit.c index 777488ff1..759e634c0 100644 --- a/cups/emit.c +++ b/cups/emit.c @@ -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; } diff --git a/cups/encode.c b/cups/encode.c index 9b9efe1fd..81b48fb50 100644 --- a/cups/encode.c +++ b/cups/encode.c @@ -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; diff --git a/cups/file.c b/cups/file.c index 9b1f592a9..5bec683f3 100644 --- a/cups/file.c +++ b/cups/file.c @@ -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; } diff --git a/cups/getputfile.c b/cups/getputfile.c index b4be78ae5..443e0c4f1 100644 --- a/cups/getputfile.c +++ b/cups/getputfile.c @@ -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) diff --git a/cups/http-addr.c b/cups/http-addr.c index 130d0a748..a3a628c54 100644 --- a/cups/http-addr.c +++ b/cups/http-addr.c @@ -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, '.')) diff --git a/cups/http-addrlist.c b/cups/http-addrlist.c index 7047f7d11..bfa519a22 100644 --- a/cups/http-addrlist.c +++ b/cups/http-addrlist.c @@ -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)), diff --git a/cups/http-support.c b/cups/http-support.c index bec268343..c1353514f 100644 --- a/cups/http-support.c +++ b/cups/http-support.c @@ -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)); } diff --git a/cups/http.c b/cups/http.c index bb3a7c3cf..8a4236e0d 100644 --- a/cups/http.c +++ b/cups/http.c @@ -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)); diff --git a/cups/http.h b/cups/http.h index db40b8123..a660ca9f9 100644 --- a/cups/http.h +++ b/cups/http.h @@ -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... diff --git a/cups/ipp-private.h b/cups/ipp-private.h index 3dd6451cc..2d8840842 100644 --- a/cups/ipp-private.h +++ b/cups/ipp-private.h @@ -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_ diff --git a/cups/ipp-support.c b/cups/ipp-support.c index 598f76a20..a6d72987b 100644 --- a/cups/ipp-support.c +++ b/cups/ipp-support.c @@ -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)); } diff --git a/cups/ipp.c b/cups/ipp.c index fc813d658..dafbf9e7b 100644 --- a/cups/ipp.c +++ b/cups/ipp.c @@ -1,124 +1,18 @@ /* * "$Id$" * - * Internet Printing Protocol functions for CUPS. - * - * Copyright 2007-2013 by Apple Inc. - * Copyright 1997-2007 by Easy Software Products, all rights reserved. - * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "LICENSE.txt" - * which should have been included with this file. If this file is - * file is missing or damaged, see the license at "http://www.cups.org/". - * - * This file is subject to the Apple OS-Developed Software exception. - * - * Contents: - * - * _cupsBufferGet() - Get a read/write buffer. - * _cupsBufferRelease() - Release a read/write buffer. - * ippAddBoolean() - Add a boolean attribute to an IPP message. - * ippAddBooleans() - Add an array of boolean values. - * ippAddCollection() - Add a collection value. - * ippAddCollections() - Add an array of collection values. - * ippAddDate() - Add a date attribute to an IPP message. - * ippAddInteger() - Add a integer attribute to an IPP message. - * ippAddIntegers() - Add an array of integer values. - * ippAddOctetString() - Add an octetString value to an IPP message. - * ippAddOutOfBand() - Add an out-of-band value to an IPP message. - * ippAddRange() - Add a range of values to an IPP message. - * ippAddRanges() - Add ranges of values to an IPP message. - * ippAddResolution() - Add a resolution value to an IPP message. - * ippAddResolutions() - Add resolution values to an IPP message. - * ippAddSeparator() - Add a group separator to an IPP message. - * ippAddString() - Add a language-encoded string to an IPP message. - * ippAddStringf() - Add a formatted string to an IPP message. - * ippAddStringfv() - Add a formatted string to an IPP message. - * ippAddStrings() - Add language-encoded strings to an IPP message. - * ippContainsInteger() - Determine whether an attribute contains the - * specified value or is within the list of ranges. - * ippContainsString() - Determine whether an attribute contains the - * specified string value. - * ippCopyAttribute() - Copy an attribute. - * ippCopyAttributes() - Copy attributes from one IPP message to another. - * ippDateToTime() - Convert from RFC 1903 Date/Time format to UNIX - * time in seconds. - * ippDelete() - Delete an IPP message. - * ippDeleteAttribute() - Delete a single attribute in an IPP message. - * ippDeleteValues() - Delete values in an attribute. - * ippFindAttribute() - Find a named attribute in a request. - * ippFindNextAttribute() - Find the next named attribute in a request. - * ippFirstAttribute() - Return the first attribute in the message. - * ippGetBoolean() - Get a boolean value for an attribute. - * ippGetCollection() - Get a collection value for an attribute. - * ippGetCount() - Get the number of values in an attribute. - * ippGetDate() - Get a date value for an attribute. - * ippGetGroupTag() - Get the group associated with an attribute. - * ippGetInteger() - Get the integer/enum value for an attribute. - * ippGetName() - Get the attribute name. - * ippGetOctetString() - Get an octetString value from an IPP attribute. - * ippGetOperation() - Get the operation ID in an IPP message. - * ippGetRange() - Get a rangeOfInteger value from an attribute. - * ippGetRequestId() - Get the request ID from an IPP message. - * ippGetResolution() - Get a resolution value for an attribute. - * ippGetState() - Get the IPP message state. - * ippGetStatusCode() - Get the status code from an IPP response or - * event message. - * ippGetString() - Get the string and optionally the language code - * for an attribute. - * ippGetValueTag() - Get the value tag for an attribute. - * ippGetVersion() - Get the major and minor version number from an - * IPP message. - * ippLength() - Compute the length of an IPP message. - * ippNextAttribute() - Return the next attribute in the message. - * ippNew() - Allocate a new IPP message. - * ippNewRequest() - Allocate a new IPP request message. - * ippNewResponse() - Allocate a new IPP response message. - * ippRead() - Read data for an IPP message from a HTTP - * connection. - * ippReadFile() - Read data for an IPP message from a file. - * ippReadIO() - Read data for an IPP message. - * ippSetBoolean() - Set a boolean value in an attribute. - * ippSetCollection() - Set a collection value in an attribute. - * ippSetDate() - Set a date value in an attribute. - * ippSetGroupTag() - Set the group tag of an attribute. - * ippSetInteger() - Set an integer or enum value in an attribute. - * ippSetName() - Set the name of an attribute. - * ippSetOctetString() - Set an octetString value in an IPP attribute. - * ippSetOperation() - Set the operation ID in an IPP request message. - * ippSetRange() - Set a rangeOfInteger value in an attribute. - * ippSetRequestId() - Set the request ID in an IPP message. - * ippSetResolution() - Set a resolution value in an attribute. - * ippSetState() - Set the current state of the IPP message. - * ippSetStatusCode() - Set the status code in an IPP response or event - * message. - * ippSetString() - Set a string value in an attribute. - * ippSetStringf() - Set a formatted string value of an attribute. - * ippSetStringf() - Set a formatted string value of an attribute. - * ippSetValueTag() - Set the value tag of an attribute. - * ippSetVersion() - Set the version number in an IPP message. - * ippTimeToDate() - Convert from UNIX time to RFC 1903 format. - * ippValidateAttribute() - Validate the contents of an attribute. - * ippValidateAttributes() - Validate all attributes in an IPP message. - * ippWrite() - Write data for an IPP message to a HTTP - * connection. - * ippWriteFile() - Write data for an IPP message to a file. - * ippWriteIO() - Write data for an IPP message. - * ipp_add_attr() - Add a new attribute to the message. - * ipp_free_values() - Free attribute values. - * ipp_get_code() - Convert a C locale/charset name into an IPP - * language/charset code. - * ipp_lang_code() - Convert a C locale name into an IPP language - * code. - * ipp_length() - Compute the length of an IPP message or - * collection value. - * ipp_read_http() - Semi-blocking read on a HTTP connection... - * ipp_read_file() - Read IPP data from a file. - * ipp_set_error() - Set a formatted, localized error string. - * ipp_set_value() - Get the value element from an attribute, - * expanding it as needed. - * ipp_write_file() - Write IPP data to a file. + * Internet Printing Protocol functions for CUPS. + * + * Copyright 2007-2014 by Apple Inc. + * Copyright 1997-2007 by Easy Software Products, all rights reserved. + * + * These coded instructions, statements, and computer programs are the + * property of Apple Inc. and are protected by Federal copyright + * law. Distribution and use rights are outlined in the file "LICENSE.txt" + * which should have been included with this file. If this file is + * file is missing or damaged, see the license at "http://www.cups.org/". + * + * This file is subject to the Apple OS-Developed Software exception. */ /* @@ -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) { diff --git a/cups/ipp.h b/cups/ipp.h index 1a930d7ea..b9268816a 100644 --- a/cups/ipp.h +++ b/cups/ipp.h @@ -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... diff --git a/cups/langprintf.c b/cups/langprintf.c index f63a473f7..f5f92a948 100644 --- a/cups/langprintf.c +++ b/cups/langprintf.c @@ -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)); diff --git a/cups/language.c b/cups/language.c index e201038eb..fdc06cba1 100644 --- a/cups/language.c +++ b/cups/language.c @@ -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); diff --git a/cups/localize.c b/cups/localize.c index 13f44c018..4c702acdf 100644 --- a/cups/localize.c +++ b/cups/localize.c @@ -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 ++) diff --git a/cups/mark.c b/cups/mark.c index b44a31a92..18d0ede55 100644 --- a/cups/mark.c +++ b/cups/mark.c @@ -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; /* diff --git a/cups/md5.c b/cups/md5.c index 843890d4d..0e1eaaafa 100644 --- a/cups/md5.c +++ b/cups/md5.c @@ -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]++; diff --git a/cups/options.c b/cups/options.c index 14b88c959..073edaee9 100644 --- a/cups/options.c +++ b/cups/options.c @@ -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)); } /* diff --git a/cups/ppd-cache.c b/cups/ppd-cache.c index e13e73ab8..64e9d3a6e 100644 --- a/cups/ppd-cache.c +++ b/cups/ppd-cache.c @@ -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 diff --git a/cups/ppd-private.h b/cups/ppd-private.h index c6c25325b..9e890e9ed 100644 --- a/cups/ppd-private.h +++ b/cups/ppd-private.h @@ -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_ diff --git a/cups/ppd.c b/cups/ppd.c index 6813ea0e6..d1f9cadf9 100644 --- a/cups/ppd.c +++ b/cups/ppd.c @@ -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) { diff --git a/cups/pwg-media.c b/cups/pwg-media.c index 87ed7b724..ca0ed8fc5 100644 --- a/cups/pwg-media.c +++ b/cups/pwg-media.c @@ -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); /* diff --git a/cups/request.c b/cups/request.c index 0ccb49965..2f909f392 100644 --- a/cups/request.c +++ b/cups/request.c @@ -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... diff --git a/cups/sidechannel.c b/cups/sidechannel.c index f4aeb18d0..d7638372d 100644 --- a/cups/sidechannel.c +++ b/cups/sidechannel.c @@ -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); diff --git a/cups/snmp-private.h b/cups/snmp-private.h index 49f5b60fa..604456191 100644 --- a/cups/snmp-private.h +++ b/cups/snmp-private.h @@ -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]; diff --git a/cups/snmp.c b/cups/snmp.c index 143563ef4..a291e8a82 100644 --- a/cups/snmp.c +++ b/cups/snmp.c @@ -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 < 0) - { - /* - * Disallow negative lengths! - */ + if (length > (unsigned)(bufend - *buffer)) + length = (unsigned)(bufend - *buffer); - *string = '\0'; - } - else if (length < strsize) + if (length < strsize) { /* * String is smaller than the buffer... @@ -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) diff --git a/cups/string.c b/cups/string.c index 7a862f661..0bc0690c5 100644 --- a/cups/string.c +++ b/cups/string.c @@ -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); diff --git a/cups/testarray.c b/cups/testarray.c index d3e677427..dc90951ba 100644 --- a/cups/testarray.c +++ b/cups/testarray.c @@ -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' || diff --git a/cups/testcups.c b/cups/testcups.c index b4b79569c..74d0660bf 100644 --- a/cups/testcups.c +++ b/cups/testcups.c @@ -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 diff --git a/cups/testfile.c b/cups/testfile.c index e3b44638b..8555e079d 100644 --- a/cups/testfile.c +++ b/cups/testfile.c @@ -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); diff --git a/cups/testhttp.c b/cups/testhttp.c index a197a2e4b..1a7b30443 100644 --- a/cups/testhttp.c +++ b/cups/testhttp.c @@ -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); diff --git a/cups/testi18n.c b/cups/testi18n.c index 84645a859..e478428bd 100644 --- a/cups/testi18n.c +++ b/cups/testi18n.c @@ -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); diff --git a/cups/testipp.c b/cups/testipp.c index c96a4b05b..abb56036b 100644 --- a/cups/testipp.c +++ b/cups/testipp.c @@ -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); } diff --git a/cups/testppd.c b/cups/testppd.c index aee7db465..dd94b003f 100644 --- a/cups/testppd.c +++ b/cups/testppd.c @@ -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, diff --git a/cups/testsnmp.c b/cups/testsnmp.c index f1498c834..66e2d76ee 100644 --- a/cups/testsnmp.c +++ b/cups/testsnmp.c @@ -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; diff --git a/cups/thread-private.h b/cups/thread-private.h index b16eec187..5bc441cde 100644 --- a/cups/thread-private.h +++ b/cups/thread-private.h @@ -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) diff --git a/cups/tls-darwin.c b/cups/tls-darwin.c index 33a70cd5b..0344a8b14 100644 --- a/cups/tls-darwin.c +++ b/cups/tls-darwin.c @@ -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) { diff --git a/cups/transcode.c b/cups/transcode.c index 380807f95..8245aa3ea 100644 --- a/cups/transcode.c +++ b/cups/transcode.c @@ -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)... diff --git a/cups/usersys.c b/cups/usersys.c index 16617e900..5dbf1e99a 100644 --- a/cups/usersys.c +++ b/cups/usersys.c @@ -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)) { diff --git a/cups/util.c b/cups/util.c index 8b3070917..0b6c289a4 100644 --- a/cups/util.c +++ b/cups/util.c @@ -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... diff --git a/filter/commandtops.c b/filter/commandtops.c index fd8e35a02..3f7691565 100644 --- a/filter/commandtops.c +++ b/filter/commandtops.c @@ -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 ... diff --git a/filter/common.c b/filter/common.c index b80f4d5b5..3d45a2037 100644 --- a/filter/common.c +++ b/filter/common.c @@ -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) { diff --git a/filter/error.c b/filter/error.c index c1cd0d3b1..26d8511d4 100644 --- a/filter/error.c +++ b/filter/error.c @@ -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 */ diff --git a/filter/gziptoany.c b/filter/gziptoany.c index a1b1e2b84..6744c3bfa 100644 --- a/filter/gziptoany.c +++ b/filter/gziptoany.c @@ -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"), diff --git a/filter/interpret.c b/filter/interpret.c index 307ad37d4..4b0a43e1a 100644 --- a/filter/interpret.c +++ b/filter/interpret.c @@ -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 != '>') diff --git a/filter/pstops.c b/filter/pstops.c index 2230a8b61..bbaf758fb 100644 --- a/filter/pstops.c +++ b/filter/pstops.c @@ -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 */ diff --git a/filter/raster.c b/filter/raster.c index 801129e60..d9658d710 100644 --- a/filter/raster.c +++ b/filter/raster.c @@ -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 */ diff --git a/filter/rasterbench.c b/filter/rasterbench.c index 69e139d37..572a928a8 100644 --- a/filter/rasterbench.c +++ b/filter/rasterbench.c @@ -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(); } } diff --git a/filter/rastertoepson.c b/filter/rastertoepson.c index 8257fec5b..3996dd808 100644 --- a/filter/rastertoepson.c +++ b/filter/rastertoepson.c @@ -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); } diff --git a/filter/rastertohp.c b/filter/rastertohp.c index ee6358ba9..42d43c8f5 100644 --- a/filter/rastertohp.c +++ b/filter/rastertohp.c @@ -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); } diff --git a/filter/rastertolabel.c b/filter/rastertolabel.c index f5d80256a..bcd5ca1d9 100644 --- a/filter/rastertolabel.c +++ b/filter/rastertolabel.c @@ -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); } diff --git a/filter/rastertopwg.c b/filter/rastertopwg.c index 622aa605a..0116fb173 100644 --- a/filter/rastertopwg.c +++ b/filter/rastertopwg.c @@ -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; diff --git a/filter/testraster.c b/filter/testraster.c index 8920e2e77..d2f152dba 100644 --- a/filter/testraster.c +++ b/filter/testraster.c @@ -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 +#include /* @@ -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]); diff --git a/locale/Makefile b/locale/Makefile index 1a977101b..4b0cc81b4 100644 --- a/locale/Makefile +++ b/locale/Makefile @@ -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... # diff --git a/locale/po2strings.c b/locale/po2strings.c index 754a487b4..fd869a77b 100644 --- a/locale/po2strings.c +++ b/locale/po2strings.c @@ -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 @@ -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) diff --git a/locale/strings2po.c b/locale/strings2po.c index 8df9059be..7e714b4b1 100644 --- a/locale/strings2po.c +++ b/locale/strings2po.c @@ -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 @@ -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; diff --git a/locale/translate.c b/locale/translate.c deleted file mode 100644 index 13228d27a..000000000 --- a/locale/translate.c +++ /dev/null @@ -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 -#include - - -/* - * 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, "
')) == NULL) - { - /* - * textarea doesn't end, abort! - */ - - puts("DIV SHORT DATA!"); - ret = 0; - break; - } - - bufptr ++; - - if ((bufend = strstr(bufptr, "
")) == NULL) - { - /* - * textarea doesn't close, abort! - */ - - puts("/DIV SHORT DATA!"); - ret = 0; - break; - } - - *bufend = '\0'; - - /* - * Copy the translation... - */ - - m->str = strdup(bufptr); - - /* - * Convert character entities to regular chars... - */ - - for (bufptr = strchr(m->str, '&'); - bufptr; - bufptr = strchr(bufptr + 1, '&')) - { - if (!strncmp(bufptr, "<", 4)) - { - *bufptr = '<'; - _cups_strcpy(bufptr + 1, bufptr + 4); - } - else if (!strncmp(bufptr, ">", 4)) - { - *bufptr = '>'; - _cups_strcpy(bufptr + 1, bufptr + 4); - } - else if (!strncmp(bufptr, "&", 5)) - _cups_strcpy(bufptr + 1, bufptr + 5); - } - - printf("\"%s\"\n", m->str); - } - else if (status == HTTP_ERROR) - { - printf("NETWORK ERROR (%s)!\n", strerror(httpError(http))); - ret = 0; - break; - } - else - { - printf("HTTP ERROR %d!\n", status); - ret = 0; - break; - } - } - - httpClose(http); - - return (ret); -} - - -/* - * 'write_string()' - Write a quoted string to a file. - */ - -int /* O - 1 on success, 0 on failure */ -write_string(cups_file_t *fp, /* I - File to write to */ - const char *s) /* I - String */ -{ - while (*s) - { - switch (*s) - { - case '\n' : - if (cupsFilePuts(fp, "\\n") < 0) - return (0); - break; - - case '\r' : - if (cupsFilePuts(fp, "\\r") < 0) - return (0); - break; - - case '\t' : - if (cupsFilePuts(fp, "\\t") < 0) - return (0); - break; - - case '\\' : - if (cupsFilePuts(fp, "\\\\") < 0) - return (0); - break; - - case '\"' : - if (cupsFilePuts(fp, "\\\"") < 0) - return (0); - break; - - default : - if ((*s & 255) < ' ') - { - if (cupsFilePrintf(fp, "\\%o", *s) < 0) - return (0); - } - else if (cupsFilePutChar(fp, *s) < 0) - return (0); - break; - } - - s ++; - } - - return (1); -} - - -/* - * End of "$Id$". - */ diff --git a/monitor/bcp.c b/monitor/bcp.c index 2354d102d..885805243 100644 --- a/monitor/bcp.c +++ b/monitor/bcp.c @@ -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); } diff --git a/monitor/tbcp.c b/monitor/tbcp.c index 9ed1e00e7..e37635a70 100644 --- a/monitor/tbcp.c +++ b/monitor/tbcp.c @@ -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); } diff --git a/ppdc/ppdc-array.cxx b/ppdc/ppdc-array.cxx index 33d8bf773..688f56c46 100644 --- a/ppdc/ppdc-array.cxx +++ b/ppdc/ppdc-array.cxx @@ -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 *)); } diff --git a/ppdc/ppdc-catalog.cxx b/ppdc/ppdc-catalog.cxx index f709d75e1..1bf46566f 100644 --- a/ppdc/ppdc-catalog.cxx +++ b/ppdc/ppdc-catalog.cxx @@ -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); diff --git a/ppdc/ppdc-driver.cxx b/ppdc/ppdc-driver.cxx index 6459a33a6..f70da0096 100644 --- a/ppdc/ppdc-driver.cxx +++ b/ppdc/ppdc-driver.cxx @@ -1,34 +1,16 @@ // // "$Id$" // -// PPD file compiler definitions for the CUPS PPD Compiler. +// PPD file compiler definitions for the CUPS PPD Compiler. // -// Copyright 2007-2011 by Apple Inc. -// Copyright 2002-2006 by Easy Software Products. +// Copyright 2007-2014 by Apple Inc. +// Copyright 2002-2006 by Easy Software Products. // -// These coded instructions, statements, and computer programs are the -// property of Apple Inc. and are protected by Federal copyright -// law. Distribution and use rights are outlined in the file "LICENSE.txt" -// which should have been included with this file. If this file is -// file is missing or damaged, see the license at "http://www.cups.org/". -// -// Contents: -// -// ppdcDriver::ppdcDriver() - Create a new printer driver. -// ppdcDriver::~ppdcDriver() - Destroy a printer driver. -// ppdcDriver::find_attr() - Find an attribute. -// ppdcDriver::find_group() - Find a group. -// ppdcDriver::find_option() - Find an option. -// ppdcDriver::find_option_group() - Find an option and its group. -// ppdcDriver::set_custom_size_code() - Set the custom page size code. -// ppdcDriver::set_default_font() - Set the default font name. -// ppdcDriver::set_default_size() - Set the default size name. -// ppdcDriver::set_file_name() - Set the full filename. -// ppdcDriver::set_manufacturer() - Set the manufacturer name. -// ppdcDriver::set_model_name() - Set the model name. -// ppdcDriver::set_pc_file_name() - Set the PC filename. -// ppdcDriver::set_version() - Set the version string. -// ppdcDriver::write_ppd_file() - Write a PPD file... +// These coded instructions, statements, and computer programs are the +// property of Apple Inc. and are protected by Federal copyright +// law. Distribution and use rights are outlined in the file "LICENSE.txt" +// which should have been included with this file. If this file is +// file is missing or damaged, see the license at "http://www.cups.org/". // // @@ -1333,7 +1315,7 @@ ppdcDriver::write_ppd_file( fn->status == PPDC_FONT_ROM ? "ROM" : "Disk", lf); cupsFilePrintf(fp, "*%% End of %s, %05d bytes.%s", pc_file_name->value, - (int)(cupsFileTell(fp) + 25 + strlen(pc_file_name->value)), + (int)((size_t)cupsFileTell(fp) + 25 + strlen(pc_file_name->value)), lf); if (delete_cat) diff --git a/ppdc/ppdc-source.cxx b/ppdc/ppdc-source.cxx index 222ccfd25..988e9dd22 100644 --- a/ppdc/ppdc-source.cxx +++ b/ppdc/ppdc-source.cxx @@ -1,59 +1,16 @@ // // "$Id$" // -// Source class for the CUPS PPD Compiler. -// -// Copyright 2007-2013 by Apple Inc. -// Copyright 2002-2007 by Easy Software Products. -// -// These coded instructions, statements, and computer programs are the -// property of Apple Inc. and are protected by Federal copyright -// law. Distribution and use rights are outlined in the file "LICENSE.txt" -// which should have been included with this file. If this file is -// file is missing or damaged, see the license at "http://www.cups.org/". -// -// Contents: -// -// ppdcSource::ppdcSource() - Load a driver source file. -// ppdcSource::~ppdcSource() - Free a driver source file. -// ppdcSource::add_include() - Add an include directory. -// ppdcSource::find_driver() - Find a driver. -// ppdcSource::find_include() - Find an include file. -// ppdcSource::find_po() - Find a message catalog for the given -// locale. -// ppdcSource::find_size() - Find a media size. -// ppdcSource::find_variable() - Find a variable. -// ppdcSource::get_attr() - Get an attribute. -// ppdcSource::get_boolean() - Get a boolean value. -// ppdcSource::get_choice() - Get a choice. -// ppdcSource::get_color_model() - Get an old-style color model option. -// ppdcSource::get_color_order() - Get an old-style color order value. -// ppdcSource::get_color_profile() - Get a color profile definition. -// ppdcSource::get_color_space() - Get an old-style colorspace value. -// ppdcSource::get_constraint() - Get a constraint. -// ppdcSource::get_custom_size() - Get a custom media size definition from -// a file. -// ppdcSource::get_duplex() - Get a duplex option. -// ppdcSource::get_filter() - Get a filter. -// ppdcSource::get_float() - Get a single floating-point number. -// ppdcSource::get_font() - Get a font definition. -// ppdcSource::get_generic() - Get a generic old-style option. -// ppdcSource::get_group() - Get an option group. -// ppdcSource::get_installable() - Get an installable option. -// ppdcSource::get_integer() - Get an integer value from a file. -// ppdcSource::get_measurement() - Get a measurement value. -// ppdcSource::get_option() - Get an option definition. -// ppdcSource::get_po() - Get a message catalog. -// ppdcSource::get_resolution() - Get an old-style resolution option. -// ppdcSource::get_simple_profile() - Get a simple color profile definition. -// ppdcSource::get_size() - Get a media size definition from a file. -// ppdcSource::get_token() - Get a token from a file. -// ppdcSource::get_variable() - Get a variable definition. -// ppdcSource::quotef() - Write a formatted, quoted string... -// ppdcSource::read_file() - Read a driver source file. -// ppdcSource::scan_file() - Scan a driver source file. -// ppdcSource::set_variable() - Set a variable. -// ppdcSource::write_file() - Write the current source data to a file. +// Source class for the CUPS PPD Compiler. +// +// Copyright 2007-2014 by Apple Inc. +// Copyright 2002-2007 by Easy Software Products. +// +// These coded instructions, statements, and computer programs are the +// property of Apple Inc. and are protected by Federal copyright +// law. Distribution and use rights are outlined in the file "LICENSE.txt" +// which should have been included with this file. If this file is +// file is missing or damaged, see the license at "http://www.cups.org/". // // @@ -235,9 +192,9 @@ ppdcSource::find_include( { // Check for the local file relative to the current directory... if (base && *base && f[0] != '/') - snprintf(n, nlen, "%s/%s", base, f); + snprintf(n, (size_t)nlen, "%s/%s", base, f); else - strlcpy(n, f, nlen); + strlcpy(n, f, (size_t)nlen); if (!access(n, 0)) return (n); @@ -253,7 +210,7 @@ ppdcSource::find_include( { for (dir = (ppdcString *)includes->first(); dir; dir = (ppdcString *)includes->next()) { - snprintf(n, nlen, "%s/%s", dir->value, f); + snprintf(n, (size_t)nlen, "%s/%s", dir->value, f); if (!access(n, 0)) return (n); } @@ -262,11 +219,11 @@ ppdcSource::find_include( // Search the standard include directories... _cups_globals_t *cg = _cupsGlobals(); // Global data - snprintf(n, nlen, "%s/ppdc/%s", cg->cups_datadir, f); + snprintf(n, (size_t)nlen, "%s/ppdc/%s", cg->cups_datadir, f); if (!access(n, 0)) return (n); - snprintf(n, nlen, "%s/po/%s", cg->cups_datadir, f); + snprintf(n, (size_t)nlen, "%s/po/%s", cg->cups_datadir, f); if (!access(n, 0)) return (n); else @@ -1810,26 +1767,26 @@ ppdcSource::get_resolution(ppdcFile *fp)// I - File to read if (color_order >= 0) { - snprintf(commptr, sizeof(command) - (commptr - command), + snprintf(commptr, sizeof(command) - (size_t)(commptr - command), "/cupsColorOrder %d", color_order); commptr += strlen(commptr); } if (color_space >= 0) { - snprintf(commptr, sizeof(command) - (commptr - command), + snprintf(commptr, sizeof(command) - (size_t)(commptr - command), "/cupsColorSpace %d", color_space); commptr += strlen(commptr); } if (compression >= 0) { - snprintf(commptr, sizeof(command) - (commptr - command), + snprintf(commptr, sizeof(command) - (size_t)(commptr - command), "/cupsCompression %d", compression); commptr += strlen(commptr); } - snprintf(commptr, sizeof(command) - (commptr - command), ">>setpagedevice"); + snprintf(commptr, sizeof(command) - (size_t)(commptr - command), ">>setpagedevice"); // Return the new choice... return (new ppdcChoice(name, text, command)); @@ -2014,7 +1971,7 @@ ppdcSource::get_token(ppdcFile *fp, // I - File to read if (!isalnum(ch) && ch != '_') break; else if (nameptr < (name + sizeof(name) - 1)) - *nameptr++ = fp->get(); + *nameptr++ = (char)fp->get(); } if (nameptr == name) @@ -2024,7 +1981,7 @@ ppdcSource::get_token(ppdcFile *fp, // I - File to read { // $$ = $ if (bufptr < bufend) - *bufptr++ = fp->get(); + *bufptr++ = (char)fp->get(); } else { @@ -2044,7 +2001,7 @@ ppdcSource::get_token(ppdcFile *fp, // I - File to read var = find_variable(name); if (var) { - strlcpy(bufptr, var->value->value, bufend - bufptr + 1); + strlcpy(bufptr, var->value->value, (size_t)(bufend - bufptr + 1)); bufptr += strlen(bufptr); } else @@ -2054,7 +2011,7 @@ ppdcSource::get_token(ppdcFile *fp, // I - File to read _("ppdc: Undefined variable (%s) on line %d of " "%s."), name, fp->line, fp->filename); - snprintf(bufptr, bufend - bufptr + 1, "$%s", name); + snprintf(bufptr, (size_t)(bufend - bufptr + 1), "$%s", name); bufptr += strlen(bufptr); } } @@ -2096,7 +2053,7 @@ ppdcSource::get_token(ppdcFile *fp, // I - File to read empty = 0; if (bufptr < bufend) - *bufptr++ = ch; + *bufptr++ = (char)ch; } } else if (ch == '\'' || ch == '\"') @@ -2112,7 +2069,7 @@ ppdcSource::get_token(ppdcFile *fp, // I - File to read { // Insert the opposing quote char... if (bufptr < bufend) - *bufptr++ = ch; + *bufptr++ = (char)ch; } else { @@ -2128,14 +2085,14 @@ ppdcSource::get_token(ppdcFile *fp, // I - File to read startline = fp->line; if (bufptr < bufend) - *bufptr++ = ch; + *bufptr++ = (char)ch; } else if ((ch == ')' && quote == '(') || (ch == '>' && quote == '<')) { quote = 0; if (bufptr < bufend) - *bufptr++ = ch; + *bufptr++ = (char)ch; } else if (ch == '\\') { @@ -2145,13 +2102,13 @@ ppdcSource::get_token(ppdcFile *fp, // I - File to read break; if (bufptr < bufend) - *bufptr++ = ch; + *bufptr++ = (char)ch; } else if (bufptr < bufend) { empty = 0; - *bufptr++ = ch; + *bufptr++ = (char)ch; if ((ch == '{' || ch == '}') && !quote) break; @@ -2171,7 +2128,6 @@ ppdcSource::get_token(ppdcFile *fp, // I - File to read else { *bufptr = '\0'; -// puts(buffer); return (buffer); } } @@ -2292,7 +2248,7 @@ ppdcSource::quotef(cups_file_t *fp, // I - File to write to if ((format - bufformat + 1) > (int)sizeof(tformat)) break; - memcpy(tformat, bufformat, format - bufformat); + memcpy(tformat, bufformat, (size_t)(format - bufformat)); tformat[format - bufformat] = '\0'; bytes += cupsFilePrintf(fp, tformat, va_arg(ap, double)); @@ -2309,7 +2265,7 @@ ppdcSource::quotef(cups_file_t *fp, // I - File to write to if ((format - bufformat + 1) > (int)sizeof(tformat)) break; - memcpy(tformat, bufformat, format - bufformat); + memcpy(tformat, bufformat, (size_t)(format - bufformat)); tformat[format - bufformat] = '\0'; # ifdef HAVE_LONG_LONG @@ -2327,7 +2283,7 @@ ppdcSource::quotef(cups_file_t *fp, // I - File to write to if ((format - bufformat + 1) > (int)sizeof(tformat)) break; - memcpy(tformat, bufformat, format - bufformat); + memcpy(tformat, bufformat, (size_t)(format - bufformat)); tformat[format - bufformat] = '\0'; bytes += cupsFilePrintf(fp, tformat, va_arg(ap, void *)); @@ -2341,7 +2297,7 @@ ppdcSource::quotef(cups_file_t *fp, // I - File to write to } else { - cupsFileWrite(fp, va_arg(ap, char *), width); + cupsFileWrite(fp, va_arg(ap, char *), (size_t)width); bytes += width; } break; @@ -2350,7 +2306,7 @@ ppdcSource::quotef(cups_file_t *fp, // I - File to write to if ((s = va_arg(ap, char *)) == NULL) s = (char *)"(nil)"; - slen = strlen(s); + slen = (int)strlen(s); if (slen > width && prec != width) width = slen; diff --git a/ppdc/ppdc.cxx b/ppdc/ppdc.cxx index b302c8aca..9074df173 100644 --- a/ppdc/ppdc.cxx +++ b/ppdc/ppdc.cxx @@ -344,7 +344,7 @@ main(int argc, // I - Number of command-line arguments for (j = 0; outname[j] && j < (int)(sizeof(pcfilename) - 1); j ++) - pcfilename[j] = tolower(outname[j] & 255); + pcfilename[j] = (char)tolower(outname[j] & 255); pcfilename[j] = '\0'; } diff --git a/ppdc/ppdmerge.cxx b/ppdc/ppdmerge.cxx index 68f291673..8c4863e11 100644 --- a/ppdc/ppdmerge.cxx +++ b/ppdc/ppdmerge.cxx @@ -1,22 +1,16 @@ // // "$Id$" // -// PPD file merge utility for the CUPS PPD Compiler. +// PPD file merge utility for the CUPS PPD Compiler. // -// Copyright 2007-2011 by Apple Inc. -// Copyright 2002-2007 by Easy Software Products. +// Copyright 2007-2014 by Apple Inc. +// Copyright 2002-2007 by Easy Software Products. // -// These coded instructions, statements, and computer programs are the -// property of Apple Inc. and are protected by Federal copyright -// law. Distribution and use rights are outlined in the file "LICENSE.txt" -// which should have been included with this file. If this file is -// file is missing or damaged, see the license at "http://www.cups.org/". -// -// Contents: -// -// main() - Main entry for the PPD merge utility. -// ppd_locale() - Return the locale associated with a PPD file. -// usage() - Show usage and exit. +// These coded instructions, statements, and computer programs are the +// property of Apple Inc. and are protected by Federal copyright +// law. Distribution and use rights are outlined in the file "LICENSE.txt" +// which should have been included with this file. If this file is +// file is missing or damaged, see the license at "http://www.cups.org/". // // @@ -302,8 +296,8 @@ main(int argc, // I - Number of command-line arguments static const char * // O - Locale string ppd_locale(ppd_file_t *ppd) // I - PPD file { - int i, // Looping var - vlen; // Length of LanguageVersion string + int i; // Looping var + size_t vlen; // Length of LanguageVersion string static char locale[255]; // Locale string static struct // LanguageVersion translation table { diff --git a/scheduler/auth.c b/scheduler/auth.c index 9e5642ef8..4c78cbb64 100644 --- a/scheduler/auth.c +++ b/scheduler/auth.c @@ -991,11 +991,11 @@ cupsdAuthorize(cupsd_client_t *con) /* I - Client connection */ * Decode the authorization string to get the input token... */ - len = strlen(authorization); - input_token.value = malloc(len); + len = (int)strlen(authorization); + input_token.value = malloc((size_t)len); input_token.value = httpDecode64_2(input_token.value, &len, authorization); - input_token.length = len; + input_token.length = (size_t)len; /* * Accept the input token to get the authorization info... @@ -1135,7 +1135,7 @@ int /* O - 1 if allowed, 0 otherwise */ cupsdCheckAccess( unsigned ip[4], /* I - Client address */ const char *name, /* I - Client hostname */ - int namelen, /* I - Length of hostname */ + size_t namelen, /* I - Length of hostname */ cupsd_location_t *loc) /* I - Location to check */ { int allow; /* 1 if allowed, 0 otherwise */ @@ -1194,7 +1194,7 @@ cupsdCheckAccess( int /* O - 1 if mask matches, 0 otherwise */ cupsdCheckAuth(unsigned ip[4], /* I - Client address */ const char *name, /* I - Client hostname */ - int name_len, /* I - Length of hostname */ + size_t name_len, /* I - Length of hostname */ cups_array_t *masks) /* I - Masks */ { int i; /* Looping var */ @@ -1596,7 +1596,7 @@ cupsdFindBest(const char *path, /* I - Resource path */ *uriptr; /* Pointer into URI */ cupsd_location_t *loc, /* Current location */ *best; /* Best match for location so far */ - int bestlen; /* Length of best match */ + size_t bestlen; /* Length of best match */ int limit; /* Limit field */ static const int limits[] = /* Map http_status_t to CUPSD_AUTH_LIMIT_xyz */ { @@ -1747,7 +1747,7 @@ cupsdIsAuthorized(cupsd_client_t *con, /* I - Connection */ /* Client hostname */ unsigned address[4]; /* Authorization address */ cupsd_location_t *best; /* Best match for location so far */ - int hostlen; /* Length of hostname */ + size_t hostlen; /* Length of hostname */ char *name, /* Current username */ username[256], /* Username to authorize */ ownername[256], /* Owner name to authorize */ @@ -2444,7 +2444,7 @@ pam_func( * Allocate memory for the responses... */ - if ((replies = malloc(sizeof(struct pam_response) * num_msg)) == NULL) + if ((replies = malloc(sizeof(struct pam_response) * (size_t)num_msg)) == NULL) return (PAM_CONV_ERR); /* diff --git a/scheduler/auth.h b/scheduler/auth.h index ef5bd401e..64c99746c 100644 --- a/scheduler/auth.h +++ b/scheduler/auth.h @@ -3,7 +3,7 @@ * * Authorization definitions for the CUPS scheduler. * - * Copyright 2007-2013 by Apple Inc. + * Copyright 2007-2014 by Apple Inc. * Copyright 1997-2006 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the @@ -74,7 +74,7 @@ typedef struct typedef struct { - int length; /* Length of name */ + size_t length; /* Length of name */ char *name; /* Name string */ } cupsd_namemask_t; @@ -91,9 +91,9 @@ typedef struct typedef struct { char *location; /* Location of resource */ + size_t length; /* Length of location string */ ipp_op_t op; /* IPP operation */ int limit, /* Limit for these types of requests */ - length, /* Length of location string */ order_type, /* Allow or Deny */ type, /* Type of authentication */ level, /* Access level required */ @@ -130,10 +130,8 @@ extern void cupsdAddLocation(cupsd_location_t *loc); extern void cupsdAddName(cupsd_location_t *loc, char *name); extern int cupsdAddNameMask(cups_array_t **masks, char *name); extern void cupsdAuthorize(cupsd_client_t *con); -extern int cupsdCheckAccess(unsigned ip[4], const char *name, - int namelen, cupsd_location_t *loc); -extern int cupsdCheckAuth(unsigned ip[4], const char *name, int namelen, - cups_array_t *masks); +extern int cupsdCheckAccess(unsigned ip[4], const char *name, size_t namelen, cupsd_location_t *loc); +extern int cupsdCheckAuth(unsigned ip[4], const char *name, size_t namelen, cups_array_t *masks); extern int cupsdCheckGroup(const char *username, struct passwd *user, const char *groupname); diff --git a/scheduler/cert.c b/scheduler/cert.c index a2f8ff4f9..f86a3cf9c 100644 --- a/scheduler/cert.c +++ b/scheduler/cert.c @@ -1,25 +1,16 @@ /* * "$Id$" * - * Authentication certificate routines for the CUPS scheduler. + * Authentication certificate routines for the CUPS scheduler. * - * Copyright 2007-2012 by Apple Inc. - * Copyright 1997-2006 by Easy Software Products. + * Copyright 2007-2014 by Apple Inc. + * Copyright 1997-2006 by Easy Software Products. * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "LICENSE.txt" - * which should have been included with this file. If this file is - * file is missing or damaged, see the license at "http://www.cups.org/". - * - * Contents: - * - * cupsdAddCert() - Add a certificate. - * cupsdDeleteCert() - Delete a single certificate. - * cupsdDeleteAllCerts() - Delete all certificates... - * cupsdFindCert() - Find a certificate. - * cupsdInitCerts() - Initialize the certificate "system" and root - * certificate. + * These coded instructions, statements, and computer programs are the + * property of Apple Inc. and are protected by Federal copyright + * law. Distribution and use rights are outlined in the file "LICENSE.txt" + * which should have been included with this file. If this file is + * file is missing or damaged, see the license at "http://www.cups.org/". */ /* diff --git a/scheduler/classes.c b/scheduler/classes.c index 5ced554f5..788d5a944 100644 --- a/scheduler/classes.c +++ b/scheduler/classes.c @@ -1,27 +1,16 @@ /* * "$Id$" * - * Printer class routines for the CUPS scheduler. + * Printer class routines for the CUPS scheduler. * - * Copyright 2007-2011 by Apple Inc. - * Copyright 1997-2007 by Easy Software Products, all rights reserved. + * Copyright 2007-2014 by Apple Inc. + * Copyright 1997-2007 by Easy Software Products, all rights reserved. * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "LICENSE.txt" - * which should have been included with this file. If this file is - * file is missing or damaged, see the license at "http://www.cups.org/". - * - * Contents: - * - * cupsdAddClass() - Add a class to the system. - * cupsdAddPrinterToClass() - Add a printer to a class... - * cupsdDeletePrinterFromClass() - Delete a printer from a class. - * cupsdDeletePrinterFromClasses() - Delete a printer from all classes. - * cupsdFindAvailablePrinter() - Find an available printer in a class. - * cupsdFindClass() - Find the named class. - * cupsdLoadAllClasses() - Load classes from the classes.conf file. - * cupsdSaveAllClasses() - Save classes to the classes.conf file. + * These coded instructions, statements, and computer programs are the + * property of Apple Inc. and are protected by Federal copyright + * law. Distribution and use rights are outlined in the file "LICENSE.txt" + * which should have been included with this file. If this file is + * file is missing or damaged, see the license at "http://www.cups.org/". */ /* @@ -93,7 +82,7 @@ cupsdAddPrinterToClass( if (c->num_printers == 0) temp = malloc(sizeof(cupsd_printer_t *)); else - temp = realloc(c->printers, sizeof(cupsd_printer_t *) * (c->num_printers + 1)); + temp = realloc(c->printers, sizeof(cupsd_printer_t *) * (size_t)(c->num_printers + 1)); if (temp == NULL) { @@ -147,7 +136,7 @@ cupsdDeletePrinterFromClass( c->num_printers --; if (i < c->num_printers) memmove(c->printers + i, c->printers + i + 1, - (c->num_printers - i) * sizeof(cupsd_printer_t *)); + (size_t)(c->num_printers - i) * sizeof(cupsd_printer_t *)); } else return (0); diff --git a/scheduler/client.c b/scheduler/client.c index dffcf99f0..eac78f3cb 100644 --- a/scheduler/client.c +++ b/scheduler/client.c @@ -1739,7 +1739,7 @@ cupsdReadClient(cupsd_client_t *con) /* I - Client to read from */ httpSetField(con->http, HTTP_FIELD_LAST_MODIFIED, httpGetDateString(filestats.st_mtime)); - httpSetLength(con->http, filestats.st_size); + httpSetLength(con->http, (size_t)filestats.st_size); if (!cupsdSendHeader(con, HTTP_STATUS_OK, line, CUPSD_AUTH_NONE)) { @@ -1783,7 +1783,7 @@ cupsdReadClient(cupsd_client_t *con) /* I - Client to read from */ { con->bytes += bytes; - if (write(con->file, line, bytes) < bytes) + if (write(con->file, line, (size_t)bytes) < bytes) { cupsdLogClient(con, CUPSD_LOG_ERROR, "Unable to write %d bytes to \"%s\": %s", bytes, @@ -1941,7 +1941,7 @@ cupsdReadClient(cupsd_client_t *con) /* I - Client to read from */ { con->bytes += bytes; - if (write(con->file, line, bytes) < bytes) + if (write(con->file, line, (size_t)bytes) < bytes) { cupsdLogClient(con, CUPSD_LOG_ERROR, "Unable to write %d bytes to \"%s\": %s", @@ -2355,7 +2355,7 @@ cupsdSendHeader( size_t auth_size; /* Size of remaining buffer */ auth_key = auth_str + strlen(auth_str); - auth_size = sizeof(auth_str) - (auth_key - auth_str); + auth_size = sizeof(auth_str) - (size_t)(auth_key - auth_str); for (name = (char *)cupsArrayFirst(con->best->names); name; @@ -2553,7 +2553,7 @@ cupsdWriteClient(cupsd_client_t *con) /* I - Client connection */ CUPS_LLCAST httpGetLength2(con->http)); } else if ((bytes = read(con->file, con->header + con->header_used, - sizeof(con->header) - con->header_used)) > 0) + sizeof(con->header) - (size_t)con->header_used)) > 0) { con->header_used += bytes; @@ -2671,7 +2671,7 @@ cupsdWriteClient(cupsd_client_t *con) /* I - Client connection */ if (con->header_used > 0) { - if (httpWrite2(con->http, con->header, con->header_used) < 0) + if (httpWrite2(con->http, con->header, (size_t)con->header_used) < 0) { cupsdLogClient(con, CUPSD_LOG_DEBUG, "Closing for error %d (%s)", httpError(con->http), strerror(httpError(con->http))); @@ -3110,7 +3110,7 @@ install_cupsd_conf(cupsd_client_t *con) /* I - Connection */ */ while ((bytes = cupsFileRead(in, buffer, sizeof(buffer))) > 0) - if (cupsFileWrite(out, buffer, bytes) < bytes) + if (cupsFileWrite(out, buffer, (size_t)bytes) < bytes) { cupsdLogClient(con, CUPSD_LOG_ERROR, "Unable to copy to config file \"%s\": %s", @@ -3482,9 +3482,9 @@ pipe_command(cupsd_client_t *con, /* I - Client connection */ */ if (commptr[1] >= '0' && commptr[1] <= '9') - *commptr = (commptr[1] - '0') << 4; + *commptr = (char)((commptr[1] - '0') << 4); else - *commptr = (tolower(commptr[1]) - 'a' + 10) << 4; + *commptr = (char)((tolower(commptr[1]) - 'a' + 10) << 4); if (commptr[2] >= '0' && commptr[2] <= '9') *commptr |= commptr[2] - '0'; @@ -3939,7 +3939,7 @@ write_file(cupsd_client_t *con, /* I - Client connection */ httpClearFields(con->http); - httpSetLength(con->http, filestats->st_size); + httpSetLength(con->http, (size_t)filestats->st_size); httpSetField(con->http, HTTP_FIELD_LAST_MODIFIED, httpGetDateString(filestats->st_mtime)); diff --git a/scheduler/colorman.c b/scheduler/colorman.c index d43fd398b..992ac2eff 100644 --- a/scheduler/colorman.c +++ b/scheduler/colorman.c @@ -1,22 +1,22 @@ /* * "$Id$" * - * Color management routines for the CUPS scheduler. + * Color management routines for the CUPS scheduler. * - * Copyright 2007-2013 by Apple Inc. - * Copyright 1997-2007 by Easy Software Products, all rights reserved. + * Copyright 2007-2014 by Apple Inc. + * Copyright 1997-2007 by Easy Software Products, all rights reserved. * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "LICENSE.txt" - * which should have been included with this file. If this file is - * file is missing or damaged, see the license at "http://www.cups.org/". + * These coded instructions, statements, and computer programs are the + * property of Apple Inc. and are protected by Federal copyright + * law. Distribution and use rights are outlined in the file "LICENSE.txt" + * which should have been included with this file. If this file is + * file is missing or damaged, see the license at "http://www.cups.org/". * - * Original DBUS/colord code is Copyright 2011 Red Hat, Inc. + * Original DBUS/colord code is Copyright 2011 Red Hat, Inc. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. @@ -25,40 +25,18 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Contents: - * - * cupsdRegisterColor() - Register vendor color profiles in a PPD - * file. - * cupsdStartColor() - Initialize color management. - * cupsdStopColor() - Shutdown color management. - * cupsdUnregisterColor() - Unregister vendor color profiles in a PPD - * file. - * apple_init_profile() - Initialize a color profile. - * apple_register_profiles() - Register color profiles for a printer. - * apple_unregister_profiles() - Remove color profiles for the specified - * printer. - * colord_create_device() - Create a device and register profiles. - * colord_create_profile() - Create a color profile for a printer. - * colord_delete_device() - Delete a device - * colord_device_add_profile() - Assign a profile to a device. - * colord_dict_add_strings() - Add two strings to a dictionary. - * colord_find_device() - Finds a device - * colord_get_qualifier_format() - Get the qualifier format. - * colord_register_printer() - Register profiles for a printer. - * colord_unregister_printer() - Unregister profiles for a printer. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. */ /* @@ -327,9 +305,7 @@ apple_init_profile( if (iccfile && *iccfile) { - url = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, - (const UInt8 *)iccfile, - strlen(iccfile), false); + url = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, (const UInt8 *)iccfile, (CFIndex)strlen(iccfile), false); if (url) { diff --git a/scheduler/conf.c b/scheduler/conf.c index 3d20b3af2..ebd065b76 100644 --- a/scheduler/conf.c +++ b/scheduler/conf.c @@ -47,7 +47,8 @@ typedef enum CUPSD_VARTYPE_TIME, /* Time interval option */ CUPSD_VARTYPE_STRING, /* String option */ CUPSD_VARTYPE_BOOLEAN, /* Boolean option */ - CUPSD_VARTYPE_PATHNAME /* File/directory name option */ + CUPSD_VARTYPE_PATHNAME, /* File/directory name option */ + CUPSD_VARTYPE_PERM /* File/directory permissions */ } cupsd_vartype_t; typedef struct @@ -129,13 +130,13 @@ static const cupsd_var_t cupsfiles_vars[] = { { "AccessLog", &AccessLog, CUPSD_VARTYPE_STRING }, { "CacheDir", &CacheDir, CUPSD_VARTYPE_STRING }, - { "ConfigFilePerm", &ConfigFilePerm, CUPSD_VARTYPE_INTEGER }, + { "ConfigFilePerm", &ConfigFilePerm, CUPSD_VARTYPE_PERM }, { "DataDir", &DataDir, CUPSD_VARTYPE_STRING }, { "DocumentRoot", &DocumentRoot, CUPSD_VARTYPE_STRING }, { "ErrorLog", &ErrorLog, CUPSD_VARTYPE_STRING }, { "FileDevice", &FileDevice, CUPSD_VARTYPE_BOOLEAN }, { "FontPath", &FontPath, CUPSD_VARTYPE_STRING }, - { "LogFilePerm", &LogFilePerm, CUPSD_VARTYPE_INTEGER }, + { "LogFilePerm", &LogFilePerm, CUPSD_VARTYPE_PERM }, { "LPDConfigFile", &LPDConfigFile, CUPSD_VARTYPE_STRING }, { "PageLog", &PageLog, CUPSD_VARTYPE_STRING }, { "Printcap", &Printcap, CUPSD_VARTYPE_STRING }, @@ -224,9 +225,9 @@ int /* O - 0 on success, -1 on error, 1 on warning */ cupsdCheckPermissions( const char *filename, /* I - File/directory name */ const char *suffix, /* I - Additional file/directory name */ - int mode, /* I - Permissions */ - int user, /* I - Owner */ - int group, /* I - Group */ + mode_t mode, /* I - Permissions */ + uid_t user, /* I - Owner */ + gid_t group, /* I - Group */ int is_dir, /* I - 1 = directory, 0 = file */ int create_dir) /* I - 1 = create directory, -1 = create w/o logging, 0 = not */ { @@ -1502,7 +1503,7 @@ cupsdReadConfiguration(void) if (!mimeType(MimeDatabase, "application", "octet-stream")) NumMimeTypes ++; - if ((MimeTypes = calloc(NumMimeTypes, sizeof(const char *))) == NULL) + if ((MimeTypes = calloc((size_t)NumMimeTypes, sizeof(const char *))) == NULL) { cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to allocate memory for %d MIME types.", @@ -2677,6 +2678,41 @@ parse_variable( } break; + case CUPSD_VARTYPE_PERM : + if (!value) + { + cupsdLogMessage(CUPSD_LOG_ERROR, + "Missing permissions value for %s on line %d of %s.", + line, linenum, filename); + return (0); + } + else if (!isdigit(*value & 255)) + { + /* TODO: Add chmod UGO syntax support */ + cupsdLogMessage(CUPSD_LOG_ERROR, + "Bad permissions value for %s on line %d of %s.", + line, linenum, filename); + return (0); + } + else + { + int n = strtol(value, NULL, 8); + /* Permissions value */ + + if (n < 0) + { + cupsdLogMessage(CUPSD_LOG_ERROR, + "Bad negative permissions value for %s on line %d of " + "%s.", line, linenum, filename); + return (0); + } + else + { + *((mode_t *)var->ptr) = (mode_t)n; + } + } + break; + case CUPSD_VARTYPE_TIME : if (!value) { @@ -3344,7 +3380,7 @@ read_cups_files_conf(cups_file_t *fp) /* I - File to read from */ */ if (isdigit(value[0])) - Group = atoi(value); + Group = (gid_t)atoi(value); else { endgrent(); @@ -3419,7 +3455,7 @@ read_cups_files_conf(cups_file_t *fp) /* I - File to read from */ return (0); } else - User = atoi(value); + User = (uid_t)atoi(value); } else { diff --git a/scheduler/conf.h b/scheduler/conf.h index 000fb8f92..949eb8bbe 100644 --- a/scheduler/conf.h +++ b/scheduler/conf.h @@ -1,16 +1,16 @@ /* * "$Id$" * - * Configuration file definitions for the CUPS scheduler. + * Configuration file definitions for the CUPS scheduler. * - * Copyright 2007-2013 by Apple Inc. - * Copyright 1997-2007 by Easy Software Products, all rights reserved. + * Copyright 2007-2014 by Apple Inc. + * Copyright 1997-2007 by Easy Software Products, all rights reserved. * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "LICENSE.txt" - * which should have been included with this file. If this file is - * file is missing or damaged, see the license at "http://www.cups.org/". + * These coded instructions, statements, and computer programs are the + * property of Apple Inc. and are protected by Federal copyright + * law. Distribution and use rights are outlined in the file "LICENSE.txt" + * which should have been included with this file. If this file is + * file is missing or damaged, see the license at "http://www.cups.org/". */ @@ -148,25 +148,27 @@ VAR char *AccessLog VALUE(NULL), /* Remote root user */ *Classification VALUE(NULL); /* Classification of system */ -VAR uid_t User VALUE(1); +VAR uid_t User VALUE(1), /* User ID for server */ + RunUser VALUE(0); + /* User to run as, used for files */ VAR gid_t Group VALUE(0); /* Group ID for server */ VAR cupsd_accesslog_t AccessLogLevel VALUE(CUPSD_ACCESSLOG_ACTIONS); /* Access log level */ VAR int ClassifyOverride VALUE(0), /* Allow overrides? */ - ConfigFilePerm VALUE(0640), - /* Permissions for config files */ LogDebugHistory VALUE(200), /* Amount of automatic debug history */ FatalErrors VALUE(CUPSD_FATAL_CONFIG), /* Which errors are fatal? */ StrictConformance VALUE(FALSE), /* Require strict IPP conformance? */ - SyncOnClose VALUE(FALSE), + SyncOnClose VALUE(FALSE); /* Call fsync() when closing files? */ - LogFilePerm VALUE(0644); +VAR mode_t ConfigFilePerm VALUE(0640U), + /* Permissions for config files */ + LogFilePerm VALUE(0644U); /* Permissions for log files */ VAR cupsd_loglevel_t LogLevel VALUE(CUPSD_LOG_WARN); /* Error log level */ @@ -202,8 +204,6 @@ VAR int MaxClients VALUE(100), /* Timeout before reload from SIGHUP */ RootCertDuration VALUE(300), /* Root certificate update interval */ - RunUser VALUE(0), - /* User to run as, used for files */ PrintcapFormat VALUE(PRINTCAP_BSD), /* Format of printcap file? */ DefaultShared VALUE(TRUE), @@ -258,8 +258,8 @@ gss_cred_id_t ServerCreds; /* Server's GSS credentials */ extern void cupsdAddAlias(cups_array_t *aliases, const char *name); extern int cupsdCheckLogFile(cups_file_t **lf, const char *logname); extern int cupsdCheckPermissions(const char *filename, - const char *suffix, int mode, - int user, int group, int is_dir, + const char *suffix, mode_t mode, + uid_t user, gid_t group, int is_dir, int create_dir); extern int cupsdCheckProgram(const char *filename, cupsd_printer_t *p); extern int cupsdDefaultAuthType(void); @@ -271,8 +271,8 @@ extern int cupsdLogClient(cupsd_client_t *con, int level, extern void cupsdLogFCMessage(void *context, _cups_fc_result_t result, const char *message); #ifdef HAVE_GSSAPI -extern int cupsdLogGSSMessage(int level, int major_status, - int minor_status, +extern int cupsdLogGSSMessage(int level, OM_uint32 major_status, + OM_uint32 minor_status, const char *message, ...); #endif /* HAVE_GSSAPI */ extern int cupsdLogJob(cupsd_job_t *job, int level, const char *message, diff --git a/scheduler/cups-deviced.c b/scheduler/cups-deviced.c index 0cd5b8ea8..2127937f2 100644 --- a/scheduler/cups-deviced.c +++ b/scheduler/cups-deviced.c @@ -1,27 +1,16 @@ /* * "$Id$" * - * Device scanning mini-daemon for CUPS. + * Device scanning mini-daemon for CUPS. * - * Copyright 2007-2011 by Apple Inc. - * Copyright 1997-2006 by Easy Software Products. + * Copyright 2007-2014 by Apple Inc. + * Copyright 1997-2006 by Easy Software Products. * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "LICENSE.txt" - * which should have been included with this file. If this file is - * file is missing or damaged, see the license at "http://www.cups.org/". - * - * Contents: - * - * main() - Scan for devices and return an IPP response. - * add_device() - Add a new device to the list. - * compare_devices() - Compare device names to eliminate duplicates. - * get_current_time() - Get the current time as a double value in seconds. - * get_device() - Get a device from a backend. - * process_children() - Process all dead children... - * sigchld_handler() - Handle 'child' signals from old processes. - * start_backend() - Run a backend to gather the available devices. + * These coded instructions, statements, and computer programs are the + * property of Apple Inc. and are protected by Federal copyright + * law. Distribution and use rights are outlined in the file "LICENSE.txt" + * which should have been included with this file. If this file is + * file is missing or damaged, see the license at "http://www.cups.org/". */ /* @@ -82,7 +71,7 @@ static cupsd_backend_t backends[MAX_BACKENDS]; static struct pollfd backend_fds[MAX_BACKENDS]; /* Array for poll() */ static cups_array_t *devices; /* Array of devices */ -static int normal_user; /* Normal user ID */ +static uid_t normal_user; /* Normal user ID */ static int device_limit; /* Maximum number of devices */ static int send_class, /* Send device-class attribute? */ send_info, /* Send device-info attribute? */ @@ -182,7 +171,7 @@ main(int argc, /* I - Number of command-line args */ return (1); } - normal_user = atoi(argv[4]); + normal_user = (uid_t)atoi(argv[4]); if (normal_user <= 0) { fprintf(stderr, "ERROR: [cups-deviced] Bad user %d!\n", normal_user); @@ -309,7 +298,7 @@ main(int argc, /* I - Number of command-line args */ timeout = (int)(1000 * (end_time - current_time)); - if (poll(backend_fds, num_backends, timeout) > 0) + if (poll(backend_fds, (nfds_t)num_backends, timeout) > 0) { for (i = 0; i < num_backends; i ++) if (backend_fds[i].revents && backends[i].pipe) @@ -326,8 +315,7 @@ main(int argc, /* I - Number of command-line args */ break; } } - while (bpipe->ptr && - memchr(bpipe->ptr, '\n', bpipe->end - bpipe->ptr)); + while (bpipe->ptr && memchr(bpipe->ptr, '\n', (size_t)(bpipe->end - bpipe->ptr))); } } diff --git a/scheduler/cups-driverd.cxx b/scheduler/cups-driverd.cxx index 49aabf60c..c6e4b17e5 100644 --- a/scheduler/cups-driverd.cxx +++ b/scheduler/cups-driverd.cxx @@ -1,48 +1,20 @@ /* * "$Id$" * - * PPD/driver support for CUPS. + * PPD/driver support for CUPS. * - * This program handles listing and installing static PPD files, PPD files - * created from driver information files, and dynamically generated PPD files - * using driver helper programs. + * This program handles listing and installing static PPD files, PPD files + * created from driver information files, and dynamically generated PPD files + * using driver helper programs. * - * Copyright 2007-2012 by Apple Inc. - * Copyright 1997-2007 by Easy Software Products. + * Copyright 2007-2014 by Apple Inc. + * Copyright 1997-2007 by Easy Software Products. * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "LICENSE.txt" - * which should have been included with this file. If this file is - * file is missing or damaged, see the license at "http://www.cups.org/". - * - * Contents: - * - * main() - Scan for drivers and return an IPP response. - * add_ppd() - Add a PPD file. - * cat_drv() - Generate a PPD from a driver info file. - * cat_ppd() - Copy a PPD file to stdout. - * copy_static() - Copy a static PPD file to stdout. - * cat_tar() - Copy an archived PPD file to stdout. - * compare_inodes() - Compare two inodes. - * compare_matches() - Compare PPD match scores for sorting. - * compare_names() - Compare PPD filenames for sorting. - * compare_ppds() - Compare PPD file make and model names for sorting. - * dump_ppds_dat() - Dump the contents of the ppds.dat file. - * free_array() - Free an array of strings. - * get_file() - Get the filename associated with a request. - * list_ppds() - List PPD files. - * load_drv() - Load the PPDs from a driver information file. - * load_drivers() - Load driver-generated PPD files. - * load_ppd() - Load a PPD file. - * load_ppds() - Load PPD files recursively. - * load_ppds_dat() - Load the ppds.dat file. - * load_tar() - Load archived PPD files. - * read_tar() - Read a file header from an archive. - * regex_device_id() - Compile a regular expression based on the 1284 device - * ID. - * regex_string() - Construct a regular expression to compare a simple - * string. + * These coded instructions, statements, and computer programs are the + * property of Apple Inc. and are protected by Federal copyright + * law. Distribution and use rights are outlined in the file "LICENSE.txt" + * which should have been included with this file. If this file is + * file is missing or damaged, see the license at "http://www.cups.org/". */ /* @@ -291,7 +263,7 @@ add_ppd(const char *filename, /* I - PPD filename */ ppd->found = 1; ppd->record.mtime = mtime; - ppd->record.size = size; + ppd->record.size = (off_t)size; ppd->record.model_number = model_number; ppd->record.type = type; @@ -674,7 +646,7 @@ cat_tar(const char *name, /* I - PPD name */ if ((size_t)(bytes = (curinfo.st_size - total)) > sizeof(buffer)) bytes = sizeof(buffer); - if ((bytes = cupsFileRead(fp, buffer, bytes)) < 0) + if ((bytes = cupsFileRead(fp, buffer, (size_t)bytes)) < 0) { if (errno == EINTR || errno == EAGAIN) { @@ -686,7 +658,7 @@ cat_tar(const char *name, /* I - PPD name */ break; } } - else if (bytes > 0 && fwrite(buffer, bytes, 1, stdout) != 1) + else if (bytes > 0 && fwrite(buffer, (size_t)bytes, 1, stdout) != 1) break; } @@ -1053,8 +1025,6 @@ list_ppds(int request_id, /* I - Request ID */ *type_str; /* ppd-type option */ int model_number, /* ppd-model-number value */ type, /* ppd-type value */ - make_and_model_len, /* Length of ppd-make-and-model */ - product_len, /* Length of ppd-product */ send_device_id, /* Send ppd-device-id? */ send_make, /* Send ppd-make? */ send_make_and_model, /* Send ppd-make-and-model? */ @@ -1065,6 +1035,8 @@ list_ppds(int request_id, /* I - Request ID */ send_psversion, /* Send ppd-psversion? */ send_type, /* Send ppd-type? */ sent_header; /* Sent the IPP header? */ + size_t make_and_model_len, /* Length of ppd-make-and-model */ + product_len; /* Length of ppd-product */ regex_t *device_id_re, /* Regular expression for matching device ID */ *make_and_model_re; /* Regular expression for matching make and model */ regmatch_t re_matches[6]; /* Regular expression matches */ @@ -1385,7 +1357,7 @@ list_ppds(int request_id, /* I - Request ID */ // See how much of the make-and-model string we matched... if (re_matches[0].rm_so == 0) { - if (re_matches[0].rm_eo == make_and_model_len) + if ((size_t)re_matches[0].rm_eo == make_and_model_len) ppd->matches += 3; // Exact match else ppd->matches += 2; // Prefix match @@ -1637,8 +1609,7 @@ load_drv(const char *filename, /* I - Actual filename */ * Add a dummy entry for the file... */ - add_ppd(name, name, "", "", "", "", "", "", mtime, size, 0, - PPD_TYPE_DRV, "drv"); + add_ppd(name, name, "", "", "", "", "", "", mtime, (size_t)size, 0, PPD_TYPE_DRV, "drv"); ChangedPPD = 1; /* @@ -1696,14 +1667,10 @@ load_drv(const char *filename, /* I - Actual filename */ if (!strcmp(product->name->value, "Product")) { if (!products_found) - ppd = add_ppd(name, uri, "en", d->manufacturer->value, make_model, - device_id ? device_id->value->value : "", - product->value->value, - ps_version ? ps_version->value->value : "(3010) 0", - mtime, size, d->model_number, type, "drv"); + ppd = add_ppd(name, uri, "en", d->manufacturer->value, make_model, device_id ? device_id->value->value : "", product->value->value, + ps_version ? ps_version->value->value : "(3010) 0", mtime, (size_t)size, d->model_number, type, "drv"); else if (products_found < PPD_MAX_PROD) - strlcpy(ppd->record.products[products_found], product->value->value, - sizeof(ppd->record.products[0])); + strlcpy(ppd->record.products[products_found], product->value->value, sizeof(ppd->record.products[0])); else break; @@ -1711,11 +1678,7 @@ load_drv(const char *filename, /* I - Actual filename */ } if (!products_found) - add_ppd(name, uri, "en", d->manufacturer->value, make_model, - device_id ? device_id->value->value : "", - d->model_name->value, - ps_version ? ps_version->value->value : "(3010) 0", - mtime, size, d->model_number, type, "drv"); + add_ppd(name, uri, "en", d->manufacturer->value, make_model, device_id ? device_id->value->value : "", d->model_name->value, ps_version ? ps_version->value->value : "(3010) 0", mtime, (size_t)size, d->model_number, type, "drv"); } src->release(); @@ -1810,7 +1773,7 @@ load_drivers(cups_array_t *include, /* I - Drivers to include */ scheme_end = scheme + strlen(scheme) - 1; if ((scheme_end > scheme && *scheme_end == '*' && - !strncmp(scheme, dent->filename, scheme_end - scheme)) || + !strncmp(scheme, dent->filename, (size_t)(scheme_end - scheme))) || !strcmp(scheme, dent->filename)) { fputs("DEBUG: [cups-driverd] Yes, exclude!\n", stderr); @@ -1837,7 +1800,7 @@ load_drivers(cups_array_t *include, /* I - Drivers to include */ scheme_end = scheme + strlen(scheme) - 1; if ((scheme_end > scheme && *scheme_end == '*' && - !strncmp(scheme, dent->filename, scheme_end - scheme)) || + !strncmp(scheme, dent->filename, (size_t)(scheme_end - scheme))) || !strcmp(scheme, dent->filename)) { fputs("DEBUG: [cups-driverd] Yes, include!\n", stderr); @@ -2307,11 +2270,7 @@ load_ppd(const char *filename, /* I - Real filename */ fprintf(stderr, "DEBUG2: [cups-driverd] Adding ppd \"%s\"...\n", name); - ppd = add_ppd(name, name, lang_version, manufacturer, make_model, - device_id, (char *)cupsArrayFirst(products), - (char *)cupsArrayFirst(psversions), - fileinfo->st_mtime, fileinfo->st_size, - model_number, type, scheme); + ppd = add_ppd(name, name, lang_version, manufacturer, make_model, device_id, (char *)cupsArrayFirst(products), (char *)cupsArrayFirst(psversions), fileinfo->st_mtime, (size_t)fileinfo->st_size, model_number, type, scheme); if (!ppd) return; @@ -2634,13 +2593,11 @@ load_ppds_dat(char *filename, /* I - Filename buffer */ unsigned ppdsync; /* Sync word */ int num_ppds; /* Number of PPDs */ - if (cupsFileRead(fp, (char *)&ppdsync, sizeof(ppdsync)) - == sizeof(ppdsync) && + if (cupsFileRead(fp, (char *)&ppdsync, sizeof(ppdsync)) == sizeof(ppdsync) && ppdsync == PPD_SYNC && !stat(filename, &fileinfo) && - ((fileinfo.st_size - sizeof(ppdsync)) % sizeof(ppd_rec_t)) == 0 && - (num_ppds = (fileinfo.st_size - sizeof(ppdsync)) / - sizeof(ppd_rec_t)) > 0) + (((size_t)fileinfo.st_size - sizeof(ppdsync)) % sizeof(ppd_rec_t)) == 0 && + (num_ppds = ((size_t)fileinfo.st_size - sizeof(ppdsync)) / sizeof(ppd_rec_t)) > 0) { /* * We have a ppds.dat file, so read it! @@ -2702,8 +2659,7 @@ load_tar(const char *filename, /* I - Actual filename */ (void)filename; - add_ppd(name, name, "", "", "", "", "", "", mtime, size, 0, - PPD_TYPE_ARCHIVE, "file"); + add_ppd(name, name, "", "", "", "", "", "", mtime, (size_t)size, 0, PPD_TYPE_ARCHIVE, "file"); ChangedPPD = 1; /* diff --git a/scheduler/cups-lpd.c b/scheduler/cups-lpd.c index f175f6669..a1de09058 100644 --- a/scheduler/cups-lpd.c +++ b/scheduler/cups-lpd.c @@ -1,27 +1,16 @@ /* * "$Id$" * - * Line Printer Daemon interface for CUPS. + * Line Printer Daemon interface for CUPS. * - * Copyright 2007-2012 by Apple Inc. - * Copyright 1997-2006 by Easy Software Products, all rights reserved. + * Copyright 2007-2014 by Apple Inc. + * Copyright 1997-2006 by Easy Software Products, all rights reserved. * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "LICENSE.txt" - * which should have been included with this file. If this file is - * file is missing or damaged, see the license at "http://www.cups.org/". - * - * Contents: - * - * main() - Process an incoming LPD request... - * create_job() - Create a new print job. - * get_printer() - Get the named printer and its options. - * print_file() - Add a file to the current job. - * recv_print_job() - Receive a print job from the client. - * remove_jobs() - Cancel one or more jobs. - * send_state() - Send the queue state. - * smart_gets() - Get a line of text, removing the trailing CR and/or LF. + * These coded instructions, statements, and computer programs are the + * property of Apple Inc. and are protected by Federal copyright + * law. Distribution and use rights are outlined in the file "LICENSE.txt" + * which should have been included with this file. If this file is + * file is missing or damaged, see the license at "http://www.cups.org/". */ /* @@ -268,21 +257,21 @@ main(int argc, /* I - Number of command-line arguments */ syslog(LOG_INFO, "Receive print job for %s", dest); /* recv_print_job() sends initial status byte */ - status = recv_print_job(dest, num_defaults, defaults); + status = (char)recv_print_job(dest, num_defaults, defaults); break; case 0x03 : /* Send queue state (short) */ syslog(LOG_INFO, "Send queue state (short) for %s %s", dest, list); /* no status byte for this command */ - status = send_state(dest, list, 0); + status = (char)send_state(dest, list, 0); break; case 0x04 : /* Send queue state (long) */ syslog(LOG_INFO, "Send queue state (long) for %s %s", dest, list); /* no status byte for this command */ - status = send_state(dest, list, 1); + status = (char)send_state(dest, list, 1); break; case 0x05 : /* Remove jobs */ @@ -300,7 +289,7 @@ main(int argc, /* I - Number of command-line arguments */ syslog(LOG_INFO, "Remove jobs %s on %s by %s", list, dest, agent); - status = remove_jobs(dest, agent, list); + status = (char)remove_jobs(dest, agent, list); } else status = 1; @@ -744,7 +733,7 @@ print_file(http_t *http, /* I - HTTP connection */ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_MIMETYPE, "document-format", NULL, format); - ippAddBoolean(request, IPP_TAG_OPERATION, "last-document", last); + ippAddBoolean(request, IPP_TAG_OPERATION, "last-document", (char)last); /* * Do the request... @@ -781,7 +770,8 @@ recv_print_job( int fd; /* Temporary file */ FILE *fp; /* File pointer */ char filename[1024]; /* Temporary filename */ - int bytes; /* Bytes received */ + ssize_t bytes; /* Bytes received */ + size_t total; /* Total bytes */ char line[256], /* Line from file/stdin */ command, /* Command from line */ *count, /* Number of bytes */ @@ -965,15 +955,15 @@ recv_print_job( * Copy the data or control file from the client... */ - for (i = atoi(count); i > 0; i -= bytes) + for (total = (size_t)strtoll(count, NULL, 10); total > 0; total -= (size_t)bytes) { - if (i > sizeof(line)) - bytes = sizeof(line); + if (total > sizeof(line)) + bytes = (ssize_t)sizeof(line); else - bytes = i; + bytes = (ssize_t)total; - if ((bytes = fread(line, 1, bytes, stdin)) > 0) - bytes = write(fd, line, bytes); + if ((bytes = (ssize_t)fread(line, 1, (size_t)bytes, stdin)) > 0) + bytes = write(fd, line, (size_t)bytes); if (bytes < 1) { @@ -1609,7 +1599,7 @@ smart_gets(char *s, /* I - Pointer to line buffer */ break; } else if (ptr < end) - *ptr++ = ch; + *ptr++ = (char)ch; } *ptr = '\0'; diff --git a/scheduler/cupsfilter.c b/scheduler/cupsfilter.c index 177766e53..56960f642 100644 --- a/scheduler/cupsfilter.c +++ b/scheduler/cupsfilter.c @@ -1,34 +1,16 @@ /* * "$Id$" * - * Filtering program for CUPS. + * Filtering program for CUPS. * - * Copyright 2007-2013 by Apple Inc. - * Copyright 1997-2006 by Easy Software Products, all rights reserved. + * Copyright 2007-2014 by Apple Inc. + * Copyright 1997-2006 by Easy Software Products, all rights reserved. * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "LICENSE.txt" - * which should have been included with this file. If this file is - * file is missing or damaged, see the license at "http://www.cups.org/". - * - * Contents: - * - * main() - Main entry for the test program. - * add_printer_filter() - Add a single filters from a PPD file. - * add_printer_filters() - Add filters from a PPD file. - * check_cb() - Callback function for _cupsFileCheck. - * compare_pids() - Compare two filter PIDs... - * escape_options() - Convert an options array to a string. - * exec_filter() - Execute a single filter. - * exec_filters() - Execute filters for the given file and options. - * get_job_file() - Get the specified job file. - * open_pipe() - Create a pipe which is closed on exec. - * read_cupsd_conf() - Read the cupsd.conf file to get the filter - * settings. - * set_string() - Copy and set a string. - * sighandler() - Signal catcher for when we print from stdin... - * usage() - Show program usage... + * These coded instructions, statements, and computer programs are the + * property of Apple Inc. and are protected by Federal copyright + * law. Distribution and use rights are outlined in the file "LICENSE.txt" + * which should have been included with this file. If this file is + * file is missing or damaged, see the license at "http://www.cups.org/". */ /* @@ -576,7 +558,7 @@ add_printer_filter( { char *ptr; /* Pointer into maxsize(nnnn) program */ - maxsize = strtoll(program + 8, &ptr, 10); + maxsize = (size_t)strtoll(program + 8, &ptr, 10); if (*ptr != ')') { @@ -745,7 +727,7 @@ escape_options( { int i; /* Looping var */ cups_option_t *option; /* Current option */ - int bytes; /* Number of bytes needed */ + size_t bytes; /* Number of bytes needed */ char *s, /* Option string */ *sptr, /* Pointer into string */ *vptr; /* Pointer into value */ @@ -773,7 +755,7 @@ escape_options( if (sptr > s) *sptr++ = ' '; - strlcpy(sptr, option->name, bytes - (sptr - s)); + strlcpy(sptr, option->name, bytes - (size_t)(sptr - s)); sptr += strlen(sptr); *sptr++ = '='; diff --git a/scheduler/dirsvc.c b/scheduler/dirsvc.c index f372c00c8..35eccb800 100644 --- a/scheduler/dirsvc.c +++ b/scheduler/dirsvc.c @@ -1,46 +1,16 @@ /* * "$Id$" * - * Directory services routines for the CUPS scheduler. + * Directory services routines for the CUPS scheduler. * - * Copyright 2007-2013 by Apple Inc. - * Copyright 1997-2007 by Easy Software Products, all rights reserved. + * Copyright 2007-2014 by Apple Inc. + * Copyright 1997-2007 by Easy Software Products, all rights reserved. * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "LICENSE.txt" - * which should have been included with this file. If this file is - * file is missing or damaged, see the license at "http://www.cups.org/". - * - * Contents: - * - * cupsdDeregisterPrinter() - Stop sending broadcast information for a local - * printer and remove any pending references to - * remote printers. - * cupsdRegisterPrinter() - Start sending broadcast information for a - * printer or update the broadcast contents. - * cupsdStartBrowsing() - Start sending and receiving broadcast - * information. - * cupsdStopBrowsing() - Stop sending and receiving broadcast - * information. - * cupsdUpdateDNSSDName() - Update the computer name we use for - * browsing... - * dnssdAddAlias() - Add a DNS-SD alias name. - * dnssdBuildTxtRecord() - Build a TXT record from printer info. - * dnssdDeregisterInstance() - Deregister a DNS-SD service instance. - * dnssdDeregisterPrinter() - Deregister all services for a printer. - * dnssdErrorString() - Return an error string for an error code. - * dnssdRegisterCallback() - Free a TXT record. - * dnssdRegisterCallback() - DNSServiceRegister callback. - * dnssdRegisterInstance() - Register an instance of a printer service. - * dnssdRegisterPrinter() - Start sending broadcast information for a - * printer or update the broadcast contents. - * dnssdStop() - Stop all DNS-SD registrations. - * dnssdUpdate() - Handle DNS-SD queries. - * get_auth_info_required() - Get the auth-info-required value to advertise. - * get_hostconfig() - Get an /etc/hostconfig service setting. - * update_lpd() - Update the LPD configuration as needed. - * update_smb() - Update the SMB configuration as needed. + * These coded instructions, statements, and computer programs are the + * property of Apple Inc. and are protected by Federal copyright + * law. Distribution and use rights are outlined in the file "LICENSE.txt" + * which should have been included with this file. If this file is + * file is missing or damaged, see the license at "http://www.cups.org/". */ /* @@ -1404,7 +1374,7 @@ get_auth_info_required( if (i) *bufptr++ = ','; - strlcpy(bufptr, p->auth_info_required[i], bufsize - (bufptr - buffer)); + strlcpy(bufptr, p->auth_info_required[i], bufsize - (size_t)(bufptr - buffer)); bufptr += strlen(bufptr); } diff --git a/scheduler/ipp.c b/scheduler/ipp.c index 8bf7498fe..c5335c698 100644 --- a/scheduler/ipp.c +++ b/scheduler/ipp.c @@ -676,7 +676,7 @@ cupsdProcessIPPRequest( struct stat fileinfo; /* File information */ if (!fstat(con->file, &fileinfo)) - length += fileinfo.st_size; + length += (size_t)fileinfo.st_size; } cupsdLogMessage(CUPSD_LOG_DEBUG, @@ -1145,9 +1145,9 @@ add_file(cupsd_client_t *con, /* I - Connection to client */ else { compressions = (int *)realloc(job->compressions, - (job->num_files + 1) * sizeof(int)); + (size_t)(job->num_files + 1) * sizeof(int)); filetypes = (mime_type_t **)realloc(job->filetypes, - (job->num_files + 1) * + (size_t)(job->num_files + 1) * sizeof(mime_type_t *)); } @@ -4129,8 +4129,8 @@ copy_banner(cupsd_client_t *con, /* I - Client connection */ */ attrname[2] = '_'; - attrname[3] = toupper(attrname[3] & 255); - attrname[4] = toupper(attrname[4] & 255); + attrname[3] = (char)toupper(attrname[3] & 255); + attrname[4] = (char)toupper(attrname[4] & 255); } snprintf(filename, sizeof(filename), "%s/banners/%s/%s", DataDir, @@ -4184,7 +4184,7 @@ copy_banner(cupsd_client_t *con, /* I - Client connection */ if (!isalpha(ch & 255) && ch != '-' && ch != '?') break; else if (s < (attrname + sizeof(attrname) - 1)) - *s++ = ch; + *s++ = (char)ch; else break; @@ -4375,7 +4375,7 @@ copy_file(const char *from, /* I - Source file */ */ while ((bytes = cupsFileRead(src, buffer, sizeof(buffer))) > 0) - if (cupsFileWrite(dst, buffer, bytes) < bytes) + if (cupsFileWrite(dst, buffer, (size_t)bytes) < bytes) { cupsFileClose(src); cupsFileClose(dst); @@ -4510,7 +4510,7 @@ copy_model(cupsd_client_t *con, /* I - Client connection */ if ((bytes = read(temppipe[0], buffer, sizeof(buffer))) > 0) { - if (write(tempfd, buffer, bytes) < bytes) + if (write(tempfd, buffer, (size_t)bytes) < bytes) break; total += bytes; @@ -4881,12 +4881,10 @@ copy_printer_attrs( } if (!ra || cupsArrayFind(ra, "printer-is-accepting-jobs")) - ippAddBoolean(con->response, IPP_TAG_PRINTER, "printer-is-accepting-jobs", - printer->accepting); + ippAddBoolean(con->response, IPP_TAG_PRINTER, "printer-is-accepting-jobs", (char)printer->accepting); if (!ra || cupsArrayFind(ra, "printer-is-shared")) - ippAddBoolean(con->response, IPP_TAG_PRINTER, "printer-is-shared", - printer->shared); + ippAddBoolean(con->response, IPP_TAG_PRINTER, "printer-is-shared", (char)printer->shared); if (!ra || cupsArrayFind(ra, "printer-more-info")) { @@ -4919,7 +4917,7 @@ copy_printer_attrs( if (!ra || cupsArrayFind(ra, "printer-type")) { - int type; /* printer-type value */ + cups_ptype_t type; /* printer-type value */ /* * Add the CUPS-specific printer-type attribute... @@ -4936,8 +4934,7 @@ copy_printer_attrs( if (!printer->shared) type |= CUPS_PRINTER_NOT_SHARED; - ippAddInteger(con->response, IPP_TAG_PRINTER, IPP_TAG_ENUM, "printer-type", - type); + ippAddInteger(con->response, IPP_TAG_PRINTER, IPP_TAG_ENUM, "printer-type", (int)type); } if (!ra || cupsArrayFind(ra, "printer-up-time")) @@ -7017,7 +7014,7 @@ get_printers(cupsd_client_t *con, /* I - Client connection */ int limit; /* Max number of printers to return */ int count; /* Number of printers that match */ cupsd_printer_t *printer; /* Current printer pointer */ - int printer_type, /* printer-type attribute */ + cups_ptype_t printer_type, /* printer-type attribute */ printer_mask; /* printer-type-mask attribute */ char *location; /* Location string */ const char *username; /* Current user */ @@ -7071,15 +7068,15 @@ get_printers(cupsd_client_t *con, /* I - Client connection */ if ((attr = ippFindAttribute(con->request, "printer-type", IPP_TAG_ENUM)) != NULL) - printer_type = attr->values[0].integer; + printer_type = (cups_ptype_t)attr->values[0].integer; else - printer_type = 0; + printer_type = (cups_ptype_t)0; if ((attr = ippFindAttribute(con->request, "printer-type-mask", IPP_TAG_ENUM)) != NULL) - printer_mask = attr->values[0].integer; + printer_mask = (cups_ptype_t)attr->values[0].integer; else - printer_mask = 0; + printer_mask = (cups_ptype_t)0; local = httpAddrLocalhost(&(con->clientaddr)); @@ -8985,8 +8982,7 @@ save_auth_info( { if (strcmp(dest->auth_info_required[i], "negotiate")) { - httpEncode64_2(line, sizeof(line), auth_info->values[i].string.text, - strlen(auth_info->values[i].string.text)); + httpEncode64_2(line, sizeof(line), auth_info->values[i].string.text, (int)strlen(auth_info->values[i].string.text)); cupsFilePutConf(fp, dest->auth_info_required[i], line); } else @@ -9017,15 +9013,13 @@ save_auth_info( * Allow fallback to username+password for Kerberized queues... */ - httpEncode64_2(line, sizeof(line), auth_info->values[0].string.text, - strlen(auth_info->values[0].string.text)); + httpEncode64_2(line, sizeof(line), auth_info->values[0].string.text, (int)strlen(auth_info->values[0].string.text)); cupsFilePutConf(fp, "username", line); cupsdSetStringf(job->auth_env + 0, "AUTH_USERNAME=%s", auth_info->values[0].string.text); - httpEncode64_2(line, sizeof(line), auth_info->values[1].string.text, - strlen(auth_info->values[1].string.text)); + httpEncode64_2(line, sizeof(line), auth_info->values[1].string.text, (int)strlen(auth_info->values[1].string.text)); cupsFilePutConf(fp, "password", line); cupsdSetStringf(job->auth_env + 1, "AUTH_PASSWORD=%s", @@ -9037,7 +9031,7 @@ save_auth_info( * Write the authenticated username... */ - httpEncode64_2(line, sizeof(line), con->username, strlen(con->username)); + httpEncode64_2(line, sizeof(line), con->username, (int)strlen(con->username)); cupsFilePutConf(fp, "username", line); cupsdSetStringf(job->auth_env + 0, "AUTH_USERNAME=%s", con->username); @@ -9046,7 +9040,7 @@ save_auth_info( * Write the authenticated password... */ - httpEncode64_2(line, sizeof(line), con->password, strlen(con->password)); + httpEncode64_2(line, sizeof(line), con->password, (int)strlen(con->password)); cupsFilePutConf(fp, "password", line); cupsdSetStringf(job->auth_env + 1, "AUTH_PASSWORD=%s", con->password); @@ -9915,9 +9909,7 @@ set_job_attrs(cupsd_client_t *con, /* I - Client connection */ { cupsdLogJob(job, CUPSD_LOG_DEBUG, "Setting job-state to %d", attr->values[0].integer); - cupsdSetJobState(job, attr->values[0].integer, - CUPSD_JOB_DEFAULT, - "Job state changed by \"%s\"", username); + cupsdSetJobState(job, (ipp_jstate_t)attr->values[0].integer, CUPSD_JOB_DEFAULT, "Job state changed by \"%s\"", username); check_jobs = 1; } break; @@ -10163,7 +10155,7 @@ set_printer_defaults( { int i; /* Looping var */ ipp_attribute_t *attr; /* Current attribute */ - int namelen; /* Length of attribute name */ + size_t namelen; /* Length of attribute name */ char name[256], /* New attribute name */ value[256]; /* String version of integer attrs */ diff --git a/scheduler/job.c b/scheduler/job.c index cc0f11b1c..42a39bf65 100644 --- a/scheduler/job.c +++ b/scheduler/job.c @@ -3,7 +3,7 @@ * * Job management routines for the CUPS scheduler. * - * Copyright 2007-2013 by Apple Inc. + * Copyright 2007-2014 by Apple Inc. * Copyright 1997-2007 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the @@ -568,9 +568,7 @@ cupsdContinueJob(cupsd_job_t *job) /* I - Job */ if (stat(filename, &fileinfo)) fileinfo.st_size = 0; - filters = mimeFilter2(MimeDatabase, job->filetypes[job->current_file], - fileinfo.st_size, job->printer->filetype, - &(job->cost)); + filters = mimeFilter2(MimeDatabase, job->filetypes[job->current_file], (size_t)fileinfo.st_size, job->printer->filetype, &(job->cost)); if (!filters) { @@ -846,7 +844,7 @@ cupsdContinueJob(cupsd_job_t *job) /* I - Job */ else argc = 7; - if ((argv = calloc(argc + 1, sizeof(char *))) == NULL) + if ((argv = calloc((size_t)argc + 1, sizeof(char *))) == NULL) { cupsdLogMessage(CUPSD_LOG_DEBUG, "Unable to allocate argument array - %s", strerror(errno)); @@ -970,8 +968,7 @@ cupsdContinueJob(cupsd_job_t *job) /* I - Job */ { if (i) *psrptr++ = ','; - strlcpy(psrptr, job->printer->reasons[i], - psrlen - (psrptr - printer_state_reasons)); + strlcpy(psrptr, job->printer->reasons[i], psrlen - (size_t)(psrptr - printer_state_reasons)); psrptr += strlen(psrptr); } } @@ -1822,16 +1819,13 @@ cupsdLoadJob(cupsd_job_t *job) /* I - Job */ { if (job->num_files == 0) { - compressions = (int *)calloc(fileid, sizeof(int)); - filetypes = (mime_type_t **)calloc(fileid, sizeof(mime_type_t *)); + compressions = (int *)calloc((size_t)fileid, sizeof(int)); + filetypes = (mime_type_t **)calloc((size_t)fileid, sizeof(mime_type_t *)); } else { - compressions = (int *)realloc(job->compressions, - sizeof(int) * fileid); - filetypes = (mime_type_t **)realloc(job->filetypes, - sizeof(mime_type_t *) * - fileid); + compressions = (int *)realloc(job->compressions, sizeof(int) * (size_t)fileid); + filetypes = (mime_type_t **)realloc(job->filetypes, sizeof(mime_type_t *) * (size_t)fileid); } if (compressions) @@ -2868,7 +2862,7 @@ dump_job_history(cupsd_job_t *job) /* I - Job */ snprintf(temp, sizeof(temp), "[Job %d] printer-state-reasons=", job->id); ptr = temp + strlen(temp); if (printer->num_reasons == 0) - strlcpy(ptr, "none", sizeof(temp) - (ptr - temp)); + strlcpy(ptr, "none", sizeof(temp) - (size_t)(ptr - temp)); else { for (i = 0; @@ -2878,7 +2872,7 @@ dump_job_history(cupsd_job_t *job) /* I - Job */ if (i) *ptr++ = ','; - strlcpy(ptr, printer->reasons[i], sizeof(temp) - (ptr - temp)); + strlcpy(ptr, printer->reasons[i], sizeof(temp) - (size_t)(ptr - temp)); ptr += strlen(ptr); } } @@ -3708,18 +3702,18 @@ get_options(cupsd_job_t *job, /* I - Job */ */ if (optptr > options) - strlcat(optptr, " ", optlength - (optptr - options)); + strlcat(optptr, " ", optlength - (size_t)(optptr - options)); if (attr->value_tag != IPP_TAG_BOOLEAN) { - strlcat(optptr, attr->name, optlength - (optptr - options)); - strlcat(optptr, "=", optlength - (optptr - options)); + strlcat(optptr, attr->name, optlength - (size_t)(optptr - options)); + strlcat(optptr, "=", optlength - (size_t)(optptr - options)); } for (i = 0; i < attr->num_values; i ++) { if (i) - strlcat(optptr, ",", optlength - (optptr - options)); + strlcat(optptr, ",", optlength - (size_t)(optptr - options)); optptr += strlen(optptr); @@ -3727,30 +3721,29 @@ get_options(cupsd_job_t *job, /* I - Job */ { case IPP_TAG_INTEGER : case IPP_TAG_ENUM : - snprintf(optptr, optlength - (optptr - options), + snprintf(optptr, optlength - (size_t)(optptr - options), "%d", attr->values[i].integer); break; case IPP_TAG_BOOLEAN : if (!attr->values[i].boolean) - strlcat(optptr, "no", optlength - (optptr - options)); + strlcat(optptr, "no", optlength - (size_t)(optptr - options)); - strlcat(optptr, attr->name, - optlength - (optptr - options)); + strlcat(optptr, attr->name, optlength - (size_t)(optptr - options)); break; case IPP_TAG_RANGE : if (attr->values[i].range.lower == attr->values[i].range.upper) - snprintf(optptr, optlength - (optptr - options) - 1, + snprintf(optptr, optlength - (size_t)(optptr - options) - 1, "%d", attr->values[i].range.lower); else - snprintf(optptr, optlength - (optptr - options) - 1, + snprintf(optptr, optlength - (size_t)(optptr - options) - 1, "%d-%d", attr->values[i].range.lower, attr->values[i].range.upper); break; case IPP_TAG_RESOLUTION : - snprintf(optptr, optlength - (optptr - options) - 1, + snprintf(optptr, optlength - (size_t)(optptr - options) - 1, "%dx%d%s", attr->values[i].resolution.xres, attr->values[i].resolution.yres, attr->values[i].resolution.units == IPP_RES_PER_INCH ? @@ -3790,10 +3783,10 @@ get_options(cupsd_job_t *job, /* I - Job */ for (i = num_pwgppds, pwgppd = pwgppds; i > 0; i --, pwgppd ++) { *optptr++ = ' '; - strlcpy(optptr, pwgppd->name, optlength - (optptr - options)); + strlcpy(optptr, pwgppd->name, optlength - (size_t)(optptr - options)); optptr += strlen(optptr); *optptr++ = '='; - strlcpy(optptr, pwgppd->value, optlength - (optptr - options)); + strlcpy(optptr, pwgppd->value, optlength - (size_t)(optptr - options)); optptr += strlen(optptr); } @@ -3847,7 +3840,7 @@ ipp_length(ipp_t *ipp) /* I - IPP request */ */ bytes ++; /* " " separator */ - bytes += attr->num_values; /* "," separators */ + bytes += (size_t)attr->num_values; /* "," separators */ /* * Boolean attributes appear as "foo,nofoo,foo,nofoo", while @@ -3857,7 +3850,7 @@ ipp_length(ipp_t *ipp) /* I - IPP request */ if (attr->value_tag != IPP_TAG_BOOLEAN) bytes += strlen(attr->name); else - bytes += attr->num_values * strlen(attr->name); + bytes += (size_t)attr->num_values * strlen(attr->name); /* * Now add the size required for each value in the attribute... @@ -3871,7 +3864,7 @@ ipp_length(ipp_t *ipp) /* I - IPP request */ * Minimum value of a signed integer is -2147483647, or 11 digits. */ - bytes += attr->num_values * 11; + bytes += (size_t)attr->num_values * 11; break; case IPP_TAG_BOOLEAN : @@ -3890,7 +3883,7 @@ ipp_length(ipp_t *ipp) /* I - IPP request */ * 23 characters max. */ - bytes += attr->num_values * 23; + bytes += (size_t)attr->num_values * 23; break; case IPP_TAG_RESOLUTION : @@ -3899,7 +3892,7 @@ ipp_length(ipp_t *ipp) /* I - IPP request */ * suffixed by the units, or 26 characters max. */ - bytes += attr->num_values * 26; + bytes += (size_t)attr->num_values * 26; break; case IPP_TAG_STRING : @@ -4099,8 +4092,8 @@ load_job_cache(const char *filename) /* I - job.cache filename */ continue; } - job->filetypes = calloc(job->num_files, sizeof(mime_type_t *)); - job->compressions = calloc(job->num_files, sizeof(int)); + job->filetypes = calloc((size_t)job->num_files, sizeof(mime_type_t *)); + job->compressions = calloc((size_t)job->num_files, sizeof(int)); if (!job->filetypes || !job->compressions) { diff --git a/scheduler/log.c b/scheduler/log.c index e72e4431b..5d5dba617 100644 --- a/scheduler/log.c +++ b/scheduler/log.c @@ -3,7 +3,7 @@ * * Log file routines for the CUPS scheduler. * - * Copyright 2007-2013 by Apple Inc. + * Copyright 2007-2014 by Apple Inc. * Copyright 1997-2007 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the @@ -28,7 +28,7 @@ static _cups_mutex_t log_mutex = _CUPS_MUTEX_INITIALIZER; /* Mutex for logging */ -static int log_linesize = 0; /* Size of line for output file */ +static size_t log_linesize = 0; /* Size of line for output file */ static char *log_line = NULL; /* Line for output file */ #ifdef HAVE_VSYSLOG @@ -114,7 +114,7 @@ cupsdCheckLogFile(cups_file_t **lf, /* IO - Log file */ * Insert the server name... */ - strlcpy(ptr, ServerName, sizeof(filename) - (ptr - filename)); + strlcpy(ptr, ServerName, sizeof(filename) - (size_t)(ptr - filename)); ptr += strlen(ptr); } else @@ -155,15 +155,14 @@ cupsdCheckLogFile(cups_file_t **lf, /* IO - Log file */ * the log file permissions as a basis... */ - int log_dir_perm = 0300 | LogFilePerm; + mode_t log_dir_perm = (mode_t)(0300 | LogFilePerm); /* LogFilePerm + owner write/search */ if (log_dir_perm & 0040) log_dir_perm |= 0010; /* Add group search */ if (log_dir_perm & 0004) log_dir_perm |= 0001; /* Add other search */ - cupsdCheckPermissions(CUPS_LOGDIR, NULL, log_dir_perm, RunUser, Group, - 1, -1); + cupsdCheckPermissions(CUPS_LOGDIR, NULL, log_dir_perm, RunUser, Group, 1, -1); *lf = cupsFileOpen(filename, "a"); } @@ -372,8 +371,8 @@ cupsdLogFCMessage( int /* O - 1 on success, 0 on error */ cupsdLogGSSMessage( int level, /* I - Log level */ - int major_status, /* I - Major GSSAPI status */ - int minor_status, /* I - Minor GSSAPI status */ + OM_uint32 major_status, /* I - Major GSSAPI status */ + OM_uint32 minor_status, /* I - Minor GSSAPI status */ const char *message, /* I - printf-style message string */ ...) /* I - Additional args as needed */ { @@ -687,41 +686,37 @@ cupsdLogPage(cupsd_job_t *job, /* I - Job being printed */ break; case 'p' : /* Printer name */ - strlcpy(bufptr, job->printer->name, - sizeof(buffer) - (bufptr - buffer)); + strlcpy(bufptr, job->printer->name, sizeof(buffer) - (size_t)(bufptr - buffer)); bufptr += strlen(bufptr); break; case 'j' : /* Job ID */ - snprintf(bufptr, sizeof(buffer) - (bufptr - buffer), "%d", job->id); + snprintf(bufptr, sizeof(buffer) - (size_t)(bufptr - buffer), "%d", job->id); bufptr += strlen(bufptr); break; case 'u' : /* Username */ - strlcpy(bufptr, job->username ? job->username : "-", - sizeof(buffer) - (bufptr - buffer)); + strlcpy(bufptr, job->username ? job->username : "-", sizeof(buffer) - (size_t)(bufptr - buffer)); bufptr += strlen(bufptr); break; case 'T' : /* Date and time */ - strlcpy(bufptr, cupsdGetDateTime(NULL, LogTimeFormat), - sizeof(buffer) - (bufptr - buffer)); + strlcpy(bufptr, cupsdGetDateTime(NULL, LogTimeFormat), sizeof(buffer) - (size_t)(bufptr - buffer)); bufptr += strlen(bufptr); break; case 'P' : /* Page number */ - strlcpy(bufptr, number, sizeof(buffer) - (bufptr - buffer)); + strlcpy(bufptr, number, sizeof(buffer) - (size_t)(bufptr - buffer)); bufptr += strlen(bufptr); break; case 'C' : /* Number of copies */ - snprintf(bufptr, sizeof(buffer) - (bufptr - buffer), "%d", copies); + snprintf(bufptr, sizeof(buffer) - (size_t)(bufptr - buffer), "%d", copies); bufptr += strlen(bufptr); break; case '{' : /* {attribute} */ - if ((nameend = strchr(format, '}')) != NULL && - (nameend - format - 2) < (sizeof(name) - 1)) + if ((nameend = strchr(format, '}')) != NULL && (size_t)(nameend - format - 2) < (sizeof(name) - 1)) { /* * Pull the name from inside the brackets... @@ -751,14 +746,12 @@ cupsdLogPage(cupsd_job_t *job, /* I - Job being printed */ { case IPP_TAG_INTEGER : case IPP_TAG_ENUM : - snprintf(bufptr, sizeof(buffer) - (bufptr - buffer), - "%d", attr->values[i].integer); + snprintf(bufptr, sizeof(buffer) - (size_t)(bufptr - buffer), "%d", attr->values[i].integer); bufptr += strlen(bufptr); break; case IPP_TAG_BOOLEAN : - snprintf(bufptr, sizeof(buffer) - (bufptr - buffer), - "%d", attr->values[i].boolean); + snprintf(bufptr, sizeof(buffer) - (size_t)(bufptr - buffer), "%d", attr->values[i].boolean); bufptr += strlen(bufptr); break; @@ -772,14 +765,12 @@ cupsdLogPage(cupsd_job_t *job, /* I - Job being printed */ case IPP_TAG_CHARSET : case IPP_TAG_LANGUAGE : case IPP_TAG_MIMETYPE : - strlcpy(bufptr, attr->values[i].string.text, - sizeof(buffer) - (bufptr - buffer)); + strlcpy(bufptr, attr->values[i].string.text, sizeof(buffer) - (size_t)(bufptr - buffer)); bufptr += strlen(bufptr); break; default : - strlcpy(bufptr, "???", - sizeof(buffer) - (bufptr - buffer)); + strlcpy(bufptr, "???", sizeof(buffer) - (size_t)(bufptr - buffer)); bufptr += strlen(bufptr); break; } @@ -1104,7 +1095,7 @@ static int /* O - -1 for fatal, 0 for retry, 1 for success */ format_log_line(const char *message, /* I - Printf-style format string */ va_list ap) /* I - Argument list */ { - int len; /* Length of formatted line */ + ssize_t len; /* Length of formatted line */ /* @@ -1130,7 +1121,7 @@ format_log_line(const char *message, /* I - Printf-style format string */ * Resize the buffer as needed... */ - if (len >= log_linesize && log_linesize < 65536) + if ((size_t)len >= log_linesize && log_linesize < 65536) { char *temp; /* Temporary string pointer */ @@ -1142,12 +1133,12 @@ format_log_line(const char *message, /* I - Printf-style format string */ else if (len > 65536) len = 65536; - temp = realloc(log_line, len); + temp = realloc(log_line, (size_t)len); if (temp) { log_line = temp; - log_linesize = len; + log_linesize = (size_t)len; return (0); } diff --git a/scheduler/main.c b/scheduler/main.c index f9ce3c9b8..162c4df48 100644 --- a/scheduler/main.c +++ b/scheduler/main.c @@ -3,7 +3,7 @@ * * Main loop for the CUPS scheduler. * - * Copyright 2007-2013 by Apple Inc. + * Copyright 2007-2014 by Apple Inc. * Copyright 1997-2007 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the @@ -324,7 +324,7 @@ main(int argc, /* I - Number of command-line args */ return (1); } - strlcpy(slash, "/cups-files.conf", len - (slash - filename)); + strlcpy(slash, "/cups-files.conf", len - (size_t)(slash - filename)); cupsdSetString(&CupsFilesFile, filename); free(filename); } @@ -501,7 +501,7 @@ main(int argc, /* I - Number of command-line args */ #endif /* RLIM_INFINITY */ MaxFDs = limit.rlim_max; - limit.rlim_cur = MaxFDs; + limit.rlim_cur = (rlim_t)MaxFDs; setrlimit(RLIMIT_NOFILE, &limit); diff --git a/scheduler/mime.c b/scheduler/mime.c index 94ad96554..56181501a 100644 --- a/scheduler/mime.c +++ b/scheduler/mime.c @@ -1,40 +1,16 @@ /* * "$Id$" * - * MIME database file routines for CUPS. + * MIME database file routines for CUPS. * - * Copyright 2007-2013 by Apple Inc. - * Copyright 1997-2006 by Easy Software Products, all rights reserved. + * Copyright 2007-2014 by Apple Inc. + * Copyright 1997-2006 by Easy Software Products, all rights reserved. * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "LICENSE.txt" - * which should have been included with this file. If this file is - * file is missing or damaged, see the license at "http://www.cups.org/". - * - * Contents: - * - * mimeDelete() - Delete (free) a MIME database. - * mimeDeleteFilter() - Delete a filter from the MIME database. - * mimeDeleteType() - Delete a type from the MIME database. - * _mimeError() - Show an error message. - * mimeFirstFilter() - Get the first filter in the MIME database. - * mimeFirstType() - Get the first type in the MIME database. - * mimeLoad() - Create a new MIME database from disk. - * mimeLoadFilters() - Load filter definitions from disk. - * mimeLoadTypes() - Load type definitions from disk. - * mimeNew() - Create a new, empty MIME database. - * mimeNextFilter() - Get the next filter in the MIME database. - * mimeNextType() - Get the next type in the MIME database. - * mimeNumFilters() - Get the number of filters in a MIME database. - * mimeNumTypes() - Get the number of types in a MIME database. - * mimeSetErrorCallback() - Set the callback for error messages. - * mime_add_fcache() - Add a filter to the filter cache. - * mime_compare_fcache() - Compare two filter cache entries. - * mime_delete_fcache() - Free all memory used by the filter cache. - * mime_delete_rules() - Free all memory for the given rule tree. - * mime_load_convs() - Load a xyz.convs file. - * mime_load_types() - Load a xyz.types file. + * These coded instructions, statements, and computer programs are the + * property of Apple Inc. and are protected by Federal copyright + * law. Distribution and use rights are outlined in the file "LICENSE.txt" + * which should have been included with this file. If this file is + * file is missing or damaged, see the license at "http://www.cups.org/". */ /* @@ -744,7 +720,7 @@ mime_load_convs( while (*lineptr != '/' && *lineptr != '\n' && *lineptr != '\0' && (temp - super + 1) < MIME_MAX_SUPER) - *temp++ = tolower(*lineptr++ & 255); + *temp++ = (char)tolower(*lineptr++ & 255); *temp = '\0'; @@ -756,7 +732,7 @@ mime_load_convs( while (*lineptr != ' ' && *lineptr != '\t' && *lineptr != '\n' && *lineptr != '\0' && (temp - type + 1) < MIME_MAX_TYPE) - *temp++ = tolower(*lineptr++ & 255); + *temp++ = (char)tolower(*lineptr++ & 255); *temp = '\0'; @@ -817,7 +793,7 @@ mime_load_convs( while (*lineptr != '/' && *lineptr != '\n' && *lineptr != '\0' && (temp - super + 1) < MIME_MAX_SUPER) - *temp++ = tolower(*lineptr++ & 255); + *temp++ = (char)tolower(*lineptr++ & 255); *temp = '\0'; @@ -829,7 +805,7 @@ mime_load_convs( while (*lineptr != ' ' && *lineptr != '\t' && *lineptr != '\n' && *lineptr != '\0' && (temp - type + 1) < MIME_MAX_TYPE) - *temp++ = tolower(*lineptr++ & 255); + *temp++ = (char)tolower(*lineptr++ & 255); *temp = '\0'; @@ -868,7 +844,7 @@ mime_load_types(mime_t *mime, /* I - MIME database */ const char *filename) /* I - Types file to load */ { cups_file_t *fp; /* Types file */ - int linelen; /* Length of line */ + size_t linelen; /* Length of line */ char line[32768], /* Input line from file */ *lineptr, /* Current position in line */ super[MIME_MAX_SUPER], /* Super-type name */ @@ -930,7 +906,7 @@ mime_load_types(mime_t *mime, /* I - MIME database */ while (*lineptr != '/' && *lineptr != '\n' && *lineptr != '\0' && (temp - super + 1) < MIME_MAX_SUPER) - *temp++ = tolower(*lineptr++ & 255); + *temp++ = (char)tolower(*lineptr++ & 255); *temp = '\0'; @@ -942,7 +918,7 @@ mime_load_types(mime_t *mime, /* I - MIME database */ while (*lineptr != ' ' && *lineptr != '\t' && *lineptr != '\n' && *lineptr != '\0' && (temp - type + 1) < MIME_MAX_TYPE) - *temp++ = tolower(*lineptr++ & 255); + *temp++ = (char)tolower(*lineptr++ & 255); *temp = '\0'; diff --git a/scheduler/printers.c b/scheduler/printers.c index 3c709c801..6d7f1ce20 100644 --- a/scheduler/printers.c +++ b/scheduler/printers.c @@ -3,7 +3,7 @@ * * Printer routines for the CUPS scheduler. * - * Copyright 2007-2013 by Apple Inc. + * Copyright 2007-2014 by Apple Inc. * Copyright 1997-2007 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the @@ -1089,7 +1089,7 @@ cupsdLoadAllPrinters(void) else if (!_cups_strcasecmp(line, "Type")) { if (value) - p->type = atoi(value); + p->type = (cups_ptype_t)atoi(value); else cupsdLogMessage(CUPSD_LOG_ERROR, "Syntax error on line %d of printers.conf.", linenum); @@ -1688,7 +1688,7 @@ cupsdSetAuthInfoRequired( strcmp(p->auth_info_required[0], "none")) p->type |= CUPS_PRINTER_AUTHENTICATED; else - p->type &= ~CUPS_PRINTER_AUTHENTICATED; + p->type &= (cups_ptype_t)~CUPS_PRINTER_AUTHENTICATED; return (1); } @@ -2070,10 +2070,10 @@ cupsdSetPrinterAttrs(cupsd_printer_t *p)/* I - Printer to setup */ if (auth_type != CUPSD_AUTH_NONE) p->type |= CUPS_PRINTER_AUTHENTICATED; else - p->type &= ~CUPS_PRINTER_AUTHENTICATED; + p->type &= (cups_ptype_t)~CUPS_PRINTER_AUTHENTICATED; } else - p->type &= ~CUPS_PRINTER_AUTHENTICATED; + p->type &= (cups_ptype_t)~CUPS_PRINTER_AUTHENTICATED; /* * Create the required IPP attributes for a printer... @@ -2152,7 +2152,7 @@ cupsdSetPrinterAttrs(cupsd_printer_t *p)/* I - Printer to setup */ if (p->type & CUPS_PRINTER_CLASS) { p->raw = 1; - p->type &= ~CUPS_PRINTER_OPTIONS; + p->type &= (cups_ptype_t)~CUPS_PRINTER_OPTIONS; /* * Add class-specific attributes... @@ -2178,7 +2178,7 @@ cupsdSetPrinterAttrs(cupsd_printer_t *p)/* I - Printer to setup */ if (attr != NULL) attr->values[i].string.text = _cupsStrAlloc(p->printers[i]->name); - p->type &= ~CUPS_PRINTER_OPTIONS | p->printers[i]->type; + p->type &= (cups_ptype_t)~CUPS_PRINTER_OPTIONS | p->printers[i]->type; } } } @@ -2467,8 +2467,7 @@ cupsdSetPrinterReasons( _cupsStrFree(p->reasons[i]); if (i < p->num_reasons) - memmove(p->reasons + i, p->reasons + i + 1, - (p->num_reasons - i) * sizeof(char *)); + memmove(p->reasons + i, p->reasons + i + 1, (size_t)(p->num_reasons - i) * sizeof(char *)); if (!strcmp(reason, "paused") && p->state == IPP_PRINTER_STOPPED) cupsdSetPrinterState(p, IPP_PRINTER_IDLE, 1); @@ -3306,7 +3305,7 @@ add_printer_filter( { char *ptr; /* Pointer into maxsize(nnnn) program */ - maxsize = strtoll(program + 8, &ptr, 10); + maxsize = (size_t)strtoll(program + 8, &ptr, 10); if (*ptr != ')') { @@ -3717,7 +3716,7 @@ load_ppd(cupsd_printer_t *p) /* I - Printer */ cupsdLogMessage(CUPSD_LOG_DEBUG, "load_ppd: Loading %s...", ppd_name); - p->type &= ~CUPS_PRINTER_OPTIONS; + p->type &= (cups_ptype_t)~CUPS_PRINTER_OPTIONS; p->type |= CUPS_PRINTER_BW; finishings[0] = IPP_FINISHINGS_NONE; @@ -3749,8 +3748,7 @@ load_ppd(cupsd_printer_t *p) /* I - Printer */ if (ppd_attr->value && !_cups_strcasecmp(ppd_attr->value, "true")) p->type |= CUPS_PRINTER_FAX; - ippAddBoolean(p->ppd_attrs, IPP_TAG_PRINTER, "color-supported", - ppd->color_device); + ippAddBoolean(p->ppd_attrs, IPP_TAG_PRINTER, "color-supported", (char)ppd->color_device); if (p->pc && p->pc->charge_info_uri) ippAddString(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_URI, @@ -3769,7 +3767,7 @@ load_ppd(cupsd_printer_t *p) /* I - Printer */ ippAddString(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "job-password-encryption-supported", NULL, "none"); ippAddInteger(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER, - "job-password-supported", strlen(p->pc->password)); + "job-password-supported", (int)strlen(p->pc->password)); } if (ppd->throughput) @@ -4619,22 +4617,16 @@ load_ppd(cupsd_printer_t *p) /* I - Printer */ CGContextRef context; /* The CG context used for resizing */ snprintf(outPath, sizeof(outPath), "%s/%s.png", CacheDir, p->name); - outUrl = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, - (UInt8 *)outPath, - strlen(outPath), - FALSE); - icnsFileUrl = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, - (UInt8 *)ppd_attr->value, - strlen(ppd_attr->value), - FALSE); + outUrl = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, (UInt8 *)outPath, (CFIndex)strlen(outPath), FALSE); + icnsFileUrl = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, (UInt8 *)ppd_attr->value, (CFIndex)strlen(ppd_attr->value), FALSE); if (outUrl && icnsFileUrl) { sourceRef = CGImageSourceCreateWithURL(icnsFileUrl, NULL); if (sourceRef) { - for (i = 0; i < CGImageSourceGetCount(sourceRef); i ++) + for (i = 0; i < (int)CGImageSourceGetCount(sourceRef); i ++) { - imageRef = CGImageSourceCreateImageAtIndex(sourceRef, i, NULL); + imageRef = CGImageSourceCreateImageAtIndex(sourceRef, (size_t)i, NULL); if (!imageRef) continue; @@ -5006,7 +4998,7 @@ write_xml_string(cups_file_t *fp, /* I - File to write to */ if (*s == '&') { if (s > start) - cupsFileWrite(fp, start, s - start); + cupsFileWrite(fp, start, (size_t)(s - start)); cupsFilePuts(fp, "&"); start = s + 1; @@ -5014,7 +5006,7 @@ write_xml_string(cups_file_t *fp, /* I - File to write to */ else if (*s == '<') { if (s > start) - cupsFileWrite(fp, start, s - start); + cupsFileWrite(fp, start, (size_t)(s - start)); cupsFilePuts(fp, "<"); start = s + 1; diff --git a/scheduler/process.c b/scheduler/process.c index 4a0985821..44ebf7324 100644 --- a/scheduler/process.c +++ b/scheduler/process.c @@ -1,26 +1,16 @@ /* * "$Id$" * - * Process management routines for the CUPS scheduler. + * Process management routines for the CUPS scheduler. * - * Copyright 2007-2012 by Apple Inc. - * Copyright 1997-2007 by Easy Software Products, all rights reserved. + * Copyright 2007-2014 by Apple Inc. + * Copyright 1997-2007 by Easy Software Products, all rights reserved. * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "LICENSE.txt" - * which should have been included with this file. If this file is - * file is missing or damaged, see the license at "http://www.cups.org/". - * - * Contents: - * - * cupsdCreateProfile() - Create an execution profile for a subprocess. - * cupsdDestroyProfile() - Delete an execution profile. - * cupsdEndProcess() - End a process. - * cupsdFinishProcess() - Finish a process and get its name. - * cupsdStartProcess() - Start a process. - * compare_procs() - Compare two processes. - * cupsd_requote() - Make a regular-expression version of a string. + * These coded instructions, statements, and computer programs are the + * property of Apple Inc. and are protected by Federal copyright + * law. Distribution and use rights are outlined in the file "LICENSE.txt" + * which should have been included with this file. If this file is + * file is missing or damaged, see the license at "http://www.cups.org/". */ /* @@ -328,7 +318,7 @@ cupsdStartProcess( const char *exec_path = command; /* Command to be exec'd */ char *real_argv[103], /* Real command-line arguments */ cups_exec[1024]; /* Path to "cups-exec" program */ - int user; /* Command UID */ + uid_t user; /* Command UID */ cupsd_proc_t *proc; /* New process record */ #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) struct sigaction action; /* POSIX signal handler */ @@ -644,7 +634,7 @@ cupsd_requote(char *dst, /* I - Destination buffer */ if (strchr(".?*()[]^$\\", ch)) *dstptr++ = '\\'; - *dstptr++ = ch; + *dstptr++ = (char)ch; } *dstptr = '\0'; diff --git a/scheduler/select.c b/scheduler/select.c index 63e6dc068..08b91714b 100644 --- a/scheduler/select.c +++ b/scheduler/select.c @@ -3,7 +3,7 @@ * * Select abstraction functions for the CUPS scheduler. * - * Copyright 2007-2013 by Apple Inc. + * Copyright 2007-2014 by Apple Inc. * Copyright 2006-2007 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -814,7 +814,7 @@ cupsdStartSelect(void) #elif defined(HAVE_KQUEUE) cupsd_kqueue_fd = kqueue(); cupsd_kqueue_changes = 0; - cupsd_kqueue_events = calloc(MaxFDs, sizeof(struct kevent)); + cupsd_kqueue_events = calloc((size_t)MaxFDs, sizeof(struct kevent)); #elif defined(HAVE_POLL) cupsd_update_pollfds = 0; diff --git a/scheduler/statbuf.c b/scheduler/statbuf.c index 644e3b0ba..518fc12be 100644 --- a/scheduler/statbuf.c +++ b/scheduler/statbuf.c @@ -1,22 +1,16 @@ /* * "$Id$" * - * Status buffer routines for the CUPS scheduler. + * Status buffer routines for the CUPS scheduler. * - * Copyright 2007-2012 by Apple Inc. - * Copyright 1997-2006 by Easy Software Products, all rights reserved. + * Copyright 2007-2014 by Apple Inc. + * Copyright 1997-2006 by Easy Software Products, all rights reserved. * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "LICENSE.txt" - * which should have been included with this file. If this file is - * file is missing or damaged, see the license at "http://www.cups.org/". - * - * Contents: - * - * cupsdStatBufDelete() - Destroy a status buffer. - * cupsdStatBufNew() - Create a new status buffer. - * cupsdStatBufUpdate() - Update the status buffer. + * These coded instructions, statements, and computer programs are the + * property of Apple Inc. and are protected by Federal copyright + * law. Distribution and use rights are outlined in the file "LICENSE.txt" + * which should have been included with this file. If this file is + * file is missing or damaged, see the license at "http://www.cups.org/". */ /* @@ -138,8 +132,7 @@ cupsdStatBufUpdate( * No, read more data... */ - if ((bytes = read(sb->fd, sb->buffer + sb->bufused, - CUPSD_SB_BUFFER_SIZE - sb->bufused - 1)) > 0) + if ((bytes = read(sb->fd, sb->buffer + sb->bufused, (size_t)(CUPSD_SB_BUFFER_SIZE - sb->bufused - 1))) > 0) { sb->bufused += bytes; sb->buffer[sb->bufused] = '\0'; diff --git a/scheduler/subscriptions.c b/scheduler/subscriptions.c index 2e9eee377..db6cfb1ff 100644 --- a/scheduler/subscriptions.c +++ b/scheduler/subscriptions.c @@ -1,37 +1,16 @@ /* * "$Id$" * - * Subscription routines for the CUPS scheduler. + * Subscription routines for the CUPS scheduler. * - * Copyright 2007-2011 by Apple Inc. - * Copyright 1997-2007 by Easy Software Products, all rights reserved. + * Copyright 2007-2014 by Apple Inc. + * Copyright 1997-2007 by Easy Software Products, all rights reserved. * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "LICENSE.txt" - * which should have been included with this file. If this file is - * file is missing or damaged, see the license at "http://www.cups.org/". - * - * Contents: - * - * cupsdAddEvent() - Add an event to the global event cache. - * cupsdAddSubscription() - Add a new subscription object. - * cupsdDeleteAllSubscriptions() - Delete all subscriptions. - * cupsdDeleteSubscription() - Delete a subscription object. - * cupsdEventName() - Return a single event name. - * cupsdEventValue() - Return the event mask value for a name. - * cupsdExpireSubscriptions() - Expire old subscription objects. - * cupsdFindSubscription() - Find a subscription by ID. - * cupsdLoadAllSubscriptions() - Load all subscriptions from the .conf file. - * cupsdSaveAllSubscriptions() - Save all subscriptions to the .conf file. - * cupsdStopAllNotifiers() - Stop all notifier processes. - * cupsd_compare_subscriptions() - Compare two subscriptions. - * cupsd_delete_event() - Delete a single event... - * cupsd_send_dbus() - Send a DBUS notification... - * cupsd_send_notification() - Send a notification for the specified - * event. - * cupsd_start_notifier() - Start a notifier subprocess... - * cupsd_update_notifier() - Read messages from notifiers. + * These coded instructions, statements, and computer programs are the + * property of Apple Inc. and are protected by Federal copyright + * law. Distribution and use rights are outlined in the file "LICENSE.txt" + * which should have been included with this file. If this file is + * file is missing or damaged, see the license at "http://www.cups.org/". */ /* @@ -212,7 +191,7 @@ cupsdAddEvent( (const char * const *)dest->reasons); ippAddBoolean(temp->attrs, IPP_TAG_EVENT_NOTIFICATION, - "printer-is-accepting-jobs", dest->accepting); + "printer-is-accepting-jobs", (char)dest->accepting); } if (job) @@ -945,9 +924,9 @@ cupsdLoadAllSubscriptions(void) if (isxdigit(valueptr[0]) && isxdigit(valueptr[1])) { if (isdigit(valueptr[0])) - sub->user_data[i] = (valueptr[0] - '0') << 4; + sub->user_data[i] = (unsigned char)((valueptr[0] - '0') << 4); else - sub->user_data[i] = (tolower(valueptr[0]) - 'a' + 10) << 4; + sub->user_data[i] = (unsigned char)((tolower(valueptr[0]) - 'a' + 10) << 4); if (isdigit(valueptr[1])) sub->user_data[i] |= valueptr[1] - '0'; @@ -966,7 +945,7 @@ cupsdLoadAllSubscriptions(void) break; } else - sub->user_data[i] = *valueptr++; + sub->user_data[i] = (unsigned char)*valueptr++; } if (*valueptr) diff --git a/scheduler/testlpd.c b/scheduler/testlpd.c index 60076939e..67019c375 100644 --- a/scheduler/testlpd.c +++ b/scheduler/testlpd.c @@ -1,27 +1,16 @@ /* * "$Id$" * - * cups-lpd test program for CUPS. + * cups-lpd test program for CUPS. * - * Copyright 2007-2013 by Apple Inc. - * Copyright 2006 by Easy Software Products, all rights reserved. + * Copyright 2007-2014 by Apple Inc. + * Copyright 2006 by Easy Software Products, all rights reserved. * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "LICENSE.txt" - * which should have been included with this file. If this file is - * file is missing or damaged, see the license at "http://www.cups.org/". - * - * Contents: - * - * main() - Simulate an LPD client. - * do_command() - Send the LPD command and wait for a response. - * print_job() - Submit a file for printing. - * print_waiting() - Print waiting jobs. - * remove_job() - Cancel a print job. - * status_long() - Show the long printer status. - * status_short() - Show the short printer status. - * usage() - Show program usage... + * These coded instructions, statements, and computer programs are the + * property of Apple Inc. and are protected by Federal copyright + * law. Distribution and use rights are outlined in the file "LICENSE.txt" + * which should have been included with this file. If this file is + * file is missing or damaged, see the license at "http://www.cups.org/". */ /* @@ -210,15 +199,15 @@ do_command(int outfd, /* I - Command file descriptor */ int infd, /* I - Response file descriptor */ const char *command) /* I - Command line to send */ { - int len; /* Length of command line */ - char status; /* Status byte */ + size_t len; /* Length of command line */ + char status; /* Status byte */ printf("COMMAND: %02X %s", command[0], command + 1); len = strlen(command); - if (write(outfd, command, len) < len) + if ((size_t)write(outfd, command, len) < len) { puts(" Write failed!"); return (-1); @@ -251,7 +240,7 @@ print_job(int outfd, /* I - Command file descriptor */ struct stat fileinfo; /* File information */ char *jobname; /* Job name */ int sequence; /* Sequence number */ - int bytes; /* Bytes read/written */ + ssize_t bytes; /* Bytes read/written */ /* @@ -305,10 +294,10 @@ print_job(int outfd, /* I - Command file descriptor */ * Send the control file... */ - bytes = strlen(control); + bytes = (ssize_t)strlen(control); snprintf(command, sizeof(command), "\002%d cfA%03dlocalhost\n", - bytes, sequence); + (int)bytes, sequence); if ((status = do_command(outfd, infd, command)) != 0) { @@ -318,14 +307,14 @@ print_job(int outfd, /* I - Command file descriptor */ bytes ++; - if (write(outfd, control, bytes) < bytes) + if (write(outfd, control, (size_t)bytes) < bytes) { - printf("CONTROL: Unable to write %d bytes!\n", bytes); + printf("CONTROL: Unable to write %d bytes!\n", (int)bytes); close(fd); return (-1); } - printf("CONTROL: Wrote %d bytes.\n", bytes); + printf("CONTROL: Wrote %d bytes.\n", (int)bytes); if (read(infd, command, 1) < 1) { @@ -355,9 +344,9 @@ print_job(int outfd, /* I - Command file descriptor */ while ((bytes = read(fd, buffer, sizeof(buffer))) > 0) { - if (write(outfd, buffer, bytes) < bytes) + if (write(outfd, buffer, (size_t)bytes) < bytes) { - printf("DATA: Unable to write %d bytes!\n", bytes); + printf("DATA: Unable to write %d bytes!\n", (int)bytes); close(fd); return (-1); } @@ -451,7 +440,7 @@ status_long(int outfd, /* I - Command file descriptor */ { char command[1024], /* Command buffer */ buffer[8192]; /* Status buffer */ - int bytes; /* Bytes read/written */ + ssize_t bytes; /* Bytes read/written */ /* @@ -463,9 +452,9 @@ status_long(int outfd, /* I - Command file descriptor */ else snprintf(command, sizeof(command), "\004%s\n", dest); - bytes = strlen(command); + bytes = (ssize_t)strlen(command); - if (write(outfd, command, bytes) < bytes) + if (write(outfd, command, (size_t)bytes) < bytes) return (-1); /* @@ -474,7 +463,7 @@ status_long(int outfd, /* I - Command file descriptor */ while ((bytes = read(infd, buffer, sizeof(buffer))) > 0) { - fwrite(buffer, 1, bytes, stdout); + fwrite(buffer, 1, (size_t)bytes, stdout); fflush(stdout); } @@ -494,7 +483,7 @@ status_short(int outfd, /* I - Command file descriptor */ { char command[1024], /* Command buffer */ buffer[8192]; /* Status buffer */ - int bytes; /* Bytes read/written */ + ssize_t bytes; /* Bytes read/written */ /* @@ -506,9 +495,9 @@ status_short(int outfd, /* I - Command file descriptor */ else snprintf(command, sizeof(command), "\003%s\n", dest); - bytes = strlen(command); + bytes = (ssize_t)strlen(command); - if (write(outfd, command, bytes) < bytes) + if (write(outfd, command, (size_t)bytes) < bytes) return (-1); /* @@ -517,7 +506,7 @@ status_short(int outfd, /* I - Command file descriptor */ while ((bytes = read(infd, buffer, sizeof(buffer))) > 0) { - fwrite(buffer, 1, bytes, stdout); + fwrite(buffer, 1, (size_t)bytes, stdout); fflush(stdout); } diff --git a/scheduler/testmime.c b/scheduler/testmime.c index e2534ca6a..176e23767 100644 --- a/scheduler/testmime.c +++ b/scheduler/testmime.c @@ -1,24 +1,16 @@ /* * "$Id$" * - * MIME test program for CUPS. + * MIME test program for CUPS. * - * Copyright 2007-2013 by Apple Inc. - * Copyright 1997-2006 by Easy Software Products, all rights reserved. + * Copyright 2007-2014 by Apple Inc. + * Copyright 1997-2006 by Easy Software Products, all rights reserved. * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "LICENSE.txt" - * which should have been included with this file. If this file is - * file is missing or damaged, see the license at "http://www.cups.org/". - * - * Contents: - * - * main() - Main entry for the test program. - * add_ppd_filter() - Add a printer filter from a PPD. - * add_ppd_filters() - Add all filters from a PPD. - * print_rules() - Print the rules for a file type... - * type_dir() - Show the MIME types for a given directory. + * These coded instructions, statements, and computer programs are the + * property of Apple Inc. and are protected by Federal copyright + * law. Distribution and use rights are outlined in the file "LICENSE.txt" + * which should have been included with this file. If this file is + * file is missing or damaged, see the license at "http://www.cups.org/". */ /* @@ -135,7 +127,7 @@ main(int argc, /* I - Number of command-line args */ sscanf(argv[i], "%15[^/]/%255s", super, type); dst = mimeType(mime, super, type); - filters = mimeFilter2(mime, src, srcinfo.st_size, dst, &cost); + filters = mimeFilter2(mime, src, (size_t)srcinfo.st_size, dst, &cost); if (!filters) { @@ -264,7 +256,7 @@ add_ppd_filter(mime_t *mime, /* I - MIME database */ { char *ptr; /* Pointer into maxsize(nnnn) program */ - maxsize = strtoll(program + 8, &ptr, 10); + maxsize = (size_t)strtoll(program + 8, &ptr, 10); if (*ptr != ')') { diff --git a/scheduler/testspeed.c b/scheduler/testspeed.c index 2be9302f5..dfd984b15 100644 --- a/scheduler/testspeed.c +++ b/scheduler/testspeed.c @@ -1,23 +1,16 @@ /* * "$Id$" * - * Scheduler speed test for CUPS. + * Scheduler speed test for CUPS. * - * Copyright 2007-2010 by Apple Inc. - * Copyright 1997-2005 by Easy Software Products. + * Copyright 2007-2014 by Apple Inc. + * Copyright 1997-2005 by Easy Software Products. * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "LICENSE.txt" - * which should have been included with this file. If this file is - * file is missing or damaged, see the license at "http://www.cups.org/". - * - * Contents: - * - * main() - Send multiple IPP requests and report on the average response - * time. - * do_test() - Run a test on a specific host... - * usage() - Show program usage... + * These coded instructions, statements, and computer programs are the + * property of Apple Inc. and are protected by Federal copyright + * law. Distribution and use rights are outlined in the file "LICENSE.txt" + * which should have been included with this file. If this file is + * file is missing or damaged, see the license at "http://www.cups.org/". */ /* @@ -303,7 +296,7 @@ do_test(const char *server, /* I - Server to use */ if (opstring) op = ippOpValue(opstring); else - op = ops[i % (sizeof(ops) / sizeof(ops[0]))]; + op = ops[i % (int)(sizeof(ops) / sizeof(ops[0]))]; request = ippNewRequest(op); diff --git a/scheduler/testsub.c b/scheduler/testsub.c index 4635c6536..f8fec4973 100644 --- a/scheduler/testsub.c +++ b/scheduler/testsub.c @@ -1,23 +1,16 @@ /* * "$Id$" * - * Scheduler notification tester for CUPS. + * Scheduler notification tester for CUPS. * - * Copyright 2007-2012 by Apple Inc. - * Copyright 2006-2007 by Easy Software Products. + * Copyright 2007-2014 by Apple Inc. + * Copyright 2006-2007 by Easy Software Products. * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "LICENSE.txt" - * which should have been included with this file. If this file is - * file is missing or damaged, see the license at "http://www.cups.org/". - * - * Contents: - * - * main() - Subscribe to the . - * print_attributes() - Print the attributes in a request... - * sigterm_handler() - Flag when the user hits CTRL-C... - * usage() - Show program usage... + * These coded instructions, statements, and computer programs are the + * property of Apple Inc. and are protected by Federal copyright + * law. Distribution and use rights are outlined in the file "LICENSE.txt" + * which should have been included with this file. If this file is + * file is missing or damaged, see the license at "http://www.cups.org/". */ /* @@ -251,7 +244,7 @@ main(int argc, /* I - Number of command-line arguments */ interval = 5; ippDelete(response); - sleep(interval); + sleep((unsigned)interval); } /* diff --git a/scheduler/type.c b/scheduler/type.c index ce7fbdaa9..8357197f3 100644 --- a/scheduler/type.c +++ b/scheduler/type.c @@ -1,26 +1,16 @@ /* * "$Id$" * - * MIME typing routines for CUPS. + * MIME typing routines for CUPS. * - * Copyright 2007-2013 by Apple Inc. - * Copyright 1997-2006 by Easy Software Products, all rights reserved. + * Copyright 2007-2014 by Apple Inc. + * Copyright 1997-2006 by Easy Software Products, all rights reserved. * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "LICENSE.txt" - * which should have been included with this file. If this file is - * file is missing or damaged, see the license at "http://www.cups.org/". - * - * Contents: - * - * mimeAddType() - Add a MIME type to a database. - * mimeAddTypeRule() - Add a detection rule for a file type. - * mimeFileType() - Determine the type of a file. - * mimeType() - Lookup a file type. - * mime_compare_types() - Compare two MIME super/type names. - * mime_check_rules() - Check each rule in a list. - * mime_patmatch() - Pattern matching. + * These coded instructions, statements, and computer programs are the + * property of Apple Inc. and are protected by Federal copyright + * law. Distribution and use rights are outlined in the file "LICENSE.txt" + * which should have been included with this file. If this file is + * file is missing or damaged, see the license at "http://www.cups.org/". */ /* @@ -319,7 +309,7 @@ mimeAddTypeRule(mime_type_t *mt, /* I - Type to add to */ */ ptr = name; - while (isalnum(*rule & 255) && (ptr - name) < (sizeof(name) - 1)) + while (isalnum(*rule & 255) && (size_t)(ptr - name) < (sizeof(name) - 1)) *ptr++ = *rule++; *ptr = '\0'; @@ -332,12 +322,12 @@ mimeAddTypeRule(mime_type_t *mt, /* I - Type to add to */ rule ++; for (num_values = 0; - num_values < (sizeof(value) / sizeof(value[0])); + num_values < (int)(sizeof(value) / sizeof(value[0])); num_values ++) { ptr = value[num_values]; - while ((ptr - value[num_values]) < (sizeof(value[0]) - 1) && + while ((size_t)(ptr - value[num_values]) < (sizeof(value[0]) - 1) && *rule != '\0' && *rule != ',' && *rule != ')') { if (isspace(*rule & 255)) @@ -358,7 +348,7 @@ mimeAddTypeRule(mime_type_t *mt, /* I - Type to add to */ quote = *rule++; while (*rule != '\0' && *rule != quote && - (ptr - value[num_values]) < (sizeof(value[0]) - 1)) + (size_t)(ptr - value[num_values]) < (sizeof(value[0]) - 1)) *ptr++ = *rule++; if (*rule == quote) @@ -371,14 +361,14 @@ mimeAddTypeRule(mime_type_t *mt, /* I - Type to add to */ rule ++; while (*rule != '>' && *rule != '\0' && - (ptr - value[num_values]) < (sizeof(value[0]) - 1)) + (size_t)(ptr - value[num_values]) < (sizeof(value[0]) - 1)) { if (isxdigit(rule[0] & 255) && isxdigit(rule[1] & 255)) { if (isdigit(*rule)) - *ptr = (*rule++ - '0') << 4; + *ptr = (char)((*rule++ - '0') << 4); else - *ptr = (tolower(*rule++) - 'a' + 10) << 4; + *ptr = (char)((tolower(*rule++) - 'a' + 10) << 4); if (isdigit(*rule)) *ptr++ |= *rule++ - '0'; @@ -456,7 +446,7 @@ mimeAddTypeRule(mime_type_t *mt, /* I - Type to add to */ */ snprintf(value[0], sizeof(value[0]), "*.%s", name); - length[0] = strlen(value[0]); + length[0] = (int)strlen(value[0]); op = MIME_MAGIC_MATCH; } @@ -467,7 +457,7 @@ mimeAddTypeRule(mime_type_t *mt, /* I - Type to add to */ if ((temp = calloc(1, sizeof(mime_magic_t))) == NULL) return (-1); - temp->invert = invert; + temp->invert = (short)invert; if (current != NULL) { temp->parent = current->parent; @@ -509,13 +499,13 @@ mimeAddTypeRule(mime_type_t *mt, /* I - Type to add to */ */ current = temp; - temp->op = op; + temp->op = (short)op; invert = 0; switch (op) { case MIME_MAGIC_MATCH : - if (length[0] > (sizeof(temp->value.matchv) - 1)) + if ((size_t)length[0] > (sizeof(temp->value.matchv) - 1)) return (-1); strlcpy(temp->value.matchv, value[0], sizeof(temp->value.matchv)); break; @@ -535,7 +525,7 @@ mimeAddTypeRule(mime_type_t *mt, /* I - Type to add to */ case MIME_MAGIC_STRING : case MIME_MAGIC_ISTRING : temp->offset = strtol(value[0], NULL, 0); - if (length[1] > sizeof(temp->value.stringv)) + if ((size_t)length[1] > sizeof(temp->value.stringv)) return (-1); temp->length = length[1]; memcpy(temp->value.stringv, value[1], length[1]); @@ -543,7 +533,7 @@ mimeAddTypeRule(mime_type_t *mt, /* I - Type to add to */ case MIME_MAGIC_CHAR : temp->offset = strtol(value[0], NULL, 0); if (length[1] == 1) - temp->value.charv = value[1][0]; + temp->value.charv = (unsigned char)value[1][0]; else temp->value.charv = (unsigned char)strtol(value[1], NULL, 0); @@ -559,7 +549,7 @@ mimeAddTypeRule(mime_type_t *mt, /* I - Type to add to */ temp->value.intv = (unsigned)strtol(value[1], NULL, 0); break; case MIME_MAGIC_LOCALE : - if (length[0] > (sizeof(temp->value.localev) - 1)) + if ((size_t)length[0] > (sizeof(temp->value.localev) - 1)) return (-1); strlcpy(temp->value.localev, value[0], sizeof(temp->value.localev)); @@ -567,7 +557,7 @@ mimeAddTypeRule(mime_type_t *mt, /* I - Type to add to */ case MIME_MAGIC_CONTAINS : temp->offset = strtol(value[0], NULL, 0); temp->region = strtol(value[1], NULL, 0); - if (length[2] > sizeof(temp->value.stringv)) + if ((size_t)length[2] > sizeof(temp->value.stringv)) return (-1); temp->length = length[2]; memcpy(temp->value.stringv, value[2], length[2]); @@ -743,8 +733,8 @@ mime_check_rules( int n; /* Looping var */ int region; /* Region to look at */ int logic, /* Logic to apply */ - result, /* Result of test */ - intv; /* Integer value */ + result; /* Result of test */ + unsigned intv; /* Integer value */ short shortv; /* Short value */ unsigned char *bufptr; /* Pointer into buffer */ @@ -938,8 +928,7 @@ mime_check_rules( if ((rules->offset + rules->length) > (fb->offset + fb->length)) result = 0; else - result = (memcmp(fb->buffer + rules->offset - fb->offset, - rules->value.stringv, rules->length) == 0); + result = !memcmp(fb->buffer + rules->offset - fb->offset, rules->value.stringv, (size_t)rules->length); DEBUG_printf(("5mime_check_rules: result=%d", result)); break; @@ -969,9 +958,7 @@ mime_check_rules( if ((rules->offset + rules->length) > (fb->offset + fb->length)) result = 0; else - result = (_cups_strncasecmp((char *)fb->buffer + rules->offset - - fb->offset, - rules->value.stringv, rules->length) == 0); + result = !_cups_strncasecmp((char *)fb->buffer + rules->offset - fb->offset, rules->value.stringv, (size_t)rules->length); break; case MIME_MAGIC_CHAR : @@ -1031,7 +1018,7 @@ mime_check_rules( else { bufptr = fb->buffer + rules->offset - fb->offset; - shortv = (bufptr[0] << 8) | bufptr[1]; + shortv = (short)((bufptr[0] << 8) | bufptr[1]); result = (shortv == rules->value.shortv); } break; @@ -1064,19 +1051,16 @@ mime_check_rules( else { bufptr = fb->buffer + rules->offset - fb->offset; - intv = (((((bufptr[0] << 8) | bufptr[1]) << 8) | - bufptr[2]) << 8) | bufptr[3]; + intv = (unsigned)((((((bufptr[0] << 8) | bufptr[1]) << 8) | bufptr[2]) << 8) | bufptr[3]); result = (intv == rules->value.intv); } break; case MIME_MAGIC_LOCALE : #if defined(WIN32) || defined(__EMX__) || defined(__APPLE__) - result = (strcmp(rules->value.localev, - setlocale(LC_ALL, "")) == 0); + result = !strcmp(rules->value.localev, setlocale(LC_ALL, "")); #else - result = (strcmp(rules->value.localev, - setlocale(LC_MESSAGES, "")) == 0); + result = !strcmp(rules->value.localev, setlocale(LC_MESSAGES, "")); #endif /* __APPLE__ */ break; @@ -1113,9 +1097,7 @@ mime_check_rules( region = fb->length - rules->length; for (n = 0; n < region; n ++) - if ((result = (memcmp(fb->buffer + rules->offset - fb->offset + n, - rules->value.stringv, - rules->length) == 0)) != 0) + if ((result = (memcmp(fb->buffer + rules->offset - fb->offset + n, rules->value.stringv, (size_t)rules->length) == 0)) != 0) break; } break; diff --git a/scheduler/util.c b/scheduler/util.c index a9356c3c7..ae6182fd7 100644 --- a/scheduler/util.c +++ b/scheduler/util.c @@ -1,28 +1,16 @@ /* * "$Id$" * - * Mini-daemon utility functions for CUPS. + * Mini-daemon utility functions for CUPS. * - * Copyright 2007-2012 by Apple Inc. - * Copyright 1997-2005 by Easy Software Products. + * Copyright 2007-2014 by Apple Inc. + * Copyright 1997-2005 by Easy Software Products. * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "LICENSE.txt" - * which should have been included with this file. If this file is - * file is missing or damaged, see the license at "http://www.cups.org/". - * - * Contents: - * - * cupsdCompareNames() - Compare two names. - * cupsdCreateStringsArray() - Create a CUPS array of strings. - * cupsdExec() - Run a program with the correct environment. - * cupsdPipeCommand() - Read output from a command. - * cupsdSendIPPGroup() - Send a group tag. - * cupsdSendIPPHeader() - Send the IPP response header. - * cupsdSendIPPInteger() - Send an integer attribute. - * cupsdSendIPPString() - Send a string attribute. - * cupsdSendIPPTrailer() - Send the end-of-message tag. + * These coded instructions, statements, and computer programs are the + * property of Apple Inc. and are protected by Federal copyright + * law. Distribution and use rights are outlined in the file "LICENSE.txt" + * which should have been included with this file. If this file is + * file is missing or damaged, see the license at "http://www.cups.org/". */ /* @@ -251,7 +239,7 @@ cups_file_t * /* O - CUPS file or NULL on error */ cupsdPipeCommand(int *pid, /* O - Process ID or 0 on error */ const char *command, /* I - Command to run */ char **argv, /* I - Arguments to pass to command */ - int user) /* I - User to run as or 0 for current */ + uid_t user) /* I - User to run as or 0 for current */ { int fd, /* Temporary file descriptor */ fds[2]; /* Pipe file descriptors */ @@ -404,8 +392,8 @@ cupsdSendIPPInteger( putchar(value_tag); len = strlen(name); - putchar(len >> 8); - putchar(len); + putchar((int)(len >> 8)); + putchar((int)len); fputs(name, stdout); @@ -441,14 +429,14 @@ cupsdSendIPPString( putchar(value_tag); len = strlen(name); - putchar(len >> 8); - putchar(len); + putchar((int)(len >> 8)); + putchar((int)len); fputs(name, stdout); len = strlen(value); - putchar(len >> 8); - putchar(len); + putchar((int)(len >> 8)); + putchar((int)len); fputs(value, stdout); } diff --git a/scheduler/util.h b/scheduler/util.h index 6c2a05ace..c6bdf2226 100644 --- a/scheduler/util.h +++ b/scheduler/util.h @@ -1,16 +1,16 @@ /* * "$Id$" * - * Mini-daemon utility definitions for CUPS. + * Mini-daemon utility definitions for CUPS. * - * Copyright 2007-2011 by Apple Inc. - * Copyright 1997-2005 by Easy Software Products. + * Copyright 2007-2014 by Apple Inc. + * Copyright 1997-2005 by Easy Software Products. * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "LICENSE.txt" - * which should have been included with this file. If this file is - * file is missing or damaged, see the license at "http://www.cups.org/". + * These coded instructions, statements, and computer programs are the + * property of Apple Inc. and are protected by Federal copyright + * law. Distribution and use rights are outlined in the file "LICENSE.txt" + * which should have been included with this file. If this file is + * file is missing or damaged, see the license at "http://www.cups.org/". */ #ifndef _CUPSD_UTIL_H_ @@ -49,7 +49,7 @@ extern int cupsdCompareNames(const char *s, const char *t); extern cups_array_t *cupsdCreateStringsArray(const char *s); extern int cupsdExec(const char *command, char **argv); extern cups_file_t *cupsdPipeCommand(int *pid, const char *command, - char **argv, int user); + char **argv, uid_t user); extern void cupsdSendIPPGroup(ipp_tag_t group_tag); extern void cupsdSendIPPHeader(ipp_status_t status_code, int request_id); diff --git a/systemv/cupstestppd.c b/systemv/cupstestppd.c index 7c080a936..30d92b47d 100644 --- a/systemv/cupstestppd.c +++ b/systemv/cupstestppd.c @@ -144,7 +144,7 @@ main(int argc, /* I - Number of command-line args */ char *argv[]) /* I - Command-line arguments */ { int i, j, k, m, n; /* Looping vars */ - int len; /* Length of option name */ + size_t len; /* Length of option name */ char *opt; /* Option character */ const char *ptr; /* Pointer into string */ cups_file_t *fp; /* PPD file */ @@ -1470,7 +1470,7 @@ main(int argc, /* I - Number of command-line args */ k < group->num_options; k ++, option ++) { - len = (int)strlen(option->keyword); + len = strlen(option->keyword); for (m = 0, group2 = ppd->groups; m < ppd->num_groups; @@ -1479,7 +1479,7 @@ main(int argc, /* I - Number of command-line args */ n < group2->num_options; n ++, option2 ++) if (option != option2 && - len < (int)strlen(option2->keyword) && + len < strlen(option2->keyword) && !strncmp(option->keyword, option2->keyword, len)) { _cupsLangPrintf(stdout, diff --git a/systemv/lp.c b/systemv/lp.c index 8f95966b4..9e895d4d6 100644 --- a/systemv/lp.c +++ b/systemv/lp.c @@ -1,22 +1,16 @@ /* * "$Id$" * - * "lp" command for CUPS. + * "lp" command for CUPS. * - * Copyright 2007-2013 by Apple Inc. - * Copyright 1997-2007 by Easy Software Products. + * Copyright 2007-2014 by Apple Inc. + * Copyright 1997-2007 by Easy Software Products. * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "LICENSE.txt" - * which should have been included with this file. If this file is - * file is missing or damaged, see the license at "http://www.cups.org/". - * - * Contents: - * - * main() - Parse options and send files for printing. - * restart_job() - Restart a job. - * set_job_attrs() - Set job attributes. + * These coded instructions, statements, and computer programs are the + * property of Apple Inc. and are protected by Federal copyright + * law. Distribution and use rights are outlined in the file "LICENSE.txt" + * which should have been included with this file. If this file is + * file is missing or damaged, see the license at "http://www.cups.org/". */ /* @@ -640,7 +634,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) { diff --git a/systemv/lpadmin.c b/systemv/lpadmin.c index a0ed62c6c..fe1e31e2a 100644 --- a/systemv/lpadmin.c +++ b/systemv/lpadmin.c @@ -1,30 +1,16 @@ /* * "$Id$" * - * "lpadmin" command for CUPS. + * "lpadmin" command for CUPS. * - * Copyright 2007-2011 by Apple Inc. - * Copyright 1997-2006 by Easy Software Products. + * Copyright 2007-2014 by Apple Inc. + * Copyright 1997-2006 by Easy Software Products. * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "LICENSE.txt" - * which should have been included with this file. If this file is - * file is missing or damaged, see the license at "http://www.cups.org/". - * - * Contents: - * - * main() - Parse options and configure the scheduler. - * add_printer_to_class() - Add a printer to a class. - * default_printer() - Set the default printing destination. - * delete_printer() - Delete a printer from the system. - * delete_printer_from_class() - Delete a printer from a class. - * delete_printer_option() - Delete a printer option. - * enable_printer() - Enable a printer. - * get_printer_type() - Determine the printer type and URI. - * set_printer_options() - Set the printer options and/or file. - * validate_name() - Make sure the printer name only contains - * valid chars. + * These coded instructions, statements, and computer programs are the + * property of Apple Inc. and are protected by Federal copyright + * law. Distribution and use rights are outlined in the file "LICENSE.txt" + * which should have been included with this file. If this file is + * file is missing or damaged, see the license at "http://www.cups.org/". */ /* @@ -1201,8 +1187,7 @@ get_printer_type(http_t *http, /* I - Server connection */ * requesting-user-name */ - httpAssembleURIf(HTTP_URI_CODING_ALL, uri, urisize, "ipp", NULL, "localhost", - ippPort(), "/printers/%s", printer); + httpAssembleURIf(HTTP_URI_CODING_ALL, uri, (int)urisize, "ipp", NULL, "localhost", ippPort(), "/printers/%s", printer); request = ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, @@ -1223,8 +1208,7 @@ get_printer_type(http_t *http, /* I - Server connection */ type = (cups_ptype_t)attr->values[0].integer; if (type & CUPS_PRINTER_CLASS) - httpAssembleURIf(HTTP_URI_CODING_ALL, uri, urisize, "ipp", NULL, - "localhost", ippPort(), "/classes/%s", printer); + httpAssembleURIf(HTTP_URI_CODING_ALL, uri, (int)urisize, "ipp", NULL, "localhost", ippPort(), "/classes/%s", printer); } else type = CUPS_PRINTER_LOCAL; diff --git a/systemv/lpoptions.c b/systemv/lpoptions.c index 12dbe5f85..36d989986 100644 --- a/systemv/lpoptions.c +++ b/systemv/lpoptions.c @@ -1,23 +1,16 @@ /* * "$Id$" * - * Printer option program for CUPS. + * Printer option program for CUPS. * - * Copyright 2007-2011 by Apple Inc. - * Copyright 1997-2006 by Easy Software Products. + * Copyright 2007-2014 by Apple Inc. + * Copyright 1997-2006 by Easy Software Products. * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "LICENSE.txt" - * which should have been included with this file. If this file is - * file is missing or damaged, see the license at "http://www.cups.org/". - * - * Contents: - * - * main() - Main entry. - * list_group() - List printer-specific options from the PPD group. - * list_options() - List printer-specific options from the PPD file. - * usage() - Show program usage and exit. + * These coded instructions, statements, and computer programs are the + * property of Apple Inc. and are protected by Federal copyright + * law. Distribution and use rights are outlined in the file "LICENSE.txt" + * which should have been included with this file. If this file is + * file is missing or damaged, see the license at "http://www.cups.org/". */ /* @@ -274,8 +267,7 @@ main(int argc, /* I - Number of command-line arguments */ num_options --; if (j < num_options) - memcpy(options + j, options + j + 1, - sizeof(cups_option_t) * (num_options - j)); + memmove(options + j, options + j + 1, sizeof(cups_option_t) * (size_t)(num_options - j)); break; } @@ -322,7 +314,7 @@ main(int argc, /* I - Number of command-line arguments */ j = dest - dests; if (j < num_dests) - memcpy(dest, dest + 1, (num_dests - j) * sizeof(cups_dest_t)); + memmove(dest, dest + 1, (size_t)(num_dests - j) * sizeof(cups_dest_t)); } } @@ -385,14 +377,12 @@ main(int argc, /* I - Number of command-line arguments */ *ptr++ = ' '; if (!options[i].value[0]) - strlcpy(ptr, options[i].name, sizeof(buffer) - (ptr - buffer)); + strlcpy(ptr, options[i].name, sizeof(buffer) - (size_t)(ptr - buffer)); else if (strchr(options[i].value, ' ') != NULL || strchr(options[i].value, '\t') != NULL) - snprintf(ptr, sizeof(buffer) - (ptr - buffer), "%s=\'%s\'", - options[i].name, options[i].value); + snprintf(ptr, sizeof(buffer) - (size_t)(ptr - buffer), "%s=\'%s\'", options[i].name, options[i].value); else - snprintf(ptr, sizeof(buffer) - (ptr - buffer), "%s=%s", - options[i].name, options[i].value); + snprintf(ptr, sizeof(buffer) - (size_t)(ptr - buffer), "%s=%s", options[i].name, options[i].value); ptr += strlen(ptr); } @@ -450,19 +440,16 @@ list_group(ppd_file_t *ppd, /* I - PPD file */ if ((coption = ppdFindCustomOption(ppd, option->keyword)) == NULL || cupsArrayCount(coption->params) == 0) - snprintf(ptr, sizeof(buffer) - (ptr - buffer), " %sCustom", - choice->marked ? "*" : ""); + snprintf(ptr, sizeof(buffer) - (size_t)(ptr - buffer), " %sCustom", choice->marked ? "*" : ""); else if (!_cups_strcasecmp(option->keyword, "PageSize") || !_cups_strcasecmp(option->keyword, "PageRegion")) - snprintf(ptr, sizeof(buffer) - (ptr - buffer), - " %sCustom.WIDTHxHEIGHT", choice->marked ? "*" : ""); + snprintf(ptr, sizeof(buffer) - (size_t)(ptr - buffer), " %sCustom.WIDTHxHEIGHT", choice->marked ? "*" : ""); else { cparam = (ppd_cparam_t *)cupsArrayFirst(coption->params); if (cupsArrayCount(coption->params) == 1) - snprintf(ptr, sizeof(buffer) - (ptr - buffer), " %sCustom.%s", - choice->marked ? "*" : "", types[cparam->type]); + snprintf(ptr, sizeof(buffer) - (size_t)(ptr - buffer), " %sCustom.%s", choice->marked ? "*" : "", types[cparam->type]); else { const char *prefix; /* Prefix string */ @@ -475,22 +462,21 @@ list_group(ppd_file_t *ppd, /* I - PPD file */ while (cparam) { - snprintf(ptr, sizeof(buffer) - (ptr - buffer), "%s%s=%s", prefix, - cparam->name, types[cparam->type]); + snprintf(ptr, sizeof(buffer) - (size_t)(ptr - buffer), "%s%s=%s", prefix, cparam->name, types[cparam->type]); cparam = (ppd_cparam_t *)cupsArrayNext(coption->params); prefix = " "; ptr += strlen(ptr); } if (ptr < (buffer + sizeof(buffer) - 1)) - strlcpy(ptr, "}", sizeof(buffer) - (ptr - buffer)); + strlcpy(ptr, "}", sizeof(buffer) - (size_t)(ptr - buffer)); } } } else if (choice->marked) - snprintf(ptr, sizeof(buffer) - (ptr - buffer), " *%s", choice->choice); + snprintf(ptr, sizeof(buffer) - (size_t)(ptr - buffer), " *%s", choice->choice); else - snprintf(ptr, sizeof(buffer) - (ptr - buffer), " %s", choice->choice); + snprintf(ptr, sizeof(buffer) - (size_t)(ptr - buffer), " %s", choice->choice); ptr += strlen(ptr); } diff --git a/systemv/lpstat.c b/systemv/lpstat.c index 370efc9db..084fc55c0 100644 --- a/systemv/lpstat.c +++ b/systemv/lpstat.c @@ -3,7 +3,7 @@ * * "lpstat" command for CUPS. * - * Copyright 2007-2013 by Apple Inc. + * Copyright 2007-2014 by Apple Inc. * Copyright 1997-2006 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -1478,11 +1478,9 @@ show_jobs(const char *dests, /* I - Destinations */ for (i = 0, aptr = alerts; i < reasons->num_values; i ++) { if (i) - snprintf(aptr, sizeof(alerts) - (aptr - alerts), " %s", - reasons->values[i].string.text); + snprintf(aptr, sizeof(alerts) - (size_t)(aptr - alerts), " %s", reasons->values[i].string.text); else - strlcpy(alerts, reasons->values[i].string.text, - sizeof(alerts)); + strlcpy(alerts, reasons->values[i].string.text, sizeof(alerts)); aptr += strlen(aptr); } @@ -1764,7 +1762,7 @@ show_printers(const char *printers, /* I - Destinations */ jobid = jobattr->values[0].integer; else if (!strcmp(jobattr->name, "job-state") && jobattr->value_tag == IPP_TAG_ENUM) - jobstate = jobattr->values[0].integer; + jobstate = (ipp_jstate_t)jobattr->values[0].integer; } if (jobstate != IPP_JOB_PROCESSING) @@ -1829,11 +1827,9 @@ show_printers(const char *printers, /* I - Destinations */ for (i = 0, aptr = alerts; i < reasons->num_values; i ++) { if (i) - snprintf(aptr, sizeof(alerts) - (aptr - alerts), " %s", - reasons->values[i].string.text); + snprintf(aptr, sizeof(alerts) - (size_t)(aptr - alerts), " %s", reasons->values[i].string.text); else - strlcpy(alerts, reasons->values[i].string.text, - sizeof(alerts)); + strlcpy(alerts, reasons->values[i].string.text, sizeof(alerts)); aptr += strlen(aptr); } @@ -1955,11 +1951,9 @@ show_printers(const char *printers, /* I - Destinations */ for (i = 0, aptr = alerts; i < reasons->num_values; i ++) { if (i) - snprintf(aptr, sizeof(alerts) - (aptr - alerts), " %s", - reasons->values[i].string.text); + snprintf(aptr, sizeof(alerts) - (size_t)(aptr - alerts), " %s", reasons->values[i].string.text); else - strlcpy(alerts, reasons->values[i].string.text, - sizeof(alerts)); + strlcpy(alerts, reasons->values[i].string.text, sizeof(alerts)); aptr += strlen(aptr); } diff --git a/test/ippfind.c b/test/ippfind.c index 2331222bf..59dbdbf77 100644 --- a/test/ippfind.c +++ b/test/ippfind.c @@ -1,42 +1,19 @@ /* * "$Id$" * - * Utility to find IPP printers via Bonjour/DNS-SD and optionally run - * commands such as IPP and Bonjour conformance tests. This tool is - * inspired by the UNIX "find" command, thus its name. + * Utility to find IPP printers via Bonjour/DNS-SD and optionally run + * commands such as IPP and Bonjour conformance tests. This tool is + * inspired by the UNIX "find" command, thus its name. * - * Copyright 2008-2013 by Apple Inc. + * Copyright 2008-2014 by Apple Inc. * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "LICENSE.txt" - * which should have been included with this file. If this file is - * file is missing or damaged, see the license at "http://www.cups.org/". + * These coded instructions, statements, and computer programs are the + * property of Apple Inc. and are protected by Federal copyright + * law. Distribution and use rights are outlined in the file "LICENSE.txt" + * which should have been included with this file. If this file is + * file is missing or damaged, see the license at "http://www.cups.org/". * - * This file is subject to the Apple OS-Developed Software exception. - * - * Contents: - * - * main() - Browse for printers. - * browse_callback() - Browse devices. - * browse_local_callback() - Browse local devices. - * browse_callback() - Browse devices. - * client_callback() - Avahi client callback function. - * compare_services() - Compare two devices. - * dnssd_error_string() - Return an error string for an error code. - * eval_expr() - Evaluate the expressions against the specified - * service. - * exec_program() - Execute a program for a service. - * get_service() - Create or update a device. - * get_time() - Get the current time-of-day in seconds. - * list_service() - List the contents of a service. - * new_expr() - Create a new expression. - * poll_callback() - Wait for input on the specified file - * descriptors. - * resolve_callback() - Process resolve data. - * set_service_uri() - Set the URI of the service. - * show_usage() - Show program usage. - * show_version() - Show program version. + * This file is subject to the Apple OS-Developed Software exception. */ /* @@ -782,7 +759,6 @@ main(int argc, /* I - Number of command-line args */ "ippfind"); show_usage(); } - show_usage(); if (!strcmp(argv[i], "1.1")) ipp_version = 11; @@ -948,7 +924,6 @@ main(int argc, /* I - Number of command-line args */ _cupsLangPrintf(stderr, _("%s: Unknown option \"-%c\"."), "ippfind", *opt); show_usage(); - break; } if (temp) @@ -1490,6 +1465,9 @@ browse_callback( * Only process "add" data... */ + (void)sdRef; + (void)interfaceIndex; + if (errorCode != kDNSServiceErr_NoError || !(flags & kDNSServiceFlagsAdd)) return; @@ -1523,6 +1501,9 @@ browse_local_callback( * Only process "add" data... */ + (void)sdRef; + (void)interfaceIndex; + if (errorCode != kDNSServiceErr_NoError || !(flags & kDNSServiceFlagsAdd)) return; @@ -1912,14 +1893,14 @@ exec_program(ippfind_srv_t *service, /* I - Service */ snprintf(txt[i], sizeof(txt[i]), "IPPFIND_TXT_%s=%s", service->txt[i].name, service->txt[i].value); for (ptr = txt[i] + 12; *ptr && *ptr != '='; ptr ++) - *ptr = _cups_toupper(*ptr); + *ptr = (char)_cups_toupper(*ptr); } for (i = 0, myenvc = 7 + service->num_txt; environ[i]; i ++) if (strncmp(environ[i], "IPPFIND_", 8)) myenvc ++; - if ((myenvp = calloc(sizeof(char *), myenvc + 1)) == NULL) + if ((myenvp = calloc(sizeof(char *), (size_t)(myenvc + 1))) == NULL) { _cupsLangPuts(stderr, _("ippfind: Out of memory.")); exit(IPPFIND_EXIT_MEMORY); @@ -1944,7 +1925,7 @@ exec_program(ippfind_srv_t *service, /* I - Service */ * Allocate and copy command-line arguments... */ - if ((myargv = calloc(sizeof(char *), num_args + 1)) == NULL) + if ((myargv = calloc(sizeof(char *), (size_t)(num_args + 1))) == NULL) { _cupsLangPuts(stderr, _("ippfind: Out of memory.")); exit(IPPFIND_EXIT_MEMORY); @@ -1980,24 +1961,24 @@ exec_program(ippfind_srv_t *service, /* I - Service */ *kptr = '\0'; if (!keyword[0] || !strcmp(keyword, "service_uri")) - strlcpy(tptr, service->uri, sizeof(temp) - (tptr - temp)); + strlcpy(tptr, service->uri, sizeof(temp) - (size_t)(tptr - temp)); else if (!strcmp(keyword, "service_domain")) - strlcpy(tptr, service->domain, sizeof(temp) - (tptr - temp)); + strlcpy(tptr, service->domain, sizeof(temp) - (size_t)(tptr - temp)); else if (!strcmp(keyword, "service_hostname")) - strlcpy(tptr, service->host, sizeof(temp) - (tptr - temp)); + strlcpy(tptr, service->host, sizeof(temp) - (size_t)(tptr - temp)); else if (!strcmp(keyword, "service_name")) - strlcpy(tptr, service->name, sizeof(temp) - (tptr - temp)); + strlcpy(tptr, service->name, sizeof(temp) - (size_t)(tptr - temp)); else if (!strcmp(keyword, "service_path")) - strlcpy(tptr, service->resource, sizeof(temp) - (tptr - temp)); + strlcpy(tptr, service->resource, sizeof(temp) - (size_t)(tptr - temp)); else if (!strcmp(keyword, "service_port")) - strlcpy(tptr, port + 20, sizeof(temp) - (tptr - temp)); + strlcpy(tptr, port + 20, sizeof(temp) - (size_t)(tptr - temp)); else if (!strcmp(keyword, "service_scheme")) - strlcpy(tptr, scheme + 22, sizeof(temp) - (tptr - temp)); + strlcpy(tptr, scheme + 22, sizeof(temp) - (size_t)(tptr - temp)); else if (!strncmp(keyword, "txt_", 4)) { if ((ptr = (char *)cupsGetOption(keyword + 4, service->num_txt, service->txt)) != NULL) - strlcpy(tptr, strdup(ptr), sizeof(temp) - (tptr - temp)); + strlcpy(tptr, strdup(ptr), sizeof(temp) - (size_t)(tptr - temp)); else *tptr = '\0'; } @@ -2279,7 +2260,7 @@ list_service(ippfind_srv_t *service) /* I - Service */ if ((attr = ippFindAttribute(response, "printer-state", IPP_TAG_ENUM)) != NULL) - pstate = ippGetInteger(attr, 0); + pstate = (ipp_pstate_t)ippGetInteger(attr, 0); else pstate = IPP_PSTATE_STOPPED; @@ -2466,8 +2447,8 @@ new_expr(ippfind_op_t op, /* I - Operation */ break; temp->num_args = num_args; - temp->args = malloc(num_args * sizeof(char *)); - memcpy(temp->args, args, num_args * sizeof(char *)); + temp->args = malloc((size_t)num_args * sizeof(char *)); + memcpy(temp->args, args, (size_t)num_args * sizeof(char *)); } return (temp); @@ -2536,7 +2517,12 @@ resolve_callback( * Only process "add" data... */ - if (errorCode != kDNSServiceErr_NoError) + (void)sdRef; + (void)flags; + (void)interfaceIndex; + (void)fullName; + + if (errorCode != kDNSServiceErr_NoError) { _cupsLangPrintf(stderr, _("ippfind: Unable to browse or resolve: %s"), dnssd_error_string(errorCode)); diff --git a/test/ippserver.c b/test/ippserver.c index 00c6c6e58..9bd717ee6 100644 --- a/test/ippserver.c +++ b/test/ippserver.c @@ -1,75 +1,17 @@ /* * "$Id$" * - * Sample IPP/2.0 server for CUPS. + * Sample IPP/2.0 server for CUPS. * - * Copyright 2010-2013 by Apple Inc. + * Copyright 2010-2014 by Apple Inc. * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "LICENSE.txt" - * which should have been included with this file. If this file is - * file is missing or damaged, see the license at "http://www.cups.org/". + * These coded instructions, statements, and computer programs are the + * property of Apple Inc. and are protected by Federal copyright + * law. Distribution and use rights are outlined in the file "LICENSE.txt" + * which should have been included with this file. If this file is + * file is missing or damaged, see the license at "http://www.cups.org/". * - * This file is subject to the Apple OS-Developed Software exception. - * - * Contents: - * - * main() - Main entry to the sample server. - * clean_jobs() - Clean out old (completed) jobs. - * compare_jobs() - Compare two jobs. - * copy_attributes() - Copy attributes from one request to - * another. - * copy_job_attrs() - Copy job attributes to the response. - * create_client() - Accept a new network connection and create - * a client object. - * create_job() - Create a new job object from a Print-Job or - * Create-Job request. - * create_listener() - Create a listener socket. - * create_media_col() - Create a media-col value. - * create_printer() - Create, register, and listen for - * connections to a printer object. - * create_requested_array() - Create an array for requested-attributes. - * debug_attributes() - Print attributes in a request or response. - * delete_client() - Close the socket and free all memory used - * by a client object. - * delete_job() - Remove from the printer and free all memory - * used by a job object. - * delete_printer() - Unregister, close listen sockets, and free - * all memory used by a printer object. - * dnssd_callback() - Handle Bonjour registration events. - * find_job() - Find a job specified in a request. - * html_escape() - Write a HTML-safe string. - * html_printf() - Send formatted text to the client, quoting - * as needed. - * ipp_cancel_job() - Cancel a job. - * ipp_create_job() - Create a job object. - * ipp_get_job_attributes() - Get the attributes for a job object. - * ipp_get_jobs() - Get a list of job objects. - * ipp_get_printer_attributes() - Get the attributes for a printer object. - * ipp_print_job() - Create a job object with an attached - * document. - * ipp_print_uri() - Create a job object with a referenced - * document. - * ipp_send_document() - Add an attached document to a job object - * created with Create-Job. - * ipp_send_uri() - Add a referenced document to a job object - * created with Create-Job. - * ipp_validate_job() - Validate job creation attributes. - * process_client() - Process client requests on a thread. - * process_http() - Process a HTTP request. - * process_ipp() - Process an IPP request. - * process_job() - Process a print job. - * register_printer() - Register a printer object via Bonjour. - * respond_http() - Send a HTTP response. - * respond_ipp() - Send an IPP response. - * respond_unsupported() - Respond with an unsupported attribute. - * run_printer() - Run the printer service. - * usage() - Show program usage. - * valid_doc_attributes() - Determine whether the document attributes - * are valid. - * valid_job_attributes() - Determine whether the job attributes are - * valid. + * This file is subject to the Apple OS-Developed Software exception. */ /* @@ -440,7 +382,6 @@ main(int argc, /* I - Number of command-line args */ case 'h' : /* -h (show help) */ usage(0); - break; case 'i' : /* -i icon.png */ i ++; @@ -505,7 +446,6 @@ main(int argc, /* I - Number of command-line args */ default : /* Unknown */ fprintf(stderr, "Unknown option \"-%c\".\n", *opt); usage(1); - break; } } else if (!name) @@ -675,57 +615,57 @@ copy_job_attributes( { case IPP_JSTATE_PENDING : ippAddString(client->response, IPP_TAG_JOB, - IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST, "job-state-reasons", + IPP_CONST_TAG(IPP_TAG_KEYWORD), "job-state-reasons", NULL, "none"); break; case IPP_JSTATE_HELD : if (job->fd >= 0) ippAddString(client->response, IPP_TAG_JOB, - IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST, + IPP_CONST_TAG(IPP_TAG_KEYWORD), "job-state-reasons", NULL, "job-incoming"); else if (ippFindAttribute(job->attrs, "job-hold-until", IPP_TAG_ZERO)) ippAddString(client->response, IPP_TAG_JOB, - IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST, + IPP_CONST_TAG(IPP_TAG_KEYWORD), "job-state-reasons", NULL, "job-hold-until-specified"); else ippAddString(client->response, IPP_TAG_JOB, - IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST, + IPP_CONST_TAG(IPP_TAG_KEYWORD), "job-state-reasons", NULL, "job-data-insufficient"); break; case IPP_JSTATE_PROCESSING : if (job->cancel) ippAddString(client->response, IPP_TAG_JOB, - IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST, + IPP_CONST_TAG(IPP_TAG_KEYWORD), "job-state-reasons", NULL, "processing-to-stop-point"); else ippAddString(client->response, IPP_TAG_JOB, - IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST, + IPP_CONST_TAG(IPP_TAG_KEYWORD), "job-state-reasons", NULL, "job-printing"); break; case IPP_JSTATE_STOPPED : ippAddString(client->response, IPP_TAG_JOB, - IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST, "job-state-reasons", + IPP_CONST_TAG(IPP_TAG_KEYWORD), "job-state-reasons", NULL, "job-stopped"); break; case IPP_JSTATE_CANCELED : ippAddString(client->response, IPP_TAG_JOB, - IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST, "job-state-reasons", + IPP_CONST_TAG(IPP_TAG_KEYWORD), "job-state-reasons", NULL, "job-canceled-by-user"); break; case IPP_JSTATE_ABORTED : ippAddString(client->response, IPP_TAG_JOB, - IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST, "job-state-reasons", + IPP_CONST_TAG(IPP_TAG_KEYWORD), "job-state-reasons", NULL, "aborted-by-system"); break; case IPP_JSTATE_COMPLETED : ippAddString(client->response, IPP_TAG_JOB, - IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST, "job-state-reasons", + IPP_CONST_TAG(IPP_TAG_KEYWORD), "job-state-reasons", NULL, "job-completed-successfully"); break; } @@ -734,12 +674,12 @@ copy_job_attributes( if (!ra || cupsArrayFind(ra, "time-at-completed")) ippAddInteger(client->response, IPP_TAG_JOB, job->completed ? IPP_TAG_INTEGER : IPP_TAG_NOVALUE, - "time-at-completed", job->completed); + "time-at-completed", (int)job->completed); if (!ra || cupsArrayFind(ra, "time-at-processing")) ippAddInteger(client->response, IPP_TAG_JOB, job->processing ? IPP_TAG_INTEGER : IPP_TAG_NOVALUE, - "time-at-processing", job->processing); + "time-at-processing", (int)job->processing); } @@ -846,7 +786,7 @@ create_job(_ipp_client_t *client) /* I - Client */ ippSetName(job->attrs, &attr, "job-originating-user-name"); else attr = ippAddString(job->attrs, IPP_TAG_JOB, - IPP_TAG_NAME | IPP_TAG_CUPS_CONST, + IPP_CONST_TAG(IPP_TAG_NAME), "job-originating-user-name", NULL, "anonymous"); if (attr) @@ -1239,18 +1179,17 @@ create_printer(const char *servername, /* I - Server hostname (NULL for default) for (i = 0; i < num_formats; i ++) { if (!_cups_strcasecmp(formats[i], "application/pdf")) - snprintf(ptr, sizeof(device_id) - (ptr - device_id), "%sPDF", prefix); + snprintf(ptr, sizeof(device_id) - (size_t)(ptr - device_id), "%sPDF", prefix); else if (!_cups_strcasecmp(formats[i], "application/postscript")) - snprintf(ptr, sizeof(device_id) - (ptr - device_id), "%sPS", prefix); + snprintf(ptr, sizeof(device_id) - (size_t)(ptr - device_id), "%sPS", prefix); else if (!_cups_strcasecmp(formats[i], "application/vnd.hp-PCL")) - snprintf(ptr, sizeof(device_id) - (ptr - device_id), "%sPCL", prefix); + snprintf(ptr, sizeof(device_id) - (size_t)(ptr - device_id), "%sPCL", prefix); else if (!_cups_strcasecmp(formats[i], "image/jpeg")) - snprintf(ptr, sizeof(device_id) - (ptr - device_id), "%sJPEG", prefix); + snprintf(ptr, sizeof(device_id) - (size_t)(ptr - device_id), "%sJPEG", prefix); else if (!_cups_strcasecmp(formats[i], "image/png")) - snprintf(ptr, sizeof(device_id) - (ptr - device_id), "%sPNG", prefix); + snprintf(ptr, sizeof(device_id) - (size_t)(ptr - device_id), "%sPNG", prefix); else if (_cups_strcasecmp(formats[i], "application/octet-stream")) - snprintf(ptr, sizeof(device_id) - (ptr - device_id), "%s%s", prefix, - formats[i]); + snprintf(ptr, sizeof(device_id) - (size_t)(ptr - device_id), "%s%s", prefix, formats[i]); ptr += strlen(ptr); prefix = ","; @@ -1294,12 +1233,12 @@ create_printer(const char *servername, /* I - Server hostname (NULL for default) /* charset-configured */ ippAddString(printer->attrs, IPP_TAG_PRINTER, - IPP_TAG_CHARSET | IPP_TAG_CUPS_CONST, + IPP_CONST_TAG(IPP_TAG_CHARSET), "charset-configured", NULL, "utf-8"); /* charset-supported */ ippAddStrings(printer->attrs, IPP_TAG_PRINTER, - IPP_TAG_CHARSET | IPP_TAG_CUPS_CONST, + IPP_CONST_TAG(IPP_TAG_CHARSET), "charset-supported", sizeof(charsets) / sizeof(charsets[0]), NULL, charsets); @@ -1309,7 +1248,7 @@ create_printer(const char *servername, /* I - Server hostname (NULL for default) /* compression-supported */ ippAddStrings(printer->attrs, IPP_TAG_PRINTER, - IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST, + IPP_CONST_TAG(IPP_TAG_KEYWORD), "compression-supported", (int)(sizeof(compressions) / sizeof(compressions[0])), NULL, compressions); @@ -1340,12 +1279,12 @@ create_printer(const char *servername, /* I - Server hostname (NULL for default) /* generated-natural-language-supported */ ippAddString(printer->attrs, IPP_TAG_PRINTER, - IPP_TAG_LANGUAGE | IPP_TAG_CUPS_CONST, + IPP_CONST_TAG(IPP_TAG_LANGUAGE), "generated-natural-language-supported", NULL, "en"); /* ipp-versions-supported */ ippAddStrings(printer->attrs, IPP_TAG_PRINTER, - IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST, + IPP_CONST_TAG(IPP_TAG_KEYWORD), "ipp-versions-supported", sizeof(versions) / sizeof(versions[0]), NULL, versions); @@ -1358,7 +1297,7 @@ create_printer(const char *servername, /* I - Server hostname (NULL for default) /* job-creation-attributes-supported */ ippAddStrings(printer->attrs, IPP_TAG_PRINTER, - IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST, + IPP_CONST_TAG(IPP_TAG_KEYWORD), "job-creation-attributes-supported", sizeof(job_creation) / sizeof(job_creation[0]), NULL, job_creation); @@ -1381,12 +1320,12 @@ create_printer(const char *servername, /* I - Server hostname (NULL for default) /* job-sheets-default */ ippAddString(printer->attrs, IPP_TAG_PRINTER, - IPP_TAG_NAME | IPP_TAG_CUPS_CONST, + IPP_CONST_TAG(IPP_TAG_NAME), "job-sheets-default", NULL, "none"); /* job-sheets-supported */ ippAddString(printer->attrs, IPP_TAG_PRINTER, - IPP_TAG_NAME | IPP_TAG_CUPS_CONST, + IPP_CONST_TAG(IPP_TAG_NAME), "job-sheets-supported", NULL, "none"); /* media-bottom-margin-supported */ @@ -1472,7 +1411,7 @@ create_printer(const char *servername, /* I - Server hostname (NULL for default) /* media-col-supported */ ippAddStrings(printer->attrs, IPP_TAG_PRINTER, - IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST, + IPP_CONST_TAG(IPP_TAG_KEYWORD), "media-col-supported", (int)(sizeof(media_col_supported) / sizeof(media_col_supported[0])), NULL, @@ -1480,7 +1419,7 @@ create_printer(const char *servername, /* I - Server hostname (NULL for default) /* media-default */ ippAddString(printer->attrs, IPP_TAG_PRINTER, - IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST, + IPP_CONST_TAG(IPP_TAG_KEYWORD), "media-default", NULL, media_supported[0]); /* media-left-margin-supported */ @@ -1499,7 +1438,7 @@ create_printer(const char *servername, /* I - Server hostname (NULL for default) /* media-supported */ ippAddStrings(printer->attrs, IPP_TAG_PRINTER, - IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST, + IPP_CONST_TAG(IPP_TAG_KEYWORD), "media-supported", (int)(sizeof(media_supported) / sizeof(media_supported[0])), NULL, media_supported); @@ -1526,7 +1465,7 @@ create_printer(const char *servername, /* I - Server hostname (NULL for default) /* media-type-supported */ ippAddStrings(printer->attrs, IPP_TAG_PRINTER, - IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST, + IPP_CONST_TAG(IPP_TAG_KEYWORD), "media-type-supported", (int)(sizeof(media_type_supported) / sizeof(media_type_supported[0])), @@ -1534,7 +1473,7 @@ create_printer(const char *servername, /* I - Server hostname (NULL for default) /* multiple-document-handling-supported */ ippAddStrings(printer->attrs, IPP_TAG_PRINTER, - IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST, + IPP_CONST_TAG(IPP_TAG_KEYWORD), "multiple-document-handling-supported", sizeof(multiple_document_handling) / sizeof(multiple_document_handling[0]), NULL, @@ -1546,7 +1485,7 @@ create_printer(const char *servername, /* I - Server hostname (NULL for default) /* natural-language-configured */ ippAddString(printer->attrs, IPP_TAG_PRINTER, - IPP_TAG_LANGUAGE | IPP_TAG_CUPS_CONST, + IPP_CONST_TAG(IPP_TAG_LANGUAGE), "natural-language-configured", NULL, "en"); /* number-up-default */ @@ -1571,12 +1510,12 @@ create_printer(const char *servername, /* I - Server hostname (NULL for default) /* output-bin-default */ ippAddString(printer->attrs, IPP_TAG_PRINTER, - IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST, + IPP_CONST_TAG(IPP_TAG_KEYWORD), "output-bin-default", NULL, "face-down"); /* output-bin-supported */ ippAddString(printer->attrs, IPP_TAG_PRINTER, - IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST, + IPP_CONST_TAG(IPP_TAG_KEYWORD), "output-bin-supported", NULL, "face-down"); /* pages-per-minute */ @@ -1590,7 +1529,7 @@ create_printer(const char *servername, /* I - Server hostname (NULL for default) /* pdl-override-supported */ ippAddString(printer->attrs, IPP_TAG_PRINTER, - IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST, + IPP_CONST_TAG(IPP_TAG_KEYWORD), "pdl-override-supported", NULL, "attempted"); /* print-quality-default */ @@ -1687,7 +1626,7 @@ create_printer(const char *servername, /* I - Server hostname (NULL for default) /* reference-uri-scheme-supported */ ippAddStrings(printer->attrs, IPP_TAG_PRINTER, - IPP_TAG_URISCHEME | IPP_TAG_CUPS_CONST, + IPP_CONST_TAG(IPP_TAG_URISCHEME), "reference-uri-schemes-supported", (int)(sizeof(reference_uri_schemes_supported) / sizeof(reference_uri_schemes_supported[0])), @@ -1695,27 +1634,27 @@ create_printer(const char *servername, /* I - Server hostname (NULL for default) /* sides-default */ ippAddString(printer->attrs, IPP_TAG_PRINTER, - IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST, + IPP_CONST_TAG(IPP_TAG_KEYWORD), "sides-default", NULL, "one-sided"); /* sides-supported */ ippAddStrings(printer->attrs, IPP_TAG_PRINTER, - IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST, + IPP_CONST_TAG(IPP_TAG_KEYWORD), "sides-supported", duplex ? 3 : 1, NULL, sides_supported); /* uri-authentication-supported */ ippAddString(printer->attrs, IPP_TAG_PRINTER, - IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST, + IPP_CONST_TAG(IPP_TAG_KEYWORD), "uri-authentication-supported", NULL, "none"); /* uri-security-supported */ ippAddString(printer->attrs, IPP_TAG_PRINTER, - IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST, + IPP_CONST_TAG(IPP_TAG_KEYWORD), "uri-security-supported", NULL, "none"); /* which-jobs-supported */ ippAddStrings(printer->attrs, IPP_TAG_PRINTER, - IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST, + IPP_CONST_TAG(IPP_TAG_KEYWORD), "which-jobs-supported", sizeof(which_jobs) / sizeof(which_jobs[0]), NULL, which_jobs); @@ -1928,6 +1867,10 @@ dnssd_callback( const char *domain, /* I - Domain for service */ _ipp_printer_t *printer) /* I - Printer */ { + (void)sdRef; + (void)flags; + (void)domain; + if (errorCode) { fprintf(stderr, "DNSServiceRegister for %s failed with error %d.\n", @@ -2003,7 +1946,7 @@ html_escape(_ipp_client_t *client, /* I - Client */ if (*s == '&' || *s == '<') { if (s > start) - httpWrite2(client->http, start, s - start); + httpWrite2(client->http, start, (size_t)(s - start)); if (*s == '&') httpWrite2(client->http, "&", 5); @@ -2017,7 +1960,7 @@ html_escape(_ipp_client_t *client, /* I - Client */ } if (s > start) - httpWrite2(client->http, start, s - start); + httpWrite2(client->http, start, (size_t)(s - start)); } @@ -2054,7 +1997,7 @@ html_printf(_ipp_client_t *client, /* I - Client */ if (*format == '%') { if (format > start) - httpWrite2(client->http, start, format - start); + httpWrite2(client->http, start, (size_t)(format - start)); tptr = tformat; *tptr++ = *format++; @@ -2077,7 +2020,7 @@ html_printf(_ipp_client_t *client, /* I - Client */ 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 @@ -2109,7 +2052,7 @@ html_printf(_ipp_client_t *client, /* I - Client */ 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 @@ -2169,7 +2112,7 @@ html_printf(_ipp_client_t *client, /* I - Client */ 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)); @@ -2185,7 +2128,7 @@ html_printf(_ipp_client_t *client, /* I - Client */ case 'o' : case 'u' : case 'x' : - if ((width + 2) > sizeof(temp)) + if ((size_t)(width + 2) > sizeof(temp)) break; # ifdef HAVE_LONG_LONG @@ -2202,7 +2145,7 @@ html_printf(_ipp_client_t *client, /* I - Client */ 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 *)); @@ -2213,7 +2156,7 @@ html_printf(_ipp_client_t *client, /* I - Client */ case 'c' : /* Character or character array */ if (width <= 1) { - temp[0] = va_arg(ap, int); + temp[0] = (char)va_arg(ap, int); temp[1] = '\0'; html_escape(client, temp, 1); } @@ -2234,7 +2177,7 @@ html_printf(_ipp_client_t *client, /* I - Client */ } if (format > start) - httpWrite2(client->http, start, format - start); + httpWrite2(client->http, start, (size_t)(format - start)); va_end(ap); } @@ -2606,7 +2549,7 @@ ipp_get_printer_attributes( { if (printer->state_reasons == _IPP_PSTATE_NONE) ippAddString(client->response, IPP_TAG_PRINTER, - IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST, + IPP_CONST_TAG(IPP_TAG_KEYWORD), "printer-state-reasons", NULL, "none"); else { @@ -2647,7 +2590,7 @@ ipp_get_printer_attributes( reasons[num_reasons ++] = "toner-low-report"; ippAddStrings(client->response, IPP_TAG_PRINTER, - IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST, + IPP_CONST_TAG(IPP_TAG_KEYWORD), "printer-state-reasons", num_reasons, NULL, reasons); } } @@ -2747,7 +2690,7 @@ ipp_print_job(_ipp_client_t *client) /* I - Client */ while ((bytes = httpRead2(client->http, buffer, sizeof(buffer))) > 0) { - if (write(job->fd, buffer, bytes) < bytes) + if (write(job->fd, buffer, (size_t)bytes) < bytes) { int error = errno; /* Write error */ @@ -2991,7 +2934,7 @@ ipp_print_uri(_ipp_client_t *client) /* I - Client */ if ((bytes = read(infile, buffer, sizeof(buffer))) < 0 && (errno == EAGAIN || errno == EINTR)) bytes = 1; - else if (bytes > 0 && write(job->fd, buffer, bytes) < bytes) + else if (bytes > 0 && write(job->fd, buffer, (size_t)bytes) < bytes) { int error = errno; /* Write error */ @@ -3072,7 +3015,7 @@ ipp_print_uri(_ipp_client_t *client) /* I - Client */ while ((bytes = httpRead2(http, buffer, sizeof(buffer))) > 0) { - if (write(job->fd, buffer, bytes) < bytes) + if (write(job->fd, buffer, (size_t)bytes) < bytes) { int error = errno; /* Write error */ @@ -3264,7 +3207,7 @@ ipp_send_document(_ipp_client_t *client)/* I - Client */ while ((bytes = httpRead2(client->http, buffer, sizeof(buffer))) > 0) { - if (write(job->fd, buffer, bytes) < bytes) + if (write(job->fd, buffer, (size_t)bytes) < bytes) { int error = errno; /* Write error */ @@ -3566,7 +3509,7 @@ ipp_send_uri(_ipp_client_t *client) /* I - Client */ if ((bytes = read(infile, buffer, sizeof(buffer))) < 0 && (errno == EAGAIN || errno == EINTR)) bytes = 1; - else if (bytes > 0 && write(job->fd, buffer, bytes) < bytes) + else if (bytes > 0 && write(job->fd, buffer, (size_t)bytes) < bytes) { int error = errno; /* Write error */ @@ -3647,7 +3590,7 @@ ipp_send_uri(_ipp_client_t *client) /* I - Client */ while ((bytes = httpRead2(http, buffer, sizeof(buffer))) > 0) { - if (write(job->fd, buffer, bytes) < bytes) + if (write(job->fd, buffer, (size_t)bytes) < bytes) { int error = errno; /* Write error */ @@ -3952,7 +3895,6 @@ process_http(_ipp_client_t *client) /* I - Client connection */ return (respond_http(client, HTTP_STATUS_OK, NULL, "text/html", 0)); else return (respond_http(client, HTTP_STATUS_NOT_FOUND, NULL, NULL, 0)); - break; case HTTP_STATE_GET : if (!strcmp(client->uri, "/icon.png")) @@ -3972,14 +3914,14 @@ process_http(_ipp_client_t *client) /* I - Client connection */ (fd = open(client->printer->icon, O_RDONLY)) >= 0) { if (!respond_http(client, HTTP_STATUS_OK, NULL, "image/png", - fileinfo.st_size)) + (size_t)fileinfo.st_size)) { close(fd); return (0); } while ((bytes = read(fd, buffer, sizeof(buffer))) > 0) - httpWrite2(client->http, buffer, bytes); + httpWrite2(client->http, buffer, (size_t)bytes); httpFlushWrite(client->http); @@ -4762,7 +4704,7 @@ run_printer(_ipp_printer_t *printer) /* I - Printer */ else timeout = -1; - if (poll(polldata, num_fds, timeout) < 0 && errno != EINTR) + if (poll(polldata, (nfds_t)num_fds, timeout) < 0 && errno != EINTR) { perror("poll() failed"); break; diff --git a/test/ipptool.c b/test/ipptool.c index b04630d2d..e32ef571c 100644 --- a/test/ipptool.c +++ b/test/ipptool.c @@ -3,7 +3,7 @@ * * ipptool command for CUPS. * - * Copyright 2007-2013 by Apple Inc. + * Copyright 2007-2014 by Apple Inc. * Copyright 1997-2007 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -123,11 +123,11 @@ typedef struct _cups_vars_s /**** Set of variables ****/ * Globals... */ -_cups_transfer_t Transfer = _CUPS_TRANSFER_AUTO; +static _cups_transfer_t Transfer = _CUPS_TRANSFER_AUTO; /* How to transfer requests */ -_cups_output_t Output = _CUPS_OUTPUT_LIST; +static _cups_output_t Output = _CUPS_OUTPUT_LIST; /* Output mode */ -int Cancel = 0, /* Cancel test? */ +static int Cancel = 0, /* Cancel test? */ IgnoreErrors = 0, /* Ignore errors? */ StopAfterIncludeError = 0, /* Stop after include errors? */ @@ -138,22 +138,7 @@ int Cancel = 0, /* Cancel test? */ PassCount = 0, /* Number of passing tests */ FailCount = 0, /* Number of failing tests */ SkipCount = 0; /* Number of skipped tests */ -char *Password = NULL; /* Password from URI */ -const char * const URIStatusStrings[] = /* URI status strings */ -{ - "URI too large", - "Bad arguments to function", - "Bad resource in URI", - "Bad port number in URI", - "Bad hostname/address in URI", - "Bad username in URI", - "Bad scheme in URI", - "Bad/empty URI", - "OK", - "Missing scheme in URI", - "Unknown scheme in URI", - "Missing resource in URI" -}; +static char *Password = NULL; /* Password from URI */ /* @@ -562,7 +547,6 @@ main(int argc, /* I - Number of command-line args */ _cupsLangPrintf(stderr, _("ipptool: Unknown option \"-%c\"."), *opt); usage(); - break; } } } @@ -598,8 +582,7 @@ main(int argc, /* I - Number of command-line args */ if (uri_status != HTTP_URI_OK) { - _cupsLangPrintf(stderr, _("ipptool: Bad URI - %s."), - URIStatusStrings[uri_status - HTTP_URI_OVERFLOW]); + _cupsLangPrintf(stderr, _("ipptool: Bad URI - %s."), httpURIStatusString(uri_status)); return (1); } @@ -663,7 +646,7 @@ main(int argc, /* I - Number of command-line args */ { while (repeat > 1) { - usleep(interval); + usleep((useconds_t)interval); do_tests(&vars, testfile); repeat --; } @@ -672,7 +655,7 @@ main(int argc, /* I - Number of command-line args */ { for (;;) { - usleep(interval); + usleep((useconds_t)interval); do_tests(&vars, testfile); } } @@ -1571,7 +1554,7 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ expand_variables(vars, token, temp, sizeof(token)); if ((op = ippOpValue(token)) == (ipp_op_t)-1 && - (op = strtol(token, NULL, 0)) == 0) + (op = (ipp_op_t)strtol(token, NULL, 0)) == 0) { print_fatal_error("Bad OPERATION code \"%s\" on line %d.", token, linenum); @@ -1633,7 +1616,7 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ if (Output == _CUPS_OUTPUT_TEST) printf(" [%g second delay]\n", delay); - usleep((int)(1000000.0 * delay)); + usleep((useconds_t)(1000000.0 * delay)); } } else if (!_cups_strcasecmp(token, "ATTR")) @@ -1680,20 +1663,19 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ if (!_cups_strcasecmp(token, "true")) attrptr = ippAddBoolean(request, group, attr, 1); else - attrptr = ippAddBoolean(request, group, attr, atoi(token)); + attrptr = ippAddBoolean(request, group, attr, (char)atoi(token)); break; case IPP_TAG_INTEGER : case IPP_TAG_ENUM : if (!strchr(token, ',')) - attrptr = ippAddInteger(request, group, value, attr, - strtol(token, &tokenptr, 0)); + attrptr = ippAddInteger(request, group, value, attr, (int)strtol(token, &tokenptr, 0)); else { int values[100], /* Values */ num_values = 1; /* Number of values */ - values[0] = strtol(token, &tokenptr, 10); + values[0] = (int)strtol(token, &tokenptr, 10); while (tokenptr && *tokenptr && num_values < (int)(sizeof(values) / sizeof(values[0]))) { @@ -1702,7 +1684,7 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ else if (!isdigit(*tokenptr & 255) && *tokenptr != '-') break; - values[num_values] = strtol(tokenptr, &tokenptr, 0); + values[num_values] = (int)strtol(tokenptr, &tokenptr, 0); num_values ++; } @@ -1724,11 +1706,11 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ yres; /* Y resolution */ char *ptr; /* Pointer into value */ - xres = yres = strtol(token, (char **)&ptr, 10); + xres = yres = (int)strtol(token, (char **)&ptr, 10); if (ptr > token && xres > 0) { if (*ptr == 'x') - yres = strtol(ptr + 1, (char **)&ptr, 10); + yres = (int)strtol(ptr + 1, (char **)&ptr, 10); } if (ptr <= token || xres <= 0 || yres <= 0 || !ptr || @@ -1744,15 +1726,12 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ } if (!_cups_strcasecmp(ptr, "dpi")) - attrptr = ippAddResolution(request, group, attr, IPP_RES_PER_INCH, - xres, yres); + attrptr = ippAddResolution(request, group, attr, IPP_RES_PER_INCH, xres, yres); else if (!_cups_strcasecmp(ptr, "dpc") || !_cups_strcasecmp(ptr, "dpcm")) - attrptr = ippAddResolution(request, group, attr, IPP_RES_PER_CM, - xres, yres); + attrptr = ippAddResolution(request, group, attr, IPP_RES_PER_CM, xres, yres); else - attrptr = ippAddResolution(request, group, attr, (ipp_res_t)0, - xres, yres); + attrptr = ippAddResolution(request, group, attr, (ipp_res_t)0, xres, yres); } break; @@ -1809,8 +1788,7 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ break; case IPP_TAG_STRING : - attrptr = ippAddOctetString(request, group, attr, token, - strlen(token)); + attrptr = ippAddOctetString(request, group, attr, token, (int)strlen(token)); break; default : @@ -1918,7 +1896,7 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ if ((statuses[num_statuses].status = ippErrorValue(token)) == (ipp_status_t)-1 && - (statuses[num_statuses].status = strtol(token, NULL, 0)) == 0) + (statuses[num_statuses].status = (ipp_status_t)strtol(token, NULL, 0)) == 0) { print_fatal_error("Bad STATUS code \"%s\" on line %d.", token, linenum); @@ -2275,7 +2253,7 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ * WITH-VALUE is a POSIX extended regular expression. */ - last_expect->with_value = calloc(1, tokenptr - token); + last_expect->with_value = calloc(1, (size_t)(tokenptr - token)); last_expect->with_flags |= _CUPS_WITH_REGEX; if (last_expect->with_value) @@ -2351,10 +2329,9 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ TestCount ++; - request->request.op.version[0] = version / 10; - request->request.op.version[1] = version % 10; - request->request.op.operation_id = op; - request->request.op.request_id = request_id; + ippSetVersion(request, version / 10, version % 10); + ippSetOperation(request, op); + ippSetRequestId(request, request_id); if (Output == _CUPS_OUTPUT_PLIST) { @@ -2461,7 +2438,7 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ */ while ((bytes = cupsFileRead(reqfile, buffer, sizeof(buffer))) > 0) - length += bytes; + length += (size_t)bytes; cupsFileClose(reqfile); } @@ -2492,10 +2469,8 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ if ((reqfile = cupsFileOpen(filename, "r")) != NULL) { while (!Cancel && - (bytes = cupsFileRead(reqfile, buffer, - sizeof(buffer))) > 0) - if ((status = cupsWriteRequestData(http, buffer, - bytes)) != HTTP_CONTINUE) + (bytes = cupsFileRead(reqfile, buffer, sizeof(buffer))) > 0) + if ((status = cupsWriteRequestData(http, buffer, (size_t)bytes)) != HTTP_CONTINUE) break; cupsFileClose(reqfile); @@ -3027,7 +3002,7 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ fflush(stdout); } - sleep(repeat_interval); + sleep((unsigned)repeat_interval); repeat_interval = _cupsNextDelay(repeat_interval, &repeat_prev); if (Output == _CUPS_OUTPUT_TEST) @@ -3524,7 +3499,7 @@ get_collection(_cups_vars_t *vars, /* I - Variables */ if (!_cups_strcasecmp(token, "true")) ippAddBoolean(col, IPP_TAG_ZERO, attr, 1); else - ippAddBoolean(col, IPP_TAG_ZERO, attr, atoi(token)); + ippAddBoolean(col, IPP_TAG_ZERO, attr, (char)atoi(token)); break; case IPP_TAG_INTEGER : @@ -3550,15 +3525,12 @@ get_collection(_cups_vars_t *vars, /* I - Variables */ } if (!_cups_strcasecmp(units, "dpi")) - ippAddResolution(col, IPP_TAG_ZERO, attr, xres, yres, - IPP_RES_PER_INCH); + ippAddResolution(col, IPP_TAG_ZERO, attr, IPP_RES_PER_INCH, xres, yres); else if (!_cups_strcasecmp(units, "dpc") || !_cups_strcasecmp(units, "dpcm")) - ippAddResolution(col, IPP_TAG_ZERO, attr, xres, yres, - IPP_RES_PER_CM); + ippAddResolution(col, IPP_TAG_ZERO, attr, IPP_RES_PER_CM, xres, yres); else - ippAddResolution(col, IPP_TAG_ZERO, attr, xres, yres, - (ipp_res_t)0); + ippAddResolution(col, IPP_TAG_ZERO, attr, (ipp_res_t)0, xres, yres); } break; @@ -3608,7 +3580,7 @@ get_collection(_cups_vars_t *vars, /* I - Variables */ } break; case IPP_TAG_STRING : - ippAddOctetString(col, IPP_TAG_ZERO, attr, token, strlen(token)); + ippAddOctetString(col, IPP_TAG_ZERO, attr, token, (int)strlen(token)); break; default : @@ -3707,7 +3679,7 @@ get_filename(const char *testfile, /* I - Current test file */ else dstptr = dst; /* Should never happen */ - strlcpy(dstptr, src, dstsize - (dstptr - dst)); + strlcpy(dstptr, src, dstsize - (size_t)(dstptr - dst)); } return (dst); @@ -3737,30 +3709,24 @@ get_string(ipp_attribute_t *attr, /* I - IPP attribute */ if (flags & _CUPS_WITH_HOSTNAME) { - if (httpSeparateURI(HTTP_URI_CODING_ALL, ptr, scheme, sizeof(scheme), - userpass, sizeof(userpass), buffer, bufsize, &port, - resource, sizeof(resource)) < HTTP_URI_STATUS_OK) - return (""); - else - return (buffer); + if (httpSeparateURI(HTTP_URI_CODING_ALL, ptr, scheme, sizeof(scheme), userpass, sizeof(userpass), buffer, (int)bufsize, &port, resource, sizeof(resource)) < HTTP_URI_STATUS_OK) + buffer[0] = '\0'; + + return (buffer); } else if (flags & _CUPS_WITH_RESOURCE) { - if (httpSeparateURI(HTTP_URI_CODING_ALL, ptr, scheme, sizeof(scheme), - userpass, sizeof(userpass), hostname, sizeof(hostname), - &port, buffer, bufsize) < HTTP_URI_STATUS_OK) - return (""); - else - return (buffer); + if (httpSeparateURI(HTTP_URI_CODING_ALL, ptr, scheme, sizeof(scheme), userpass, sizeof(userpass), hostname, sizeof(hostname), &port, buffer, (int)bufsize) < HTTP_URI_STATUS_OK) + buffer[0] = '\0'; + + return (buffer); } else if (flags & _CUPS_WITH_SCHEME) { - if (httpSeparateURI(HTTP_URI_CODING_ALL, ptr, buffer, bufsize, - userpass, sizeof(userpass), hostname, sizeof(hostname), - &port, resource, sizeof(resource)) < HTTP_URI_STATUS_OK) - return (""); - else - return (buffer); + if (httpSeparateURI(HTTP_URI_CODING_ALL, ptr, buffer, (int)bufsize, userpass, sizeof(userpass), hostname, sizeof(hostname), &port, resource, sizeof(resource)) < HTTP_URI_STATUS_OK) + buffer[0] = '\0'; + + return (buffer); } else return (ptr); @@ -3820,15 +3786,15 @@ get_token(FILE *fp, /* I - File to read from */ */ if (bufptr < bufend) - *bufptr++ = ch; + *bufptr++ = (char)ch; if ((ch = getc(fp)) != EOF && bufptr < bufend) - *bufptr++ = ch; + *bufptr++ = (char)ch; } else if (ch == quote) break; else if (bufptr < bufend) - *bufptr++ = ch; + *bufptr++ = (char)ch; } *bufptr = '\0'; @@ -3862,7 +3828,7 @@ get_token(FILE *fp, /* I - File to read from */ if (isspace(ch) || ch == '#') break; else if (bufptr < bufend) - *bufptr++ = ch; + *bufptr++ = (char)ch; if (ch == '#') ungetc(ch, fp); @@ -5187,8 +5153,7 @@ validate_attr(cups_array_t *errors, /* I - Errors array */ "\"%s\": Bad URI value \"%s\" - %s " "(RFC 2911 section 4.1.5).", attr->name, attr->values[i].string.text, - URIStatusStrings[uri_status - - HTTP_URI_OVERFLOW]); + httpURIStatusString(uri_status)); } if (strlen(attr->values[i].string.text) > (IPP_MAX_URI - 1)) @@ -5449,7 +5414,7 @@ with_value(cups_array_t *errors, /* I - Errors array */ if (!*valptr) break; - intvalue = strtol(valptr, &nextptr, 0); + intvalue = (int)strtol(valptr, &nextptr, 0); if (nextptr == valptr) break; valptr = nextptr; @@ -5459,8 +5424,7 @@ with_value(cups_array_t *errors, /* I - Errors array */ (op == '>' && attr->values[i].integer > intvalue)) { if (!matchbuf[0]) - snprintf(matchbuf, matchlen, "%d", - attr->values[i].integer); + snprintf(matchbuf, matchlen, "%d", attr->values[i].integer); valmatch = 1; break; @@ -5515,7 +5479,7 @@ with_value(cups_array_t *errors, /* I - Errors array */ if (!*valptr) break; - intvalue = strtol(valptr, &nextptr, 0); + intvalue = (int)strtol(valptr, &nextptr, 0); if (nextptr == valptr) break; valptr = nextptr; diff --git a/vcnet/regex/regcomp.c b/vcnet/regex/regcomp.c index 5df5d53fc..22e74336a 100644 --- a/vcnet/regex/regcomp.c +++ b/vcnet/regex/regcomp.c @@ -1345,7 +1345,7 @@ sopno finish; /* to this less one */ return(ret); enlarge(p, p->ssize + len); /* this many unexpected additions */ assert(p->ssize >= p->slen + len); - (void) memcpy((char *)(p->strip + p->slen), + (void) memmove((char *)(p->strip + p->slen), (char *)(p->strip + start), (size_t)len*sizeof(sop)); p->slen += len; return(ret); diff --git a/xcode/CUPS.xcodeproj/project.pbxproj b/xcode/CUPS.xcodeproj/project.pbxproj index 206b9966d..ed3354a19 100644 --- a/xcode/CUPS.xcodeproj/project.pbxproj +++ b/xcode/CUPS.xcodeproj/project.pbxproj @@ -337,6 +337,11 @@ 728FB7F11536167A005426E1 /* libiconv.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 728FB7EF1536167A005426E1 /* libiconv.dylib */; }; 728FB7F21536167A005426E1 /* libresolv.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 728FB7F01536167A005426E1 /* libresolv.dylib */; }; 72C16CB9137B195D007E4BF4 /* file.c in Sources */ = {isa = PBXBuildFile; fileRef = 72C16CB8137B195D007E4BF4 /* file.c */; }; + 72CF95E318A13543000FCAE4 /* dest-job.c in Sources */ = {isa = PBXBuildFile; fileRef = 72CF95E018A13543000FCAE4 /* dest-job.c */; }; + 72CF95E418A13543000FCAE4 /* dest-localization.c in Sources */ = {isa = PBXBuildFile; fileRef = 72CF95E118A13543000FCAE4 /* dest-localization.c */; }; + 72CF95E518A13543000FCAE4 /* dest-options.c in Sources */ = {isa = PBXBuildFile; fileRef = 72CF95E218A13543000FCAE4 /* dest-options.c */; }; + 72CF95EC18A19134000FCAE4 /* libcups.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 72220EAE1333047D00FCA411 /* libcups.dylib */; }; + 72CF95F318A19165000FCAE4 /* ippfind.c in Sources */ = {isa = PBXBuildFile; fileRef = 72CF95F218A19165000FCAE4 /* ippfind.c */; }; 72D53A2A15B49110003F877F /* GSS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 72D53A2915B49110003F877F /* GSS.framework */; }; 72D53A2D15B4913D003F877F /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 72D53A2C15B4913D003F877F /* IOKit.framework */; }; 72D53A2E15B4915B003F877F /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 278C58E8136B64B000836530 /* SystemConfiguration.framework */; }; @@ -821,6 +826,13 @@ remoteGlobalIDString = 274FF6891333B1C400317ECB; remoteInfo = libcups_static; }; + 72CF95E818A19134000FCAE4 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 72BF96371333042100B1EAD7 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 72220EAD1333047D00FCA411; + remoteInfo = libcups; + }; 72F75A651336FA30004BB496 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 72BF96371333042100B1EAD7 /* Project object */; @@ -1070,6 +1082,15 @@ ); runOnlyForDeploymentPostprocessing = 1; }; + 72CF95ED18A19134000FCAE4 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; 72F75A501336F950004BB496 /* CopyFiles */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; @@ -1315,6 +1336,11 @@ 728FB7F01536167A005426E1 /* libresolv.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libresolv.dylib; path = /usr/lib/libresolv.dylib; sourceTree = ""; }; 72A4332F155844CF002E172D /* libcups_static.a */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libcups_static.a; sourceTree = BUILT_PRODUCTS_DIR; }; 72C16CB8137B195D007E4BF4 /* file.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = file.c; path = ../scheduler/file.c; sourceTree = SOURCE_ROOT; }; + 72CF95E018A13543000FCAE4 /* dest-job.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = "dest-job.c"; path = "../cups/dest-job.c"; sourceTree = ""; }; + 72CF95E118A13543000FCAE4 /* dest-localization.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = "dest-localization.c"; path = "../cups/dest-localization.c"; sourceTree = ""; }; + 72CF95E218A13543000FCAE4 /* dest-options.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = "dest-options.c"; path = "../cups/dest-options.c"; sourceTree = ""; }; + 72CF95F118A19134000FCAE4 /* ipptool copy */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "ipptool copy"; sourceTree = BUILT_PRODUCTS_DIR; }; + 72CF95F218A19165000FCAE4 /* ippfind.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = ippfind.c; path = ../test/ippfind.c; sourceTree = ""; }; 72D53A2915B49110003F877F /* GSS.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GSS.framework; path = /System/Library/Frameworks/GSS.framework; sourceTree = ""; }; 72D53A2C15B4913D003F877F /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = /System/Library/Frameworks/IOKit.framework; sourceTree = ""; }; 72D53A3315B4925B003F877F /* ApplicationServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ApplicationServices.framework; path = /System/Library/Frameworks/ApplicationServices.framework; sourceTree = ""; }; @@ -1588,6 +1614,14 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 72CF95EB18A19134000FCAE4 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 72CF95EC18A19134000FCAE4 /* libcups.dylib in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 72F75A4F1336F950004BB496 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -1671,6 +1705,7 @@ 274FF68713333B6E00317ECB /* cupsfilter.c */, 2732E08B137A3F5200FAFEF6 /* cupstestdsc.c */, 72F75A5B1336F988004BB496 /* cupstestppd.c */, + 72CF95F218A19165000FCAE4 /* ippfind.c */, 726AD701135E8A90002C930D /* ippserver.c */, 276683F91337F7A9000D33D0 /* ipptool.c */, 2732E08C137A3F5200FAFEF6 /* lp.c */, @@ -1728,6 +1763,7 @@ 726AD6F7135E88F0002C930D /* ippserver */, 278C58CB136B640300836530 /* testhttp */, 72A4332F155844CF002E172D /* libcups_static.a */, + 72CF95F118A19134000FCAE4 /* ipptool copy */, ); name = Products; sourceTree = ""; @@ -1747,6 +1783,9 @@ 72220EC21333056300FCA411 /* custom.c */, 72220ED1133305BB00FCA411 /* debug.c */, 72220ED2133305BB00FCA411 /* dest.c */, + 72CF95E018A13543000FCAE4 /* dest-job.c */, + 72CF95E118A13543000FCAE4 /* dest-localization.c */, + 72CF95E218A13543000FCAE4 /* dest-options.c */, 72220ED3133305BB00FCA411 /* dir.c */, 72220ED4133305BB00FCA411 /* dir.h */, 72220ED5133305BB00FCA411 /* emit.c */, @@ -1760,8 +1799,8 @@ 72220EDE133305BB00FCA411 /* http-addr.c */, 72220EDF133305BB00FCA411 /* http-addrlist.c */, 72220EE1133305BB00FCA411 /* http-support.c */, - 72220EE5133305BB00FCA411 /* ipp-support.c */, 72220EE6133305BB00FCA411 /* ipp.c */, + 72220EE5133305BB00FCA411 /* ipp-support.c */, 72220EE8133305BB00FCA411 /* langprintf.c */, 72220EEA133305BB00FCA411 /* language.c */, 72220EEC133305BB00FCA411 /* localize.c */, @@ -2624,6 +2663,24 @@ productReference = 726AD6F7135E88F0002C930D /* ippserver */; productType = "com.apple.product-type.tool"; }; + 72CF95E618A19134000FCAE4 /* ippfind */ = { + isa = PBXNativeTarget; + buildConfigurationList = 72CF95EE18A19134000FCAE4 /* Build configuration list for PBXNativeTarget "ippfind" */; + buildPhases = ( + 72CF95E918A19134000FCAE4 /* Sources */, + 72CF95EB18A19134000FCAE4 /* Frameworks */, + 72CF95ED18A19134000FCAE4 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + 72CF95E718A19134000FCAE4 /* PBXTargetDependency */, + ); + name = ippfind; + productName = ipptool; + productReference = 72CF95F118A19134000FCAE4 /* ipptool copy */; + productType = "com.apple.product-type.tool"; + }; 72F75A511336F950004BB496 /* cupstestppd */ = { isa = PBXNativeTarget; buildConfigurationList = 72F75A581336F951004BB496 /* Build configuration list for PBXNativeTarget "cupstestppd" */; @@ -2700,6 +2757,7 @@ 72F75A511336F950004BB496 /* cupstestppd */, 724379461333FEA9009631B9 /* dnssd */, 724378FC1333E43E009631B9 /* ipp */, + 72CF95E618A19134000FCAE4 /* ippfind */, 726AD6F6135E88F0002C930D /* ippserver */, 276683EF1337F78E000D33D0 /* ipptool */, 724379171333E532009631B9 /* lpd */, @@ -2964,6 +3022,7 @@ 72220F19133305BB00FCA411 /* http-addrlist.c in Sources */, 72220F1B133305BB00FCA411 /* http-support.c in Sources */, 72220F1C133305BB00FCA411 /* http.c in Sources */, + 72CF95E518A13543000FCAE4 /* dest-options.c in Sources */, 72220F1F133305BB00FCA411 /* ipp-support.c in Sources */, 72220F20133305BB00FCA411 /* ipp.c in Sources */, 72220F22133305BB00FCA411 /* langprintf.c in Sources */, @@ -2984,10 +3043,12 @@ 72220F3A133305BB00FCA411 /* snprintf.c in Sources */, 72220F3C133305BB00FCA411 /* string.c in Sources */, 72220F3D133305BB00FCA411 /* tempfile.c in Sources */, + 72CF95E418A13543000FCAE4 /* dest-localization.c in Sources */, 72220F3F133305BB00FCA411 /* thread.c in Sources */, 72220F40133305BB00FCA411 /* transcode.c in Sources */, 72220F42133305BB00FCA411 /* usersys.c in Sources */, 72220F43133305BB00FCA411 /* util.c in Sources */, + 72CF95E318A13543000FCAE4 /* dest-job.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3099,6 +3160,14 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 72CF95E918A19134000FCAE4 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 72CF95F318A19165000FCAE4 /* ippfind.c in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 72F75A4E1336F950004BB496 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -3450,6 +3519,11 @@ target = 274FF6891333B1C400317ECB /* libcups_static */; targetProxy = 726AD705135E8AC5002C930D /* PBXContainerItemProxy */; }; + 72CF95E718A19134000FCAE4 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 72220EAD1333047D00FCA411 /* libcups */; + targetProxy = 72CF95E818A19134000FCAE4 /* PBXContainerItemProxy */; + }; 72F75A661336FA30004BB496 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 72220EAD1333047D00FCA411 /* libcups */; @@ -3983,12 +4057,19 @@ 72BF963C1333042100B1EAD7 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES; + CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES; DEBUG_INFORMATION_FORMAT = dwarf; GCC_PREPROCESSOR_DEFINITIONS = DEBUG; + GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; + GCC_TREAT_WARNINGS_AS_ERRORS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_SHADOW = YES; + GCC_WARN_SIGN_COMPARE = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_LABEL = YES; @@ -4009,11 +4090,18 @@ 72BF963D1333042100B1EAD7 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES; + CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; + GCC_TREAT_WARNINGS_AS_ERRORS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_SHADOW = YES; + GCC_WARN_SIGN_COMPARE = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_LABEL = YES; @@ -4030,6 +4118,22 @@ }; name = Release; }; + 72CF95EF18A19134000FCAE4 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + INSTALL_PATH = /usr/bin; + PRODUCT_NAME = "ipptool copy"; + }; + name = Debug; + }; + 72CF95F018A19134000FCAE4 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + INSTALL_PATH = /usr/bin; + PRODUCT_NAME = "ipptool copy"; + }; + name = Release; + }; 72F75A591336F951004BB496 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -4355,6 +4459,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + 72CF95EE18A19134000FCAE4 /* Build configuration list for PBXNativeTarget "ippfind" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 72CF95EF18A19134000FCAE4 /* Debug */, + 72CF95F018A19134000FCAE4 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; 72F75A581336F951004BB496 /* Build configuration list for PBXNativeTarget "cupstestppd" */ = { isa = XCConfigurationList; buildConfigurations = ( -- 2.39.2