Skip to content

Commit

Permalink
Use RW_SEEK constants for RWseek()
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Nov 8, 2009
1 parent 2ad1bc1 commit 7464176
Show file tree
Hide file tree
Showing 14 changed files with 45 additions and 45 deletions.
2 changes: 1 addition & 1 deletion IMG.c
Expand Up @@ -156,7 +156,7 @@ SDL_Surface *IMG_LoadTyped_RW(SDL_RWops *src, int freesrc, char *type)
}

/* See whether or not this data source can handle seeking */
if ( SDL_RWseek(src, 0, SEEK_CUR) < 0 ) {
if ( SDL_RWseek(src, 0, RW_SEEK_CUR) < 0 ) {
IMG_SetError("Can't seek in this data source");
if(freesrc)
SDL_RWclose(src);
Expand Down
10 changes: 5 additions & 5 deletions IMG_bmp.c
Expand Up @@ -47,7 +47,7 @@ int IMG_isBMP(SDL_RWops *src)
is_BMP = 1;
}
}
SDL_RWseek(src, start, SEEK_SET);
SDL_RWseek(src, start, RW_SEEK_SET);
return(is_BMP);
}

Expand All @@ -70,7 +70,7 @@ static int IMG_isICOCUR(SDL_RWops *src, int type)
bfCount = SDL_ReadLE16(src);
if ((bfReserved == 0) && (bfType == type) && (bfCount != 0))
is_ICOCUR = 1;
SDL_RWseek(src, start, SEEK_SET);
SDL_RWseek(src, start, RW_SEEK_SET);

return (is_ICOCUR);
}
Expand Down Expand Up @@ -361,7 +361,7 @@ static SDL_Surface *LoadBMP_RW (SDL_RWops *src, int freesrc)
/* Load the palette, if any */
palette = (surface->format)->palette;
if ( palette ) {
if ( SDL_RWseek(src, fp_offset+14+biSize, SEEK_SET) < 0 ) {
if ( SDL_RWseek(src, fp_offset+14+biSize, RW_SEEK_SET) < 0 ) {
SDL_Error(SDL_EFSEEK);
was_error = SDL_TRUE;
goto done;
Expand Down Expand Up @@ -393,7 +393,7 @@ static SDL_Surface *LoadBMP_RW (SDL_RWops *src, int freesrc)
}

/* Read the surface pixels. Note that the bmp image is upside down */
if ( SDL_RWseek(src, fp_offset+bfOffBits, SEEK_SET) < 0 ) {
if ( SDL_RWseek(src, fp_offset+bfOffBits, RW_SEEK_SET) < 0 ) {
SDL_Error(SDL_EFSEEK);
was_error = SDL_TRUE;
goto done;
Expand Down Expand Up @@ -489,7 +489,7 @@ static SDL_Surface *LoadBMP_RW (SDL_RWops *src, int freesrc)
done:
if ( was_error ) {
if ( src ) {
SDL_RWseek(src, fp_offset, SEEK_SET);
SDL_RWseek(src, fp_offset, RW_SEEK_SET);
}
if ( surface ) {
SDL_FreeSurface(surface);
Expand Down
4 changes: 2 additions & 2 deletions IMG_gif.c
Expand Up @@ -47,7 +47,7 @@ int IMG_isGIF(SDL_RWops *src)
is_GIF = 1;
}
}
SDL_RWseek(src, start, SEEK_SET);
SDL_RWseek(src, start, RW_SEEK_SET);
return(is_GIF);
}

Expand Down Expand Up @@ -266,7 +266,7 @@ IMG_LoadGIF_RW(SDL_RWops *src)

done:
if ( image == NULL ) {
SDL_RWseek(src, start, SEEK_SET);
SDL_RWseek(src, start, RW_SEEK_SET);
}
return image;
}
Expand Down
10 changes: 5 additions & 5 deletions IMG_jpg.c
Expand Up @@ -195,7 +195,7 @@ int IMG_isJPG(SDL_RWops *src)
} else if( (magic[0] != 0xFF) || (magic[1] == 0xFF) ) {
/* Extra padding in JPEG (legal) */
/* or this is data and we are scanning */
SDL_RWseek(src, -1, SEEK_CUR);
SDL_RWseek(src, -1, RW_SEEK_CUR);
} else if(magic[1] == 0xD9) {
/* Got to end of good JPEG */
break;
Expand All @@ -212,7 +212,7 @@ int IMG_isJPG(SDL_RWops *src)
Uint32 end;
start = SDL_RWtell(src);
size = (magic[2] << 8) + magic[3];
end = SDL_RWseek(src, size-2, SEEK_CUR);
end = SDL_RWseek(src, size-2, RW_SEEK_CUR);
if ( end != start + size - 2 ) is_JPG = 0;
if ( magic[1] == 0xDA ) {
/* Now comes the actual JPEG meat */
Expand All @@ -228,7 +228,7 @@ int IMG_isJPG(SDL_RWops *src)
}
}
}
SDL_RWseek(src, start, SEEK_SET);
SDL_RWseek(src, start, RW_SEEK_SET);
return(is_JPG);
}

Expand Down Expand Up @@ -393,7 +393,7 @@ SDL_Surface *IMG_LoadJPG_RW(SDL_RWops *src)
if ( surface != NULL ) {
SDL_FreeSurface(surface);
}
SDL_RWseek(src, start, SEEK_SET);
SDL_RWseek(src, start, RW_SEEK_SET);
IMG_SetError("JPEG loading error");
return NULL;
}
Expand Down Expand Up @@ -441,7 +441,7 @@ SDL_Surface *IMG_LoadJPG_RW(SDL_RWops *src)

if ( surface == NULL ) {
lib.jpeg_destroy_decompress(&cinfo);
SDL_RWseek(src, start, SEEK_SET);
SDL_RWseek(src, start, RW_SEEK_SET);
IMG_SetError("Out of memory");
return NULL;
}
Expand Down
6 changes: 3 additions & 3 deletions IMG_lbm.c
Expand Up @@ -79,7 +79,7 @@ int IMG_isLBM( SDL_RWops *src )
is_LBM = 1;
}
}
SDL_RWseek(src, start, SEEK_SET);
SDL_RWseek(src, start, RW_SEEK_SET);
return( is_LBM );
}

Expand Down Expand Up @@ -220,7 +220,7 @@ SDL_Surface *IMG_LoadLBM_RW( SDL_RWops *src )
if ( size & 1 ) ++size; /* padding ! */
size -= bytesloaded;
/* skip the remaining bytes of this chunk */
if ( size ) SDL_RWseek( src, size, SEEK_CUR );
if ( size ) SDL_RWseek( src, size, RW_SEEK_CUR );
}
}

Expand Down Expand Up @@ -474,7 +474,7 @@ SDL_Surface *IMG_LoadLBM_RW( SDL_RWops *src )

if ( error )
{
SDL_RWseek(src, start, SEEK_SET);
SDL_RWseek(src, start, RW_SEEK_SET);
if ( Image ) {
SDL_FreeSurface( Image );
Image = NULL;
Expand Down
4 changes: 2 additions & 2 deletions IMG_pcx.c
Expand Up @@ -82,7 +82,7 @@ int IMG_isPCX(SDL_RWops *src)
is_PCX = 1;
}
}
SDL_RWseek(src, start, SEEK_SET);
SDL_RWseek(src, start, RW_SEEK_SET);
return(is_PCX);
}

Expand Down Expand Up @@ -250,7 +250,7 @@ SDL_Surface *IMG_LoadPCX_RW(SDL_RWops *src)
done:
free(buf);
if ( error ) {
SDL_RWseek(src, start, SEEK_SET);
SDL_RWseek(src, start, RW_SEEK_SET);
if ( surface ) {
SDL_FreeSurface(surface);
surface = NULL;
Expand Down
4 changes: 2 additions & 2 deletions IMG_png.c
Expand Up @@ -281,7 +281,7 @@ int IMG_isPNG(SDL_RWops *src)
is_PNG = 1;
}
}
SDL_RWseek(src, start, SEEK_SET);
SDL_RWseek(src, start, RW_SEEK_SET);
return(is_PNG);
}

Expand Down Expand Up @@ -492,7 +492,7 @@ SDL_Surface *IMG_LoadPNG_RW(SDL_RWops *src)
free(row_pointers);
}
if ( error ) {
SDL_RWseek(src, start, SEEK_SET);
SDL_RWseek(src, start, RW_SEEK_SET);
if ( surface ) {
SDL_FreeSurface(surface);
surface = NULL;
Expand Down
4 changes: 2 additions & 2 deletions IMG_pnm.c
Expand Up @@ -63,7 +63,7 @@ int IMG_isPNM(SDL_RWops *src)
is_PNM = 1;
}
}
SDL_RWseek(src, start, SEEK_SET);
SDL_RWseek(src, start, RW_SEEK_SET);
return(is_PNM);
}

Expand Down Expand Up @@ -232,7 +232,7 @@ SDL_Surface *IMG_LoadPNM_RW(SDL_RWops *src)
done:
free(buf);
if(error) {
SDL_RWseek(src, start, SEEK_SET);
SDL_RWseek(src, start, RW_SEEK_SET);
if ( surface ) {
SDL_FreeSurface(surface);
surface = NULL;
Expand Down
6 changes: 3 additions & 3 deletions IMG_tga.c
Expand Up @@ -189,7 +189,7 @@ SDL_Surface *IMG_LoadTGA_RW(SDL_RWops *src)
goto unsupported;
}

SDL_RWseek(src, hdr.infolen, SEEK_CUR); /* skip info field */
SDL_RWseek(src, hdr.infolen, RW_SEEK_CUR); /* skip info field */

w = LE16(hdr.width);
h = LE16(hdr.height);
Expand Down Expand Up @@ -235,7 +235,7 @@ SDL_Surface *IMG_LoadTGA_RW(SDL_RWops *src)
SDL_SetColorKey(img, SDL_SRCCOLORKEY, ckey);
} else {
/* skip unneeded colormap */
SDL_RWseek(src, palsiz, SEEK_CUR);
SDL_RWseek(src, palsiz, RW_SEEK_CUR);
}
}

Expand Down Expand Up @@ -312,7 +312,7 @@ SDL_Surface *IMG_LoadTGA_RW(SDL_RWops *src)
error = "Unsupported TGA format";

error:
SDL_RWseek(src, start, SEEK_SET);
SDL_RWseek(src, start, RW_SEEK_SET);
if ( img ) {
SDL_FreeSurface(img);
}
Expand Down
8 changes: 4 additions & 4 deletions IMG_tif.c
Expand Up @@ -168,9 +168,9 @@ static toff_t tiff_size(thandle_t fd)
toff_t size;

save_pos = SDL_RWtell((SDL_RWops*)fd);
SDL_RWseek((SDL_RWops*)fd, 0, SEEK_END);
SDL_RWseek((SDL_RWops*)fd, 0, RW_SEEK_END);
size = SDL_RWtell((SDL_RWops*)fd);
SDL_RWseek((SDL_RWops*)fd, save_pos, SEEK_SET);
SDL_RWseek((SDL_RWops*)fd, save_pos, RW_SEEK_SET);
return size;
}

Expand All @@ -196,7 +196,7 @@ int IMG_isTIF(SDL_RWops* src)
is_TIF = 1;
}
}
SDL_RWseek(src, start, SEEK_SET);
SDL_RWseek(src, start, RW_SEEK_SET);
return(is_TIF);
}

Expand Down Expand Up @@ -261,7 +261,7 @@ SDL_Surface* IMG_LoadTIF_RW(SDL_RWops* src)
return surface;

error:
SDL_RWseek(src, start, SEEK_SET);
SDL_RWseek(src, start, RW_SEEK_SET);
if ( surface ) {
SDL_FreeSurface(surface);
}
Expand Down
20 changes: 10 additions & 10 deletions IMG_xcf.c
Expand Up @@ -222,7 +222,7 @@ int IMG_isXCF(SDL_RWops *src)
is_XCF = 1;
}
}
SDL_RWseek(src, start, SEEK_SET);
SDL_RWseek(src, start, RW_SEEK_SET);
return(is_XCF);
}

Expand Down Expand Up @@ -282,7 +282,7 @@ static void xcf_read_property (SDL_RWops * src, xcf_prop * prop) {
break;
default:
// SDL_RWread (src, &prop->data, prop->length, 1);
SDL_RWseek (src, prop->length, SEEK_CUR);
SDL_RWseek (src, prop->length, RW_SEEK_CUR);
}
}

Expand Down Expand Up @@ -553,17 +553,17 @@ static int do_layer_surface (SDL_Surface * surface, SDL_RWops * src, xcf_header
int x, y, tx, ty, ox, oy, i, j;
Uint32 *row;

SDL_RWseek (src, layer->hierarchy_file_offset, SEEK_SET);
SDL_RWseek (src, layer->hierarchy_file_offset, RW_SEEK_SET);
hierarchy = read_xcf_hierarchy (src);

level = NULL;
for (i = 0; hierarchy->level_file_offsets [i]; i++) {
SDL_RWseek (src, hierarchy->level_file_offsets [i], SEEK_SET);
SDL_RWseek (src, hierarchy->level_file_offsets [i], RW_SEEK_SET);
level = read_xcf_level (src);

ty = tx = 0;
for (j = 0; level->tile_file_offsets [j]; j++) {
SDL_RWseek (src, level->tile_file_offsets [j], SEEK_SET);
SDL_RWseek (src, level->tile_file_offsets [j], RW_SEEK_SET);
ox = tx+64 > level->width ? level->width % 64 : 64;
oy = ty+64 > level->height ? level->height % 64 : 64;

Expand Down Expand Up @@ -739,7 +739,7 @@ SDL_Surface *IMG_LoadXCF_RW(SDL_RWops *src)
// Blit layers backwards, because Gimp saves them highest first
for (i = offsets; i > 0; i--) {
SDL_Rect rs, rd;
SDL_RWseek (src, head->layer_file_offsets [i-1], SEEK_SET);
SDL_RWseek (src, head->layer_file_offsets [i-1], RW_SEEK_SET);

layer = read_xcf_layer (src);
do_layer_surface (lays, src, head, layer, load_tile);
Expand All @@ -759,17 +759,17 @@ SDL_Surface *IMG_LoadXCF_RW(SDL_RWops *src)

SDL_FreeSurface (lays);

SDL_RWseek (src, fp, SEEK_SET);
SDL_RWseek (src, fp, RW_SEEK_SET);

// read channels
channel = NULL;
chnls = 0;
while ((offset = SDL_ReadBE32 (src))) {
channel = (xcf_channel **) realloc (channel, sizeof (xcf_channel *) * (chnls+1));
fp = SDL_RWtell (src);
SDL_RWseek (src, offset, SEEK_SET);
SDL_RWseek (src, offset, RW_SEEK_SET);
channel [chnls++] = (read_xcf_channel (src));
SDL_RWseek (src, fp, SEEK_SET);
SDL_RWseek (src, fp, RW_SEEK_SET);
}

if (chnls) {
Expand Down Expand Up @@ -797,7 +797,7 @@ SDL_Surface *IMG_LoadXCF_RW(SDL_RWops *src)
done:
free_xcf_header (head);
if ( error ) {
SDL_RWseek(src, start, SEEK_SET);
SDL_RWseek(src, start, RW_SEEK_SET);
if ( surface ) {
SDL_FreeSurface(surface);
surface = NULL;
Expand Down
4 changes: 2 additions & 2 deletions IMG_xpm.c
Expand Up @@ -68,7 +68,7 @@ int IMG_isXPM(SDL_RWops *src)
is_XPM = 1;
}
}
SDL_RWseek(src, start, SEEK_SET);
SDL_RWseek(src, start, RW_SEEK_SET);
return(is_XPM);
}

Expand Down Expand Up @@ -457,7 +457,7 @@ static SDL_Surface *load_xpm(char **xpm, SDL_RWops *src)
done:
if(error) {
if ( src )
SDL_RWseek(src, start, SEEK_SET);
SDL_RWseek(src, start, RW_SEEK_SET);
if ( image ) {
SDL_FreeSurface(image);
image = NULL;
Expand Down
4 changes: 2 additions & 2 deletions IMG_xv.c
Expand Up @@ -96,7 +96,7 @@ int IMG_isXV(SDL_RWops *src)
if ( get_header(src, &w, &h) == 0 ) {
is_XV = 1;
}
SDL_RWseek(src, start, SEEK_SET);
SDL_RWseek(src, start, RW_SEEK_SET);
return(is_XV);
}

Expand Down Expand Up @@ -139,7 +139,7 @@ SDL_Surface *IMG_LoadXV_RW(SDL_RWops *src)

done:
if ( error ) {
SDL_RWseek(src, start, SEEK_SET);
SDL_RWseek(src, start, RW_SEEK_SET);
if ( surface ) {
SDL_FreeSurface(surface);
surface = NULL;
Expand Down
4 changes: 2 additions & 2 deletions IMG_xxx.c
Expand Up @@ -41,7 +41,7 @@ int IMG_isXXX(SDL_RWops *src)

/* Detect the image here */

SDL_RWseek(src, start, SEEK_SET);
SDL_RWseek(src, start, RW_SEEK_SET);
return(is_XXX);
}

Expand All @@ -61,7 +61,7 @@ SDL_Surface *IMG_LoadXXX_RW(SDL_RWops *src)
/* Load the image here */

if ( error ) {
SDL_RWseek(src, start, SEEK_SET);
SDL_RWseek(src, start, RW_SEEK_SET);
if ( surface ) {
SDL_FreeSurface(surface);
surface = NULL;
Expand Down

0 comments on commit 7464176

Please sign in to comment.