cfengine  3.15.4
About: CFEngine is a configuration management system for configuring and maintaining Unix-like computers (using an own high level policy language). Community version.
  Fossies Dox: cfengine-3.15.4.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

feature.c
Go to the documentation of this file.
1 #include <syntax.h>
2 #include <string.h>
3 #include <cfnet.h>
4 #include <sysinfo.h>
5 #include <buffer.h>
6 
7 static const char* features[] = {
8 #ifdef HAVE_LIBYAML
9  "yaml",
10 #endif
11 #ifdef HAVE_LIBXML2
12  "xml",
13 #endif
14 #ifdef HAVE_LIBCURL
15  "curl",
16 #endif
17  "tls_1_0", /* we require versions of OpenSSL that support
18  * at least TLS 1.0 */
19 #ifdef HAVE_TLS_1_1
20  "tls_1_1",
21 #endif
22 #ifdef HAVE_TLS_1_2
23  "tls_1_2",
24 #endif
25 #ifdef HAVE_TLS_1_3
26  "tls_1_3",
27 #endif
28  "def_json_preparse",
29  NULL
30 };
31 
32 int KnownFeature(const char *feature)
33 {
34  // dumb algorithm, but still effective for a small number of features
35  for(int i=0 ; features[i]!=NULL ; i++) {
36  int r = strcmp(feature, features[i]);
37  if(r==0) {
38  return 1;
39  }
40  }
41  return 0;
42 }
43 
45 {
46  Buffer *buffer = BufferNew();
47 
48  for(int i=0 ; features[i]!=NULL ; i++) {
49  BufferPrintf(buffer, "feature_%s", features[i]);
51  }
52  BufferDestroy(buffer);
53 }
void BufferDestroy(Buffer *buffer)
Destroys a buffer and frees the memory associated with it.
Definition: buffer.c:72
Buffer * BufferNew(void)
Buffer initialization routine.
Definition: buffer.c:48
const char * BufferData(const Buffer *buffer)
Provides a pointer to the internal data.
Definition: buffer.c:470
int BufferPrintf(Buffer *buffer, const char *format,...)
Stores complex data on the buffer.
Definition: buffer.c:348
void CreateHardClassesFromFeatures(EvalContext *ctx, char *tags)
Definition: feature.c:44
static const char * features[]
Definition: feature.c:7
int KnownFeature(const char *feature)
Definition: feature.c:32
#define NULL
Definition: getopt1.c:56
Definition: buffer.h:50
void CreateHardClassesFromCanonification(EvalContext *ctx, const char *canonified, char *tags)
Definition: sysinfo.c:1041