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


C++ sbuf_clear函数代码示例

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


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

示例1: init

void init(DWORD netbase, DWORD recv, DWORD send)
{
	if (recv)
	{
		pfn_ws2_recv = reinterpret_cast<void*>(*reinterpret_cast<DWORD*>(recv));
		*reinterpret_cast<DWORD*>(recv) = reinterpret_cast<DWORD>(ws2_recv);

		rbuf_clear();
	}

	if (send)
	{
		pfn_ws2_send = reinterpret_cast<void*>(*reinterpret_cast<DWORD*>(send));
		*reinterpret_cast<DWORD*>(send) = reinterpret_cast<DWORD>(ws2_send);

		sbuf_clear();
	}

	{
		DWORD address = config::get_n("packet", "plt_address");
		bool as = false;
		
		if (address == 0)
		{
			address = netbase;
			as = true;
		}

		packet = new CPacket;
		packet->initialize(address, as);
	}

	dbgprintf(0, "recv_a=%08X recv_o=%08X recv_m=%08X send_a=%08X send_o=%08X send_m=%08X\n", recv, pfn_ws2_recv, ws2_recv, send, pfn_ws2_send, ws2_send);
}
开发者ID:kaina,项目名称:sandbox,代码行数:34,代码来源:nethook.cpp

示例2: vfs_mountroot

void
vfs_mountroot(void)
{
	struct mount *mp;
	struct sbuf *sb;
	struct thread *td;
	time_t timebase;
	int error;

	td = curthread;

	vfs_mountroot_wait();

	sb = sbuf_new_auto();
	vfs_mountroot_conf0(sb);
	sbuf_finish(sb);

	error = vfs_mountroot_devfs(td, &mp);
	while (!error) {
		error = vfs_mountroot_parse(sb, mp);
		if (!error) {
			error = vfs_mountroot_shuffle(td, mp);
			if (!error) {
				sbuf_clear(sb);
				error = vfs_mountroot_readconf(td, sb);
				sbuf_finish(sb);
			}
		}
	}

	sbuf_delete(sb);

	/*
	 * Iterate over all currently mounted file systems and use
	 * the time stamp found to check and/or initialize the RTC.
	 * Call inittodr() only once and pass it the largest of the
	 * timestamps we encounter.
	 */
	timebase = 0;
	mtx_lock(&mountlist_mtx);
	mp = TAILQ_FIRST(&mountlist);
	while (mp != NULL) {
		if (mp->mnt_time > timebase)
			timebase = mp->mnt_time;
		mp = TAILQ_NEXT(mp, mnt_list);
	}
	mtx_unlock(&mountlist_mtx);
	inittodr(timebase);

	/* Keep prison0's root in sync with the global rootvnode. */
	mtx_lock(&prison0.pr_mtx);
	prison0.pr_root = rootvnode;
	vref(prison0.pr_root);
	mtx_unlock(&prison0.pr_mtx);

	mtx_lock(&mountlist_mtx);
	atomic_store_rel_int(&root_mount_complete, 1);
	wakeup(&root_mount_complete);
	mtx_unlock(&mountlist_mtx);
}
开发者ID:BillTheBest,项目名称:libuinet,代码行数:60,代码来源:vfs_mountroot.c

示例3: job_status_end

void
job_status_end(struct sbuf *msg)
{
	sbuf_finish(msg);
	printf("%s\n", sbuf_data(msg));
	/*printf("\033]0; %s\007", sbuf_data(msg));*/
	sbuf_clear(msg);
}
开发者ID:dotike,项目名称:pkg,代码行数:8,代码来源:event.c

示例4: sbuf_init

void
sbuf_init(struct sbuf **buf)
{
	if (*buf == NULL)
		*buf = sbuf_new_auto();
	else
		sbuf_clear(*buf);
}
开发者ID:baloo,项目名称:pkgng,代码行数:8,代码来源:utils.c

示例5: sbuf_reset

void
sbuf_reset(struct sbuf *buf)
{
	if (buf != NULL) {
		sbuf_clear(buf);
		sbuf_finish(buf);
	}
}
开发者ID:baloo,项目名称:pkgng,代码行数:8,代码来源:utils.c

示例6: 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

示例7: sbuf_cpy

/*
 * Copy a string into an sbuf.
 */
int
sbuf_cpy(struct sbuf *s, const char *str)
{
	assert_sbuf_integrity(s);
	assert_sbuf_state(s, 0);
	
	sbuf_clear(s);
	return (sbuf_cat(s, str));
}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:12,代码来源:subr_sbuf.c

示例8: sbuf_bcpy

/*
 * Copy a byte string into an sbuf.
 */
int
sbuf_bcpy(struct sbuf *s, const char *str, size_t len)
{
	assert_sbuf_integrity(s);
	assert_sbuf_state(s, 0);
	
	sbuf_clear(s);
	return (sbuf_bcat(s, str, len));
}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:12,代码来源:subr_sbuf.c

示例9: sbuf_bcpy

/*
 * Copy a byte string into an sbuf.
 */
int
sbuf_bcpy(struct sbuf *s, const void *buf, size_t len)
{
	assert_sbuf_integrity(s);
	assert_sbuf_state(s, 0);

	sbuf_clear(s);
	return (sbuf_bcat(s, buf, len));
}
开发者ID:genua,项目名称:anoubis_os,代码行数:12,代码来源:subr_sbuf.c

示例10: fin

void fin()
{
	if (packet)
	{
		delete packet;
		packet = NULL;
	}

	rbuf_clear();
	sbuf_clear();
}
开发者ID:kaina,项目名称:sandbox,代码行数:11,代码来源:nethook.cpp

示例11: packing_append_tree

int
packing_append_tree(struct packing *pack, const char *treepath,
    const char *newroot)
{
	FTS *fts = NULL;
	FTSENT *fts_e = NULL;
	size_t treelen;
	struct sbuf *sb;
	char *paths[2] = { __DECONST(char *, treepath), NULL };

	treelen = strlen(treepath);
	fts = fts_open(paths, FTS_PHYSICAL | FTS_XDEV, NULL);
	if (fts == NULL)
		goto cleanup;

	sb = sbuf_new_auto();
	while ((fts_e = fts_read(fts)) != NULL) {
		switch(fts_e->fts_info) {
		case FTS_D:
		case FTS_DEFAULT:
		case FTS_F:
		case FTS_SL:
		case FTS_SLNONE:
			 /* Entries not within this tree are irrelevant. */
			 if (fts_e->fts_pathlen <= treelen)
				  break;
			 sbuf_clear(sb);
			 /* Strip the prefix to obtain the target path */
			 if (newroot) /* Prepend a root if one is specified */
				  sbuf_cat(sb, newroot);
			 /* +1 = skip trailing slash */
			 sbuf_cat(sb, fts_e->fts_path + treelen + 1);
			 sbuf_finish(sb);
			 packing_append_file(pack, fts_e->fts_name,
			    sbuf_get(sb));
			 break;
		case FTS_DC:
		case FTS_DNR:
		case FTS_ERR:
		case FTS_NS:
			 /* XXX error cases, check fts_e->fts_errno and
			  *     bubble up the call chain */
			 break;
		default:
			 break;
		}
	}
	sbuf_free(sb);
cleanup:
	fts_close(fts);
	return EPKG_OK;
}
开发者ID:HonestQiao,项目名称:pkgng,代码行数:52,代码来源:packing.c

示例12: sbuf_json_escape

static char *
sbuf_json_escape(struct sbuf *buf, const char *str)
{
	sbuf_clear(buf);
	while (str != NULL && *str != '\0') {
		if (*str == '"' || *str == '\\')
			sbuf_putc(buf, '\\');
		sbuf_putc(buf, *str);
		str++;
	}
	sbuf_finish(buf);

	return (sbuf_data(buf));
}
开发者ID:grembo,项目名称:pkg,代码行数:14,代码来源:pkg_event.c

示例13: job_status_begin

void
job_status_begin(struct sbuf *msg)
{
	int n;

	sbuf_clear(msg);
#ifdef HAVE_LIBJAIL
	static char hostname[MAXHOSTNAMELEN] = "";
	static int jailed = -1;
	size_t intlen;

	if (jailed == -1) {
		intlen = sizeof(jailed);
		if (sysctlbyname("security.jail.jailed", &jailed, &intlen,
		    NULL, 0) == -1)
			jailed = 0;
	}

	if (jailed == 1) {
		if (hostname[0] == '\0')
			gethostname(hostname, sizeof(hostname));

		sbuf_printf(msg, "[%s] ", hostname);
	}
#endif

	/* Only used for pkg-add right now. */
	if (add_deps_depth) {
		if (add_deps_depth > 1) {
			for (n = 0; n < (2 * add_deps_depth); ++n) {
				if (n % 4 == 0 && n < (2 * add_deps_depth))
					sbuf_cat(msg, "|");
				else
					sbuf_cat(msg, " ");
			}
		}
		sbuf_cat(msg, "`-- ");
	}

	if (nbactions > 0 && nbdone > 0)
		sbuf_printf(msg, "[%d/%d] ", nbdone, nbactions);
}
开发者ID:dotike,项目名称:pkg,代码行数:42,代码来源:event.c

示例14: xendebug_filter

static int
xendebug_filter(void *arg)
{
#if defined(STACK) && defined(DDB)
	struct stack st;
	struct trapframe *frame;

	frame = arg;
	stack_zero(&st);
	stack_save(&st);

	mtx_lock_spin(&lock);
	sbuf_clear(buf);
	xc_printf("Printing stack trace vCPU%d\n", PCPU_GET(vcpu_id));
	stack_sbuf_print_ddb(buf, &st);
	sbuf_finish(buf);
	mtx_unlock_spin(&lock);
#endif

	return (FILTER_HANDLED);
}
开发者ID:2asoft,项目名称:freebsd,代码行数:21,代码来源:debug.c

示例15: urlencode

static int
urlencode(const char *src, struct sbuf **dest)
{
	size_t len;
	size_t i;

	if (*dest == NULL)
		*dest = sbuf_new_auto();
	else
		sbuf_clear(*dest);

	len = strlen(src);
	for (i = 0; i < len; i++) {
		if (!isascii(src[i]) || src[i] == '%')
			sbuf_printf(*dest, "%%%.2x", (unsigned char)src[i]);
		else
			sbuf_putc(*dest, src[i]);
	}
	sbuf_finish(*dest);

	return (EPKG_OK);
}
开发者ID:dnaeon,项目名称:pkgng,代码行数:22,代码来源:pkg_manifest.c


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