/*                                                                          */
/* File Name   : mbdr_dsp_debug_stream_manage.c                             */
/*                                                                          */
/* Written By  : 79556                                                      */
/*                                                                          */
/* versions    :                                                            */
/*+--------+-----------+---------------------------------------------------+*/
/*| Version| Date      | Change content                                    |*/
/*+--------+-----------+---------------------------------------------------+*/
/*| 0.04.12|26/Feb/2014|-PRI print 3 digits                                |*/
/*|        |           |-increase MBDR_DSP_DBG_PRINT_FIX_LINE_SIZE 80->86  |*/
/*+--------+-----------+---------------------------------------------------+*/



#include  "windef.h"
#include  "string.h"
#include  "mbdr_dsp_debug_stream_manage.h"

mbdr_dsp_dbg_print_output_stream_procs_t
                                     *mbdr_dsp_dbg_print_stream_p; 


void mbdr_dsp_dbg_print_output_stream_open(mbdr_dsp_dbg_print_output_stream_procs_t
                                                   *pio_output_stream_manage_p)
{
  pio_output_stream_manage_p->stream_open_proc_p(pio_output_stream_manage_p);
}

void mbdr_dsp_dbg_print_output_stream_close(mbdr_dsp_dbg_print_output_stream_procs_t
                                                   *pio_output_stream_manage_p)
{
  pio_output_stream_manage_p->stream_close_proc_p(pio_output_stream_manage_p);
}


#define MBDR_DSP_DBG_PRINT_FIX_LINE_SIZE 86


void mbdr_dsp_dbg_print_output_stream_print(mbdr_dsp_dbg_print_output_stream_procs_t
                                                   *pio_output_stream_manage_p,
                                                   char *pio_string_p)
{
  SHORT org_string_length, i;//, clipped_string_length;

  /* put end of line delimiter*/
  org_string_length      = strlen(pio_string_p);
  //cipped_string_length  = min(org_string_length, MBDR_DSP_DBG_PRINT_FIX_LINE_SIZE);

  /* pad with spaces */
  //memset(string_p, ' ', MBDR_DSP_DBG_PRINT_FIX_LINE_SIZE-clipped_string_length);

  /* pads print string */
  for(i=org_string_length; i<MBDR_DSP_DBG_PRINT_FIX_LINE_SIZE; i++)
      pio_string_p[i] = ' ';
  //pio_string_p[MBDR_DSP_DBG_PRINT_FIX_LINE_SIZE] = 0;

  /* put end of line */
  pio_string_p[MBDR_DSP_DBG_PRINT_FIX_LINE_SIZE+0] = 10;
  pio_string_p[MBDR_DSP_DBG_PRINT_FIX_LINE_SIZE+1] = 13;
  pio_string_p[MBDR_DSP_DBG_PRINT_FIX_LINE_SIZE+2] =  0;

  pio_output_stream_manage_p->stream_print_string_proc_p(pio_output_stream_manage_p,
                                                         pio_string_p);

}
