| 1 |
/* |
| 2 |
* FCML - Free Code Manipulation Library. |
| 3 |
* Copyright (C) 2010-2020 Slawomir Wojtasiak |
| 4 |
* |
| 5 |
* This library is free software; you can redistribute it and/or |
| 6 |
* modify it under the terms of the GNU Lesser General Public |
| 7 |
* License as published by the Free Software Foundation; either |
| 8 |
* version 2.1 of the License, or (at your option) any later version. |
| 9 |
* |
| 10 |
* This library is distributed in the hope that it will be useful, |
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 |
* Lesser General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU Lesser General Public |
| 16 |
* License along with this library; if not, write to the Free Software |
| 17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 |
*/ |
| 19 |
|
| 20 |
#include <fcml_renderer.h> |
| 21 |
|
| 22 |
#include "fcml_stream.h" |
| 23 |
#include "fcml_dialect_int.h" |
| 24 |
#include "fcml_trace.h" |
| 25 |
#include "fcml_env_int.h" |
| 26 |
|
| 27 |
fcml_ceh_error LIB_CALL fcml_fn_render(const fcml_st_dialect *dialect, |
| 28 |
const fcml_st_render_config *config, fcml_char *buffer, |
| 29 |
fcml_usize buffer_len, |
| 30 |
const fcml_st_disassembler_result *result) { |
| 31 |
|
| 32 |
fcml_st_memory_stream output_stream; |
| 33 |
output_stream.base_address = buffer; |
| 34 |
output_stream.offset = 0; |
| 35 |
output_stream.size = buffer_len; |
| 36 |
|
| 37 |
fcml_st_dialect_context_int *dialect_context_int = |
| 38 |
(fcml_st_dialect_context_int*)dialect; |
| 39 |
if (dialect_context_int->instruction_renderer) { |
| 40 |
fcml_fnp_render_instruction renderer = (fcml_fnp_render_instruction) |
| 41 |
dialect_context_int->instruction_renderer; |
| 42 |
return renderer( dialect, config, &output_stream, result ); |
| 43 |
} else { |
| 44 |
/* Dialect not initialized correctly.*/ |
| 45 |
FCML_TRACE_MSG("Rendering not supported by current dialect."); |
| 46 |
return FCML_CEH_GEC_FEATURE_NOT_SUPPORTED; |
| 47 |
} |
| 48 |
|
| 49 |
} |