From: mike Date: Thu, 24 Jan 2013 18:09:22 +0000 (+0000) Subject: Fix builds with Visual C++ X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=353faf125dcd7f76bb841eb753ab00d108950dfc;p=thirdparty%2Fcups.git Fix builds with Visual C++ git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@10837 7a7537e8-13f0-0310-91df-b6672ffda945 --- diff --git a/cups/http-addr.c b/cups/http-addr.c index e3dba9e9ab..c8834df418 100644 --- a/cups/http-addr.c +++ b/cups/http-addr.c @@ -162,11 +162,11 @@ httpAddrListen(http_addr_t *addr, /* I - Address to bind to */ } val = 1; - setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val)); + setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, CUPS_SOCAST &val, sizeof(val)); #ifdef IPV6_V6ONLY if (addr->addr.sa_family == AF_INET6) - setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &val, sizeof(val)); + setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, CUPS_SOCAST &val, sizeof(val)); #endif /* IPV6_V6ONLY */ _httpAddrSetPort(addr, port); @@ -195,7 +195,7 @@ httpAddrListen(http_addr_t *addr, /* I - Address to bind to */ */ val = 1; - setsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, &val, sizeof(val)); + setsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, CUPS_SOCAST &val, sizeof(val)); #endif /* SO_NOSIGPIPE */ return (fd); diff --git a/cups/http-addrlist.c b/cups/http-addrlist.c index 470376d5f3..fd5da4bbe3 100644 --- a/cups/http-addrlist.c +++ b/cups/http-addrlist.c @@ -139,21 +139,16 @@ httpAddrConnect2( */ val = 1; -#ifdef WIN32 - setsockopt(*sock, SOL_SOCKET, SO_REUSEADDR, (const char *)&val, - sizeof(val)); -#else - setsockopt(*sock, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val)); -#endif /* WIN32 */ + setsockopt(*sock, SOL_SOCKET, SO_REUSEADDR, CUPS_SOCAST &val, sizeof(val)); #ifdef SO_REUSEPORT val = 1; - setsockopt(*sock, SOL_SOCKET, SO_REUSEPORT, &val, sizeof(val)); + setsockopt(*sock, SOL_SOCKET, SO_REUSEPORT, CUPS_SOCAST &val, sizeof(val)); #endif /* SO_REUSEPORT */ #ifdef SO_NOSIGPIPE val = 1; - setsockopt(*sock, SOL_SOCKET, SO_NOSIGPIPE, &val, sizeof(val)); + setsockopt(*sock, SOL_SOCKET, SO_NOSIGPIPE, CUPS_SOCAST &val, sizeof(val)); #endif /* SO_NOSIGPIPE */ /* @@ -162,12 +157,7 @@ httpAddrConnect2( */ val = 1; -#ifdef WIN32 - setsockopt(*sock, IPPROTO_TCP, TCP_NODELAY, (const char *)&val, - sizeof(val)); -#else - setsockopt(*sock, IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val)); -#endif /* WIN32 */ + setsockopt(*sock, IPPROTO_TCP, TCP_NODELAY, CUPS_SOCAST &val, sizeof(val)); #ifdef FD_CLOEXEC /* diff --git a/cups/http-private.h b/cups/http-private.h index 7e006e59c2..910d7ec48d 100644 --- a/cups/http-private.h +++ b/cups/http-private.h @@ -34,11 +34,13 @@ # ifdef WIN32 # include # include +# define CUPS_SOCAST (const char *) # else # include # include # include # define closesocket(f) close(f) +# define CUPS_SOCAST # endif /* WIN32 */ # ifdef HAVE_GSSAPI diff --git a/cups/http-support.c b/cups/http-support.c index 294021f11d..fe2041c8a3 100644 --- a/cups/http-support.c +++ b/cups/http-support.c @@ -1553,15 +1553,15 @@ _httpResolveURI( # ifdef HAVE_DNSSD if (DNSServiceCreateConnection(&ref) == kDNSServiceErr_NoError) { - int interface = kDNSServiceInterfaceIndexAny; + int myinterface = kDNSServiceInterfaceIndexAny; /* Lookup on any interface */ if (!strcmp(scheme, "ippusb")) - interface = kDNSServiceInterfaceIndexLocalOnly; + myinterface = kDNSServiceInterfaceIndexLocalOnly; localref = ref; if (DNSServiceResolve(&localref, - kDNSServiceFlagsShareConnection, interface, + kDNSServiceFlagsShareConnection, myinterface, hostname, regtype, "local.", http_resolve_cb, &uribuf) == kDNSServiceErr_NoError) { @@ -1636,7 +1636,7 @@ _httpResolveURI( domainref = ref; if (DNSServiceResolve(&domainref, kDNSServiceFlagsShareConnection, - interface, hostname, regtype, domain, + myinterface, hostname, regtype, domain, http_resolve_cb, &uribuf) == kDNSServiceErr_NoError) domainsent = 1; diff --git a/cups/http.c b/cups/http.c index 2075ec2d08..7b7446cd7a 100644 --- a/cups/http.c +++ b/cups/http.c @@ -347,7 +347,7 @@ httpAcceptConnection(int fd, /* I - Listen socket file descriptor */ */ val = 1; - setsockopt(http->fd, SOL_SOCKET, SO_NOSIGPIPE, &val, sizeof(val)); + setsockopt(http->fd, SOL_SOCKET, SO_NOSIGPIPE, CUPS_SOCAST &val, sizeof(val)); #endif /* SO_NOSIGPIPE */ /* @@ -358,7 +358,7 @@ httpAcceptConnection(int fd, /* I - Listen socket file descriptor */ */ val = 1; - setsockopt(http->fd, IPPROTO_TCP, TCP_NODELAY, (char *)&val, sizeof(val)); + setsockopt(http->fd, IPPROTO_TCP, TCP_NODELAY, CUPS_SOCAST &val, sizeof(val)); #ifdef FD_CLOEXEC /* @@ -2253,10 +2253,18 @@ httpRead2(http_t *http, /* I - Connection to server */ ssize_t bytes; /* Bytes read */ +#ifdef HAVE_LIBZ DEBUG_printf(("httpRead2(http=%p, buffer=%p, length=" CUPS_LLFMT ") coding=%d data_encoding=%d data_remaining=" CUPS_LLFMT, - http, buffer, CUPS_LLCAST length, http->coding, + http, buffer, CUPS_LLCAST length, + http->coding, + http->data_encoding, CUPS_LLCAST http->data_remaining)); +#else + DEBUG_printf(("httpRead2(http=%p, buffer=%p, length=" CUPS_LLFMT + ") data_encoding=%d data_remaining=" CUPS_LLFMT, + http, buffer, CUPS_LLCAST length, http->data_encoding, CUPS_LLCAST http->data_remaining)); +#endif /* HAVE_LIBZ */ if (http == NULL || buffer == NULL) return (-1); @@ -2374,8 +2382,8 @@ httpRead2(http_t *http, /* I - Connection to server */ DEBUG_printf(("1httpRead2: Reading up to %d bytes into buffer.", (int)length)); - if (length > http->data_remaining) - length = http->data_remaining; + if (length > (size_t)http->data_remaining) + length = (size_t)http->data_remaining; if ((bytes = http_read_buffered(http, buffer, length)) > 0) http->data_remaining -= bytes; @@ -4039,6 +4047,7 @@ httpWriteResponse(http_t *http, /* I - HTTP connection */ http_set_length(http); +#ifdef HAVE_LIBZ /* * Then start any content encoding... */ @@ -4046,6 +4055,7 @@ httpWriteResponse(http_t *http, /* I - HTTP connection */ DEBUG_puts("1httpWriteResponse: Calling http_content_coding_start."); http_content_coding_start(http, httpGetField(http, HTTP_FIELD_CONTENT_ENCODING)); +#endif /* HAVE_LIBZ */ } return (0); @@ -5035,8 +5045,8 @@ http_set_timeout(int fd, /* I - File descriptor */ DWORD tv = (DWORD)(timeout * 1000); /* Timeout in milliseconds */ - setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(tv)); - setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, (char *)&tv, sizeof(tv)); + setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, CUPS_SOCAST &tv, sizeof(tv)); + setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, CUPS_SOCAST &tv, sizeof(tv)); #else struct timeval tv; /* Timeout in secs and usecs */ @@ -5044,8 +5054,8 @@ http_set_timeout(int fd, /* I - File descriptor */ tv.tv_sec = (int)timeout; tv.tv_usec = (int)(1000000 * fmod(timeout, 1.0)); - setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)); - setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)); + setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, CUPS_SOCAST &tv, sizeof(tv)); + setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, CUPS_SOCAST &tv, sizeof(tv)); #endif /* WIN32 */ } diff --git a/cups/libcups2.def b/cups/libcups2.def index ef22daa4f3..c4cf462126 100644 --- a/cups/libcups2.def +++ b/cups/libcups2.def @@ -1,5 +1,5 @@ LIBRARY libcups2 -VERSION 2.9 +VERSION 2.10 EXPORTS _cupsBufferGet _cupsBufferRelease @@ -34,12 +34,9 @@ _cups_strncasecmp _cups_strcpy _cups_strlcat _cups_strlcpy -_httpAddrPort _httpAddrSetPort _httpAssembleUUID -_httpCreate _httpEncodeURI -_httpPeek _httpResolveURI _httpWait _ippFindOption @@ -186,32 +183,40 @@ cupsSetPasswordCB cupsSetServer cupsSetServerCertCB cupsSetUser +cupsSetUserAgent cupsTempFd cupsTempFile cupsTempFile2 +cupsUserAgent cupsUTF32ToUTF8 cupsUTF8ToCharset cupsUTF8ToUTF32 cupsUser cupsWriteRequestData +httpAcceptConnection httpAddCredential httpAddrAny httpAddrConnect +httpAddrCopyList httpAddrEqual httpAddrFreeList httpAddrGetList httpAddrLength +httpAddrListen httpAddrLocalhost httpAddrLookup +httpAddrPort httpAddrString httpAssembleURI httpAssembleURIf +httpAssembleUUID httpBlocking httpCheck httpClearCookie httpClearFields httpClose httpConnect +httpConnect2 httpConnectEncrypt httpCopyCredentials httpDecode64 @@ -226,10 +231,12 @@ httpFlushWrite httpFreeCredentials httpGet httpGetBlocking +httpGetContentEncoding httpGetCookie httpGetDateString httpGetDateString2 httpGetDateTime +httpGetExpect httpGetFd httpGetField httpGetHostByName @@ -246,17 +253,20 @@ httpMD5 httpMD5Final httpMD5String httpOptions +httpPeek httpPost httpPrintf httpPut httpRead httpRead2 +httpReadRequest httpReconnect httpSeparate httpSeparate2 httpSeparateURI httpSetCookie httpSetCredentials +httpSetDefaultField httpSetExpect httpSetField httpSetLength @@ -267,6 +277,7 @@ httpUpdate httpWait httpWrite httpWrite2 +httpWriteResponse ippAddBoolean ippAddBooleans ippAddCollection @@ -282,8 +293,12 @@ ippAddResolution ippAddResolutions ippAddSeparator ippAddString +ippAddStringf +ippAddStringfv ippAddStrings ippAttributeString +ippContainsInteger +ippContainsString ippCopyAttribute ippCopyAttributes ippDateToTime @@ -316,6 +331,7 @@ ippGetVersion ippLength ippNew ippNewRequest +ippNewResponse ippNextAttribute ippOpString ippOpValue @@ -337,11 +353,15 @@ ippSetResolution ippSetState ippSetStatusCode ippSetString +ippSetStringf +ippSetStringfv ippSetValueTag ippSetVersion ippTagString ippTagValue ippTimeToDate +ippValidateAttribute +ippValidateAttributes ippWrite ippWriteFile ippWriteIO diff --git a/cups/request.c b/cups/request.c index f81785d3a2..191a536fcc 100644 --- a/cups/request.c +++ b/cups/request.c @@ -1015,8 +1015,13 @@ _cupsConnect(void) char ch; /* Connection check byte */ +#ifdef WIN32 + if (recv(cg->http->fd, &ch, 1, MSG_PEEK) < 0 && + WSAGetLastError() != WSAEWOULDBLOCK) +#else if (recv(cg->http->fd, &ch, 1, MSG_PEEK | MSG_DONTWAIT) < 0 && errno != EWOULDBLOCK) +#endif /* WIN32 */ { /* * Nope, close the connection... diff --git a/cups/snmp.c b/cups/snmp.c index 33dd1d4ea6..034db89a9e 100644 --- a/cups/snmp.c +++ b/cups/snmp.c @@ -362,11 +362,7 @@ _cupsSNMPOpen(int family) /* I - Address family - @code AF_INET@ or @code AF_IN val = 1; -#ifdef WIN32 - if (setsockopt(fd, SOL_SOCKET, SO_BROADCAST, (char *)&val, sizeof(val))) -#else - if (setsockopt(fd, SOL_SOCKET, SO_BROADCAST, &val, sizeof(val))) -#endif /* WIN32 */ + if (setsockopt(fd, SOL_SOCKET, SO_BROADCAST, CUPS_SOCAST &val, sizeof(val))) { DEBUG_printf(("5_cupsSNMPOpen: Returning -1 (%s)", strerror(errno))); diff --git a/cups/usersys.c b/cups/usersys.c index fc2ed9ceda..12d76f7724 100644 --- a/cups/usersys.c +++ b/cups/usersys.c @@ -462,8 +462,8 @@ cupsSetUserAgent(const char *user_agent)/* I - User-Agent string or @code NULL@ _cups_globals_t *cg = _cupsGlobals(); /* Thread globals */ #ifdef WIN32 - SYSTEM_INFO sysinfo; /* System information */ - OSVERSIONEX version; /* OS version info */ + SYSTEM_INFO sysinfo; /* System information */ + OSVERSIONINFO version; /* OS version info */ #else struct utsname name; /* uname info */ #endif /* WIN32 */ @@ -476,13 +476,13 @@ cupsSetUserAgent(const char *user_agent)/* I - User-Agent string or @code NULL@ } #ifdef WIN32 - version.dwOSVersionInfoSize = sizeof(OSVERSIONEX); - GetVersionInfoEx(&version); + version.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + GetVersionEx(&version); GetNativeSystemInfo(&sysinfo); snprintf(cg->user_agent, sizeof(cg->user_agent), CUPS_MINIMAL " (Windows %d.%d; %s) IPP/2.0", - version.major, version.minor, + version.dwMajorVersion, version.dwMinorVersion, sysinfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64 ? "amd64" : sysinfo.wProcessorArchitecture diff --git a/vcnet/config.h b/vcnet/config.h index 627aa178cb..bd73518e2d 100644 --- a/vcnet/config.h +++ b/vcnet/config.h @@ -3,7 +3,7 @@ * * Configuration file for CUPS on Windows. * - * Copyright 2007-2012 by Apple Inc. + * Copyright 2007-2013 by Apple Inc. * Copyright 1997-2007 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -234,7 +234,7 @@ * Use ? */ -#define HAVE_STDINT_H 1 +/* #undef HAVE_STDINT_H */ /*