//------------------------------------------------------------------------- // Desc: Class for displaying an FDB structure 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: imonfdb.cpp 12329 2006-01-20 17:49:30 -0700 (Fri, 20 Jan 2006) ahodgkinson $ //------------------------------------------------------------------------- #include "flaimsys.h" /**************************************************************************** Desc: This procedure generates the HTML page to display the contents of the FDB structure ****************************************************************************/ RCODE F_FDBPage::display( FLMUINT uiNumParams, const char ** ppszParams) { RCODE rc = FERR_OK; FLMBOOL bRefresh = FALSE; #define GENERIC_SIZE_A 100 char szAddressParm[ GENERIC_SIZE_A]; void * pvFFileAddress; void * pvFDBAddress; char szFFileAddress[20]; char szFDBAddress[20]; char szBucket[20]; FLMINT uiBucket; FDB LocalFDB; FDB_p pDb=NULL; FFILE_p pFile = NULL; char szTemp[GENERIC_SIZE_A]; FLMBOOL bpFileInc = FALSE; char szAddress[20]; char * pszTemp = NULL; if( RC_BAD( rc = f_alloc( 200, &pszTemp))) { printErrorPage( rc, TRUE, "Failed to allocate temporary buffer"); goto Exit; } // Let's extract as much information as we can from the parameters // before we proceed. // Determine if we are being requested to refresh this page or not. bRefresh = DetectParameter( uiNumParams, ppszParams, "Refresh"); // FFileAddress - required if (RC_BAD(rc = ExtractParameter( uiNumParams, ppszParams, "FFileAddress", sizeof( szAddressParm), szAddressParm))) { goto Exit; } else { pvFFileAddress = (void *)f_atoud( szAddressParm); } // FDBAddress - required if (RC_BAD( rc = ExtractParameter( uiNumParams, ppszParams, "FDBAddress", sizeof( szAddressParm), szAddressParm))) { goto Exit; } else { pvFDBAddress = (void *)f_atoud( szAddressParm); } // Bucket - index into the file hash table - required if (RC_BAD( rc = ExtractParameter( uiNumParams, ppszParams, "Bucket", sizeof( szBucket), szBucket))) { goto Exit; } else { uiBucket = f_atoud( szBucket); } // Now we will search for the FFile first, then look for the FDB. f_mutexLock( gv_FlmSysData.hShareMutex); pFile = (FFILE_p)gv_FlmSysData.pFileHashTbl[uiBucket].pFirstInBucket; while ((pFile != NULL) && ((void *)pFile != pvFFileAddress)) { pFile = pFile->pNext; } if (pFile) { pDb = pFile->pFirstDb; //Now let's look for the FDB we want... while (pDb && ((void *)pDb != pvFDBAddress)) { pDb = pDb->pNextForFile; } if (pDb) { f_memcpy( &LocalFDB, pDb, sizeof(LocalFDB)); } // Now we want to make sure the pFile doesn't go away while we are // using it. if (++pFile->uiUseCount == 1) { flmUnlinkFileFromNUList( pFile); } bpFileInc = TRUE; } f_mutexUnlock( gv_FlmSysData.hShareMutex); // Save the FFileAddress and the FDBAddress. printAddress( pvFFileAddress, szAddress); f_sprintf( szFFileAddress, "%s", szAddress); printAddress( pvFDBAddress, szAddress); f_sprintf( szFDBAddress, "%s", szAddress); // At this point we will either have a valid FDB or we will have not been able // to find it. stdHdr(); fnPrintf( m_pHRequest, HTML_DOCTYPE); fnPrintf( m_pHRequest, "\n"); if (bRefresh) { // Send back the page with a refresh command in the header f_sprintf( szTemp, "%s/FDB?Refresh?FFileAddress=%s?Bucket=%s?FDBAddress=%s", m_pszURLString, szFFileAddress, szBucket, szFDBAddress); fnPrintf( m_pHRequest, "
" "" "Unable to find the FDB structure that " "you requested. This is probably because the state" " of the system changed between the time that you " "displayed the previous page and the time that " "you clicked on the link that brought you here.\n" "
Click on your browser's \"Back\" button, then" " click \"Reload\" and then try the link again."); } else { printTableStart( "FDB Database Context", 4, 100); printTableRowStart(); printColumnHeading( "", JUSTIFY_LEFT, FLM_IMON_COLOR_PUTTY_1, 4, 1, FALSE); fnPrintf( m_pHRequest, "Refresh, ", szTemp); fnPrintf( m_pHRequest, "%s\n", pszTemp); printColumnHeadingClose(); printTableRowEnd(); // Write out the table headings. printTableRowStart(); printColumnHeading( "Byte Offset (hex)"); printColumnHeading( "Field Name"); printColumnHeading( "Field Type"); printColumnHeading( "Value"); printTableRowEnd(); // Insert a new table into the page to display the FDB fields write_data( (pDb ? &LocalFDB : NULL), szFDBAddress, uiBucket); } fnPrintf( m_pHRequest, "