本文整理汇总了C++中ds_put_format函数的典型用法代码示例。如果您正苦于以下问题:C++ ds_put_format函数的具体用法?C++ ds_put_format怎么用?C++ ds_put_format使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ds_put_format函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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, ',');
}
}
示例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);
}
}
示例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);
}
示例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);
}
示例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();
}
}
示例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);
}
示例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, ")");
}
示例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);
}
}
示例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));
}
}
示例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));
}
}
}
示例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, ',');
}
}
示例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, ',');
}
}
示例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));
}
}
示例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");
}
}