コード例 #1
0
ファイル: dal.c プロジェクト: thewacokid/marfs
// Put data into a MC Object. For performance reasons we will need to
// try to align the size of `buf' with the underlying buffers in the
// n+e lib.  This could be hard to achieve, since the buffer size may
// be determined by fuse, or PFTool. Is there some efficient way to
// simply give the buffer to the n+e library and relinquish ownership,
// using a fresh buffer for the next write?
int mc_put(DAL_Context* ctx,
           const char* buf,
           size_t size) {
   ENTRY();

   ObjectStream* os     = MC_OS(ctx);

   if(! (os->flags & OSF_OPEN)) {
      LOG(LOG_ERR, "Attempted put on OS that is not open.\n");
      errno = EBADF;
      return -1;
   }

   ne_handle handle = MC_HANDLE(ctx);
   int written = ne_write(handle, buf, size);

   if(written < 0) {
      LOG(LOG_ERR, "ftone_write() failed.\n");
      return -1;
   }

   os->written += written;
   
   EXIT();
   return written;
}
コード例 #2
0
ファイル: ne_socket.c プロジェクト: dveeden/Prestan
static ssize_t write_raw(ne_socket *sock, const char *data, size_t length) 
{
    ssize_t wrote;
    
    do {
	wrote = ne_write(sock->fd, data, length);
        if (wrote > 0) {
            data += wrote;
            length -= wrote;
        }
    } while ((wrote > 0 || NE_ISINTR(ne_errno)) && length > 0);

    if (wrote < 0) {
	int errnum = ne_errno;
	set_strerror(sock, errnum);
	return MAP_ERR(errnum);
    }

    return 0;
}