2 * Copyright (C) 2015 Thadeu Lima de Souza Cascardo <cascardo@cascardo.eti.br>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 void sistema_free(struct declaracao *dec)
30 free(dec->sistema.so);
31 if (dec->sistema.so_versao)
32 free(dec->sistema.so_versao);
33 if (dec->sistema.jvm_versao)
34 free(dec->sistema.jvm_versao);
36 free(dec->sistema.mac);
39 static int run_sistema(struct declaracao *dec, char **args, int argc)
41 struct rendimento *rendimento;
45 dec->sistema.so = strdup(args[1]);
46 dec->sistema.so_versao = strdup(args[2]);
47 dec->sistema.jvm_versao = strdup(args[3]);
48 dec->sistema.mac = strdup(args[4]);
49 if (!dec->sistema.so || !dec->sistema.so_versao ||
50 !dec->sistema.jvm_versao || !dec->sistema.mac)
58 void sistema_salva(struct declaracao *dec, FILE *f)
60 fprintf(f, "sistema \"%s\" \"%s\" \"%s\" \"%s\"\n",
61 dec->sistema.so, dec->sistema.so_versao,
62 dec->sistema.jvm_versao, dec->sistema.mac);
65 static struct cmd cmd_sistema = {
70 int sistema_cmd_init(void)
72 cmd_add(&cmd_sistema);
76 #define SISTEMA_SO_DEFAULT "LINUX"
77 #define SISTEMA_SO_VERSAO_DEFAULT "3.16.0"
78 #define SISTEMA_JVM_VERSAO_DEFAULT "1.7.0"
79 #define SISTEMA_MAC_DEFAULT "000000000000"
81 char * sistema_get_so(struct declaracao *dec)
84 return SISTEMA_SO_DEFAULT;
85 return dec->sistema.so;
88 char * sistema_get_so_versao(struct declaracao *dec)
90 if (!dec->sistema.so_versao)
91 return SISTEMA_SO_VERSAO_DEFAULT;
92 return dec->sistema.so_versao;
95 char * sistema_get_jvm_versao(struct declaracao *dec)
97 if (!dec->sistema.jvm_versao)
98 return SISTEMA_JVM_VERSAO_DEFAULT;
99 return dec->sistema.jvm_versao;
102 char * sistema_get_mac(struct declaracao *dec)
104 if (!dec->sistema.mac)
105 return SISTEMA_MAC_DEFAULT;
106 return dec->sistema.mac;