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


C++ Fread函数代码示例

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


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

示例1: getximgpal

/* *** Palette aus XIMG auslesen *** */
int getximgpal(char *filename, int pal[][3])
{
 XIMGHEAD ximg;
 int fhndl;
 int i,j;

 fhndl=Fopen(filename, 0);
 if(fhndl<0) return(fhndl);
 Fread(fhndl, sizeof(XIMGHEAD), &ximg);		/* IMG einlesen */

 if(ximg.palmagic!=0x58494D47L || ximg.color_model!=0)  /* 0x58494D47L='XIMG' */
  { Fclose(fhndl); return(1); }

 if(ximg.Planes>1 && ximg.Planes<=8)
  for(i=0; i<(1<<ximg.Planes); i++)
   {
    switch(ximg.Planes)
     {
      case 2: j=hw2vdic2[i]; break;
      case 4: j=hw2vdic4[i]; break;
      case 8: j=hw2vdic8[i]; break;
      default: j=i; break;
     }
    Fread(fhndl, 6L, &pal[j][0]);
   }
 Fclose(fhndl);

 return 0;
}
开发者ID:daemqn,项目名称:Atari_ST_Sources,代码行数:30,代码来源:loadimg.c

示例2: headerRead

Header headerRead(FD_t fd, int magicp)
{
    int32_t block[4];
    int32_t * ei = NULL;
    int32_t il;
    int32_t dl;
    Header h = NULL;
    unsigned int len, blen;

    if (magicp == HEADER_MAGIC_YES) {
	int32_t magic;

	if (Fread(block, 1, 4*sizeof(*block), fd) != 4*sizeof(*block))
	    goto exit;

	magic = block[0];

	if (memcmp(&magic, rpm_header_magic, sizeof(magic)))
	    goto exit;

	il = ntohl(block[2]);
	dl = ntohl(block[3]);
    } else {
	if (Fread(block, 1, 2*sizeof(*block), fd) != 2*sizeof(*block))
	    goto exit;

	il = ntohl(block[0]);
	dl = ntohl(block[1]);
    }

    blen = (il * sizeof(struct entryInfo_s)) + dl;
    len = sizeof(il) + sizeof(dl) + blen;

    /* Sanity checks on header intro. */
    if (hdrchkTags(il) || hdrchkData(dl) || len > headerMaxbytes)
	goto exit;

    ei = xmalloc(len);
    ei[0] = htonl(il);
    ei[1] = htonl(dl);

    if (Fread((char *)&ei[2], 1, blen, fd) != blen)
	goto exit;
    
    h = headerImport(ei, len, 0);

exit:
    if (h == NULL && ei != NULL) {
	free(ei);
    }
    return h;
}
开发者ID:ereshetova,项目名称:rpm,代码行数:52,代码来源:header.c

示例3: main

void main(void)
{   int Hdl;
    void *OldScreen;
    int dummy;
    long i;

/* d‚termine la base line A pour la position souris
*/
    linea_init();

/* charge l'image et la duplique en largeur
*/       
    Hdl=Fopen("MORETA.NEO",0); if (Hdl<0) { appl_exit(); Pterm0(); }
    Fseek(4L,Hdl,0);
    Fread(Hdl,32L,NewPalette);
    Fseek(128L,Hdl,0);
    for (i=0;i<200;i++) 
    {    LINE1 *p=(LINE1 *)&picbuf[0].line[i];
         Fread(Hdl,sizeof(LINE1),p);
         p[1]=p[0];
    }
    Fclose(Hdl);

/* Duplique l'image en hauteur 
*/  
    picbuf[1]=picbuf[0];
         
/* Installe la pallette et sauve l'ancienne
*/
    InsPalette(); 
    
/* Sauve l'adresse de l'‚cran courant
*/  
    OldScreen=GetScreenPtr();

/* Installe la routine de scrolling en VBL
*/
    InsVBL(Scrolling);
    
/* Boucle en attendant un Ctrl-C
*/
    while (1) if (Bconstat(2)<0 && (char)Bconin(2)==3) break;

/* Remet tout en ordre et sort de l…
*/  
    RmvVBL();
    SetScreenPtr(OldScreen);
    SetScroll(0);
    SetLineStride(0);
    RestPalette();
}
开发者ID:daemqn,项目名称:Atari_ST_Sources,代码行数:51,代码来源:biglow.c

示例4: printFile

static void printFile(char *fileNam)
{
	int fi, fo;
#define NBUFF 256
	char buff[NBUFF];
	long len;
	
	fileNam[0] = 'd';			/* force data file */

	if ( (fi=Fopen(fileNam, FO_READ)) >= 0 ) {
		if ( (fo=Fcreate(prDevice, 0)) < 0)
			fo=Fopen(prDevice, FO_WRITE);
		/* Fopen may return < 0 for devices like PRN: ! */
		if ( fo > -31) {
	
			while ( (len=Fread(fi, NBUFF, buff)) > 0)
				Fwrite(fo, len, buff);
	
			Fclose(fo);
		} else {
	        uiPrintf(uiH, uiPrERR, "cannot open device|>%s<", prDevice);
		}
		Fclose(fi);
	} else {
        uiPrintf(uiH, uiPrERR, "cannot open dFile");
	}

	Fdelete(fileNam);
	fileNam[0] = 'c';			/* force control file */
	Fdelete(fileNam);
}	
开发者ID:daemqn,项目名称:Atari_ST_Sources,代码行数:31,代码来源:LPD.C

示例5: Copy_file

int Copy_file(char *tos_name,char *long_name,int attributes)
{
 short in_file,out_file;
 long size;
 int error;

 if ((in_file=Fopen(tos_name,0))<0)
  return(FALSE);

 if ((out_file=Fcreate(long_name,attributes))<0)
 {
  Fclose(in_file);
  return(FALSE);
 }

 do
 {
  size=Fread(in_file,FILE_BUFF_SIZE,file_buff);
  error=(size!=Fwrite(out_file,size,file_buff));
 } while((size==FILE_BUFF_SIZE)&&(!error));

 Fclose(out_file);
 Fclose(in_file);
 return(!error);
}
开发者ID:daemqn,项目名称:Atari_ST_Sources,代码行数:25,代码来源:CONV.C

示例6: fdConsume

static rpmRC fdConsume(FD_t fd, off_t start, off_t nbytes)
{
    size_t bufsiz = 32*BUFSIZ;
    unsigned char buf[bufsiz];
    off_t left = nbytes;
    ssize_t nb;

    if (start && fdJump(fd, start))
	return RPMRC_FAIL;

    while (left > 0) {
	nb = Fread(buf, 1, (left < bufsiz) ? left : bufsiz, fd);
	if (nb > 0)
	    left -= nb;
	else
	    break;
    };

    if (left) {
	rpmlog(RPMLOG_ERR, _("Failed to read %jd bytes in file %s: %s\n"),
	       (intmax_t) nbytes, Fdescr(fd), Fstrerror(fd));
    }

    return (left == 0) ? RPMRC_OK : RPMRC_FAIL;
}
开发者ID:nforro,项目名称:rpm,代码行数:25,代码来源:pack.c

示例7: LoadImg

/* *** Die Laderoutine *** */
int LoadImg(char *Filename, MFDB *raster)
{
 IMGHEAD *img;
 long Length;
 int fhndl;

 fhndl=Fopen(Filename, 0);
 if(fhndl<0) return(fhndl);
 Length=Fseek(0L, fhndl, 2);
 Fseek(0L, fhndl, 0);
 img=(void *)Mxalloc(Length, 0);
 if( ((signed long)img)==-32L )  img=(void *)Malloc(Length);
 if( (signed long)img<=0L) { Fclose(fhndl); return((int)img); }
 Fread(fhndl, Length, img);		/* IMG einlesen */
 Fclose(fhndl);

 raster->fd_w = img->LineWidth;
 raster->fd_h = img->Lines;
 raster->fd_wdwidth = (raster->fd_w + 15) / 16;
 raster->fd_stand = 1;
 raster->fd_nplanes = img->Planes;

 Length=(long)raster->fd_wdwidth * 2L * raster->fd_h * raster->fd_nplanes;
 raster->fd_addr=(void *)Mxalloc(Length, 0);
 if( ((signed long)raster->fd_addr)==-32L )
   raster->fd_addr=(void *)Malloc(Length);
 if( (signed long)raster->fd_addr<=0L )  return((int)raster->fd_addr);

 Decompress(img, raster->fd_addr);

 Mfree(img);
 return(0);
}
开发者ID:daemqn,项目名称:Atari_ST_Sources,代码行数:34,代码来源:loadimg.c

示例8: RawDocOutput

/* num should be greater than or equal to 1 */
int 
RawDocOutput (query_data * qd, u_long num, FILE * Output)
{
  static last_pos = 0;
  static u_char *c_buffer = 0;
  static int buf_len = -1;
  static u_char *uc_buffer = 0;
  u_long pos, len;
  int ULen;

  FetchDocStart (qd, num, &pos, &len);

  if ((int) len > buf_len)
    {
      if (c_buffer)
	{
	  Xfree (c_buffer);
	  Xfree (uc_buffer);
	}
      if (!(c_buffer = Xmalloc (len)))
	return -1;
      if (!(uc_buffer = Xmalloc ((int) (qd->td->cth.ratio * 1.01 *
					len) + 100)))
	return -1;
      buf_len = len;
    }
  if (last_pos != pos)
    Fseek (qd->td->TextFile, pos, 0);
  Fread (c_buffer, 1, len, qd->td->TextFile);
  last_pos = pos + len;
  DecodeText (qd->cd, c_buffer, len, uc_buffer, &ULen);
  fwrite (uc_buffer, ULen, sizeof (u_char), Output);
  return 0;
}
开发者ID:plbogen,项目名称:CSDL,代码行数:35,代码来源:mgquery.c

示例9: spol_gblk

VOID spol_gblk(VOID)
{
	BYTE    handle;

#if GEMDOS
	handle = Fopen( (const char *)spol_path, 0x0000 );
#else
	handle = dos_open( spol_path, 0x0000 );
#endif
	if (handle)
	{
#if GEMDOS
		Fseek( spol_fcnt, handle, 0x0000 );
		spol_cntr = (WORD)Fread( handle, SPLSIZE, (VOID *)spol_pbuf );
#else
		dos_lseek( handle, 0x0000, spol_fcnt );
		spol_cntr = dos_read( handle, SPLSIZE, spol_pbuf );
#endif
		if ( spol_cntr != SPLSIZE )
			spol_sts = TRUE;
		spol_fcnt += LW( spol_cntr );
#if GEMDOS
		Fclose( handle );
#else
		dos_close( handle );
#endif
		spol_ptr = spol_bufr;
	}
	else
	{
		spol_sts = TRUE;
		spol_cntr = 0;
	}
}
开发者ID:daemqn,项目名称:Atari_ST_Sources,代码行数:34,代码来源:SPOL.C

示例10: raw_read_file

/*
 * raw_read_file:
 *	read the CKB file completely
 */
BOOL raw_read_file(char *name)
{
	DTA		mydta;
	int		handle;

	if (CKBfileblock) {
		Mfree(CKBfileblock);
		CKBfileblock = NULL;
	}

	Readlnidx = 0; cline=0;

	/* locate file */
	Fsetdta(&mydta);
	if (Fsfirst(name, FA_READONLY|FA_ARCHIVE|FA_SYSTEM)!=0) return FALSE;		/* file not found */

	/* alloc space for the file */
	CKBfileblock = Malloc((mydta.d_length+16L)&(-16L));
	if (CKBfileblock==0) return FALSE;				/* out of memory */

	/* open the file */
	handle = (int)Fopen(name, FO_READ);
	if (handle<=0) return FALSE;					/* file open error */

	/* read all of it */
	CKBfilesize = Fread(handle, mydta.d_length, CKBfileblock);

	/* close it */
	Fclose(handle);

	if (CKBfilesize<=0) return FALSE;
	return TRUE;
}
开发者ID:daemqn,项目名称:Atari_ST_Sources,代码行数:37,代码来源:CKB_FILE.C

示例11: readline

int readline(char *str,int n,int handle)
{
	int  count=0,succ=0;
	char c;

	while (Fread(handle,1,&c)==1)
	{
		if (c==13)
		{
			succ=1;
			break;
		}
		else
		{
			if (c!=10)
			{
				str[count++]=c;
				if (count>=n) break;
			}
		}
	}

	str[count]=0;

	return((count) || (succ));
}
开发者ID:daemqn,项目名称:Atari_ST_Sources,代码行数:26,代码来源:INITMAN.C

示例12: copyFile

/**
 * Copy header+payload, calculating digest(s) on the fly.
 * @param sfdp source file
 * @param sfnp source path
 * @param tfdp destination file
 * @param tfnp destination path
 */
static int copyFile(FD_t *sfdp, const char *sfnp,
		FD_t *tfdp, const char *tfnp)
{
    unsigned char buf[BUFSIZ];
    ssize_t count;
    int rc = 1;

    while ((count = Fread(buf, sizeof(buf[0]), sizeof(buf), *sfdp)) > 0)
    {
	if (Fwrite(buf, sizeof(buf[0]), count, *tfdp) != count) {
	    rpmlog(RPMLOG_ERR, _("%s: Fwrite failed: %s\n"), tfnp,
		Fstrerror(*tfdp));
	    goto exit;
	}
    }
    if (count < 0) {
	rpmlog(RPMLOG_ERR, _("%s: Fread failed: %s\n"), sfnp, Fstrerror(*sfdp));
	goto exit;
    }
    if (Fflush(*tfdp) != 0) {
	rpmlog(RPMLOG_ERR, _("%s: Fflush failed: %s\n"), tfnp,
	    Fstrerror(*tfdp));
    }

    rc = 0;

exit:
    return rc;
}
开发者ID:maxamillion,项目名称:rpm,代码行数:36,代码来源:rpmgensig.c

示例13: ddstry

short ddstry(short fd, char *ext, char *text, char *name, long size)
{
	char c;
	short hdrlen, i;

	/* 4 Bytes f�r "ext", 4 Bytes f�r "size",
	   2 Bytes f�r Stringendnullen */

	hdrlen = (short) (4 + 4 + strlen(text)+1 + strlen(name)+1);


	/* Header senden */

	if (Fwrite(fd, 2L, &hdrlen) != 2L)
		return(DD_NAK);

	i = (short) Fwrite(fd, 4L, ext);
	i += (short) Fwrite(fd, 4L, &size);
	i += (short) Fwrite(fd, strlen(text)+1, text);
	i += (short) Fwrite(fd, strlen(name)+1, name);

	if (i != hdrlen)
		return(DD_NAK);


	/* auf die Antwort warten */

	if (Fread(fd, 1L, &c) != 1L)
		return(DD_NAK);

	return(c);
}
开发者ID:pcwalton,项目名称:NetSurf,代码行数:32,代码来源:dragdrop.c

示例14: P2C

static void
pk_glyphs_fn P2C(FILE *, f,  struct font *, fontp)
{
  register struct glyph *g;
  int hppp, vppp;

  if (debug & DBG_PK)
    Printf ("Reading PK pixel file %s\n", fontp->filename);

  /* skip comment */
  Fseek (f, (long) one (f), SEEK_CUR);

  (void) four (f);	/* skip design size */
  (void) four (f);	/* skip checksum */
  hppp = sfour (f);
  vppp = sfour (f);
  if (hppp != vppp && (debug & DBG_PK))
    Printf ("Font has non-square aspect ratio %d:%d\n", vppp, hppp);

  /* Initialize glyph array.  */
  for (g = fontp->glyph; g < fontp->glyph + 256; ++g)
    {
      g->packed_data = NULL;
      g->bitmap.bits = NULL;
      g->bitmap2.bits = NULL;
    }

  /* Read glyph directory (really a pass over the whole file).  */
  for (;;)
    {
      int bytes_left, flag_low_bits;
      unsigned int cc;

      PK_skip_specials (f, fontp);
      if (PK_flag_byte == PK_POST)
	break;
      flag_low_bits = PK_flag_byte & 0x7;
      if (flag_low_bits == 7)
	{
	  bytes_left = four (f);
	  cc = four (f);
	}
      else if (flag_low_bits > 3)
	{
	  bytes_left = ((flag_low_bits - 4) << 16) + two (f);
	  cc = one (f);
	}
      else
	{
	  bytes_left = (flag_low_bits << 8) + one (f);
	  cc = one (f);
	}
      /* Use the (randomly chosen) `x2' field for the flag byte.  */
      fontp->glyph[cc].x2 = PK_flag_byte;
      
      /* Read the bitmap data, but don't unpack it.  */
      fontp->glyph[cc].packed_data = xmalloc (bytes_left);
      Fread (fontp->glyph[cc].packed_data, bytes_left, 1, f);
    }
}
开发者ID:LambdaCalculus379,项目名称:SLS-1.02,代码行数:60,代码来源:pk.c

示例15: ufdCopy

off_t ufdCopy(FD_t sfd, FD_t tfd)
{
    char buf[BUFSIZ];
    ssize_t rdbytes, wrbytes;
    off_t total = 0;

    while (1) {
	rdbytes = Fread(buf, sizeof(buf[0]), sizeof(buf), sfd);

	if (rdbytes > 0) {
	    wrbytes = Fwrite(buf, sizeof(buf[0]), rdbytes, tfd);
	    if (wrbytes != rdbytes) {
		total = -1;
		break;
	    }
	    total += wrbytes;
	} else {
	    if (rdbytes < 0)
		total = -1;
	    break;
	}
    }

    return total;
}
开发者ID:maxamillion,项目名称:rpm,代码行数:25,代码来源:rpmio.c


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