Main Page | Class List | File List | Class Members | File Members | Related Pages

ut_utils.c File Reference

Various internal functions. More...

#include <sys/stat.h>
#include <unistd.h>
#include <float.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <endian.h>
#include <byteswap.h>
#include "utrac.h"
#include "ut_text.h"
#include "ut_charset.h"
#include "debug.h"

Include dependency graph for ut_utils.c:

Include dependency graph

Go to the source code of this file.

Functions

UtCode ut_load_charset_file (const char *filename, char **buffer)
 Load a file in a buffer.
void ut_print_binary (ulong src)
 Print a number in binary form on stdout (debug).
UtCode ut_debug_text (UtText *text)
 Print content of a UtText structure (debug).
UtCode ut_debug_text_rating (UtText *text)
 Print content of a UtText::evaluation array (debug).
UtCharsetIndex ut_find_charset (char *charset_name)
 get charset index from a string
UtEolType ut_find_eol (char *eol_name)
int ut_find_lang_sys (char *language_name, UtLangSys *lang_sys)
bool ut_str_fuzzy_cmp (const char *str1, const char *str2, char stop_char)
 Approximative comparaison between two strings.
double ut_get_charset_coef (UtCharsetIndex i)
bool ut_update_progress (UtText *text, ulong processed, bool start_stop)
 Function which call the user-defined function UtText::progress_function.
ulong ut_crc32 (ushort data, ulong crc_in)
 Function which call the user-defined function UtText::progress_function.

Variables

ulong ut_crc32_table [256]
 table CRC32 ?
const ulong UT_CRC32_POLY = 0x04c11db7


Detailed Description

Various internal functions.

Author:
Antoine Calando (antoine@alliancemca.net)

Definition in file ut_utils.c.


Function Documentation

bool is_letter char  c  )  [inline, static]
 

brief Utility functions for ut_str_fuzzy_cmp() These functions test if a character is uppercase, lowercase, letter or number.

Definition at line 164 of file ut_utils.c.

References is_maj().

Referenced by ut_str_fuzzy_cmp().

Here is the call graph for this function:

bool is_maj char  c  )  [inline, static]
 

brief Utility functions for ut_str_fuzzy_cmp() These functions test if a character is uppercase, lowercase, letter or number.

Definition at line 162 of file ut_utils.c.

Referenced by is_letter(), and ut_str_fuzzy_cmp().

bool is_min char  c  )  [inline, static]
 

brief Utility functions for ut_str_fuzzy_cmp() These functions test if a character is uppercase, lowercase, letter or number.

Definition at line 163 of file ut_utils.c.

bool is_num char  c  )  [inline, static]
 

brief Utility functions for ut_str_fuzzy_cmp() These functions test if a character is uppercase, lowercase, letter or number.

Definition at line 165 of file ut_utils.c.

Referenced by ut_str_fuzzy_cmp().

ulong ut_crc32 ushort  data,
ulong  crc_in
 

Function which call the user-defined function UtText::progress_function.

Parameters:
data The data to "checksum"
crc_in The previous returned checksum, 0 if none
Returns:
The resulting checksum.
Note:
Compute the CRC of a data. Code was modified and the following may not be exact : The following C code (by Rob Warnock <rpw3@sgi.com>) does CRC-32 in BigEndian/BigEndian byte/bit order. That is, the data is sent most significant byte first, and each of the bits within a byte is sent most significant bit first, as in FDDI. You will need to twiddle with it to do Ethernet CRC, i.e., BigEndian/LittleEndian byte/bit order. The CRCs this code generates agree with the vendor-supplied Verilog models of several of the popular FDDI "MAC" chips.

Definition at line 366 of file ut_utils.c.

References UT_CRC32_POLY, and ut_crc32_table.

Referenced by ut_xascii_pass().

UtCode ut_load_charset_file const char *  filename,
char **  buffer
 

Load a file in a buffer.

Parameters:
filename Path to the file.
buffer Pointer used to return buffer address. Buffer must be free after used by user.
Returns:
UT_OK on succes, error code otherwise.

Bug:
EC il n'y a qu'un appel à read or lorsque read!=size ce n'est pas une erreur si errno vaut EAGAIN. AC read() ne peut pas renvoyer EAGAIN si le fichier n'a pas été open() en mode EAGAIN (norme POSIX)

Definition at line 64 of file ut_utils.c.

Referenced by ut_load_charsets().

void ut_print_binary ulong  src  ) 
 

Print a number in binary form on stdout (debug).

Parameters:
src Number to print.

Bug:
pas de gestion big/little endian

Definition at line 102 of file ut_utils.c.

Referenced by ut_debug_text(), and ut_utf8c_to_unicode().

bool ut_str_fuzzy_cmp const char *  str1,
const char *  str2,
char  stop_char
 

Approximative comparaison between two strings.

The comparaison focuses only on substrings composed of number or letter (case is not significant). For instance "iso8859 1"=="ISO-8859-1", but "Mac Roman"!="MacRoman".

Definition at line 232 of file ut_utils.c.

References is_letter(), is_maj(), and is_num().

Referenced by ut_find_charset(), and ut_init_noalloc().

Here is the call graph for this function:

bool ut_update_progress UtText text,
ulong  processed,
bool  start_stop
 

Function which call the user-defined function UtText::progress_function.

Parameters:
text Related UtText structure.
processed Size in byte processed, compared to UtText::size.
start_stop If true, the user-defined function will be call for initialisation or cleanup.
Returns:
This function returns the same return code than the user-defined function, i.e. 0 if the processing must be interrupted, 1 otherwise.

Definition at line 316 of file ut_utils.c.

References UtText::progress_done, UtSession::progress_function, UtText::progress_todo, UtText::size, and ut_update_progress().

Referenced by ut_conversion_pass(), ut_convert(), ut_distrib_utf_pass(), ut_eol_pass(), ut_load(), ut_recognize(), ut_update_progress(), and ut_xascii_pass().

Here is the call graph for this function:


Variable Documentation

const ulong UT_CRC32_POLY = 0x04c11db7
 

MAGIC NUMBER ?

Definition at line 345 of file ut_utils.c.

Referenced by ut_crc32().


Generated on Fri Feb 25 18:30:16 2005 for Utrac by  doxygen 1.3.9