-
Notifications
You must be signed in to change notification settings - Fork 0
/
azkaban.c
61 lines (55 loc) · 1.93 KB
/
azkaban.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include "comandos.h"
#include <string.h>
#include <stdio.h>
#define COMANDO_PERDONABLES "perdonables"
#define COMANDO_LIBERAR "liberar"
#define COMANDO_ACTUALIZAR "actualizar"
#define COMANDO_MOSTRAR_LIBERADOS "mostrar_liberados"
#define COMANDO_AYUDA "ayuda"
#define COMANDO 1
#define PARAMETRO_2 2
#define PARAMETRO_3 3
#define PARAMETRO_4 4
#define PRIMERA_LETRA 0
#define ARGUMENTOS_PERDONABLES 3
#define ARGUMENTOS_LIBERAR 5
#define ARGUMENTOS_ACTUALIZAR 3
#define ARGUMENTOS_MOSTRAR_LIBERADOS 3
/*PRE: el usuario debe ingresar la linea de ejecucion con el comando y parametros que desee*/
/*POST: el programa efectua el comando deseado si la linea de ejecucion fue ingresada correctamente, de lo contrario se muestra una ayuda*/
void efectuar_comandos (int argc, char* argv[]) {
if (strcmp (argv[COMANDO], COMANDO_PERDONABLES)==0) {
if (argc!=ARGUMENTOS_PERDONABLES)
mostrar_ayuda ();
else
presos_perdonables (argv[PARAMETRO_2]);
}
else if (strcmp (argv[COMANDO], COMANDO_LIBERAR)==0) {
if (argc!=ARGUMENTOS_LIBERAR)
mostrar_ayuda ();
else
presos_liberados (argv[PARAMETRO_2], argv[PARAMETRO_3], argv[PARAMETRO_4][PRIMERA_LETRA]);
}
else if (strcmp (argv[COMANDO], COMANDO_ACTUALIZAR)==0) {
if (argc!=ARGUMENTOS_ACTUALIZAR)
mostrar_ayuda ();
else
archivos_actualizados (argv[PARAMETRO_2]);
}
else if (strcmp (argv[COMANDO], COMANDO_MOSTRAR_LIBERADOS)==0) {
if (argc!=ARGUMENTOS_MOSTRAR_LIBERADOS)
mostrar_ayuda ();
else
liberados_por_pantalla (argv[PARAMETRO_2]);
}
else if (strcmp (argv[COMANDO], COMANDO_AYUDA)==0) {
mostrar_ayuda ();
}
else
mostrar_ayuda ();
}
/*Llama al procedimiento que se encarga de efectuar los distintos comandos*/
int main (int argc, char *argv[]) {
efectuar_comandos (argc, argv);
return 0;
}