OpenScop  0.9.0
Functions
strings.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <osl/macros.h>
#include <osl/util.h>
#include <osl/interface.h>
#include <osl/strings.h>
Include dependency graph for strings.c:

Go to the source code of this file.

Functions

void osl_strings_idump (FILE *file, osl_strings_p strings, int level)
void osl_strings_dump (FILE *file, osl_strings_p strings)
char * osl_strings_sprint (osl_strings_p strings)
void osl_strings_print (FILE *file, osl_strings_p strings)
osl_strings_p osl_strings_sread (char **input)
osl_strings_p osl_strings_read (FILE *file)
osl_strings_p osl_strings_malloc ()
void osl_strings_free (osl_strings_p strings)
osl_strings_p osl_strings_clone (osl_strings_p strings)
size_t osl_strings_find (osl_strings_p strings, char const *const string)
void osl_strings_add (osl_strings_p strings, char const *const string)
int osl_strings_equal (osl_strings_p s1, osl_strings_p s2)
size_t osl_strings_size (osl_const_strings_const_p strings)
osl_strings_p osl_strings_encapsulate (char *string)
osl_interface_p osl_strings_interface ()
osl_strings_p osl_strings_generate (char *prefix, int nb_strings)

Function Documentation

void osl_strings_add ( osl_strings_p  strings,
char const *const  string 
)

osl_strings_add function. this function adds a copy of the string in the strings.

Parameters:
[in,out]stringsThe strings structure.
[in]stringThe string to add in strings.

Definition at line 368 of file strings.c.

References OSL_realloc, osl_strings_size(), and osl_strings::string.

osl_strings_clone function. this function builds and return a "hard copy" (not a pointer copy) of an strings structure provided as parameter.

Parameters:
[in]stringsThe strings structure to clone.
Returns:
The clone of the strings structure.

Definition at line 327 of file strings.c.

References OSL_malloc, OSL_strdup, osl_strings_malloc(), osl_strings_size(), and osl_strings::string.

Referenced by osl_body_clone(), osl_names_clone(), osl_scatnames_clone(), and osl_strings_interface().

void osl_strings_dump ( FILE *  file,
osl_strings_p  strings 
)

osl_strings_dump function: this function prints the content of an osl_strings_t structure (*strings) into a file (file, possibly stdout).

Parameters:
[in]fileThe file where the information has to be printed.
[in]stringsThe strings structure which has to be printed.

Definition at line 119 of file strings.c.

References osl_strings_idump().

osl_strings_encapsulate function: this function builds a new strings structure to encapsulate the string provided as a parameter (the reference to this string is used directly).

Parameters:
[in]stringThe string to encapsulate in a strings structure.
Returns:
A new strings structure containing only the provided string.

Definition at line 431 of file strings.c.

References OSL_malloc, osl_strings_malloc(), and osl_strings::string.

Referenced by osl_body_sread().

osl_strings_equal function: this function returns true if the two strings structures are the same (content-wise), false otherwise.

Parameters:
[in]s1The first strings structure.
[in]s2The second strings structure.
Returns:
1 if s1 and s2 are the same (content-wise), 0 otherwise.

Definition at line 385 of file strings.c.

References osl_strings_size(), and osl_strings::string.

Referenced by osl_body_equal(), osl_scatnames_equal(), and osl_strings_interface().

size_t osl_strings_find ( osl_strings_p  strings,
char const *const  string 
)

osl_strings_find function. this function finds the string in the strings.

Parameters:
[in,out]stringsThe strings structure.
[in]stringThe string to find in strings.
Returns:
the index where is the string, osl_strings_size if not found

Definition at line 353 of file strings.c.

References osl_strings_size(), and osl_strings::string.

void osl_strings_free ( osl_strings_p  strings)

osl_strings_free function: this function frees the allocated memory for a strings data structure.

Parameters:
[in]stringsThe strings structure we want to free.

Definition at line 298 of file strings.c.

References osl_strings::string.

Referenced by osl_body_free(), osl_names_free(), osl_relation_read_type(), osl_scatnames_free(), osl_scop_pread(), osl_scop_print(), osl_scop_print_scoplib(), and osl_strings_interface().

osl_strings_p osl_strings_generate ( char *  prefix,
int  nb_strings 
)

osl_strings_generate function: this function generates a new strings structure containing 'nb_strings' strings of the form "prefixXX" where XX goes from 1 to nb_strings.

Parameters:
[in]prefixThe prefix of the generated strings.
[in]nb_stringsThe number of strings to generate.
Returns:
A new strings structure containing generated strings.

Definition at line 473 of file strings.c.

References OSL_error, OSL_malloc, OSL_strdup, osl_strings_malloc(), and osl_strings::string.

Referenced by osl_arrays_to_strings(), and osl_names_generate().

void osl_strings_idump ( FILE *  file,
osl_strings_p  strings,
int  level 
)

osl_strings_idump function: this function displays an array of strings into a file (file, possibly stdout) in a way that trends to be understandable. It includes an indentation level (level) in order to work with others idump functions.

Parameters:
[in]fileThe file where the information has to be printed.
[in]stringsThe array of strings that has to be printed.
[in]levelNumber of spaces before printing, for each line.

Definition at line 89 of file strings.c.

References osl_strings_size(), and osl_strings::string.

Referenced by osl_body_idump(), osl_names_idump(), osl_scatnames_idump(), osl_strings_dump(), and osl_strings_interface().

osl_strings_interface function: this function creates an interface structure corresponding to the strings structure and returns it).

Returns:
An interface structure for the strings structure.

Definition at line 448 of file strings.c.

References osl_interface_malloc(), OSL_strdup, osl_strings_clone(), osl_strings_equal(), osl_strings_free(), osl_strings_idump(), osl_strings_malloc(), osl_strings_sprint(), osl_strings_sread(), and OSL_URI_STRINGS.

Referenced by osl_interface_get_default_registry().

osl_strings_malloc function: This function allocates the memory space for an osl_strings_t structure and sets its fields with default values. Then it returns a pointer to the allocated space.

Returns:
A pointer to an empty strings structure with fields set to default values.

Definition at line 282 of file strings.c.

References OSL_malloc, and osl_strings::string.

Referenced by osl_body_sread(), osl_strings_clone(), osl_strings_encapsulate(), osl_strings_generate(), osl_strings_interface(), and osl_strings_sread().

void osl_strings_print ( FILE *  file,
osl_strings_p  strings 
)

osl_strings_print function: this function prints the content of an osl_strings_t structure (*body) into a file (file, possibly stdout) in the OpenScop format.

Parameters:
[in]fileFile where informations are printed.
[in]stringsThe strings whose information has to be printed.

Definition at line 166 of file strings.c.

References osl_strings_sprint().

Referenced by osl_body_print(), osl_body_print_scoplib(), and osl_scop_print_scoplib().

osl_strings_p osl_strings_read ( FILE *  file)

osl_strings_read function. this function reads a strings structure from a file (possibly stdin) complying to the OpenScop textual format and returns a pointer to this structure. parameter nb_strings).

Parameters:
[in]fileThe file where to read the strings structure.
Returns:
The strings structure that has been read.

Definition at line 258 of file strings.c.

References OSL_MAX_STRING, osl_strings_sread(), and osl_util_skip_blank_and_comments().

Referenced by osl_relation_read_type(), and osl_scop_pread().

osl_strings_size function: this function returns the number of elements in the NULL-terminated strings array of the strings structure.

Parameters:
[in]stringsThe strings structure we need to know the size.
Returns:
The number of strings in the strings structure.

Definition at line 411 of file strings.c.

Referenced by osl_body_print(), osl_body_print_scoplib(), osl_body_sprint(), osl_relation_read_type(), osl_scop_pread(), osl_statement_integrity_check(), osl_strings_add(), osl_strings_clone(), osl_strings_equal(), osl_strings_find(), osl_strings_idump(), and osl_strings_sprint().

char* osl_strings_sprint ( osl_strings_p  strings)

osl_strings_sprint function: this function prints the content of an osl_strings_t structure (*strings) into a string (returned) in the OpenScop textual format.

Parameters:
[in]stringsThe strings structure which has to be printed.
Returns:
A string containing the OpenScop dump of the strings structure.

Definition at line 131 of file strings.c.

References OSL_malloc, OSL_MAX_STRING, osl_strings_size(), osl_util_safe_strcat(), and osl_strings::string.

Referenced by osl_body_sprint(), osl_scatnames_sprint(), osl_strings_interface(), and osl_strings_print().

osl_strings_p osl_strings_sread ( char **  input)

osl_strings_sread function: this function reads a strings structure from a string complying to the OpenScop textual format and returns a pointer to this strings structure. The input string should only contain the list of strings this function has to read (comments at the end of the line are accepted). The input parameter is updated to the position in the input string this function reach right after reading the strings structure.

Parameters:
[in,out]inputThe input string where to find a strings structure. Updated to the position after what has been read.
Returns:
A pointer to the strings structure that has been read.

Definition at line 194 of file strings.c.

References OSL_malloc, OSL_MAX_STRING, OSL_strdup, osl_strings_malloc(), osl_util_sskip_blank_and_comments(), and osl_strings::string.

Referenced by osl_body_sread(), osl_relation_read_type(), osl_scatnames_sread(), osl_strings_interface(), and osl_strings_read().