/ src / setup / src / settings.c
settings.c
 1  /* FinnOS - Beowulf cluster linux distro.
 2   * If you find this software useful, please consider supporting future development.
 3   * Donate what you believe this software is worth at: https://SammTech.net/donate
 4   * Copyright (c) 2025 Samm and FinnOS Contributors.
 5   * Licensed under the GNU General Public License, version 2 (GPLv2).
 6   * See LICENSE.txt for details.
 7   */
 8  
 9  #include "settings.h"
10  #include <stdlib.h>
11  
12  int create_default_settings(SetupSettings* settings) {
13      if (settings == NULL) return -1;
14      settings->is_default_master_arch = 1;
15      settings->is_default_node_arch = 1;
16  
17      settings->master_archs = (CPUArch*)malloc(sizeof(CPUArch)*1);
18      if (settings->master_archs == NULL) return -2;
19      settings->master_archs[0] = X86_64;
20  
21      settings->master_arch_len = 1;
22  
23      settings->node_archs = (CPUArch*)malloc(sizeof(CPUArch)*5);
24      if (settings->node_archs == NULL) return -2;
25      settings->node_archs[0] = ARM64;
26      settings->node_archs[1] = X86_32;
27      settings->node_archs[2] = ARM32;
28      settings->node_archs[3] = RISCV64;
29      settings->node_archs[4] = X86_64;
30  
31      settings->node_arch_len = 5;
32  
33      settings->is_default_master_platform = 1;
34      settings->master_platforms = (PlatformArch*)malloc(sizeof(PlatformArch)*1);
35      settings->master_platform_len = 1;
36  
37      return 0;
38  }
39  
40  void destroy_settings(SetupSettings* settings) {
41      if (settings == NULL) return;
42  
43      free(settings->master_archs);
44      settings->master_archs = NULL;
45      free(settings->node_archs);
46      settings->node_archs = NULL;
47  
48      free(settings->master_platforms);
49      settings->master_platforms = NULL;
50  }