/** * \file * header file of ProtoInterface */ #ifndef PROTOINTERFACE_H #define PROTOINTERFACE_H #include "buffer.h" #include "proto.h" /*====================================================== ======== TYPES ========================================= ======================================================*/ /** \defgroup ProtoInterface ProtoInterface for protoLIN.dll */ /** \{ */ #define PROTOINTERFACE_MESSAGE_BUFFER_INIT_SIZE 300 /** Encapsulate memory allocation and message printing calls. This is needed because PowerView needs PROTO_Alloc() to allocate memory and PROTO_Printf() or PROTO_Puts to print strings. For testing purporses another implementation is linked. */ typedef struct ProtoInterface { protoContext context; BufferVector printBuffer; } ProtoInterface; /** \} */ /*====================================================== ======== FUNCTIONS ===================================== ======================================================*/ /** \addtogroup ProtoInterface */ /** \{ */ int protoInterface_init(ProtoInterface *protoInterfacep, protoContext context); void protoInterface_destroy(ProtoInterface *protoInterfacep); /** Add formated message to print buffer and print till last '\n'. \returns number of written characters if successfully or 0 if failed. */ int protoInterface_printf(ProtoInterface *protoInterfacep, const char *formatString, ...); /** Add message to print buffer and print till last '\n'. \returns number of written characters if successfully or 0 if failed. */ int protoInterface_prints(ProtoInterface *protoInterfacep, const char *outputStringp); /* Force print of buffer and flushs it. */ void protoInterface_flush(ProtoInterface *protoInterfacep); /* Allocates memory. */ INLINE void* protoInterface_alloc(ProtoInterface *protoInterfacep, size_t size) { return PROTO_Alloc(protoInterfacep->context, size); } /* Frees allocated memory. In case of PROTO this is done by host software => nothing todo. */ INLINE void protoInterface_free(ProtoInterface *protoInterfacep, void *p) { } /** \} */ #endif