#include <ansi_parms.h>
#include <ewl_misra_types.h>
#include <stdio_api.h>
#include <string.h>

void * _EWL_CDECL __StringWrite(void * osc, const char_t * Buffer, size_t NumChars)
{
    size_t CharsToBeWritten;

    __OutStrCtrl * Oscp = (__OutStrCtrl*)osc;

    CharsToBeWritten = ((Oscp->CharsWritten + NumChars) <= Oscp->MaxCharCount) ? NumChars :
                                                            (Oscp->MaxCharCount - Oscp->CharsWritten);
    memcpy(Oscp->CharStr + Oscp->CharsWritten, Buffer, CharsToBeWritten);
    Oscp->CharsWritten += CharsToBeWritten;

    MISRA_EXCEPTION_RULE_11_3()
    return ((void*)1);
}
