123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- #include <FL/Fl.H>
- #include <Fl/fl_draw.H>
- #include <FL/Fl_Double_Window.H>
-
- #include "cmPrefix.h"
- #include "cmGlobal.h"
- #include "cmFloatTypes.h"
- #include "cmRpt.h"
- #include "cmErr.h"
- #include "cmCtx.h"
- #include "cmMem.h"
- #include "cmMallocDebug.h"
- #include "cmLinkedHeap.h"
- #include "cmThread.h"
- #include "cmFileSys.h"
- #include "cmText.h"
-
- #include "appErr.h"
- #include "app.h"
-
-
-
-
- void print( void*, const cmChar_t* text)
- { puts(text); }
-
- cmRC_t print_queue_cb(void* userCbPtr, unsigned msgByteCnt, const void* msgDataPtr )
- {
- print(NULL,(const char*)msgDataPtr);
- return cmOkRC;
- }
-
-
- int main( int argc, char* argv[] )
- {
- cmCtx_t ctx;
- cmTsMp1cH_t printqH = cmTsMp1cNullHandle;
- int appWndW = 1000;
- int appWndH = 750;
- const char* appPrefDir = "gv";
- const char* appTitle = "GV Console";
- bool memDebugFl = cmDEBUG_FL;
- unsigned memPadByteCnt = memDebugFl ? 8 : 0;
- unsigned memAlignByteCnt = 16;
- unsigned memFlags = memDebugFl ? (kTrackMmFl | kDeferFreeMmFl | kFillUninitMmFl) : 0;
-
- cmCtxSetup(&ctx,appTitle,print,print,NULL,memPadByteCnt,memAlignByteCnt,memFlags);
-
- // initialize the memory mgr
- if(cmMdInitialize( memPadByteCnt, memAlignByteCnt, memFlags, &ctx.rpt ) != kOkMmRC )
- {
- cmErrMsg(&ctx.err,kMemFailAppRC,"Heap initialization failed.");
- goto errLabel;
- }
-
- // initialize the file system
- if( cmFsInitialize( &ctx, appPrefDir ) != kOkFsRC )
- cmErrMsg(&ctx.err,kFileSysFailAppRC,"File system initialization failed.");
-
- // initialize the text system
- if( cmTsInitialize(&ctx) != kOkTxRC )
- cmErrMsg(&ctx.err,kTextSysFailAppRC,"Text system initialization failed.");
-
- // create the print queue
- if( cmTsMp1cCreate( &printqH, 8192, print_queue_cb, NULL, NULL ) != kOkThRC )
- cmErrMsg(&ctx.err,kQueueFailAppRC,"Print queue creation failed.");
-
-
- if( cmErrLastRC(&ctx.err) == kOkAppRC )
- {
- app proj(&ctx, printqH, appWndW, appWndH, appTitle, argc, argv);
- Fl::run();
-
- // reset the pgm context and print queue console output to stdout
- cmRptSetup(&ctx.rpt,print,print,NULL);
- cmTsMp1cSetCbFunc(printqH, print_queue_cb, NULL );
- }
-
- // empty any pending text to stdout
- while( cmTsMp1cMsgWaiting(printqH) )
- if( cmTsMp1cDequeueMsg(printqH, NULL, 0) != kOkThRC )
- cmErrMsg(&ctx.err,kQueueFailAppRC,"Print dequeue failed.");
-
- // destroy the print queue
- if( cmTsMp1cDestroy(&printqH) != kOkThRC )
- cmErrMsg(&ctx.err,kQueueFailAppRC,"Print queue destroy failed.");
-
- // finalize the text system
- if( cmTsFinalize() != kOkTxRC )
- cmErrMsg(&ctx.err,kTextSysFailAppRC,"Text system finalization failed.");
-
- // finalize the file system
- if( cmFsFinalize() != kOkFsRC )
- cmErrMsg(&ctx.err,kFileSysFailAppRC,"File system finalize failed.");
-
- // report memory mgr errors
- if( cmMdIsValid() )
- cmMdReport( kIgnoreNormalMmFl );
-
- // finalize the memory manager
- if( cmMdFinalize() != kOkMmRC )
- cmErrMsg(&ctx.err,kMemFailAppRC,"Heap finalization failed.");
-
- errLabel:
-
-
-
-
- return 0;
- }
|