| 1 |
|
| /* |
| 2 |
|
| * File: callback_stubs.c |
| 3 |
|
| * Author: Igor Vlasenko <vlasenko@imath.kiev.ua> |
| 4 |
|
| * Created: Tue Jul 14 22:47:11 2009 |
| 5 |
|
| */ |
| 6 |
|
| |
| 7 |
|
| #include "pstring.h" |
| 8 |
|
| #include "pbuffer.h" |
| 9 |
|
| |
| 10 |
|
| struct builtin_writer_state { |
| 11 |
|
| size_t size; |
| 12 |
|
| pbuffer* bufptr; |
| 13 |
|
| }; |
| 14 |
|
| |
| 15 |
|
| |
| 16 |
|
| /* writer_functype stub */ |
| 17 |
|
| /* endnext points on next character to end of interval as in c++ */ |
| 18 |
0 |
| static void BACKCALL stub_write_chars_to_stdout (ABSTRACT_WRITER* none,const char* begin, const char* endnext) { |
| 19 |
0 |
▶ | if (endnext==begin) return; |
Branch: 1 branch
| Branch | True | False | Total |
| if (endnext==begin) return; |
0 |
0 |
0 |
|
| 20 |
0 |
▶ | if (0==fwrite(begin, sizeof(char), endnext-begin, stdout)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (0==fwrite(begin, sizeof(char), endnext-begin, stdout)) { |
0 |
0 |
0 |
|
| 21 |
0 |
| tmpl_log(TMPL_LOG_ERROR,"find_file_func stub: can't fwrite to stdout\n"); |
| 22 |
|
| } |
| 23 |
|
| } |
| 24 |
|
| |
| 25 |
|
| /* writer_functype stub */ |
| 26 |
|
| /* endnext points at the character next to the end of the interval */ |
| 27 |
0 |
| static void BACKCALL stub_write_chars_to_pbuffer (ABSTRACT_WRITER* state,const char* begin, const char* endnext) { |
| 28 |
0 |
| size_t addlen = endnext-begin; |
| 29 |
|
| size_t oldlen; |
| 30 |
|
| pbuffer* pbuf; |
| 31 |
0 |
▶ | if (addlen==0) return; |
Branch: 1 branch
| Branch | True | False | Total |
| if (addlen==0) return; |
0 |
0 |
0 |
|
| 32 |
0 |
| oldlen = ((struct builtin_writer_state*) state)->size; |
| 33 |
0 |
| pbuf = ((struct builtin_writer_state*) state)->bufptr; |
| 34 |
0 |
| pbuffer_resize(pbuf, oldlen + addlen + 1); |
| 35 |
0 |
| memcpy(pbuffer_string(pbuf) + oldlen, begin, addlen); |
| 36 |
0 |
| ((struct builtin_writer_state*) state)->size += addlen; |
| 37 |
|
| } |
| 38 |
|
| |
| 39 |
0 |
| static ABSTRACT_USERFUNC* BACKCALL stub_is_expr_userfnc_func (ABSTRACT_FUNCMAP* af, PSTRING name) { |
| 40 |
0 |
| tmpl_log(TMPL_LOG_DEBUG,"is_expr_userfnc_func stub: EXPR is not initialized properly. user func dispatcher was not supplied.\n"); |
| 41 |
0 |
| return NULL; |
| 42 |
|
| } |
| 43 |
|
| |
| 44 |
0 |
| static PSTRING BACKCALL stub_load_file_func (ABSTRACT_FILTER* none, const char* filename) { |
| 45 |
0 |
| tmpl_log(TMPL_LOG_ERROR,"load_file_func stub: callback function for filters was not specified."); |
| 46 |
0 |
| return mmap_load_file(filename); |
| 47 |
|
| } |
| 48 |
|
| |
| 49 |
0 |
| static int BACKCALL stub_unload_file_func (ABSTRACT_FILTER* none, PSTRING memarea) { |
| 50 |
0 |
| tmpl_log(TMPL_LOG_ERROR,"unload_file_func stub: callback function for filters was not specified."); |
| 51 |
0 |
| return mmap_unload_file(memarea); |
| 52 |
|
| } |
| 53 |
|
| |
| 54 |
0 |
| static int BACKCALL stub_get_ABSTRACT_ARRAY_length_func (ABSTRACT_DATASTATE* none1, ABSTRACT_ARRAY* none) { |
| 55 |
0 |
| return -1; /* treat all arrays as arrays of undefined length */ |
| 56 |
|
| } |
| 57 |
|
| |
| 58 |
|
| |
| 59 |
|
| /* |
| 60 |
|
| * Local Variables: |
| 61 |
|
| * mode: c |
| 62 |
|
| * End: |
| 63 |
|
| */ |