81
81
int virRunWithHook(const char *const*argv,
82
82
virExecHook hook, void *data,
83
83
int *status) ATTRIBUTE_RETURN_CHECK;
84
int virPipeReadUntilEOF(int outfd, int errfd,
85
char **outbuf, char **errbuf);
84
86
int virFork(pid_t *pid);
86
88
int virFileReadLimFD(int fd, int maxlen, char **buf) ATTRIBUTE_RETURN_CHECK;
188
190
void virSkipSpaces(const char **str);
189
191
int virParseNumber(const char **str);
192
int virParseVersionString(const char *str, unsigned long *version);
190
193
int virAsprintf(char **strp, const char *fmt, ...) ATTRIBUTE_FMT_PRINTF(2, 3);
191
194
char *virStrncpy(char *dest, const char *src, size_t n, size_t destbytes)
192
195
ATTRIBUTE_RETURN_CHECK;
193
196
char *virStrcpy(char *dest, const char *src, size_t destbytes)
194
197
ATTRIBUTE_RETURN_CHECK;
195
#define virStrcpyStatic(dest, src) virStrcpy((dest), (src), sizeof(dest))
198
# define virStrcpyStatic(dest, src) virStrcpy((dest), (src), sizeof(dest))
197
#define VIR_MAC_BUFLEN 6
198
#define VIR_MAC_PREFIX_BUFLEN 3
199
#define VIR_MAC_STRING_BUFLEN VIR_MAC_BUFLEN * 3
200
# define VIR_MAC_BUFLEN 6
201
# define VIR_MAC_PREFIX_BUFLEN 3
202
# define VIR_MAC_STRING_BUFLEN VIR_MAC_BUFLEN * 3
201
204
int virParseMacAddr(const char* str,
202
205
unsigned char *addr) ATTRIBUTE_RETURN_CHECK;
216
219
unsigned int ntypes,
219
#define VIR_ENUM_IMPL(name, lastVal, ...) \
222
# define VIR_ENUM_IMPL(name, lastVal, ...) \
220
223
static const char *const name ## TypeList[] = { __VA_ARGS__ }; \
221
224
extern int (* name ## Verify (void)) [verify_true (ARRAY_CARDINALITY(name ## TypeList) == lastVal)]; \
222
225
const char *name ## TypeToString(int type) { \
233
#define VIR_ENUM_DECL(name) \
236
# define VIR_ENUM_DECL(name) \
234
237
const char *name ## TypeToString(int type); \
235
238
int name ## TypeFromString(const char*type);
238
241
static inline int getuid (void) { return 0; }
242
245
static inline int getgid (void) { return 0; }
245
248
char *virGetHostnameLocalhost(int allow_localhost);
246
249
char *virGetHostname(virConnectPtr conn);
248
251
int virKillProcess(pid_t pid, int sig);
250
#ifdef HAVE_GETPWUID_R
251
253
char *virGetUserDirectory(uid_t uid);
252
254
char *virGetUserName(uid_t uid);
253
255
int virGetUserID(const char *name,
254
256
uid_t *uid) ATTRIBUTE_RETURN_CHECK;
255
257
int virGetGroupID(const char *name,
256
258
gid_t *gid) ATTRIBUTE_RETURN_CHECK;
259
260
int virRandomInitialize(unsigned int seed) ATTRIBUTE_RETURN_CHECK;
260
261
int virRandom(int max);
263
263
char *virFileFindMountPoint(const char *type);
266
265
void virFileWaitForDevices(void);
268
#define virBuildPath(path, ...) virBuildPathInternal(path, __VA_ARGS__, NULL)
267
# define virBuildPath(path, ...) virBuildPathInternal(path, __VA_ARGS__, NULL)
269
268
int virBuildPathInternal(char **path, ...) ATTRIBUTE_SENTINEL;
271
270
#endif /* __VIR_UTIL_H__ */