--- io.c 2001/01/18 20:30:50 1.3
+++ io.c 2001/01/19 14:56:33 1.4
@@ -1,6 +1,6 @@
/*
$Source: /v/ossp/cvs/ossp-pkg/petidomo/io.c,v $
- $Revision: 1.3 $
+ $Revision: 1.4 $
Copyright (C) 2000 by CyberSolutions GmbH, Germany.
@@ -20,6 +20,7 @@
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
+#include <string.h>
#include "petidomo.h"
@@ -42,7 +43,7 @@
for (;;) {
rc = read(fd, (buffer+read_size), (buffer_size - read_size - 1));
if (rc == -1) {
- syslog(LOG_ERR, "Error occured while reading file: %m");
+ syslog(LOG_ERR, "Error occured while reading file: %s", strerror(errno));
free(buffer);
return NULL;
}
@@ -83,7 +84,7 @@
assert(filename);
if ((fd = open(filename, O_RDONLY, 0)) == -1) {
- syslog(LOG_WARNING, "open(\"%s\", O_RDONLY): %m", filename);
+ syslog(LOG_WARNING, "open(\"%s\", O_RDONLY): %s", filename, strerror(errno));
return NULL;
}
lock.l_start = 0;
@@ -92,11 +93,11 @@
lock.l_whence = SEEK_SET;
fcntl(fd, F_SETLKW, &lock);
if ((len = lseek(fd, 0, SEEK_END)) == -1) {
- syslog(LOG_WARNING, "lseek(\"%s\", SEEK_END): %m", filename);
+ syslog(LOG_WARNING, "lseek(\"%s\", SEEK_END): %s", filename, strerror(errno));
return NULL;
}
if ((lseek(fd, 0, SEEK_SET) == -1)) {
- syslog(LOG_WARNING, "lseek(\"%s\", SEEK_SET): %m", filename);
+ syslog(LOG_WARNING, "lseek(\"%s\", SEEK_SET): %s", filename, strerror(errno));
return NULL;
}
buffer = malloc(len+1);
@@ -106,7 +107,7 @@
}
rc = read(fd, buffer, len);
if (rc != len) {
- syslog(LOG_WARNING, "read(\"%s\", %d) read %d byte: %m", filename, len, rc);
+ syslog(LOG_WARNING, "read(\"%s\", %d) read %d byte: %s", filename, len, rc, strerror(errno));
return NULL;
}
buffer[len] = '\0';
@@ -133,12 +134,12 @@
lock.l_whence = SEEK_SET;
fcntl(fd, F_SETLKW, &lock);
if (fd == -1) {
- syslog(LOG_ERR, "open(\"%s\"): %m", filename);
+ syslog(LOG_ERR, "open(\"%s\"): %s", filename, strerror(errno));
return -1;
}
rc = write(fd, buffer, len);
if (rc == -1) {
- syslog(LOG_ERR, "Error occured while writing to file \"%s\": %m", filename);
+ syslog(LOG_ERR, "Error occured while writing to file \"%s\": %s", filename, strerror(errno));
close(fd);
return -1;
}
|