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


C++ sbuf_printf函数代码示例

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


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

示例1: smp_command_decode

/*
 * Decode a SMP request buffer into a string of hexadecimal numbers.
 *
 * smp_request:    SMP request
 * request_len:    length of the SMP request buffer, may be reduced if the
 *                 caller only wants part of the buffer printed
 * sb:             sbuf(9) buffer
 * line_prefix:    prefix for new lines, or an empty string ("")
 * first_line_len: length left on first line
 * line_len:       total length of subsequent lines, 0 for no additional lines
 *                 if there are no additional lines, first line will get ...
 *                 at the end if there is additional data
 */
void
smp_command_decode(uint8_t *smp_request, int request_len, struct sbuf *sb,
		   char *line_prefix, int first_line_len, int line_len)
{
	int i, cur_len;

	for (i = 0, cur_len = first_line_len; i < request_len; i++) {
		/*
		 * Each byte takes 3 characters.  As soon as we go less
		 * than 6 (meaning we have at least 3 and at most 5
		 * characters left), check to see whether the subsequent
		 * line length (line_len) is long enough to bother with.
		 * If the user set it to 0, or some other length that isn't
		 * enough to hold at least the prefix and one byte, put ...
		 * on the first line to indicate that there is more data
		 * and bail out.
		 */
		if ((cur_len < 6)
		 && (line_len < (strlen(line_prefix) + 3))) {
			sbuf_printf(sb, "...");
			return;
		}
		if (cur_len < 3) {
			sbuf_printf(sb, "\n%s", line_prefix);
			cur_len = line_len - strlen(line_prefix);
		}
		sbuf_printf(sb, "%02x ", smp_request[i]);
		cur_len = cur_len - 3;
	}
}
开发者ID:ele7enxxh,项目名称:dtrace-pf,代码行数:43,代码来源:smp_all.c

示例2: g_bsd_dumpconf

/*
 * Dump configuration information in XML format.
 * Notice that the function is called once for the geom and once for each
 * consumer and provider.  We let g_slice_dumpconf() do most of the work.
 */
static void
g_bsd_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp, struct g_consumer *cp, struct g_provider *pp)
{
	struct g_bsd_softc *ms;
	struct g_slicer *gsp;

	gsp = gp->softc;
	ms = gsp->softc;
	g_slice_dumpconf(sb, indent, gp, cp, pp);
	if (indent != NULL && pp == NULL && cp == NULL) {
		sbuf_printf(sb, "%s<labeloffset>%jd</labeloffset>\n",
		    indent, (intmax_t)ms->labeloffset);
		sbuf_printf(sb, "%s<rawoffset>%jd</rawoffset>\n",
		    indent, (intmax_t)ms->rawoffset);
		sbuf_printf(sb, "%s<mbroffset>%jd</mbroffset>\n",
		    indent, (intmax_t)ms->mbroffset);
	} else if (pp != NULL) {
		if (indent == NULL)
			sbuf_printf(sb, " ty %d",
			    ms->ondisk.d_partitions[pp->index].p_fstype);
		else
			sbuf_printf(sb, "%s<type>%d</type>\n", indent,
			    ms->ondisk.d_partitions[pp->index].p_fstype);
	}
}
开发者ID:2asoft,项目名称:freebsd,代码行数:30,代码来源:geom_bsd.c

示例3: text_status

/*
 * CONTROL MESSAGES
 */
static int
text_status(node_p node, struct priv *priv, char *arg, u_int len)
{
	struct sbuf sbuf;

	sbuf_new(&sbuf, arg, len, 0);

	if (priv->upper)
		sbuf_printf(&sbuf, "upper hook: %s connected to %s:%s\n",
		    NG_HOOK_NAME(priv->upper),
		    NG_NODE_NAME(NG_HOOK_NODE(NG_HOOK_PEER(priv->upper))),
		    NG_HOOK_NAME(NG_HOOK_PEER(priv->upper)));
	else
		sbuf_printf(&sbuf, "upper hook: <not connected>\n");

	if (priv->lower)
		sbuf_printf(&sbuf, "lower hook: %s connected to %s:%s\n",
		    NG_HOOK_NAME(priv->lower),
		    NG_NODE_NAME(NG_HOOK_NODE(NG_HOOK_PEER(priv->lower))),
		    NG_HOOK_NAME(NG_HOOK_PEER(priv->lower)));
	else
		sbuf_printf(&sbuf, "lower hook: <not connected>\n");

	sbuf_printf(&sbuf, "sscf state: %s\n",
	    priv->enabled == NULL ? "<disabled>" :
	    sscfu_statename(sscfu_getstate(priv->sscf)));

	sbuf_finish(&sbuf);
	return (sbuf_len(&sbuf));
}
开发者ID:MarginC,项目名称:kame,代码行数:33,代码来源:ng_sscfu.c

示例4: ata_status_sbuf

/*
 * ata_status_abuf() returns 0 for success and -1 for failure.
 */
int
ata_status_sbuf(struct ccb_ataio *ataio, struct sbuf *sb)
{

	sbuf_printf(sb, "ATA status: %02x (%s%s%s%s%s%s%s%s)",
	    ataio->res.status,
	    (ataio->res.status & 0x80) ? "BSY " : "",
	    (ataio->res.status & 0x40) ? "DRDY " : "",
	    (ataio->res.status & 0x20) ? "DF " : "",
	    (ataio->res.status & 0x10) ? "SERV " : "",
	    (ataio->res.status & 0x08) ? "DRQ " : "",
	    (ataio->res.status & 0x04) ? "CORR " : "",
	    (ataio->res.status & 0x02) ? "IDX " : "",
	    (ataio->res.status & 0x01) ? "ERR" : "");
	if (ataio->res.status & 1) {
	    sbuf_printf(sb, ", error: %02x (%s%s%s%s%s%s%s%s)",
		ataio->res.error,
		(ataio->res.error & 0x80) ? "ICRC " : "",
		(ataio->res.error & 0x40) ? "UNC " : "",
		(ataio->res.error & 0x20) ? "MC " : "",
		(ataio->res.error & 0x10) ? "IDNF " : "",
		(ataio->res.error & 0x08) ? "MCR " : "",
		(ataio->res.error & 0x04) ? "ABRT " : "",
		(ataio->res.error & 0x02) ? "NM " : "",
		(ataio->res.error & 0x01) ? "ILI" : "");
	}

	return(0);
}
开发者ID:Alkzndr,项目名称:freebsd,代码行数:32,代码来源:ata_all.c

示例5: sysctl_handle_dpi

static int
sysctl_handle_dpi(SYSCTL_HANDLER_ARGS)
{
	struct ioat_softc *ioat;
	struct sbuf sb;
#define	PRECISION	"1"
	const uintmax_t factor = 10;
	uintmax_t rate;
	int error;

	ioat = arg1;
	sbuf_new_for_sysctl(&sb, NULL, 16, req);

	if (ioat->stats.interrupts == 0) {
		sbuf_printf(&sb, "NaN");
		goto out;
	}
	rate = ioat->stats.descriptors_processed * factor /
	    ioat->stats.interrupts;
	sbuf_printf(&sb, "%ju.%." PRECISION "ju", rate / factor,
	    rate % factor);
#undef	PRECISION
out:
	error = sbuf_finish(&sb);
	sbuf_delete(&sb);
	if (error != 0 || req->newptr == NULL)
		return (error);
	return (EINVAL);
}
开发者ID:cyrilmagsuci,项目名称:freebsd,代码行数:29,代码来源:ioat.c

示例6: i915_capabilities

static int
i915_capabilities(struct drm_device *dev, struct sbuf *m, void *data)
{
	const struct intel_device_info *info = INTEL_INFO(dev);

	sbuf_printf(m, "gen: %d\n", info->gen);
	if (HAS_PCH_SPLIT(dev))
		sbuf_printf(m, "pch: %d\n", INTEL_PCH_TYPE(dev));
#define B(x) sbuf_printf(m, #x ": %s\n", yesno(info->x))
	B(is_mobile);
	B(is_i85x);
	B(is_i915g);
	B(is_i945gm);
	B(is_g33);
	B(need_gfx_hws);
	B(is_g4x);
	B(is_pineview);
	B(has_fbc);
	B(has_pipe_cxsr);
	B(has_hotplug);
	B(cursor_needs_physical);
	B(has_overlay);
	B(overlay_needs_physical);
	B(supports_tv);
	B(has_bsd_ring);
	B(has_blt_ring);
	B(has_llc);
#undef B

	return (0);
}
开发者ID:JabirTech,项目名称:Source,代码行数:31,代码来源:i915_debug.c

示例7: ctl_data_print

void
ctl_data_print(union ctl_io *io)
{
	char str[128];
	char path_str[64];
	struct sbuf sb;
	int i, j, len;

	if (io->io_hdr.io_type != CTL_IO_SCSI)
		return;
	if (io->io_hdr.flags & CTL_FLAG_BUS_ADDR)
		return;
	if (io->io_hdr.flags & CTL_FLAG_EDPTR_SGLIST)	/* XXX: Implement */
		return;
	ctl_scsi_path_string(io, path_str, sizeof(path_str));
	len = min(io->scsiio.kern_data_len, 4096);
	for (i = 0; i < len; ) {
		sbuf_new(&sb, str, sizeof(str), SBUF_FIXEDLEN);
		sbuf_cat(&sb, path_str);
		sbuf_printf(&sb, " %#6x:%04x:", io->scsiio.tag_num, i);
		for (j = 0; j < 16 && i < len; i++, j++) {
			if (j == 8)
				sbuf_cat(&sb, " ");
			sbuf_printf(&sb, " %02x", io->scsiio.kern_data_ptr[i]);
		}
		sbuf_cat(&sb, "\n");
		sbuf_finish(&sb);
		printf("%s", sbuf_data(&sb));
	}
}
开发者ID:Lxg1582,项目名称:freebsd,代码行数:30,代码来源:ctl_util.c

示例8: acpi_cpu_usage_sysctl

static int
acpi_cpu_usage_sysctl(SYSCTL_HANDLER_ARGS)
{
    struct acpi_cpu_softc *sc;
    struct sbuf	 sb;
    char	 buf[128];
    int		 i;
    uintmax_t	 fract, sum, whole;

    sc = (struct acpi_cpu_softc *) arg1;
    sum = 0;
    for (i = 0; i < sc->cpu_cx_count; i++)
	sum += sc->cpu_cx_stats[i];
    sbuf_new(&sb, buf, sizeof(buf), SBUF_FIXEDLEN);
    for (i = 0; i < sc->cpu_cx_count; i++) {
	if (sum > 0) {
	    whole = (uintmax_t)sc->cpu_cx_stats[i] * 100;
	    fract = (whole % sum) * 100;
	    sbuf_printf(&sb, "%u.%02u%% ", (u_int)(whole / sum),
		(u_int)(fract / sum));
	} else
	    sbuf_printf(&sb, "0.00%% ");
    }
    sbuf_printf(&sb, "last %dus", sc->cpu_prev_sleep);
    sbuf_trim(&sb);
    sbuf_finish(&sb);
    sysctl_handle_string(oidp, sbuf_data(&sb), sbuf_len(&sb), req);
    sbuf_delete(&sb);

    return (0);
}
开发者ID:DangerDexter,项目名称:FreeBSD-8.0-dyntick,代码行数:31,代码来源:acpi_cpu.c

示例9: khttpd_ktr_logging

static void
khttpd_ktr_logging(struct sbuf *sbuf)
{
	struct uio auio;
	struct iovec aiov;
	struct ktr_entry *ep;
	struct thread *td;
	int error, fd, i, n;

	KHTTPD_ASSERT_CURPROC_IS_KHTTPD();

	td = curthread;

	error = kern_openat(td, AT_FDCWD, KHTTPD_KTR_FILE,
	    UIO_SYSSPACE, O_WRONLY | O_APPEND, 0666);
	if (error != 0) {
		log(LOG_WARNING,
		    "khttpd: failed to open ktr file '%s' (error %d)",
		    KHTTPD_KTR_FILE, error);
		return;
	}
	fd = td->td_retval[0];

	sbuf_clear(sbuf);

	n = ktr_entries;
	for (i = khttpd_ktr_logging_idx; i != ktr_idx;
	     i = i == n - 1 ? 0 : i + 1) {
		ep = &ktr_buf[i];

		sbuf_printf(sbuf, "%lld %p %d ",
		    (long long)ep->ktr_timestamp, ep->ktr_thread,
		    ep->ktr_cpu);
		sbuf_printf(sbuf, ep->ktr_desc, ep->ktr_parms[0],
		    ep->ktr_parms[1], ep->ktr_parms[2],
		    ep->ktr_parms[3], ep->ktr_parms[4],
		    ep->ktr_parms[5]);
		sbuf_cat(sbuf, "\n");
	}

	sbuf_finish(sbuf);

	khttpd_ktr_logging_idx = i;

	aiov.iov_base = sbuf_data(sbuf);
	aiov.iov_len = sbuf_len(sbuf);
	auio.uio_iov = &aiov;
	auio.uio_iovcnt = 1;
	auio.uio_resid = aiov.iov_len;
	auio.uio_segflg = UIO_SYSSPACE;
	error = kern_writev(td, fd, &auio);
	if (error != 0)
		log(LOG_WARNING, "khttpd: KTR flush failed "
		    "(error: %d)", error);

	kern_close(td, fd);
}
开发者ID:Taketsuru,项目名称:khttpd,代码行数:57,代码来源:khttpd_ktr.c

示例10: pkg_delete

int
pkg_delete(struct pkg *pkg, struct pkgdb *db, int force)
{
	struct pkg **rdeps;
	int i, ret;
	struct sbuf *rdep_msg;

	if (pkg == NULL)
		return (ERROR_BAD_ARG("pkg"));

	if (db == NULL)
		return (ERROR_BAD_ARG("db"));

	/*
	 * Ensure that we have all the informations we need
	 */
	if ((ret = pkgdb_loadrdeps(db, pkg)) != EPKG_OK)
		return (ret);
	if ((ret = pkgdb_loadfiles(db, pkg)) != EPKG_OK)
		return (ret);
	if ((ret = pkgdb_loadscripts(db, pkg)) != EPKG_OK)
		return (ret);
	if ((ret = pkgdb_loadmtree(db, pkg)) != EPKG_OK)
		return (ret);

	rdeps = pkg_rdeps(pkg);

	if (rdeps[0] != NULL) {
		rdep_msg = sbuf_new_auto();
		sbuf_printf(rdep_msg, "%s-%s is required by other packages:", pkg_get(pkg, PKG_NAME), pkg_get(pkg, PKG_VERSION));
		for (i = 0;rdeps[i] != NULL; i++) {
			sbuf_cat(rdep_msg, " ");
			sbuf_printf(rdep_msg, "%s-%s", pkg_get(rdeps[i], PKG_NAME), pkg_get(rdeps[i], PKG_VERSION));
		}
		if (!force) {
			sbuf_finish(rdep_msg);
			ret = pkg_error_set(EPKG_REQUIRED, "%s", sbuf_get(rdep_msg));
			sbuf_free(rdep_msg);
			return ret;
		}
		sbuf_cat(rdep_msg, ", deleting anyway");
		sbuf_finish(rdep_msg);
		fprintf(stderr, "%s\n", sbuf_get(rdep_msg));
		sbuf_free(rdep_msg);
	}

	if ((ret = pkg_script_pre_deinstall(pkg)) != EPKG_OK)
		return (ret);

	if ((ret = pkg_delete_files(pkg, force)) != EPKG_OK)
		return (ret);

	if ((ret = pkg_script_post_deinstall(pkg)) != EPKG_OK)
		return (ret);

	return (pkgdb_unregister_pkg(db, pkg_get(pkg, PKG_ORIGIN)));
}
开发者ID:flz,项目名称:pkgng,代码行数:57,代码来源:pkg_delete.c

示例11: procfs_doproctype

int
procfs_doproctype(PFS_FILL_ARGS)
{
	static const char *none = "Not Available";

	if (p != NULL && p->p_sysent && p->p_sysent->sv_name)
		sbuf_printf(sb, "%s", p->p_sysent->sv_name);
	else
		sbuf_printf(sb, "%s", none);
	sbuf_putc(sb, '\n');
	return (0);
}
开发者ID:2asoft,项目名称:freebsd,代码行数:12,代码来源:procfs_type.c

示例12: procfs_doprocrlimit

int
procfs_doprocrlimit(PFS_FILL_ARGS)
{
	struct plimit *limp;
	int i;

	/*
	 * Obtain a private reference to resource limits
	 */

	PROC_LOCK(p);
	limp = lim_hold(p->p_limit);
	PROC_UNLOCK(p);

	for (i = 0; i < RLIM_NLIMITS; i++) {

		/*
		 * Add the rlimit ident
		 */

		sbuf_printf(sb, "%s ", rlimit_ident[i]);

		/*
		 * Replace RLIM_INFINITY with -1 in the string
		 */

		/*
		 * current limit
		 */

		if (limp->pl_rlimit[i].rlim_cur == RLIM_INFINITY) {
			sbuf_printf(sb, "-1 ");
		} else {
			sbuf_printf(sb, "%llu ",
			    (unsigned long long)limp->pl_rlimit[i].rlim_cur);
		}

		/*
		 * maximum limit
		 */

		if (limp->pl_rlimit[i].rlim_max == RLIM_INFINITY) {
			sbuf_printf(sb, "-1\n");
		} else {
			sbuf_printf(sb, "%llu\n",
			    (unsigned long long)limp->pl_rlimit[i].rlim_max);
		}
	}

	lim_free(limp);
	return (0);
}
开发者ID:2trill2spill,项目名称:freebsd,代码行数:52,代码来源:procfs_rlimit.c

示例13: nvme_print_ident

void
nvme_print_ident(const struct nvme_controller_data *cdata,
    const struct nvme_namespace_data *data, struct sbuf *sb)
{

	sbuf_printf(sb, "<");
	cam_strvis_sbuf(sb, cdata->mn, sizeof(cdata->mn), 0);
	sbuf_printf(sb, " ");
	cam_strvis_sbuf(sb, cdata->fr, sizeof(cdata->fr), 0);
	sbuf_printf(sb, " ");
	cam_strvis_sbuf(sb, cdata->sn, sizeof(cdata->sn), 0);
	sbuf_printf(sb, ">\n");
}
开发者ID:2trill2spill,项目名称:freebsd,代码行数:13,代码来源:nvme_all.c

示例14: pkg_repo_binary_stat

int64_t
pkg_repo_binary_stat(struct pkg_repo *repo, pkg_stats_t type)
{
	sqlite3 *sqlite = PRIV_GET(repo);
	sqlite3_stmt	*stmt = NULL;
	int64_t		 stats = 0;
	struct sbuf	*sql = NULL;
	int		 ret;

	sql = sbuf_new_auto();

	switch(type) {
	case PKG_STATS_LOCAL_COUNT:
		goto out;
		break;
	case PKG_STATS_LOCAL_SIZE:
		goto out;
		break;
	case PKG_STATS_REMOTE_UNIQUE:
		sbuf_printf(sql, "SELECT COUNT(id) FROM main.packages;");
		break;
	case PKG_STATS_REMOTE_COUNT:
		sbuf_printf(sql, "SELECT COUNT(id) FROM main.packages;");
		break;
	case PKG_STATS_REMOTE_SIZE:
		sbuf_printf(sql, "SELECT SUM(pkgsize) FROM main.packages;");
		break;
	case PKG_STATS_REMOTE_REPOS:
		goto out;
		break;
	}

	sbuf_finish(sql);
	pkg_debug(4, "binary_repo: running '%s'", sbuf_data(sql));
	ret = sqlite3_prepare_v2(sqlite, sbuf_data(sql), -1, &stmt, NULL);
	if (ret != SQLITE_OK) {
		ERROR_SQLITE(sqlite, sbuf_data(sql));
		goto out;
	}

	while (sqlite3_step(stmt) != SQLITE_DONE) {
		stats = sqlite3_column_int64(stmt, 0);
	}

out:
	sbuf_free(sql);
	if (stmt != NULL)
		sqlite3_finalize(stmt);

	return (stats);
}
开发者ID:baitisj,项目名称:pkg,代码行数:51,代码来源:query.c

示例15: ctl_scsi_sense_sbuf

/*
 * ctl_scsi_sense_sbuf() returns 0 for success and -1 for failure.
 */
int
ctl_scsi_sense_sbuf(struct ctl_scsiio *ctsio,
		    struct scsi_inquiry_data *inq_data, struct sbuf *sb,
		    scsi_sense_string_flags flags)
{
	char	  path_str[64];

	if ((ctsio == NULL) || (sb == NULL))
		return(-1);

	ctl_scsi_path_string((union ctl_io *)ctsio, path_str, sizeof(path_str));

	if (flags & SSS_FLAG_PRINT_COMMAND) {

		sbuf_cat(sb, path_str);

		ctl_scsi_command_string(ctsio, inq_data, sb);

		sbuf_printf(sb, "\n");
	}

	scsi_sense_only_sbuf(&ctsio->sense_data, ctsio->sense_len, sb,
			     path_str, inq_data, ctsio->cdb, ctsio->cdb_len);

	return(0);
}
开发者ID:FreeBSDFoundation,项目名称:freebsd,代码行数:29,代码来源:ctl_scsi_all.c


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