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

utrac.c File Reference

Public API for using Utrac. More...

#include <stdlib.h>
#include <stdio.h>
#include "utrac.h"
#include "debug.h"

Include dependency graph for utrac.c:

Include dependency graph

Go to the source code of this file.

Defines

#define _UTRAC_C_
#define UT_DEBUG   3

Functions

UtCode ut_init ()
 Initialize the Utrac library.
UtCode ut_init_noalloc ()
 Initialize the Utrac library, without allocating memory for UtSession. Used internally.
void ut_finish ()
 Free ressources allocated during initialization of Utrac.
void ut_finish_nofree ()
 Free ressources allocated during initialization of Utrac, without freeing UtSession. Used internally.
UtTextut_init_text_heap ()
 Allocates and initalizes an UtText structure.
void ut_init_text (UtText *new_text)
 Initalizes an UtText structure.
void ut_free_text_heap (UtText *text)
 Free an UtText structure.
void ut_free_text (UtText *text)
 Free the contents of an UtText structure, without freeing the structure itself.
UtCode ut_init_progress (UtText *text)
 Initialize an UtText structure before using the 'progress bar' callback feature.
UtCode ut_load (UtText *text, const char *filename)
 Load a file in an UtText structure.
UtCode ut_recognize (UtText *text)
 Recognize charset and EOL of a text.
UtCode ut_convert (UtText *src_text, UtText *dst_text)
 Convert a text.


Detailed Description

Public API for using Utrac.

Author:
Antoine Calando (antoine@alliancemca.net)

Definition in file utrac.c.


Function Documentation

UtCode ut_convert UtText src_text,
UtText dst_text
 

Convert a text.

Parameters:
src_text source text, with input eol and charset set.
dst_text destination text, with output eol and charset set. If it is null, src_text will be replaced by the destination text, and output eol and charset will be selectionned from ut_session.
If ut_session->progress_function is set, it will be called during loading and members of text dealing with this feature will be updated.

Definition at line 470 of file utrac.c.

References UtText::charset, UtSession::charset_default, UtText::current_pass, UtText::data, UtText::distribution, UtText::eol, UtText::eol_alt, UtSession::eol_alt_default, UtSession::eol_default, UtText::ext_char, UtExtCharLine::next, UtText::pass_flags, UtText::progress_done, UtSession::progress_function, UtText::progress_todo, UtText::size, ut_conversion_pass(), ut_free_text_heap(), ut_init_progress(), ut_init_text_heap(), UT_UNSET, and ut_update_progress().

Here is the call graph for this function:

void ut_finish  ) 
 

Free ressources allocated during initialization of Utrac.

This function frees the structure allocated in ut_session by ut_init(). It must be the last Utrac function called.

Returns:
UT_OK on success, an error code on failure.

Definition at line 154 of file utrac.c.

References ut_finish_nofree().

Here is the call graph for this function:

void ut_free_text UtText text  ) 
 

Free the contents of an UtText structure, without freeing the structure itself.

Parameters:
text pointer to the structure to free.

Definition at line 265 of file utrac.c.

References UtText::data, UtText::distribution, UtText::evaluation, UtText::ext_char, and UtExtCharLine::next.

Referenced by ut_free_text_heap().

void ut_free_text_heap UtText text  ) 
 

Free an UtText structure.

Parameters:
text pointer to the structure to free.

Definition at line 253 of file utrac.c.

References ut_free_text().

Referenced by ut_convert().

Here is the call graph for this function:

UtCode ut_init  ) 
 

Initialize the Utrac library.

This function must be called before any other Utrac function. It allocates an UtSession struture that is accessible by the ut_session pointer, initalizes it, loads charsets data, and sets default language, charset and end of line type. The memory used is about 630kb for 47 charsets loaded.

Note:
On Unix systems, LANG, LC_ALL and LC_TYPE are parsed to find default language and charsets (ISO-8859-1 is used else), and eol type is set to LF.
Returns:
UT_OK on success, an error code on failure.

Definition at line 56 of file utrac.c.

References ut_init_noalloc().

Here is the call graph for this function:

UtCode ut_init_progress UtText text  ) 
 

Initialize an UtText structure before using the 'progress bar' callback feature.

Can be used internaly or by the user. The UtText must have member UtText::pass_flag set, or at least UtText::flags (if UtText::pass_flags is unset, it will be set for just a recognition pass and subpasses will be selected upon the value of UtText::flags).

Definition at line 289 of file utrac.c.

References UtText::flags, UtText::pass_flags, UtText::progress_done, UtText::progress_todo, UT_F_ADD_FINAL_EOL, UT_F_REMOVE_ILLEGAL_CHAR, and UT_F_TRANSFORM_EOL.

Referenced by ut_convert(), ut_load(), and ut_recognize().

void ut_init_text UtText new_text  ) 
 

Initalizes an UtText structure.

Parameters:
new_text A pointer on the structure to initialize

Definition at line 221 of file utrac.c.

References UtText::charset, UtText::current_pass, UtText::data, UtText::distribution, UtText::eol, UtText::eol_alt, UtText::evaluation, UtText::ext_char, UtText::flags, UtText::nb_lines, UtText::nb_lines_alt, UtText::pass_flags, UtText::progress_done, UtText::progress_todo, UtText::size, UtText::skip_char, and UtText::user.

Referenced by ut_init_text_heap().

UtText* ut_init_text_heap  ) 
 

Allocates and initalizes an UtText structure.

Returns:
A pointer to the allocated structure, or NULL if the allocation failed.

Definition at line 206 of file utrac.c.

References ut_init_text().

Referenced by ut_convert().

Here is the call graph for this function:

UtCode ut_load UtText text,
const char *  filename
 

Load a file in an UtText structure.

If filename is null, it will read stdin. text->data and text->size will be set. If ut_session->progress_function is set, it will be called during loading and members of text dealing with this feature will be updated.

Definition at line 330 of file utrac.c.

References UtText::current_pass, UtText::pass_flags, UtText::progress_done, UtSession::progress_function, UtText::progress_todo, ut_init_progress(), and ut_update_progress().

Here is the call graph for this function:

UtCode ut_recognize UtText text  ) 
 

Recognize charset and EOL of a text.

text->data must be set. If text->size is null, recognition will stop at the first null character. text->flags must also be set to select processes to do (see UtTextFlags).

If ut_session->progress_function is set, it will be called during loading and members of text dealing with this feature will be updated.

If UT_F_FORCE_BINARY is set, texts with caracters between 0 and 0x19 (space is 0x20, and TAB, CR, LF are excluded of this range) won't produce error.

If UT_F_IDENTIFY_EOL is set, text->eol, text->eol_alt, text->nb_lines, text->nb_lines_alt will be updated. If convertion of EOL is planned, UT_F_TRANSFORM_EOL must be set.

If UT_F_IDENTIFY_CHARSET is set, text->charset will be updated. text->evaluation also if charset is 8bits and ASCII -erivated.

text->distribution will always be set, text->ext_char also (but this is a bug!)

If ut_session->progress_function is set, it will be called during loading and members of text dealing with this feature will be updated.

Definition at line 387 of file utrac.c.

References UtText::charset, UtText::current_pass, UtText::data, UtText::distribution, UtText::flags, UtText::pass_flags, UtText::progress_done, UtSession::progress_function, UtText::progress_todo, UtText::skip_char, ut_distrib_utf_pass(), UT_EOL_ALT_CHAR, ut_eol_pass(), ut_init_progress(), UT_UNSET, ut_update_progress(), and ut_xascii_pass().

Here is the call graph for this function:


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