本文整理汇总了C++中sbuf_printf函数的典型用法代码示例。如果您正苦于以下问题:C++ sbuf_printf函数的具体用法?C++ sbuf_printf怎么用?C++ sbuf_printf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sbuf_printf函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: vfs_mountroot_readconf
static int
vfs_mountroot_readconf(struct thread *td, struct sbuf *sb)
{
static char buf[128];
struct nameidata nd;
off_t ofs;
ssize_t resid;
int error, flags, len;
NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, "/.mount.conf", td);
flags = FREAD;
error = vn_open(&nd, &flags, 0, NULL);
if (error)
return (error);
NDFREE(&nd, NDF_ONLY_PNBUF);
ofs = 0;
len = sizeof(buf) - 1;
while (1) {
error = vn_rdwr(UIO_READ, nd.ni_vp, buf, len, ofs,
UIO_SYSSPACE, IO_NODELOCKED, td->td_ucred,
NOCRED, &resid, td);
if (error)
break;
if (resid == len)
break;
buf[len - resid] = 0;
sbuf_printf(sb, "%s", buf);
ofs += len - resid;
}
VOP_UNLOCK(nd.ni_vp, 0);
vn_close(nd.ni_vp, FREAD, td->td_ucred, td);
return (error);
}
开发者ID:ChristosKa,项目名称:freebsd,代码行数:35,代码来源:vfs_mountroot.c
示例17: print_status_begin
static void
print_status_begin(struct sbuf *msg)
{
if (nbactions > 0)
sbuf_printf(msg, "[%d/%d] ", nbdone, nbactions);
}
开发者ID:dschossig,项目名称:pkg,代码行数:7,代码来源:event.c
示例18: pkg_repo_binary_build_search_query
static int
pkg_repo_binary_build_search_query(struct sbuf *sql, match_t match,
pkgdb_field field, pkgdb_field sort)
{
const char *how = NULL;
const char *what = NULL;
const char *orderby = NULL;
how = pkg_repo_binary_search_how(match);
switch (field) {
case FIELD_NONE:
what = NULL;
break;
case FIELD_ORIGIN:
what = "origin";
break;
case FIELD_NAME:
what = "name";
break;
case FIELD_NAMEVER:
what = "name || '-' || version";
break;
case FIELD_COMMENT:
what = "comment";
break;
case FIELD_DESC:
what = "desc";
break;
}
if (what != NULL && how != NULL)
sbuf_printf(sql, how, what);
switch (sort) {
case FIELD_NONE:
orderby = NULL;
break;
case FIELD_ORIGIN:
orderby = " ORDER BY origin";
break;
case FIELD_NAME:
orderby = " ORDER BY name";
break;
case FIELD_NAMEVER:
orderby = " ORDER BY name, version";
break;
case FIELD_COMMENT:
orderby = " ORDER BY comment";
break;
case FIELD_DESC:
orderby = " ORDER BY desc";
break;
}
if (orderby != NULL)
sbuf_cat(sql, orderby);
return (EPKG_OK);
}
开发者ID:baitisj,项目名称:pkg,代码行数:60,代码来源:query.c
示例19: sysctl_debug_ddb_scripting_scripts
static int
sysctl_debug_ddb_scripting_scripts(SYSCTL_HANDLER_ARGS)
{
struct sbuf sb;
int error, i, len;
char *buffer;
/*
* Make space to include a maximum-length name, = symbol,
* maximum-length script, and carriage return for every script that
* may be defined.
*/
len = DB_MAXSCRIPTS * (DB_MAXSCRIPTNAME + 1 + DB_MAXSCRIPTLEN + 1);
buffer = malloc(len, M_TEMP, M_WAITOK);
(void)sbuf_new(&sb, buffer, len, SBUF_FIXEDLEN);
mtx_lock(&db_script_mtx);
for (i = 0; i < DB_MAXSCRIPTS; i++) {
if (strlen(db_script_table[i].ds_scriptname) == 0)
continue;
(void)sbuf_printf(&sb, "%s=%s\n",
db_script_table[i].ds_scriptname,
db_script_table[i].ds_script);
}
mtx_unlock(&db_script_mtx);
sbuf_finish(&sb);
error = SYSCTL_OUT(req, sbuf_data(&sb), sbuf_len(&sb) + 1);
sbuf_delete(&sb);
free(buffer, M_TEMP);
return (error);
}
开发者ID:oza,项目名称:FreeBSD-7.3-dyntick,代码行数:30,代码来源:db_script.c
示例20: ucl_sbuf_append_double
static int
ucl_sbuf_append_double(double val, void *data)
{
struct sbuf *buf = data;
const double delta = 0.0000001;
if (val == (double)(int)val) {
sbuf_printf(buf, "%.1lf", val);
} else if (fabs(val - (double)(int)val) < delta) {
sbuf_printf(buf, "%.*lg", DBL_DIG, val);
} else {
sbuf_printf(buf, "%lf", val);
}
return (0);
}
开发者ID:baitisj,项目名称:pkg,代码行数:16,代码来源:utils.c
注:本文中的sbuf_printf函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论