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