FOSSology  4.4.0
Open Source License Compliance by Open Source Software
libfossrepo.h
1 /*
2  librep: A set of functions for accessing the file repository.
3 
4  SPDX-FileCopyrightText: © 2007-2011 Hewlett-Packard Development Company, L.P.
5 
6  SPDX-License-Identifier: LGPL-2.1-only
7 */
28 #ifndef LIBFOSSREPO_H
29 #define LIBFOSSREPO_H
30 
31 #include <fossconfig.h>
32 
33 #include <stdlib.h>
34 #include <stdint.h>
35 #include <stdio.h>
36 #include <unistd.h>
37 #include <string.h>
38 #include <ctype.h>
39 #include <limits.h>
40 #include <utime.h>
41 #include <errno.h>
42 #include <time.h>
43 #include <sys/types.h>
44 #include <sys/mman.h>
45 #include <fcntl.h>
46 #include <grp.h>
47 
48 #ifndef FOSSREPO_CONF
49 #define FOSSREPO_CONF "/srv/fossology/repository"
50 #endif
51 #ifndef FOSSGROUP
52 #define FOSSGROUP "fossology"
53 #endif
54 
55 
56 /* General Repository usage */
57 int fo_RepOpen();
58 /* call before using any other function */
59 void fo_RepClose();
60 /* call after using all other functions */
61 int fo_RepOpenFull(fo_conf* config);
62 /* agents should call fo_RepOpen() */
63 char* fo_RepValidate(fo_conf* config); /* checks the repo config */
64 
65 /* Get info -- caller must free() returned string. */
66 char* fo_RepGetRepPath();
67 /* path to mounted repository */
68 char* fo_RepGetHost(char* Type, char* Filename);
69 char* fo_RepMkPath(const char* Type, char* Filename);
70 
71 /* Not intended for external use */
72 int _RepMkDirs(char* Filename);
73 
74 /* Sanity checks */
75 int fo_RepExist(char* Type, char* Filename);
76 int fo_RepExist2(char* Type, char* Filename);
77 int fo_RepHostExist(char* Type, char* Host);
78 
79 /* Removal */
80 int fo_RepRemove(char* Type, char* Filename);
81 
82 /* Replacements for fopen/fclose */
83 FILE* fo_RepFread(char* Type, char* Filename);
84 FILE* fo_RepFwrite(char* Type, char* Filename);
85 int fo_RepFclose(FILE* F);
86 int fo_RepImport(char* Source, char* Type, char* Filename, int HardLink);
87 
90 {
91  int FileHandle;
92  unsigned char* Mmap;
93  uint32_t MmapSize;
94  uint32_t _MmapSize;
95 };
96 typedef struct RepMmapStruct RepMmapStruct;
98 RepMmapStruct* fo_RepMmap(char* Type, char* Filename);
99 RepMmapStruct* fo_RepMmapFile(char* FullFilename);
100 
101 #endif
FOSSology library to read config file.
FILE * fo_RepFwrite(char *Type, char *Filename)
Perform an fwrite. Also creates directories.
Definition: libfossrepo.c:710
char * fo_RepMkPath(const char *Type, char *Filename)
Given a filename, construct the full path to the file.
Definition: libfossrepo.c:352
int fo_RepOpenFull(fo_conf *config)
Loads common information from configuration files into ram.
Definition: libfossrepo.c:920
int fo_RepExist2(char *Type, char *Filename)
Determine if a file exists.
Definition: libfossrepo.c:531
int fo_RepImport(char *Source, char *Type, char *Filename, int Link)
Import a file into the repository.
Definition: libfossrepo.c:812
int fo_RepFclose(FILE *F)
Perform an fclose.
Definition: libfossrepo.c:601
char * fo_RepGetRepPath()
Determine the path for the repository's root.
Definition: libfossrepo.c:102
FILE * fo_RepFread(char *Type, char *Filename)
Perform an fopen for reading only.
Definition: libfossrepo.c:613
char * fo_RepValidate(fo_conf *config)
validates the repository configuration information.
Definition: libfossrepo.c:977
int fo_RepOpen()
wrapper function for agents. Simply call fo_RepOpenFull() passing in the default system configuration
Definition: libfossrepo.c:908
int fo_RepHostExist(char *Type, char *Host)
Determine if a host exists.
Definition: libfossrepo.c:120
RepMmapStruct * fo_RepMmap(char *Type, char *Filename)
Perform a mmap.
Definition: libfossrepo.c:786
int fo_RepExist(char *Type, char *Filename)
Determine if a file exists.
Definition: libfossrepo.c:486
char * fo_RepGetHost(char *Type, char *Filename)
Determine the host for a filename.
Definition: libfossrepo.c:221
int fo_RepRemove(char *Type, char *Filename)
Delete a repository file.
Definition: libfossrepo.c:568
void fo_RepClose()
Close and unmap the repository configuration file.
Definition: libfossrepo.c:894
void fo_RepMunmap(RepMmapStruct *M)
Perform a munmap.
Definition: libfossrepo.c:721
RepMmapStruct * fo_RepMmapFile(char *Fname)
Perform a mmap on a regular file name.
Definition: libfossrepo.c:734
int _RepMkDirs(char *Fname)
Same as command-line "mkdir -p".
Definition: libfossrepo.c:408
unsigned char * Mmap
Memory pointer from mmap.
Definition: libfossrepo.h:92
int FileHandle
Handle from open()
Definition: libfossrepo.h:91
uint32_t MmapSize
Size of file mmap.
Definition: libfossrepo.h:93
uint32_t _MmapSize
Real size of mmap (set to page boundary)
Definition: libfossrepo.h:94
char * Filename
Filename.
Definition: run_tests.c:17