~ubuntu-branches/ubuntu/maverick/libvirt/maverick-proposed

« back to all changes in this revision

Viewing changes to src/util/util.h

  • Committer: Bazaar Package Importer
  • Author(s): Guido Günther
  • Date: 2010-04-19 18:11:57 UTC
  • mfrom: (0.2.6 upstream) (3.8.3 sid)
  • mto: This revision was merged to the branch mainline in revision 92.
  • Revision ID: james.westby@ubuntu.com-20100419181157-p8x7wvat9ovlae6m
Tags: 0.8.0-2
* [70fbcb6] New patch 0007-nwfilter-Don-t-crash-if-driverState- NULL.patch
  nwfilter: Don't crash if driverState == NULL (Closes: #577728)
* [d7d1abd] New patch 0008-Ignore-empty-type-statement-in-disk-
  element.patch Ignore empty type statement in disk element
  (Closes: #578347)

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 */
24
24
 
25
25
#ifndef __VIR_UTIL_H__
26
 
#define __VIR_UTIL_H__
 
26
# define __VIR_UTIL_H__
27
27
 
28
 
#include "verify.h"
29
 
#include "internal.h"
30
 
#include <unistd.h>
31
 
#include <sys/select.h>
32
 
#include <sys/types.h>
 
28
# include "verify.h"
 
29
# include "internal.h"
 
30
# include <unistd.h>
 
31
# include <sys/select.h>
 
32
# include <sys/types.h>
33
33
 
34
34
int saferead(int fd, void *buf, size_t count);
35
35
ssize_t safewrite(int fd, const void *buf, size_t count);
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);
85
87
 
86
88
int virFileReadLimFD(int fd, int maxlen, char **buf) ATTRIBUTE_RETURN_CHECK;
187
189
 
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))
196
199
 
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
200
203
 
201
204
int virParseMacAddr(const char* str,
202
205
                    unsigned char *addr) ATTRIBUTE_RETURN_CHECK;
216
219
                            unsigned int ntypes,
217
220
                            int type);
218
221
 
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) {                        \
230
233
                                 type);                                 \
231
234
    }
232
235
 
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);
236
239
 
237
 
#ifndef HAVE_GETUID
 
240
# ifndef HAVE_GETUID
238
241
static inline int getuid (void) { return 0; }
239
 
#endif
 
242
# endif
240
243
 
241
 
#ifndef HAVE_GETGID
 
244
# ifndef HAVE_GETGID
242
245
static inline int getgid (void) { return 0; }
243
 
#endif
 
246
# endif
244
247
 
245
248
char *virGetHostnameLocalhost(int allow_localhost);
246
249
char *virGetHostname(virConnectPtr conn);
247
250
 
248
251
int virKillProcess(pid_t pid, int sig);
249
252
 
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;
257
 
#endif
258
259
 
259
260
int virRandomInitialize(unsigned int seed) ATTRIBUTE_RETURN_CHECK;
260
261
int virRandom(int max);
261
262
 
262
 
#ifdef HAVE_MNTENT_H
263
263
char *virFileFindMountPoint(const char *type);
264
 
#endif
265
264
 
266
265
void virFileWaitForDevices(void);
267
266
 
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;
270
269
 
271
270
#endif /* __VIR_UTIL_H__ */