123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- #define BUILDING_OPENDOORS
- #include <stdio.h>
- #include <stdarg.h>
- #include <string.h>
- #include <stdlib.h>
- #include "OpenDoor.h"
- #include "ODCore.h"
- #include "ODGen.h"
- #include "ODKrnl.h"
- #define WORK_BUFFER_SIZE 512
- ODAPIDEF void ODVCALL od_printf(const char *pszFormat,...)
- {
- va_list pArgumentList;
- static char *pszWorkBuffer = NULL;
- char *pchCurrent;
- char *pchStart;
- BOOL bNotFound;
- INT nCharCount;
-
- TRACE(TRACE_API, "od_printf()");
-
- if(!bODInitialized) od_init();
- OD_API_ENTRY();
-
- if(pszWorkBuffer == NULL &&
- (pszWorkBuffer = malloc(WORK_BUFFER_SIZE)) == NULL)
- {
-
- od_control.od_error = ERR_MEMORY;
- OD_API_EXIT();
- return;
- }
-
- va_start(pArgumentList, pszFormat);
-
- vsprintf(pszWorkBuffer, pszFormat, pArgumentList);
- va_end(pArgumentList);
-
-
- if(!od_control.od_color_char && !od_control.od_color_delimiter)
- goto quick_print;
- chColorCheck = od_control.od_color_delimiter;
- bNotFound = TRUE;
- pchCurrent = (char *)pszWorkBuffer;
- pchStart = (char *)pszWorkBuffer;
- nCharCount = 0;
- while(*pchCurrent)
- {
- if(*pchCurrent == od_control.od_color_delimiter)
- {
- bNotFound = FALSE;
- if(nCharCount != 0)
- {
- od_disp(pchStart, nCharCount, TRUE);
- }
- if(!*(++pchCurrent))
- {
- chColorCheck = 0;
- OD_API_EXIT();
- return;
- }
- od_set_attrib(od_color_config(pchCurrent));
- if(!*(pchCurrent = (char *)pchColorEndPos))
- {
- chColorCheck = 0;
- OD_API_EXIT();
- return;
- }
- if(!*(++pchCurrent))
- {
- OD_API_EXIT();
- return;
- }
- pchStart = (char *)pchCurrent;
- nCharCount = 0;
- }
- else if(*pchCurrent == od_control.od_color_char)
- {
- bNotFound = FALSE;
- if(nCharCount != 0)
- {
- od_disp(pchStart, nCharCount, TRUE);
- }
- if(!*(++pchCurrent))
- {
- OD_API_EXIT();
- return;
- }
- od_set_attrib(*pchCurrent);
- if(!*(++pchCurrent))
- {
- OD_API_EXIT();
- return;
- }
- pchStart = (char *)pchCurrent;
- nCharCount = 0;
- }
- else
- {
- ++nCharCount;
- ++pchCurrent;
- }
- }
- chColorCheck = 0;
- if(bNotFound)
- {
- quick_print:
-
- od_disp_str(pszWorkBuffer);
- }
- else if(nCharCount != 0)
- {
-
- od_disp(pchStart, nCharCount, TRUE);
- }
- OD_API_EXIT();
- }
|