File: feature.c

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 (55 lines) | stat: -rw-r--r-- 1,204 bytes parent folder | download | duplicates (3)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <syntax.h>
#include <string.h>
#include <cfnet.h>
#include <sysinfo.h>
#include <buffer.h>

static const char* features[] = {
#ifdef HAVE_LIBYAML
    "yaml",
#endif
#ifdef HAVE_LIBXML2
    "xml",
#endif
#ifdef HAVE_LIBCURL
    "curl",
#endif
    "tls_1_0",                  /* we require versions of OpenSSL that support
                                 * at least TLS 1.0 */
#ifdef HAVE_TLS_1_1
    "tls_1_1",
#endif
#ifdef HAVE_TLS_1_2
    "tls_1_2",
#endif
#ifdef HAVE_TLS_1_3
    "tls_1_3",
#endif
    "def_json_preparse",
    "host_specific_data_load",
    "copyfrom_restrict_keys",
    NULL
};

int KnownFeature(const char *feature)
{
    // dumb algorithm, but still effective for a small number of features
    for(int i=0 ; features[i]!=NULL ; i++) {
        int r = strcmp(feature, features[i]);
        if(r==0) {
            return 1;
        }
    }
    return 0;
}

void CreateHardClassesFromFeatures(EvalContext *ctx, char *tags)
{
    Buffer *buffer = BufferNew();

    for(int i=0 ; features[i]!=NULL ; i++) {
        BufferPrintf(buffer, "feature_%s", features[i]);
        CreateHardClassesFromCanonification(ctx, BufferData(buffer), tags);
    }
    BufferDestroy(buffer);
}