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)
44 dec->sistema.so = strdup(args[1]);
45 dec->sistema.so_versao = strdup(args[2]);
46 dec->sistema.jvm_versao = strdup(args[3]);
47 dec->sistema.mac = strdup(args[4]);
48 if (!dec->sistema.so || !dec->sistema.so_versao ||
49 !dec->sistema.jvm_versao || !dec->sistema.mac)
57 void sistema_salva(struct declaracao *dec, FILE *f)
59 fprintf(f, "sistema \"%s\" \"%s\" \"%s\" \"%s\"\n",
60 dec->sistema.so, dec->sistema.so_versao,
61 dec->sistema.jvm_versao, dec->sistema.mac);
64 static struct cmd cmd_sistema = {
69 int sistema_cmd_init(void)
71 cmd_add(&cmd_sistema);
75 #define SISTEMA_SO_DEFAULT "LINUX"
76 #define SISTEMA_SO_VERSAO_DEFAULT "3.16.0"
77 #define SISTEMA_JVM_VERSAO_DEFAULT "1.7.0"
78 #define SISTEMA_MAC_DEFAULT "000000000000"
80 char * sistema_get_so(struct declaracao *dec)
83 return SISTEMA_SO_DEFAULT;
84 return dec->sistema.so;
87 char * sistema_get_so_versao(struct declaracao *dec)
89 if (!dec->sistema.so_versao)
90 return SISTEMA_SO_VERSAO_DEFAULT;
91 return dec->sistema.so_versao;
94 char * sistema_get_jvm_versao(struct declaracao *dec)
96 if (!dec->sistema.jvm_versao)
97 return SISTEMA_JVM_VERSAO_DEFAULT;
98 return dec->sistema.jvm_versao;
101 char * sistema_get_mac(struct declaracao *dec)
103 if (!dec->sistema.mac)
104 return SISTEMA_MAC_DEFAULT;
105 return dec->sistema.mac;