2004-01-10 11:20:36 +03:00
|
|
|
/*
|
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef LAM_INFO_H
|
|
|
|
#define LAM_INFO_H
|
|
|
|
|
2004-02-10 03:09:36 +03:00
|
|
|
#include <string.h>
|
|
|
|
|
2004-01-10 11:20:36 +03:00
|
|
|
#include "mpi.h"
|
2004-02-11 18:30:51 +03:00
|
|
|
#include "lam/util/strncpy.h"
|
2004-02-11 01:15:55 +03:00
|
|
|
#include "lam/lfc/lam_list.h"
|
2004-02-04 01:03:22 +03:00
|
|
|
#include "lam/lam.h"
|
|
|
|
|
2004-01-10 11:20:36 +03:00
|
|
|
|
2004-02-02 01:27:22 +03:00
|
|
|
/**
|
|
|
|
* lam_info_t structure. MPI_Info is a pointer to this structure
|
|
|
|
*/
|
2004-01-10 20:10:29 +03:00
|
|
|
struct lam_info_t {
|
2004-02-04 01:03:22 +03:00
|
|
|
lam_list_t super; /**< generic list pointer which is
|
|
|
|
* the container for (key,value) pairs */
|
|
|
|
int i_fhandle; /**< fortran handle for info. This is needed
|
|
|
|
* for translation from fortran to C and vice versa */
|
2004-01-10 20:10:29 +03:00
|
|
|
};
|
|
|
|
typedef struct lam_info_t lam_info_t;
|
2004-01-10 11:20:36 +03:00
|
|
|
|
2004-02-02 01:27:22 +03:00
|
|
|
/**
|
|
|
|
* lam_info_entry_t object. Each item in lam_info_list is of this
|
|
|
|
* type. It contains (key,value) pairs
|
|
|
|
*/
|
|
|
|
struct lam_info_entry_t {
|
|
|
|
lam_list_item_t super; /**< required for lam_list_t type */
|
2004-02-04 01:03:22 +03:00
|
|
|
char *ie_value; /**< value part of the (key, value) pair.
|
2004-02-02 01:27:22 +03:00
|
|
|
* Maximum length is MPI_MAX_INFO_VAL */
|
2004-02-04 01:03:22 +03:00
|
|
|
char ie_key[MPI_MAX_INFO_KEY + 1]; /**< "key" part of the (key, value)
|
2004-02-02 01:27:22 +03:00
|
|
|
* pair */
|
|
|
|
};
|
|
|
|
typedef struct lam_info_entry_t lam_info_entry_t;
|
|
|
|
|
2004-02-04 01:03:22 +03:00
|
|
|
/**
|
2004-02-10 17:04:27 +03:00
|
|
|
* Some declarations needed to use OBJ_NEW and OBJ_DESTRUCT macros
|
2004-02-04 01:03:22 +03:00
|
|
|
*/
|
2004-02-10 17:04:27 +03:00
|
|
|
extern lam_class_info_t lam_info_t_class_info;
|
|
|
|
extern lam_class_info_t lam_info_entry_t_class_info;
|
2004-02-04 01:03:22 +03:00
|
|
|
|
|
|
|
#if defined(c_plusplus) || defined(__cplusplus)
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
2004-02-10 17:04:27 +03:00
|
|
|
void lam_info_construct(lam_info_t *info);
|
|
|
|
void lam_info_destruct(lam_info_t *info);
|
2004-02-04 01:03:22 +03:00
|
|
|
|
2004-02-10 17:04:27 +03:00
|
|
|
void lam_info_entry_construct(lam_info_entry_t *entry);
|
|
|
|
void lam_info_entry_destruct(lam_info_entry_t *entry);
|
2004-02-11 18:30:51 +03:00
|
|
|
int lam_info_dup (lam_info_t *info, lam_info_t **newinfo);
|
|
|
|
int lam_info_set (lam_info_t *info, char *key, char *value);
|
|
|
|
int lam_info_free (lam_info_t **info);
|
|
|
|
int lam_info_get (lam_info_t *info, char *key, int valuelen,
|
|
|
|
char *value, int *flag);
|
|
|
|
int lam_info_delete (lam_info_t *info, char *key);
|
|
|
|
int lam_info_get_valuelen (lam_info_t *info, char *key, int *valuelen,
|
|
|
|
int *flag);
|
2004-02-04 01:03:22 +03:00
|
|
|
#if defined(c_plusplus) || defined(__cplusplus)
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Iterate through the list and search for "key"
|
|
|
|
*
|
2004-02-11 18:30:51 +03:00
|
|
|
* @param info pointer to lam_info_t handle
|
2004-02-04 01:03:22 +03:00
|
|
|
* @param key Key value to search for
|
|
|
|
*
|
|
|
|
* @retval (lam_info_entry_t *) to the object having the same key
|
|
|
|
* NULL if no matching item is found
|
|
|
|
*
|
|
|
|
* We need a function to go through the entries and find whether
|
|
|
|
* a given key is already present in the list. If so, this function
|
|
|
|
* returns the item which matches this key. It was required
|
|
|
|
* often enough to make it into a function. No error checking on
|
|
|
|
* info is performed.
|
|
|
|
* Assumptions:
|
|
|
|
* "info" is a valid key
|
|
|
|
*/
|
2004-02-11 18:30:51 +03:00
|
|
|
static inline lam_info_entry_t *lam_info_find_key (lam_info_t *info,
|
2004-02-04 01:03:22 +03:00
|
|
|
char *key) {
|
|
|
|
lam_info_entry_t *iterator;
|
|
|
|
int nkeys;
|
|
|
|
|
|
|
|
/* Iterate over all the entries. If the key is found, then
|
|
|
|
* return immediately. Else, the loop will fall of the edge
|
|
|
|
* and NULL is returned
|
|
|
|
*/
|
|
|
|
nkeys = lam_list_get_size(&(info->super));
|
|
|
|
for (iterator = (lam_info_entry_t *)lam_list_get_first(&(info->super));
|
|
|
|
nkeys > 0;
|
|
|
|
nkeys--) {
|
|
|
|
if (0 == strcmp(key, iterator->ie_key)) {
|
|
|
|
return iterator;
|
|
|
|
}
|
|
|
|
iterator = (lam_info_entry_t *)iterator->super.lam_list_next;
|
|
|
|
}
|
|
|
|
return (lam_info_entry_t *)0;
|
|
|
|
}
|
|
|
|
|
2004-02-11 18:30:51 +03:00
|
|
|
/**
|
|
|
|
* Get the number of keys defined on on an MPI_Info object
|
|
|
|
* @param info Pointer to lam_info_t object.
|
|
|
|
* @param nkeys Pointer to nkeys, which needs to be filled up.
|
|
|
|
*
|
|
|
|
* @retval The number of keys defined on info
|
|
|
|
*/
|
|
|
|
static inline int
|
|
|
|
lam_info_get_nkeys(lam_info_t *info, int *nkeys) {
|
|
|
|
*nkeys = (int) lam_list_get_size(&(info->super));
|
|
|
|
return MPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* lam_info_get_nthkey - Get a key indexed by integer from an 'MPI_Info' o
|
|
|
|
*
|
|
|
|
* @param info Pointer to lam_info_t object
|
|
|
|
* @param n index of key to retrieve (integer)
|
|
|
|
* @param key character string of at least 'MPI_MAX_INFO_KEY' characters
|
|
|
|
*
|
|
|
|
* @retval MPI_SUCCESS
|
|
|
|
* @retval MPI_ERR_ARG
|
|
|
|
*/
|
|
|
|
static inline int
|
|
|
|
lam_info_get_nthkey (lam_info_t *info, int n, char *key) {
|
|
|
|
lam_info_entry_t *iterator;
|
|
|
|
/*
|
|
|
|
* Iterate over and over till we get to the nth key
|
|
|
|
*/
|
|
|
|
iterator = (lam_info_entry_t *)lam_list_get_first(&(info->super));
|
|
|
|
for ( ; n > 0; n--) {
|
|
|
|
iterator = (lam_info_entry_t *)
|
|
|
|
iterator->super.lam_list_next;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* iterator is of the type lam_list_item_t. We have to
|
|
|
|
* cast it to lam_info_entry_t before we can use it to
|
|
|
|
* access the value
|
|
|
|
*/
|
|
|
|
strcpy(key, iterator->ie_key);
|
|
|
|
return MPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2004-01-10 11:20:36 +03:00
|
|
|
#endif /* LAM_INFO_H */
|