util.h File Reference

#include <stdio.h>
Include dependency graph for util.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

char * osl_util_skip_blank_and_comments (FILE *, char *)
void osl_util_sskip_blank_and_comments (char **)
int osl_util_read_int (FILE *, char **)
char * osl_util_read_string (FILE *, char **)
char * osl_util_read_line (FILE *, char **)
char * osl_util_read_tag (FILE *, char **)
char * osl_util_read_tail (FILE *)
char * osl_util_read_uptotag (FILE *, char *)
char * osl_util_read_uptoendtag (FILE *, char *)
char * osl_util_tag_content (char *, char *)
void osl_util_safe_strcat (char **, char *, int *)
int osl_util_get_precision ()
void osl_util_print_provided (FILE *, int, char *)
char * osl_util_identifier_substitution (char *, char **)

Function Documentation

int osl_util_get_precision (  ) 

osl_util_get_precision function: this function returns the precision defined by the precision environment variable or the highest available precision if it is not defined.

Returns:
environment precision if defined or highest available precision.

Definition at line 461 of file util.c.

References OSL_PRECISION_DP, OSL_PRECISION_ENV, OSL_PRECISION_ENV_DP, OSL_PRECISION_ENV_MP, OSL_PRECISION_ENV_SP, OSL_PRECISION_MP, OSL_PRECISION_SP, and OSL_warning.

Referenced by osl_relation_list_read(), osl_relation_malloc(), osl_relation_read(), osl_scop_read(), osl_statement_read(), and osl_vector_malloc().

char* osl_util_identifier_substitution ( char *  expression,
char **  identifiers 
)

osl_util_identifier_substitution function: this function replaces some identifiers in an input expression string and returns the final string. The list of identifiers to replace are provided as an array of strings. They are replaced from the input string with the new substring "@i@" or "(@i@)" where i is the rank of the identifier in the array of identifiers. The parentheses are added when it is not obvious that the identifier can be replaced with an arbitrary expression without the need of parentheses. For instance, let us consider the input expression "C[i+j]+=A[2*i]*B[j];" and the array of strings {"i", "j"}: the resulting string would be "C[@0@+@1@]+=A[2*(@0@)]*B[@1@];".

Parameters:
[in] expression The original expression.
[in] identifiers NULL-terminated array of identifiers.
Returns:
A new string where the ith identifier is replaced by @i@.

Definition at line 625 of file util.c.

References OSL_malloc, OSL_MAX_STRING, osl_util_identifier_is_here(), osl_util_lazy_isolated_identifier(), and osl_util_safe_strcat().

void osl_util_print_provided ( FILE *  file,
int  provided,
char *  title 
)

osl_util_print_provided function: this function prints a "provided" boolean in a file (file, possibly stdout), with a comment title according to the OpenScop specification.

Parameters:
[in] file File where the information has to be printed.
[in] provided The provided boolean to print.
[in] title A string to use as a title for the provided booblean.

Definition at line 500 of file util.c.

Referenced by osl_scop_print().

int osl_util_read_int ( FILE *  file,
char **  str 
)

osl_util_read_int function: reads an int on the input 'file' or the input string 'str' depending on which one is not NULL (exactly one of them must not be NULL).

Parameters:
[in] file The file where to read an int (if not NULL).
[in,out] str The string where to read an int (if not NULL). This pointer is updated to reflect the read and points after the int in the input string.
Returns:
The int that has been read.

Definition at line 140 of file util.c.

References OSL_error, OSL_MAX_STRING, osl_util_skip_blank_and_comments(), and osl_util_sskip_blank_and_comments().

Referenced by osl_arrays_sread(), osl_body_sread(), osl_coordinates_sread(), osl_relation_list_pread(), osl_scop_pread(), and osl_statement_pread().

char* osl_util_read_line ( FILE *  file,
char **  str 
)

osl_util_read_line function: reads a line on the input 'file' or the input string 'str' depending on which one is not NULL (exactly one of them must not be NULL). A line is defined as the array of characters before the comment tag or the end of line (it may include spaces).

Parameters:
[in] file The file where to read a line (if not NULL).
[in,out] str The string where to read a line (if not NULL). This pointer is updated to reflect the read and points after the line in the input string.
Returns:
The line that has been read.

Definition at line 226 of file util.c.

References OSL_error, OSL_malloc, OSL_MAX_STRING, OSL_realloc, osl_util_skip_blank_and_comments(), and osl_util_sskip_blank_and_comments().

Referenced by osl_body_sread(), and osl_coordinates_sread().

char* osl_util_read_string ( FILE *  file,
char **  str 
)

osl_util_read_string function: reads a string on the input 'file' or the input string 'str' depending on which one is not NULL (exactly one of them must not be NULL).

Parameters:
[in] file The file where to read a string (if not NULL).
[in,out] str The string where to read a string (if not NULL). This pointer is updated to reflect the read and points after the string in the input string.
Returns:
The string that has been read.

Definition at line 181 of file util.c.

References OSL_error, OSL_malloc, OSL_MAX_STRING, OSL_realloc, osl_util_skip_blank_and_comments(), and osl_util_sskip_blank_and_comments().

Referenced by osl_arrays_sread().

char* osl_util_read_tag ( FILE *  file,
char **  str 
)

osl_util_read_int internal function: reads a tag (the form of a tag with name "name" is <name>) on the input 'file' or the input string 'str' depending on which one is not NULL (exactly one of them must not be NULL). It returns the name of the tag (thus without the < and > as a string. Note that in the case of an ending tag, e.g., </foo>, the slash is returned as a part of the name, e.g., /foo.

Parameters:
[in] file The file where to read a tag (if not NULL).
[in,out] str The string where to read a tag (if not NULL). This pointer is updated to reflect the read and points after the tag in the input string.
Returns:
The tag name that has been read.

Definition at line 267 of file util.c.

References OSL_error, OSL_malloc, OSL_MAX_STRING, osl_util_skip_blank_and_comments(), and osl_util_sskip_blank_and_comments().

Referenced by osl_generic_read_one().

char* osl_util_read_tail ( FILE *   ) 
char* osl_util_read_uptoendtag ( FILE *  file,
char *  name 
)

osl_util_read_uptoendtag function: this function reads a file up to a given end tag (this end tag is read) or the end of file. The name of the tag is provided as parameter (hence without the starting "</" end the closing ">"). It puts everything it reads in a string which is returned.

Parameters:
[in] file The file where to read the tail.
[in] name The name of the end tag to the file reading.
Returns:
The string that has been read from the file.

Definition at line 374 of file util.c.

References osl_util_read_uptotag().

Referenced by osl_generic_read_one().

char* osl_util_read_uptotag ( FILE *  file,
char *  tag 
)

osl_util_read_uptotag function: this function reads a file up to a given tag (the tag is read) or the end of file. It puts everything it reads, except the tag, in a string which is returned. However ot returns NULL is the tag is not found.

Parameters:
[in] file The file where to read the tail.
[in] tag The tag which, when reached, stops the file reading.
Returns:
The string that has been read from the file.

Definition at line 324 of file util.c.

References OSL_debug, OSL_malloc, OSL_MAX_STRING, and OSL_realloc.

Referenced by osl_generic_read(), osl_scop_pread(), and osl_util_read_uptoendtag().

void osl_util_safe_strcat ( char **  dst,
char *  src,
int *  hwm 
)

osl_util_safe_strcat function: this function concatenates the string src to the string *dst and reallocates *dst if necessary. The current size of the *dst buffer must be *hwm (high water mark), if there is some reallocation, this value is updated.

Parameters:
[in,out] dst pointer to the destination string (may be reallocated).
[in] src string to concatenate to dst.
[in,out] hwm pointer to the size of the *dst buffer (may be updated).

Definition at line 444 of file util.c.

References OSL_MAX_STRING, and OSL_realloc.

Referenced by osl_arrays_sprint(), osl_body_sprint(), osl_comment_sprint(), osl_coordinates_sprint(), osl_irregular_sprint(), osl_relation_spprint(), osl_relation_spprint_polylib(), osl_relation_sprint_comment(), osl_strings_sprint(), and osl_util_identifier_substitution().

char* osl_util_skip_blank_and_comments ( FILE *  file,
char *  str 
)

osl_util_skip_blank_and_comments "file skip" function: this function reads the open file 'file' line by line and skips blank/comment lines and spaces. The first line where there is some useful information is stored at the address 'str' (the memory to store the line must be allocated before the call to this function and must be at least OSL_MAX_STRING * sizeof(char)). The pointer to the first useful information in this line is returned by the function.

Parameters:
[in] file The (opened) file to read.
[in] str Address of an allocated space to store the first line that contains useful information.
Returns:
The address of the first useful digit in str.

Definition at line 91 of file util.c.

References OSL_MAX_STRING.

Referenced by osl_relation_pread(), osl_strings_read(), osl_util_read_int(), osl_util_read_line(), osl_util_read_string(), and osl_util_read_tag().

void osl_util_sskip_blank_and_comments ( char **  str  ) 

osl_util_sskip_blank_and_comments "string skip" function: this function updates the str pointer, which initialy points to a string, to the first character in this string which is not a space or a comment (comments start at '#' and end at '
'), or to the end of string.

Parameters:
[in,out] str Address of a string, updated to the address of the first non-space or comment character.

Definition at line 113 of file util.c.

Referenced by osl_strings_sread(), osl_util_read_int(), osl_util_read_line(), osl_util_read_string(), and osl_util_read_tag().

char* osl_util_tag_content ( char *  str,
char *  name 
)

osl_util_tag_content function: this function returns a freshly allocated string containing the content, in the given string 'str', between the tag '<name>' and the tag '</name>'. If the tag '<name>' is not found, it returns NULL.

Parameters:
[in] str The string where to find a given content.
[in] name The name of the tag we are looking for.
Returns:
The string between '<name>' and '</name>' in 'str'.

Definition at line 391 of file util.c.

References OSL_malloc.

Referenced by osl_generic_sread().

Generated on Fri Feb 17 15:26:48 2012 for OpenScop by  doxygen 1.6.3