• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ ds_put_format函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中ds_put_format函数的典型用法代码示例。如果您正苦于以下问题:C++ ds_put_format函数的具体用法?C++ ds_put_format怎么用?C++ ds_put_format使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ds_put_format函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: process_status_msg

/* Given 'status', which is a process status in the form reported by waitpid(2)
 * and returned by process_status(), returns a string describing how the
 * process terminated.  The caller is responsible for freeing the string when
 * it is no longer needed. */
char *
process_status_msg(int status)
{
    struct ds ds = DS_EMPTY_INITIALIZER;
#ifndef _WIN32
    if (WIFEXITED(status)) {
        ds_put_format(&ds, "exit status %d", WEXITSTATUS(status));
    } else if (WIFSIGNALED(status)) {
        char namebuf[SIGNAL_NAME_BUFSIZE];

        ds_put_format(&ds, "killed (%s)",
                      signal_name(WTERMSIG(status), namebuf, sizeof namebuf));
    } else if (WIFSTOPPED(status)) {
        char namebuf[SIGNAL_NAME_BUFSIZE];

        ds_put_format(&ds, "stopped (%s)",
                      signal_name(WSTOPSIG(status), namebuf, sizeof namebuf));
    } else {
        ds_put_format(&ds, "terminated abnormally (%x)", status);
    }
    if (WCOREDUMP(status)) {
        ds_put_cstr(&ds, ", core dumped");
    }
#else
    ds_put_cstr(&ds, "function not supported.");
#endif
    return ds_cstr(&ds);
}
开发者ID:wenxueliu,项目名称:code_clips,代码行数:32,代码来源:daemon-unix.c


示例2: format_flow_tunnel

static void
format_flow_tunnel(struct ds *s, const struct match *match)
{
    const struct flow_wildcards *wc = &match->wc;
    const struct flow_tnl *tnl = &match->flow.tunnel;

    switch (wc->masks.tunnel.tun_id) {
    case 0:
        break;
    case CONSTANT_HTONLL(UINT64_MAX):
        ds_put_format(s, "tun_id=%#"PRIx64",", ntohll(tnl->tun_id));
        break;
    default:
        ds_put_format(s, "tun_id=%#"PRIx64"/%#"PRIx64",",
                      ntohll(tnl->tun_id),
                      ntohll(wc->masks.tunnel.tun_id));
        break;
    }
    format_ip_netmask(s, "tun_src", tnl->ip_src, wc->masks.tunnel.ip_src);
    format_ip_netmask(s, "tun_dst", tnl->ip_dst, wc->masks.tunnel.ip_dst);

    if (wc->masks.tunnel.ip_tos) {
        ds_put_format(s, "tun_tos=%"PRIx8",", tnl->ip_tos);
    }
    if (wc->masks.tunnel.ip_ttl) {
        ds_put_format(s, "tun_ttl=%"PRIu8",", tnl->ip_ttl);
    }
    if (wc->masks.tunnel.flags) {
        format_flags(s, flow_tun_flag_to_string, tnl->flags, '|');
        ds_put_char(s, ',');
    }
}
开发者ID:AlickHill,项目名称:Lantern,代码行数:32,代码来源:match.c


示例3: ovsdb_type_to_english

char *
ovsdb_type_to_english(const struct ovsdb_type *type)
{
    const char *key = ovsdb_atomic_type_to_string(type->key.type);
    const char *value = ovsdb_atomic_type_to_string(type->value.type);
    if (ovsdb_type_is_scalar(type)) {
        return xstrdup(key);
    } else {
        struct ds s = DS_EMPTY_INITIALIZER;
        ds_put_cstr(&s, ovsdb_type_is_set(type) ? "set" : "map");
        if (type->n_max == UINT_MAX) {
            if (type->n_min) {
                ds_put_format(&s, " of %u or more", type->n_min);
            } else {
                ds_put_cstr(&s, " of");
            }
        } else if (type->n_min) {
            ds_put_format(&s, " of %u to %u", type->n_min, type->n_max);
        } else {
            ds_put_format(&s, " of up to %u", type->n_max);
        }
        if (ovsdb_type_is_set(type)) {
            ds_put_format(&s, " %ss", key);
        } else {
            ds_put_format(&s, " (%s, %s) pairs", key, value);
        }
        return ds_cstr(&s);
    }
}
开发者ID:AnyBucket,项目名称:OpenStack-Install-and-Understand-Guide,代码行数:29,代码来源:ovsdb-types.c


示例4: process_status_msg

/* Given 'status', which is a process status in the form reported by waitpid(2)
 * and returned by process_status(), returns a string describing how the
 * process terminated.  The caller is responsible for freeing the string when
 * it is no longer needed. */
char *
process_status_msg(int status)
{
    struct ds ds = DS_EMPTY_INITIALIZER;
    if (WIFEXITED(status)) {
        ds_put_format(&ds, "exit status %d", WEXITSTATUS(status));
    } else if (WIFSIGNALED(status) || WIFSTOPPED(status)) {
        int signr = WIFSIGNALED(status) ? WTERMSIG(status) : WSTOPSIG(status);
        const char *name = NULL;
#ifdef HAVE_STRSIGNAL
        name = strsignal(signr);
#endif
        ds_put_format(&ds, "%s by signal %d",
                      WIFSIGNALED(status) ? "killed" : "stopped", signr);
        if (name) {
            ds_put_format(&ds, " (%s)", name);
        }
    } else {
        ds_put_format(&ds, "terminated abnormally (%x)", status);
    }
    if (WCOREDUMP(status)) {
        ds_put_cstr(&ds, ", core dumped");
    }
    return ds_cstr(&ds);
}
开发者ID:InCNTRE,项目名称:OFTT,代码行数:29,代码来源:process.c


示例5: format_flags

void
format_flags(struct ds *ds, const char *(*bit_to_string)(uint32_t),
             uint32_t flags, char del)
{
    uint32_t bad = 0;

    if (!flags) {
        return;
    }
    while (flags) {
        uint32_t bit = rightmost_1bit(flags);
        const char *s;

        s = bit_to_string(bit);
        if (s) {
            ds_put_format(ds, "%s%c", s, del);
        } else {
            bad |= bit;
        }

        flags &= ~bit;
    }

    if (bad) {
        ds_put_format(ds, "0x%"PRIx32"%c", bad, del);
    }
    ds_chomp(ds, del);
}
开发者ID:Grace-Liu,项目名称:dpdk-ovs,代码行数:28,代码来源:flow.c


示例6: lex_token_format_value

static void
lex_token_format_value(const union mf_subvalue *value,
                       enum lex_format format, struct ds *s)
{
    switch (format) {
    case LEX_F_DECIMAL:
        ds_put_format(s, "%"PRIu64, ntohll(value->integer));
        break;

    case LEX_F_HEXADECIMAL:
        mf_format_subvalue(value, s);
        break;

    case LEX_F_IPV4:
        ds_put_format(s, IP_FMT, IP_ARGS(value->ipv4));
        break;

    case LEX_F_IPV6:
        ipv6_format_addr(&value->ipv6, s);
        break;

    case LEX_F_ETHERNET:
        ds_put_format(s, ETH_ADDR_FMT, ETH_ADDR_ARGS(value->mac));
        break;

    default:
        OVS_NOT_REACHED();
    }

}
开发者ID:l8huang,项目名称:ovs,代码行数:30,代码来源:lex.c


示例7: multipath_format

/* Appends a description of 'mp' to 's', in the format that ovs-ofctl(8)
 * describes. */
void
multipath_format(const struct ofpact_multipath *mp, struct ds *s)
{
    const char *fields, *algorithm;

    fields = flow_hash_fields_to_str(mp->fields);

    switch (mp->algorithm) {
    case NX_MP_ALG_MODULO_N:
        algorithm = "modulo_n";
        break;
    case NX_MP_ALG_HASH_THRESHOLD:
        algorithm = "hash_threshold";
        break;
    case NX_MP_ALG_HRW:
        algorithm = "hrw";
        break;
    case NX_MP_ALG_ITER_HASH:
        algorithm = "iter_hash";
        break;
    default:
        algorithm = "<unknown>";
    }

    ds_put_format(s, "%smultipath(%s%s,%"PRIu16",%s,%d,%"PRIu32",",
                  colors.paren, colors.end, fields, mp->basis, algorithm,
                  mp->max_link + 1, mp->arg);
    mf_format_subfield(&mp->dst, s);
    ds_put_format(s, "%s)%s", colors.paren, colors.end);
}
开发者ID:iwaseyusuke,项目名称:ovs,代码行数:32,代码来源:multipath.c


示例8: bundle_format

/* Appends a human-readable representation of 'nab' to 's'. */
void
bundle_format(const struct nx_action_bundle *nab, struct ds *s)
{
    const char *action, *fields, *algorithm, *slave_type;
    size_t i;

    fields = flow_hash_fields_to_str(ntohs(nab->fields));

    switch (ntohs(nab->algorithm)) {
    case NX_BD_ALG_HRW:
        algorithm = "hrw";
        break;
    case NX_BD_ALG_ACTIVE_BACKUP:
        algorithm = "active_backup";
        break;
    default:
        algorithm = "<unknown>";
    }

    switch (ntohl(nab->slave_type)) {
    case NXM_OF_IN_PORT:
        slave_type = "ofport";
        break;
    default:
        slave_type = "<unknown>";
    }

    switch (ntohs(nab->subtype)) {
    case NXAST_BUNDLE:
        action = "bundle";
        break;
    case NXAST_BUNDLE_LOAD:
        action = "bundle_load";
        break;
    default:
        NOT_REACHED();
    }

    ds_put_format(s, "%s(%s,%"PRIu16",%s,%s,", action, fields,
                  ntohs(nab->basis), algorithm, slave_type);

    if (nab->subtype == htons(NXAST_BUNDLE_LOAD)) {
        nxm_format_field_bits(s, ntohl(nab->dst),
                              nxm_decode_ofs(nab->ofs_nbits),
                              nxm_decode_n_bits(nab->ofs_nbits));
        ds_put_cstr(s, ",");
    }

    ds_put_cstr(s, "slaves:");
    for (i = 0; i < ntohs(nab->n_slaves); i++) {
        if (i) {
            ds_put_cstr(s, ",");
        }

        ds_put_format(s, "%"PRIu16, bundle_get_slave(nab, i));
    }

    ds_put_cstr(s, ")");
}
开发者ID:Danesca,项目名称:openvswitch,代码行数:60,代码来源:bundle.c


示例9: print_queue_rate

static void
print_queue_rate(struct ds *string, const char *name, unsigned int rate)
{
    if (rate <= 1000) {
        ds_put_format(string, " %s:%u.%u%%", name, rate / 10, rate % 10);
    } else if (rate < UINT16_MAX) {
        ds_put_format(string, " %s:(disabled)", name);
    }
}
开发者ID:blp,项目名称:ovs-reviews,代码行数:9,代码来源:ofp-queue.c


示例10: eth_format_masked

void
eth_format_masked(const uint8_t eth[ETH_ADDR_LEN],
                  const uint8_t mask[ETH_ADDR_LEN], struct ds *s)
{
    ds_put_format(s, ETH_ADDR_FMT, ETH_ADDR_ARGS(eth));
    if (mask && !eth_mask_is_exact(mask)) {
        ds_put_format(s, "/"ETH_ADDR_FMT, ETH_ADDR_ARGS(mask));
    }
}
开发者ID:asteven,项目名称:openvswitch,代码行数:9,代码来源:packets.c


示例11: ip_format_masked

void
ip_format_masked(ovs_be32 ip, ovs_be32 mask, struct ds *s)
{
    ds_put_format(s, IP_FMT, IP_ARGS(&ip));
    if (mask != htonl(UINT32_MAX)) {
        if (ip_is_cidr(mask)) {
            ds_put_format(s, "/%d", ip_count_cidr_bits(mask));
        } else {
            ds_put_format(s, "/"IP_FMT, IP_ARGS(&mask));
        }
    }
}
开发者ID:mashoujiang,项目名称:openvswitch_1.4.6_v4v6,代码行数:12,代码来源:packets.c


示例12: format_be64_masked

static void
format_be64_masked(struct ds *s, const char *name,
                   ovs_be64 value, ovs_be64 mask)
{
    if (mask != htonll(0)) {
        ds_put_format(s, "%s=%#"PRIx64, name, ntohll(value));
        if (mask != OVS_BE64_MAX) {
            ds_put_format(s, "/%#"PRIx64, ntohll(mask));
        }
        ds_put_char(s, ',');
    }
}
开发者ID:daolicloud,项目名称:daolinet-openstack,代码行数:12,代码来源:match.c


示例13: format_uint32_masked

static void
format_uint32_masked(struct ds *s, const char *name,
                   uint32_t value, uint32_t mask)
{
    if (mask) {
        ds_put_format(s, "%s=%#"PRIx32, name, value);
        if (mask != UINT32_MAX) {
            ds_put_format(s, "/%#"PRIx32, mask);
        }
        ds_put_char(s, ',');
    }
}
开发者ID:daolicloud,项目名称:daolinet-openstack,代码行数:12,代码来源:match.c


示例14: flow_format

void
flow_format(struct ds *ds, const struct flow *flow)
{
    ds_put_format(ds, "priority:%"PRIu32
                      ",tunnel:%#"PRIx64
                      ",metadata:%#"PRIx64
                      ",in_port:%04"PRIx16,
                      flow->skb_priority,
                      ntohll(flow->tun_id),
                      ntohll(flow->metadata),
                      flow->in_port);

    ds_put_format(ds, ",tci(");
    if (flow->vlan_tci) {
        ds_put_format(ds, "vlan:%"PRIu16",pcp:%d",
                      vlan_tci_to_vid(flow->vlan_tci),
                      vlan_tci_to_pcp(flow->vlan_tci));
    } else {
        ds_put_char(ds, '0');
    }
    ds_put_format(ds, ") mac("ETH_ADDR_FMT"->"ETH_ADDR_FMT
                      ") type:%04"PRIx16,
                  ETH_ADDR_ARGS(flow->dl_src),
                  ETH_ADDR_ARGS(flow->dl_dst),
                  ntohs(flow->dl_type));

    if (flow->dl_type == htons(ETH_TYPE_IPV6)) {
        ds_put_format(ds, " label:%#"PRIx32" proto:%"PRIu8" tos:%#"PRIx8
                          " ttl:%"PRIu8" ipv6(",
                      ntohl(flow->ipv6_label), flow->nw_proto,
                      flow->nw_tos, flow->nw_ttl);
        print_ipv6_addr(ds, &flow->ipv6_src);
        ds_put_cstr(ds, "->");
        print_ipv6_addr(ds, &flow->ipv6_dst);
        ds_put_char(ds, ')');
    } else {
        ds_put_format(ds, " proto:%"PRIu8" tos:%#"PRIx8" ttl:%"PRIu8
                          " ip("IP_FMT"->"IP_FMT")",
                          flow->nw_proto, flow->nw_tos, flow->nw_ttl,
                          IP_ARGS(&flow->nw_src), IP_ARGS(&flow->nw_dst));
    }
    if (flow->nw_frag) {
        ds_put_format(ds, " frag(%s)",
                      flow->nw_frag == FLOW_NW_FRAG_ANY ? "first"
                      : flow->nw_frag == (FLOW_NW_FRAG_ANY | FLOW_NW_FRAG_LATER)
                      ? "later" : "<error>");
    }
    if (flow->tp_src || flow->tp_dst) {
        ds_put_format(ds, " port(%"PRIu16"->%"PRIu16")",
                ntohs(flow->tp_src), ntohs(flow->tp_dst));
    }
    if (!eth_addr_is_zero(flow->arp_sha) || !eth_addr_is_zero(flow->arp_tha)) {
        ds_put_format(ds, " arp_ha("ETH_ADDR_FMT"->"ETH_ADDR_FMT")",
                ETH_ADDR_ARGS(flow->arp_sha),
                ETH_ADDR_ARGS(flow->arp_tha));
    }
}
开发者ID:leihnwong,项目名称:lazyctrl,代码行数:57,代码来源:flow.c


示例15: format_odp_flow_stats

void
format_odp_flow_stats(struct ds *ds, const struct odp_flow_stats *s)
{
    ds_put_format(ds, "packets:%llu, bytes:%llu, used:",
                  (unsigned long long int) s->n_packets,
                  (unsigned long long int) s->n_bytes);
    if (s->used_sec) {
        long long int used = s->used_sec * 1000 + s->used_nsec / 1000000;
        ds_put_format(ds, "%.3fs", (time_msec() - used) / 1000.0);
    } else {
        ds_put_format(ds, "never");
    }
}
开发者ID:InCNTRE,项目名称:OFTT,代码行数:13,代码来源:odp-util.c


示例16: ofputil_switch_config_format

void
ofputil_switch_config_format(struct ds *s,
                             const struct ofputil_switch_config *config)
{
    ds_put_format(s, " frags=%s",
                  ofputil_frag_handling_to_string(config->frag));

    if (config->invalid_ttl_to_controller > 0) {
        ds_put_format(s, " invalid_ttl_to_controller");
    }

    ds_put_format(s, " miss_send_len=%"PRIu16"\n", config->miss_send_len);
}
开发者ID:JScheurich,项目名称:ovs,代码行数:13,代码来源:ofp-switch.c


示例17: classifierd_debug_dump

void
classifierd_debug_dump(struct ds *ds, int argc, const char *argv[])

{
    bool list_all_ports = true;
    const char *port_name;
    const struct ovsrec_port *port_row = NULL;
    unsigned int iface_idx;
    struct ovsrec_interface *interface;


    if (argc > 1) {
        list_all_ports = false;
        port_name = argv[1];
    }

    OVSREC_PORT_FOR_EACH (port_row, idl) {
        if (list_all_ports
            || (!strcmp(port_name, port_row->name))) {

            if(port_row->n_interfaces == 0) {
                VLOG_DBG("No interfaces assigned yet..\n");
                continue;
            }

            if(port_row->n_interfaces == 1) {
                VLOG_DBG("single interface assigned to port..\n");
                interface = port_row->interfaces[0];
                ds_put_format(ds, "Port: name=%s\n", port_row->name);
                classifierd_debug_dump_port_acl_info(ds,port_row);
                classifierd_debug_dump_interface_info(ds, interface);
                ds_put_format(ds,"\n");
            } else {   /* LAG */
                VLOG_DBG("LAG interfaces ..\n");
                ds_put_format(ds, "LAG name=%s\n", port_row->name);
                classifierd_debug_dump_port_acl_info(ds,port_row);
                for(iface_idx = 0;
                        iface_idx < port_row->n_interfaces;iface_idx++) {
                    interface = port_row->interfaces[iface_idx];
                    classifierd_debug_dump_interface_info(ds, interface);
                } /* end for loop */
            } /* LAG */

            /* line between port row entries */
            ds_put_cstr(ds,"\n");
        } /* if list_all_ports or matching name */
    } /* for each ROW */

} /* classifierd_debug_dump */
开发者ID:open-switch,项目名称:ops-classifierd,代码行数:49,代码来源:classifierd_ovsdb_util.c


示例18: format_be32_masked

static void
format_be32_masked(struct ds *s, const char *name,
                   ovs_be32 value, ovs_be32 mask)
{
    if (mask != htonl(0)) {
        ds_put_format(s, "%s=", name);
        if (mask == OVS_BE32_MAX) {
            ds_put_format(s, "%"PRIu32, ntohl(value));
        } else {
            ds_put_format(s, "0x%"PRIx32"/0x%"PRIx32,
                          ntohl(value), ntohl(mask));
        }
        ds_put_char(s, ',');
    }
}
开发者ID:daolicloud,项目名称:daolinet-openstack,代码行数:15,代码来源:match.c


示例19: format_be16_masked

static void
format_be16_masked(struct ds *s, const char *name,
                   ovs_be16 value, ovs_be16 mask)
{
    if (mask != htons(0)) {
        ds_put_format(s, "%s=", name);
        if (mask == htons(UINT16_MAX)) {
            ds_put_format(s, "%"PRIu16, ntohs(value));
        } else {
            ds_put_format(s, "0x%"PRIx16"/0x%"PRIx16,
                          ntohs(value), ntohs(mask));
        }
        ds_put_char(s, ',');
    }
}
开发者ID:AlickHill,项目名称:Lantern,代码行数:15,代码来源:match.c


示例20: jsonrpc_log_msg

static void
jsonrpc_log_msg(const struct jsonrpc *rpc, const char *title,
                const struct jsonrpc_msg *msg)
{
    if (VLOG_IS_DBG_ENABLED()) {
        struct ds s = DS_EMPTY_INITIALIZER;
        if (msg->method) {
            ds_put_format(&s, ", method=\"%s\"", msg->method);
        }
        if (msg->params) {
            ds_put_cstr(&s, ", params=");
            json_to_ds(msg->params, 0, &s);
        }
        if (msg->result) {
            ds_put_cstr(&s, ", result=");
            json_to_ds(msg->result, 0, &s);
        }
        if (msg->error) {
            ds_put_cstr(&s, ", error=");
            json_to_ds(msg->error, 0, &s);
        }
        if (msg->id) {
            ds_put_cstr(&s, ", id=");
            json_to_ds(msg->id, 0, &s);
        }
        VLOG_DBG("%s: %s %s%s", rpc->name, title,
                 jsonrpc_msg_type_to_string(msg->type), ds_cstr(&s));
        ds_destroy(&s);
    }
}
开发者ID:rafaelfonte,项目名称:ovs,代码行数:30,代码来源:jsonrpc.c



注:本文中的ds_put_format函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ dscal_函数代码示例发布时间:2022-05-30
下一篇:
C++ ds_put_char函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap