⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gpr_data_type_print_fns.c

📁 MPI stands for the Message Passing Interface. Written by the MPI Forum (a large committee comprising
💻 C
📖 第 1 页 / 共 2 页
字号:
/* * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana *                         University Research and Technology *                         Corporation.  All rights reserved. * Copyright (c) 2004-2006 The University of Tennessee and The University *                         of Tennessee Research Foundation.  All rights *                         reserved. * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, *                         University of Stuttgart.  All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. *                         All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow * * $HEADER$ */#include "orte_config.h"#include <sys/types.h>#if HAVE_NETINET_IN_H#include <netinet/in.h>#endif#include "orte/dss/dss.h"#include "orte/mca/errmgr/errmgr.h"#include "orte/mca/gpr/base/base.h"static void orte_gpr_base_quick_print(char **output, char *type_name, char *prefix, void *src, orte_std_cntr_t src_size);/* * STANDARD PRINT FUNCTION - WORKS FOR EVERYTHING NON-STRUCTURED */int orte_gpr_base_std_print(char **output, char *prefix, void *src, orte_data_type_t type){    /* set default result */    *output = NULL;    switch(type) {        case ORTE_GPR_CMD:            orte_gpr_base_quick_print(output, "ORTE_GPR_CMD", prefix, src, sizeof(orte_gpr_cmd_flag_t));            break;        case ORTE_GPR_SUBSCRIPTION_ID:            orte_gpr_base_quick_print(output, "ORTE_GPR_SUBSCRIPTION_ID", prefix, src, sizeof(orte_gpr_subscription_id_t));            break;        case ORTE_GPR_TRIGGER_ID:            orte_gpr_base_quick_print(output, "ORTE_GPR_TRIGGER_ID", prefix, src, sizeof(orte_gpr_trigger_id_t));            break;        case ORTE_GPR_NOTIFY_ACTION:            orte_gpr_base_quick_print(output, "ORTE_GPR_NOTIFY_ACTION", prefix, src, sizeof(orte_gpr_notify_action_t));            break;        case ORTE_GPR_TRIGGER_ACTION:            orte_gpr_base_quick_print(output, "ORTE_GPR_TRIGGER_ACTION", prefix, src, sizeof(orte_gpr_trigger_action_t));            break;        case ORTE_GPR_NOTIFY_MSG_TYPE:            orte_gpr_base_quick_print(output, "ORTE_GPR_NOTIFY_MSG_TYPE", prefix, src, sizeof(orte_gpr_notify_msg_type_t));            break;        case ORTE_GPR_ADDR_MODE:            orte_gpr_base_quick_print(output, "ORTE_GPR_ADDR_MODE", prefix, src, sizeof(orte_gpr_addr_mode_t));            break;        default:            ORTE_ERROR_LOG(ORTE_ERR_UNKNOWN_DATA_TYPE);            return ORTE_ERR_UNKNOWN_DATA_TYPE;    }    return ORTE_SUCCESS;}/* PRINT FUNCTIONS FOR COMPLEX TYPES *//* KEYVAL */int orte_gpr_base_print_keyval(char **output, char *prefix, orte_gpr_keyval_t *src, orte_data_type_t type){    char *tmp, *tmp2, *pfx, *prefx;    int rc;    /* set default result */    *output = NULL;    /* deal with NULL prefix */    if (NULL == prefix) asprintf(&prefx, " ");    else prefx = prefix;    if (NULL == src->key) {        asprintf(&tmp, "%sData for keyval: NULL key\n", prefx);    } else {        asprintf(&tmp, "%sData for keyval: Key: %s\n", prefx, src->key);    }    asprintf(&pfx, "%s\t", prefx);    if (ORTE_SUCCESS != (rc = orte_dss.print(&tmp2, pfx, src->value, ORTE_DATA_VALUE))) {        ORTE_ERROR_LOG(rc);        free(pfx);        free(tmp);        return rc;    }    asprintf(output, "%s%s\n", tmp, tmp2);    free(pfx);    free(tmp);    free(tmp2);    return ORTE_SUCCESS;}/* VALUE */int orte_gpr_base_print_gpr_value(char **output, char *prefix, orte_gpr_value_t *value, orte_data_type_t type){    orte_gpr_addr_mode_t addr;    char *tmp, *tmp2, *tmp3, *pfx, *prefx;    orte_std_cntr_t j;    int rc;    /* set default result */    *output = NULL;    /* deal with NULL prefix */    if (NULL == prefix) asprintf(&prefx, " ");    else prefx = prefix;    if (NULL == value->segment) {        asprintf(&tmp, "%sValue from NULL segment name - %lu keyvals",            prefx, (unsigned long) value->cnt);    } else {        asprintf(&tmp, "%sValue from segment %s with %lu keyvals",                prefx, value->segment, (unsigned long) value->cnt);    }    if (NULL == value->tokens) {            asprintf(&tmp2, "%s\n%s\tNULL tokens (wildcard)", tmp, prefx);        free(tmp);    } else {        asprintf(&tmp2, "%s\n%s\t%lu Tokens returned", tmp, prefx, (unsigned long) value->num_tokens);        free(tmp);        for (j=0; j < value->num_tokens; j++) {            if (NULL == value->tokens[j]) {                asprintf(&tmp, "%s\n%s\t\tToken %lu: NULL token pointer", tmp2, prefx, (unsigned long) j);            } else {                asprintf(&tmp, "%s\n%s\t\tToken %lu: %s", tmp2, prefx, (unsigned long) j, value->tokens[j]);            }            free(tmp2);            tmp2 = tmp;        }    }    addr = value->addr_mode;    asprintf(&tmp, "%s\n%s\tToken addressing mode:", tmp2, prefx);    free(tmp2);    if (0x0000 == (0x00ff & addr)) {        asprintf(&tmp2, "%s\n%s\t\tNONE\n", tmp, prefx);        free(tmp);        tmp = tmp2;    } else {        if (ORTE_GPR_TOKENS_AND & addr) {            asprintf(&tmp2, "%s\n%s\t\tORTE_GPR_TOKENS_AND", tmp, prefx);            free(tmp);            tmp = tmp2;        }        if (ORTE_GPR_TOKENS_OR & addr) {            asprintf(&tmp2, "%s\n%s\t\tORTE_GPR_TOKENS_OR", tmp, prefx);            free(tmp);            tmp = tmp2;        }        if (ORTE_GPR_TOKENS_XAND & addr) {            asprintf(&tmp2, "%s\n%s\t\tORTE_GPR_TOKENS_XAND", tmp, prefx);            free(tmp);            tmp = tmp2;        }        if (ORTE_GPR_TOKENS_XOR & addr) {            asprintf(&tmp2, "%s\n%s\t\tORTE_GPR_TOKENS_XOR", tmp, prefx);            free(tmp);            tmp = tmp2;        }        if (ORTE_GPR_TOKENS_NOT & addr) {            asprintf(&tmp2, "%s\n%s\t\tORTE_GPR_TOKENS_NOT", tmp, prefx);            free(tmp);            tmp = tmp2;        }    }    asprintf(&tmp2, "%s\n%s\tKey addressing mode:", tmp, prefx);    free(tmp);    tmp = tmp2;    if (0x0000 == (0xff00 & addr)) {        asprintf(&tmp2, "%s\n%s\t\tNONE\n", tmp, prefx);        free(tmp);        tmp = tmp2;    } else {        if (ORTE_GPR_KEYS_AND & addr) {            asprintf(&tmp2, "%s\n%s\t\tORTE_GPR_KEYS_AND", tmp, prefx);            free(tmp);            tmp = tmp2;        }        if (ORTE_GPR_KEYS_OR & addr) {            asprintf(&tmp2, "%s\n%s\t\tORTE_GPR_KEYS_OR", tmp, prefx);            free(tmp);            tmp = tmp2;        }        if (ORTE_GPR_KEYS_XAND & addr) {            asprintf(&tmp2, "%s\n%s\t\tORTE_GPR_KEYS_XAND", tmp, prefx);            free(tmp);            tmp = tmp2;        }        if (ORTE_GPR_KEYS_XOR & addr) {            asprintf(&tmp2, "%s\n%s\t\tORTE_GPR_KEYS_XOR", tmp, prefx);            free(tmp);            tmp = tmp2;        }        if (ORTE_GPR_KEYS_NOT & addr) {            asprintf(&tmp2, "%s\n%s\t\tORTE_GPR_KEYS_NOT", tmp, prefx);            free(tmp);            tmp = tmp2;        }    }    /* indent another level for keyvals */    asprintf(&pfx, "%s\t", prefx);    for (j=0; j < value->cnt; j++) {        if (ORTE_SUCCESS != (rc = orte_gpr_base_print_keyval(&tmp2, pfx,                                (orte_gpr_keyval_t*)(value->keyvals[j]), ORTE_GPR_KEYVAL))) {            ORTE_ERROR_LOG(rc);            free(tmp);            free(pfx);            return rc;        }        asprintf(&tmp3, "%s\n%s", tmp, tmp2);        free(tmp);        free(tmp2);        tmp = tmp3;    }    /* put results in final location */    *output = tmp;    return ORTE_SUCCESS;}/* SUBSCRIPTION */int orte_gpr_base_print_subscription(char **output, char *prefix, orte_gpr_subscription_t *sub, orte_data_type_t type){    int rc;    char *tmp, *tmp2, *tmp3, *pfx, *prefx;    orte_std_cntr_t j;    /* set default result */    *output = NULL;    /* deal with NULL prefix */    if (NULL == prefix) asprintf(&prefx, " ");    else prefx = prefix;    if (NULL == sub->name) {        asprintf(&tmp, "%sSubscription - NO NAME\tid: %lu", prefx, (unsigned long) sub->id);    } else {        asprintf(&tmp, "%sSubscription - Name: %s\tid: %lu", prefx, sub->name, (unsigned long) sub->id);    }    asprintf(&tmp2, "%s\n%s\tAction flags:", tmp, prefx);    free(tmp);    tmp = tmp2;    if (ORTE_GPR_NOTIFY_NONE == sub->action) {        asprintf(&tmp2, "%s\n%s\t\tNONE\n", tmp, prefx);        free(tmp);        tmp = tmp2;    } else {        if (ORTE_GPR_NOTIFY_VALUE_CHG_TO & sub->action) {            asprintf(&tmp2, "%s\n%s\t\tORTE_GPR_NOTIFY_VALUE_CHG_TO", tmp, prefx);            free(tmp);            tmp = tmp2;        }        if (ORTE_GPR_NOTIFY_VALUE_CHG_FRM & sub->action) {            asprintf(&tmp2, "%s\n%s\t\tORTE_GPR_NOTIFY_VALUE_CHG_FRM", tmp, prefx);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -