f481edbbc3504db7af470cf663628427fcc278da
[tools/librpm-tizen.git] / lib / misc.h
1 #ifndef H_MISC
2 #define H_MISC
3
4 /** \file lib/misc.h
5  *
6  */
7
8 #include <unistd.h>
9 #include <sys/types.h>
10
11 #include "header.h"
12 #include "ugid.h"
13
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17
18 /**
19  */
20 /*@only@*/ char ** splitString(const char * str, int length, char sep);
21
22 /**
23  */
24 void    freeSplitString( /*@only@*/ char ** list);
25
26 /**
27  * Remove occurences of trailing character from string.
28  * @param s             string
29  * @param c             character to strip
30  * @return              string
31  */
32 /*@unused@*/ static inline char * stripTrailingChar(char * s, char c)
33         /*@modifies *s */
34 {
35     char * t;
36     for (t = s + strlen(s) - 1; *t == c && t >= s; t--)
37         *t = '\0';
38     return s;
39 }
40
41 /**
42  */
43 int     rpmfileexists(const char * filespec)    /*@*/;
44
45 /**
46  */
47 int     rpmvercmp(const char * one, const char * two);
48
49 /* these are like the normal functions, but they malloc() the space which
50    is needed */
51
52 /**
53  */
54 int     dosetenv(const char *name, const char *value, int overwrite);
55
56 /**
57  */
58 int     doputenv(const char * str);
59
60 /**
61  */
62 int     makeTempFile(const char * prefix, /*@out@*/ const char ** fnptr,
63                         /*@out@*/ FD_t * fdptr);
64
65 /**
66  * @return              cureent working directory (malloc'ed)
67  */
68 /*@only@*/ char * currentDirectory(void);
69
70 /**
71  */
72 void    compressFilelist(Header h);
73
74 /**
75  */
76 void    expandFilelist(Header h);
77
78 /**
79  */
80 void    buildOrigFileList(Header h, /*@out@*/ const char *** fileListPtr, 
81                         /*@out@*/ int * fileCountPtr);
82
83 /**
84  */
85 int myGlobPatternP (const char *patternURL)     /*@*/;
86
87 /**
88  */
89 int rpmGlob(const char * patterns, /*@out@*/ int * argcPtr,
90         /*@out@*/ const char *** argvPtr)
91                 /*@modifies *argcPtr, *argvPtr @*/;
92
93 /**
94  */
95 void providePackageNVR(Header h);
96
97 #ifdef __cplusplus
98 }
99 #endif
100
101 #endif  /* H_MISC */