Category : Printer + Display Graphics
Archive   : RAYSH386.ZIP
Filename : A2HF.C

 
Output of file : A2HF.C contained in archive : RAYSH386.ZIP
#include

/*
* simple ascii to rayshade height field converter.
* reads standard in, writes standard out.
* each number must be on a line by itself.
*
* Rusty Wright
* [email protected]
*/

#ifdef __WATCOMC__
#include
#endif

main(int argc,char **argv) {
char buf[BUFSIZ];
int length, line;
float height;


if (argc!=1) {
printf("Convert ascii file to .hf file for RayShade.\n\n");
printf("usage: a2hf < infile > outfile\n\n");
exit(1);
}

#ifdef __WATCOMC__
setmode(stdin->_handle,O_BINARY);
setmode(stdout->_handle,O_BINARY);
#endif

if (fgets(buf, sizeof(buf), stdin) == NULL) {
fprintf(stderr, "premature eof on stdin\n");
exit(1);
}

line = 1;

if (sscanf(buf, "%d", &length) != 1) {
fprintf(stderr, "format error line %d\n", line);
exit(1);
}

if (fwrite((char *) &length, sizeof(length), 1, stdout) != 1) {
perror("write");
exit(1);
}

while (fgets(buf, sizeof(buf), stdin) != NULL) {
line++;


if (sscanf(buf, "%g", &height) != 1) {
fprintf(stderr, "format error line %d\n", line);
exit(1);
}

if (fwrite((char *) &height, sizeof(height), 1, stdout) != 1) {
perror("write");
exit(1);
}
}

exit(0);
}


  3 Responses to “Category : Printer + Display Graphics
Archive   : RAYSH386.ZIP
Filename : A2HF.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/