XBT_PUBLIC(char *) xbt_str_varsubst(const char *str, xbt_dict_t patterns);
/* */
-XBT_PUBLIC(void) xbt_str_strip_spaces(char *);
XBT_PUBLIC(char *) xbt_str_diff(const char *a, const char *b);
XBT_PUBLIC(char *) xbt_str_from_file(FILE * file);
-XBT_PUBLIC(int) xbt_str_start_with(const char* str, const char* start);
-
XBT_PUBLIC(long int) xbt_str_parse_int(const char* str, const char* error_msg);
XBT_PUBLIC(double) xbt_str_parse_double(const char* str, const char* error_msg);
/** Contains all the parameters we got from the command line (including argv[0]) */
XBT_PUBLIC_DATA(xbt_dynar_t) xbt_cmdline;
-/**
- *
- * Time management functions, returns the system time or sleeps a process.
- */
-XBT_PUBLIC(double) xbt_time(void);
-XBT_PUBLIC(void) xbt_sleep(double sec);
-
-
SG_END_DECL()
#endif /* __XBT_VIRTU_H__ */
/** @brief constructor */
xbt_sha_t xbt_sha_new(void)
{
- xbt_sha_t sha;
-
- sha = xbt_new(s_xbt_sha_t, 1);
+ xbt_sha_t sha = xbt_new(s_xbt_sha_t, 1);
xbt_sha_reset(sha);
-
return sha;
}
xbt_str_ltrim(s, char_list);
}
-/** @brief Replace double whitespaces (but no other characters) from the string.
- *
- * The function modifies the string so that each time that several spaces appear,
- * they are replaced by a single space. It will only do so for spaces (ASCII 32, 0x20).
- *
- * @param s The string to strip. Modified in place.
- *
- */
-void xbt_str_strip_spaces(char *s)
-{
- char *p = s;
- int e = 0;
-
- if (!s)
- return;
-
- while (1) {
- if (!*p)
- goto end;
-
- if (*p != ' ')
- break;
-
- p++;
- }
-
- e = 1;
-
- do {
- if (e)
- *s++ = *p;
-
- if (!*++p)
- goto end;
-
- if (e ^ (*p != ' '))
- if ((e = !e))
- *s++ = ' ';
- } while (1);
-
-end:
- *s = '\0';
-}
-
/** @brief Substitutes a char for another in a string
*
* @param str the string to modify
return res;
}
-/* @brief Retrun 1 if string 'str' starts with string 'start'
- *
- * \param str a string
- * \param start the string to search in str
- *
- * \return 1 if 'str' starts with 'start'
- */
-int xbt_str_start_with(const char* str, const char* start)
-{
- unsigned int i;
- size_t l_str = strlen(str);
- size_t l_start = strlen(start);
-
- if(l_start > l_str) return 0;
-
- for(i = 0; i< l_start; i++){
- if(str[i] != start[i]) return 0;
- }
-
- return 1;
-}
-
/** @brief Parse an integer out of a string, or raise an error
*
* The #str is passed as argument to your #error_msg, as follows:
int_f_void_t xbt_getpid = xbt_fake_pid;
-/*
- * Time elapsed since the beginning of the simulation.
- */
-double xbt_time()
-{
- /* FIXME: check if we should use the request mechanism or not */
- return SIMIX_get_clock();
-}
-
-/*
- * Freeze the process for the specified amount of time
- */
-void xbt_sleep(double sec)
-{
- simcall_process_sleep(sec);
-}
-
const char *xbt_procname(void)
{
return SIMIX_process_self_get_name();