static void _ibprof_conf_mode(char *env) { char *lower_env, *ptr; int i; i = sys_strlen(env); lower_env = sys_strdup(env); while (i--) lower_env[i] = tolower(env[i]); ptr = sys_strstr(lower_env, "use_ibv"); if (NULL != ptr) { sscanf(ptr, "use_ibv=%d", (int *) enviroment[IBPROF_MODE_IBV]); } ptr = sys_strstr(lower_env, "use_hcol"); if (NULL != ptr) { sscanf(ptr, "use_hcol=%d", (int *) enviroment[IBPROF_MODE_HCOL]); } ptr = sys_strstr(lower_env, "use_mxm"); if (NULL != ptr) { sscanf(ptr, "use_mxm=%d", (int *) enviroment[IBPROF_MODE_MXM]); } ptr = sys_strstr(lower_env, "use_pmix"); if (NULL != ptr) { sscanf(ptr, "use_pmix=%d", (int *) enviroment[IBPROF_MODE_PMIX]); } ptr = sys_strstr(lower_env, "use_shmem"); if (NULL != ptr) { sscanf(ptr, "use_shmem=%d", (int *) enviroment[IBPROF_MODE_SHMEM]); } sys_free(lower_env); }
static int _ibprof_io_plain_prefix(void *stream, const char* format, ...) { char *buffer, *ptr; int size = 0; va_list args; va_start(args, format); size = sys_vsnprintf(NULL, 0, format, args); va_end(args); if (0 >= size) return -1; buffer = (char*) sys_malloc(size); if (NULL == buffer) return -1; va_start(args, format); sys_vsnprintf(buffer, size, format, args); va_end(args); /* We need to plainify output to make sure * that each line prefixed with libibprof:host:pid */ ptr = sys_strstr(buffer, "\n"); while (ptr != NULL) { *ptr = ' '; ptr = sys_strstr(buffer, "\n"); } /* Skip empty lines */ if (strcmp(buffer, "")) sys_fprintf(stream, "[libibprof:%s:%d] %s\n", hostname, pid, buffer); sys_free(buffer); return 0; }