MCPcopy Create free account
hub / github.com/ElementsProject/lightning / version_to_number

Function version_to_number

common/deprecation.c:10–42  ·  view source on GitHub ↗

Returns 1 + patchnumber + 10*minor + 120*major. 0 on malformed */

Source from the content-addressed store, hash-verified

8
9/* Returns 1 + patchnumber + 10*minor + 120*major. 0 on malformed */
10u32 version_to_number(const char *version)
11{
12 char *yend, *mend;
13 long year, month, patchlevel;
14
15 if (version[0] != 'v')
16 return 0;
17
18 year = strtol(version + 1, &yend, 10);
19 if (yend == version + 1 || *yend != '.')
20 return 0;
21 if (year > 99)
22 return 0;
23
24 month = strtol(yend + 1, &mend, 10);
25 if (mend == yend + 1)
26 return 0;
27
28 if (month < 1 || month > 12)
29 return 0;
30
31 if (*mend == '.') {
32 char *endp;
33 patchlevel = strtol(mend + 1, &endp, 10);
34 if (endp == mend + 1)
35 return 0;
36 if (patchlevel >= MONTH_VAL)
37 return 0;
38 } else
39 patchlevel = 0;
40
41 return 1 + year*YEAR_VAL + month*MONTH_VAL + patchlevel;
42}
43
44enum deprecation_level {
45 /* Will be deprecated in future */

Callers 4

json_parse_deprecatedFunction · 0.85
deprecationFunction · 0.85
mainFunction · 0.85
add_deprecatedFunction · 0.85

Calls

no outgoing calls

Tested by 1

mainFunction · 0.68