From: Jamal Hadi Salim Date: Tue, 8 Aug 2006 19:10:08 +0000 (-0700) Subject: First part of cleaning up the help output of actions. X-Git-Tag: v2.6.19-061214~55 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ebf32083e0a15b416357087362738e123cd0df9f;p=thirdparty%2Fiproute2.git First part of cleaning up the help output of actions. Signed-off-by: Stephen Hemminger --- diff --git a/tc/m_action.c b/tc/m_action.c index c67bc8836..e11d2f3bd 100644 --- a/tc/m_action.c +++ b/tc/m_action.c @@ -58,6 +58,7 @@ void act_usage(void) "\t\tExample ACTNAME is gact, mirred etc\n" "\t\tEach action has its own parameters (ACTPARAMS)\n" "\n"); + exit(-1); } static int print_noaopt(struct action_util *au, FILE *f, struct rtattr *opt) diff --git a/tc/m_gact.c b/tc/m_gact.c index 3ad872af5..ae75933bd 100644 --- a/tc/m_gact.c +++ b/tc/m_gact.c @@ -45,22 +45,28 @@ explain(void) #ifdef CONFIG_GACT_PROB fprintf(stderr, "Usage: ... gact [RAND] [INDEX]\n"); fprintf(stderr, - "Where: ACTION := reclassify | drop | continue | pass " - "RAND := random " - "RANDTYPE := netrand | determ" - "VAL : = value not exceeding 10000" - "INDEX := index value used" + "Where: \tACTION := reclassify | drop | continue | pass \n" + "\tRAND := random \n" + "\tRANDTYPE := netrand | determ\n" + "\tVAL : = value not exceeding 10000\n" + "\tINDEX := index value used\n" "\n"); #else fprintf(stderr, "Usage: ... gact [INDEX]\n"); fprintf(stderr, - "Where: ACTION := reclassify | drop | continue | pass " - "INDEX := index value used" + "Where: \tACTION := reclassify | drop | continue | pass \n" + "\tINDEX := index value used\n" "\n"); #endif } -#define usage() return(-1) +static void +usage(void) +{ + explain(); + exit(-1); +} + int get_act(char ***argv_p) @@ -157,6 +163,8 @@ parse_gact(struct action_util *a, int *argc_p, char ***argv_p, int tca_id, struc } argc--; argv++; + } else if (matches(*argv, "help") == 0) { + usage(); } } #endif diff --git a/tc/m_mirred.c b/tc/m_mirred.c index cbfea841e..ed87c8183 100644 --- a/tc/m_mirred.c +++ b/tc/m_mirred.c @@ -33,13 +33,19 @@ explain(void) { fprintf(stderr, "Usage: mirred [index INDEX] \n"); fprintf(stderr, "where: \n"); - fprintf(stderr, "DIRECTION := \n"); - fprintf(stderr, "aCTION := \n"); - fprintf(stderr, " : INDEX is the specific policy instance id\n"); - fprintf(stderr, " : DEVICENAME is the devicename \n"); + fprintf(stderr, "\tDIRECTION := \n"); + fprintf(stderr, "\tACTION := \n"); + fprintf(stderr, "\tINDEX is the specific policy instance id\n"); + fprintf(stderr, "\tDEVICENAME is the devicename \n"); + } -#define usage() return(-1) +static void +usage(void) +{ + explain(); + exit(-1); +} char *mirred_n2a(int action) { @@ -133,7 +139,6 @@ parse_egress(struct action_util *a, int *argc_p, char ***argv_p, int tca_id, str } if (!ok && !iok) { - explain(); return -1; } @@ -235,9 +240,10 @@ parse_mirred(struct action_util *a, int *argc_p, char ***argv_p, int tca_id, str } else if (matches(*argv, "ingress") == 0) { fprintf(stderr,"mirred ingress not supported at the moment\n"); - + } else if (matches(*argv, "help") == 0) { + usage(); } else { - fprintf(stderr,"mirred not supported %s\n", *argv); + fprintf(stderr,"mirred option not supported %s\n", *argv); } return -1; diff --git a/tc/m_pedit.c b/tc/m_pedit.c index acfa58198..5ac84a58f 100644 --- a/tc/m_pedit.c +++ b/tc/m_pedit.c @@ -33,25 +33,30 @@ static struct m_pedit_util *pedit_list; int pedit_debug = 1; static void -p_explain(void) +explain(void) { - fprintf(stderr, "Usage: ... pedit \n"); + fprintf(stderr, "Usage: ... pedit munge \n"); fprintf(stderr, "Where: MUNGE := |\n" - ":= [ATC]\n " - "OFFSETC:= offset \n " - "ATC:= at offmask shift \n " - "NOTE: offval is byte offset, must be multiple of 4\n " - "NOTE: maskval is a 32 bit hex number\n " - "NOTE: shiftval is a is a shift value\n " - "CMD:= clear | invert | set | retain\n " - ":= ip | ip6 \n " - " | udp | tcp | icmp \n" - "For Example usage look at the examples directory"); + "\t:= [ATC]\n " + "\t\tOFFSETC:= offset \n " + "\t\tATC:= at offmask shift \n " + "\t\tNOTE: offval is byte offset, must be multiple of 4\n " + "\t\tNOTE: maskval is a 32 bit hex number\n " + "\t\tNOTE: shiftval is a is a shift value\n " + "\t\tCMD:= clear | invert | set | retain\n " + "\t:= ip | ip6 \n " + " \t\t| udp | tcp | icmp \n" + "For Example usage look at the examples directory\n"); } -#define usage() return(-1) +static void +usage(void) +{ + explain(); + exit(-1); +} static int pedit_parse_nopopt (int *argc_p, char ***argv_p,struct tc_pedit_sel *sel,struct tc_pedit_key *tkey) @@ -423,11 +428,6 @@ parse_munge(int *argc_p, char ***argv_p,struct tc_pedit_sel *sel) NEXT_ARG(); res = parse_offset(&argc, &argv,sel,&tkey); goto done; -#if jamal - } else if (strcmp(*argv, "help") == 0) { - p_explain(); - return -1; -#endif } else { char k[16]; struct m_pedit_util *p = NULL; @@ -479,16 +479,18 @@ parse_pedit(struct action_util *a, int *argc_p, char ***argv_p, int tca_id, stru NEXT_ARG(); ok++; continue; + } else if (matches(*argv, "help") == 0) { + usage(); } else if (matches(*argv, "munge") == 0) { if (!ok) { fprintf(stderr, "Illegal pedit construct (%s) \n", *argv); - p_explain(); + explain(); return -1; } NEXT_ARG(); if (parse_munge(&argc, &argv,&sel.sel)) { fprintf(stderr, "Illegal pedit construct (%s) \n", *argv); - p_explain(); + explain(); return -1; } ok++; @@ -499,7 +501,7 @@ parse_pedit(struct action_util *a, int *argc_p, char ***argv_p, int tca_id, stru } if (!ok) { - p_explain(); + explain(); return -1; } diff --git a/tc/m_police.c b/tc/m_police.c index 71adb594a..7b803672a 100644 --- a/tc/m_police.c +++ b/tc/m_police.c @@ -32,7 +32,7 @@ struct action_util police_action_util = { .print_aopt = print_police, }; -static void explain(void) +static void usage(void) { fprintf(stderr, "Usage: ... police rate BPS burst BYTES[/BYTES] [ mtu BYTES[/BYTES] ]\n"); fprintf(stderr, " [ peakrate BPS ] [ avrate BPS ]\n"); @@ -41,6 +41,7 @@ static void explain(void) fprintf(stderr, "New Syntax ACTIONTERM := conform-exceed [/NOTEXCEEDACT] \n"); fprintf(stderr, "Where: *EXCEEDACT := pipe | ok | reclassify | drop | continue \n"); fprintf(stderr, "Where: pipe is only valid for new syntax \n"); + exit(-1); } static void explain1(char *arg) @@ -48,9 +49,6 @@ static void explain1(char *arg) fprintf(stderr, "Illegal \"%s\"\n", arg); } -#define usage() return(-1) - - char *police_action_n2a(int action, char *buf, int len) { switch (action) { @@ -236,8 +234,7 @@ int act_parse_police(struct action_util *a,int *argc_p, char ***argv_p, int tca_ return -1; } } else if (strcmp(*argv, "help") == 0) { - explain(); - return -1; + usage(); } else { break; }