/ lib / info.c
info.c
 1  /*
 2   * SPDX-FileCopyrightText: Le'Sec collective
 3   *
 4   * SPDX-License-Identifier: LGPL-3.0-or-later
 5   */
 6  
 7  #include <lesec/info.h>
 8  
 9  #define str(x) #x
10  #define str2(x) str(x)
11  
12  #define nelems(a) (sizeof(a) / sizeof(a[0]))
13  
14  static char *data[] = {
15    str2(LESEC_MAJOR_VERSION),    /* [0] */
16    str2(LESEC_MINOR_VERSION),    /* [1] */
17    str2(LESEC_PATCH_VERSION),    /* [2] */
18  };
19  
20  LESEC_EXPORT LE_STATUS LeSec_info(int index, const char **info)
21  {
22    if (index < 0 || index >= nelems(data))
23      return LE_STS_ERROR;
24    *info = data[index];
25    return LE_STS_SUCCESS;
26  }