FileError File::read( FileHandle fh, void* buffer, size_t inSize ) { if( !Is_Open( fh ) || !Read_Bytes( fh, buffer, inSize ) ) return FILE_READ_FAIL; else return FILE_SUCCESS; }
*/ int Read_Line(STD_TERM *term, char *result, int limit) /* ** Read a line (as a sequence of bytes) from the terminal. ** Handles line editing and line history recall. ** Returns number of bytes in line. ** ***********************************************************************/ { char buf[READ_BUF_LEN]; char *cp; int len; // length of IO read term->pos = term->end = 0; term->hist = Line_Count; term->out = 0; term->buffer[0] = 0; do { Read_Bytes(term, buf, READ_BUF_LEN-2); for (cp = buf; *cp;) { cp = Process_Key(term, cp); } } while (!term->out); // Not at end of input? Save any unprocessed chars: if (*cp) { if (strlen(term->residue) + strlen(cp) < TERM_BUF_LEN-1) // avoid overrun strcat(term->residue, cp); } // Fill the output buffer: len = strlen(term->out); if (len >= limit-1) len = limit-2; strncpy(result, term->out, limit); result[len++] = LF; result[len] = 0; return len; }
void Load_Opacity(char filename []) { char local_filename[FILENAME_STRING_SIZE]; int fd; strcpy(local_filename,filename); strcat(local_filename,".opc"); fd = Open_File(local_filename); Read_Shorts(fd,(unsigned char *)&opc_version, (long)sizeof(opc_version)); if (opc_version != OPC_CUR_VERSION) Error(" Can't load version %d file\n",opc_version); Read_Shorts(fd,(unsigned char *)opc_len,(long)sizeof(map_len)); Read_Longs(fd,(unsigned char *)&opc_length,(long)sizeof(opc_length)); Allocate_Opacity(&opc_address,opc_length); printf(" Loading opacity map from .opc file...\n"); Read_Bytes(fd,(unsigned char *)opc_address,(long)(opc_length*sizeof(OPACITY))); Close_File(fd); }