FOSSology
4.4.0
Open Source License Compliance by Open Source Software
|
Repository access functions. All internal functions are prefixed by '_'. More...
#include "libfossrepo.h"
#include "libfossscheduler.h"
#include "fossconfig.h"
#include <sys/stat.h>
#include <glib.h>
Go to the source code of this file.
Macros | |
#define | MAXHOSTNAMELEN 64 |
Max host name length. | |
#define | MAXLINE 1024 |
Max length of a line. | |
#define | REPONAME "REPOSITORY" |
Default repo name. | |
#define | GROUP 0 |
Default group ID. | |
#define | REPCONFCHECK() { if (!*RepPath) fo_RepOpen(); } |
Functions | |
int | _RepCheckType (const char *S) |
Simple check to see if the string S is valid filename. More... | |
int | _RepCheckString (char *S) |
Simple check to see if the string is valid. More... | |
char * | fo_RepGetRepPath () |
Determine the path for the repository's root. More... | |
int | fo_RepHostExist (char *Type, char *Host) |
Determine if a host exists. More... | |
char * | _RepGetHost (const char *Type, char *Filename, int MatchNum) |
Determine the host for the tree. More... | |
char * | fo_RepGetHost (char *Type, char *Filename) |
Determine the host for a filename. More... | |
char * | fo_RepMkPathTmp (const char *Type, char *Filename, char *Ext, int Which) |
Given a filename, construct the full path to the file. More... | |
char * | fo_RepMkPath (const char *Type, char *Filename) |
Given a filename, construct the full path to the file. More... | |
void | _RepUpdateTime (char *File) |
Update the last modified time of a file. More... | |
int | _RepMkDirs (char *Fname) |
Same as command-line "mkdir -p". More... | |
int | fo_RepRenameTmp (char *Type, char *Filename, char *Ext) |
Rename a temp file to a real file. More... | |
int | fo_RepExist (char *Type, char *Filename) |
Determine if a file exists. More... | |
int | fo_RepExist2 (char *Type, char *Filename) |
Determine if a file exists. More... | |
int | fo_RepRemove (char *Type, char *Filename) |
Delete a repository file. More... | |
int | fo_RepFclose (FILE *F) |
Perform an fclose. More... | |
FILE * | fo_RepFread (char *Type, char *Filename) |
Perform an fopen for reading only. More... | |
FILE * | fo_RepFwriteTmp (char *Type, char *Filename, char *Ext) |
Perform an fwrite. Also creates directories. More... | |
FILE * | fo_RepFwrite (char *Type, char *Filename) |
Perform an fwrite. Also creates directories. More... | |
void | fo_RepMunmap (RepMmapStruct *M) |
Perform a munmap. More... | |
RepMmapStruct * | fo_RepMmapFile (char *Fname) |
Perform a mmap on a regular file name. More... | |
RepMmapStruct * | fo_RepMmap (char *Type, char *Filename) |
Perform a mmap. More... | |
int | fo_RepImport (char *Source, char *Type, char *Filename, int Link) |
Import a file into the repository. More... | |
void | fo_RepClose () |
Close and unmap the repository configuration file. | |
int | fo_RepOpen () |
wrapper function for agents. Simply call fo_RepOpenFull() passing in the default system configuration More... | |
int | fo_RepOpenFull (fo_conf *config) |
Loads common information from configuration files into ram. More... | |
char * | fo_RepValidate (fo_conf *config) |
validates the repository configuration information. More... | |
Variables | |
int | RepDepth = 2 |
char | RepPath [MAXLINE+1] = "" |
Repository access functions. All internal functions are prefixed by '_'.
Definition in file libfossrepo.c.
int _RepCheckString | ( | char * | S | ) |
Simple check to see if the string is valid.
Valid strings only contain alphanumerics, and "@%_.=+-"
.
Used for types, hostnames, and filenames.
S | string to check |
Definition at line 83 of file libfossrepo.c.
int _RepCheckType | ( | const char * | S | ) |
Simple check to see if the string S is valid filename.
A valid name is composed of only alphanumerics, and "&%_=+-"
Used for types, hostnames, and filenames.
(Just like _RepCheckString, except dots are not allowed.)
S | string to check |
Definition at line 61 of file libfossrepo.c.
char* _RepGetHost | ( | const char * | Type, |
char * | Filename, | ||
int | MatchNum | ||
) |
Determine the host for the tree.
Type | Type of data. |
Filename | Filename to match. |
MatchNum | Used to identify WHICH match to return. (MatchNum permits fallback paths.) |
Definition at line 158 of file libfossrepo.c.
int _RepMkDirs | ( | char * | Fname | ) |
Same as command-line "mkdir -p".
Fname | filename |
Definition at line 408 of file libfossrepo.c.
void _RepUpdateTime | ( | char * | File | ) |
Update the last modified time of a file.
Every file access (read/write) should update the timestamp on the file. This allows us to determine when files are stale.
File | file name |
Definition at line 394 of file libfossrepo.c.
int fo_RepExist | ( | char * | Type, |
char * | Filename | ||
) |
Determine if a file exists.
Type | Type of data. |
Filename | The file in question |
Definition at line 486 of file libfossrepo.c.
int fo_RepExist2 | ( | char * | Type, |
char * | Filename | ||
) |
Determine if a file exists.
If it does not exist, return an error code (errno). This is a replacement for fo_RepExist().
Type | is the type of data. |
Filename |
Definition at line 531 of file libfossrepo.c.
int fo_RepFclose | ( | FILE * | F | ) |
Perform an fclose.
F | File handler |
Definition at line 601 of file libfossrepo.c.
FILE* fo_RepFread | ( | char * | Type, |
char * | Filename | ||
) |
Perform an fopen for reading only.
Type | Type of data. |
Filename | File to open. |
Definition at line 613 of file libfossrepo.c.
FILE* fo_RepFwrite | ( | char * | Type, |
char * | Filename | ||
) |
Perform an fwrite. Also creates directories.
Same as fo_RepFwriteTmp() but without ext.
Type | Type of data. |
Filename | File to write |
Definition at line 710 of file libfossrepo.c.
FILE* fo_RepFwriteTmp | ( | char * | Type, |
char * | Filename, | ||
char * | Ext | ||
) |
Perform an fwrite. Also creates directories.
Type | Type of data. |
Filename | File to write to |
Ext | An optional extension (for making temporary files). |
Definition at line 648 of file libfossrepo.c.
char* fo_RepGetHost | ( | char * | Type, |
char * | Filename | ||
) |
Determine the host for a filename.
Type | Type of data. |
Filename | Filename to match. |
Definition at line 221 of file libfossrepo.c.
char* fo_RepGetRepPath | ( | ) |
Determine the path for the repository's root.
The RepPath is where all the repository mounts are located. The path should NOT end with a "/".
Definition at line 102 of file libfossrepo.c.
int fo_RepHostExist | ( | char * | Type, |
char * | Host | ||
) |
Determine if a host exists.
Type | This is the repo type (files, gold, ununpack, ...) |
Host | Host to check |
Definition at line 120 of file libfossrepo.c.
int fo_RepImport | ( | char * | Source, |
char * | Type, | ||
char * | Filename, | ||
int | Link | ||
) |
Import a file into the repository.
This is a REALLY FAST copy.
Source | Source filename |
Type | Type of data. |
Filename | The destination filename |
Link | true if this should be a hardlink instead of a copy |
Definition at line 812 of file libfossrepo.c.
char* fo_RepMkPath | ( | const char * | Type, |
char * | Filename | ||
) |
Given a filename, construct the full path to the file.
Type | Type of data. |
Filename | filename |
This does NOT make the actual file or modify the file system!
Definition at line 352 of file libfossrepo.c.
char* fo_RepMkPathTmp | ( | const char * | Type, |
char * | Filename, | ||
char * | Ext, | ||
int | Which | ||
) |
Given a filename, construct the full path to the file.
Type | Type of data. |
Filename | Filename to construct |
Ext | An optional extension (for making temporary files). |
Which | Used to identify WHICH match to return. |
This does NOT make the actual file or modify the file system!
Definition at line 244 of file libfossrepo.c.
RepMmapStruct* fo_RepMmap | ( | char * | Type, |
char * | Filename | ||
) |
Perform a mmap.
Type | Type of data. |
Filename | The filename to match. |
Definition at line 786 of file libfossrepo.c.
RepMmapStruct* fo_RepMmapFile | ( | char * | Fname | ) |
Perform a mmap on a regular file name.
Filename |
Definition at line 734 of file libfossrepo.c.
void fo_RepMunmap | ( | RepMmapStruct * | M | ) |
Perform a munmap.
This frees the struct RepMmap.
M | RepMmapStruct pointer |
Definition at line 721 of file libfossrepo.c.
int fo_RepOpen | ( | ) |
wrapper function for agents. Simply call fo_RepOpenFull() passing in the default system configuration
Definition at line 908 of file libfossrepo.c.
int fo_RepOpenFull | ( | fo_conf * | config | ) |
Loads common information from configuration files into ram.
config | The configuration to use |
Definition at line 920 of file libfossrepo.c.
int fo_RepRemove | ( | char * | Type, |
char * | Filename | ||
) |
Delete a repository file.
Type | Type of data. |
Filename | File to be deleted. |
Definition at line 568 of file libfossrepo.c.
int fo_RepRenameTmp | ( | char * | Type, |
char * | Filename, | ||
char * | Ext | ||
) |
Rename a temp file to a real file.
Type | Type of data. |
Filename | File to be renamed |
Ext | An optional extension (for making temporary files). |
Definition at line 454 of file libfossrepo.c.
char* fo_RepValidate | ( | fo_conf * | config | ) |
validates the repository configuration information.
Checks that the repository entries in fossology.conf are correct. If this function does not return NULL, then the caller owns the return value.
config | the configuration information |
Definition at line 977 of file libfossrepo.c.