File: cgvg-common.pl

package info (click to toggle)
cgvg 1.6.2-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny, sarge, squeeze
  • size: 216 kB
  • ctags: 3
  • sloc: perl: 404; sh: 330; makefile: 43
file content (153 lines) | stat: -rw-r--r-- 4,161 bytes parent folder | download | duplicates (5)
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
# cgvg-common.pl - common variables and functions to cgvg
# Copyright 2000-2002 by Joshua Uziel <uzi@uzix.org> - version 1.6.2
#
# 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.

# Where to store the data
$LOGDIR = "$ENV{'HOME'}/.cgvg";

# Store the data in a file named for the HOSTNAME.PID of the shell.
$HOSTNAME = $ENV{'HOSTNAME'} ? $ENV{'HOSTNAME'} : "localhost";
$PPID = getppid;
$LOGFILE = "$LOGDIR/$HOSTNAME.$PPID";

# Symlink to the last log taken.
$LASTLOG = "$ENV{'HOME'}/.cglast";

# Path to the rc file
$RCFILE = "$ENV{'HOME'}/.cgvgrc";

# Default search list:
# 	Make* *.c *.h *.s *.cc *.pl *.pm *.java *.*sh *.idl
$SEARCH = '(^Make.*$|^.*\.([chslySC]|cc|p[lm]|java|php|.*sh|idl)$)';


# List of files and strings to exclude from our search.
$EXCLUDE = "SCCS|RCS|tags|\.make\.state";

# Oldest age (in days) before we delete.
$AGE = 30;

# Set if you want colors (and your term supports it).  This is required
# for the $BOLD* options.
$COLORS = 1;

# Have everything printed in bold... 1 (yes) or 0 (no) only.  This option
# is overrided by $BOLD_ALTERNATE and only available with $COLORS
$BOLD = 0;

# Make every other line bold.
$BOLD_ALTERNATE = 1;

# Colon mode - prints file:number instead of spacing it out
$COLON = 0;

# Use the cg-built-in pager by default... 1 (yes) or 0 (no)
$PAGER = 0;

# Use the $EDITOR env. variable if it exists, else default to something.
$EDITOR = $ENV{'EDITOR'} ? ($ENV{'EDITOR'}) : "vi";

# Defined colors
%colors = ( 'black'	=> "30",
	    'red'	=> "31",
	    'green'	=> "32",
	    'yellow'	=> "33",
	    'blue'	=> "34",
	    'magenta'	=> "35",
	    'cyan'	=> "36",
	    'white'	=> "37",
	    'b_black'	=> "30",
	    'b_red'	=> "31",
	    'b_green'	=> "32",
	    'b_yellow'	=> "33",
	    'b_blue'	=> "34",
	    'b_magenta'	=> "35",
	    'b_cyan'	=> "36",
	    'b_white'	=> "37");

# Default color for column #
$color[1] = 'cyan';
$color[2] = 'blue';
$color[3] = 'red';
$color[4] = 'green';
$color[5] = 'b_white';

# Set b (bold) and c (color) values for printing
for ($i=1; $i<=5; $i++) {
	$c[$i] = $colors{$color[$i]};
	$b[$i] = ($color[$i] =~ /^b_/) ? 1 : 0; 
}

# Code to parse the RCFILE entries
sub parse_rcfile {

	if (-f $RCFILE) {
		open (IN, "<$RCFILE");
		
		while (<IN>) {
			chomp;
			
			# Strip leading spaces and skip blank and comment lines
			s/\s*//g;
			next if (/^#/);
			next if (/^$/);
			
			($key, $value) = split /=/;

			# Match only the specific value.
			if ($key =~ /^COLORS$/) {
				$COLORS=$value;
			} elsif ($key =~ /^AGE$/) {
				$AGE=$value;
			} elsif ($key =~ /^BOLD_ALTERNATE$/) {
				$BOLD_ALTERNATE=$value;
			} elsif ($key =~ /^COLON$/) {
				$COLON=$value;
 			} elsif ($key =~ /^PAGER$/) {
 			         $PAGER=$value;
			} elsif ($key =~ /^EDITOR$/) {
				$EDITOR=$value;
			} elsif ($key =~ /^EXCLUDE$/) {
				$EXCLUDE=$value;
			} elsif ($key =~ /^SEARCH$/) {
				$SEARCH=$value;

			# Change colors from the defaults.
			} elsif ($key =~ /^COLOR[1-5]$/) {

				# See that a legal color has been given
				if ($value =~ 
/^(black|red|green|yellow|blue|magenta|cyan|white|\
|b_black|b_red|b_green|b_yellow|b_blue|b_magenta|b_cyan|b_white)$/) {
					$coltmp = $key;
					$coltmp =~ s/COLOR//;
					$c[$coltmp] = $colors{$value};
					$b[$coltmp] = $value =~ /^b_/ ? 1 : 0;
				} else {
					die "error: Unknown color '$value' in",
						" $RCFILE at line $..\n";
				}
			} else {
				die "error: Unknown option '$key' in $RCFILE",
					" at line $..\n";
			}
		}

		close (IN);
	}
}

1; # Return a true value ...