better error messages

This commit is contained in:
albert 2005-01-05 21:21:58 +00:00
parent 0fb81f5c39
commit 0edb6a86fb
2 changed files with 14 additions and 13 deletions

1
NEWS
View File

@ -1,6 +1,7 @@
procps-3.2.4 --> procps-3.2.5
display problem on 64-bit systems fixed
sysctl: better error messages
ps: security labels can contain any printable ASCII
top: help and version message on stdout, with exit(0) #283541
ps: SIGTSTP from ^Z shouldn't print bug email address

View File

@ -52,15 +52,15 @@ static bool IgnoreError;
static bool Quiet;
/* error messages */
static const char ERR_UNKNOWN_PARAMETER[] = "error: Unknown parameter '%s'\n";
static const char ERR_MALFORMED_SETTING[] = "error: Malformed setting '%s'\n";
static const char ERR_NO_EQUALS[] = "error: '%s' must be of the form name=value\n";
static const char ERR_INVALID_KEY[] = "error: '%s' is an unknown key\n";
static const char ERR_UNKNOWN_WRITING[] = "error: unknown error %d setting key '%s'\n";
static const char ERR_UNKNOWN_READING[] = "error: unknown error %d reading key '%s'\n";
static const char ERR_UNKNOWN_PARAMETER[] = "error: Unknown parameter \"%s\"\n";
static const char ERR_MALFORMED_SETTING[] = "error: Malformed setting \"%s\"\n";
static const char ERR_NO_EQUALS[] = "error: \"%s\" must be of the form name=value\n";
static const char ERR_INVALID_KEY[] = "error: \"%s\" is an unknown key\n";
static const char ERR_UNKNOWN_WRITING[] = "error: \"%s\" setting key \"%s\"\n";
static const char ERR_UNKNOWN_READING[] = "error: \"%s\" reading key \"%s\"\n";
static const char ERR_PERMISSION_DENIED[] = "error: permission denied on key '%s'\n";
static const char ERR_OPENING_DIR[] = "error: unable to open directory '%s'\n";
static const char ERR_PRELOAD_FILE[] = "error: unable to open preload file '%s'\n";
static const char ERR_OPENING_DIR[] = "error: unable to open directory \"%s\"\n";
static const char ERR_PRELOAD_FILE[] = "error: unable to open preload file \"%s\"\n";
static const char WARN_BAD_LINE[] = "warning: %s(%d): invalid syntax, continuing...\n";
@ -159,7 +159,7 @@ static int ReadSetting(const char *restrict const name) {
rc = -1;
break;
default:
fprintf(stderr, ERR_UNKNOWN_READING, errno, outname);
fprintf(stderr, ERR_UNKNOWN_READING, strerror(errno), outname);
rc = -1;
break;
}
@ -198,7 +198,7 @@ static int ReadSetting(const char *restrict const name) {
break;
}
default:
fprintf(stderr, ERR_UNKNOWN_READING, errno, outname);
fprintf(stderr, ERR_UNKNOWN_READING, strerror(errno), outname);
rc = -1;
break;
}
@ -314,19 +314,19 @@ static int WriteSetting(const char *setting) {
rc = -1;
break;
default:
fprintf(stderr, ERR_UNKNOWN_WRITING, errno, outname);
fprintf(stderr, ERR_UNKNOWN_WRITING, strerror(errno), outname);
rc = -1;
break;
}
} else {
rc = fprintf(fp, "%s\n", value);
if (rc < 0) {
fprintf(stderr, ERR_UNKNOWN_WRITING, errno, outname);
fprintf(stderr, ERR_UNKNOWN_WRITING, strerror(errno), outname);
fclose(fp);
} else {
rc=fclose(fp);
if (rc != 0)
fprintf(stderr, ERR_UNKNOWN_WRITING, errno, outname);
fprintf(stderr, ERR_UNKNOWN_WRITING, strerror(errno), outname);
}
if (rc==0 && !Quiet) {
if (NameOnly) {