summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2013-06-02 10:12:12 -0700
committerDaniil Baturin <daniil@baturin.org>2013-06-02 10:12:12 -0700
commit6698b613928f89f35a0b8b4c9f48e954f03db8de (patch)
treed28b004ee92df50a2ab9bbc8c04bbebb623436a4
parent2cbe465938894f91a8c7a4d91acea3d60a6bb188 (diff)
downloadipaddrcheck-6698b613928f89f35a0b8b4c9f48e954f03db8de.tar.gz
ipaddrcheck-6698b613928f89f35a0b8b4c9f48e954f03db8de.zip
Exit with different exit code in case of errors unrelated
to check result (2, specifically). Remove some debug output.
-rw-r--r--src/ipaddrcheck.c10
-rw-r--r--src/ipaddrcheck_functions.h1
2 files changed, 4 insertions, 7 deletions
diff --git a/src/ipaddrcheck.c b/src/ipaddrcheck.c
index 34c95a3..7706ad9 100644
--- a/src/ipaddrcheck.c
+++ b/src/ipaddrcheck.c
@@ -105,7 +105,7 @@ int main(int argc, char* argv[])
if( errno == ENOMEM )
{
fprintf(stderr, "Error: could not allocate memory!\n");
- return(EXIT_FAILURE);
+ return(RESULT_INT_ERROR);
}
while( (optc = getopt_long(argc, argv, "acdefghijklmnoprstuzABC?", options, &option_index)) != -1 )
@@ -189,7 +189,7 @@ int main(int argc, char* argv[])
default:
fprintf(stderr, "Error: invalid option\n");
print_help(program_name);
- return(EXIT_FAILURE);
+ return(RESULT_INT_ERROR);
break;
}
@@ -206,7 +206,7 @@ int main(int argc, char* argv[])
{
fprintf(stderr, "Error: wrong number of arguments, one argument required!\n");
print_help(program_name);
- return(EXIT_FAILURE);
+ return(RESULT_INT_ERROR);
}
CIDR *address;
@@ -218,13 +218,10 @@ int main(int argc, char* argv[])
if( !( (is_valid_address(address) == RESULT_SUCCESS) &&
((is_any_cidr(address_str) == RESULT_SUCCESS) || (is_any_single(address_str) == RESULT_SUCCESS)) ) )
{
- printf("cond: %d\n", (is_any_cidr(address_str) != RESULT_SUCCESS) || (is_any_single(address_str) != RESULT_SUCCESS));
- printf("valid: %d\n", (is_valid_address(address) != RESULT_SUCCESS));
return(EXIT_FAILURE);
}
/* no else needed, the rest is one big else */
- printf("action_count: %d\n", action_count);
while( (action_count >= 0) && (result == RESULT_SUCCESS) )
{
switch(actions[action_count])
@@ -299,7 +296,6 @@ int main(int argc, char* argv[])
default:
break;
}
- printf("action: %d\n", actions[action_count]);
action_count--;
}
diff --git a/src/ipaddrcheck_functions.h b/src/ipaddrcheck_functions.h
index 67cc410..bf39338 100644
--- a/src/ipaddrcheck_functions.h
+++ b/src/ipaddrcheck_functions.h
@@ -33,6 +33,7 @@
#define RESULT_SUCCESS 1
#define RESULT_FAILURE 0
+#define RESULT_INT_ERROR 2
#define IPV4_MULTICAST "224.0.0.0/4"
#define IPV4_LOOPBACK "127.0.0.0/8"