From b40e37f93ddbcce9db44e213e925d74d0df9858a Mon Sep 17 00:00:00 2001 From: Steve Holme Date: Wed, 31 Dec 2014 14:02:25 +0000 Subject: endian: Fixed Linux compilation issues Having files named endian.[c|h] seemed to cause issues under Linux so renamed them both to have the curl_ prefix in the filenames. --- lib/Makefile.inc | 4 +- lib/Makefile.vc6 | 2 +- lib/curl_endian.c | 105 +++++++++++++++++++++++++++++++++++++ lib/curl_endian.h | 43 +++++++++++++++ lib/curl_ntlm_core.c | 2 +- lib/curl_ntlm_msgs.c | 2 +- lib/endian.c | 105 ------------------------------------- lib/endian.h | 43 --------------- packages/Symbian/group/libcurl.mmp | 2 +- 9 files changed, 154 insertions(+), 154 deletions(-) create mode 100644 lib/curl_endian.c create mode 100644 lib/curl_endian.h delete mode 100644 lib/endian.c delete mode 100644 lib/endian.h diff --git a/lib/Makefile.inc b/lib/Makefile.inc index 9678ca5e3..8f9d16d8b 100644 --- a/lib/Makefile.inc +++ b/lib/Makefile.inc @@ -45,7 +45,7 @@ LIB_CFILES = file.c timeval.c base64.c hostip.c progress.c formdata.c \ asyn-thread.c curl_gssapi.c curl_ntlm.c curl_ntlm_wb.c \ curl_ntlm_core.c curl_ntlm_msgs.c curl_sasl.c curl_multibyte.c \ hostcheck.c bundles.c conncache.c pipeline.c dotdot.c x509asn1.c \ - http2.c curl_sasl_sspi.c smb.c curl_sasl_gssapi.c endian.c + http2.c curl_sasl_sspi.c smb.c curl_sasl_gssapi.c curl_endian.c LIB_HFILES = arpa_telnet.h netrc.h file.h timeval.h hostip.h progress.h \ formdata.h cookie.h http.h sendf.h ftp.h url.h dict.h if2ip.h \ @@ -63,7 +63,7 @@ LIB_HFILES = arpa_telnet.h netrc.h file.h timeval.h hostip.h progress.h \ curl_ntlm.h curl_gssapi.h curl_ntlm_wb.h curl_ntlm_core.h \ curl_ntlm_msgs.h curl_sasl.h curl_multibyte.h hostcheck.h bundles.h \ conncache.h curl_setup_once.h multihandle.h setup-vms.h pipeline.h \ - dotdot.h x509asn1.h http2.h sigpipe.h smb.h endian.h + dotdot.h x509asn1.h http2.h sigpipe.h smb.h curl_endian.h LIB_RCFILES = libcurl.rc diff --git a/lib/Makefile.vc6 b/lib/Makefile.vc6 index b72488b64..ee20ebe12 100644 --- a/lib/Makefile.vc6 +++ b/lib/Makefile.vc6 @@ -535,6 +535,7 @@ X_OBJS= \ $(DIROBJ)\cookie.obj \ $(DIROBJ)\curl_addrinfo.obj \ $(DIROBJ)\curl_darwinssl.obj \ + $(DIROBJ)\curl_endian.obj \ $(DIROBJ)\curl_fnmatch.obj \ $(DIROBJ)\curl_gethostname.obj \ $(DIROBJ)\curl_gssapi.obj \ @@ -555,7 +556,6 @@ X_OBJS= \ $(DIROBJ)\dict.obj \ $(DIROBJ)\dotdot.obj \ $(DIROBJ)\easy.obj \ - $(DIROBJ)\endian.obj \ $(DIROBJ)\escape.obj \ $(DIROBJ)\file.obj \ $(DIROBJ)\fileinfo.obj \ diff --git a/lib/curl_endian.c b/lib/curl_endian.c new file mode 100644 index 000000000..41202d73d --- /dev/null +++ b/lib/curl_endian.c @@ -0,0 +1,105 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ***************************************************************************/ + +#include "curl_setup.h" + +#include "curl_endian.h" + +/* + * Curl_read16_le() + * + * This function converts a 16-bit integer from the little endian format, as + * used in the incoming package to whatever endian format we're using + * natively. + * + * Parameters: + * + * buf [in] - A pointer to a 2 byte buffer. + * + * Returns the integer. + */ +unsigned short Curl_read16_le(unsigned char *buf) +{ + return (unsigned short)(((unsigned short)buf[0]) | + ((unsigned short)buf[1] << 8)); +} + +/* + * Curl_read32_le() + * + * This function converts a 32-bit integer from the little endian format, as + * used in the incoming package to whatever endian format we're using + * natively. + * + * Parameters: + * + * buf [in] - A pointer to a 4 byte buffer. + * + * Returns the integer. + */ +unsigned int Curl_read32_le(unsigned char *buf) +{ + return ((unsigned int)buf[0]) | ((unsigned int)buf[1] << 8) | + ((unsigned int)buf[2] << 16) | ((unsigned int)buf[3] << 24); +} + +/* + * Curl_write32_le() + * + * This function converts a 32-bit integer from the native endian format, + * to little endian format ready for sending down the wire. + * + * Parameters: + * + * value [in] - The 32-bit integer value. + * buffer [in] - A pointer to the output buffer. + */ +void Curl_write32_le(const int value, unsigned char *buffer) +{ + buffer[0] = (char)(value & 0x000000FF); + buffer[1] = (char)((value & 0x0000FF00) >> 8); + buffer[2] = (char)((value & 0x00FF0000) >> 16); + buffer[3] = (char)((value & 0xFF000000) >> 24); +} + +#if (CURL_SIZEOF_CURL_OFF_T > 4) +/* + * Curl_write64_le() + * + * This function converts a 64-bit integer from the native endian format, + * to little endian format ready for sending down the wire. + * + * Parameters: + * + * value [in] - The 64-bit integer value. + * buffer [in] - A pointer to the output buffer. + */ +#if defined(HAVE_LONGLONG) +void Curl_write64_le(const long long value, unsigned char *buffer) +#else +void Curl_write64_le(const __int64 value, unsigned char *buffer) +#endif +{ + Curl_write32_le((int)value, buffer); + Curl_write32_le((int)(value >> 32), buffer + 4); +} +#endif diff --git a/lib/curl_endian.h b/lib/curl_endian.h new file mode 100644 index 000000000..a8811c940 --- /dev/null +++ b/lib/curl_endian.h @@ -0,0 +1,43 @@ +#ifndef HEADER_CURL_ENDIAN_H +#define HEADER_CURL_ENDIAN_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ***************************************************************************/ + +/* Converts a 16-bit integer from little endian */ +unsigned short Curl_read16_le(unsigned char *buf); + +/* Converts a 32-bit integer from little endian */ +unsigned int Curl_read32_le(unsigned char *buf); + +/* Converts a 32-bit integer to little endian */ +void Curl_write32_le(const int value, unsigned char *buffer); + +#if (CURL_SIZEOF_CURL_OFF_T > 4) +/* Converts a 64-bit integer to little endian */ +#if defined(HAVE_LONGLONG) +void Curl_write64_le(const long long value, unsigned char *buffer); +#else +void Curl_write64_le(const __int64 value, unsigned char *buffer); +#endif +#endif + +#endif /* HEADER_CURL_ENDIAN_H */ diff --git a/lib/curl_ntlm_core.c b/lib/curl_ntlm_core.c index b28d21df0..299e1afea 100644 --- a/lib/curl_ntlm_core.c +++ b/lib/curl_ntlm_core.c @@ -106,7 +106,7 @@ #include "curl_md5.h" #include "curl_hmac.h" #include "warnless.h" -#include "endian.h" +#include "curl_endian.h" #define _MPRINTF_REPLACE /* use our functions only */ #include diff --git a/lib/curl_ntlm_msgs.c b/lib/curl_ntlm_msgs.c index c25bebe1e..865954d3b 100644 --- a/lib/curl_ntlm_msgs.c +++ b/lib/curl_ntlm_msgs.c @@ -52,7 +52,7 @@ #define BUILDING_CURL_NTLM_MSGS_C #include "curl_ntlm_msgs.h" #include "curl_sasl.h" -#include "endian.h" +#include "curl_endian.h" #define _MPRINTF_REPLACE /* use our functions only */ #include diff --git a/lib/endian.c b/lib/endian.c deleted file mode 100644 index cc329771e..000000000 --- a/lib/endian.c +++ /dev/null @@ -1,105 +0,0 @@ -/*************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ - * \___|\___/|_| \_\_____| - * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. - * - * This software is licensed as described in the file COPYING, which - * you should have received as part of this distribution. The terms - * are also available at http://curl.haxx.se/docs/copyright.html. - * - * You may opt to use, copy, modify, merge, publish, distribute and/or sell - * copies of the Software, and permit persons to whom the Software is - * furnished to do so, under the terms of the COPYING file. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ***************************************************************************/ - -#include "curl_setup.h" - -#include "endian.h" - -/* - * Curl_read16_le() - * - * This function converts a 16-bit integer from the little endian format, as - * used in the incoming package to whatever endian format we're using - * natively. - * - * Parameters: - * - * buf [in] - A pointer to a 2 byte buffer. - * - * Returns the integer. - */ -unsigned short Curl_read16_le(unsigned char *buf) -{ - return (unsigned short)(((unsigned short)buf[0]) | - ((unsigned short)buf[1] << 8)); -} - -/* - * Curl_read32_le() - * - * This function converts a 32-bit integer from the little endian format, as - * used in the incoming package to whatever endian format we're using - * natively. - * - * Parameters: - * - * buf [in] - A pointer to a 4 byte buffer. - * - * Returns the integer. - */ -unsigned int Curl_read32_le(unsigned char *buf) -{ - return ((unsigned int)buf[0]) | ((unsigned int)buf[1] << 8) | - ((unsigned int)buf[2] << 16) | ((unsigned int)buf[3] << 24); -} - -/* - * Curl_write32_le() - * - * This function converts a 32-bit integer from the native endian format, - * to little endian format ready for sending down the wire. - * - * Parameters: - * - * value [in] - The 32-bit integer value. - * buffer [in] - A pointer to the output buffer. - */ -void Curl_write32_le(const int value, unsigned char *buffer) -{ - buffer[0] = (char)(value & 0x000000FF); - buffer[1] = (char)((value & 0x0000FF00) >> 8); - buffer[2] = (char)((value & 0x00FF0000) >> 16); - buffer[3] = (char)((value & 0xFF000000) >> 24); -} - -#if (CURL_SIZEOF_CURL_OFF_T > 4) -/* - * Curl_write64_le() - * - * This function converts a 64-bit integer from the native endian format, - * to little endian format ready for sending down the wire. - * - * Parameters: - * - * value [in] - The 64-bit integer value. - * buffer [in] - A pointer to the output buffer. - */ -#if defined(HAVE_LONGLONG) -void Curl_write64_le(const long long value, unsigned char *buffer) -#else -void Curl_write64_le(const __int64 value, unsigned char *buffer) -#endif -{ - Curl_write32_le((int)value, buffer); - Curl_write32_le((int)(value >> 32), buffer + 4); -} -#endif diff --git a/lib/endian.h b/lib/endian.h deleted file mode 100644 index a8811c940..000000000 --- a/lib/endian.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef HEADER_CURL_ENDIAN_H -#define HEADER_CURL_ENDIAN_H -/*************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ - * \___|\___/|_| \_\_____| - * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. - * - * This software is licensed as described in the file COPYING, which - * you should have received as part of this distribution. The terms - * are also available at http://curl.haxx.se/docs/copyright.html. - * - * You may opt to use, copy, modify, merge, publish, distribute and/or sell - * copies of the Software, and permit persons to whom the Software is - * furnished to do so, under the terms of the COPYING file. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ***************************************************************************/ - -/* Converts a 16-bit integer from little endian */ -unsigned short Curl_read16_le(unsigned char *buf); - -/* Converts a 32-bit integer from little endian */ -unsigned int Curl_read32_le(unsigned char *buf); - -/* Converts a 32-bit integer to little endian */ -void Curl_write32_le(const int value, unsigned char *buffer); - -#if (CURL_SIZEOF_CURL_OFF_T > 4) -/* Converts a 64-bit integer to little endian */ -#if defined(HAVE_LONGLONG) -void Curl_write64_le(const long long value, unsigned char *buffer); -#else -void Curl_write64_le(const __int64 value, unsigned char *buffer); -#endif -#endif - -#endif /* HEADER_CURL_ENDIAN_H */ diff --git a/packages/Symbian/group/libcurl.mmp b/packages/Symbian/group/libcurl.mmp index e89ae3d82..2419c206c 100644 --- a/packages/Symbian/group/libcurl.mmp +++ b/packages/Symbian/group/libcurl.mmp @@ -40,7 +40,7 @@ SOURCE \ curl_ntlm.c curl_ntlm_wb.c curl_ntlm_core.c curl_ntlm_msgs.c \ curl_sasl.c vtls/curl_schannel.c curl_multibyte.c \ vtls/curl_darwinssl.c bundles.c conncache.c curl_sasl_sspi.c smb.c \ - curl_sasl_gssapi.c endian.c + curl_sasl_gssapi.c curl_endian.c USERINCLUDE ../../../lib ../../../include/curl #ifdef ENABLE_SSL -- cgit v1.2.3