/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * COPYING NOTES:
 *
 * iofile.h -- Advanced I/O file managing functions header
 *
 * Copyright (C) 2000 Roberto A. Foglietta <robang@libero.it>
 * Copyright (C) 2002 GEA-Automotive <fogliettar@gea-automotive.com>
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program; if not, write to the Free Software
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
 */

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
 * REVISION NOTES:
 *
 * released 16-10-2002 by Roberto A. Foglietta
 *
 */
 
 
#ifndef _LIBIOFILE_H
#define _LIBIOFILE_H

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Include that are necessary or supposed usefull
 */
#include <stdio.h>   //declaretion of FILE* type variable for the file pointer
#include <stdlib.h>  //useful for function 'free' to dealloc the file buffer
 

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Function syntax  
 */ 


FILE *check_n_openfile (const char *name, const char *mode);
/*
 * filep = check_n_openfile ( name, mode );
 *
 * this function return the pointer 'filep' to the file which 'name' was passed
 * as first argument opened in 'mode' (es.: "r+", "wt", etc.). In case of fatal 
 * error 'filep' will be set to NULL.
 */

unsigned long get_file_lenght (FILE * fp);
/*
 * lung = get_file_lenght ( filep );
 *
 * this function return the lenght 'lung' of the file pointed by 'filep' passed
 * as first parameter, that point to opened file which you're interested in.
 */

unsigned char *read_file_to_buffer (const char *name, const char *mode, long *lun);
/*
 * buffer = read_file_to_buffer (name, mode, &lun);
 *
 * this function try to access to the file specified by path in the first 
 * parameter 'name' and check if it possibile open it in 'mode' (es.: "r+", 
 * "rt", etc.), check the lenght and store it in 'lun', alloc the necessary 
 * memory, open the file and read it into allocated buffer. If each of these
 * will succeded it will return the pointer to allocated buffer which contain
 * the file contenent otherwise it will return NULL.
 */

#endif