File: version_comparison.h

package info (click to toggle)
cfengine3 3.24.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 37,552 kB
  • sloc: ansic: 163,161; sh: 10,296; python: 2,950; makefile: 1,744; lex: 784; yacc: 633; perl: 211; pascal: 157; xml: 21; sed: 13
file content (37 lines) | stat: -rw-r--r-- 946 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#ifndef CF_VERSION_COMPARISON_H
#define CF_VERSION_COMPARISON_H

#include <stdbool.h> // bool

typedef enum VersionComparison
{
    VERSION_SMALLER,
    VERSION_EQUAL,
    VERSION_GREATER,
    VERSION_ERROR,
} VersionComparison;

typedef enum BooleanOrError
{
    BOOLEAN_ERROR = -1,
    BOOLEAN_FALSE = false,
    BOOLEAN_TRUE = true,
} BooleanOrError;

VersionComparison CompareVersion(const char *a, const char *b);

/**
  @brief Compare 2 version numbers using an operator.
  @note This function is just a wrapper around CompareVersion().
  @see CompareVersion()
  @param [in] a The first version number of the expression.
  @param [in] operator One of: [">", "<", "=", "==", "!=", ">=", "<="].
  @param [in] b The second version number of the expression.
  @return true or false or -1 (invalid operator or version numbers).
*/
BooleanOrError CompareVersionExpression(
    const char *a,
    const char *operator,
    const char *b);

#endif