summaryrefslogtreecommitdiff
path: root/src/pg_common.h
blob: 52c2db293789adef397189db3b19299962c7dc5e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
 * Copyright (C) 2008 Mark Wong
 */

#ifndef _PG_COMMON_H_
#define _PG_COMMON_H_

#ifdef PG_MODULE_MAGIC
PG_MODULE_MAGIC;
#endif

#define BIGINT_LEN 20
#define FLOAT_LEN 20
#define INTEGER_LEN 10

#ifdef __linux__
#include <ctype.h>
#include <linux/magic.h>

#define PROCFS "/proc"

#define GET_NEXT_VALUE(p, q, value, length, msg, delim) \
        if ((q = strchr(p, delim)) == NULL) \
        { \
            elog(ERROR, msg); \
            return 0; \
        } \
        length = q - p; \
        strncpy(value, p, length); \
        value[length] = '\0'; \
        p = q + 1;

#define SKIP_TOKEN(p) \
		/* Skipping leading white space. */ \
		while (isspace(*p)) \
			p++; \
		/* Skip token. */ \
		while (*p && !isspace(*p)) \
			p++; \
		/* Skipping trailing white space. */ \
		while (isspace(*p)) \
			p++;
#endif /* __linux__ */

#endif /* _PG_COMMON_H_ */