FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
util.h
1 /***************************************************************
2  Copyright (C) 2006-2009 Hewlett-Packard Development Company, L.P.
3 
4  This program is free software; you can redistribute it and/or
5  modify it under the terms of the GNU General Public License
6  version 2 as published by the Free Software Foundation.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License along
14  with this program; if not, write to the Free Software Foundation, Inc.,
15  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 
17 ***************************************************************/
18 
19 #ifndef _UTIL_H
20 #define _UTIL_H
21 
22 #include <stdio.h>
23 #include <sys/stat.h>
24 int isDIR(char *dpath);
25 int isEMPTYDIR(char *dpath);
26 int isEMPTYFILE(char *fpath);
27 int isBLOCK(char *bpath);
28 int isCHAR(char *cpath);
29 int isPIPE(char *ppath);
30 int isSYMLINK(char *spath);
31 int isINODE(char *ipath, int typ);
32 char *newReloTarget(char *basename);
33 char *pluralName(char *s, int count);
34 
35 #ifdef MEMORY_TRACING
36 char *memAllocTagged(int size, char *name);
37 void memFreeTagged(void *ptr, char *note);
38 void memCacheDump(char *s);
39 #endif /* MEMORY_TRACING */
40 
41 char *findBol(char *s, char *upperLimit);
42 char *findEol(char *s);
43 void changeDir(char *pathname);
44 void renameInode(char *oldpath, char *newpath);
45 void unlinkFile(char *pathname);
46 void chmodInode(char *pathname, int mode);
47 FILE *fopenFile(char *pathname, char *mode);
48 FILE *popenProc(char *command, char *mode);
49 char *wordCount(char *textp);
50 char *copyString(char *s, char *label);
51 char *pathBasename(char *path);
52 char *getInstances(char *textp, int size, int nBefore, int nAfter, char *regex, int recordOffsets);
53 char *curDate();
54 
55 #ifdef MEMSTATS
56 void memStats(char *s);
57 #endif /* MEMSTATS */
58 
59 void makeSymlink(char *path);
60 
61 //void freeAndClearScan(struct curScan *thisScan);
62 void printRegexMatch(int n, int cached);
63 char *mmapFile(char *pathname);
64 void mmapOpenListing();
65 void munmapFile(void *ptr);
66 int bufferLineCount(char *p, int len);
67 void appendFile(char *pathname, char *str);
68 int nftwFileFilter(char *pathname, struct stat *st, int onlySingleLink);
69 void makePath(char *dirpath);
70 void makeDir(char *dirpath);
71 void removeDir(char *dir);
72 int mySystem(const char *fmt, ...);
73 int iMadeThis(char *textp);
74 int isFILE(char *pathname);
75 int addEntry(char *pathname, int forceFlag, const char *fmt, ...);
76 void Msg(const char *fmt, ...);
77 void Log(const char *fmt, ...);
78 void MsgLog(const char *fmt, ...);
79 void Note(const char *fmt, ...);
80 void Warn(const char *fmt, ...);
81 void Assert(int fatalFlag, const char *fmt, ...);
82 void Error(const char *fmt, ...);
83 void Fatal(const char *fmt, ...);
84 void traceFunc(char *fmtStr, ...);
85 
86 #endif /* _UTIL_H */
int isFILE(char *pathname)
Check if an inode is a file.
Definition: util.c:1352
int isEMPTYFILE(char *fpath)
Check if given file is empty.
Definition: util.c:77
char * curDate()
Get the current date.
Definition: util.c:925
void chmodInode(char *pathname, int mode)
Change inode mode bits.
Definition: util.c:462
int s
The socket that the CLI will use to communicate.
Definition: fo_cli.c:48
char * wordCount(char *textp)
VERY simple line count, does NOT have to be perfect!
Definition: util.c:563
int bufferLineCount(char *p, int len)
Finds the length of first line in a buffer.
Definition: util.c:1265
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:642
int isCHAR(char *cpath)
Check if given path is a character device.
Definition: util.c:110
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:1394
int addEntry(char *pathname, int forceFlag, const char *fmt,...)
adds a line to the specified pathname
Definition: util.c:1370
void Assert(int fatalFlag, const char *fmt,...)
Raise an assert.
Definition: util.c:1407
void printRegexMatch(int n, int cached)
CDB – Need to review this code, particularly for the use of an external file (Nomos.strings.txt). Despite the fact that variable is named debugStr, the file appears to be used for more than just debugging.
Definition: util.c:998
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:1094
char * copyString(char *s, char *label)
Create a copy of a string.
Definition: util.c:605
char * pathBasename(char *path)
Get the basename from a file path.
Definition: util.c:627
int isSYMLINK(char *spath)
Check if given path is a symbolic link.
Definition: util.c:140
int isDIR(char *dpath)
Check if given path is a directory.
Definition: util.c:62
int mySystem(const char *fmt,...)
Run a system command.
Definition: util.c:1315
void renameInode(char *oldpath, char *newpath)
Rename an inode at oldpath to newpath.
Definition: util.c:421
int isBLOCK(char *bpath)
Check if given path is a Block device.
Definition: util.c:95
char * findEol(char *s)
Find first ROL in a string.
Definition: util.c:390
int isPIPE(char *ppath)
Check if given path is a pipe.
Definition: util.c:125
int isINODE(char *ipath, int typ)
Check for a inode against a flag.
Definition: util.c:155
void munmapFile(void *ptr)
Definition: util.c:1209
void appendFile(char *pathname, char *str)
Append a string at the end of the file.
Definition: util.c:1295
char * findBol(char *s, char *upperLimit)
Find Begin of Line in a string.
Definition: util.c:352
void makeSymlink(char *path)
Create symbolic links for a given path in current directory.
Definition: util.c:972
FILE * fopenFile(char *pathname, char *mode)
Open a file and return the file pointer.
Definition: util.c:488
FILE * popenProc(char *command, char *mode)
Open a process pipe using popen()
Definition: util.c:533
Fatal($msg, $filenm, $lineno)
Write message to stdout and die.
Definition: common-ui.php:75
char * newReloTarget(char *basename)
Check if a relocation target is accessible.
Definition: util.c:187