Back to index

nagios-plugins  1.4.16
Defines | Functions
full-write.c File Reference
#include <config.h>
#include "full-read.h"
#include <errno.h>
#include "safe-read.h"
#include "full-write.h"
#include "safe-write.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define safe_rw   safe_write
#define full_rw   full_write
#define ZERO_BYTE_TRANSFER_ERRNO   ENOSPC

Functions

size_t full_rw (int fd, const void *buf, size_t count)

Define Documentation

#define full_rw   full_write

Definition at line 38 of file full-write.c.

#define safe_rw   safe_write

Definition at line 37 of file full-write.c.

#define ZERO_BYTE_TRANSFER_ERRNO   ENOSPC

Definition at line 48 of file full-write.c.


Function Documentation

size_t full_rw ( int  fd,
const void *  buf,
size_t  count 
)

Definition at line 58 of file full-write.c.

{
  size_t total = 0;
  const char *ptr = (const char *) buf;

  while (count > 0)
    {
      size_t n_rw = safe_rw (fd, ptr, count);
      if (n_rw == (size_t) -1)
        break;
      if (n_rw == 0)
        {
          errno = ZERO_BYTE_TRANSFER_ERRNO;
          break;
        }
      total += n_rw;
      ptr += n_rw;
      count -= n_rw;
    }

  return total;
}