FOSSology  4.4.0
Open Source License Compliance by Open Source Software
regexscan-Stage3.c File Reference

Stage 3 demonstration. More...

#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <ctype.h>
#include <signal.h>
#include <libgen.h>
#include <regex.h>
#include <stdbool.h>
#include "libfossology.h"
Include dependency graph for regexscan-Stage3.c:

Go to the source code of this file.

Macros

#define MAXCMD   4096
 
#define myBUFSIZ   2048
 

Functions

int regexScan (regex_t *regex, char *regexStr, FILE *scanFilePtr, char *fileName)
 Scan a file for a regex - regular expression.
the regex is compiled in this function for performance. More...
 
int pfileNumToNames (char *pfileNum, char *pfileRepoName, char *pfileRealName)
 Creates filenames from pfile_pk value. More...
 
int regexScanUpload (char *uploadNum, char *regexStr)
 Scan an Upload for a regex - regular expression.
gets a list of files in an upload and calls regexScan() More...
 
void Usage (char *Name)
 Usage description for this regexscan agent. More...
 
int main (int argc, char *argv[])
 

Variables

char SQL [256]
 For DB. More...
 
PGconn * pgConn = NULL
 Database connection. More...
 

Detailed Description

Stage 3 demonstration.

This is stage 3 and demonstrates the fundamental agent requirements:

  1. Connect to database
  2. Connect to Scheduler
  3. Process -r as a regex argument
  4. Process filename and report regex scan results from command line
  5. Process upload file collection from upload_pk stdin input
  6. Terminate
    Author
    Paul Guttmann
    Date
    2013

Definition in file regexscan-Stage3.c.

Function Documentation

◆ pfileNumToNames()

int pfileNumToNames ( char *  pfileNum,
char *  pfileRepoName,
char *  pfileRealName 
)

Creates filenames from pfile_pk value.

Parameters
pfileNumString containing pfile_pk value
pfileRepoNameString with repo path and filename
pfileRealNameString with original filename
Returns
0 = OK, otherwise error code

Definition at line 121 of file regexscan-Stage3.c.

◆ regexScan()

int regexScan ( regex_t *  regex,
char *  regexStr,
FILE *  scanFilePtr,
char *  fileName 
)

Scan a file for a regex - regular expression.
the regex is compiled in this function for performance.

Parameters
regexHolds the compiled regular expression
regexStrString containing the regex
scanFilePtrHandle for file to scan
fileNameString name of file to scan
Returns
0 = OK, otherwise error code

Definition at line 59 of file regexscan-Stage3.c.

◆ regexScanUpload()

int regexScanUpload ( char *  uploadNum,
char *  regexStr 
)

Scan an Upload for a regex - regular expression.
gets a list of files in an upload and calls regexScan()

Parameters
uploadNumString containing upload_pk value
regexStrString containing the regex
Returns
i = number of files scanned, 0 = error

Definition at line 169 of file regexscan-Stage3.c.

◆ Usage()

void Usage ( char *  Name)

Usage description for this regexscan agent.

Say how to run this program.

Usage():

Definition at line 272 of file regexscan-Stage3.c.

Variable Documentation

◆ pgConn

PGconn* pgConn = NULL

Database connection.

DB connection.

Database connection.

Definition at line 47 of file regexscan-Stage3.c.

◆ SQL

char SQL[256]

For DB.

SQL query to execute.

Definition at line 37 of file regexscan-Stage3.c.