FOSSology  4.4.0
Open Source License Compliance by Open Source Software
wc_agent.c File Reference

The word count agent, count the word count for one file. More...

#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <ctype.h>
#include <signal.h>
#include <libgen.h>
#include "libfossology.h"
Include dependency graph for wc_agent.c:

Go to the source code of this file.

Macros

#define MAXCMD   2048
 

Functions

int IsFile (long mode)
 Check if the pfile_id is a file. More...
 
int ProcessData (long PfileFk, char *Pfile)
 This function does the work. More...
 
void Usage (char *Name)
 Say how to run this program. More...
 
int main (int argc, char *argv[])
 main function More...
 

Variables

void * pgConn = NULL
 Database connection. More...
 
long GlobalPfileFk =-1
 
char GlobalPfile [MAXCMD]
 

Detailed Description

The word count agent, count the word count for one file.

Definition in file wc_agent.c.

Function Documentation

◆ IsFile()

int IsFile ( long  mode)

Check if the pfile_id is a file.

The pfile (sha1.md5.len) to process

Parameters
modemode of the pfile, if is from ufile_mode in table upload_tree
container=1<<29, artifact=1<<28, project=1<<27, replica(same pfile)=1<<26, package=1<<25,directory=1<<18
Returns
1 on yes, is a file; 0 on no, not a file

if ((mode & 1<<18) + (mode & 0040000) != 0), is dir if ((mode & 1<<28) != 0), is artifact if ((mode & 1<<29) != 0), is container a file is not dir, artifact, and container

Definition at line 55 of file wc_agent.c.

◆ main()

int main ( int  argc,
char *  argv[] 
)

main function

Returns
0 on success, exit(-1) on failure.

< is a file?

Definition at line 166 of file wc_agent.c.

◆ ProcessData()

int ProcessData ( long  PfileFk,
char *  Pfile 
)

This function does the work.

In this example, we'll just run wc and store the results in the database.

Note
Requires: DB open and ready.
Parameters
PfileFkpfile id
Pfilethe file path in repo
Returns
0 on success, != 0 on failure.

Definition at line 79 of file wc_agent.c.

◆ Usage()

void Usage ( char *  Name)

Say how to run this program.

Many agents permit running from the command-line for testing. At minimum, you need "-i" to initialize the DB and exit.

Definition at line 154 of file wc_agent.c.

Variable Documentation

◆ GlobalPfile

char GlobalPfile[MAXCMD]

The pfile_fk to process

Definition at line 45 of file wc_agent.c.

◆ pgConn

void* pgConn = NULL

Database connection.

DB connection.

Definition at line 41 of file wc_agent.c.