Example #1
0
void captaincyLogInit(void)
{
    if (logEnable)
    {
        logfileClear(CAPTAINCYLOGFILE);
    }
}
Example #2
0
void titanLogFileOpen(void)
{
	time_t now;
	char datestring[16];

    if (logEnable)
    {
        logfileClear(TITAN_LOG_FILE_NAME);
		now = time(NULL);
		strftime(datestring, 16, "%a %b %d %Y", gmtime(&now));
		titanDebug("Todays date is: %s", datestring);
    }
}
/*-----------------------------------------------------------------------------
    Name        : dbwStart
    Description : Start up the debug window and initialize all panes.
    Inputs      : void
    Outputs     : Clears all pane buffers to spaces
    Return      : Success flag (OKAY if window created OK)
----------------------------------------------------------------------------*/
sdword dbwStart(udword hInstance, udword hWndParent)
{
    WNDCLASS windowClass;
    SIZE   fontSize;
    sdword index, width, height;
    char keyString[DIS_StringLength];
    char returnString[DIS_StringLength];
    char defaultString[DIS_StringLength];
    BOOL fontLoaded = FALSE;
    LOGBRUSH brush =
    {
        BS_SOLID,
        GetSysColor(COLOR_WINDOW),
        0
    };

#if DBW_TO_FILE
    if (debugToFile)
    {
        logfileClear(DBW_FILE_NAME);
    }
#endif
    if (dbwEnabled)                                         //don't start if already started
    {
        return ERROR;
    }

    //get location from .INI file
    sprintf(defaultString, "%d, %d", DBW_WindowX, DBW_WindowY);
//    GetPrivateProfileString(DIS_SectionName, DIS_Location,
//                            defaultString, returnString, DIS_StringLength, DIS_FileName);
    dbwFindString(DIS_FileName, DIS_Location, defaultString, returnString, DIS_StringLength);
    sscanf(returnString, "%d, %d", &dbwWindowX, &dbwWindowY);

    //get size from .INI file
    sprintf(defaultString, "%d, %d", DBW_WindowWidth, DBW_WindowHeight);
//    GetPrivateProfileString(DIS_SectionName, DIS_Size,
//                            defaultString, returnString, DIS_StringLength, DIS_FileName);
    dbwFindString(DIS_FileName, DIS_Size, defaultString, returnString, DIS_StringLength);
    sscanf(returnString, "%d, %d", &dbwWindowWidth, &dbwWindowHeight);

    dbwFontWidth = dbwFontHeight = 8;                       //assume a default size for now

    // set up and register window class
    windowClass.style         = CS_NOCLOSE | CS_OWNDC;
    windowClass.lpfnWndProc   = dbwWindowProc;
    windowClass.cbClsExtra    = 0;
    windowClass.cbWndExtra    = 0;
    windowClass.hInstance     = (HINSTANCE)hInstance;
    windowClass.hIcon         = NULL;
    windowClass.hCursor       = LoadCursor( NULL, IDC_ARROW );
    windowClass.hbrBackground = CreateBrushIndirect(&brush);
    windowClass.lpszMenuName  = NULL;
    windowClass.lpszClassName = DBW_ClassName;

    RegisterClass(&windowClass);

    width = dbwWindowWidth * dbwFontWidth +  + GetSystemMetrics(SM_CXSIZEFRAME) * 2;
    height = dbwWindowHeight * dbwFontHeight + GetSystemMetrics(SM_CYCAPTION) +
            GetSystemMetrics(SM_CYSIZEFRAME);
    //now create the window
    hDebugWindow = CreateWindowEx(
        0,//WS_EX_STATICEDGE,                                   //cannot be sized
        DBW_ClassName,                                      //class name string
        DBW_WindowTitle,                                    //title string
        WS_POPUP | WS_CAPTION,
        dbwWindowX, dbwWindowY,                             //location
        width,                                              //size based upon font
        height,
        (HWND)hWndParent,                                   //parent window
        NULL,                                               //no menu
        (HINSTANCE)hInstance,                               //app instance
        NULL );                                             //no lParam

    if (hDebugWindow == NULL)                               //if function failed
    {
        return(ERROR);
    }

    //now we must compute the proper size of the font, and thus the window
//    if (GetPrivateProfileStruct(DIS_SectionName, DIS_Font,
//                            &dbwLogicalFont, sizeof(LOGFONT), DIS_FileName) == FALSE)
    if (!dbwFindBinary(DIS_FileName, DIS_Font, (ubyte *)&dbwLogicalFont, sizeof(LOGFONT)))
    {
        if (dbwFontChoose() != OKAY)
        {
            return(ERROR);
        }
    }
    hDebugFont = CreateFontIndirect(&dbwLogicalFont);       //create a font object
    if (hDebugFont == NULL)
    {
        return(ERROR);
    }

    hDebugDC = GetDC(hDebugWindow);                         //get device context
    if (hDebugDC == NULL)
    {
        return(ERROR);
    }

    SelectObject(hDebugDC, hDebugFont);                     //select our font in
    GetTextExtentPoint32(hDebugDC, " ", 1, &fontSize);      //get size of a single character
    dbwFontWidth = fontSize.cx;
    dbwFontHeight = fontSize.cy;

    width = dbwWindowWidth * dbwFontWidth +  + GetSystemMetrics(SM_CXSIZEFRAME) * 2;
    height = dbwWindowHeight * dbwFontHeight + GetSystemMetrics(SM_CYCAPTION) +
            GetSystemMetrics(SM_CYSIZEFRAME) * 2;
    MoveWindow(hDebugWindow, dbwWindowX, dbwWindowY,        //resize the window
               width, height, FALSE);

    ShowWindow(hDebugWindow, SW_SHOW);                      //show the window
    UpdateWindow(hDebugWindow);                             //update the window

    dbwEnabled = TRUE;

    //now that we have a window, let's init our panes
    for (index = 0; index < DBW_NumberPanes; index++)
    {
        //attempt to load pane structure from disk
        sprintf(keyString, "%s%d", DIS_PaneBase, index);
        strcpy(defaultString, "");
//        sprintf(defaultString, "%d, %d, %d, %d, %d", 0, 0, dbwWindowWidth,
//                dbwWindowHeight, DBW_BufferHeight);
//        if (GetPrivateProfileString(DIS_SectionName,
//               keyString, defaultString, returnString,
//               DIS_StringLength, DIS_FileName) <= 0)
        if (!dbwFindString(DIS_FileName, keyString, defaultString, returnString, DIS_StringLength))
        {
            //by default there is only 1 pane
            if (index != 0)                                //only init the first one
                continue;
            dbwPane[index].flags = DPF_Enabled;
            dbwPane[index].x = 0;                          //set size of pane to defaults
            dbwPane[index].y = 0;
            dbwPane[index].width = dbwWindowWidth;
            dbwPane[index].height = dbwWindowHeight;
            dbwPane[index].bufferHeight = DBW_BufferHeight;
        }
        else
        {
            dbwPane[index].flags = DPF_Enabled;
            sscanf(returnString, "%d, %d, %d, %d, %d", &dbwPane[index].x,
                    &dbwPane[index].y, &dbwPane[index].width,
                    &dbwPane[index].height, &dbwPane[index].bufferHeight);
        }

        if (dbwPaneAlloc(index) != OKAY)                    //allocate mem for pane
        {
            bitClear(dbwPane[index].flags, DPF_Enabled);
            continue;
        }
        dbwPaneClear(index);                                //clear the pane out
        dbwPane[index].logFile = NULL;                      //by default, logging is off
    }

//    testItOut(); //!!!
    return OKAY;
}