MCPcopy Create free account
hub / github.com/apache/httpd / compare_version

Function compare_version

modules/metadata/mod_version.c:76–137  ·  view source on GitHub ↗

* compare the supplied version with the core one */

Source from the content-addressed store, hash-verified

74 * compare the supplied version with the core one
75 */
76static int compare_version(char *version_string, const char **error)
77{
78 char *p = version_string, *ep;
79 int version[3] = {0, 0, 0};
80 int c = 0;
81
82 *error = "Version appears to be invalid. It must have the format "
83 "major[.minor[.patch]] where major, minor and patch are "
84 "numbers.";
85
86 if (!apr_isdigit(*p)) {
87 return 0;
88 }
89
90 /* parse supplied version */
91 ep = version_string + strlen(version_string);
92 while (p <= ep && c < 3) {
93 if (*p == '.') {
94 *p = '\0';
95 }
96
97 if (!*p) {
98 version[c++] = atoi(version_string);
99 version_string = ++p;
100 continue;
101 }
102
103 if (!apr_isdigit(*p)) {
104 break;
105 }
106
107 ++p;
108 }
109
110 if (p < ep) { /* syntax error */
111 return 0;
112 }
113
114 *error = NULL;
115
116 if (httpd_version.major > version[0]) {
117 return 1;
118 }
119 else if (httpd_version.major < version[0]) {
120 return -1;
121 }
122 else if (httpd_version.minor > version[1]) {
123 return 1;
124 }
125 else if (httpd_version.minor < version[1]) {
126 return -1;
127 }
128 else if (httpd_version.patch > version[2]) {
129 return 1;
130 }
131 else if (httpd_version.patch < version[2]) {
132 return -1;
133 }

Callers 1

start_ifversionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected