//-------------------------------------------------------------------------
// Desc: Class for displaying a file handle manager in HTML on a web page.
// Tabs: 3
//
// Copyright (c) 2001-2003,2005-2006 Novell, Inc. All Rights Reserved.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the GNU General Public
// License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, contact Novell, Inc.
//
// To contact Novell about this file by physical or electronic mail,
// you may find current contact information at www.novell.com
//
// $Id: imonfmgr.cpp 12329 2006-01-20 17:49:30 -0700 (Fri, 20 Jan 2006) ahodgkinson $
//-------------------------------------------------------------------------
#include "flaimsys.h"
/****************************************************************************
Desc: This function implementd the display method of the FileHdlMgrPage web
page.
*****************************************************************************/
RCODE F_FileHdlMgrPage::display(
FLMUINT uiNumParams,
const char ** ppszParams)
{
RCODE rc = FERR_OK;
F_FileHdlMgr * pFileHdlMgr;
F_ListMgr * pListMgr;
FLMUINT uiNumAvailItems;
FLMUINT uiNumUsedItems;
char szTemp[20];
FLMUINT uiLoop;
FLMBOOL bRefresh = FALSE;
char szAddress[20];
FLMBOOL bHighlight = FALSE;
FLMBYTE * pszTemp = NULL;
FLMBYTE * pszTemp1 = NULL;
if( RC_BAD( rc = f_alloc( 250, &pszTemp)))
{
printErrorPage( rc, TRUE, (char *)"Failed to allocate temporary buffer");
goto Exit;
}
if( RC_BAD( rc = f_alloc( 250, &pszTemp1)))
{
printErrorPage( rc, TRUE, (char *)"Failed to allocate temporary buffer");
goto Exit;
}
stdHdr();
fnPrintf( m_pHRequest, HTML_DOCTYPE);
fnPrintf( m_pHRequest, "\n");
// Determine if we are being requested to refresh this page or not.
if ((bRefresh = DetectParameter(
uiNumParams,
ppszParams,
"Refresh")) == TRUE)
{
// Send back the page with a refresh command in the header
fnPrintf( m_pHRequest,
"
"
""
"gv_FlmSysData.pFileHdlMgr\n",
m_pszURLString);
}
else
{
fnPrintf( m_pHRequest,
"gv_FlmSysData.pFileHdlMgr\n");
}
printStyle();
fnPrintf( m_pHRequest, "\n");
fnPrintf( m_pHRequest, "\n");
// If we are not to refresh this page, then don't include the
// refresh meta command
if (!bRefresh)
{
f_sprintf( (char *)pszTemp,
"Start Auto-refresh (5 sec.)",
m_pszURLString);
}
else
{
f_sprintf( (char *)pszTemp,
"Stop Auto-refresh",
m_pszURLString);
}
// Prepare the refresh link.
f_sprintf( (char *)pszTemp1, "Refresh",
m_pszURLString);
if (gv_FlmSysData.pFileHdlMgr == NULL)
{
fnPrintf( m_pHRequest,
"No File Handle Manager exists. "
"Please ensure that a database has been opened."
"\n");
}
else
{
// Lock the file handle manager Mutex and add a reference
// to it to hold it until we are done.
f_mutexLock( gv_FlmSysData.hFileHdlMutex);
pFileHdlMgr = gv_FlmSysData.pFileHdlMgr;
pFileHdlMgr->AddRef();
f_mutexUnlock( gv_FlmSysData.hFileHdlMutex);
printTableStart( "File Handle Manager", 1, 100);
printTableRowStart();
printColumnHeading( "", JUSTIFY_LEFT, FLM_IMON_COLOR_PUTTY_1, 4, 1, FALSE);
fnPrintf( m_pHRequest, "%s, ", pszTemp1);
fnPrintf( m_pHRequest, "%s\n", pszTemp);
printColumnHeadingClose();
printTableRowEnd();
printTableEnd();
printTableStart( "File Handle Manager - Methods", 2, 100);
// Write out the table headings.
printTableRowStart();
printColumnHeading( "Method Name");
printColumnHeading( "Value");
printTableRowEnd();
// GetOpenThreshold - method to return the file open threshold
printTableRowStart( bHighlight = ~bHighlight);
fnPrintf( m_pHRequest, TD_s, "GetOpenThreshold");
fnPrintf( m_pHRequest, TD_ld, pFileHdlMgr->GetOpenThreshold());
printTableRowEnd();
// GetOpenedFiles - Returns the number of opened files
printTableRowStart( bHighlight = ~bHighlight);
fnPrintf( m_pHRequest, TD_s, "GetOpenedFiles");
fnPrintf( m_pHRequest, TD_ld, pFileHdlMgr->GetOpenedFiles());
printTableRowEnd();
// GetMaxAvailTime
printTableRowStart( bHighlight = ~bHighlight);
fnPrintf( m_pHRequest, TD_s, "GetMaxAvailTime");
FormatTime( pFileHdlMgr->GetMaxAvailTime(), szTemp);
fnPrintf( m_pHRequest, TD_s, szTemp);
fnPrintf( m_pHRequest, TR_END);
printTableRowEnd();
// Introduce another table to show the private members
printTableStart( "File Handle Manager - Fields", 4, 100);
// Write out the table headings.
printTableRowStart();
printColumnHeading( "Byte Offset (hex)");
printColumnHeading( "Field Name");
printColumnHeading( "Field Type");
printColumnHeading( "Value");
printTableRowEnd();
// m_phMutex (show the address)
printAddress( &pFileHdlMgr->m_phMutex, szAddress);
printHTMLString(
"m_phMutex",
"F_MUTEX",
(void *)pFileHdlMgr,
(void *)&pFileHdlMgr->m_phMutex,
(char *)szAddress,
(bHighlight = ~bHighlight));
// m_uiOpenThreshold
printHTMLUint(
"m_uiOpenThreshold",
"FLMUINT",
(void *)pFileHdlMgr,
(void *)&pFileHdlMgr->m_uiOpenThreshold,
pFileHdlMgr->m_uiOpenThreshold,
(bHighlight = ~bHighlight));
// m_uiMaxAvailTime
FormatTime( pFileHdlMgr->m_uiMaxAvailTime, szTemp);
printHTMLString(
"m_uiMaxAvailTime",
"FLMUINT",
(void *)pFileHdlMgr,
(void *)&pFileHdlMgr->m_uiMaxAvailTime,
(char *)szTemp,
(bHighlight = ~bHighlight));
// m_ListMgr (show address)
printAddress( &pFileHdlMgr->m_ListMgr, szAddress);
printHTMLString(
"m_ListMgr",
"F_ListMgr",
(void *)pFileHdlMgr,
(void *)&pFileHdlMgr->m_ListMgr,
(char *)szAddress,
(bHighlight = ~bHighlight));
// m_LNodes (show address)
printAddress( &pFileHdlMgr->m_LNodes[0], szAddress);
printHTMLString(
"m_LNodes",
"LNODE[]",
(void *)pFileHdlMgr,
(void *)&pFileHdlMgr->m_LNodes,
(char *)szAddress,
(bHighlight = ~bHighlight));
// m_bIsSetup
printHTMLString(
"m_bIsSetup",
"FLMBOOL",
(void *)pFileHdlMgr,
(void *)&pFileHdlMgr->m_bIsSetup,
(char *)(pFileHdlMgr->m_bIsSetup ? "Yes" : "No"),
(bHighlight = ~bHighlight));
// m_uiFileIdCounter
printHTMLUint(
"m_uiFileIdCounter",
"FLMUINT",
(void *)pFileHdlMgr,
(void *)&pFileHdlMgr->m_uiFileIdCounter,
pFileHdlMgr->m_uiFileIdCounter,
(bHighlight = ~bHighlight));
printTableEnd();
fnPrintf( m_pHRequest, "
\n");
fnPrintf( m_pHRequest, "\n");
fnPrintf( m_pHRequest, "Shown below are the AVAILABLE and the USED File "
"Handle Lists.
To select a File Handle to view, "
"you may click the appropriate \"NEXT FILE HANDLE\" "
"button or choose from the drop down selection list."
"\n");
fnPrintf( m_pHRequest, "\n");
fnPrintf( m_pHRequest, "
\n");
// Define the form to present the File Handle Lists
// Begin with the Available List of File Handles
// Get a reference to the list manager, then find out
// how many items are in the Available List
pListMgr = pFileHdlMgr->GetListMgr();
uiNumAvailItems = pListMgr->GetCount( FHM_AVAIL_LIST);
if (uiNumAvailItems > 0)
{
fnPrintf( m_pHRequest, "\n");
}
else
{
fnPrintf( m_pHRequest, "Available List - "
"No Entries
\n");
}
uiNumUsedItems = pListMgr->GetCount( FHM_USED_LIST);
if (uiNumUsedItems > 0)
{
fnPrintf( m_pHRequest, "\n");
}
else
{
fnPrintf( m_pHRequest, "Used List - "
"No Entries
\n");
}
fnPrintf( m_pHRequest, "\n");
// Now release the FileHdlMgr...
f_mutexLock( gv_FlmSysData.hFileHdlMutex);
pFileHdlMgr->Release();
pFileHdlMgr = NULL;
f_mutexUnlock( gv_FlmSysData.hFileHdlMutex);
} // else
fnPrintf( m_pHRequest, "\n");
fnEmit();
Exit:
if (pszTemp)
{
f_free( &pszTemp);
}
if (pszTemp1)
{
f_free( &pszTemp1);
}
return( rc);
}