lbfileio.h File Reference


Detailed Description

Library for r/w of little/big endian binary data from files.

Purpose:
Header file. Defines exported routines from lbfileio.c
Comment:
Those are simple, low-level functions, so all are defined as inline.
Author:
Tomasz Lis
Date:
11 Mar 2005 - 22 Jul 2008
Copying and copyrights:
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

Definition in file lbfileio.h.

#include <stdio.h>

Go to the source code of this file.

Functions

long file_length (char *path)
 Returns length of given file.
long file_length_opened (FILE *fp)
 Returns length of opened file.
long read_int32_le_file (FILE *fp)
 Reads 4-byte little-endian number from given FILE.
long read_int32_le_buf (const unsigned char *buff)
 Reads 4-byte little-endian number from given buffer.
unsigned short read_int16_le_file (FILE *fp)
 Reads 2-byte little-endian number from given FILE.
unsigned short read_int16_le_buf (const unsigned char *buff)
 Reads 2-byte little-endian number from given buffer.
void write_int16_le_file (FILE *fp, unsigned short x)
 Writes 2-byte little-endian number to given FILE.
void write_int16_le_buf (unsigned char *buff, unsigned short x)
 Writes 2-byte little-endian number into given buffer.
void write_int32_le_file (FILE *fp, unsigned long x)
 Writes 4-byte little-endian number to given FILE.
void write_int32_le_buf (unsigned char *buff, unsigned long x)
 Writes 4-byte little-endian number into given buffer.
long read_int32_be_file (FILE *fp)
 Reads 4-byte big-endian number from given FILE.
long read_int32_be_buf (const unsigned char *buff)
 Reads 4-byte big-endian number from given buffer.
unsigned short read_int16_be_file (FILE *fp)
 Reads 2-byte big-endian number from given FILE.
unsigned short read_int16_be_buf (const unsigned char *buff)
 Reads 2-byte big-endian number from given buffer.
void write_int16_be_file (FILE *fp, unsigned short x)
void write_int16_be_buf (unsigned char *buff, unsigned short x)
 Writes 2-byte big-endian number into given buffer.
void write_int32_be_file (FILE *fp, unsigned long x)
void write_int32_be_buf (unsigned char *buff, unsigned long x)
 Writes 4-byte big-endian number into given buffer.
unsigned char read_int8_buf (const unsigned char *buff)
 Reads 1-byte number from given buffer.
short nth_bit (unsigned char c, short n)
 Returns the nth bit of character c.
short nth_bit_fourbytes (unsigned char c[4], short n)
 Returns the nth bit of c.


Function Documentation

long file_length ( char *  path  )  [inline]

Returns length of given file.

Value -1 means error.

Definition at line 184 of file lbfileio.c.

long file_length_opened ( FILE *  fp  )  [inline]

Returns length of opened file.

Value -1 means error.

Definition at line 203 of file lbfileio.c.

Referenced by read_datfile_data(), read_jtytabfile_data(), and read_tabfile_data().

short nth_bit ( unsigned char  c,
short  n 
) [inline]

Returns the nth bit of character c.

Parameters:
c Source character.
n Source bit number.
Returns:
The nth bit, either 1 or 0.

Definition at line 233 of file lbfileio.c.

Referenced by nth_bit_fourbytes().

short nth_bit_fourbytes ( unsigned char  c[4],
short  n 
) [inline]

Returns the nth bit of c.

Goes like this: [31 30 29 28 27 26 25 24][...][...][7 6 5 4 3 2 1 0]

Parameters:
c Source characters array.
n Source bit number.
Returns:
The nth bit, either 1 or 0.

Definition at line 250 of file lbfileio.c.

unsigned short read_int16_be_buf ( const unsigned char *  buff  )  [inline]

Reads 2-byte big-endian number from given buffer.

Definition at line 141 of file lbfileio.c.

Referenced by rnc_unpack().

unsigned short read_int16_be_file ( FILE *  fp  )  [inline]

Reads 2-byte big-endian number from given FILE.

Definition at line 152 of file lbfileio.c.

unsigned short read_int16_le_buf ( const unsigned char *  buff  )  [inline]

unsigned short read_int16_le_file ( FILE *  fp  )  [inline]

Reads 2-byte little-endian number from given FILE.

Definition at line 104 of file lbfileio.c.

Referenced by read_datfile_data().

long read_int32_be_buf ( const unsigned char *  buff  )  [inline]

Reads 4-byte big-endian number from given buffer.

Definition at line 128 of file lbfileio.c.

Referenced by rnc_plen(), rnc_ulen(), and rnc_unpack().

long read_int32_be_file ( FILE *  fp  )  [inline]

Reads 4-byte big-endian number from given FILE.

Definition at line 115 of file lbfileio.c.

long read_int32_le_buf ( const unsigned char *  buff  )  [inline]

Reads 4-byte little-endian number from given buffer.

Definition at line 80 of file lbfileio.c.

Referenced by load_apt(), load_clm(), load_cubedata(), load_lgt(), read_jtytabfile_data(), and read_tabfile_data().

long read_int32_le_file ( FILE *  fp  )  [inline]

Reads 4-byte little-endian number from given FILE.

Definition at line 67 of file lbfileio.c.

unsigned char read_int8_buf ( const unsigned char *  buff  )  [inline]

Reads 1-byte number from given buffer.

Simple wrapper for use with both little and big endian files.

Definition at line 222 of file lbfileio.c.

Referenced by bit_advance(), bitread_fix(), and bitread_init().

void write_int16_be_buf ( unsigned char *  buff,
unsigned short  x 
) [inline]

Writes 2-byte big-endian number into given buffer.

Definition at line 163 of file lbfileio.c.

void write_int16_be_file ( FILE *  fp,
unsigned short  x 
) [inline]

void write_int16_le_buf ( unsigned char *  buff,
unsigned short  x 
) [inline]

Writes 2-byte little-endian number into given buffer.

Definition at line 36 of file lbfileio.c.

void write_int16_le_file ( FILE *  fp,
unsigned short  x 
) [inline]

Writes 2-byte little-endian number to given FILE.

Definition at line 27 of file lbfileio.c.

Referenced by write_bmp_fp_24b(), write_bmp_fp_idx(), write_cubedata(), write_dat(), write_flg(), write_slb(), and write_tng().

void write_int32_be_buf ( unsigned char *  buff,
unsigned long  x 
) [inline]

Writes 4-byte big-endian number into given buffer.

Definition at line 172 of file lbfileio.c.

void write_int32_be_file ( FILE *  fp,
unsigned long  x 
) [inline]

void write_int32_le_buf ( unsigned char *  buff,
unsigned long  x 
) [inline]

Writes 4-byte little-endian number into given buffer.

Definition at line 56 of file lbfileio.c.

Referenced by level_clear_datclm(), and write_clm().

void write_int32_le_file ( FILE *  fp,
unsigned long  x 
) [inline]

Writes 4-byte little-endian number to given FILE.

Definition at line 45 of file lbfileio.c.

Referenced by write_apt(), write_bmp_fp_24b(), write_bmp_fp_idx(), write_cubedata(), write_jtytabfile_data(), write_lgt(), and write_tabfile_data().


Generated on Tue Sep 2 18:51:48 2008 for libAdikted by  doxygen 1.5.6