示例#1
0
//------------------------------------------------------------------
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
0
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
0
文件: lex.c 项目: coyizumi/cs111
/*
 * 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
0
文件: rpmgensig.c 项目: jwakely/rpm
/**
 * 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
0
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
0
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
0
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
0
文件: file.c 项目: bsdcpp/mylib
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
0
//------------------------------------------------------------------
void Error::Pointer(const char *class_name, const char *func_name,
                    const char *ptr_name)
{
    FILE *fp;
    error_func_name = "Pointer";

    printf(error_string[pointer], class_name, func_name, ptr_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[pointer], class_name, func_name, ptr_name);
    Fclose(fp);

    Exit(exit_value[pointer]);

}
示例#10
0
void RpmTransaction::addToTransactionUpgrade(const StringToStringMap& files)
{
  for (StringToStringMap::const_iterator it = files.begin();it != files.end();it++)
    {
      FD_t fd = Fopen(it->second.c_str(), "r.ufdio");
      if (fd == NULL)
	throw PkgBackEndException("Fopen(" + it->second + ")");
      Header hdr;
      int rc = rpmReadPackageHeader(fd, &hdr, 0, NULL, NULL);
      if (rc != 0)
	throw PkgBackEndException("rpmReadPackageHeader()");
      rc = rpmtransAddPackage(m_ts, hdr, NULL, it->second.c_str(), 1, 0);
      if (rc != 0)
	throw PkgBackEndException("rpmtransAddPackage()");
      headerFree(hdr);
      Fclose(fd);
    }
}
示例#11
0
//###################################################################################
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();
  }
}
示例#12
0
/*
 * 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);
}
示例#13
0
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;
}
示例#14
0
文件: verify.c 项目: nforro/rpm
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;
}
示例#15
0
文件: pack.c 项目: nforro/rpm
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;
}
示例#16
0
文件: fsm.c 项目: nforro/rpm
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;
    }
}
示例#17
0
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;
}
示例#18
0
/* ------------------------
   | Load option settings |
   ------------------------ */
void load_options(void)
{
long f_handle;

strcpy(option_file, path);
strcpy(strchr(option_file, '.') - 1, "DSPROG.OPT");

f_handle = Fopen(option_file, FO_READ);
if (f_handle > 0)
	{
	Fread((int)f_handle, 2L, &flt_ovsm);
	Fread((int)f_handle, 2L, &flt_bad);
	Fread((int)f_handle, 2L, &flt_pitch);
	Fread((int)f_handle, 2L, &flt_slice);

	Fread((int)f_handle, 2L, &pck_filt);
	Fread((int)f_handle, 2L, &pck_4plus);
	Fread((int)f_handle, 2L, &pck_4bit);
	Fread((int)f_handle, 2L, &pck_alter);

	Fread((int)f_handle, 2L, &ovsm_typ);

	Fread((int)f_handle, 2L, &ply_speed);
	Fread((int)f_handle, 2L, &play_ovsm);
	Fread((int)f_handle, 2L, &play_dev);

	Fread((int)f_handle, 4L, &spd_table[4]);
	Fread((int)f_handle, sizeof(mw_data), mw_data);

	Fread((int)f_handle, 4L, smp_extension);
	Fread((int)f_handle, 4L, pck_extension);
	Fread((int)f_handle, 4L, avr_extension);
	
	Fclose((int)f_handle);
	
	ltoa(spd_table[4], playopt_dia.tree[MANUSPD].ob_spec.tedinfo->te_ptmplt, 10);
	strcat(playopt_dia.tree[MANUSPD].ob_spec.tedinfo->te_ptmplt, " KHz");
	
	strcpy(mboard_dia.tree[MBMANU].ob_spec.tedinfo->te_ptmplt,
				 playopt_dia.tree[MBMANU].ob_spec.tedinfo->te_ptmplt);
	}
}
示例#19
0
文件: test.c 项目: wsy2220/Playground
void hash_table_test()
{
	hash_table ht;
	ht.size = 569;
	ht.hash = hash_str;
	ht.iseq = iseq_str;
	ht.frac = 0.618;
	ht.print = print_str;
	hash_table_alloc(&ht);
	FILE *fp = Fopen(PATH, "r");
	string *strpool[MAX_LINE], *str;
	size_t i, line_total;
	for(i = 0; i < MAX_LINE; i++){
		str = malloc(MAX_LEN + sizeof(string));
		strpool[i] = str;
		str->strp = (char *)str + sizeof(string);
		str->nline = i + 1;
		if(fgets(str->strp, MAX_LEN, fp) != NULL){
			str->length = strlen(str->strp);
			hash_table_insert(&ht, strpool[i]);
		}
		else{
			strpool[i] = NULL;
			free(str);
			break;
		}
	}
	line_total = i;
	string sample, *result;
	sample.strp = "{\n";
	sample.length = strlen(sample.strp);
	result = hash_table_search(&ht, &sample);
	//hash_table_print(&ht);
	if(result != NULL)
		printf("%lu\t%s",result->nline, result->strp);
	else
		printf("not found\n");
	hash_table_destroy(&ht);
	for(i = 0; i < line_total; i++)
		free(strpool[i]);
	Fclose(fp);
}
示例#20
0
main()
{
	char buf[80];
	const char *str = "AAAAAAAAAAAAAAAAAAAA";
	long fh;
	
	printf("\nVilken fil:");
	gets(buf);
	
	if((fh = Fopen(buf,O_RDWR)) < 0){
		printf("\nKan ej ”ppna filen !");
		exit(1);
	}
	
	Fseek(10L,fh,SEEK_SET);
	
	Fwrite(fh,20,str);
	
	Fclose(fh);
}
示例#21
0
char *
load_file(char *filename)
{
	long file_handle;
	char *file;
	struct xattr file_info;
	
	if(Fxattr(0,filename,&file_info)==0)
	{
		file_handle=Fopen(filename,16);
		file=(char *)malloc(file_info.size);
		Fread(file_handle,file_info.size,file);
		Fclose(file_handle);
	}
	else
	{
		file=strdup("<html><head><title>Page not found</title></head><body><h1>Page not found</h1></body></html>");
	}
	return(file);
}
示例#22
0
//------------------------------------------------------------------
void Verbose::Warn(const char *class_name, const char *func_name,
		   const char *format, ...) {
    
    if(!active[VERBOSE_WARN_LEVEL]) return;

    va_list args;
    va_start(args, format);
    printf("WARNING %s::%s :\n\t", class_name, func_name);
    vprintf(format, args);
    
    FILE *fp;
    char *filename = "phys.warn";
    if( (fp = Fopen(filename, "a")) == NULL ) {
	ERR.FileA("Verbose","Warn", filename);
    }
    Fprintf(fp,"WARNING %s::%s :\n\t", class_name, func_name);
    Vfprintf(fp, format, args);
    Fclose(fp);
    
}
示例#23
0
文件: DVfs.cpp 项目: laulandne/src
// Return the CBM-style load address..
// TODO: figure out where this belongs!
unsigned int DVfs::getStartAddress(const char *filename)
{
  if(!filename) return 0;
  diskError=false;
  if(disk[diskNum]) {
    // NOTE: fopen, etc are OUR versions, not the standard C ones...
    void *fd=Fopen(filename,"rb");
    if(!fd) {
      return 0;
    }
    BYTE l,h;
    Fread(&l,1,1,fd);
    Fread(&h,1,1,fd);
    unsigned int saddr=(h*256)+l;
    Fclose(fd);
    return saddr;
  }
  else noSuchDisk();
  return 0;
}
示例#24
0
bool FILEIO::Fopen(_TCHAR *filename, int mode)
{
	Fclose();
	
	switch(mode) {
	case FILEIO_READ_BINARY:
		return ((fp = _tfopen(filename, _T("rb"))) != NULL);
	case FILEIO_WRITE_BINARY:
		return ((fp = _tfopen(filename, _T("wb"))) != NULL);
	case FILEIO_READ_WRITE_BINARY:
		return ((fp = _tfopen(filename, _T("r+b"))) != NULL);
	case FILEIO_READ_ASCII:
		return ((fp = _tfopen(filename, _T("r"))) != NULL);
	case FILEIO_WRITE_ASCII:
		return ((fp = _tfopen(filename, _T("w"))) != NULL);
	case FILEIO_READ_WRITE_ASCII:
		return ((fp = _tfopen(filename, _T("r+w"))) != NULL);
	}
	return false;
}
示例#25
0
void
savedeadletter(FILE *fp)
{
	FILE *dbuf;
	int c;
	char *cp;

	if (fsize(fp) == 0)
		return;
	cp = getdeadletter();
	c = umask(077);
	dbuf = Fopen(cp, "a");
	(void)umask(c);
	if (dbuf == NULL)
		return;
	while ((c = getc(fp)) != EOF)
		(void)putc(c, dbuf);
	(void)Fclose(dbuf);
	rewind(fp);
}
示例#26
0
void vdoa_test(void)
{
    uint8_t *buffer = malloc(IMG_WIDTH * IMG_HEIGHT * 1.5 + 0x1000);
	/*the VDOA file is extracted from VPU decoder in tiled frame mode*/
	uint8_t readfile[] = "vdoa_in.yuv";
    int count, err;
    int fin = 0;

    if (buffer == NULL)
        return;

    hdmi_1080P60_video_output(1, 0);
    if (FSInit(NULL, bufy, maxdevices, maxhandles, maxcaches) != SUCCESS) {
        err = -1;
        return;
    }

    FSDriveInit(DeviceNum);
    SetCWDHandle(DeviceNum);

    print_media_fat_info(DeviceNum);

    if ((fin = Fopen(readfile, (uint8_t *) "r")) < 0) {
        printf("cannot open file %s!\n", readfile);
        return;
    }

    buffer = (uint8_t *) (((uint32_t) buffer + 0xFFF) & 0xFFFFF000);

    set_card_access_mode(1, 0);
    
    count = Fread(fin, (uint8_t *) buffer, IMG_WIDTH * IMG_HEIGHT * 1.5);

    vdoa_clear_interrupt();
    vdoa_setup(IMG_WIDTH, IMG_HEIGHT, IMG_WIDTH, IMG_WIDTH, 0, 0, 16, 0);
    vdoa_start((uint32_t) buffer, IMG_WIDTH * IMG_HEIGHT, IPU2_CH23_EBA0, IMG_WIDTH * 1088);

    while (!vdoa_check_tx_eot()) ;
    Fclose(fin);
}
示例#27
0
    unsigned int ReadSeedFile( void ) {
	FILE *seedfp = NULL;
	int i, io_state, n = peNum;
	unsigned int *iseed, seed; 

	// Check we have actually been initialised:
	if( !Is_Initialised ) CommsInit();

#ifdef MPISCU_DEBUG
	fprintf_all(logFile,"MPISCU::ReadSeedFile: Opening seed file %s.\n", seedFileName);
#endif

	// Create the seeds buffer:
	iseed = new unsigned int[n+1];
    
	// Open the file:
	seedfp = Fopen(seedFileName, "r" );
	if( seedfp == NULL ) 
	    RaiseError("SCUReadSeedFile: could not open seed file!\n");
    
	// Read in n seeds:
	i = 0; while( i < n && fscanf(seedfp,"%u",&(iseed[i])) != EOF ) i++;
    
	// Close the file:
	Fclose(seedfp); seedfp = NULL;
    
	// Die if the file ended before all seeds had been read in:
	if( i < n )
	    RaiseError("SCUReadSeedFile: not enough seeds have been supplied in the seed file!");
	// XXX, EXTREME warning.  This killed one thread and then hung.
    
	// Get the seed which belongs to this PE:
	seed = iseed[peRank];

	// Delete the seeds buffer:
	delete [] iseed;

	// Return this PE's seed:
	return seed;
    }
示例#28
0
文件: sepolicy.c 项目: akozumpl/rpm
static rpmRC sepolWritePolicy(const sepol * pol, char **path)
{
    char *tmppath = NULL;
    FD_t fd = NULL;
    char *policy = NULL;
    size_t policylen;
    rpmRC rc = RPMRC_FAIL;

    if (rpmBase64Decode(pol->data, (void **) &policy, &policylen) != 0) {
	rpmlog(RPMLOG_ERR, _("Failed to decode policy for %s\n"),
	       pol->name);
	goto exit;
    }

    fd = rpmMkTempFile(NULL, &tmppath);
    if (fd == NULL || Ferror(fd)) {
	rpmlog(RPMLOG_ERR, _("Failed to create temporary file for %s: %s\n"),
	       pol->name, strerror(errno));
	goto exit;
    }

    if (!Fwrite(policy, sizeof(*policy), policylen, fd)) {
	rpmlog(RPMLOG_ERR, _("Failed to write %s policy to file %s\n"),
	       pol->name, tmppath);
	goto exit;
    }

    *path = tmppath;
    rc = RPMRC_OK;

  exit:
    if (fd)
	Fclose(fd);
    _free(policy);
    if (rc != RPMRC_OK)
	_free(tmppath);

    return rc;
}
示例#29
0
//------------------------------------------------------------------
void Error::General(const char *class_name, const char *func_name,
                    const char *format,  // format of message
                    ...)                 // argument list of message
{
    FILE *fp;
    error_func_name = "General";
    va_list args;
    va_start(args, format);

    printf(error_string[general], class_name, func_name);
    vprintf(format, args);

    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[general], class_name, func_name);
    Vfprintf(fp, format, args);
    Fclose(fp);

    Exit(exit_value[general]);
}
示例#30
0
static void recordTransitions(Node *queue) {
  FILE *fp = Fopen(FILE_NAME, "w");
  fprintf(fp, "***beginning of testdominon transitions***\n");

  // record states
  struct gameState *oldState = Dequeue(queue, &queue);
  while (queue != NULL && queue != NULL) {
    // record transition from old state to new state
    struct gameState *newState = Dequeue(queue, &queue);
    debug(fp, oldState, newState);

    // clean-up and update old state
    Free(oldState);
    oldState = newState;
  }

  fprintf(fp, "***end of testdominon transitions***\n");

  // clean-up old state and file
  Free(oldState);
  Fclose(fp);
}