summaryrefslogtreecommitdiffstats
path: root/lib/Utils/read_write.cpp
diff options
context:
space:
mode:
authorNikola Pajkovsky <npajkovs@redhat.com>2010-08-05 17:04:59 +0200
committerNikola Pajkovsky <npajkovs@redhat.com>2010-08-10 09:56:27 +0200
commitf926010c0f67582bcb37d1221cfe09743248b148 (patch)
treeff31b19eff3bc831a6b482b336b2116e555bdcb5 /lib/Utils/read_write.cpp
parent952420f6b5843e7f16474e3fd288bd8585c05373 (diff)
downloadabrt-f926010c0f67582bcb37d1221cfe09743248b148.tar.gz
abrt-f926010c0f67582bcb37d1221cfe09743248b148.tar.xz
abrt-f926010c0f67582bcb37d1221cfe09743248b148.zip
pure C for logging, read_wirte and xfuncs
Signed-off-by: Nikola Pajkovsky <npajkovs@redhat.com>
Diffstat (limited to 'lib/Utils/read_write.cpp')
-rw-r--r--lib/Utils/read_write.cpp93
1 files changed, 0 insertions, 93 deletions
diff --git a/lib/Utils/read_write.cpp b/lib/Utils/read_write.cpp
deleted file mode 100644
index 38907aa9..00000000
--- a/lib/Utils/read_write.cpp
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Utility routines.
- *
- * Licensed under GPLv2 or later, see file COPYING in this tarball for details.
- */
-#include "abrtlib.h"
-
-ssize_t safe_read(int fd, void *buf, size_t count)
-{
- ssize_t n;
-
- do {
- n = read(fd, buf, count);
- } while (n < 0 && errno == EINTR);
-
- return n;
-}
-
-ssize_t full_read(int fd, void *buf, size_t len)
-{
- ssize_t cc;
- ssize_t total;
-
- total = 0;
-
- while (len) {
- cc = safe_read(fd, buf, len);
-
- if (cc < 0) {
- if (total) {
- /* we already have some! */
- /* user can do another read to know the error code */
- return total;
- }
- return cc; /* read() returns -1 on failure. */
- }
- if (cc == 0)
- break;
- buf = ((char *)buf) + cc;
- total += cc;
- len -= cc;
- }
-
- return total;
-}
-
-/* Die with an error message if we can't read the entire buffer. */
-void xread(int fd, void *buf, size_t count)
-{
- if (count) {
- ssize_t size = full_read(fd, buf, count);
- if ((size_t)size != count)
- error_msg_and_die("short read");
- }
-}
-
-ssize_t safe_write(int fd, const void *buf, size_t count)
-{
- ssize_t n;
-
- do {
- n = write(fd, buf, count);
- } while (n < 0 && errno == EINTR);
-
- return n;
-}
-
-ssize_t full_write(int fd, const void *buf, size_t len)
-{
- ssize_t cc;
- ssize_t total;
-
- total = 0;
-
- while (len) {
- cc = safe_write(fd, buf, len);
-
- if (cc < 0) {
- if (total) {
- /* we already wrote some! */
- /* user can do another write to know the error code */
- return total;
- }
- return cc; /* write() returns -1 on failure. */
- }
-
- total += cc;
- buf = ((const char *)buf) + cc;
- len -= cc;
- }
-
- return total;
-}