/**** * * Implementation of images.h, including raw hex data for the images. The * hard-coded sizes for the images were determined using "ls -l". * * A critical subtlety in the code is the use of the "b" option in the second * arg of fopen. The "b" is for "binary", and it's necessary to avoid * conversion of "\n" to "\m\n" in the cygwin (Windoze) version of fwrite. * According to the ANSI doc for fopen, the "b" option is a completely ignored * anachronism, which exists only for backwards compatibility. Evidently, it * is not anachronistic in Windoze, since without it, the small_black_arrow * data get hosed in Windoze, since they contain two instances of "\n". * * All this was discovered when the size of the written small-black-arrow.gif * was 52 bytes, instead of the 50 bytes that the fwrite arg says were supposed * to be written. "What part of ``write N bytes'' does Windows not * understand?!?" was the refrain during the search for the problem, with * attitudes ranging from bemused, to incredulous, to fully pissed off. * */ #include #include "images.h" /** * Raw hex for component-symbol.gif. */ const char component_symbol[] = { 0x47, 0x49, 0x46, 0x38, 0x37, 0x61, 0x0f, 0x00, 0x09, 0x00, 0xf0, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x09, 0x00, 0x00, 0x02, 0x17, 0x84, 0x0f, 0x81, 0x7b, 0xa1, 0xce, 0x0c, 0x44, 0x53, 0xaa, 0x98, 0x1e, 0x5e, 0xef, 0xc6, 0x9a, 0x71, 0x9e, 0x18, 0x6e, 0x52, 0x54, 0x00, 0x00, 0x3b }; int component_symbol_size = 56; /** * Raw hex for inheritance-symbol.gif. */ const char inheritance_symbol[] = { 0x47, 0x49, 0x46, 0x38, 0x37, 0x61, 0x09, 0x00, 0x0b, 0x00, 0xf0, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x0b, 0x00, 0x00, 0x02, 0x14, 0x84, 0x6f, 0x81, 0x19, 0x8a, 0xee, 0x40, 0x3b, 0x6a, 0xbe, 0xf8, 0x24, 0x96, 0x34, 0x53, 0xb8, 0x68, 0x1b, 0x55, 0x00, 0x00, 0x3b, 0x00 }; int inheritance_symbol_size = 53; /** * Raw hex for small-black-arrow.gif. */ const char small_black_arrow[] = { 0x47, 0x49, 0x46, 0x38, 0x37, 0x61, 0x08, 0x00, 0x0a, 0x00, 0xf0, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0a, 0x00, 0x00, 0x02, 0x11, 0x0c, 0x8e, 0x10, 0x9b, 0xba, 0x86, 0x1e, 0x3b, 0xf2, 0xb9, 0x8a, 0x59, 0x8d, 0x33, 0xb6, 0x53, 0x00, 0x00, 0x3b }; int small_black_arrow_size = 50; extern int errno; Images::Images() { component_symbol_file = "component-symbol.gif"; inheritance_symbol_file = "inheritance-symbol.gif"; small_black_arrow_file = "small-black-arrow.gif"; } void Images::Write() { FILE* fd; fd = fopen(component_symbol_file, "wb"); if (fwrite(component_symbol, 1, component_symbol_size, fd) == -1) { printf("Cannot write small image file.\n"); } fd = fopen(inheritance_symbol_file, "wb"); if (fwrite(inheritance_symbol, 1, inheritance_symbol_size, fd) == -1) { printf("Cannot write small image file.\n"); } fd = fopen(small_black_arrow_file, "wb"); if (fwrite(small_black_arrow, 1, small_black_arrow_size, fd) == -1) { printf("Cannot write small image file.\n"); } }