FOSSology  4.7.1
Open Source License Compliance by Open Source Software
snippet_scan.c File Reference

Scanoss agent for Fossology. Scans for licenses on osskb.org. More...

#include "snippet_scan.h"
#include <stdio.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
Include dependency graph for snippet_scan.c:

Go to the source code of this file.

Functions

void logme (char *msg)
 
static int run_scanoss_command (const char *pythonPath, const char *scanossPath, const char *folder, const char *outputFile, const char *apiurl, const char *key)
 Safely run scanoss-py command using fork+exec instead of popen. More...
 
int splitLine (char *lineToSplit, char *separator, char **fields)
 
void extract_csv (char *out, char *in, int n, long limit, char sep)
 
FILE * openFileByKey (long pFileKey)
 Open a file of the repository given its primary key. More...
 
int getLicenseId (unsigned char *name)
 Retrieves the license id (license_ref.rf_pk) given its short name.
 
void dumpToFile (const char *path, unsigned char *content, long size)
 Dumps the content of a file in the repository to a temporary file. More...
 
void RestoreTempFile (char *uploadFolder, long key, long realParent, char *realName)
 
void ParseResults (char *folder)
 Parse results from a temporary file and store results on database. More...
 
int ScanFolder (char *folder)
 Scans a Temporary folder. More...
 
int RebuildUpload (long upload_pk, char *tempFolder)
 
void Usage (char *Name)
 Say how to run this program. More...
 

Variables

char * baseTMP
 
int Verbose = 0
 Verbose level. More...
 
PGconn * db_conn = NULL
 The connection to Database. More...
 
int Agent_pk
 agent identifier
 
char ApiUrl [200]
 
char accToken [100]
 

Detailed Description

Scanoss agent for Fossology. Scans for licenses on osskb.org.

snippet_scan.c

The SCANOSS Agent for Fossology tool

Copyright (C) 2018-2025 SCANOSS.COM

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.

Date

Definition in file snippet_scan.c.

Function Documentation

◆ dumpToFile()

void dumpToFile ( const char *  path,
unsigned char *  content,
long  size 
)

Dumps the content of a file in the repository to a temporary file.

Parameters
pathPath to the temporary file
contentBuffer containing the file
sizeSize of the file to be stored

Definition at line 236 of file snippet_scan.c.

◆ openFileByKey()

FILE* openFileByKey ( long  pFileKey)

Open a file of the repository given its primary key.

Parameters
pFileKeythe key of the file to be retrieved
Returns
Pointer to the file

Definition at line 174 of file snippet_scan.c.

◆ ParseResults()

void ParseResults ( char *  folder)

Parse results from a temporary file and store results on database.

Parameters
folderPath to the temporary project folder

Definition at line 291 of file snippet_scan.c.

◆ run_scanoss_command()

static int run_scanoss_command ( const char *  pythonPath,
const char *  scanossPath,
const char *  folder,
const char *  outputFile,
const char *  apiurl,
const char *  key 
)
static

Safely run scanoss-py command using fork+exec instead of popen.

Parameters
pythonPathPath to Python dependencies
scanossPathPath to scanoss-py executable
folderFolder to scan
outputFileOutput CSV file path
apiurlAPI URL option (or empty string)
keyAPI key option (or empty string)
Returns
0 on success, -1 on failure

Definition at line 46 of file snippet_scan.c.

◆ ScanFolder()

int ScanFolder ( char *  folder)

Scans a Temporary folder.

Scans a Temporary folder with a rebuild project and places results in results.csv

Parameters
folderpath to temp folder
Returns
0 on success, -1 on failure

Definition at line 403 of file snippet_scan.c.

◆ Usage()

void Usage ( char *  Name)

Say how to run this program.

Print usage of bucket agent

Parameters
NameAbsolute path of agent

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

Say how to run this program.

Parameters
Name- the name of the executable, usually it is mimetype

Say how to run this program.

Parameters
NamePath to nomos binary

Usage():

Say how to run this program.

Usage():

Say how to run this program.

Usage():

Parameters
NamePath of the binary

Definition at line 533 of file snippet_scan.c.

Variable Documentation

◆ db_conn

PGconn* db_conn = NULL

The connection to Database.

the connection to Database

Definition at line 129 of file snippet_scan.c.

◆ Verbose

int Verbose = 0

Verbose level.

Global verbose level.

Contains all the functions supported by delagent

Verbosity level

Definition at line 128 of file snippet_scan.c.