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  * \file
19  * \brief Contains global declaration of variables
20  */
21 #ifndef UNUNPACK_GLOBALS_H
22 #define UNUNPACK_GLOBALS_H
23 
24 #ifdef COMMIT_HASH
25 char BuildVersion[]="Build version: " COMMIT_HASH ".\n";
26 char Version[]=COMMIT_HASH;
27 #else
28 char Version[]="0.9.9";
29 #endif
30 
31 int Verbose=0;
32 int Quiet=0;
33 int UnlinkSource=0;
34 int UnlinkAll=0;
35 int ForceContinue=0;
36 int ForceDuplicate=0;	/* when using db, should it process duplicates? */
37 int PruneFiles=0;
38 int SetContainerArtifact=1;	/* should initial container be an artifact? */
39 FILE *ListOutFile=NULL;
40 int ReunpackSwitch=0;
41 int IgnoreSCMData=0;
42 
43 /* for the repository */
44 int UseRepository=0;
45 char REP_GOLD[16]="gold";
46 char REP_FILES[16]="files";
47 
48 char UploadFileName[FILENAME_MAX];  /* upload file name */
49 
50 /*** For DB queries ***/
51 char *Pfile = NULL;
52 char *Pfile_Pk = NULL; /* PK for *Pfile */
53 char *Upload_Pk = NULL; /* PK for upload table */
54 PGconn *pgConn = NULL; /* PGconn from DB */
55 int agent_pk=-1;	/* agent ID */
56 char SQL[MAXSQL];
57 char uploadtree_tablename[19];  /* upload.uploadtree_tablename */
58 magic_t MagicCookie = 0;
59 
60 unpackqueue Queue[MAXCHILD+1];    /* manage children */
61 int MaxThread=1; /* value between 1 and MAXCHILD */
62 int Thread=0;
63 
64 /*** Global Stats (for summaries) ***/
65 long TotalItems=0;	/* number of records inserted */
66 int TotalFiles=0;
67 int TotalCompressedFiles=0;
68 int TotalDirectories=0;
69 int TotalContainers=0;
70 int TotalArtifacts=0;
71 
72 /***  Command table ***/
73 cmdlist CMD[] =
74 {
75 /* 0 */ { "","","","","",CMD_NULL,0,0177000,0177000, },
76 /* 1 */ { "application/gzip","zcat","","> '%s' 2>/dev/null","",CMD_PACK,1,0177000,0177000, },
77 /* 2 */ { "application/x-gzip","zcat","","> '%s' 2>/dev/null","",CMD_PACK,1,0177000,0177000, },
78 /* 3 */ { "application/x-compress","zcat","","> '%s' 2>/dev/null","",CMD_PACK,1,0177000,0177000, },
79 /* 4 */ { "application/x-bzip","bzcat","","> '%s' 2>/dev/null","",CMD_PACK,1,0177000,0177000, },
80 /* 5 */ { "application/x-bzip2","bzcat","","> '%s' 2>/dev/null","",CMD_PACK,1,0177000,0177000, },
81 /* 6 */ { "application/x-upx","upx","-d -o'%s'",">/dev/null 2>&1","",CMD_PACK,1,0177000,0177000, },
82 /* 7 */ { "application/pdf","pdftotext","-htmlmeta","'%s' >/dev/null 2>&1","",CMD_PACK,1,0100000,0100000, },
83 /* 8 */ { "application/x-pdf","pdftotext","-htmlmeta","'%s' >/dev/null 2>&1","",CMD_PACK,1,0100000,0100000, },
84 /* 9 */ { "application/x-zip","unzip","-q -P none -o","-x / >/dev/null 2>&1","unzip -Zhzv '%s' > '%s'",CMD_ARC,1,0177000,0177000, },
85 /* 10 */{ "application/zip","unzip","-q -P none -o","-x / >/dev/null 2>&1","unzip -Zhzv '%s' > '%s'",CMD_ARC,1,0177000,0177000, },
86 /* 11 */{ "application/x-tar","tar","-xSf","2>&1 ; echo ''","",CMD_ARC,1,0177000,0177777, },
87 /* 12 */{ "application/x-gtar","tar","-xSf","2>&1 ; echo ''","",CMD_ARC,1,0177000,0177777, },
88 /* 13 */{ "application/x-cpio","cpio","--no-absolute-filenames -i -d <",">/dev/null 2>&1","",CMD_ARC,1,0177777,0177777, },
89 /* 14 */{ "application/x-rar","unrar","x -o+ -p-",">/dev/null 2>&1","",CMD_ARC,1,0177000,0177000, },
90 /* 15 */{ "application/x-cab","cabextract","",">/dev/null 2>&1","",CMD_ARC,1,0177000,0177000, },
91 /* 16 */{ "application/x-7z-compressed","7z","x -y -pjunk",">/dev/null 2>&1","",CMD_ARC,1,0177000,0177000, },
92 /* 17 */{ "application/x-7z-w-compressed","7z","x -y -pjunk",">/dev/null 2>&1","",CMD_ARC,1,0177000,0177000, },
93 /* 18 */{ "application/x-rpm","rpm2cpio","","> '%s' 2> /dev/null","rpm -qip '%s' > '%s' 2>&1",CMD_RPM,1,0177000,0177000, },
94 /* 19 */{ "application/x-archive","ar","x",">/dev/null 2>&1","",CMD_AR,1,0177000,0177777, },
95 /* 20 */{ "application/x-debian-package","ar","x",">/dev/null 2>&1","dpkg -I '%s' > '%s'",CMD_AR,1,0177000,0177777, },
96 /* 21 */{ "application/x-iso","","","","isoinfo -d -i '%s' > '%s'",CMD_ISO,1,0177777,0177777, },
97 /* 22 */{ "application/x-iso9660-image","","","","isoinfo -d -i '%s' > '%s'",CMD_ISO,1,0177777,0177777, },
98 /* 23 */{ "application/x-fat","fat","","","",CMD_DISK,1,0177700,0177777, },
99 /* 24 */{ "application/x-ntfs","ntfs","","","",CMD_DISK,1,0177700,0177777, },
100 /* 25 */{ "application/x-ext2","linux-ext","","","",CMD_DISK,1,0177777,0177777, },
101 /* 26 */{ "application/x-ext3","linux-ext","","","",CMD_DISK,1,0177777,0177777, },
102 /* 27 */{ "application/x-x86_boot","departition","","> /dev/null 2>&1","",CMD_PARTITION,1,0177000,0177000, },
103 /* 28 */{ "application/x-debian-source","dpkg-source","-x","'%s' >/dev/null 2>&1","",CMD_DEB,1,0177000,0177000, },
104 /* 29 */{ "application/x-xz","tar","-JxSf",">/dev/null 2>&1","",CMD_ARC,1,0177000,0177777, },
105 /* 30 */{ "application/jar","unzip","-q -P none -o","-x / >/dev/null 2>&1","unzip -Zhzv '%s' > '%s'",CMD_ARC,1,0177000,0177000, },
106 /* 31 */{ "application/java-archive","unzip","-q -P none -o","-x / >/dev/null 2>&1","unzip -Zhzv '%s' > '%s'",CMD_ARC,1,0177000,0177000, },
107 /* 32 */{ "application/x-dosexec","7z","x -y -pjunk",">/dev/null 2>&1","",CMD_ARC,1,0177000,0177000, },
108 /* 33 */{ "application/vnd.debian.binary-package","ar","x",">/dev/null 2>&1","dpkg -I '%s' > '%s'",CMD_AR,1,0177000,0177777, },
109 /* 34 */{ "","","",">/dev/null 2>&1","",CMD_DEFAULT,1,0177000,0177000, },
110   { NULL,NULL,NULL,NULL,NULL,-1,-1,0177000,0177000, },
111 };
112 #endif
113