奇怪的编程方法?---请问这种代码的源文件怎么执行?
像这种源代码,怎么去调用?
源代码实现的功能是 从代码所在的目录下的读入自定义的一种图片格式的文件,然后转换成sun raster file 格式输出,这个文件的文件名是 ihdr2sum
请问像这种源代码,怎么去调用,怎么去执行----我连 bulid都找不到?
还请问这种main与其自带大括号中间还放上其参数变量算什么c语言的什么性质---在圣经《c程序设计语言》用什么关键字可以找到,我想看一下。
main(argc,argv)
int argc;
char *argv[];
{
int width,height,depth,filesize,maplength;
struct rasterfile rasterhdr;
char *filename, *mapfile, *outfile, sunfile[BUFSIZE];
unsigned char *data, *map;
IHEAD *ihead;
FILE *fp;
procargs(argc,argv,&filename,&mapfile,&outfile);
ReadIheadRaster(filename,&ihead,&data,&width,&height,&depth);
if((depth != 1) && (depth != 8)){
(void) fprintf(stderr,"Pixel depth of %d is not currently supported.\n",
depth);
exit(-1);
}
rasterhdr.ras_magic = RAS_MAGIC;
rasterhdr.ras_width = width;
rasterhdr.ras_height = height;
rasterhdr.ras_depth = depth;
filesize = SizeFromDepth(width,height,depth);
rasterhdr.ras_length = filesize;
rasterhdr.ras_type = RT_STANDARD;
if (depth == 8) {
if (mapfile == (char *) NULL)
mapfile = DEFAULTMAP;
ReadSunColormap(mapfile, &map, &maplength);
rasterhdr.ras_maplength = maplength;
rasterhdr.ras_maptype = RMT_EQUAL_RGB;
} else {
maplength = 0;
rasterhdr.ras_maplength = maplength;
rasterhdr.ras_maptype = RMT_NONE;
}
if (outfile == (char *) NULL) {
(void) strcpy(sunfile, filename);
fileroot(sunfile);
(void) strcat(sunfile, SUNEXT);
} else
(void) strcpy(sunfile, outfile);
if ((fp = fopen(sunfile,"w")) == (FILE *) NULL) {
(void) fprintf(stderr,"Unable to open file %s\n",sunfile);
exit(-1);
}
(void) fwrite((char *)&rasterhdr,1,sizeof(struct rasterfile),fp);
if (maplength != 0) {
(void) fwrite((char *)map, 1, maplength, fp);
free((char *) map);
}