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