FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
regexscan-Stage1.c
Go to the documentation of this file.
1 /***************************************************************
2  regexscan: Scan file(s) for regular expression(s)
3 
4  Copyright (C) 2007-2013 Hewlett-Packard Development Company, L.P.
5 
6  This program is free software; you can redistribute it and/or
7  modify it under the terms of the GNU General Public License
8  version 2 as published by the Free Software Foundation.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License along
16  with this program; if not, write to the Free Software Foundation, Inc.,
17  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  ***************************************************************/
19 
30 #include <stdlib.h>
31 #include <stdio.h>
32 #include <unistd.h>
33 #include <string.h>
34 #include <ctype.h>
35 #include <signal.h>
36 #include <libgen.h>
37 
38 #include "libfossology.h"
39 
40 #define MAXCMD 4096
41 char SQL[256];
42 
43 #define myBUFSIZ 2048
44 
45 /*
46 #ifdef COMMIT_HASH
47 char BuildVersion[]="Build version: " COMMIT_HASH ".\n";
48 #endif
49 */
50 
51 PGconn *pgConn = NULL; // Database connection
52 
56 void Usage (char *Name)
57 {
58  printf("Usage: %s [options] [id [id ...]]\n",Name);
59  printf(" -i :: initialize the database, then exit.\n");
60  printf(" -c SYSCONFDIR :: FOSSology configuration directory.\n");
61  printf(" -h :: show available command line options.\n");
62  printf(" -v :: increase agent logging verbosity.\n");
63 } /* Usage() */
64 
65 /*********************************************************/
66 int main (int argc, char *argv[])
67 {
68  int c;
69 
70  char *COMMIT_HASH;
71  char *VERSION;
72  char agent_rev[myBUFSIZ];
73 
74  /* connect to scheduler. Noop if not run from scheduler. */
75  fo_scheduler_connect(&argc, argv, &pgConn);
76 
77 /*
78  Version reporting.
79 */
80  COMMIT_HASH = fo_sysconfig("regexscan", "COMMIT_HASH");
81  VERSION = fo_sysconfig("regexscan", "VERSION");
82  sprintf(agent_rev, "%s.%s", VERSION, COMMIT_HASH);
83 
84  fprintf(stdout, "regexscan reports version info as '%s.%s'.\n", VERSION, COMMIT_HASH);
85 
86  /* Process command-line */
87  while((c = getopt(argc,argv,"civ")) != -1)
88  {
89  switch(c)
90  {
91  case 'c':
92  break; /* handled by fo_scheduler_connect() */
93  case 'i':
94  PQfinish(pgConn);
95  return(0);
96  case 'v':
97  agent_verbose++;
98  break;
99  case 'h':
100  default:
101  Usage(argv[0]);
102  fflush(stdout);
103  PQfinish(pgConn);
104  exit(-1);
105  }
106  }
107 
108  PQfinish(pgConn);
110 
111  return 0;
112 } /* main() */
113 
char SQL[256]
For DB.
void fo_scheduler_disconnect(int retcode)
Disconnect the scheduler connection.
void fo_scheduler_connect(int *argc, char **argv, PGconn **db_conn)
Establish a connection between an agent and the scheduler.
int agent_verbose
Common verbose flags for the agents, this is used so that the scheduler can change the verbose level ...
void Usage(char *Name)
Say how to run this program.
The main FOSSology C library.
PGconn * pgConn
Database connection.
char * fo_sysconfig(const char *sectionname, const char *variablename)
gets a system configuration variable from the configuration data.