• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ sbuf_clear函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: ucl_object_emit_sbuf

bool
ucl_object_emit_sbuf(const ucl_object_t *obj, enum ucl_emitter emit_type,
                     struct sbuf **buf)
{
	bool ret = false;
	struct ucl_emitter_functions func = {
		.ucl_emitter_append_character = ucl_sbuf_append_character,
		.ucl_emitter_append_len = ucl_sbuf_append_len,
		.ucl_emitter_append_int = ucl_sbuf_append_int,
		.ucl_emitter_append_double = ucl_sbuf_append_double
	};

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

	func.ud = *buf;

	ret = ucl_object_emit_full(obj, emit_type, &func);
	sbuf_finish(*buf);

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


示例17: t_rename_parse

struct t_rename_pattern *
t_rename_parse(const char *source)
{
	const char sep = '%';
	const char *c = source;
	struct t_rename_pattern *pattern = NULL;
	struct t_rename_token *token;
	struct sbuf *sb = NULL;
	enum {
		PARSING_STRING,
		PARSING_SIMPLE_TAG,
		PARSING_BRACE_TAG
	} state;

	sb = sbuf_new_auto();
	if (sb == NULL)
		goto error_label;

	pattern = malloc(sizeof(struct t_rename_pattern));
	if (pattern == NULL)
		goto error_label;
	TAILQ_INIT(pattern);

	state = PARSING_STRING;
	while (*c != '\0') {
		/* if we parse a litteral string, check if this is the start of
		   a tag */
		if (state == PARSING_STRING && *c == sep) {
			/* avoid to add a empty token. This can happen when
			   when parsing two consecutive tags like `%tag%tag' */
			if (sbuf_len(sb) > 0) {
				if (sbuf_finish(sb) == -1)
					goto error_label;
				token = t_rename_token_new(T_STRING, sbuf_data(sb));
				if (token == NULL)
					goto error_label;
				TAILQ_INSERT_TAIL(pattern, token, entries);
			}
			sbuf_clear(sb);
			c += 1;
			if (*c == '{') {
				c += 1;
				state = PARSING_BRACE_TAG;
			} else {
				state = PARSING_SIMPLE_TAG;
			}
		/* if we parse a tag, check for the end of it */
		} else if ((state == PARSING_SIMPLE_TAG && (*c == sep || !isalnum(*c))) ||
		           (state == PARSING_BRACE_TAG  && *c == '}')) {
			if (sbuf_len(sb) == 0)
				warnx("empty tag in rename pattern");
			if (sbuf_finish(sb) == -1)
				goto error_label;
			token = t_rename_token_new(T_TAG, sbuf_data(sb));
			if (token == NULL)
				goto error_label;
			sbuf_clear(sb);
			TAILQ_INSERT_TAIL(pattern, token, entries);
			if (state == PARSING_BRACE_TAG) {
				/* eat the closing `}' */
				c += 1;
			}
			state = PARSING_STRING;
		} else {
			/* default case for both string and tags. `\' escape
			   everything */
			if (*c == '\\') {
				c += 1;
				if (*c == '\0')
					break;
			}
			sbuf_putc(sb, *c);
			c += 1;
		}
	}
	/* we've hit the end of the source. Check in which state we are and try
	   to finish cleany */
	switch (state) {
	case PARSING_BRACE_TAG:
		warnx("missing closing `}' at the end of the rename pattern");
		goto error_label;
	case PARSING_SIMPLE_TAG:
		if (sbuf_len(sb) == 0)
			warnx("empty tag at the end of the rename pattern");
	case PARSING_STRING: /* FALLTHROUGH */
	default:
		/* all is right */;
	}
	/* finish the last tag unless it is the empty string */
	if (state != PARSING_STRING || sbuf_len(sb) > 0) {
		if (sbuf_finish(sb) == -1)
			goto error_label;
		token = t_rename_token_new(
			    (state == PARSING_STRING ? T_STRING : T_TAG),
			    sbuf_data(sb));
		if (token == NULL)
			goto error_label;
		TAILQ_INSERT_TAIL(pattern, token, entries);
	}

//.........这里部分代码省略.........
开发者ID:kAworu,项目名称:tagutil,代码行数:101,代码来源:t_renamer.c


示例18: format_str

static void
format_str(struct pkg *pkg, struct sbuf *dest, const char *qstr, void *data)
{
	char size[7];
	const char *tmp;
	bool automatic;
	int64_t flatsize;
	lic_t licenselogic;

	sbuf_clear(dest);

	while (qstr[0] != '\0') {
		if (qstr[0] == '%') {
			qstr++;
			switch (qstr[0]) {
				case 'n':
					pkg_get(pkg, PKG_NAME, &tmp);
					sbuf_cat(dest, tmp);
					break;
				case 'v':
					pkg_get(pkg, PKG_VERSION, &tmp);
					sbuf_cat(dest, tmp);
					break;
				case 'o':
					pkg_get(pkg, PKG_ORIGIN, &tmp);
					sbuf_cat(dest, tmp);
					break;
				case 'p':
					pkg_get(pkg, PKG_PREFIX, &tmp);
					sbuf_cat(dest, tmp);
					break;
				case 'm':
					pkg_get(pkg, PKG_MAINTAINER, &tmp);
					sbuf_cat(dest, tmp);
					break;
				case 'c':
					pkg_get(pkg, PKG_COMMENT, &tmp);
					sbuf_cat(dest, tmp);
					break;
				case 'w':
					pkg_get(pkg, PKG_WWW, &tmp);
					sbuf_cat(dest, tmp);
					break;
				case 'a':
					pkg_get(pkg, PKG_AUTOMATIC, &automatic);
					sbuf_printf(dest, "%d", automatic);
					break;
				case 's':
					qstr++;
					pkg_get(pkg, PKG_FLATSIZE, &flatsize);
					if (qstr[0] == 'h') {
						humanize_number(size, sizeof(size), flatsize, "B", HN_AUTOSCALE, 0);
						sbuf_cat(dest, size);
					} else if (qstr[0] == 'b') {
						sbuf_printf(dest, "%" PRId64, flatsize);
					}
					break;
				case '?':
					qstr++;
					switch (qstr[0]) {
						case 'd':
							sbuf_printf(dest, "%d", !pkg_list_is_empty(pkg, PKG_DEPS));
							break;
						case 'r':
							sbuf_printf(dest, "%d", !pkg_list_is_empty(pkg, PKG_RDEPS));
							break;
						case 'C':
							sbuf_printf(dest, "%d", !pkg_list_is_empty(pkg, PKG_CATEGORIES));
							break;
						case 'F':
							sbuf_printf(dest, "%d", !pkg_list_is_empty(pkg, PKG_FILES));
							break;
						case 'O':
							sbuf_printf(dest, "%d", !pkg_list_is_empty(pkg, PKG_OPTIONS));
							break;
						case 'D':
							sbuf_printf(dest, "%d", !pkg_list_is_empty(pkg, PKG_DIRS));
							break;
						case 'L':
							sbuf_printf(dest, "%d", !pkg_list_is_empty(pkg, PKG_LICENSES));
							break;
						case 'U':
							sbuf_printf(dest, "%d", !pkg_list_is_empty(pkg, PKG_USERS));
							break;
						case 'G':
							sbuf_printf(dest, "%d", !pkg_list_is_empty(pkg, PKG_GROUPS));
							break;
					}
					break;
				case 'l':
					pkg_get(pkg, PKG_LICENSE_LOGIC, &licenselogic);
					switch (licenselogic) {
						case LICENSE_SINGLE:
							sbuf_cat(dest, "single");
							break;
						case LICENSE_OR:
							sbuf_cat(dest, "or");
							break;
						case LICENSE_AND:
							sbuf_cat(dest, "and");
//.........这里部分代码省略.........
开发者ID:culot,项目名称:pkgng,代码行数:101,代码来源:query.c


示例19: attempt_to_merge

static void
attempt_to_merge(bool renamed, struct pkg_config_file *rcf,
  struct pkg *local, char *pathname, const char *path, struct sbuf *newconf)
{
	const struct pkg_file *lf = NULL;
	struct pkg_config_file *lcf = NULL;

	char *localconf = NULL;
	size_t sz;
	char *localsum;

	if (!renamed) {
		pkg_debug(3, "Not renamed");
		return;
	}

	if (rcf == NULL) {
		pkg_debug(3, "No remote config file");
		return;
	}

	if (local == NULL) {
		pkg_debug(3, "No local package");
		return;
	}

	if (!pkg_is_config_file(local, path, &lf, &lcf)) {
		pkg_debug(3, "No local package");
		return;
	}

	if (lcf->content == NULL) {
		pkg_debug(3, "Empty configuration content for local package");
		return;
	}
	
	pkg_debug(1, "Config file found %s", pathname);
	file_to_buffer(pathname, &localconf, &sz);

	pkg_debug(2, "size: %d vs %d", sz, strlen(lcf->content));

	if (sz == strlen(lcf->content)) {
		pkg_debug(2, "Ancient vanilla and deployed conf are the same size testing checksum");
		localsum = pkg_checksum_data(localconf, sz,
		    PKG_HASH_TYPE_SHA256_HEX);
		if (localsum && strcmp(localsum, lf->sum) == 0) {
			pkg_debug(2, "Checksum are the same %d", strlen(localconf));
			free(localconf);
			free(localsum);
			return;
		}
		free(localsum);
		pkg_debug(2, "Checksum are different %d", strlen(localconf));
	}

	pkg_debug(1, "Attempting to merge %s", pathname);
	if (merge_3way(lcf->content, localconf, rcf->content, newconf) != 0) {
		pkg_emit_error("Impossible to merge configuration file");
		sbuf_clear(newconf);
		strlcat(pathname, ".pkgnew", MAXPATHLEN);
	}
	free(localconf);
}
开发者ID:WorldofOpenDev,项目名称:pkg,代码行数:63,代码来源:pkg_add.c


示例20: do_extract

static int
do_extract(struct archive *a, struct archive_entry *ae, const char *location,
    int nfiles, struct pkg *pkg, struct pkg *local)
{
	int	retcode = EPKG_OK;
	int	ret = 0, cur_file = 0;
	char	path[MAXPATHLEN], pathname[MAXPATHLEN], rpath[MAXPATHLEN];
	struct stat st;
	const struct stat *aest;
	bool renamed = false;
	const struct pkg_file *rf;
	struct pkg_config_file *rcf;
	struct sbuf *newconf;
	bool automerge = pkg_object_bool(pkg_config_get("AUTOMERGE"));
	unsigned long set, clear;

#ifndef HAVE_ARC4RANDOM
	srand(time(NULL));
#endif

	if (nfiles == 0)
		return (EPKG_OK);

	pkg_emit_extract_begin(pkg);
	pkg_emit_progress_start(NULL);

	newconf = sbuf_new_auto();

	do {
		ret = ARCHIVE_OK;
		sbuf_clear(newconf);
		rf = NULL;
		rcf = NULL;
		pkg_absolutepath(archive_entry_pathname(ae), path, sizeof(path));
		snprintf(pathname, sizeof(pathname), "%s%s%s",
		    location ? location : "", *path == '/' ? "" : "/",
		    path
		);
		strlcpy(rpath, pathname, sizeof(rpath));

		aest = archive_entry_stat(ae);
		archive_entry_fflags(ae, &set, &clear);
		if (lstat(rpath, &st) != -1) {
			/*
			 * We have an existing file on the path, so handle it
			 */
			if (!S_ISDIR(aest->st_mode)) {
				pkg_debug(2, "Old version found, renaming");
				pkg_add_file_random_suffix(rpath, sizeof(rpath), 12);
				renamed = true;
			}

			if (!S_ISDIR(st.st_mode) && S_ISDIR(aest->st_mode)) {
				if (S_ISLNK(st.st_mode)) {
					if (stat(rpath, &st) == -1) {
						pkg_emit_error("Dead symlink %s", rpath);
					} else {
						pkg_debug(2, "Directory is a symlink, use it");
						pkg_emit_progress_tick(cur_file++, nfiles);
						continue;
					}
				}
			}
		}

		archive_entry_set_pathname(ae, rpath);

		/* load in memory the content of config files */
		if (pkg_is_config_file(pkg, path, &rf, &rcf)) {
			pkg_debug(1, "Populating config_file %s", pathname);
			size_t len = archive_entry_size(ae);
			rcf->content = malloc(len);
			archive_read_data(a, rcf->content, len);
			if (renamed && (!automerge || local == NULL))
				strlcat(pathname, ".pkgnew", sizeof(pathname));
		}

		/*
		 * check if the file is already provided by previous package
		 */
		if (!automerge)
			attempt_to_merge(renamed, rcf, local, pathname, path, newconf);

		if (sbuf_len(newconf) == 0 && (rcf == NULL || rcf->content == NULL)) {
			pkg_debug(1, "Extracting: %s", archive_entry_pathname(ae));
			int install_as_user = (getenv("INSTALL_AS_USER") != NULL);
			int extract_flags = EXTRACT_ARCHIVE_FLAGS;
			if (install_as_user) {
				/* when installing as user don't try to set file ownership */
				extract_flags &= ~ARCHIVE_EXTRACT_OWNER;
			}
			ret = archive_read_extract(a, ae, extract_flags);
		} else {
			if (sbuf_len(newconf) == 0) {
				sbuf_cat(newconf, rcf->content);
				sbuf_finish(newconf);
			}
			pkg_debug(2, "Writing conf in %s", pathname);
			unlink(rpath);
			FILE *f = fopen(rpath, "w+");
//.........这里部分代码省略.........
开发者ID:WorldofOpenDev,项目名称:pkg,代码行数:101,代码来源:pkg_add.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ sbuf_data函数代码示例发布时间:2022-05-30
下一篇:
C++ sbspace函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap