diff options
author | 2007-05-09 05:40:59 (JST) | |
---|---|---|
committer | 2007-05-09 06:38:49 (JST) | |
commit | 61c3ca978c586c673aec618cb94210657278dda8 (patch) | |
tree | 7011987769e65ad0e7aa8b79f648357e9cd88c30 /git.h | |
parent | 66cacd053ba900c8eb3b7962027370c84a97f990 (diff) | |
download | cgit-61c3ca978c586c673aec618cb94210657278dda8.zip cgit-61c3ca978c586c673aec618cb94210657278dda8.tar.gz |
Update to libgit 1.5.2-rc2
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (limited to 'git.h')
-rw-r--r-- | git.h | 699 |
1 files changed, 0 insertions, 699 deletions
@@ -1,699 +0,0 @@ | |||
1 | #ifndef GIT_H | ||
2 | #define GIT_H | ||
3 | |||
4 | |||
5 | /* | ||
6 | * from git:git-compat-util.h | ||
7 | */ | ||
8 | |||
9 | |||
10 | #ifndef FLEX_ARRAY | ||
11 | #if defined(__GNUC__) && (__GNUC__ < 3) | ||
12 | #define FLEX_ARRAY 0 | ||
13 | #else | ||
14 | #define FLEX_ARRAY /* empty */ | ||
15 | #endif | ||
16 | #endif | ||
17 | |||
18 | |||
19 | #include <unistd.h> | ||
20 | #include <stdio.h> | ||
21 | #include <sys/stat.h> | ||
22 | #include <fcntl.h> | ||
23 | #include <stddef.h> | ||
24 | #include <stdlib.h> | ||
25 | #include <stdarg.h> | ||
26 | #include <string.h> | ||
27 | #include <errno.h> | ||
28 | #include <limits.h> | ||
29 | #include <sys/param.h> | ||
30 | #include <netinet/in.h> | ||
31 | #include <sys/types.h> | ||
32 | #include <dirent.h> | ||
33 | #include <time.h> | ||
34 | #include <regex.h> | ||
35 | |||
36 | /* On most systems <limits.h> would have given us this, but | ||
37 | * not on some systems (e.g. GNU/Hurd). | ||
38 | */ | ||
39 | #ifndef PATH_MAX | ||
40 | #define PATH_MAX 4096 | ||
41 | #endif | ||
42 | |||
43 | #ifdef __GNUC__ | ||
44 | #define NORETURN __attribute__((__noreturn__)) | ||
45 | #else | ||
46 | #define NORETURN | ||
47 | #ifndef __attribute__ | ||
48 | #define __attribute__(x) | ||
49 | #endif | ||
50 | #endif | ||
51 | |||
52 | |||
53 | extern void die(const char *err, ...) NORETURN __attribute__((format (printf, 1, 2))); | ||
54 | |||
55 | |||
56 | static inline char* xstrdup(const char *str) | ||
57 | { | ||
58 | char *ret = strdup(str); | ||
59 | if (!ret) | ||
60 | die("Out of memory, strdup failed"); | ||
61 | return ret; | ||
62 | } | ||
63 | |||
64 | static inline void *xmalloc(size_t size) | ||
65 | { | ||
66 | void *ret = malloc(size); | ||
67 | if (!ret && !size) | ||
68 | ret = malloc(1); | ||
69 | if (!ret) | ||
70 | die("Out of memory, malloc failed"); | ||
71 | #ifdef XMALLOC_POISON | ||
72 | memset(ret, 0xA5, size); | ||
73 | #endif | ||
74 | return ret; | ||
75 | } | ||
76 | |||
77 | static inline void *xrealloc(void *ptr, size_t size) | ||
78 | { | ||
79 | void *ret = realloc(ptr, size); | ||
80 | if (!ret && !size) | ||
81 | ret = realloc(ptr, 1); | ||
82 | if (!ret) | ||
83 | die("Out of memory, realloc failed"); | ||
84 | return ret; | ||
85 | } | ||
86 | |||
87 | static inline void *xcalloc(size_t nmemb, size_t size) | ||
88 | { | ||
89 | void *ret = calloc(nmemb, size); | ||
90 | if (!ret && (!nmemb || !size)) | ||
91 | ret = calloc(1, 1); | ||
92 | if (!ret) | ||
93 | die("Out of memory, calloc failed"); | ||
94 | return ret; | ||
95 | } | ||
96 | |||
97 | static inline ssize_t xread(int fd, void *buf, size_t len) | ||
98 | { | ||
99 | ssize_t nr; | ||
100 | while (1) { | ||
101 | nr = read(fd, buf, len); | ||
102 | if ((nr < 0) && (errno == EAGAIN || errno == EINTR)) | ||
103 | continue; | ||
104 | return nr; | ||
105 | } | ||
106 | } | ||
107 | |||
108 | static inline ssize_t xwrite(int fd, const void *buf, size_t len) | ||
109 | { | ||
110 | ssize_t nr; | ||
111 | while (1) { | ||
112 | nr = write(fd, buf, len); | ||
113 | if ((nr < 0) && (errno == EAGAIN || errno == EINTR)) | ||
114 | continue; | ||
115 | return nr; | ||
116 | } | ||
117 | } | ||
118 | |||
119 | |||
120 | |||
121 | |||
122 | /* | ||
123 | * from git:cache.h | ||
124 | */ | ||
125 | |||
126 | |||
127 | enum object_type { | ||
128 | OBJ_NONE = 0, | ||
129 | OBJ_COMMIT = 1, | ||
130 | OBJ_TREE = 2, | ||
131 | OBJ_BLOB = 3, | ||
132 | OBJ_TAG = 4, | ||
133 | /* 5 for future expansion */ | ||
134 | OBJ_OFS_DELTA = 6, | ||
135 | OBJ_REF_DELTA = 7, | ||
136 | OBJ_BAD, | ||
137 | }; | ||
138 | |||
139 | |||
140 | /* Convert to/from hex/sha1 representation */ | ||
141 | #define MINIMUM_ABBREV 4 | ||
142 | #define DEFAULT_ABBREV 7 | ||
143 | |||
144 | extern const unsigned char null_sha1[20]; | ||
145 | |||
146 | extern int sha1_object_info(const unsigned char *, char *, unsigned long *); | ||
147 | |||
148 | extern void * read_sha1_file(const unsigned char *sha1, char *type, unsigned long *size); | ||
149 | |||
150 | extern int get_sha1(const char *str, unsigned char *sha1); | ||
151 | extern int get_sha1_hex(const char *hex, unsigned char *sha1); | ||
152 | extern char *sha1_to_hex(const unsigned char *sha1); /* static buffer result! */ | ||
153 | |||
154 | static inline int is_null_sha1(const unsigned char *sha1) | ||
155 | { | ||
156 | return !memcmp(sha1, null_sha1, 20); | ||
157 | } | ||
158 | static inline int hashcmp(const unsigned char *sha1, const unsigned char *sha2) | ||
159 | { | ||
160 | return memcmp(sha1, sha2, 20); | ||
161 | } | ||
162 | static inline void hashcpy(unsigned char *sha_dst, const unsigned char *sha_src) | ||
163 | { | ||
164 | memcpy(sha_dst, sha_src, 20); | ||
165 | } | ||
166 | static inline void hashclr(unsigned char *hash) | ||
167 | { | ||
168 | memset(hash, 0, 20); | ||
169 | } | ||
170 | |||
171 | |||
172 | /* | ||
173 | * from git:grep.h | ||
174 | */ | ||
175 | |||
176 | enum grep_pat_token { | ||
177 | GREP_PATTERN, | ||
178 | GREP_PATTERN_HEAD, | ||
179 | GREP_PATTERN_BODY, | ||
180 | GREP_AND, | ||
181 | GREP_OPEN_PAREN, | ||
182 | GREP_CLOSE_PAREN, | ||
183 | GREP_NOT, | ||
184 | GREP_OR, | ||
185 | }; |