mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
ANSIfied somewhat.
This commit is contained in:
parent
c6d846a5d5
commit
92fa23fd6d
1 changed files with 22 additions and 21 deletions
|
@ -17,6 +17,7 @@
|
||||||
#include "allobjects.h"
|
#include "allobjects.h"
|
||||||
#include "modsupport.h"
|
#include "modsupport.h"
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* from image.h
|
* from image.h
|
||||||
|
@ -80,12 +81,12 @@ typedef struct {
|
||||||
|
|
||||||
#define CHANOFFSET(z) (3-(z)) /* this is byte order dependent */
|
#define CHANOFFSET(z) (3-(z)) /* this is byte order dependent */
|
||||||
|
|
||||||
static expandrow();
|
static expandrow PROTO((unsigned char *, unsigned char *, int));
|
||||||
static setalpha();
|
static setalpha PROTO((unsigned char *, int));
|
||||||
static copybw();
|
static copybw PROTO((long *, int));
|
||||||
static interleaverow();
|
static interleaverow PROTO((unsigned char *, unsigned char *, int, int));
|
||||||
static int compressrow();
|
static int compressrow PROTO((unsigned char *, unsigned char *, int, int));
|
||||||
static lumrow();
|
static lumrow PROTO((unsigned char *, unsigned char *, int));
|
||||||
|
|
||||||
#ifdef ADD_TAGS
|
#ifdef ADD_TAGS
|
||||||
#define TAGLEN (5)
|
#define TAGLEN (5)
|
||||||
|
@ -164,7 +165,7 @@ static readheader(inf,image)
|
||||||
FILE *inf;
|
FILE *inf;
|
||||||
IMAGE *image;
|
IMAGE *image;
|
||||||
{
|
{
|
||||||
bzero(image,sizeof(IMAGE));
|
memset(image,0,sizeof(IMAGE));
|
||||||
image->imagic = getshort(inf);
|
image->imagic = getshort(inf);
|
||||||
image->type = getshort(inf);
|
image->type = getshort(inf);
|
||||||
image->dim = getshort(inf);
|
image->dim = getshort(inf);
|
||||||
|
@ -179,7 +180,7 @@ IMAGE *image;
|
||||||
{
|
{
|
||||||
IMAGE t;
|
IMAGE t;
|
||||||
|
|
||||||
bzero(&t,sizeof(IMAGE));
|
memset(&t,0,sizeof(IMAGE));
|
||||||
fwrite(&t,sizeof(IMAGE),1,outf);
|
fwrite(&t,sizeof(IMAGE),1,outf);
|
||||||
fseek(outf,0,SEEK_SET);
|
fseek(outf,0,SEEK_SET);
|
||||||
putshort(outf,image->imagic);
|
putshort(outf,image->imagic);
|
||||||
|
@ -260,7 +261,7 @@ longimagedata(self, args)
|
||||||
object *self, *args;
|
object *self, *args;
|
||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
unsigned long *base, *lptr;
|
unsigned char *base, *lptr;
|
||||||
unsigned char *rledat, *verdat;
|
unsigned char *rledat, *verdat;
|
||||||
long *starttab, *lengthtab;
|
long *starttab, *lengthtab;
|
||||||
FILE *inf;
|
FILE *inf;
|
||||||
|
@ -331,7 +332,7 @@ longimagedata(self, args)
|
||||||
free(rledat);
|
free(rledat);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
base = (unsigned long *) getstringvalue(rv);
|
base = (unsigned char *) getstringvalue(rv);
|
||||||
#ifdef ADD_TAGS
|
#ifdef ADD_TAGS
|
||||||
addlongimgtag(base,xsize,ysize);
|
addlongimgtag(base,xsize,ysize);
|
||||||
#endif
|
#endif
|
||||||
|
@ -355,7 +356,7 @@ longimagedata(self, args)
|
||||||
fread(rledat,lengthtab[y+z*ysize],1,inf);
|
fread(rledat,lengthtab[y+z*ysize],1,inf);
|
||||||
cur += lengthtab[y+z*ysize];
|
cur += lengthtab[y+z*ysize];
|
||||||
expandrow(lptr,rledat,3-z);
|
expandrow(lptr,rledat,3-z);
|
||||||
lptr += xsize;
|
lptr += xsize * sizeof(unsigned long);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -370,13 +371,13 @@ longimagedata(self, args)
|
||||||
cur += lengthtab[y+z*ysize];
|
cur += lengthtab[y+z*ysize];
|
||||||
expandrow(lptr,rledat,3-z);
|
expandrow(lptr,rledat,3-z);
|
||||||
}
|
}
|
||||||
lptr += xsize;
|
lptr += xsize * sizeof(unsigned long);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(zsize == 3)
|
if(zsize == 3)
|
||||||
setalpha(base,xsize*ysize);
|
setalpha(base,xsize*ysize);
|
||||||
else if(zsize<3)
|
else if(zsize<3)
|
||||||
copybw(base,xsize*ysize);
|
copybw((long *) base,xsize*ysize);
|
||||||
fclose(inf);
|
fclose(inf);
|
||||||
free(starttab);
|
free(starttab);
|
||||||
free(lengthtab);
|
free(lengthtab);
|
||||||
|
@ -389,7 +390,7 @@ longimagedata(self, args)
|
||||||
fclose(inf);
|
fclose(inf);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
base = (unsigned long *) getstringvalue(rv);
|
base = (unsigned char *) getstringvalue(rv);
|
||||||
#ifdef ADD_TAGS
|
#ifdef ADD_TAGS
|
||||||
addlongimgtag(base,xsize,ysize);
|
addlongimgtag(base,xsize,ysize);
|
||||||
#endif
|
#endif
|
||||||
|
@ -400,13 +401,13 @@ longimagedata(self, args)
|
||||||
for(y=0; y<ysize; y++) {
|
for(y=0; y<ysize; y++) {
|
||||||
fread(verdat,xsize,1,inf);
|
fread(verdat,xsize,1,inf);
|
||||||
interleaverow(lptr,verdat,3-z,xsize);
|
interleaverow(lptr,verdat,3-z,xsize);
|
||||||
lptr += xsize;
|
lptr += xsize * sizeof(unsigned long);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(zsize == 3)
|
if(zsize == 3)
|
||||||
setalpha(base,xsize*ysize);
|
setalpha(base,xsize*ysize);
|
||||||
else if(zsize<3)
|
else if(zsize<3)
|
||||||
copybw(base,xsize*ysize);
|
copybw((long *) base,xsize*ysize);
|
||||||
fclose(inf);
|
fclose(inf);
|
||||||
free(verdat);
|
free(verdat);
|
||||||
return rv;
|
return rv;
|
||||||
|
@ -535,7 +536,7 @@ static object *
|
||||||
longstoimage(self, args)
|
longstoimage(self, args)
|
||||||
object *self, *args;
|
object *self, *args;
|
||||||
{
|
{
|
||||||
unsigned long *lptr;
|
unsigned char *lptr;
|
||||||
char *name;
|
char *name;
|
||||||
int xsize, ysize, zsize;
|
int xsize, ysize, zsize;
|
||||||
FILE *outf;
|
FILE *outf;
|
||||||
|
@ -543,7 +544,7 @@ longstoimage(self, args)
|
||||||
int tablen, y, z, pos, len;
|
int tablen, y, z, pos, len;
|
||||||
long *starttab, *lengthtab;
|
long *starttab, *lengthtab;
|
||||||
unsigned char *rlebuf;
|
unsigned char *rlebuf;
|
||||||
unsigned long *lumbuf;
|
unsigned char *lumbuf;
|
||||||
int rlebuflen, goodwrite;
|
int rlebuflen, goodwrite;
|
||||||
|
|
||||||
if (!getargs(args, "(s#iiis)", &lptr, &len, &xsize, &ysize, &zsize, &name))
|
if (!getargs(args, "(s#iiis)", &lptr, &len, &xsize, &ysize, &zsize, &name))
|
||||||
|
@ -561,9 +562,9 @@ longstoimage(self, args)
|
||||||
lengthtab = (long *)malloc(tablen);
|
lengthtab = (long *)malloc(tablen);
|
||||||
rlebuflen = 1.05*xsize+10;
|
rlebuflen = 1.05*xsize+10;
|
||||||
rlebuf = (unsigned char *)malloc(rlebuflen);
|
rlebuf = (unsigned char *)malloc(rlebuflen);
|
||||||
lumbuf = (unsigned long *)malloc(xsize*sizeof(long));
|
lumbuf = (unsigned char *)malloc(xsize*sizeof(long));
|
||||||
|
|
||||||
bzero(&image,sizeof(IMAGE));
|
memset(&image,0,sizeof(IMAGE));
|
||||||
image.imagic = IMAGIC;
|
image.imagic = IMAGIC;
|
||||||
image.type = RLE(1);
|
image.type = RLE(1);
|
||||||
if(zsize>1)
|
if(zsize>1)
|
||||||
|
@ -600,7 +601,7 @@ longstoimage(self, args)
|
||||||
lengthtab[y+z*ysize] = len;
|
lengthtab[y+z*ysize] = len;
|
||||||
pos += len;
|
pos += len;
|
||||||
}
|
}
|
||||||
lptr += xsize;
|
lptr += xsize * sizeof(unsigned long);
|
||||||
}
|
}
|
||||||
|
|
||||||
fseek(outf,512,SEEK_SET);
|
fseek(outf,512,SEEK_SET);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue