1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201
|
<?php
//
// ggcov - A GTK frontend for exploring gcov coverage data
// Copyright (c) 2005 Greg Banks <gnb@users.sourceforge.net>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// 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, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// $Id: basic.php,v 1.12 2010/05/09 05:37:14 gnb Exp $
//
require_once 'ggcov/lib/cov.php';
function basic_test_dir()
{
static $test_dir = null;
if ($test_dir === null)
{
$test_dir = getenv('GGCOV_TEST_DIR');
if (!$test_dir)
$test_dir = '/var/cache/ggcov/tests';
}
return $test_dir;
}
function basic_valid_test($t)
{
return (preg_match('/^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/', $t) &&
cov::database_exists(basic_test_dir() . '/' . $t));
}
function basic_test()
{
static $test = null;
if ($test === null)
{
if (array_key_exists('test', $_GET))
{
$test = $_GET['test'];
if (!basic_valid_test($test))
cov_callbacks::fatal("Invalid test");
}
if ($test === null)
{
$t = getenv('GGCOV_DEFAULT_TEST');
if ($t && basic_valid_test($t))
$test = $t;
}
if ($test === null && file_exists(basic_test_dir()))
{
$d = opendir(basic_test_dir());
if ($d)
{
while (($test = readdir($d)) && !basic_valid_test($test))
;
closedir($d);
}
}
}
return $test;
}
function basic_list_tests()
{
$list = array();
if (file_exists(basic_test_dir()) && $d = opendir(basic_test_dir()))
{
while ($test = readdir($d))
{
if (basic_valid_test($test))
$list[] = $test;
}
closedir($d);
sort($list);
}
return $list;
}
class basic_cov_callbacks extends cov_callbacks
{
function add_state($query)
{
$test = basic_test();
if ($test)
$query['test'] = $test;
return $query;
}
}
function basic_cov()
{
$cov = new cov(new basic_cov_callbacks);
$test = basic_test();
if (!$test)
{
// No default test, so redirect to tests.php which will at
// least tell the user what needs to be done to add a test.
$cov->credirect('tests.php');
}
$cov->attach(basic_test_dir() . '/' . $test);
return $cov;
}
function basic_url($base)
{
$test = basic_test();
if ($test)
{
$base .= (strchr($base,'?') == null ? '?' : '&');
$base .= 'test=' . urlencode($test);
}
return htmlentities($base);
}
function basic_header($title)
{
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title><?php echo $title; ?></title>
<link rel="stylesheet" type="text/css" href="basic.css">
<link rel="SHORTCUT ICON" href="favicon.ico">
</head>
<body>
<table border="0" cellpadding="5" cellspacing="0" width="100%">
<tr>
<td colspan="3" class="nav_header"><?php echo $title; ?></td>
</tr>
<tr>
<td class="nav_menu" valign="top" width="10" nowrap>
<img width="64" height="64" src="ggcov64.gif" alt="ggcov"><br><br>
<a href="<?php echo 'tests.php'; ?>">Tests</a><br>
<a href="<?php echo basic_url('summary.php'); ?>">Summary</a><br>
<a href="<?php echo basic_url('reports.php'); ?>">Reports</a><br>
<a href="<?php echo basic_url('files.php'); ?>">Files</a><br>
<a href="<?php echo basic_url('functions.php'); ?>">Functions</a><br>
<a href="<?php echo basic_url('calls.php'); ?>">Calls</a><br>
<a href="<?php echo basic_url('callbutterfly.php'); ?>">Call Butterfly</a><br>
<a href="<?php echo basic_url('diagram.php?d=callgraph'); ?>">Call Graph</a><br>
<a href="<?php echo basic_url('diagram.php?d=lego'); ?>">Lego Diagram</a><br>
<a href="<?php echo basic_url('source.php'); ?>">Source</a><br>
<!--
<a href="http://validator.w3.org/check/referer"><img width=88 height=31 border=0 src="valid-html40.gif" alt="Valid HTML 4.0"></a>
-->
</td>
<td valign="top">
<?php
}
function basic_footer()
{
?>
</td>
<td class="nav_menu"> </td>
</tr>
<tr>
<td colspan="3" class="nav_footer">Generated by <a href="http://ggcov.sourceforge.net/">ggcov</a> which is Copyright (c) 2001-2005 Greg Banks</td>
</tr>
</table>
</body>
</html>
<?php
}
function basic_page()
{
$cov = basic_cov();
$page = $cov->create_page($_SERVER['PHP_SELF']);
$page->parse_args($_GET);
if ($page->content_type() == 'text/html')
basic_header($page->title());
$page->render();
$cov->detach();
if ($page->content_type() == 'text/html')
basic_footer();
}
?>
|