diff options
Diffstat (limited to 'src/version.c')
-rw-r--r-- | src/version.c | 100 |
1 files changed, 50 insertions, 50 deletions
diff --git a/src/version.c b/src/version.c index e769e31..4b3a535 100644 --- a/src/version.c +++ b/src/version.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* grecs - Gray's Extensible Configuration System | 1 | /* argot - Gray's Extensible Configuration System |
2 | Copyright (C) 2007-2016 Sergey Poznyakoff | 2 | Copyright (C) 2007-2016 Sergey Poznyakoff |
3 | 3 | ||
4 | Grecs is free software; you can redistribute it and/or modify it | 4 | Grecs is free software; you can redistribute it and/or modify it |
@@ -17,22 +17,22 @@ | |||
17 | #ifdef HAVE_CONFIG_H | 17 | #ifdef HAVE_CONFIG_H |
18 | # include <config.h> | 18 | # include <config.h> |
19 | #endif | 19 | #endif |
20 | #include <grecs.h> | 20 | #include <argot.h> |
21 | #include <string.h> | 21 | #include <string.h> |
22 | #include <ctype.h> | 22 | #include <ctype.h> |
23 | #include <stdlib.h> | 23 | #include <stdlib.h> |
24 | #include "gitid.h" | 24 | #include "gitid.h" |
25 | 25 | ||
26 | const char *grecs_vcs_id = "$Id: " GRECS_GIT_ID " $"; | 26 | const char *argot_vcs_id = "$Id: " ARGOT_GIT_ID " $"; |
27 | 27 | ||
28 | struct grecs_version_info * | 28 | struct argot_version_info * |
29 | grecs_version_split(const char *vstr) | 29 | argot_version_split(const char *vstr) |
30 | { | 30 | { |
31 | char *p; | 31 | char *p; |
32 | size_t len; | 32 | size_t len; |
33 | struct grecs_version_info *pv = grecs_zalloc(sizeof(*pv)); | 33 | struct argot_version_info *pv = argot_zalloc(sizeof(*pv)); |
34 | 34 | ||
35 | pv->buffer = grecs_strdup(vstr); | 35 | pv->buffer = argot_strdup(vstr); |
36 | len = strcspn(pv->buffer, " \t"); | 36 | len = strcspn(pv->buffer, " \t"); |
37 | if (pv->buffer[len]) { | 37 | if (pv->buffer[len]) { |
38 | pv->package = pv->buffer; | 38 | pv->package = pv->buffer; |
@@ -67,62 +67,62 @@ grecs_version_split(const char *vstr) | |||
67 | } | 67 | } |
68 | 68 | ||
69 | void | 69 | void |
70 | grecs_version_info_free(struct grecs_version_info *pv) | 70 | argot_version_info_free(struct argot_version_info *pv) |
71 | { | 71 | { |
72 | if (pv) { | 72 | if (pv) { |
73 | if (pv->buffer) | 73 | if (pv->buffer) |
74 | grecs_free(pv->buffer); | 74 | argot_free(pv->buffer); |
75 | free(pv); | 75 | free(pv); |
76 | } | 76 | } |
77 | } | 77 | } |
78 | 78 | ||
79 | struct grecs_version_info * | 79 | struct argot_version_info * |
80 | grecs_version(void) | 80 | argot_version(void) |
81 | { | 81 | { |
82 | struct grecs_version_info *pv = grecs_zalloc(sizeof(*pv)); | 82 | struct argot_version_info *pv = argot_zalloc(sizeof(*pv)); |
83 | size_t size = 0; | 83 | size_t size = 0; |
84 | 84 | ||
85 | pv->package = PACKAGE_NAME; | 85 | pv->package = PACKAGE_NAME; |
86 | #ifdef GRECS_VERSION_PATCHLEVEL | 86 | #ifdef ARGOT_VERSION_PATCHLEVEL |
87 | # ifdef GRECS_VERSION_SUFFIX | 87 | # ifdef ARGOT_VERSION_SUFFIX |
88 | grecs_asprintf(&pv->buffer, &size, | 88 | argot_asprintf(&pv->buffer, &size, |
89 | "%d.%d.%d%s", | 89 | "%d.%d.%d%s", |
90 | GRECS_VERSION_MAJOR, GRECS_VERSION_MINOR, | 90 | ARGOT_VERSION_MAJOR, ARGOT_VERSION_MINOR, |
91 | GRECS_VERSION_PATCHLEVEL, GRECS_VERSION_SUFFIX); | 91 | ARGOT_VERSION_PATCHLEVEL, ARGOT_VERSION_SUFFIX); |
92 | # else | 92 | # else |
93 | grecs_asprintf(&pv->buffer, &size, | 93 | argot_asprintf(&pv->buffer, &size, |
94 | "%d.%d.%d", | 94 | "%d.%d.%d", |
95 | GRECS_VERSION_MAJOR, GRECS_VERSION_MINOR, | 95 | ARGOT_VERSION_MAJOR, ARGOT_VERSION_MINOR, |
96 | GRECS_VERSION_PATCHLEVEL); | 96 | ARGOT_VERSION_PATCHLEVEL); |
97 | # endif | 97 | # endif |
98 | #else | 98 | #else |
99 | # ifdef GRECS_VERSION_SUFFIX | 99 | # ifdef ARGOT_VERSION_SUFFIX |
100 | grecs_asprintf(&pv->buffer, &size, | 100 | argot_asprintf(&pv->buffer, &size, |
101 | "%d.%d%s", | 101 | "%d.%d%s", |
102 | GRECS_VERSION_MAJOR, GRECS_VERSION_MINOR, | 102 | ARGOT_VERSION_MAJOR, ARGOT_VERSION_MINOR, |
103 | GRECS_VERSION_SUFFIX); | 103 | ARGOT_VERSION_SUFFIX); |
104 | # else | 104 | # else |
105 | grecs_asprintf(&pv->buffer, &size, | 105 | argot_asprintf(&pv->buffer, &size, |
106 | "%d.%d", | 106 | "%d.%d", |
107 | GRECS_VERSION_MAJOR, GRECS_VERSION_MINOR); | 107 | ARGOT_VERSION_MAJOR, ARGOT_VERSION_MINOR); |
108 | # endif | 108 | # endif |
109 | #endif | 109 | #endif |
110 | pv->version = pv->buffer; | 110 | pv->version = pv->buffer; |
111 | pv->major = GRECS_VERSION_MAJOR; | 111 | pv->major = ARGOT_VERSION_MAJOR; |
112 | pv->minor = GRECS_VERSION_MINOR; | 112 | pv->minor = ARGOT_VERSION_MINOR; |
113 | #ifdef GRECS_VERSION_PATCHLEVEL | 113 | #ifdef ARGOT_VERSION_PATCHLEVEL |
114 | pv->patch = GRECS_VERSION_PATCHLEVEL; | 114 | pv->patch = ARGOT_VERSION_PATCHLEVEL; |
115 | #endif | 115 | #endif |
116 | #ifdef GRECS_VERSION_SUFFIX | 116 | #ifdef ARGOT_VERSION_SUFFIX |
117 | pv->suffix = GRECS_VERSION_SUFFIX; | 117 | pv->suffix = ARGOT_VERSION_SUFFIX; |
118 | #endif | 118 | #endif |
119 | pv->id = GRECS_GIT_ID; | 119 | pv->id = ARGOT_GIT_ID; |
120 | return pv; | 120 | return pv; |
121 | } | 121 | } |
122 | 122 | ||
123 | int | 123 | int |
124 | grecs_version_info_cmp(struct grecs_version_info *vx, | 124 | argot_version_info_cmp(struct argot_version_info *vx, |
125 | struct grecs_version_info *vy, | 125 | struct argot_version_info *vy, |
126 | int *pres) | 126 | int *pres) |
127 | { | 127 | { |
128 | if (vx->package && vy->package && strcmp(vx->package, vy->package)) | 128 | if (vx->package && vy->package && strcmp(vx->package, vy->package)) |
@@ -147,43 +147,43 @@ grecs_version_info_cmp(struct grecs_version_info *vx, | |||
147 | } | 147 | } |
148 | 148 | ||
149 | int | 149 | int |
150 | grecs_version_cmp(const char *vstr1, const char *vstr2, int *pres) | 150 | argot_version_cmp(const char *vstr1, const char *vstr2, int *pres) |
151 | { | 151 | { |
152 | struct grecs_version_info *v1, *v2; | 152 | struct argot_version_info *v1, *v2; |
153 | int rc; | 153 | int rc; |
154 | 154 | ||
155 | if (!vstr1 || !vstr2) | 155 | if (!vstr1 || !vstr2) |
156 | return -1; | 156 | return -1; |
157 | v1 = grecs_version_split(vstr1); | 157 | v1 = argot_version_split(vstr1); |
158 | if (!v1) | 158 | if (!v1) |
159 | return -1; | 159 | return -1; |
160 | v2 = grecs_version_split(vstr2); | 160 | v2 = argot_version_split(vstr2); |
161 | if (!v2) { | 161 | if (!v2) { |
162 | grecs_version_info_free(v1); | 162 | argot_version_info_free(v1); |
163 | return -1; | 163 | return -1; |
164 | } | 164 | } |
165 | rc = grecs_version_info_cmp(v1, v2, pres); | 165 | rc = argot_version_info_cmp(v1, v2, pres); |
166 | grecs_version_info_free(v1); | 166 | argot_version_info_free(v1); |
167 | grecs_version_info_free(v2); | 167 | argot_version_info_free(v2); |
168 | return rc; | 168 | return rc; |
169 | } | 169 | } |
170 | 170 | ||
171 | int | 171 | int |
172 | grecs_version_ok(const char *vstr) | 172 | argot_version_ok(const char *vstr) |
173 | { | 173 | { |
174 | struct grecs_version_info *vmy, *vreq; | 174 | struct argot_version_info *vmy, *vreq; |
175 | int rc, res; | 175 | int rc, res; |
176 | 176 | ||
177 | if (!vstr) | 177 | if (!vstr) |
178 | return -1; | 178 | return -1; |
179 | vreq = grecs_version_split(vstr); | 179 | vreq = argot_version_split(vstr); |
180 | if (!vreq) | 180 | if (!vreq) |
181 | return -1; | 181 | return -1; |
182 | vmy = grecs_version(); | 182 | vmy = argot_version(); |
183 | if (vreq->suffix && !vmy->suffix) | 183 | if (vreq->suffix && !vmy->suffix) |
184 | vmy->suffix = ""; | 184 | vmy->suffix = ""; |
185 | rc = grecs_version_info_cmp(vmy, vreq, &res); | 185 | rc = argot_version_info_cmp(vmy, vreq, &res); |
186 | grecs_version_info_free(vmy); | 186 | argot_version_info_free(vmy); |
187 | grecs_version_info_free(vreq); | 187 | argot_version_info_free(vreq); |
188 | return rc == 0 && res >= 0; | 188 | return rc == 0 && res >= 0; |
189 | } | 189 | } |