FOSSology  4.4.0
Open Source License Compliance by Open Source Software
util.h
1 /*
2  SPDX-FileCopyrightText: © 2006-2009 Hewlett-Packard Development Company, L.P.
3 
4  SPDX-License-Identifier: GPL-2.0-only
5 */
6 
7 #ifndef _UTIL_H
8 #define _UTIL_H
9 
10 #include <stdio.h>
11 #include <sys/stat.h>
12 int isDIR(char *dpath);
13 int isEMPTYDIR(char *dpath);
14 int isEMPTYFILE(char *fpath);
15 int isBLOCK(char *bpath);
16 int isCHAR(char *cpath);
17 int isPIPE(char *ppath);
18 int isSYMLINK(char *spath);
19 int isINODE(char *ipath, int typ);
20 char *newReloTarget(char *basename);
21 char *pluralName(char *s, int count);
22 
23 #ifdef MEMORY_TRACING
24 char *memAllocTagged(int size, char *name);
25 void memFreeTagged(void *ptr, char *note);
26 void memCacheDump(char *s);
27 #endif /* MEMORY_TRACING */
28 
29 char *findBol(char *s, char *upperLimit);
30 char *findEol(char *s);
31 void changeDir(char *pathname);
32 void renameInode(char *oldpath, char *newpath);
33 void unlinkFile(char *pathname);
34 void chmodInode(char *pathname, int mode);
35 FILE *fopenFile(char *pathname, char *mode);
36 FILE *popenProc(char *command, char *mode);
37 char *wordCount(char *textp);
38 char *copyString(char *s, char *label);
39 char *pathBasename(char *path);
40 char *getInstances(char *textp, int size, int nBefore, int nAfter, char *regex, int recordOffsets);
41 char *curDate();
42 
43 #ifdef MEMSTATS
44 void memStats(char *s);
45 #endif /* MEMSTATS */
46 
47 void makeSymlink(char *path);
48 
49 //void freeAndClearScan(struct curScan *thisScan);
50 void printRegexMatch(int n, int cached);
51 char *mmapFile(char *pathname);
52 void mmapOpenListing();
53 void munmapFile(void *ptr);
54 int bufferLineCount(char *p, int len);
55 void appendFile(char *pathname, char *str);
56 int nftwFileFilter(char *pathname, struct stat *st, int onlySingleLink);
57 void makePath(char *dirpath);
58 void makeDir(char *dirpath);
59 void removeDir(char *dir);
60 int mySystem(const char *fmt, ...);
61 int iMadeThis(char *textp);
62 int isFILE(char *pathname);
63 int addEntry(char *pathname, int forceFlag, const char *fmt, ...);
64 void Msg(const char *fmt, ...);
65 void Log(const char *fmt, ...);
66 void MsgLog(const char *fmt, ...);
67 void Note(const char *fmt, ...);
68 void Warn(const char *fmt, ...);
69 void Assert(int fatalFlag, const char *fmt, ...);
70 void Error(const char *fmt, ...);
71 void Fatal(const char *fmt, ...);
72 void traceFunc(char *fmtStr, ...);
73 
74 #endif /* _UTIL_H */
Fatal($msg, $filenm, $lineno)
Write message to stdout and die.
Definition: common-ui.php:66
int s
The socket that the CLI will use to communicate.
Definition: fo_cli.c:37
char * findBol(char *s, char *upperLimit)
Find Begin of Line in a string.
Definition: util.c:340
int isSYMLINK(char *spath)
Check if given path is a symbolic link.
Definition: util.c:128
void munmapFile(void *ptr)
Definition: util.c:1197
FILE * fopenFile(char *pathname, char *mode)
Open a file and return the file pointer.
Definition: util.c:476
int isFILE(char *pathname)
Check if an inode is a file.
Definition: util.c:1340
int isINODE(char *ipath, int typ)
Check for a inode against a flag.
Definition: util.c:143
int isEMPTYFILE(char *fpath)
Check if given file is empty.
Definition: util.c:65
void printRegexMatch(int n, int cached)
CDB – Need to review this code, particularly for the use of an external file (Nomos....
Definition: util.c:986
char * pathBasename(char *path)
Get the basename from a file path.
Definition: util.c:615
char * getInstances(char *textp, int size, int nBefore, int nAfter, char *regex, int recordOffsets)
Get occurrence of a regex in a given string pointer.
Definition: util.c:630
FILE * popenProc(char *command, char *mode)
Open a process pipe using popen()
Definition: util.c:521
int isDIR(char *dpath)
Check if given path is a directory.
Definition: util.c:50
char * copyString(char *s, char *label)
Create a copy of a string.
Definition: util.c:593
int isPIPE(char *ppath)
Check if given path is a pipe.
Definition: util.c:113
char * curDate()
Get the current date.
Definition: util.c:913
void Assert(int fatalFlag, const char *fmt,...)
Raise an assert.
Definition: util.c:1395
char * wordCount(char *textp)
VERY simple line count, does NOT have to be perfect!
Definition: util.c:551
void renameInode(char *oldpath, char *newpath)
Rename an inode at oldpath to newpath.
Definition: util.c:409
int mySystem(const char *fmt,...)
Run a system command.
Definition: util.c:1303
int isBLOCK(char *bpath)
Check if given path is a Block device.
Definition: util.c:83
int bufferLineCount(char *p, int len)
Finds the length of first line in a buffer.
Definition: util.c:1253
void appendFile(char *pathname, char *str)
Append a string at the end of the file.
Definition: util.c:1283
void chmodInode(char *pathname, int mode)
Change inode mode bits.
Definition: util.c:450
void makeSymlink(char *path)
Create symbolic links for a given path in current directory.
Definition: util.c:960
char * findEol(char *s)
Find first ROL in a string.
Definition: util.c:378
void Msg(const char *fmt,...)
DO NOT automatically add to a string passed to Msg(); in parseDistro, we sometimes want to dump a p...
Definition: util.c:1382
int addEntry(char *pathname, int forceFlag, const char *fmt,...)
adds a line to the specified pathname
Definition: util.c:1358
int isCHAR(char *cpath)
Check if given path is a character device.
Definition: util.c:98
char * mmapFile(char *pathname)
Blarg. Files that are EXACTLY a multiple of the system pagesize do not get a NULL on the end of the b...
Definition: util.c:1082
char * newReloTarget(char *basename)
Check if a relocation target is accessible.
Definition: util.c:175