Commit 39452379 authored by Jakob Luettgau's avatar Jakob Luettgau Committed by Shane Snyder

Darshan logutil helpers for Python bindings

parent 55921949
......@@ -1837,6 +1837,98 @@ int darshan_log_get_namerecs_3_00(void *name_rec_buf, int buf_len,
return(buf_processed);
}
/*
* Support functions for use with other languages
*/
/*
* darshan_log_get_modules
*
* Gets list of modules present in logs and returns the info
*/
void darshan_log_get_modules (darshan_fd fd,
struct darshan_mod_info **mods,
int* count)
{
int i;
int j;
*mods = malloc(sizeof(**mods) * DARSHAN_MAX_MODS);
assert(*mods);
for (i = 0, j = 0; i < DARSHAN_MAX_MODS; i++)
{
if (fd->mod_map[i].len)
{
(*mods)[j].name = darshan_module_names[i];
(*mods)[j].len = fd->mod_map[i].len;
(*mods)[j].ver = fd->mod_ver[i];
(*mods)[j].idx = i;
j += 1;
}
}
*count = j;
}
/*
* darshan_log_get_name_records
*
* Gets list of hashed name_records present in logs and returns the info
*/
void darshan_log_get_name_records(darshan_fd fd,
struct darshan_name_record_info **name_records,
int* count)
{
int ret;
struct darshan_name_record_ref *name_hash = NULL;
struct darshan_name_record_ref *ref = NULL;
struct darshan_name_record_ref *tmp = NULL;
struct darshan_name_record_ref *curr = NULL;
/* read hash of darshan records */
ret = darshan_log_get_namehash(fd, &name_hash);
if(ret < 0)
{
darshan_log_close(fd);
return(-1);
}
int num = HASH_CNT(hlink, name_hash);
*name_records = malloc(sizeof(**name_records) * num);
assert(*name_records);
int i = 0;
HASH_ITER(hlink, name_hash, curr, tmp)
{
(*name_records)[i].id = curr->name_record->id;
(*name_records)[i].name = curr->name_record->name;
i++;
}
*count = num;
return;
}
/*
* darshan_log_get_record
*
* Wrapper to hide the mod_logutils callback functions.
*/
int darshan_log_get_record (darshan_fd fd,
int mod_idx,
void **buf)
{
int r;
r = mod_logutils[mod_idx]->log_get_record(fd, buf);
return r;
}
/*
* Local variables:
* c-indent-level: 4
......
......@@ -68,6 +68,22 @@ struct darshan_mnt_info
char mnt_path[DARSHAN_EXE_LEN];
};
struct darshan_mod_info
{
char *name;
int len;
int ver;
int idx;
};
struct darshan_name_record_info
{
darshan_record_id id;
char *name;
};
/* functions to be implemented by each module for integration with
* darshan log file utilities (e.g., parser & convert tools)
*/
......@@ -158,6 +174,11 @@ int darshan_log_put_mod(darshan_fd fd, darshan_module_id mod_id,
void *mod_buf, int mod_buf_sz, int ver);
void darshan_log_close(darshan_fd file);
void darshan_log_print_version_warnings(const char *version_string);
void darshan_log_get_modules (darshan_fd fd, struct darshan_mod_info **mods, int* count);
void darshan_log_get_name_records(darshan_fd fd,
struct darshan_name_record_info **mods,
int* count);
int darshan_log_get_record (darshan_fd fd, int mod_idx, void **buf);
/* convenience macros for printing Darshan counters */
#define DARSHAN_PRINT_HEADER() \
......
......@@ -109,7 +109,7 @@ static int darshan_log_get_stdio_record(darshan_fd fd, void** stdio_buf_p)
*((int64_t *)src_p) = -1;
}
memcpy(file, scratch, sizeof(struct darshan_posix_file));
memcpy(file, scratch, sizeof(struct darshan_stdio_file));
}
exit:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment