root/ompi/mpi/c/info_get.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. MPI_Info_get

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
   2 /*
   3  * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
   4  *                         University Research and Technology
   5  *                         Corporation.  All rights reserved.
   6  * Copyright (c) 2004-2005 The University of Tennessee and The University
   7  *                         of Tennessee Research Foundation.  All rights
   8  *                         reserved.
   9  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
  10  *                         University of Stuttgart.  All rights reserved.
  11  * Copyright (c) 2004-2005 The Regents of the University of California.
  12  *                         All rights reserved.
  13  * Copyright (c) 2013      Los Alamos National Security, LLC.  All rights
  14  *                         reserved.
  15  * Copyright (c) 2015      Research Organization for Information Science
  16  *                         and Technology (RIST). All rights reserved.
  17  * Copyright (c) 2016-2017 IBM Corporation. All rights reserved.
  18  * $COPYRIGHT$
  19  *
  20  * Additional copyrights may follow
  21  *
  22  * $HEADER$
  23  */
  24 
  25 #include "ompi_config.h"
  26 
  27 #include "ompi/mpi/c/bindings.h"
  28 #include "ompi/runtime/params.h"
  29 #include "ompi/communicator/communicator.h"
  30 #include "ompi/errhandler/errhandler.h"
  31 #include "ompi/info/info.h"
  32 #include <stdlib.h>
  33 #include <string.h>
  34 
  35 #if OMPI_BUILD_MPI_PROFILING
  36 #if OPAL_HAVE_WEAK_SYMBOLS
  37 #pragma weak MPI_Info_get = PMPI_Info_get
  38 #endif
  39 #define MPI_Info_get PMPI_Info_get
  40 #endif
  41 
  42 static const char FUNC_NAME[] = "MPI_Info_get";
  43 
  44 /**
  45  *   MPI_Info_get - Get a (key, value) pair from an 'MPI_Info' object
  46  *
  47  *   @param info info object (handle)
  48  *   @param key null-terminated character string of the index key
  49  *   @param valuelen maximum length of 'value' (integer)
  50  *   @param value null-terminated character string of the value
  51  *   @param flag true (1) if 'key' defined on 'info', false (0) if not
  52  *               (logical)
  53  *
  54  *   @retval MPI_SUCCESS
  55  *   @retval MPI_ERR_ARG
  56  *   @retval MPI_ERR_INFO
  57  *   @retval MPI_ERR_INFO_KEY
  58  *   @retval MPI_ERR_INFO_VALUE
  59  *
  60  *   In C and C++, 'valuelen' should be one less than the allocated space
  61  *   to allow for for the null terminator.
  62  */
  63 int MPI_Info_get(MPI_Info info, const char *key, int valuelen,
  64                  char *value, int *flag)
  65 {
  66     int err;
  67     int key_length;
  68 
  69     /*
  70      * Simple function. All we need to do is search for the value
  71      * having the "key" associated with it and then populate the
  72      * necessary structures.
  73      */
  74     if (MPI_PARAM_CHECK) {
  75         OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
  76         if (NULL == info || MPI_INFO_NULL == info ||
  77             ompi_info_is_freed(info)) {
  78             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_INFO,
  79                                           FUNC_NAME);
  80         }
  81         if (0 > valuelen){
  82             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG,
  83                                           FUNC_NAME);
  84         }
  85 
  86         key_length = (key) ? (int)strlen (key) : 0;
  87         if ((NULL == key) || (0 == key_length) ||
  88             (MPI_MAX_INFO_KEY <= key_length)) {
  89             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_INFO_KEY,
  90                                           FUNC_NAME);
  91         }
  92         if (NULL == value) {
  93             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_INFO_VALUE,
  94                                           FUNC_NAME);
  95         }
  96         if (NULL == flag) {
  97             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG,
  98                                           FUNC_NAME);
  99         }
 100     }
 101 
 102     OPAL_CR_ENTER_LIBRARY();
 103 
 104     err = ompi_info_get(info, key, valuelen, value, flag);
 105     OMPI_ERRHANDLER_RETURN(err, MPI_COMM_WORLD, err, FUNC_NAME);
 106 }

/* [<][>][^][v][top][bottom][index][help] */