File: fosslic.php

package info (click to toggle)
fossology 1.1.0-2
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 10,984 kB
  • ctags: 7,160
  • sloc: ansic: 32,477; php: 22,920; sh: 1,572; perl: 1,352; makefile: 1,110; xml: 201; sql: 21
file content (99 lines) | stat: -rwxr-xr-x 2,831 bytes parent folder | download
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
#!/usr/bin/php
<?php
/***********************************************************
 Copyright (C) 2008 Hewlett-Packard Development Company, L.P.

 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 version 2 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, write to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
***********************************************************/

/**************************************************************
 fosslic
 
 Perform a command-line one-shot license analysis.
 
 @return 0 for success, 1 for failure.
 *************************************************************/

/* Have to set this or else plugins will not load. */
$GlobalReady = 1;

/* Load all code */
require_once(dirname(__FILE__) . '/../share/fossology/php/pathinclude.php');
global $WEBDIR;
$UI_CLI = 1; /* this is a command-line program */
require_once("$WEBDIR/common/common.php");
cli_Init();

$Usage = "Usage: " . basename($argv[0]) . " [options] file [file [file...]]
  Perform a license analysis on the specified files.
  Options:
    -h       = this help message
    -v       = enable verbose debugging
  ";

/* Load command-line options */
global $DB;
global $Plugins;
$Verbose=0;
$Test=0;

/************************************************************************/
/************************************************************************/
/************************************************************************/

$Lic = &$Plugins[plugin_find_id("agent_license_once")];
if (empty($Lic))
	{
	print "FATAL: Unable to find license plugin.\n";
	exit(1);
	}

global $PROJECTSTATEDIR;
$LicCache = "$PROJECTSTATEDIR/agents/License.bsam";

for($i=1; $i < $argc; $i++)
  {
  switch($argv[$i])
    {
    case '-v':
	$Verbose++;
	break;
    case '-h':
    case '-?':
	print $Usage . "\n";
	return(0);
    default:
	if (substr($argv[$i],0,1)=='-')
	  {
	  print "Unknown parameter: '" . $argv[$i] . "'\n";
	  print $Usage . "\n";
	  return(1);
	  }
	if (!file_exists($argv[$i])) { print "ERROR: File '" . $argv[$i] . "' does not exist.\n"; }
	else
	  {
	  $_FILES['licfile']['tmp_name'] = $argv[$i];
	  $_FILES['licfile']['size'] = filesize($argv[$i]);
	  $V = $Lic->AnalyzeOne(0,$LicCache);
	  print $argv[$i] . ": ";
	  if (empty($V)) { print "None"; }
	  else { print $V; }
	  print "\n";
	  }
	break;
    } /* switch */
  } /* for each parameter */

return(0);
?>