X-Git-Url: https://gapil.gnulinux.it/gitweb/?a=blobdiff_plain;f=listati%2Ferrcode_mess.c;fp=listati%2Ferrcode_mess.c;h=61321bc8725f6ea04488b4a8f8caac16227d5860;hb=cf60963212306540ce7485ed7c86405e143a3352;hp=0000000000000000000000000000000000000000;hpb=6377acba6d39c62ceff07a420e0028bf6e03408c;p=gapil.git diff --git a/listati/errcode_mess.c b/listati/errcode_mess.c new file mode 100644 index 0000000..61321bc --- /dev/null +++ b/listati/errcode_mess.c @@ -0,0 +1,17 @@ + /* convert string to number */ + err = strtol(argv[optind], NULL, 10); + /* testing error condition on conversion */ + if (err==LONG_MIN) { + perror("Underflow on error code"); + return 1; + } else if (err==LONG_MIN) { + perror("Overflow on error code"); + return 1; + } + /* conversion is fine */ + if (message) { + printf("Error message for %d is %s\n", err, strerror(err)); + } + if (label) { + printf("Error label for %d is %s\n", err, err_code[err]); + }