example.c
/*
   This function is passed a buffer which is to be filled by the function.
   It returns the amount within it.
   Returning 0 represents EOF and -1 represents an error.
   When an error occurs, this function should handle clean up.
*/
This function is passed a buffer which is to be filled by the function.
It returns the amount within it.
Returning 0 represents EOF and -1 represents an error.
When an error occurs, this function should handle clean up.
This function is passed a buffer which is to be filled by the function . It returns the amount within it . Returning 0 represents EOF and - 1 represents an error . When an error occurs this function should handle clean up .
static int ReadAttach(FILE **File, void *Buffer, unsigned int BufferSize)
{
	size_t Result;
	if (*File == NULL) {
		*File = fopen(ATTACHMENT_FILE, "rb");
		if (!*File) {
			fprintf(stderr, "Error while reading '%s'.\n", ATTACHMENT_FILE);
			return -1;
		}
	}
	Result = fread(Buffer, 1, BufferSize, *File);
	if (Result != BufferSize) {
		if (ferror(*File)) {
			CloseAttach(File);
			return -1;
		}
		else if (!Result && feof(*File))
			CloseAttach(File);
	}
	return Result;
}
static int ReadAttach ( FILE * * File , void * Buffer , unsigned int BufferSize ) { size_t Result ; if ( * File == NULL ) { * File = fopen ( ATTACHMENT_FILE , " " ) ; if ( ! * File ) { fprintf ( stderr , " \n " , ATTACHMENT_FILE ) ; return -1 ; } } Result = fread ( Buffer , 1 , BufferSize , * File ) ; if ( Result != BufferSize ) { if ( ferror ( * File ) ) { CloseAttach ( File ) ; return -1 ; } else if ( ! Result && feof ( * File ) ) CloseAttach ( File ) ; } return Result ; }
This function is passed a buffer which is to be filled by the function.
This function is passed a buffer which is to be filled by the function .