/usr/include/CGAL/ImageIO/bmpendian_impl.h is in libcgal-dev 4.11-2build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | // Copyright (c) 2005-2008 ASCLEPIOS Project, INRIA Sophia-Antipolis (France)
// All rights reserved.
//
// This file is part of the ImageIO Library, and as been adapted for
// CGAL (www.cgal.org).
// You can redistribute it and/or modify it under the terms of the
// GNU Lesser General Public License as published by the Free Software Foundation;
// either version 3 of the License, or (at your option) any later version.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// These files are provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $URL$
// $Id$
//
//
// Author(s) : ASCLEPIOS Project (INRIA Sophia-Antipolis), Laurent Rineau
#ifdef CGAL_HEADER_ONLY
#define CGAL_INLINE_FUNCTION inline
#else
#define CGAL_INLINE_FUNCTION
#endif
/*
* These functions read and write our basic integer types from a little-endian
* file. The endian and word-size of the host machine will not affect this
* code. The only assumption made is that the C data type (char) is one byte
* long. This should be a safe assumption.
*/
#include <stdio.h>
#include <CGAL/ImageIO/bmptypes.h>
/*****************************************************************************
*
* Read functions. All read functions take an open file pointer as the first
* parameter and a pointer to data as the second parameter. The return value
* will be 0 on success, and EOF on failure. If successful, the second
* parameter will point to the data read.
*/
/*
* The CGAL_INT8 and CGAL_UINT8 types are stored as a single byte on disk. The INT8
* type is a signed integer with range (-128..127). The CGAL_UINT8 type is an
* unsigned integer with range (0..255).
*/
CGAL_INLINE_FUNCTION
int readINT8little(FILE *f, CGAL_INT8 *i)
{
int rc;
rc = fgetc(f);
if (rc == EOF)
return rc;
*i = CGAL_INT8(rc & 0xff);
return 0;
}
CGAL_INLINE_FUNCTION
int readUINT8little(FILE *f, CGAL_UINT8 *i)
{
int rc;
rc = fgetc(f);
if (rc == EOF)
return rc;
*i = CGAL_UINT8(rc & 0xff);
return 0;
}
/*
* The CGAL_INT16 and CGAL_UINT16 types are stored as two bytes on disk. The INT16 type
* is a signed integer with range (-32768..32767). The CGAL_UINT16 type is an
* unisgned integer with range (0..65535).
*/
CGAL_INLINE_FUNCTION
int readINT16little(FILE *f, CGAL_INT16 *i)
{
int rc;
CGAL_INT16 temp = 0;
temp = (fgetc(f) & 0xff);
rc = fgetc(f);
if (rc == EOF)
return rc;
temp = temp | CGAL_INT16((rc & 0xff) << 8);
*i = temp;
return 0;
}
CGAL_INLINE_FUNCTION
int readUINT16little(FILE *f, CGAL_UINT16 *i)
{
int rc;
CGAL_UINT16 temp = 0;
temp = (fgetc(f) & 0xff);
rc = fgetc(f);
if (rc == EOF)
return rc;
temp = CGAL_INT16(temp | ((rc & 0xff) << 8));
*i = temp;
return 0;
}
/*
* The CGAL_INT32 and CGAL_UINT32 types are stored as four bytes on disk. The INT32
* type is a signed integer with range (-2147483648..2147483647). The CGAL_UINT32
* type is an unisgned integer with range (0..4294967295).
*/
CGAL_INLINE_FUNCTION
int readINT32little(FILE *f, CGAL_INT32 *i)
{
int rc;
CGAL_INT32 temp = 0;
temp = ((long)fgetc(f) & 0xff);
temp = CGAL_INT32(temp | (((long)fgetc(f) & 0xff) << 8));
temp = CGAL_INT32(temp | (((long)fgetc(f) & 0xff) << 16));
rc = fgetc(f);
if (rc == EOF)
return rc;
temp = CGAL_INT32(temp | (((long)rc & 0xff) << 24));
*i = temp;
return 0;
}
CGAL_INLINE_FUNCTION
int readUINT32little(FILE *f, CGAL_UINT32 *i)
{
int rc;
CGAL_UINT32 temp = 0;
temp = ((long)fgetc(f) & 0xff);
temp = CGAL_UINT32(temp | (((long)fgetc(f) & 0xff) << 8));
temp = CGAL_UINT32(temp | (((long)fgetc(f) & 0xff) << 16));
rc = fgetc(f);
if (rc == EOF)
return rc;
temp = CGAL_UINT32(temp | (((long)rc & 0xff) << 24));
*i = temp;
return 0;
}
/*****************************************************************************
*
* Write functions. All write functions take an open file pointer as the first
* parameter and a data as the second parameter. The return value will be 0 on
* success, and EOF on failure. If successful, the second parameter will have
* been written to the open file.
*/
CGAL_INLINE_FUNCTION
int writeINT8little(FILE *f, CGAL_INT8 i)
{
return fputc(i, f);
}
CGAL_INLINE_FUNCTION
int writeUINT8little(FILE *f, CGAL_UINT8 i)
{
return fputc(i, f);
}
CGAL_INLINE_FUNCTION
int writeINT16little(FILE *f, CGAL_INT16 i)
{
int rc;
rc = fputc((i & 0xff), f);
if (rc == EOF)
return rc;
return fputc(((i >> 8) & 0xff), f);
}
CGAL_INLINE_FUNCTION
int writeUINT16little(FILE *f, CGAL_UINT16 i)
{
int rc;
rc = fputc((i & 0xff), f);
if (rc == EOF)
return rc;
return fputc(((i >> 8) & 0xff), f);
}
CGAL_INLINE_FUNCTION
int writeINT32little(FILE *f, CGAL_INT32 i)
{
int rc;
rc = fputc((i & 0xff), f);
if (rc == EOF)
return rc;
rc = fputc(((i >> 8) & 0xff), f);
if (rc == EOF)
return rc;
rc = fputc(((i >> 16) & 0xff), f);
if (rc == EOF)
return rc;
return fputc(((i >> 24) & 0xff), f);
}
CGAL_INLINE_FUNCTION
int writeUINT32little(FILE *f, CGAL_UINT32 i)
{
int rc;
rc = fputc((i & 0xff), f);
if (rc == EOF)
return rc;
rc = fputc(((i >> 8) & 0xff), f);
if (rc == EOF)
return rc;
rc = fputc(((i >> 16) & 0xff), f);
if (rc == EOF)
return rc;
return fputc(((i >> 24) & 0xff), f);
}
/*
* Formatting information for emacs in c-mode
*
* Local Variables:
* c-indent-level:4
* c-continued-statement-offset:4
* c-brace-offset:-4
* c-brace-imaginary-offset:0
* c-argdecl-indent:4
* c-label-offset:-4
* End:
*/
|