1 #include "ficl.h" 2 3 extern ficlSystem *ficlSystemGlobal; 4 5 /* 6 * f i c l C a l l b a c k T e x t O u t 7 * Feeds text to the vm's output callback 8 */ 9 void 10 ficlCallbackTextOut(ficlCallback *callback, char *text) 11 { 12 ficlOutputFunction textOut = NULL; 13 14 if (callback != NULL) { 15 if (callback->textOut != NULL) 16 textOut = callback->textOut; 17 else if ((callback->system != NULL) && 18 (callback != &(callback->system->callback))) { 19 ficlCallbackTextOut(&(callback->system->callback), 20 text); 21 return; 22 } 23 } 24 25 if ((textOut == NULL) && (ficlSystemGlobal != NULL)) { 26 callback = &(ficlSystemGlobal->callback); 27 textOut = callback->textOut; 28 } 29 30 if (textOut == NULL) 31 textOut = ficlCallbackDefaultTextOut; 32 33 (textOut)(callback, text); 34 } 35 36 /* 37 * f i c l C a l l b a c k E r r o r O u t 38 * Feeds text to the vm's error output callback 39 */ 40 void 41 ficlCallbackErrorOut(ficlCallback *callback, char *text) 42 { 43 ficlOutputFunction errorOut = NULL; 44 45 if (callback != NULL) { 46 if (callback->errorOut != NULL) 47 errorOut = callback->errorOut; 48 else if ((callback->system != NULL) && 49 (callback != &(callback->system->callback))) { 50 ficlCallbackErrorOut(&(callback->system->callback), 51 text); 52 return; 53 } 54 } 55 56 if ((errorOut == NULL) && (ficlSystemGlobal != NULL)) { 57 callback = &(ficlSystemGlobal->callback); 58 errorOut = callback->errorOut; 59 } 60 61 if (errorOut == NULL) { 62 ficlCallbackTextOut(callback, text); 63 return; 64 } 65 66 (errorOut)(callback, text); 67 } 68