ipp2p: use param_act() for parameter validation

This commit is contained in:
Jan Engelhardt
2008-03-27 09:20:40 +01:00
parent 376d41618c
commit 54f78ac3ef

View File

@@ -6,6 +6,7 @@
#include <ctype.h> #include <ctype.h>
#include <xtables.h> #include <xtables.h>
#include "xt_ipp2p.h" #include "xt_ipp2p.h"
#define param_act(t, s, f) param_act((t), "ipp2p", (s), (f))
static void ipp2p_mt_help(void) static void ipp2p_mt_help(void)
{ {
@@ -60,138 +61,104 @@ static int ipp2p_mt_parse(int c, char **argv, int invert, unsigned int *flags,
switch (c) { switch (c) {
case '2': /*cmd: edk*/ case '2': /*cmd: edk*/
if ((*flags & IPP2P_EDK) == IPP2P_EDK) param_act(P_ONLY_ONCE, "--edk", *flags & IPP2P_EDK);
param_act(P_NO_INVERT, "--edk", invert);
if (*flags & IPP2P_DATA_EDK)
exit_error(PARAMETER_PROBLEM, exit_error(PARAMETER_PROBLEM,
"ipp2p: `--edk' may only be "
"specified once");
if ((*flags & IPP2P_DATA_EDK) == IPP2P_DATA_EDK)
exit_error(PARAMETER_PROBLEM,
"ipp2p: use `--edk' OR `--edk-data' but not both of them!"); "ipp2p: use `--edk' OR `--edk-data' but not both of them!");
if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
*flags |= IPP2P_EDK; *flags |= IPP2P_EDK;
info->cmd |= IPP2P_EDK; info->cmd |= IPP2P_EDK;
break; break;
case '7': /*cmd: dc*/ case '7': /*cmd: dc*/
if ((*flags & IPP2P_DC) == IPP2P_DC) param_act(P_ONLY_ONCE, "--dc", *flags & IPP2P_DC);
exit_error(PARAMETER_PROBLEM, param_act(P_NO_INVERT, "--dc", invert);
"ipp2p: `--dc' may only be " if (*flags & IPP2P_DATA_DC)
"specified once!"); exit_error(PARAMETER_PROBLEM,
if ((*flags & IPP2P_DATA_DC) == IPP2P_DATA_DC)
exit_error(PARAMETER_PROBLEM,
"ipp2p: use `--dc' OR `--dc-data' but not both of them!"); "ipp2p: use `--dc' OR `--dc-data' but not both of them!");
if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
*flags |= IPP2P_DC; *flags |= IPP2P_DC;
info->cmd |= IPP2P_DC; info->cmd |= IPP2P_DC;
break; break;
case '9': /*cmd: gnu*/ case '9': /*cmd: gnu*/
if ((*flags & IPP2P_GNU) == IPP2P_GNU) param_act(P_ONLY_ONCE, "--gnu", *flags & IPP2P_GNU);
exit_error(PARAMETER_PROBLEM, param_act(P_NO_INVERT, "--gnu", invert);
"ipp2p: `--gnu' may only be " if (*flags & IPP2P_DATA_GNU)
"specified once!"); exit_error(PARAMETER_PROBLEM,
if ((*flags & IPP2P_DATA_GNU) == IPP2P_DATA_GNU)
exit_error(PARAMETER_PROBLEM,
"ipp2p: use `--gnu' OR `--gnu-data' but not both of them!"); "ipp2p: use `--gnu' OR `--gnu-data' but not both of them!");
if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
*flags |= IPP2P_GNU; *flags |= IPP2P_GNU;
info->cmd |= IPP2P_GNU; info->cmd |= IPP2P_GNU;
break; break;
case 'a': /*cmd: kazaa*/ case 'a': /*cmd: kazaa*/
if ((*flags & IPP2P_KAZAA) == IPP2P_KAZAA) param_act(P_ONLY_ONCE, "--kazaa", *flags & IPP2P_KAZAA);
exit_error(PARAMETER_PROBLEM, param_act(P_NO_INVERT, "--kazaa", invert);
"ipp2p: `--kazaa' may only be " if (*flags & IPP2P_DATA_KAZAA)
"specified once!"); exit_error(PARAMETER_PROBLEM,
if ((*flags & IPP2P_DATA_KAZAA) == IPP2P_DATA_KAZAA)
exit_error(PARAMETER_PROBLEM,
"ipp2p: use `--kazaa' OR `--kazaa-data' but not both of them!"); "ipp2p: use `--kazaa' OR `--kazaa-data' but not both of them!");
if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
*flags |= IPP2P_KAZAA; *flags |= IPP2P_KAZAA;
info->cmd |= IPP2P_KAZAA; info->cmd |= IPP2P_KAZAA;
break; break;
case 'b': /*cmd: bit*/ case 'b': /*cmd: bit*/
if ((*flags & IPP2P_BIT) == IPP2P_BIT) param_act(P_ONLY_ONCE, "--kazaa", *flags & IPP2P_BIT);
exit_error(PARAMETER_PROBLEM, param_act(P_NO_INVERT, "--kazaa", invert);
"ipp2p: `--bit' may only be "
"specified once!");
*flags |= IPP2P_BIT; *flags |= IPP2P_BIT;
info->cmd |= IPP2P_BIT; info->cmd |= IPP2P_BIT;
break; break;
case 'c': /*cmd: apple*/ case 'c': /*cmd: apple*/
if ((*flags & IPP2P_APPLE) == IPP2P_APPLE) param_act(P_ONLY_ONCE, "--apple", *flags & IPP2P_APPLE);
exit_error(PARAMETER_PROBLEM, param_act(P_NO_INVERT, "--apple", invert);
"ipp2p: `--apple' may only be "
"specified once!");
if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
*flags |= IPP2P_APPLE; *flags |= IPP2P_APPLE;
info->cmd |= IPP2P_APPLE; info->cmd |= IPP2P_APPLE;
break; break;
case 'd': /*cmd: soul*/ case 'd': /*cmd: soul*/
if ((*flags & IPP2P_SOUL) == IPP2P_SOUL) param_act(P_ONLY_ONCE, "--soul", *flags & IPP2P_SOUL);
exit_error(PARAMETER_PROBLEM, param_act(P_NO_INVERT, "--soul", invert);
"ipp2p: `--soul' may only be "
"specified once!");
if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
*flags |= IPP2P_SOUL; *flags |= IPP2P_SOUL;
info->cmd |= IPP2P_SOUL; info->cmd |= IPP2P_SOUL;
break; break;
case 'e': /*cmd: winmx*/ case 'e': /*cmd: winmx*/
if ((*flags & IPP2P_WINMX) == IPP2P_WINMX) param_act(P_ONLY_ONCE, "--winmx", *flags & IPP2P_WINMX);
exit_error(PARAMETER_PROBLEM, param_act(P_NO_INVERT, "--winmx", invert);
"ipp2p: `--winmx' may only be "
"specified once!");
if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
*flags |= IPP2P_WINMX; *flags |= IPP2P_WINMX;
info->cmd |= IPP2P_WINMX; info->cmd |= IPP2P_WINMX;
break; break;
case 'f': /*cmd: ares*/ case 'f': /*cmd: ares*/
if ((*flags & IPP2P_ARES) == IPP2P_ARES) param_act(P_ONLY_ONCE, "--ares", *flags & IPP2P_ARES);
exit_error(PARAMETER_PROBLEM, param_act(P_NO_INVERT, "--ares", invert);
"ipp2p: `--ares' may only be "
"specified once!");
if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
*flags |= IPP2P_ARES; *flags |= IPP2P_ARES;
info->cmd |= IPP2P_ARES; info->cmd |= IPP2P_ARES;
break; break;
case 'g': /*cmd: mute*/ case 'g': /*cmd: mute*/
if ((*flags & IPP2P_MUTE) == IPP2P_MUTE) param_act(P_ONLY_ONCE, "--mute", *flags & IPP2P_MUTE);
exit_error(PARAMETER_PROBLEM, param_act(P_NO_INVERT, "--mute", invert);
"ipp2p: `--mute' may only be "
"specified once!");
if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
*flags |= IPP2P_MUTE; *flags |= IPP2P_MUTE;
info->cmd |= IPP2P_MUTE; info->cmd |= IPP2P_MUTE;
break; break;
case 'h': /*cmd: waste*/ case 'h': /*cmd: waste*/
if ((*flags & IPP2P_WASTE) == IPP2P_WASTE) param_act(P_ONLY_ONCE, "--waste", *flags & IPP2P_WASTE);
exit_error(PARAMETER_PROBLEM, param_act(P_NO_INVERT, "--waste", invert);
"ipp2p: `--waste' may only be "
"specified once!");
if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
*flags |= IPP2P_WASTE; *flags |= IPP2P_WASTE;
info->cmd |= IPP2P_WASTE; info->cmd |= IPP2P_WASTE;
break; break;
case 'i': /*cmd: xdcc*/ case 'i': /*cmd: xdcc*/
if ((*flags & IPP2P_XDCC) == IPP2P_XDCC) param_act(P_ONLY_ONCE, "--xdcc", *flags & IPP2P_XDCC);
exit_error(PARAMETER_PROBLEM, param_act(P_NO_INVERT, "--xdcc", invert);
"ipp2p: `--ares' may only be "
"specified once!");
if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
*flags |= IPP2P_XDCC; *flags |= IPP2P_XDCC;
info->cmd |= IPP2P_XDCC; info->cmd |= IPP2P_XDCC;
break; break;
case 'j': /*cmd: debug*/ case 'j': /*cmd: debug*/
if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!"); param_act(P_ONLY_ONCE, "--debug", info->debug);
param_act(P_NO_INVERT, "--debug", invert);
info->debug = 1; info->debug = 1;
break; break;