PageRenderTime 3ms CodeModel.GetById 12ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 1ms

/src/types.h

https://code.google.com/
C++ Header | 154 lines | 84 code | 38 blank | 32 comment | 4 complexity | 7af292a2e4e8b6322304fb04b4d18966 MD5 | raw file
  1/*
  2    $Id: types.h 231 2011-06-27 13:46:19Z marc.noirot $
  3
  4    FLV Metadata updater
  5
  6    Copyright (C) 2007-2012 Marc Noirot <marc.noirot AT gmail.com>
  7
  8    This file is part of FLVMeta.
  9
 10    FLVMeta is free software; you can redistribute it and/or modify
 11    it under the terms of the GNU General Public License as published by
 12    the Free Software Foundation; either version 2 of the License, or
 13    (at your option) any later version.
 14
 15    FLVMeta is distributed in the hope that it will be useful,
 16    but WITHOUT ANY WARRANTY; without even the implied warranty of
 17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 18    GNU General Public License for more details.
 19
 20    You should have received a copy of the GNU General Public License
 21    along with FLVMeta; if not, write to the Free Software
 22    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 23*/
 24#ifndef __TYPES_H__
 25#define __TYPES_H__
 26
 27/* Configuration of the sources */
 28#ifdef HAVE_CONFIG_H
 29# include <config.h>
 30#endif
 31
 32#ifdef HAVE_STDINT_H
 33# include <stdint.h>
 34#endif
 35
 36#ifdef HAVE_SYS_TYPES_H
 37#  include <sys/types.h> /* off_t */
 38#endif
 39
 40#ifdef HAVE_INTTYPES_H
 41# include <inttypes.h>
 42#endif
 43
 44#include <stdio.h>
 45
 46typedef uint8_t byte, uint8, uint8_bitmask;
 47
 48typedef uint16_t uint16, uint16_be, uint16_le;
 49
 50typedef int16_t sint16, sint16_be, sint16_le;
 51
 52typedef uint32_t uint32, uint32_be, uint32_le;
 53
 54typedef int32_t sint32, sint32_be, sint32_le;
 55
 56typedef struct __uint24 {
 57    uint8 b[3];
 58} uint24, uint24_be, uint24_le;
 59
 60typedef uint64_t uint64, uint64_le, uint64_be;
 61
 62typedef int64_t sint64, sint64_le, sint64_be;
 63
 64typedef
 65#if SIZEOF_FLOAT == 8
 66float
 67#elif SIZEOF_DOUBLE == 8
 68double
 69#elif SIZEOF_LONG_DOUBLE == 8
 70long double
 71#else
 72uint64_t
 73#endif
 74number64, number64_le, number64_be;
 75
 76#ifdef __cplusplus
 77extern "C" {
 78#endif /* __cplusplus */
 79
 80#ifdef WORDS_BIGENDIAN
 81
 82# define swap_uint16(x) (x)
 83# define swap_sint16(x) (x)
 84# define swap_uint32(x) (x)
 85# define swap_number64(x) (x)
 86
 87#else /* !defined WORDS_BIGENDIAN */
 88
 89/* swap 16 bits integers */
 90# define swap_uint16(x) ((uint16)((((x) & 0x00FFU) << 8) | \
 91    (((x) & 0xFF00U) >> 8)))
 92# define swap_sint16(x) ((sint16)((((x) & 0x00FF) << 8) | \
 93    (((x) & 0xFF00) >> 8)))
 94
 95/* swap 32 bits integers */
 96# define swap_uint32(x) ((uint32)((((x) & 0x000000FFU) << 24) | \
 97    (((x) & 0x0000FF00U) << 8)  | \
 98    (((x) & 0x00FF0000U) >> 8)  | \
 99    (((x) & 0xFF000000U) >> 24)))
100
101/* swap 64 bits doubles */
102number64 swap_number64(number64);
103
104#endif /* WORDS_BIGENDIAN */
105
106/* convert big endian 24 bits integers to native integers */
107# define uint24_be_to_uint32(x) ((uint32)(((x).b[0] << 16) | \
108    ((x).b[1] << 8) | (x).b[2]))
109
110/* convert native integers into 24 bits big endian integers */
111uint24_be uint32_to_uint24_be(uint32);
112
113/* large file support */
114#ifdef HAVE_FSEEKO
115# define lfs_ftell ftello
116# define lfs_fseek fseeko
117
118# define FILE_OFFSET_T_64_BITS 1
119typedef off_t file_offset_t;
120
121#else /* !HAVE_SEEKO */
122
123# ifdef WIN32
124
125# define FILE_OFFSET_T_64_BITS 1
126typedef long long int file_offset_t;
127
128/* Win32 large file support */
129file_offset_t lfs_ftell(FILE * stream);
130int lfs_fseek(FILE * stream, file_offset_t offset, int whence);
131
132# else /* !defined WIN32 */
133
134# define lfs_ftell ftell
135# define lfs_fseek fseek
136
137typedef long file_offset_t;
138
139# endif /* WIN32 */
140
141#endif /* HAVE_FSEEKO */
142
143/* file offset printf specifier */
144#ifdef FILE_OFFSET_T_64_BITS
145# define FILE_OFFSET_PRINTF_FORMAT "ll"
146#else
147# define FILE_OFFSET_PRINTF_FORMAT "l"
148#endif
149
150#ifdef __cplusplus
151}
152#endif /* __cplusplus */
153
154#endif /* __TYPES_H__ */