FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
wget_agent.h
1 /*********************************************************************
2 Copyright (C) 2011-2014 Hewlett-Packard Development Company, L.P.
3 
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 version 2 as published by the Free Software Foundation.
7 
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12 
13 You should have received a copy of the GNU General Public License along
14 with this program; if not, write to the Free Software Foundation, Inc.,
15 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16  *********************************************************************/
17 
18 /*
19  * \file wget_agent.h
20  */
21 
22 #ifndef _WGET_AGENT_H
23 #define _WGET_AGENT_H 1
24 
25 /* specify support for files > 2G */
26 #define __USE_LARGEFILE64
27 
28 #include <stdio.h>
29 #include <stdlib.h>
30 #include <unistd.h>
31 #include <sys/types.h>
32 #include <sys/stat.h>
33 #include <sys/wait.h>
34 #include <string.h>
35 #include <ctype.h>
36 #include <signal.h>
37 #include <grp.h>
38 #include <libgen.h>
39 
40 #define lstat64(x,y) lstat(x,y)
41 #define stat64(x,y) stat(x,y)
42 #define systemError(line, error, cmd) LOG_FATAL("[%s:%d] Error exit: %d, CMD:%s\n", __FILE__, line, WEXITSTATUS(error), cmd);
43 
44 typedef struct stat stat_t;
45 
46 #include "libfossology.h"
47 
48 #include "../../ununpack/agent/checksum.h"
49 
50 #define URLMAX 3072
51 #define STRMAX 2048
52 #define FILEPATH 2048
53 
54 extern char SQL[STRMAX];
55 
56 /* for the DB */
57 extern PGconn *pgConn;
58 /* input for this system */
59 extern long GlobalUploadKey;
60 extern char GlobalTempFile[STRMAX];
61 extern char GlobalURL[URLMAX];
62 extern char GlobalParam[STRMAX];
63 extern char GlobalType[STRMAX];
64 extern int GlobalImportGold; /* set to 0 to not store file in gold repository */
65 extern gid_t ForceGroup;
66 
67 /* for debugging */
68 extern int Debug;
69 
70 int IsFile(char *Fname, int Link);
71 void SafeExit (int rc);
72 int GetPosition(char *URL);
73 void DBLoadGold ();
74 int TaintURL(char *Sin, char *Sout, int SoutSize);
75 int GetURL(char *TempFile, char *URL, char *TempFileDir);
76 void SetEnv(char *S, char *TempFileDir);
77 char *PathCheck (char *DirPath);
78 
79 void Usage (char *Name);
80 
81 int Archivefs(char *Path, char *TempFile, char *TempFileDir, struct stat Status);
82 
83 int GetVersionControl();
84 
85 void GetProxy();
86 
88 
89 void MaskPassword();
90 
91 char* GetVersionControlCommand(int withPassword);
92 
93 #endif /* _WGET_AGENT_H */
94 
char * PathCheck(char *DirPath)
Check if path contains a "%U" or "%H". If so, substitute a unique ID for U.
Definition: utils.c:1672
void MaskPassword()
Get the username from GlobalParam and create new parameters without password.
Definition: wget_agent.c:1075
gid_t ForceGroup
Set to group id to be used for download files.
Definition: wget_agent.c:43
int Archivefs(char *Path, char *TempFile, char *TempFileDir, struct stat Status)
Copy downloaded files to temporary directory.
Definition: wget_agent.c:831
int GetPosition(char *URL)
Get the position (ending + 1) of http|https|ftp:// of one url.
Definition: wget_agent.c:78
PGconn * pgConn
Database connection.
Definition: adj2nest.c:98
int IsFile(long mode)
Check if the pfile_id is a file.
Definition: wc_agent.c:67
long GlobalUploadKey
Input for this system.
Definition: wget_agent.c:35
char * GetVersionControlCommand(int withPassword)
get the command to run to get files from version control system
Definition: wget_agent.c:1130
char GlobalParam[STRMAX]
Additional parameters.
Definition: wget_agent.c:39
int GetURL(char *TempFile, char *URL, char *TempFileDir)
Do the wget.
Definition: wget_agent.c:340
char GlobalType[STRMAX]
Type of download (FILE/version control)
Definition: wget_agent.c:38
void replace_url_with_auth()
Translate authentication of git clone.
Definition: wget_agent.c:1018
void GetProxy()
Get proxy from fossology.conf.
Definition: wget_agent.c:928
char GlobalURL[URLMAX]
URL to download.
Definition: wget_agent.c:37
void SetEnv(char *S, char *TempFileDir)
Convert input pairs into globals.
Definition: wget_agent.c:695
void DBLoadGold()
Insert a file into the database and repository.
Definition: wget_agent.c:93
char SQL[256]
SQL query to execute.
Definition: adj2nest.c:90
char GlobalTempFile[STRMAX]
Temp file to be used.
Definition: wget_agent.c:36
Usage()
Print Usage statement.
Definition: fo_dbcheck.php:75
int GetVersionControl()
Get source code from version control system.
Definition: wget_agent.c:578
The main FOSSology C library.
int GlobalImportGold
Set to 0 to not store file in gold repository.
Definition: wget_agent.c:42
int TaintURL(char *Sin, char *Sout, int SoutSize)
Given a URL string, taint-protect it.
Definition: wget_agent.c:281
void SafeExit(int rc)
Close scheduler and database connections, then exit.
Definition: utils.c:88