/*
 * esd10.h
 *
 * Copyright (c) 2010 ETEL SA. All Rights Reserved.
 *
 * This software is the confidential and proprietary informatione of ETEL SA
 * ("Confidential Information"). You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the
 * license agreement you entered into with ETEL.
 *
 * This software is provided "AS IS," without a warranty of any kind. ALL
 * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
 * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
 * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. ETEL AND ITS LICENSORS SHALL NOT BE
 * LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
 * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL ETEL OR ITS
 * LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
 * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
 * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
 * OR INABILITY TO USE SOFTWARE, EVEN IF ETEL HAS BEEN ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGES.
 *
 * This software is not designed or intended for use in on-line control of
 * aircraft, air traffic, aircraft navigation or aircraft communications; or in
 * the design, construction, operation or maintenance of any nuclear
 * facility. Licensee represents and warrants that it will not use or
 * redistribute the Software for such purposes.
 *
 */

/**
 * This header file contains public declarations for the etel sequence downloader EDI library.\n
 * This library is conformed to POSIX 1003.1c
 * @file esd10.h
 */


#ifndef _GEN10_H
#define _GEN10_H


/**********************************************************************************************************/
/*- LIBRARIES */
/**********************************************************************************************************/

/*----------------------*/
/* common libraries		*/
#include <stdio.h>
#include <stddef.h>
#include <stdarg.h>
#include <time.h>
#include <string.h>
#if defined __cplusplus && !defined LINUX
	#include <typeinfo.h>
#endif

#include <lib20.h>

/**
 * @defgroup ESDAll ESD All functions
 */
/*@{*/
/*@}*/

/**
 * @defgroup ESDErrorsAndWarnings ESD Error and warnings
 */
/*@{*/
/*@}*/


/**********************************************************************************************************/
/*- LITTERALS */
/**********************************************************************************************************/

#ifdef __WIN32__		/* defined by Borland C++ Builder */
	#ifndef WIN32
		#define WIN32
	#endif
#endif


#ifdef __cplusplus
	extern "C" {
#endif

/*------------------------------*/
/* WINDOWS type modifiers		*/
#ifdef WIN32
	#define _ESD_EXPORT __cdecl                          /* function exported by static library */
#endif /* WIN32 */

/*------------------------------*/
/* POSIX type modifiers			*/
#ifdef POSIX
	#define _ESD_EXPORT                           /* function exported by library */
#endif /* POSIX */

/*------------------------------------------------------------------------------
 * error codes - c
 *-----------------------------------------------------------------------------*/
#define ESD_ENOTAVAILABLE                -2514       /**< the required element is not available */
#define ESD_EBADLABEL                    -2513       /**< the label numer is out of range */
#define ESD_EFORMAT                      -2509       /**< bad file format */
#define ESD_EEOF                         -2508       /**< unexpected end of file reached */
#define ESD_EIO                         -2507       /**< cannot access to the file */
#define ESD_EOVERFLOW                    -2506       /**< the buffer is too small */
#define ESD_EINTERNAL                    -2503       /**< some internal error in the etel software */
#define ESD_ESYSTEM                      -2501       /**< some system resource return an error */
#define ESD_EBADPARAM                    -2500       /**< one of the parameter is not valid */


/*------------------------------------------------------------------------------
 * hidden structures for library clients
 *-----------------------------------------------------------------------------*/
#ifndef ESD_XML_STREAM
	#define ESD_XML_STREAM void
#endif

#define ESD_MAX_SEQ_FLASH_SIZE			1048576			/* Size of the available flash for sequence and source in the drive */

/**********************************************************************************************************/
/*- PROTOTYPES */
/**********************************************************************************************************/

/**
 * @addtogroup ESDAll
 * @{
 */
dword _ESD_EXPORT esd_get_version(void);
dword _ESD_EXPORT esd_get_edi_version(void);
time_t _ESD_EXPORT esd_get_build_time(void);
char_cp _ESD_EXPORT esd_translate_error(int code);

int	_ESD_EXPORT esd_xml_create_input_stream(ESD_XML_STREAM **s, char *filename);
int	_ESD_EXPORT esd_xml_destroy_stream(ESD_XML_STREAM *s);
int _ESD_EXPORT esd_xml_read_tag(ESD_XML_STREAM *s, char *buff, int len);
int _ESD_EXPORT esd_xml_read_text(ESD_XML_STREAM *s, char *buff, int len);
int _ESD_EXPORT esd_xml_reset(ESD_XML_STREAM *s);
int _ESD_EXPORT esd_get_source_code(char *stream_data, int stream_data_size, char **source_code_begin, long *source_code_size);
bool _ESD_EXPORT esd_check_stream_data_crc(char *stream_data, int stream_data_size);
int _ESD_EXPORT esd_build_eseq_file(char *src_file_name, char *xml_file_name, char *eseq_file_name);
int _ESD_EXPORT esd_build_stream_data(char *src_file_name, char *xml_file_name, char *stream_data, long stream_data_max, long *stream_data_size);
int _ESD_EXPORT esd_build_stream_data2(char *xml_file_name, char *stream_data, long stream_data_max, long *stream_data_size);
int _ESD_EXPORT esd_extract_source_code(char *eseq_file_name, char *src_file_name);
/** @} */

#ifdef __cplusplus
	} /* extern "C" */
#endif

#endif /* _GEN10_H */
