本文整理汇总了C++中Fclose函数的典型用法代码示例。如果您正苦于以下问题:C++ Fclose函数的具体用法?C++ Fclose怎么用?C++ Fclose使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Fclose函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: printf
//------------------------------------------------------------------
void Error::FileA(const char *class_name, const char *func_name,
const char *file_name) // file name
{
FILE *fp;
error_func_name = "FileA";
printf(error_string[file_a], class_name, func_name, file_name);
if( (fp = Fopen(ALL_NODES,error_file_name, "w")) == NULL ) {
printf(error_string[file_w], error_class_name, error_func_name, error_file_name);
Exit(exit_value[file_w]);
}
Fprintf(fp, error_string[file_a], class_name, func_name, file_name);
Fclose(fp);
Exit(exit_value[file_a]);
}
示例2: rpmwfFini
rpmRC rpmwfFini(rpmwf wf)
{
int xx;
if (_rpmwf_debug)
fprintf(stderr, "==> rpmwfFini(%p)\n", wf);
if (wf->b && wf->b != (void *)-1) {
xx = munmap(wf->b, wf->nb);
wf->b = NULL;
}
if (wf->fd) {
(void) Fclose(wf->fd);
wf->fd = NULL;
}
return RPMRC_OK;
}
示例3: load
/*
* Load a file of user definitions.
*/
void
load(char *name)
{
FILE *in, *oldin;
if ((in = Fopen(name, "r")) == NULL)
return;
oldin = input;
input = in;
loading = 1;
sourcing = 1;
commands();
loading = 0;
sourcing = 0;
input = oldin;
(void)Fclose(in);
}
示例4: makeGPGSignature
/**
* Generate GPG signature(s) for a header+payload file.
* @param sigh signature header
* @param ishdr header-only signature?
* @param sigt signature target
* @param passPhrase private key pass phrase
* @return 0 on success, 1 on failure
*/
static int makeGPGSignature(Header sigh, int ishdr, sigTarget sigt)
{
char * sigfile = rstrscat(NULL, sigt->fileName, ".sig", NULL);
struct stat st;
uint8_t * pkt = NULL;
size_t pktlen = 0;
int rc = 1; /* assume failure */
if (runGPG(sigt, sigfile))
goto exit;
if (stat(sigfile, &st)) {
/* GPG failed to write signature */
rpmlog(RPMLOG_ERR, _("gpg failed to write signature\n"));
goto exit;
}
pktlen = st.st_size;
rpmlog(RPMLOG_DEBUG, "GPG sig size: %zd\n", pktlen);
pkt = xmalloc(pktlen);
{ FD_t fd;
rc = 0;
fd = Fopen(sigfile, "r.ufdio");
if (fd != NULL && !Ferror(fd)) {
rc = Fread(pkt, sizeof(*pkt), pktlen, fd);
(void) Fclose(fd);
}
if (rc != pktlen) {
rpmlog(RPMLOG_ERR, _("unable to read the signature\n"));
goto exit;
}
}
rpmlog(RPMLOG_DEBUG, "Got %zd bytes of GPG sig\n", pktlen);
/* Parse the signature, change signature tag as appropriate. */
rc = putSignature(sigh, ishdr, pkt, pktlen);
exit:
(void) unlink(sigfile);
free(sigfile);
free(pkt);
return rc;
}
示例5: F_close
F_close()
{
register char wRetStat;
register int iocb16, iocb;
iocb16 = reg_X;
iocb = iocb16 >> 4;
Fclose(rgwDOShand[iocb]);
rgwDOShand[iocb] = -1;
wRetStat = 1;
reg_Y = wRetStat;
reg_Z = wRetStat;
reg_N = (wRetStat & 0x80) ? TRUE : FALSE;
reg_PC = 0xE45B;
}
示例6: Fopen
void RpmTransaction::addToTransactionInstall(const StringVector& files)
{
for (StringVector::size_type i = 0;i < files.size();i++)
{
FD_t fd = Fopen(files[i].c_str(), "r.ufdio");
if (fd == NULL)
throw PkgBackEndException("Fopen(" + files[i] + ")");
Header hdr;
int rc = rpmReadPackageHeader(fd, &hdr, 0, NULL, NULL);
if (rc != 0)
throw PkgBackEndException("rpmReadPackageHeader()");
rc = rpmtransAddPackage(m_ts, hdr, NULL, files[i].c_str(), 0, 0);
if (rc != 0)
throw PkgBackEndException("rpmtransAddPackage()");
headerFree(hdr);
Fclose(fd);
}
}
示例7: Fopen
void RpmTransaction::addToTransactionUpgrade(const StringVector& files)
{
for (StringVector::size_type i = 0;i < files.size();i++)
{
FD_t fd = Fopen(files[i].c_str(), "r.ufdio");
if (fd == NULL)
RPMSTOP("Fopen()");
Header hdr;
int rc = rpmReadPackageHeader(fd, &hdr, 0, NULL, NULL);
if (rc != 0)
RPMSTOP("rpmReadPackageHeader()");
rc = rpmtransAddPackage(m_ts, hdr, NULL, files[i].c_str(), 1, 0);
if (rc != 0)
RPMSTOP("rpmtransAddPackage()");
headerFree(hdr);
Fclose(fd);
}
}
示例8: main
int main(int argc, char* argv[])
{
FILE *fp;
const char *file = "kj2010030144.txt";
char buf[500];
int len;
memset(buf, 0, sizeof(buf));
fp = Fopen(file, "r");
Fgets(buf, 500, fp);
len = strlen(buf) - 1;
buf[len] = 0;
printf("%s", buf);
Fclose(fp);
return 0;
}
示例9: ReadTestFile
//###################################################################################
void ReadTestFile(char *name, unsigned char *buf, U16 bufsize)
//###################################################################################
{
unsigned long i;
S16 fileid;
fileid=Fopen("01.TXT",F_READ);
if(fileid>=0 && fileid<MAX_OPEN_FILE)
{
StartTimer();
for(i=0; i<TEST_FILE_SIZE; i+=bufsize)
{
if(Fread(buf,bufsize,fileid)!=bufsize) break;
}
Fclose(fileid);
printf("% 3lu",(U32)bufsize);
StopTimer();
}
}
示例10: mesedit
/*
* Edit the message being collected on fp.
* On return, make the edit file the new temp file.
*/
static void
mesedit(int c, struct header *hp)
{
sighandler_type sigint = safe_signal(SIGINT, SIG_IGN);
FILE *nf = run_editor(collf, (off_t)-1, c, 0, hp, NULL, SEND_MBOX,
sigint);
if (nf != NULL) {
if (hp) {
rewind(nf);
makeheader(nf, hp);
} else {
fseek(nf, 0L, SEEK_END);
Fclose(collf);
collf = nf;
}
}
safe_signal(SIGINT, sigint);
}
示例11: resetdccs
int resetdccs(){
short temp=9;
while(temp>-1){
if(dcc[temp].dcfh){Fclose(dcc[temp].dcfh);dcc[temp].dcfh=-1;}
if(dcc[temp].cn)TCP_close(dcc[temp].cn,1);
strcpy(dcc[temp].avec,"\0");
strcpy(dcc[temp].fname,"\0");
dcc[temp].cn=0;
dcc[temp].dcfh=-1;
dcc[temp].stat=0;
dcc[temp].cnt=0;
dcc[temp].lack=0;
dcc[temp].dir=-1;
temp--;
}
return 0;
}
示例12: rpmcliVerify
int rpmcliVerify(rpmts ts, QVA_t qva, char * const * argv)
{
rpmVSFlags vsflags, ovsflags;
int ec = 0;
FD_t scriptFd = fdDup(STDOUT_FILENO);
/*
* Open the DB + indices explicitly before possible chroot,
* otherwises BDB is going to be unhappy...
*/
rpmtsOpenDB(ts, O_RDONLY);
rpmdbOpenAll(rpmtsGetRdb(ts));
if (rpmChrootSet(rpmtsRootDir(ts)) || rpmChrootIn()) {
ec = 1;
goto exit;
}
if (qva->qva_showPackage == NULL)
qva->qva_showPackage = showVerifyPackage;
vsflags = rpmExpandNumeric("%{?_vsflags_verify}");
vsflags |= rpmcliVSFlags;
vsflags &= ~RPMVSF_NEEDPAYLOAD;
rpmtsSetScriptFd(ts, scriptFd);
ovsflags = rpmtsSetVSFlags(ts, vsflags);
ec = rpmcliArgIter(ts, qva, argv);
rpmtsSetVSFlags(ts, ovsflags);
rpmtsSetScriptFd(ts, NULL);
if (qva->qva_showPackage == showVerifyPackage)
qva->qva_showPackage = NULL;
rpmtsEmpty(ts);
if (rpmChrootOut() || rpmChrootSet(NULL))
ec = 1;
exit:
Fclose(scriptFd);
return ec;
}
示例13: rpmPackageFilesArchive
static int rpmPackageFilesArchive(rpmfiles fi, int isSrc,
FD_t cfd, ARGV_t dpaths,
rpm_loff_t * archiveSize, char ** failedFile)
{
int rc = 0;
rpmfi archive = rpmfiNewArchiveWriter(cfd, fi);
while (!rc && (rc = rpmfiNext(archive)) >= 0) {
/* Copy file into archive. */
FD_t rfd = NULL;
const char *path = dpaths[rpmfiFX(archive)];
rfd = Fopen(path, "r.ufdio");
if (Ferror(rfd)) {
rc = RPMERR_OPEN_FAILED;
} else {
rc = rpmfiArchiveWriteFile(archive, rfd);
}
if (rc && failedFile)
*failedFile = xstrdup(path);
if (rfd) {
/* preserve any prior errno across close */
int myerrno = errno;
Fclose(rfd);
errno = myerrno;
}
}
if (rc == RPMERR_ITER_END)
rc = 0;
/* Finish the payload stream */
if (!rc)
rc = rpmfiArchiveClose(archive);
if (archiveSize)
*archiveSize = (rc == 0) ? rpmfiArchiveTell(archive) : 0;
rpmfiFree(archive);
return rc;
}
示例14: wfd_close
static void wfd_close(FD_t *wfdp)
{
if (wfdp && *wfdp) {
int myerrno = errno;
static int oneshot = 0;
static int flush_io = 0;
if (!oneshot) {
flush_io = rpmExpandNumeric("%{?_flush_io}");
oneshot = 1;
}
if (flush_io) {
int fdno = Fileno(*wfdp);
fsync(fdno);
}
Fclose(*wfdp);
*wfdp = NULL;
errno = myerrno;
}
}
示例15: read_labels
mnist_labels_t read_labels(uint32_t train)
{
char *full_path;
if (train) {
full_path = concat_fname(mnist_path, train_label_fname);
} else {
full_path = concat_fname(mnist_path, test_label_fname);
}
char *mode = FILE_MODE;
FILE *fp = Fopen(full_path, mode);
uint8_t header[LABEL_HEADER_SIZE];
Fread(header, sizeof(uint8_t), LABEL_HEADER_SIZE, fp);
uint32_t num_labels = read_word(header, NUM_ITEMS_OFFSET);
vector_t lbls = Vector((size_t) num_labels);
uint8_t *label_bytes = (uint8_t*) Calloc(num_labels, sizeof(uint8_t));
uint32_t actual_size;
if ((actual_size = fread(label_bytes, sizeof(uint8_t), num_labels, fp)) < num_labels) {
Free(label_bytes);
vector_destroy(lbls);
return NULL;
}
uint32_t *vector_data = (uint32_t*) Calloc(num_labels, sizeof(uint32_t));
for (uint32_t i = 0; i < num_labels; i++) {
vector_data[i] = (uint32_t) label_bytes[i];
}
lbls->data = vector_data;
mnist_labels_t mnist_lbls = Mnist_labels((size_t) num_labels);
mnist_lbls->labels = lbls;
Free(full_path);
Free(label_bytes);
Fclose(fp);
return mnist_lbls;
}