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
|
#include <string.h>
#include <stdio.h>
void filter(char *s)
{
*(s + strlen(s) - 1) = 0;
}
const char *opt[] = {
"r",
"i",
"m",
"c",
0
};
int process(char *s)
{
int i;
i = -1;
while (opt[++i])
if (!strcmp(opt[i], s))
return (1);
return (0);
}
int main()
{
char command[1024];
printf("Comandos: \nr: resuelve el nombre de un host\n"
"i: devuelve el nombre correspondiente a una IP\n"
"m: devuelve los nombres de servidores de correo de un dominio\n"
"c: cambia el sevidor de nombres a una nueva IP\n"
"exit: salir del cliente dns\n\n");
printf("> ");
while (fgets(command, 1024, stdin))
{
filter(command);
if (!strcmp(command, "exit"))
break;
if (!process(command))
puts("Sintaxa del comando incorrecta");
printf("> ");
}
printf("Bye.");
return (0);
} |
Partager