本文整理汇总了C++中efread函数的典型用法代码示例。如果您正苦于以下问题:C++ efread函数的具体用法?C++ efread怎么用?C++ efread使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了efread函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: load_sprites
void load_sprites( unsigned int table, FILE *f )
{
free_sprites(table);
Uint16 temp;
efread(&temp, sizeof(Uint16), 1, f);
sprite_table[table].count = temp;
for (unsigned int i = 0; i < sprite_table[table].count; ++i)
{
Sprite * const cur_sprite = sprite(table, i);
if (!getc(f)) // sprite is empty
continue;
efread(&cur_sprite->width, sizeof(Uint16), 1, f);
efread(&cur_sprite->height, sizeof(Uint16), 1, f);
efread(&cur_sprite->size, sizeof(Uint16), 1, f);
cur_sprite->data = malloc(cur_sprite->size);
efread(cur_sprite->data, sizeof(Uint8), cur_sprite->size, f);
}
}
开发者ID:carstene1ns,项目名称:opentyrian-wii,代码行数:25,代码来源:sprite.c
示例2: intp3
void intp3(FILE *fp, float *p1, float *p2, float *p3, float *p4, float *po,
float o1, float d1, int n1, int n2,
int i21, int i22, int i31, int i32,
float w21, float w22, float w31, float w32) {
long lpos;
int i1;
lpos = i21+i31*n2;
lpos = lpos*n1*4;
fseek2g(fp,lpos,0);
efread(p1,sizeof(float),n1,fp);
lpos = i22+i31*n2;
lpos = lpos*n1*4;
fseek2g(fp,lpos,0);
efread(p2,sizeof(float),n1,fp);
lpos = i21+i32*n2;
lpos = lpos*n1*4;
fseek2g(fp,lpos,0);
efread(p3,sizeof(float),n1,fp);
lpos = i22+i32*n2;
lpos = lpos*n1*4;
fseek2g(fp,lpos,0);
efread(p4,sizeof(float),n1,fp);
for(i1=0;i1<n1;i1++) {
po[i1] = (p1[i1]*w21 + p2[i1]*w22)*w31 +
(p3[i1]*w21 + p4[i1]*w22)*w32;
}
}
开发者ID:JOravetz,项目名称:SeisUnix,代码行数:35,代码来源:sudipstk.c
示例3: JE_loadSong
void JE_loadSong( JE_word songnum )
{
JE_word x;
FILE *fi, *test;
JE_resetFile(&fi, "music.mus");
if (notYetLoadedMusic)
{
/* SYN: We're loading offsets into MUSIC.MUS for each song here. */
notYetLoadedMusic = false;
efread(&x, sizeof(x), 1, fi);
efread(songPos, sizeof(JE_longint), sizeof(songPos) / sizeof(JE_longint), fi); /* SYN: reads long int (i.e. 4) * MUSICNUM */
fseek(fi, 0, SEEK_END);
songPos[MUSIC_NUM] = ftell(fi); /* Store file size */
}
/* SYN: Now move to the start of the song we want, and load the number of bytes given by the
difference in offsets between it and the next song. */
fseek(fi, songPos[songnum - 1], SEEK_SET);
efread(&musicData, 1, songPos[songnum] - songPos[songnum - 1], fi);
/* currentSong = songnum; */
fclose(fi);
}
开发者ID:simX,项目名称:opentyrian,代码行数:26,代码来源:nortsong.c
示例4: JE_loadPic
void JE_loadPic(SDL_Surface *screen, uint8_t PCXnumber, bool storepal )
{
PCXnumber--;
FILE *f = dir_fopen_die(data_dir(), "tyrian.pic", "rb");
static bool first = true;
if (first)
{
first = false;
uint16_t temp;
efread(&temp, sizeof(uint16_t), 1, f);
for (int i = 0; i < PCX_NUM; i++)
{
efread(&pcxpos[i], sizeof(int32_t), 1, f);
}
pcxpos[PCX_NUM] = ftell_eof(f);
}
uint32_t size = pcxpos[PCXnumber + 1] - pcxpos[PCXnumber];
uint8_t *buffer = malloc(size);
fseek(f, pcxpos[PCXnumber], SEEK_SET);
efread(buffer, sizeof(uint8_t), size, f);
fclose(f);
uint8_t *p = buffer;
uint8_t *s; /* screen pointer, 8-bit specific */
s = (uint8_t *)screen->pixels;
for (int i = 0; i < 320 * 200; )
{
if ((*p & 0xc0) == 0xc0)
{
i += (*p & 0x3f);
memset(s, *(p + 1), (*p & 0x3f));
s += (*p & 0x3f); p += 2;
} else {
i++;
*s = *p;
s++; p++;
}
if (i && (i % 320 == 0))
{
s += screen->pitch - 320;
}
}
free(buffer);
memcpy(colors, palettes[pcxpal[PCXnumber]], sizeof(colors));
if (storepal)
set_palette(colors, 0, 255);
}
开发者ID:Silenthal,项目名称:opentyrian,代码行数:58,代码来源:picload.c
示例5: JE_loadMainShapeTables
void JE_loadMainShapeTables( const char *shpfile )
{
#ifdef TYRIAN2000
const int SHP_NUM = 13;
#else
const int SHP_NUM = 12;
#endif
FILE *f = dir_fopen_die(data_dir(), shpfile, "rb");
JE_word shpNumb;
JE_longint shpPos[SHP_NUM + 1]; // +1 for storing file length
efread(&shpNumb, sizeof(JE_word), 1, f);
assert(shpNumb + 1u == COUNTOF(shpPos));
for (unsigned int i = 0; i < shpNumb; ++i)
efread(&shpPos[i], sizeof(JE_longint), 1, f);
fseek(f, 0, SEEK_END);
for (unsigned int i = shpNumb; i < COUNTOF(shpPos); ++i)
shpPos[i] = ftell(f);
int i;
// fonts, interface, option sprites
for (i = 0; i < 7; i++)
{
fseek(f, shpPos[i], SEEK_SET);
load_sprites(i, f);
}
// player shot sprites
shapesC1.size = shpPos[i + 1] - shpPos[i];
JE_loadCompShapesB(&shapesC1, f);
i++;
// player ship sprites
shapes9.size = shpPos[i + 1] - shpPos[i];
JE_loadCompShapesB(&shapes9 , f);
i++;
// power-up sprites
eShapes[5].size = shpPos[i + 1] - shpPos[i];
JE_loadCompShapesB(&eShapes[5], f);
i++;
// coins, datacubes, etc sprites
eShapes[4].size = shpPos[i + 1] - shpPos[i];
JE_loadCompShapesB(&eShapes[4], f);
i++;
// more player shot sprites
shapesW2.size = shpPos[i + 1] - shpPos[i];
JE_loadCompShapesB(&shapesW2, f);
fclose(f);
}
开发者ID:twinaphex,项目名称:OpenTyrian,代码行数:57,代码来源:sprite.c
示例6: JE_loadMainShapeTables
void JE_loadMainShapeTables( const char *shpfile )
{
const int SHP_NUM = 12;
FILE *f = dir_fopen_die(data_dir(), shpfile, "rb");
JE_word shpNumb;
JE_longint shpPos[SHP_NUM + 1]; // +1 for storing file length
efread(&shpNumb, sizeof(JE_word), 1, f);
assert(shpNumb + 1 <= COUNTOF(shpPos));
for (int i = 0; i < shpNumb; i++)
{
efread(&shpPos[i], sizeof(JE_longint), 1, f);
}
fseek(f, 0, SEEK_END);
shpPos[shpNumb] = ftell(f);
int i;
// fonts, interface, option sprites
for (i = 0; i < 7; i++)
{
fseek(f, shpPos[i], SEEK_SET);
load_sprites(i, f);
}
// player shot sprites
shapesC1.size = shpPos[i + 1] - shpPos[i];
JE_loadCompShapesB(&shapesC1, f);
i++;
// player ship sprites
shapes9.size = shpPos[i + 1] - shpPos[i];
JE_loadCompShapesB(&shapes9 , f);
i++;
// power-up sprites
eShapes6.size = shpPos[i + 1] - shpPos[i];
JE_loadCompShapesB(&eShapes6, f);
i++;
// coins, datacubes, etc sprites
eShapes5.size = shpPos[i + 1] - shpPos[i];
JE_loadCompShapesB(&eShapes5, f);
i++;
// more player shot sprites
shapesW2.size = shpPos[i + 1] - shpPos[i];
JE_loadCompShapesB(&shapesW2, f);
fclose(f);
}
开发者ID:carstene1ns,项目名称:opentyrian-wii,代码行数:53,代码来源:sprite.c
示例7: JE_analyzeLevel
void JE_analyzeLevel( void )
{
FILE *f = dir_fopen_die(data_dir(), levelFile, "rb");
efread(&lvlNum, sizeof(JE_word), 1, f);
for (int x = 0; x < lvlNum; x++)
efread(&lvlPos[x], sizeof(JE_longint), 1, f);
lvlPos[lvlNum] = ftell_eof(f);
fclose(f);
}
开发者ID:EuPhobos,项目名称:opentyrian,代码行数:13,代码来源:lvllib.c
示例8: load_music
void load_music( void )
{
if (music_file == NULL)
{
music_file = dir_fopen_die(data_dir(), "music.mus", "rb");
efread(&song_count, sizeof(song_count), 1, music_file);
song_offset = malloc((song_count + 1) * sizeof(song_offset));
efread(song_offset, 4, song_count, music_file);
song_offset[song_count] = ftell_eof(music_file);
}
}
开发者ID:intervigilium,项目名称:android-opentyrian,代码行数:14,代码来源:loudness.c
示例9: JE_analyzeLevel
void JE_analyzeLevel( void )
{
JE_word x;
FILE *f;
JE_resetFile(&f, levelFile);
efread(&lvlNum, sizeof(JE_word), 1, f);
for (x = 0; x < lvlNum; x++)
{
efread(&lvlPos[x], sizeof(JE_longint), 1, f);
}
fseek(f, 0, SEEK_END);
lvlPos[lvlNum] = ftell(f);
fclose(f);
}
开发者ID:simX,项目名称:opentyrian,代码行数:15,代码来源:lvllib.c
示例10: JE_loadCompShapesB
void JE_loadCompShapesB( Sprite2_array *sprite2s, FILE *f )
{
free_sprite2s(sprite2s);
sprite2s->data = malloc(sizeof(Uint8) * sprite2s->size);
efread(sprite2s->data, sizeof(Uint8), sprite2s->size, f);
}
开发者ID:carstene1ns,项目名称:opentyrian-wii,代码行数:7,代码来源:sprite.c
示例11: fputdata
void fputdata(FILE *fileptr, FILE *headerptr, float *outdata, int nt)
{
efread(&tr, 1, HDRBYTES, headerptr);
erewind(headerptr);
memcpy((void *)tr.data, (const void *) outdata, nt*FSIZE);
fputtr(fileptr, &tr);
}
开发者ID:captainobvious62,项目名称:3CPolar,代码行数:9,代码来源:supolar_PS.c
示例12: JE_loadPage
/* Loads the given page into memory.
*
* Returns 0 on success or nonzero on failure (bad data)
*/
int JE_loadPage( uint32_t pagenumber )
{
uint32_t i, pageSize;
if (Curlpnum == pagenumber) { return(0); } /* Already loaded */
Curlpnum = pagenumber;
/* We need to seek to the page and load it into our buffer.
* Pages have a fixed size of 0x10000; any left over space is padded
* unless it's the end of the file.
*
* Pages repeat their headers for some reason. They then have two bytes of
* padding folowed by a word for every record. THEN the data starts.
*/
fseek(InFile, ANIM_OFFSET + (pagenumber * ANI_PAGE_SIZE), SEEK_SET);
efread(&CurrentPageHeader.baseRecord, 2, 1, InFile);
efread(&CurrentPageHeader.nRecords, 2, 1, InFile);
efread(&CurrentPageHeader.nBytes, 2, 1, InFile);
fseek(InFile, 2, SEEK_CUR);
for (i = 0; i < CurrentPageHeader.nRecords; i++)
{
efread(&CurrentPageRecordSizes[i], 2, 1, InFile);
}
/* What remains is the 'compressed' data */
efread(CurrentPageBuffer, 1, CurrentPageHeader.nBytes, InFile);
/* Okay, we've succeeded in all our IO checks. Now, make sure the
* headers aren't lying or damaged or something.
*/
pageSize = 0;
for (i = 0; i < CurrentPageHeader.nRecords; i++)
{
pageSize += CurrentPageRecordSizes[i];
}
if(pageSize != CurrentPageHeader.nBytes) { return(-1); }
/* So far, so good */
return(0);
}
开发者ID:Silenthal,项目名称:opentyrian,代码行数:47,代码来源:animlib.c
示例13: JE_loadPCX
void JE_loadPCX( char *file ) // this is only meant to load tshp2.pcx
{
FILE *f;
Uint8 *s = VGAScreen->pixels; /* 8-bit specific */
JE_resetFile(&f, file);
fseek(f, -769, SEEK_END);
if (fgetc(f) == 12)
{
for (int i = 0; i < 256; i++)
{
efread(&colors[i].r, 1, 1, f);
efread(&colors[i].g, 1, 1, f);
efread(&colors[i].b, 1, 1, f);
}
}
fseek(f, 128, SEEK_SET);
for (int i = 0; i < 320 * 200; )
{
Uint8 p = fgetc(f);
if ((p & 0xc0) == 0xc0)
{
i += (p & 0x3f);
memset(s, fgetc(f), (p & 0x3f));
s += (p & 0x3f);
} else {
i++;
*s = p;
s++;
}
if (i && (i % 320 == 0))
{
s += VGAScreen->pitch - 320;
}
}
fclose(f);
}
开发者ID:simX,项目名称:opentyrian,代码行数:42,代码来源:pcxload.c
示例14: dataread
static
int dataread(struct insegyinfo *iptr, segy *tp, cwp_Bool fixed_length)
{
unsigned int nsread = fixed_length?iptr->nsfirst:tp->ns;
unsigned int databytes = infoptr->bytesper*nsread;
int nread;
int itest = 1;
char *ctest = (char *) (&itest);
/* read trace data */
switch(tp->trid) {
case CHARPACK:
nread = efread((char *) (&((tp->data)[0])),1,databytes,
iptr->infp);
case SHORTPACK:
nread = efread((char *) (&((tp->data)[0])),1,databytes,
iptr->infp);
if(ctest[0]) swab((char *) (&((tp->data)[0])),
(char *) (&((tp->data)[0])),
databytes);
break;
default:
nread = efread(((char *) (iptr->buf))+HDRBYTES,1,databytes,
iptr->infp);
if(nread != databytes || FALSE == xdr_vector(iptr->segy_xdr,
(char *) (&((tp->data)[0])),
nsread,sizeof(float),(xdrproc_t) xdr_float))
nread = 0;
else
nread = databytes;
break;
}
if(nread > 0 && nread != databytes)
err("%s: on trace #%ld, tried to read %d bytes, "
"read %d bytes",
__FILE__, (infoptr->itr)+1, databytes, nread);
return(nread);
}
开发者ID:gganssle,项目名称:stripper,代码行数:42,代码来源:fgettr.c
示例15: JE_loadPCX
void JE_loadPCX( const char *file ) // this is only meant to load tshp2.pcx
{
Uint8 *s = (Uint8 *)VGAScreen->pixels; /* 8-bit specific */
SDL_RWops *f = dir_fopen_die(data_dir(), file, "rb");
efseek(f, -769, SEEK_END);
if (efgetc(f) == 12)
{
for (int i = 0; i < 256; i++)
{
efread(f, &colors[i].r, 1, 1);
efread(f, &colors[i].g, 1, 1);
efread(f, &colors[i].b, 1, 1);
}
}
efseek(f, 128, SEEK_SET);
for (int i = 0; i < 320 * 200; )
{
Uint8 p = efgetc(f);
if ((p & 0xc0) == 0xc0)
{
i += (p & 0x3f);
memset(s, efgetc(f), (p & 0x3f));
s += (p & 0x3f);
} else {
i++;
*s = p;
s++;
}
if (i && (i % 320 == 0))
{
s += VGAScreen->pitch - 320;
}
}
efclose(f);
}
开发者ID:ZHANITEST,项目名称:SDLProgramming,代码行数:41,代码来源:pcxload.cpp
示例16: initauxtbl
bool initauxtbl(char *aux) {
char *filename;
FILE * fp ;
int pflen, nread, pfargc, targc, i, j ;
char *argstr, **targv ;
if( !getnpar(0,aux,"s",&filename) ) {
fprintf(stderr,"Can't get auxiliary input %s definition\n",aux) ;
return 0 ;
}
fp = fopen(filename, "r") ;
if( fp == NULL ) {
fprintf(stderr,"Can't open auxiliary input file %s=%s\n",aux,filename);
return 0 ;
}
/* Get the length */
efseek(fp, 0, SEEK_END);
pflen = eftell(fp);
rewind(fp);
argstr = (char *) ealloc1(1+pflen+1, 1);
/* Read the parfile */
nread = efread(argstr+1, 1, pflen, fp);
if (nread != pflen) {
err("%s: fread only %d bytes out of %d from %s",
__FILE__,nread,pflen,filename);
}
efclose(fp);
/* Zap whites in parfile to help in parsing */
argstr[0] = '\0' ;
pfargc = white2null(argstr, pflen);
targc = pfargc ;
/* Allocate space for total arg pointers */
targv = (char **) ealloc1(targc, sizeof(char*));
/* Parse the parfile. Skip over multiple NULLs */
for( j=1, i=0; j < pflen; j++) {
if( argstr[j] && !argstr[j-1] ) {
targv[i++] = argstr + j;
}
}
/* Allocate space for the pointer table */
argtbl = (ArgStruct*) ealloc1(targc, sizeof(ArgStruct));
/* Tabulate targv */
tabulate(targc, targv);
return 1 ;
}
开发者ID:JOravetz,项目名称:SeisUnix,代码行数:52,代码来源:getpars.c
示例17: fputdata3c
void fputdata3c(FILE *fileptr, FILE *headerptr, float **outdata3c, int nt)
{
int i;
for(i=1;i<=3;i++) {
efread(&tr, 1, HDRBYTES, headerptr);
memcpy((void *)tr.data, (const void *) outdata3c[i], nt*FSIZE);
fputtr(fileptr, &tr);
}
erewind(headerptr);
}
开发者ID:captainobvious62,项目名称:3CPolar,代码行数:13,代码来源:supolar_PS.c
示例18: main
int
main(int argc, char **argv)
{
char *outpar; /* name of file holding output parfile */
FILE *outparfp; /* ... its file pointer */
int n1; /* number of floats per line */
size_t n1read; /* number of items read */
size_t n2 = 0; /* number of lines in input file */
float *z; /* binary floats */
/* Hook up getpar */
initargs(argc, argv);
requestdoc(1);
/* Get parameters and do set up */
if (!getparstring("outpar", &outpar)) outpar = "/dev/tty" ;
outparfp = efopen(outpar, "w");
MUSTGETPARINT("n1",&n1);
z = ealloc1float(n1);
/* Loop over data converting to ascii */
while ((n1read = efread(z, FSIZE, n1, stdin))) {
register int i1;
if (n1read != n1)
err("out of data in forming line #%d", n2+1);
for (i1 = 0; i1 < n1; ++i1)
/* z2xyz.c:70: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘size_t’ */
/* printf("%d %d %11.4e \n",n2,i1,z[i1]); */
#if __WORDSIZE == 64
printf("%lu %d %11.4e \n",n2,i1,z[i1]);
#else
printf("%u %d %11.4e \n",n2,i1,z[i1]);
#endif
++n2;
}
/* Make par file */
/* z2xyz.c:76: warning: format ‘%d’ expects type ‘int’, but argument 3 has type ‘size_t’ */
/* fprintf(outparfp, "n2=%d\n", n2); */
#if __WORDSIZE == 64
fprintf(outparfp, "n2=%lu\n", n2);
#else
fprintf(outparfp, "n2=%u\n", n2);
#endif
return(CWP_Exit());
}
开发者ID:gwowen,项目名称:seismicunix,代码行数:50,代码来源:z2xyz.c
示例19: main
int
main (int argc, char **argv)
{
int n1,n2,i2;
float f1,f2,d1,d2,*x;
char *label2="Trace",label[256];
FILE *infp=stdin,*outfp=stdout;
/* hook up getpar to handle the parameters */
initargs(argc,argv);
requestdoc(0);
/* get optional parameters */
if (!getparint("n1",&n1)) {
if (efseeko(infp,(off_t) 0,SEEK_END)==-1)
err("input file size is unknown; specify n1!\n");
if ((n1=((int) (eftello(infp)/((off_t) sizeof(float)))))<=0)
err("input file size is unknown; specify n1!\n");
efseeko(infp,(off_t) 0,SEEK_SET);
}
if (!getparfloat("d1",&d1)) d1 = 1.0;
if (!getparfloat("f1",&f1)) f1 = d1;
if (!getparint("n2",&n2)) n2 = -1;
if (!getparfloat("d2",&d2)) d2 = 1.0;
if (!getparfloat("f2",&f2)) f2 = d2;
getparstring("label2",&label2);
/* allocate space */
x = ealloc1float(n1);
/* loop over 2nd dimension */
for (i2=0; i2<n2 || n2<0; i2++) {
/* read input array, watching for end of file */
if (efread(x,sizeof(float),n1,infp)!=n1) break;
/* make plot label */
sprintf(label,"%s %0.4g",label2,f2+i2*d2);
/* plot the array */
prp1d(outfp,label,n1,d1,f1,x);
}
return(CWP_Exit());
}
开发者ID:gwowen,项目名称:seismicunix,代码行数:46,代码来源:prplot.c
示例20: read_encrypted_pascal_string
void read_encrypted_pascal_string( char *s, int size, FILE *f )
{
int len = getc(f);
if (len != EOF)
{
int skip = MAX((len + 1) - size, 0);
assert(skip == 0);
len -= skip;
efread(s, 1, len, f);
if (size > 0)
s[len] = '\0';
fseek(f, skip, SEEK_CUR);
decrypt_pascal_string(s, len);
}
}
开发者ID:carstene1ns,项目名称:opentyrian-wii,代码行数:17,代码来源:helptext.c
注:本文中的efread函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论