Logo Search packages:      
Sourcecode: samba-doc-ja version File versions

ssize_t smbc_write ( int  fd,
void *  buf,
size_t  bufsize 
)

Write to a file using an opened file handle.

Parameters:
fd Open file handle from smbc_open() or smbc_creat()
buf Pointer to buffer to recieve read data
bufsize Size of buf in bytes
Returns:
Number of bytes written, < 0 on error with errno set:
  • EISDIR fd refers to a directory.
  • EBADF fd is not a valid file descriptor or is not open for reading.
  • EINVAL fd is attached to an object which is unsuitable for reading, or no buffer passed or smbc_init not called.
See also:
smbc_open(), smbc_read()

Definition at line 793 of file libsmbclient.c.

Referenced by smbc_print_file().

{
      ssize_t ret;
      struct smbc_file *fe;

      if (!smbc_initialized) {

            errno = EINVAL;
            return -1;

      }

      if (fd < smbc_start_fd || fd >= (smbc_start_fd + SMBC_MAX_FD)) {

            errno = EBADF;
            return -1;
    
      }

      /* Check that the buffer exists ... */

      if (buf == NULL) {

            errno = EINVAL;
            return -1;

      }

      fe = smbc_file_table[fd - smbc_start_fd];

      if (!fe || !fe->file) {

            errno = EBADF;
            return -1;

      }

      ret = cli_write(&fe->srv->cli, fe->cli_fd, 0, buf, fe->offset, count);

      if (ret <= 0) {

            errno = smbc_errno(&fe->srv->cli);
            return -1;

      }

      fe->offset += ret;

      return ret;  /* Success, 0 bytes of data ... */
}


Generated by  Doxygen 1.6.0   Back to index