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

Miscellaneous utility functions for maintagent. More...

#include "maintagent.h"
Include dependency graph for utils.c:

Go to the source code of this file.

Functions

FUNCTION void exitNow (int exitVal)
 Exit function. This does all cleanup and should be used instead of calling exit() or main() return. More...
 
FUNCTION char * strtoupper (char *s)
 Helper function to upper case a string. More...
 
FUNCTION void recurseDir (const char *type, char *path, int level)
 Recursively read directory till level is 0. More...
 
FUNCTION void checkPFileExists (char *sha1, char *md5, long fsize, const char *type)
 Check if given checksums exists in DB, if not call deleteRepoFile() More...
 
FUNCTION void deleteRepoFile (char *sha1, char *md5, long fsize, const char *type)
 Take a file checksum, generate repo path and call unlink() More...
 

Detailed Description

Miscellaneous utility functions for maintagent.

Definition in file utils.c.

Function Documentation

◆ checkPFileExists()

FUNCTION void checkPFileExists ( char *  sha1,
char *  md5,
long  fsize,
const char *  type 
)

Check if given checksums exists in DB, if not call deleteRepoFile()

Parameters
sha1SHA1 of the file
md5MD5 of the file
fsizesize of the file
typeType of file

Definition at line 130 of file utils.c.

◆ deleteRepoFile()

FUNCTION void deleteRepoFile ( char *  sha1,
char *  md5,
long  fsize,
const char *  type 
)

Take a file checksum, generate repo path and call unlink()

Parameters
sha1SHA1 of the file
md5MD5 of the file
fsizesize of the file
typeType of file (gold/files)
See also
fo_RepMkPath()

Definition at line 177 of file utils.c.

◆ exitNow()

FUNCTION void exitNow ( int  exitVal)

Exit function. This does all cleanup and should be used instead of calling exit() or main() return.

Parameters
exitValExit value
Returns
void Calls exit()

Definition at line 21 of file utils.c.

◆ recurseDir()

FUNCTION void recurseDir ( const char *  type,
char *  path,
int  level 
)

Recursively read directory till level is 0.

Since files in repository are stored in following format, we need to iterate on path for 3 levels before we reach a file.

*   /srv/fossology/repository/localhost/gold
*   ├── fc
*   │   └── 49
*   │       └── 77
*   │           └── fc49776c2a..... < the actual file
* 

The function will iteratively go to deper level till it reaches level 0, i.e. the file level. Once at file level, will call checkPFileExists() with individual pfile elements.

Parameters
typeType of repo file (gold/files)
pathRoot of path to traverse
levelHow many more levels to go (0 if we've reached file level)

Definition at line 67 of file utils.c.

◆ strtoupper()

FUNCTION char* strtoupper ( char *  s)

Helper function to upper case a string.

Parameters
sInput string
Returns
char* Upper case string
See also
toupper()

Definition at line 39 of file utils.c.