当前位置: 首页>>代码示例>>C++>>正文


C++ xo_emit函数代码示例

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


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

示例1: pr_family

/*
 * Print address family header before a section of the routing table.
 */
void
pr_family(int af1)
{
	const char *afname;

	switch (af1) {
	case AF_INET:
		afname = "Internet";
		break;
#ifdef INET6
	case AF_INET6:
		afname = "Internet6";
		break;
#endif /*INET6*/
	case AF_ISO:
		afname = "ISO";
		break;
	case AF_CCITT:
		afname = "X.25";
		break;
	case AF_NETGRAPH:
		afname = "Netgraph";
		break;
	default:
		afname = NULL;
		break;
	}
	if (afname)
		xo_emit("\n{k:address-family/%s}:\n", afname);
	else
		xo_emit("\n{L:Protocol Family} {k:address-family/%d}:\n", af1);
}
开发者ID:mulichao,项目名称:freebsd,代码行数:35,代码来源:route.c

示例2: printtime

static void
printtime(const char *field, time_t ftime)
{
	char longstring[80];
	char fmt[BUFSIZ];
	static time_t now = 0;
	const char *format;
	static int d_first = -1;

	if (d_first < 0)
		d_first = (*nl_langinfo(D_MD_ORDER) == 'd');
	if (now == 0)
		now = time(NULL);

#define	SIXMONTHS	((365 / 2) * 86400)
	if (f_timeformat)  /* user specified format */
		format = f_timeformat;
	else if (f_sectime)
		/* mmm dd hh:mm:ss yyyy || dd mmm hh:mm:ss yyyy */
		format = d_first ? "%e %b %T %Y" : "%b %e %T %Y";
	else if (ftime + SIXMONTHS > now && ftime < now + SIXMONTHS)
		/* mmm dd hh:mm || dd mmm hh:mm */
		format = d_first ? "%e %b %R" : "%b %e %R";
	else
		/* mmm dd  yyyy || dd mmm  yyyy */
		format = d_first ? "%e %b  %Y" : "%b %e  %Y";
	strftime(longstring, sizeof(longstring), format, localtime(&ftime));

	snprintf(fmt, sizeof(fmt), "{d:%s/%%hs} ", field);
	xo_attr("value", "%ld", (long) ftime);
	xo_emit(fmt, longstring);
	snprintf(fmt, sizeof(fmt), "{en:%s/%%ld} ", field);
	xo_emit(fmt, (long) ftime);
}
开发者ID:denir-li,项目名称:freebsd,代码行数:34,代码来源:print.c

示例3: p_sockaddr

static int
p_sockaddr(const char *name, struct sockaddr *sa, struct sockaddr *mask,
    int flags, int width)
{
	const char *cp;
	char buf[128];
	int protrusion;

	cp = fmt_sockaddr(sa, mask, flags);

	if (width < 0) {
		snprintf(buf, sizeof(buf), "{:%s/%%s} ", name);
		xo_emit(buf, cp);
		protrusion = 0;
	} else {
		if (Wflag != 0 || numeric_addr) {
			snprintf(buf, sizeof(buf), "{[:%d}{:%s/%%s}{]:} ",
			    -width, name);
			xo_emit(buf, cp);
			protrusion = strlen(cp) - width;
			if (protrusion < 0)
				protrusion = 0;
		} else {
			snprintf(buf, sizeof(buf), "{[:%d}{:%s/%%-.*s}{]:} ",
			    -width, name);
			xo_emit(buf, width, cp);
			protrusion = 0;
		}
	}
	return (protrusion);
}
开发者ID:mulichao,项目名称:freebsd,代码行数:31,代码来源:route.c

示例4: procstat_env

void
procstat_env(struct procstat *procstat, struct kinfo_proc *kipp)
{
	int i;
	char **envs;

	if (!hflag) {
		xo_emit("{T:/%5s %-16s %-53s}\n", "PID", "COMM", "ENVIRONMENT");
	}

	envs = procstat_getenvv(procstat, kipp, 0);

	xo_emit("{k:process_id/%5d/%d} {:command/%-16s/%s}", kipp->ki_pid,
	    kipp->ki_comm);

	if (envs == NULL) {
		xo_emit(" {d:env/-}\n");
		return;
	}

	xo_open_list("environment");
	for (i = 0; envs[i] != NULL; i++)
		xo_emit(" {l:env/%s}", envs[i]);
	xo_close_list("environment");
	xo_emit("\n");
}
开发者ID:hmatyschok,项目名称:MeshBSD,代码行数:26,代码来源:procstat_args.c

示例5: ipsec_hist_new

/*
 * Dump IPSEC statistics structure.
 */
static void
ipsec_hist_new(const uint64_t *hist, size_t histmax,
    const struct val2str *name, const char *title, const char *cname)
{
	int first;
	size_t proto;
	const struct val2str *p;

	first = 1;
	for (proto = 0; proto < histmax; proto++) {
		if (hist[proto] <= 0)
			continue;
		if (first) {
			xo_open_list(cname);
			xo_emit("\t{T:/%s histogram}:\n", title);
			first = 0;
		}
		xo_open_instance(cname);
		for (p = name; p && p->str; p++) {
			if (p->val == (int)proto)
				break;
		}
		if (p && p->str) {
			xo_emit("\t\t{k:name}: {:count/%ju}\n", p->str,
			    (uintmax_t)hist[proto]);
		} else {
			xo_emit("\t\t#{k:name/%lu}: {:count/%ju}\n",
			    (unsigned long)proto, (uintmax_t)hist[proto]);
		}
		xo_close_instance(cname);
	}
	if (!first)
		xo_close_list(cname);
}
开发者ID:2trill2spill,项目名称:freebsd,代码行数:37,代码来源:ipsec.c

示例6: inet6print

void
inet6print(const char *container, struct in6_addr *in6, int port,
    const char *proto, int numeric)
{
	struct servent *sp = 0;
	char line[80], *cp;
	int width;

	if (container)
		xo_open_container(container);

	sprintf(line, "%.*s.", Wflag ? 39 : (Aflag && !numeric) ? 12 : 16,
	    inet6name(in6));
	cp = strchr(line, '\0');
	if (!numeric && port)
		GETSERVBYPORT6(port, proto, sp);
	if (sp || port == 0)
		sprintf(cp, "%.15s", sp ? sp->s_name : "*");
	else
		sprintf(cp, "%d", ntohs((u_short)port));
	width = Wflag ? 45 : Aflag ? 18 : 22;

	xo_emit("{d:target/%-*.*s} ", width, width, line);

	int alen = cp - line - 1, plen = strlen(cp) - 1;
	xo_emit("{e:address/%*.*s}{e:port/%*.*s}", alen, alen, line, plen,
	    plen, cp);

	if (container)
		xo_close_container(container);
}
开发者ID:fengsi,项目名称:freebsd,代码行数:31,代码来源:inet6.c

示例7: printstream

void
printstream(const DISPLAY *dp)
{
	FTSENT *p;
	int chcnt;

	xo_open_list("entry");
	for (p = dp->list, chcnt = 0; p; p = p->fts_link) {
		if (p->fts_number == NO_PRINT)
			continue;
		/* XXX strlen does not take octal escapes into account. */
		if (strlen(p->fts_name) + chcnt +
		    (p->fts_link ? 2 : 0) >= (unsigned)termwidth) {
			xo_emit("\n");
			chcnt = 0;
		}
		xo_open_instance("file");
		chcnt += printaname(p, dp->s_inode, dp->s_block);
		xo_close_instance("file");
		if (p->fts_link) {
			xo_emit(", ");
			chcnt += 2;
		}
	}
	xo_close_list("entry");
	if (chcnt)
		xo_emit("\n");
}
开发者ID:denir-li,项目名称:freebsd,代码行数:28,代码来源:print.c

示例8: pr_idle

/*
 * pr_idle --
 *	Display the idle time.
 *	Returns number of excess characters that were used for long idle time.
 */
int
pr_idle(time_t idle)
{
	/* If idle more than 36 hours, print as a number of days. */
	if (idle >= 36 * 3600) {
		int days = idle / 86400;
		xo_emit(" {:idle/%dday%s} ", days, days > 1 ? "s" : " " );
		if (days >= 100)
			return (2);
		if (days >= 10)
			return (1);
	}

	/* If idle more than an hour, print as HH:MM. */
	else if (idle >= 3600)
		xo_emit(" {:idle/%2d:%02d/} ",
		    (int)(idle / 3600), (int)((idle % 3600) / 60));

	else if (idle / 60 == 0)
		xo_emit("     - ");

	/* Else print the minutes idle. */
	else
		xo_emit("    {:idle/%2d} ", (int)(idle / 60));

	return (0); /* not idle longer than 9 days */
}
开发者ID:hmatyschok,项目名称:MeshBSD,代码行数:32,代码来源:pr_time.c

示例9: get

/*
 * Display an individual arp entry
 */
static int
get(char *host)
{
	struct sockaddr_in *addr;
	int found;

	addr = getaddr(host);
	if (addr == NULL)
		return (1);

	xo_set_version(ARP_XO_VERSION);
	xo_open_container("arp");
	xo_open_list("arp-cache");

	found = search(addr->sin_addr.s_addr, print_entry);

	if (found == 0) {
		xo_emit("{d:hostname/%s} ({d:ip-address/%s}) -- no entry",
		    host, inet_ntoa(addr->sin_addr));
		if (rifname)
			xo_emit(" on {d:interface/%s}", rifname);
		xo_emit("\n");
	}

	xo_close_list("arp-cache");
	xo_close_container("arp");
	xo_finish();

	return (found == 0);
}
开发者ID:mulichao,项目名称:freebsd,代码行数:33,代码来源:arp.c

示例10: printaname

/*
 * print [inode] [size] name
 * return # of characters printed, no trailing characters.
 */
static int
printaname(const FTSENT *p, u_long inodefield, u_long sizefield)
{
	struct stat *sp;
	int chcnt;
#ifdef COLORLS
	int color_printed = 0;
#endif

	sp = p->fts_statp;
	chcnt = 0;
	if (f_inode)
		chcnt += xo_emit("{t:inode/%*ju} ",
		    (int)inodefield, (uintmax_t)sp->st_ino);
	if (f_size)
		chcnt += xo_emit("{t:size/%*jd} ",
		    (int)sizefield, howmany(sp->st_blocks, blocksize));
#ifdef COLORLS
	if (f_color)
		color_printed = colortype(sp->st_mode);
#endif
	chcnt += printname("name", p->fts_name);
#ifdef COLORLS
	if (f_color && color_printed)
		endcolor(0);
#endif
	if (f_type)
		chcnt += printtype(sp->st_mode);
	return (chcnt);
}
开发者ID:denir-li,项目名称:freebsd,代码行数:34,代码来源:print.c

示例11: procstat_rusage

void
procstat_rusage(struct procstat *procstat, struct kinfo_proc *kipp)
{
	struct kinfo_proc *kip;
	unsigned int count, i;

	if (!hflag) {
		xo_emit("{d:ta/%5s} ", "PID");
		if (Hflag)
			xo_emit("{d:tb/%6s} ", "TID");
		xo_emit("{d:tc/%-16s %-32s %14s}\n", "COMM", "RESOURCE",
		    "VALUE        ");
	}

	if (!Hflag) {
		print_rusage(kipp);
		return;
	}

	xo_emit("{e:process_id/%d}", kipp->ki_pid);
	xo_emit("{e:command/%s}", kipp->ki_comm);
	xo_open_container("threads");

	kip = procstat_getprocs(procstat, KERN_PROC_PID | KERN_PROC_INC_THREAD,
	    kipp->ki_pid, &count);
	if (kip == NULL)
		return;
	kinfo_proc_sort(kip, count);
	for (i = 0; i < count; i++) {
		print_rusage(&kip[i]);
	}

	xo_close_container("threads");
	procstat_freeprocs(procstat, kip);
}
开发者ID:hmatyschok,项目名称:MeshBSD,代码行数:35,代码来源:procstat_rusage.c

示例12: routepr

/*
 * Print routing tables.
 */
void
routepr(int fibnum, int af)
{
	size_t intsize;
	int numfibs;

	if (live == 0)
		return;

	intsize = sizeof(int);
	if (fibnum == -1 &&
	    sysctlbyname("net.my_fibnum", &fibnum, &intsize, NULL, 0) == -1)
		fibnum = 0;
	if (sysctlbyname("net.fibs", &numfibs, &intsize, NULL, 0) == -1)
		numfibs = 1;
	if (fibnum < 0 || fibnum > numfibs - 1)
		errx(EX_USAGE, "%d: invalid fib", fibnum);
	/*
	 * Since kernel & userland use different timebase
	 * (time_uptime vs time_second) and we are reading kernel memory
	 * directly we should do rt_expire --> expire_time conversion.
	 */
	if (clock_gettime(CLOCK_UPTIME, &uptime) < 0)
		err(EX_OSERR, "clock_gettime() failed");

	xo_open_container("route-information");
	xo_emit("{T:Routing tables}");
	if (fibnum)
		xo_emit(" ({L:fib}: {:fib/%d})", fibnum);
	xo_emit("\n");
	p_rtable_sysctl(fibnum, af);
	xo_close_container("route-information");
}
开发者ID:mulichao,项目名称:freebsd,代码行数:36,代码来源:route.c

示例13: procstat_args

void
procstat_args(struct procstat *procstat, struct kinfo_proc *kipp)
{
	int i;
	char **args;

	if (!hflag) {
		xo_emit("{T:/%5s %-16s %-53s}\n", "PID", "COMM", "ARGS");
	}

	args = procstat_getargv(procstat, kipp, 0);

	xo_emit("{k:process_id/%5d/%d} {:command/%-16s/%s}", kipp->ki_pid,
	    kipp->ki_comm);

	if (args == NULL) {
		xo_emit(" {d:args/-}\n");
		return;
	}

	xo_open_list("arguments");
	for (i = 0; args[i] != NULL; i++)
		xo_emit(" {l:args/%s}", args[i]);
	xo_close_list("arguments");
	xo_emit("\n");
}
开发者ID:hmatyschok,项目名称:MeshBSD,代码行数:26,代码来源:procstat_args.c

示例14: print_prefix

static void
print_prefix(struct kinfo_proc *kipp)
{

	xo_emit("{d:process_id/%5d/%d} ", kipp->ki_pid);
	if (Hflag)
		xo_emit("{d:thread_id/%6d/%d} ", kipp->ki_tid);
	xo_emit("{d:command/%-16s/%s} ", kipp->ki_comm);
}
开发者ID:hmatyschok,项目名称:MeshBSD,代码行数:9,代码来源:procstat_rusage.c

示例15: p_flags

static void
p_flags(int f, const char *format)
{
	struct bits *p;

	xo_emit(format, fmt_flags(f));

	xo_open_list("flags_pretty");
	for (p = bits; p->b_mask; p++)
		if (p->b_mask & f)
			xo_emit("{le:flags_pretty/%s}", p->b_name);
	xo_close_list("flags_pretty");
}
开发者ID:mulichao,项目名称:freebsd,代码行数:13,代码来源:route.c


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