mirror of
git://git.code.sf.net/p/xtables-addons/xtables-addons
synced 2025-09-07 13:15:12 +02:00
ipp2p: use param_act() for parameter validation
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include <ctype.h>
|
||||
#include <xtables.h>
|
||||
#include "xt_ipp2p.h"
|
||||
#define param_act(t, s, f) param_act((t), "ipp2p", (s), (f))
|
||||
|
||||
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) {
|
||||
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,
|
||||
"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!");
|
||||
if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
|
||||
*flags |= IPP2P_EDK;
|
||||
info->cmd |= IPP2P_EDK;
|
||||
break;
|
||||
|
||||
case '7': /*cmd: dc*/
|
||||
if ((*flags & IPP2P_DC) == IPP2P_DC)
|
||||
exit_error(PARAMETER_PROBLEM,
|
||||
"ipp2p: `--dc' may only be "
|
||||
"specified once!");
|
||||
if ((*flags & IPP2P_DATA_DC) == IPP2P_DATA_DC)
|
||||
exit_error(PARAMETER_PROBLEM,
|
||||
param_act(P_ONLY_ONCE, "--dc", *flags & IPP2P_DC);
|
||||
param_act(P_NO_INVERT, "--dc", invert);
|
||||
if (*flags & IPP2P_DATA_DC)
|
||||
exit_error(PARAMETER_PROBLEM,
|
||||
"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;
|
||||
info->cmd |= IPP2P_DC;
|
||||
break;
|
||||
|
||||
case '9': /*cmd: gnu*/
|
||||
if ((*flags & IPP2P_GNU) == IPP2P_GNU)
|
||||
exit_error(PARAMETER_PROBLEM,
|
||||
"ipp2p: `--gnu' may only be "
|
||||
"specified once!");
|
||||
if ((*flags & IPP2P_DATA_GNU) == IPP2P_DATA_GNU)
|
||||
exit_error(PARAMETER_PROBLEM,
|
||||
param_act(P_ONLY_ONCE, "--gnu", *flags & IPP2P_GNU);
|
||||
param_act(P_NO_INVERT, "--gnu", invert);
|
||||
if (*flags & IPP2P_DATA_GNU)
|
||||
exit_error(PARAMETER_PROBLEM,
|
||||
"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;
|
||||
info->cmd |= IPP2P_GNU;
|
||||
break;
|
||||
|
||||
case 'a': /*cmd: kazaa*/
|
||||
if ((*flags & IPP2P_KAZAA) == IPP2P_KAZAA)
|
||||
exit_error(PARAMETER_PROBLEM,
|
||||
"ipp2p: `--kazaa' may only be "
|
||||
"specified once!");
|
||||
if ((*flags & IPP2P_DATA_KAZAA) == IPP2P_DATA_KAZAA)
|
||||
exit_error(PARAMETER_PROBLEM,
|
||||
param_act(P_ONLY_ONCE, "--kazaa", *flags & IPP2P_KAZAA);
|
||||
param_act(P_NO_INVERT, "--kazaa", invert);
|
||||
if (*flags & IPP2P_DATA_KAZAA)
|
||||
exit_error(PARAMETER_PROBLEM,
|
||||
"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;
|
||||
info->cmd |= IPP2P_KAZAA;
|
||||
break;
|
||||
|
||||
case 'b': /*cmd: bit*/
|
||||
if ((*flags & IPP2P_BIT) == IPP2P_BIT)
|
||||
exit_error(PARAMETER_PROBLEM,
|
||||
"ipp2p: `--bit' may only be "
|
||||
"specified once!");
|
||||
param_act(P_ONLY_ONCE, "--kazaa", *flags & IPP2P_BIT);
|
||||
param_act(P_NO_INVERT, "--kazaa", invert);
|
||||
*flags |= IPP2P_BIT;
|
||||
info->cmd |= IPP2P_BIT;
|
||||
break;
|
||||
|
||||
case 'c': /*cmd: apple*/
|
||||
if ((*flags & IPP2P_APPLE) == IPP2P_APPLE)
|
||||
exit_error(PARAMETER_PROBLEM,
|
||||
"ipp2p: `--apple' may only be "
|
||||
"specified once!");
|
||||
if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
|
||||
param_act(P_ONLY_ONCE, "--apple", *flags & IPP2P_APPLE);
|
||||
param_act(P_NO_INVERT, "--apple", invert);
|
||||
*flags |= IPP2P_APPLE;
|
||||
info->cmd |= IPP2P_APPLE;
|
||||
break;
|
||||
|
||||
case 'd': /*cmd: soul*/
|
||||
if ((*flags & IPP2P_SOUL) == IPP2P_SOUL)
|
||||
exit_error(PARAMETER_PROBLEM,
|
||||
"ipp2p: `--soul' may only be "
|
||||
"specified once!");
|
||||
if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
|
||||
param_act(P_ONLY_ONCE, "--soul", *flags & IPP2P_SOUL);
|
||||
param_act(P_NO_INVERT, "--soul", invert);
|
||||
*flags |= IPP2P_SOUL;
|
||||
info->cmd |= IPP2P_SOUL;
|
||||
break;
|
||||
|
||||
case 'e': /*cmd: winmx*/
|
||||
if ((*flags & IPP2P_WINMX) == IPP2P_WINMX)
|
||||
exit_error(PARAMETER_PROBLEM,
|
||||
"ipp2p: `--winmx' may only be "
|
||||
"specified once!");
|
||||
if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
|
||||
param_act(P_ONLY_ONCE, "--winmx", *flags & IPP2P_WINMX);
|
||||
param_act(P_NO_INVERT, "--winmx", invert);
|
||||
*flags |= IPP2P_WINMX;
|
||||
info->cmd |= IPP2P_WINMX;
|
||||
break;
|
||||
|
||||
case 'f': /*cmd: ares*/
|
||||
if ((*flags & IPP2P_ARES) == IPP2P_ARES)
|
||||
exit_error(PARAMETER_PROBLEM,
|
||||
"ipp2p: `--ares' may only be "
|
||||
"specified once!");
|
||||
if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
|
||||
param_act(P_ONLY_ONCE, "--ares", *flags & IPP2P_ARES);
|
||||
param_act(P_NO_INVERT, "--ares", invert);
|
||||
*flags |= IPP2P_ARES;
|
||||
info->cmd |= IPP2P_ARES;
|
||||
break;
|
||||
|
||||
case 'g': /*cmd: mute*/
|
||||
if ((*flags & IPP2P_MUTE) == IPP2P_MUTE)
|
||||
exit_error(PARAMETER_PROBLEM,
|
||||
"ipp2p: `--mute' may only be "
|
||||
"specified once!");
|
||||
if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
|
||||
param_act(P_ONLY_ONCE, "--mute", *flags & IPP2P_MUTE);
|
||||
param_act(P_NO_INVERT, "--mute", invert);
|
||||
*flags |= IPP2P_MUTE;
|
||||
info->cmd |= IPP2P_MUTE;
|
||||
break;
|
||||
|
||||
case 'h': /*cmd: waste*/
|
||||
if ((*flags & IPP2P_WASTE) == IPP2P_WASTE)
|
||||
exit_error(PARAMETER_PROBLEM,
|
||||
"ipp2p: `--waste' may only be "
|
||||
"specified once!");
|
||||
if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
|
||||
param_act(P_ONLY_ONCE, "--waste", *flags & IPP2P_WASTE);
|
||||
param_act(P_NO_INVERT, "--waste", invert);
|
||||
*flags |= IPP2P_WASTE;
|
||||
info->cmd |= IPP2P_WASTE;
|
||||
break;
|
||||
|
||||
case 'i': /*cmd: xdcc*/
|
||||
if ((*flags & IPP2P_XDCC) == IPP2P_XDCC)
|
||||
exit_error(PARAMETER_PROBLEM,
|
||||
"ipp2p: `--ares' may only be "
|
||||
"specified once!");
|
||||
if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
|
||||
param_act(P_ONLY_ONCE, "--xdcc", *flags & IPP2P_XDCC);
|
||||
param_act(P_NO_INVERT, "--xdcc", invert);
|
||||
*flags |= IPP2P_XDCC;
|
||||
info->cmd |= IPP2P_XDCC;
|
||||
break;
|
||||
|
||||
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;
|
||||
break;
|
||||
|
||||
|
Reference in New Issue
Block a user