Changeset 865


Ignore:
Timestamp:
Apr 24, 2006, 11:09:06 PM (14 years ago)
Author:
Sam Hocevar
Message:
  • Renamed htons/htonl to hton16/hton32 to avoid useless conflicts.
Location:
libcaca/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/common.h

    r863 r865  
    3333#endif
    3434
    35 #if !defined(HAVE_HTONS) && !defined(HAVE_NETINET_IN_H)
     35#if defined(HAVE_HTONS)
     36#   define hton16 htons
     37#   define hton32 htonl
     38#else
    3639#   if defined(HAVE_ENDIAN_H)
    3740#       include <endian.h>
    3841#   endif
    39 static inline uint16_t htons(uint16_t x)
     42static inline uint16_t hton16(uint16_t x)
    4043{
     44    /* This is compile-time optimised with at least -O1 or -Os */
    4145#if defined(HAVE_ENDIAN_H)
    4246    if(__BYTE_ORDER == __BIG_ENDIAN)
    4347#else
    44     /* This is compile-time optimised with at least -O1 or -Os */
    4548    uint32_t const dummy = 0x12345678;
    4649    if(*(uint8_t const *)&dummy == 0x12)
     
    5154}
    5255
    53 static inline uint32_t htonl(uint32_t x)
     56static inline uint32_t hton32(uint32_t x)
    5457{
     58    /* This is compile-time optimised with at least -O1 or -Os */
    5559#if defined(HAVE_ENDIAN_H)
    5660    if(__BYTE_ORDER == __BIG_ENDIAN)
    5761#else
    58     /* This is compile-time optimised with at least -O1 or -Os */
    5962    uint32_t const dummy = 0x12345678;
    6063    if(*(uint8_t const *)&dummy == 0x12)
  • libcaca/trunk/configure.ac

    r861 r865  
    6262  [  --enable-doc            build documentation (needs doxygen and LaTeX)])
    6363
    64 AC_CHECK_HEADERS(stdio.h stdarg.h signal.h sys/ioctl.h sys/time.h inttypes.h endian.h unistd.h arpa/inet.h netinet/in.h)
     64AC_CHECK_HEADERS(stdio.h stdarg.h signal.h sys/ioctl.h sys/time.h inttypes.h endian.h unistd.h arpa/inet.h netinet/in.h winsock2.h)
    6565AC_CHECK_FUNCS(signal ioctl vsnprintf getenv putenv strcasecmp htons)
    6666AC_CHECK_FUNCS(usleep gettimeofday)
  • libcaca/trunk/cucul/font.c

    r862 r865  
    137137
    138138    memcpy(&f->header, f->private + 8, sizeof(struct font_header));
    139     f->header.control_size = htonl(f->header.control_size);
    140     f->header.data_size = htonl(f->header.data_size);
    141     f->header.version = htons(f->header.version);
    142     f->header.blocks = htons(f->header.blocks);
    143     f->header.glyphs = htonl(f->header.glyphs);
    144     f->header.bpp = htons(f->header.bpp);
    145     f->header.width = htons(f->header.width);
    146     f->header.height = htons(f->header.height);
    147     f->header.flags = htons(f->header.flags);
     139    f->header.control_size = hton32(f->header.control_size);
     140    f->header.data_size = hton32(f->header.data_size);
     141    f->header.version = hton16(f->header.version);
     142    f->header.blocks = hton16(f->header.blocks);
     143    f->header.glyphs = hton32(f->header.glyphs);
     144    f->header.bpp = hton16(f->header.bpp);
     145    f->header.width = hton16(f->header.width);
     146    f->header.height = hton16(f->header.height);
     147    f->header.flags = hton16(f->header.flags);
    148148
    149149    if(size != 8 + f->header.control_size + f->header.data_size
     
    162162    for(i = 0; i < f->header.blocks; i++)
    163163    {
    164         f->block_list[i].start = htonl(f->block_list[i].start);
    165         f->block_list[i].stop = htonl(f->block_list[i].stop);
    166         f->block_list[i].index = htonl(f->block_list[i].index);
     164        f->block_list[i].start = hton32(f->block_list[i].start);
     165        f->block_list[i].stop = hton32(f->block_list[i].stop);
     166        f->block_list[i].index = hton32(f->block_list[i].index);
    167167
    168168        if(f->block_list[i].start > f->block_list[i].stop
     
    183183    for(i = 0; i < f->header.glyphs; i++)
    184184    {
    185         f->glyph_list[i].width = htons(f->glyph_list[i].width);
    186         f->glyph_list[i].height = htons(f->glyph_list[i].height);
    187         f->glyph_list[i].data_offset = htonl(f->glyph_list[i].data_offset);
     185        f->glyph_list[i].width = hton16(f->glyph_list[i].width);
     186        f->glyph_list[i].height = hton16(f->glyph_list[i].height);
     187        f->glyph_list[i].data_offset = hton32(f->glyph_list[i].data_offset);
    188188
    189189        if(f->glyph_list[i].data_offset >= f->header.data_size
  • libcaca/trunk/src/cacaserver.c

    r859 r865  
    1919#include <string.h>
    2020#include <stdlib.h>
     21#if defined(HAVE_ARPA_INET_H)
     22#   include <arpa/inet.h>
     23#elif defined(HAVE_NETINET_IN_H)
     24#   include <netinet/in.h>
     25#elif defined(HAVE_WINSOCK2_H)
     26#   include <winsock2.h>
     27#endif
    2128#include <sys/types.h>
    2229#include <sys/socket.h>
    23 #include <arpa/inet.h>
    2430#include <fcntl.h>
    2531#include <signal.h>
  • libcaca/trunk/tools/makefont.c

    r861 r865  
    273273static int printf_u32(char const *fmt, uint32_t i)
    274274{
    275     uint32_t ni = htonl(i);
     275    uint32_t ni = hton32(i);
    276276    return printf_hex(fmt, (uint8_t *)&ni, 4);
    277277}
     
    279279static int printf_u16(char const *fmt, uint16_t i)
    280280{
    281     uint16_t ni = htons(i);
     281    uint16_t ni = hton16(i);
    282282    return printf_hex(fmt, (uint8_t *)&ni, 2);
    283283}
Note: See TracChangeset for help on using the changeset viewer.