#include #include #include "verify_indata.h" void indata_error () { fprintf(stderr, "Try invoke with -h (or --help);\n also see the README and HELP files.\n"); exit(1); } void number_of_params (int argc, int oc, int expected) { int params = argc - oc - 1; if (params != expected) { fprintf(stderr, "Error: number of parameters (%d) should be %d.\n", params, expected); indata_error(); } } // TODO void check_arg_types () { } void sensible_indata (int miles_one_year_ago, int miles_today, int liters) { signed int miles = miles_today - miles_one_year_ago; if (miles < 0) { fprintf(stderr, "Error: distance (%d miles) less than 0\n", miles); indata_error(); } if ((miles == 0) && (liters > 0)) { fprintf(stderr, "Error: 0 distance (%d miles); used liters (%d) more than 0\n", miles, liters); indata_error(); } // TODO: if verbose /* printf("Miles one year ago: %d\nMiles today: %d\n(Miles: %d)\nLiters: %d\n", */ /* miles_one_year_ago, miles_today, miles, liters); */ }