X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/99e824529b9afeefa3855403974e88f6006dbc4c..6f4585f1e19602414bc4971c9d19fc5d600eb0fa:/src/xbt/xbt_str.c?ds=sidebyside diff --git a/src/xbt/xbt_str.c b/src/xbt/xbt_str.c index 73279a41e8..d18a94588f 100644 --- a/src/xbt/xbt_str.c +++ b/src/xbt/xbt_str.c @@ -699,3 +699,23 @@ char *xbt_str_diff(char *a, char *b) return res; } + + +/** @brief creates a new string containing what can be read on a fd + * + */ +char* xbt_str_from_file(FILE *file) { + xbt_strbuff_t buff = xbt_strbuff_new(); + char *res; + char bread[1024]; + + while (!feof(file)) { + fread(bread, 1, 1023, file); + bread[1023] = '\0'; + xbt_strbuff_append(buff,bread); + } + + res = buff->data; + xbt_strbuff_free_container(buff); + return res; +}