drmaa2_dict_get
- drmaa2_dict_get, Returns the value of given key from a dictionary.
#include "drmaa2.h"
const char drmaa2_dict_get(const drmaa2_dict dict, const char key)
Searches the value of a given key in a given dictionary.
Returns the value of the key or NULL in case the key was not found or an error occured (like wrong arguments). The returned value is not a copy, it is a pointer to the value stored in the dictionary.
static void drmaa2_dict_string_free(char** key, char** value)
{
drmaa2_string_free(key);
drmaa2_string_free(value);
}
/* ... */
/* Create dictionary for job environment variables. */
drmaa2_dict dict = drmaa2_dict_create((drmaa2_dict_entryfree)drmaa2_dict_string_free);
if (dict == NULL) {
printf("Error: Could not create a new dictionary.\n");
return;
}
if (drmaa2_dict_set(dict, strdup("key"), strdup("value")) != DRMAA2_SUCCESS) {
printf("Error: Could not set a new value in the dictionary.\n");
return;
}
if (drmaa2_dict_get(dict, "key") != NULL) {
printf("The key \"key\" has the value \"%s\".\n", drmaa2_dict_get(dict, "key"));
}
/* Frees strings implicitly. */
drmaa2_dict_free(&dict);
drmaa2_dict_create(3), drmaa2_dict_free(3), drmaa2_dict_list(3), drmaa2_dict_has(3), drmaa2_dict_get(3), drmaa2_dict_del(3), drmaa2_dict_set(3)
Copyright Univa Corporation 2013