]>
Commit | Line | Data |
---|---|---|
07800601 IM |
1 | #ifndef CACHE_H |
2 | #define CACHE_H | |
3 | ||
4 | #include "util.h" | |
5 | #include "strbuf.h" | |
f37a291c | 6 | #include "../perf.h" |
07800601 IM |
7 | |
8 | #define PERF_DIR_ENVIRONMENT "PERF_DIR" | |
9 | #define PERF_WORK_TREE_ENVIRONMENT "PERF_WORK_TREE" | |
10 | #define DEFAULT_PERF_DIR_ENVIRONMENT ".perf" | |
11 | #define DB_ENVIRONMENT "PERF_OBJECT_DIRECTORY" | |
12 | #define INDEX_ENVIRONMENT "PERF_INDEX_FILE" | |
13 | #define GRAFT_ENVIRONMENT "PERF_GRAFT_FILE" | |
14 | #define TEMPLATE_DIR_ENVIRONMENT "PERF_TEMPLATE_DIR" | |
15 | #define CONFIG_ENVIRONMENT "PERF_CONFIG" | |
16 | #define EXEC_PATH_ENVIRONMENT "PERF_EXEC_PATH" | |
17 | #define CEILING_DIRECTORIES_ENVIRONMENT "PERF_CEILING_DIRECTORIES" | |
18 | #define PERFATTRIBUTES_FILE ".perfattributes" | |
19 | #define INFOATTRIBUTES_FILE "info/attributes" | |
20 | #define ATTRIBUTE_MACRO_PREFIX "[attr]" | |
21 | ||
22 | typedef int (*config_fn_t)(const char *, const char *, void *); | |
23 | extern int perf_default_config(const char *, const char *, void *); | |
24 | extern int perf_config_from_file(config_fn_t fn, const char *, void *); | |
25 | extern int perf_config(config_fn_t fn, void *); | |
26 | extern int perf_parse_ulong(const char *, unsigned long *); | |
27 | extern int perf_config_int(const char *, const char *); | |
28 | extern unsigned long perf_config_ulong(const char *, const char *); | |
29 | extern int perf_config_bool_or_int(const char *, const char *, int *); | |
30 | extern int perf_config_bool(const char *, const char *); | |
31 | extern int perf_config_string(const char **, const char *, const char *); | |
32 | extern int perf_config_set(const char *, const char *); | |
33 | extern int perf_config_set_multivar(const char *, const char *, const char *, int); | |
34 | extern int perf_config_rename_section(const char *, const char *); | |
35 | extern const char *perf_etc_perfconfig(void); | |
36 | extern int check_repository_format_version(const char *var, const char *value, void *cb); | |
37 | extern int perf_config_system(void); | |
38 | extern int perf_config_global(void); | |
39 | extern int config_error_nonbool(const char *); | |
40 | extern const char *config_exclusive_filename; | |
41 | ||
42 | #define MAX_PERFNAME (1000) | |
43 | extern char perf_default_email[MAX_PERFNAME]; | |
44 | extern char perf_default_name[MAX_PERFNAME]; | |
45 | extern int user_ident_explicitly_given; | |
46 | ||
47 | extern const char *perf_log_output_encoding; | |
48 | extern const char *perf_mailmap_file; | |
49 | ||
50 | /* IO helper functions */ | |
51 | extern void maybe_flush_or_die(FILE *, const char *); | |
52 | extern int copy_fd(int ifd, int ofd); | |
53 | extern int copy_file(const char *dst, const char *src, int mode); | |
54 | extern ssize_t read_in_full(int fd, void *buf, size_t count); | |
55 | extern ssize_t write_in_full(int fd, const void *buf, size_t count); | |
56 | extern void write_or_die(int fd, const void *buf, size_t count); | |
57 | extern int write_or_whine(int fd, const void *buf, size_t count, const char *msg); | |
58 | extern int write_or_whine_pipe(int fd, const void *buf, size_t count, const char *msg); | |
59 | extern void fsync_or_die(int fd, const char *); | |
60 | ||
61 | /* pager.c */ | |
62 | extern void setup_pager(void); | |
63 | extern const char *pager_program; | |
64 | extern int pager_in_use(void); | |
65 | extern int pager_use_color; | |
66 | ||
67 | extern const char *editor_program; | |
68 | extern const char *excludes_file; | |
69 | ||
70 | char *alias_lookup(const char *alias); | |
71 | int split_cmdline(char *cmdline, const char ***argv); | |
72 | ||
73 | #define alloc_nr(x) (((x)+16)*3/2) | |
74 | ||
75 | /* | |
76 | * Realloc the buffer pointed at by variable 'x' so that it can hold | |
77 | * at least 'nr' entries; the number of entries currently allocated | |
78 | * is 'alloc', using the standard growing factor alloc_nr() macro. | |
79 | * | |
80 | * DO NOT USE any expression with side-effect for 'x' or 'alloc'. | |
81 | */ | |
82 | #define ALLOC_GROW(x, nr, alloc) \ | |
83 | do { \ | |
84 | if ((nr) > alloc) { \ | |
85 | if (alloc_nr(alloc) < (nr)) \ | |
86 | alloc = (nr); \ | |
87 | else \ | |
88 | alloc = alloc_nr(alloc); \ | |
89 | x = xrealloc((x), alloc * sizeof(*(x))); \ | |
90 | } \ | |
91 | } while(0) | |
92 | ||
93 | ||
94 | static inline int is_absolute_path(const char *path) | |
95 | { | |
96 | return path[0] == '/'; | |
97 | } | |
6f06ccbc IM |
98 | |
99 | const char *make_absolute_path(const char *path); | |
100 | const char *make_nonrelative_path(const char *path); | |
101 | const char *make_relative_path(const char *abs, const char *base); | |
102 | int normalize_path_copy(char *dst, const char *src); | |
103 | int longest_ancestor_length(const char *path, const char *prefix_list); | |
104 | char *strip_path_suffix(const char *path, const char *suffix); | |
105 | ||
106 | extern char *mkpath(const char *fmt, ...) __attribute__((format (printf, 1, 2))); | |
107 | extern char *perf_path(const char *fmt, ...) __attribute__((format (printf, 1, 2))); | |
16f762a2 IM |
108 | /* perf_mkstemp() - create tmp file honoring TMPDIR variable */ |
109 | extern int perf_mkstemp(char *path, size_t len, const char *template); | |
6f06ccbc IM |
110 | |
111 | extern char *mksnpath(char *buf, size_t n, const char *fmt, ...) | |
112 | __attribute__((format (printf, 3, 4))); | |
113 | extern char *perf_snpath(char *buf, size_t n, const char *fmt, ...) | |
114 | __attribute__((format (printf, 3, 4))); | |
115 | extern char *perf_pathdup(const char *fmt, ...) | |
116 | __attribute__((format (printf, 1, 2))); | |
117 | ||
118 | extern size_t strlcpy(char *dest, const char *src, size_t size); | |
119 | ||
07800601 | 120 | #endif /* CACHE_H */ |