tools/header_generation/create_hdr_common.c
/***************************************************************************
 * Function	:	read_file_in_buffer
 * Arguments	:	Pointer to bugffer, File Name
 * Return	:	SUCCESS or FAILURE
 * Description	:	Opens a binary file and places the content in a
 *			buffer memory
 ***************************************************************************/
Function     :       read_file_in_buffer
Arguments    :       Pointer to bugffer, File Name
Return       :       SUCCESS or FAILURE
Description  :       Opens a binary file and places the content in a
buffer memory
Function : read_file_in_buffer Arguments : Pointer to bugffer File Name Return : SUCCESS or FAILURE Description : Opens a binary file and places the content in a buffer memory
int read_file_in_buffer(uint8_t *ptr, char *file_name)
{
	FILE *fp;
	size_t bytes, bytes_copied;
	unsigned char buf[IOBLOCK];
	fp = fopen(file_name, "rb");
	if (fp == NULL) {
		printf("Error in opening the IE Table file\n");
		return FAILURE;
	}
	fseek(fp, 0L, SEEK_SET);
	bytes_copied = 0;
	bytes = 0;
	while (!feof(fp)) {
		bytes = fread(buf, 1, IOBLOCK, fp);
		if (ferror(fp)) {
			printf("Error in reading file\n");
			fclose(fp);
			return FAILURE;
		} else if (feof(fp) && (bytes == 0)) {
			break;
		}
		memcpy(ptr + bytes_copied, buf, bytes);
		bytes_copied += bytes;
	}
	fclose(fp);
	return SUCCESS;
}
int read_file_in_buffer ( uint8_t * ptr , char * file_name ) { FILE * fp ; size_t bytes , bytes_copied ; unsigned char buf [ IOBLOCK ] ; fp = fopen ( file_name , " " ) ; if ( fp == NULL ) { printf ( " \n " ) ; return FAILURE ; } fseek ( fp , 0L , SEEK_SET ) ; bytes_copied = 0 ; bytes = 0 ; while ( ! feof ( fp ) ) { bytes = fread ( buf , 1 , IOBLOCK , fp ) ; if ( ferror ( fp ) ) { printf ( " \n " ) ; fclose ( fp ) ; return FAILURE ; } else if ( feof ( fp ) && ( bytes == 0 ) ) { break ; } memcpy ( ptr + bytes_copied , buf , bytes ) ; bytes_copied += bytes ; } fclose ( fp ) ; return SUCCESS ; }
Function     :       read_file_in_buffer
 Arguments    :       Pointer to bugffer, File Name
 Return       :       SUCCESS or FAILURE
 Description  :       Opens a binary file and places the content in a
                      buffer memory
Function : read_file_in_buffer Arguments : Pointer to bugffer File Name Return : SUCCESS or FAILURE Description : Opens a binary file and places the content in a buffer memory
/* go to the begenning */ /* read some data */