heraia/trunk/libheraia/decode.c File Reference

#include <libheraia.h>

Include dependency graph for decode.c:

Go to the source code of this file.

Functions

static gboolean bissextile_year (guint32 year)
static void calc_which_month_day (date_and_time_t *mydate, guint32 day, guint tab_ns_months[12])
static void which_month_day (date_and_time_t *mydate, guint32 day, gboolean bi)
static guint32 remove_days_from_first_january (guint32 base_year, guint8 base_month, guint8 base_day)
static void which_year_month_day (date_and_time_t *mydate, guint32 days, guint32 base_year, guint base_month, guint8 base_day)
static void make_date_and_time (date_and_time_t *mydate, guchar *data, guint8 len, guint64 nbticks, guint32 base_year, guint base_month, guint8 base_day)
static void transform_bcd_to_human (gchar *bcd, guint8 part, guint8 part_number)
gchar * decode_8bits_signed (guchar *data)
gchar * decode_8bits_unsigned (guchar *data)
gchar * decode_16bits_signed (guchar *data)
gchar * decode_16bits_unsigned (guchar *data)
gchar * decode_32bits_signed (guchar *data)
gchar * decode_32bits_unsigned (guchar *data)
gchar * decode_64bits_signed (guchar *data)
gchar * decode_64bits_unsigned (guchar *data)
static gchar * date_printf (date_and_time_t *mydate)
gchar * decode_dos_date (guchar *data, date_and_time_t *mydate)
gchar * decode_filetime_date (guchar *data, date_and_time_t *mydate)
gchar * decode_C_date (guchar *data, date_and_time_t *mydate)
gchar * decode_HFS_date (guchar *data, date_and_time_t *mydate)
gchar * decode_to_bits (guchar *data)
gchar * decode_packed_BCD (guchar *data)
gboolean swap_bytes (guchar *to_swap, guint first, guint last)
void reverse_byte_order (guchar *to_reverse)


Function Documentation

static gboolean bissextile_year ( guint32  year  )  [static]

Says whether a year is a leap one or not

Definition at line 213 of file decode.c.

Referenced by remove_days_from_first_january(), and which_year_month_day().

static void calc_which_month_day ( date_and_time_t mydate,
guint32  day,
guint  tab_ns_months[12] 
) [static]

Says, from a number of days (eg 154), which month it is (eg may) and which day in the corresponding month (eg 2 (leap year) or 3)

Definition at line 244 of file decode.c.

References date_and_time_t::day, and date_and_time_t::month.

Referenced by which_month_day().

static gchar* date_printf ( date_and_time_t mydate  )  [static]

Return a gchar* that contains the date and time encoded from the values contained in the date_and_time_t structure it may be freed when no longer needed We do not use any of the g_date_strftime or strftime function because interpreted dates are not always valid !

Definition at line 422 of file decode.c.

References date_and_time_t::day, date_and_time_t::hour, date_and_time_t::minutes, date_and_time_t::month, date_and_time_t::seconds, and date_and_time_t::year.

Referenced by decode_C_date(), decode_dos_date(), decode_filetime_date(), and decode_HFS_date().

gchar* decode_16bits_signed ( guchar *  data  ) 

general purpose of this function is to take a 2 byte data stream and convert it as if it is a 16 bits signed number data : 2 guchars returns a gchar* that may be freed when no longer needed

Definition at line 85 of file decode.c.

Referenced by refresh_data_interpretor_window().

gchar* decode_16bits_unsigned ( guchar *  data  ) 

general purpose of this function is to take a 2 byte data stream and convert it as if it is a 16 bits unsigned number data : 2 guchars returns a gchar* that may be freed when no longer needed

Definition at line 107 of file decode.c.

Referenced by refresh_data_interpretor_window().

gchar* decode_32bits_signed ( guchar *  data  ) 

general purpose of this function is to take a 4 byte data stream and convert it as if it is a 32 bits signed number data : 4 guchars returns a gchar* that may be freed when no longer needed

Definition at line 129 of file decode.c.

Referenced by refresh_data_interpretor_window().

gchar* decode_32bits_unsigned ( guchar *  data  ) 

general purpose of this function is to take a 4 byte data stream and convert it as if it is a 32 bits unsigned number data : 4 guchars returns a gchar* that may be freed when no longer needed

Definition at line 151 of file decode.c.

Referenced by refresh_data_interpretor_window().

gchar* decode_64bits_signed ( guchar *  data  ) 

general purpose of this function is to take a 8 byte data stream and convert it as if it is a 64 bits signed number data : 8 guchars returns a gchar* that may be freed when no longer needed

Definition at line 172 of file decode.c.

Referenced by refresh_data_interpretor_window().

gchar* decode_64bits_unsigned ( guchar *  data  ) 

general purpose of this function is to take a 8 byte data stream and convert it as if it is a 64 bits unsigned number data : 8 guchars returns a gchar* that may be freed when no longer needed

Definition at line 194 of file decode.c.

Referenced by refresh_data_interpretor_window().

gchar* decode_8bits_signed ( guchar *  data  ) 

General purpose of this function is to take a 1 byte data stream and convert it as if it is an 8 bits signed number data : 1 guchar returns a gchar* that may be freed when no longer needed

Definition at line 40 of file decode.c.

Referenced by refresh_data_interpretor_window().

gchar* decode_8bits_unsigned ( guchar *  data  ) 

general purpose of this function is to take a 1 byte data stream and convert it as if it is an 8 bits unsigned number data : 1 guchar returns a gchar* that may be freed when no longer needed

Definition at line 62 of file decode.c.

Referenced by refresh_data_interpretor_window().

gchar* decode_C_date ( guchar *  data,
date_and_time_t mydate 
)

general purpose of this function is to take a 4 byte data stream and convert it as if it is a C date. If it is not, the result may be funny ! Counting seconds from 01/01/1970 data : 4 guchars returns a gchar* that may be freed when no longer needed

Definition at line 513 of file decode.c.

References date_printf(), and make_date_and_time().

Referenced by refresh_data_interpretor_window().

Here is the call graph for this function:

gchar* decode_dos_date ( guchar *  data,
date_and_time_t mydate 
)

general purpose of this function is to take a 4 byte data stream and convert it as if it is a dos date. If it is not, the result may be funny ! data : 4 guchars returns a gchar* that may be freed when no longer needed

Definition at line 435 of file decode.c.

References date_printf(), date_and_time_t::day, date_and_time_t::hour, date_and_time_t::minutes, date_and_time_t::month, date_and_time_t::seconds, and date_and_time_t::year.

Referenced by refresh_data_interpretor_window().

Here is the call graph for this function:

gchar* decode_filetime_date ( guchar *  data,
date_and_time_t mydate 
)

general purpose of this function is to take a 8 byte data stream and convert it as if it is a filetime date. If it is not, the result may be funny ! Counting 100th of nanoseconds from 01/01/1601 data : 8 guchars returns a gchar* that may be freed when no longer needed

Definition at line 492 of file decode.c.

References date_printf(), and make_date_and_time().

Referenced by refresh_data_interpretor_window().

Here is the call graph for this function:

gchar* decode_HFS_date ( guchar *  data,
date_and_time_t mydate 
)

general purpose of this function is to take a 4 byte data stream and convert it as if it is a HFS date. If it is not, the result may be funny ! Counting seconds 01/01/1904 data : 4 guchars returns a gchar* that may be freed when no longer needed

Definition at line 533 of file decode.c.

References date_printf(), and make_date_and_time().

Referenced by refresh_data_interpretor_window().

Here is the call graph for this function:

gchar* decode_packed_BCD ( guchar *  data  ) 

Decode one byte as a Packed BCD (Binary Coded Decimal) and return a gchar* that me be freed when no longer needed

Definition at line 644 of file decode.c.

References transform_bcd_to_human().

Referenced by refresh_data_interpretor_window().

Here is the call graph for this function:

gchar* decode_to_bits ( guchar *  data  ) 

decodes the stream represented by *data (one byte) to a string containing eight 0 or 1 (Little Endian style)

Definition at line 552 of file decode.c.

Referenced by refresh_data_interpretor_window().

static void make_date_and_time ( date_and_time_t mydate,
guchar *  data,
guint8  len,
guint64  nbticks,
guint32  base_year,
guint  base_month,
guint8  base_day 
) [static]

Reads the data from the stream (specified length !! <= 64 bits ) . date_and_time_t *mydate : the resulting date . guchar *data : the stream . guint8 len : length of the stream in bytes ( must be <= 64 bits) . guint64 nbticks : number of ticks per seconds (1, 1000, ...) . guint32 base_year : Epoch year (1970, 1904, ...) . guint8 base_month : Epoch month (january, ...) . guint8 base_day : Epoch day (01, 15, ...) populates the date_and_time_t structure

Definition at line 467 of file decode.c.

References date_and_time_t::hour, date_and_time_t::minutes, date_and_time_t::seconds, and which_year_month_day().

Referenced by decode_C_date(), decode_filetime_date(), and decode_HFS_date().

Here is the call graph for this function:

static guint32 remove_days_from_first_january ( guint32  base_year,
guint8  base_month,
guint8  base_day 
) [static]

Returns the number of days since 01/01/base_year eg 15/02/base_year --> 31 + 15 = 46

Definition at line 305 of file decode.c.

References bissextile_year().

Referenced by which_year_month_day().

Here is the call graph for this function:

void reverse_byte_order ( guchar *  to_reverse  ) 

Reverse the byte order LSB -> MSB in MSB -> LSB 12345678 in 87654321

Definition at line 708 of file decode.c.

Referenced by change_endianness().

gboolean swap_bytes ( guchar *  to_swap,
guint  first,
guint  last 
)

Code that has moved into libheraia

gchar *decode_8bits_signed(guchar *data) gchar *decode_8bits_unsigned(guchar *data) gchar *decode_16bits_signed(guchar *data) gchar *decode_16bits_unsigned(guchar *data) gchar *decode_32bits_signed(guchar *data) gchar *decode_32bits_unsigned(guchar *data) gchar *decode_64bits_signed(guchar *data) gchar *decode_64bits_unsigned(guchar *data) Swap bytes from the buffer to_swap recursive function !! call with first = 0 and last = last byte of buffer to swap

Definition at line 687 of file decode.c.

References swap_bytes().

Referenced by change_endianness(), and swap_bytes().

Here is the call graph for this function:

static void transform_bcd_to_human ( gchar *  bcd,
guint8  part,
guint8  part_number 
) [static]

transcribes the bcd number "part" into a gchar * human readable string Coding style is from ETSI GSM 04.08 ETS 300557 p387 TODO : give choice of coding style (eg for numbers >=10)

Definition at line 580 of file decode.c.

Referenced by decode_packed_BCD().

static void which_month_day ( date_and_time_t mydate,
guint32  day,
gboolean  bi 
) [static]

Front end function for the calc_which_month_day function !

Definition at line 268 of file decode.c.

References calc_which_month_day(), date_and_time_t::day, and date_and_time_t::month.

Referenced by which_year_month_day().

Here is the call graph for this function:

static void which_year_month_day ( date_and_time_t mydate,
guint32  days,
guint32  base_year,
guint  base_month,
guint8  base_day 
) [static]

About date calculation : Leap years are periods of 4 years except the years that we can divide by 100 and not 400. So we can distinguish 2 periods : one of 400 years and one of 4 years.

  • we have 100 bissextiles years in a period of 400 years this means that every 400 years we have exactly 146100 days.
  • we have 1 bissextile year every 4 years : this means that we have exactly 1461 days every 4 years. As we can calculate _exactly_ the number of days in a filetime or C_date format, we could calculate _exactly_ the number of periods of 400 years and then the number of periods of 4 years.

Definition at line 374 of file decode.c.

References bissextile_year(), remove_days_from_first_january(), which_month_day(), and date_and_time_t::year.

Referenced by make_date_and_time().

Here is the call graph for this function:


Generated on Mon Oct 20 21:22:47 2008 for Heraia by  doxygen 1.5.6