File: filemagic.pl

package info (click to toggle)
cfingerd 1.4.3-1.2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, sarge
  • size: 636 kB
  • ctags: 437
  • sloc: ansic: 3,706; perl: 502; makefile: 166; sh: 72
file content (44 lines) | stat: -rw-r--r-- 711 bytes parent folder | download | duplicates (13)
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
## File Magic Parser
## by Ken Hollis <khollis@bitgate.com>
##
## This program is GPLed.  Please read the LICENSE file for more information.
## Copyright (C) 1996, Bitgate Software.

sub check_exist {
	local($type, $filename, $checkfor, $cfile) = @_;
	if ($type eq "2") {
		if (-e $filename) {
			return 1;
		} else {
			return 0;
		}
	}

	if ($type eq "1") {
		if (-e $filename) {
			$clean = 0;
			open(IF, $filename);

			while(<IF>) {
				chop;
				if (/$checkfor/) {
					$clean = 1;
					last;
				}
			}
			close(IF);

			if (!$clean) {
				&disp_file($cfile);
				return &ask_question("Go ahead?", "N", BOOLEAN_QUESTION, $cfile);
			} else {
				return "Y";
			}
		} else {
			return "0";
		}
	}
}

1;