/** * 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. * \param[in] file File where informations are printed. * \param[in] strings The strings whose information has to be printed. */ void osl_strings_print(FILE * file, osl_strings_p strings) { char * string; string = osl_strings_sprint(strings); if (string != NULL) { fprintf(file, "%s", string); free(string); } }
/** * osl_body_sprint function: * this function prints the content of an osl_body_t structure * (*body) into a string (returned) in the OpenScop textual format. * \param[in] body The body structure which has to be printed. * \return A string containing the OpenScop dump of the body structure. */ char * osl_body_sprint(osl_body_p body) { int nb_iterators; int high_water_mark = OSL_MAX_STRING; char * string = NULL; char buffer[OSL_MAX_STRING]; char * iterators, * expression; OSL_malloc(string, char *, high_water_mark * sizeof(char)); string[0] = '\0'; if (body != NULL) { nb_iterators = osl_strings_size(body->iterators); sprintf(buffer, "# Number of original iterators\n%d\n", nb_iterators); osl_util_safe_strcat(&string, buffer, &high_water_mark); if (nb_iterators > 0) { sprintf(buffer, "# List of original iterators\n"); osl_util_safe_strcat(&string, buffer, &high_water_mark); iterators = osl_strings_sprint(body->iterators); osl_util_safe_strcat(&string, iterators, &high_water_mark); free(iterators); } sprintf(buffer, "# Statement body expression\n"); osl_util_safe_strcat(&string, buffer, &high_water_mark); expression = osl_strings_sprint(body->expression); osl_util_safe_strcat(&string, expression, &high_water_mark); free(expression); } else { sprintf(buffer, "# NULL body\n"); osl_util_safe_strcat(&string, buffer, &high_water_mark); } return string; }
/** * osl_scatnames_sprint function: * this function prints the content of an osl_scatnames_t structure * (*scatnames) into a string (returned) in the OpenScop textual format. * \param[in] scatnames The scatnames structure to print. * \return A string containing the OpenScop dump of the scatnames structure. */ char * osl_scatnames_sprint(osl_scatnames_p scatnames) { return osl_strings_sprint(scatnames->names); }