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