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

C++ close_fp函数代码示例

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

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



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

示例1: make_rev_sig

static int make_rev_sig(const char *dst, const char *sig, const char *endfile, int compression, struct cntr *cntr)
{
	FILE *dstfp=NULL;
	gzFile dstzp=NULL;
	FILE *sigp=NULL;
	rs_result result;
//logp("make rev sig: %s %s\n", dst, sig);

	if(dpth_is_compressed(compression, dst))
		dstzp=gzopen_file(dst, "rb");
	else
		dstfp=open_file(dst, "rb");

	if((!dstzp && !dstfp)
	  || !(sigp=open_file(sig, "wb")))
	{
		gzclose_fp(&dstzp);
		close_fp(&dstfp);
		return -1;
	}
	result=rs_sig_gzfile(dstfp, dstzp, sigp,
		get_librsync_block_len(endfile),
		RS_DEFAULT_STRONG_LEN, NULL, cntr);
	gzclose_fp(&dstzp);
	close_fp(&dstfp);
	close_fp(&sigp);
//logp("end of make rev sig\n");
	return result;
}
开发者ID:tcheneau,项目名称:burp,代码行数:29,代码来源:backup_phase4_server.c


示例2: ncp_put_super

static void
ncp_put_super(struct super_block *sb)
{
        struct ncp_server *server = NCP_SBP(sb);

	lock_super(sb);

	ncp_lock_server(server);
        ncp_disconnect(server);
	ncp_unlock_server(server);

	close_fp(server->ncp_filp);

	ncp_dont_catch_watchdog(server);
	close_fp(server->wdog_filp);
	close_fp(server->msg_filp);

        ncp_free_all_inodes(server);

        ncp_kfree_s(server->packet, server->packet_size);

	sb->s_dev = 0;
        ncp_kfree_s(NCP_SBP(sb), sizeof(struct ncp_server));
	NCP_SBP(sb) = NULL;

	unlock_super(sb);

        MOD_DEC_USE_COUNT;
}
开发者ID:shattered,项目名称:linux-m68k,代码行数:29,代码来源:inode.c


示例3: make_rev_sig

static int make_rev_sig(const char *dst, const char *sig, const char *endfile,
	int compression, struct conf *conf)
{
	int ret=-1;
	FILE *dstfp=NULL;
	gzFile dstzp=NULL;
	FILE *sigp=NULL;
//logp("make rev sig: %s %s\n", dst, sig);

	if(dpthl_is_compressed(compression, dst))
		dstzp=gzopen_file(dst, "rb");
	else
		dstfp=open_file(dst, "rb");

	if((!dstzp && !dstfp)
	  || !(sigp=open_file(sig, "wb"))
	  || rs_sig_gzfile(NULL, dstfp, dstzp, sigp,
		get_librsync_block_len(endfile),
		RS_DEFAULT_STRONG_LEN, NULL, conf->cntr)!=RS_DONE)
			goto end;
	ret=0;
end:
//logp("end of make rev sig\n");
	gzclose_fp(&dstzp);
	close_fp(&dstfp);
	if(close_fp(&sigp))
	{
		logp("error closing %s in %s\n", sig, __func__);
		return -1;
	}
	return ret;
}
开发者ID:Sherlock221B,项目名称:burp,代码行数:32,代码来源:backup_phase4.c


示例4: compress

static int compress(const char *src, const char *dst, struct config *cconf)
{
	int res;
	int got;
	FILE *mp=NULL;
	gzFile zp=NULL;
	char buf[ZCHUNK];

	if(!(mp=open_file(src, "rb"))
	  || !(zp=gzopen_file(dst, comp_level(cconf))))
	{
		close_fp(&mp);
		gzclose_fp(&zp);
		return -1;
	}
	while((got=fread(buf, 1, sizeof(buf), mp))>0)
	{
		res=gzwrite(zp, buf, got);
		if(res!=got)
		{
			logp("compressing manifest - read %d but wrote %d\n",
				got, res);
			close_fp(&mp);
			gzclose_fp(&zp);
			return -1;
		}
	}
	close_fp(&mp);
	return gzclose_fp(&zp); // this can give an error when out of space
}
开发者ID:barroque,项目名称:burp,代码行数:30,代码来源:current_backups_server.c


示例5: rewrite_client_conf

/* Rewrite the config file with the ssl_peer_cn value changed to what the
   server told us it should be. */
static int rewrite_client_conf(struct config *conf)
{
	int ret=-1;
	char p[32]="";
	FILE *dp=NULL;
	FILE *sp=NULL;
	char *tmp=NULL;
	char buf[4096]="";

	logp("Rewriting config file: %s\n", conf->configfile);
	snprintf(p, sizeof(p), ".%d", getpid());
	if(!(tmp=prepend(conf->configfile, p, strlen(p), "")))
		goto end;
	if(!(sp=open_file(conf->configfile, "rb"))
	  || !(dp=open_file(tmp, "wb")))
		goto end;

	while(fgets(buf, sizeof(buf), sp))
	{
		char *copy=NULL;
		char *field=NULL;
		char *value=NULL;

		if(!(copy=strdup(buf)))
		{
			logp("out of memory\n");
			goto end;
		}
		if(config_get_pair(buf, &field, &value)
		  || !field || !value
		  || strcmp(field, "ssl_peer_cn"))
		{
			fprintf(dp, "%s", copy);
			free(copy);
			continue;
		}
		free(copy);

		fprintf(dp, "ssl_peer_cn = %s\n", conf->ssl_peer_cn);
	}
	close_fp(&sp);
	close_fp(&dp);
#ifdef HAVE_WIN32
	// Need to delete the destination, or Windows gets upset.
	unlink(conf->configfile);
#endif
	if(do_rename(tmp, conf->configfile)) goto end;

	ret=0;
end:
	close_fp(&sp);
	close_fp(&dp);
	if(ret)
	{
		logp("Rewrite failed\n");
		unlink(tmp);
	}
	if(tmp) free(tmp);
	return ret;
}
开发者ID:tcheneau,项目名称:burp,代码行数:62,代码来源:ca_client.c


示例6: inflate_or_link_oldfile

static int inflate_or_link_oldfile(const char *oldpath, const char *infpath)
{
	int ret=0;
	struct stat statp;

	if(lstat(oldpath, &statp))
	{
		logp("could not lstat %s\n", oldpath);
		return -1;
	}

	if(dpth_is_compressed(oldpath))
	{
		FILE *source=NULL;
		FILE *dest=NULL;

		//logp("inflating...\n");

		if(!(dest=open_file(infpath, "wb")))
		{
			close_fp(&dest);
			return -1;
		}

		if(!statp.st_size)
		{
			// Empty file - cannot inflate.
			// just close the destination and we have duplicated a
			// zero length file.
			logp("asked to inflate zero length file: %s\n", oldpath);
			close_fp(&dest);
			return 0;
		}

		if(!(source=open_file(oldpath, "rb")))
		{
			close_fp(&dest);
			return -1;
		}

		if((ret=zlib_inflate(source, dest))!=Z_OK)
			logp("zlib_inflate returned: %d\n", ret);

		close_fp(&source);
		close_fp(&dest);
	}
	else
	{
		// Not compressed - just hard link it.
		if(link(oldpath, infpath))
		{
			logp("hardlink %s to %s failed: %s\n",
				infpath, oldpath, strerror(errno));
			ret=-1;
		}
	}
	return ret;
}
开发者ID:fenio,项目名称:burp,代码行数:58,代码来源:restore_server.c


示例7: make_rev_delta

static int make_rev_delta(const char *src, const char *sig, const char *del,
	int compression, struct conf *cconf)
{
	int ret=-1;
	FILE *srcfp=NULL;
	FILE *delfp=NULL;
	FILE *sigp=NULL;
	gzFile srczp=NULL;
	gzFile delzp=NULL;
	rs_signature_t *sumset=NULL;

//logp("make rev delta: %s %s %s\n", src, sig, del);
	if(!(sigp=open_file(sig, "rb"))) goto end;

	if(rs_loadsig_file(sigp, &sumset, NULL)!=RS_DONE
	  || rs_build_hash_table(sumset)!=RS_DONE)
		goto end;

//logp("make rev deltb: %s %s %s\n", src, sig, del);

	if(dpthl_is_compressed(compression, src))
		srczp=gzopen_file(src, "rb");
	else
		srcfp=open_file(src, "rb");

	if(!srczp && !srcfp) goto end;

	if(cconf->compression)
		delzp=gzopen_file(del, comp_level(cconf));
	else
		delfp=open_file(del, "wb");
	if(!delzp && !delfp) goto end;

	if(rs_delta_gzfile(NULL, sumset, srcfp, srczp,
		delfp, delzp, NULL, cconf->cntr)!=RS_DONE)
			goto end;
	ret=0;
end:
	if(sumset) rs_free_sumset(sumset);
	gzclose_fp(&srczp);
	close_fp(&srcfp);
	close_fp(&sigp);
	if(gzclose_fp(&delzp))
	{
		logp("error closing zp %s in %s\n", del, __func__);
		ret=-1;
	}
	if(close_fp(&delfp))
	{
		logp("error closing fp %s in %s\n", del, __func__);
		ret=-1;
	}
	return ret;
}
开发者ID:Sherlock221B,项目名称:burp,代码行数:54,代码来源:backup_phase4.c


示例8: do_patch

// Also used by backup_phase4_server.c
int do_patch(const char *dst, const char *del, const char *upd, bool gzupd, struct cntr *cntr, struct config *cconf)
{
	FILE *dstp=NULL;
	FILE *delfp=NULL;
	gzFile delzp=NULL;
	gzFile updp=NULL;
	FILE *updfp=NULL;
	rs_result result;

	//logp("patching...\n");

	if(!(dstp=fopen(dst, "rb")))
	{
		logp("could not open %s for reading\n", dst);
		return -1;
	}

	if(dpth_is_compressed(del))
		delzp=gzopen(del, "rb");
	else
		delfp=fopen(del, "rb");

	if(!delzp && !delfp)
	{
		logp("could not open %s for reading\n", del);
		close_fp(&dstp);
		return -1;
	}

	if(gzupd)
		updp=gzopen(upd, comp_level(cconf));
	else
		updfp=fopen(upd, "wb");

	if(!updp && !updfp)
	{
		logp("could not open %s for writing\n", upd);
		close_fp(&dstp);
		gzclose_fp(&delzp);
		close_fp(&delfp);
		return -1;
	}
	
	result=rs_patch_gzfile(dstp, delfp, delzp, updfp, updp, NULL, cntr);

	fclose(dstp);
	gzclose_fp(&delzp);
	close_fp(&delfp);
	if(updp) gzclose_fp(&updp);
	if(updfp) fclose(updfp);

	return result;
}
开发者ID:fenio,项目名称:burp,代码行数:54,代码来源:restore_server.c


示例9: manio_read_fcount

int manio_read_fcount(struct manio *manio)
{
	int ret=-1;
	size_t s;
	FILE *fp=NULL;
	char *path=NULL;
	char buf[16]="";
	if(!(path=get_fcount_path(manio))
	  || !(fp=open_file(path, "rb")))
		goto end;
	if(!fgets(buf, sizeof(buf), fp))
	{
		logp("fgets on %s failed\n", path);
		goto end;
	}
	s=strlen(buf);
	if(s!=9)
	{
		logp("data in %s is not the right length (%s!=9)\n", s);
		goto end;
	}
	manio->offset.fcount=strtoul(buf, NULL, 16);
	ret=0;
end:
	close_fp(&fp);
	free_w(&path);
	return ret;
}
开发者ID:adrianimboden,项目名称:burp,代码行数:28,代码来源:manio.c


示例10: incexc_matches

static int incexc_matches(const char *fullrealwork, const char *incexc)
{
	int ret=0;
	int got=0;
	FILE *fp=NULL;
	char buf[4096]="";
	const char *inc=NULL;
	char *old_incexc_path=NULL;
	if(!(old_incexc_path=prepend_s(fullrealwork, "incexc")))
		return -1;
	if(!(fp=open_file(old_incexc_path, "rb")))
	{
		// Assume that no incexc file could be found because the client
		// was on an old version. Assume resume is OK and return 1.
		ret=1;
		goto end;
	}
	inc=incexc;
	while((got=fread(buf, 1, sizeof(buf), fp))>0)
	{
		if(strlen(inc)<(size_t)got) break;
		if(strncmp(buf, inc, got)) break;
		inc+=got;
	}
	if(inc && strlen(inc)) ret=0;
	else ret=1;
end:
	close_fp(&fp);
	free(old_incexc_path);
	return ret;
}
开发者ID:jkniiv,项目名称:burp,代码行数:31,代码来源:run_action.c


示例11: zlib_inflate

int zlib_inflate(struct asfd *asfd, const char *source,
	const char *dest, struct conf *conf)
{
	int ret=-1;
	size_t b=0;
	FILE *fp=NULL;
	gzFile zp=NULL;
	unsigned char in[ZCHUNK];

	if(!(zp=gzopen_file(source, "rb")))
	{
		logw(asfd, conf, "could not open %s in %s\n", source, __func__);
		goto end;
	}
	if(!(fp=open_file(dest, "wb")))
	{
		logw(asfd, conf, "could not open %s in %s: %s\n",
			dest, __func__, strerror(errno));
		goto end;
	}
	while((b=gzread(zp, in, ZCHUNK))>0)
	{
		if(fwrite(in, 1, b, fp)!=b)
		{
			logw(asfd, conf, "error when writing to %s\n", dest);
			goto end;
		}
	}
	if(!gzeof(zp))
	{
		logw(asfd, conf,
			"error while gzreading %s in %s\n", source, __func__);
		goto end;
	}
	if(close_fp(&fp))
	{
		logw(asfd, conf,
			"error when closing %s in %s: %s\n",
				dest, __func__, strerror(errno));
		goto end;
	}
	ret=0;
end:
	gzclose_fp(&zp);
	close_fp(&fp);
	return ret;
}
开发者ID:jkniiv,项目名称:burp,代码行数:47,代码来源:zlibio.c


示例12: do_patch

// Also used by restore.c.
// FIX THIS: This stuff is very similar to make_rev_delta, can maybe share
// some code.
int do_patch(struct asfd *asfd, const char *dst, const char *del,
	const char *upd, bool gzupd, int compression, struct conf *cconf)
{
	FILE *dstp=NULL;
	FILE *delfp=NULL;
	gzFile delzp=NULL;
	gzFile updp=NULL;
	FILE *updfp=NULL;
	rs_result result=RS_IO_ERROR;

	//logp("patching...\n");

	if(!(dstp=open_file(dst, "rb"))) goto end;

	if(dpthl_is_compressed(compression, del))
		delzp=gzopen_file(del, "rb");
	else
		delfp=open_file(del, "rb");

	if(!delzp && !delfp) goto end;

	if(gzupd)
		updp=gzopen(upd, comp_level(cconf));
	else
		updfp=fopen(upd, "wb");

	if(!updp && !updfp) goto end;

	result=rs_patch_gzfile(asfd,
		dstp, delfp, delzp, updfp, updp, NULL, cconf->cntr);
end:
	close_fp(&dstp);
	gzclose_fp(&delzp);
	close_fp(&delfp);
	if(close_fp(&updfp))
	{
		logp("error closing %s in %s\n", upd, __func__);
		result=RS_IO_ERROR;
	}
	if(gzclose_fp(&updp))
	{
		logp("error gzclosing %s in %s\n", upd, __func__);
		result=RS_IO_ERROR;
	}
	return result;
}
开发者ID:Sherlock221B,项目名称:burp,代码行数:49,代码来源:backup_phase4.c


示例13: close_file_for_send

int close_file_for_send(BFILE *bfd, FILE **fp)
{
	if(fp) return close_fp(fp);
#ifdef HAVE_WIN32
	if(bfd) return bclose(bfd);
#endif
	return -1;
}
开发者ID:goneri,项目名称:burp,代码行数:8,代码来源:handy.c


示例14: nfs_put_super

void nfs_put_super(struct super_block *sb)
{
        /* No locks should be open on this, so 0 should be safe as a fd. */
	close_fp(sb->u.nfs_sb.s_server.file, 0);
	lock_super(sb);
	sb->s_dev = 0;
	unlock_super(sb);
}
开发者ID:wanggx,项目名称:Linux1.0,代码行数:8,代码来源:inode.c


示例15: dpth_release_all

int dpth_release_all(struct dpth *dpth)
{
	int ret=0;
	if(!dpth) return 0;
	if(dpth->fp && close_fp(&dpth->fp)) ret=-1;
	while(dpth->head) if(release_and_move_to_next_in_list(dpth)) ret=-1;
	return ret;
}
开发者ID:Kalimeiro,项目名称:burp,代码行数:8,代码来源:dpth.c


示例16: nfs_put_super

void nfs_put_super(struct super_block *sb)
{
	close_fp(sb->u.nfs_sb.s_server.file);
	rpc_closesock(sb->u.nfs_sb.s_server.rsock);
	lock_super(sb);
	sb->s_dev = 0;
	unlock_super(sb);
	MOD_DEC_USE_COUNT;
}
开发者ID:shattered,项目名称:linux-m68k,代码行数:9,代码来源:inode.c


示例17: copy_path_to_File

static int copy_path_to_File(const char *src, FILE *dp)
{
	size_t b=0;
	size_t w=0;
	unsigned char in[ZCHUNK];
	FILE *sp=NULL;

	if(!(sp=open_file(src, "rb")))
		return -1;

	if(copy_File_to_File(sp, dp))
	{
		close_fp(&sp);
		return -1;
	}

	close_fp(&sp);
	return 0;
}
开发者ID:bassu,项目名称:burp,代码行数:19,代码来源:backup_phase2_server.c


示例18: cntr_stats_to_file

int cntr_stats_to_file(struct cntr *cntr,
	const char *directory, enum action act)
{
	int x=0;
	int ret=-1;
	FILE *fp;
	char *path;
	time_t now;
	const char *fname=NULL;

	if(act==ACTION_BACKUP
	  ||  act==ACTION_BACKUP_TIMED)
		fname="backup_stats";
	else if(act==ACTION_RESTORE)
		fname="restore_stats";
	else if(act==ACTION_VERIFY)
		fname="verify_stats";
	else
		return 0;

	now=time(NULL);

	if(!(path=prepend_s(directory, fname))
	  || !(fp=open_file(path, "wb")))
		goto end;

	fprintf(fp, "client:%s\n", cntr->cname);
	fprintf(fp, "time_start:%lu\n", cntr->start);
	fprintf(fp, "time_end:%lu\n", now);
	fprintf(fp, "time_taken:%lu\n", now-cntr->start);
	for(x=0; x<cntr->colen; x++)
		quint_print_to_file(fp,
			cntr->ent[(uint8_t)cntr->cmd_order[x]], act);

	bottom_part_to_file(cntr, fp, act);

	if(close_fp(&fp)) goto end;
	ret=0;
end:
	free(path);
	close_fp(&fp);
	return ret;
}
开发者ID:jkniiv,项目名称:burp,代码行数:43,代码来源:cntr.c


示例19: _close_allfiles

void _close_allfiles(void)
{
    register struct file *filp;
    register char *pi = 0;

    do {
	if ((filp = current->files.fd[(int) pi])) {
	    current->files.fd[(int) pi] = NULL;
	    close_fp(filp);
	}
    } while (((int)(++pi)) < NR_OPEN);
}
开发者ID:foolsh,项目名称:elks,代码行数:12,代码来源:open.c


示例20: deal_with_receive_end_file

static int deal_with_receive_end_file(struct asfd *asfd, struct sdirs *sdirs,
	struct sbuf *rb, FILE *p2fp, struct conf *cconf, char **last_requested)
{
	static char *cp=NULL;
	static struct iobuf *rbuf;
	rbuf=asfd->rbuf;
	// Finished the file.
	// Write it to the phase2 file, and free the buffers.

	if(close_fp(&(rb->burp1->fp)))
	{
		logp("error closing delta for %s in receive\n", rb->path);
		goto error;
	}
	if(gzclose_fp(&(rb->burp1->zp)))
	{
		logp("error gzclosing delta for %s in receive\n", rb->path);
		goto error;
	}
	iobuf_copy(&rb->burp1->endfile, rbuf);
	rbuf->buf=NULL;
	if(rb->flags & SBUFL_RECV_DELTA && finish_delta(sdirs, rb))
		goto error;

	if(sbufl_to_manifest(rb, p2fp, NULL))
		goto error;

	if(rb->flags & SBUFL_RECV_DELTA)
		cntr_add_changed(cconf->cntr, rb->path.cmd);
	else
		cntr_add(cconf->cntr, rb->path.cmd, 0);

	if(*last_requested && !strcmp(rb->path.buf, *last_requested))
	{
		free(*last_requested);
		*last_requested=NULL;
	}

	cp=strchr(rb->burp1->endfile.buf, ':');
	if(rb->burp1->endfile.buf)
		cntr_add_bytes(cconf->cntr,
			strtoull(rb->burp1->endfile.buf, NULL, 10));
	if(cp)
	{
		// checksum stuff goes here
	}

	sbuf_free_content(rb);
	return 0;
error:
	sbuf_free_content(rb);
	return -1;
}
开发者ID:jkniiv,项目名称:burp,代码行数:53,代码来源:backup_phase2.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ close_handle函数代码示例发布时间:2022-05-30
下一篇:
C++ close_files函数代码示例发布时间: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