您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ writev函数代码示例

51自学网 2021-06-03 10:07:42
  C++
这篇教程C++ writev函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中writev函数的典型用法代码示例。如果您正苦于以下问题:C++ writev函数的具体用法?C++ writev怎么用?C++ writev使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了writev函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: wl_connection_data

int wl_connection_data(struct wl_connection *connection, uint32_t mask){	struct wl_buffer *b;	struct iovec iov[2];	int len, head, tail, count, size, available;	if (mask & WL_CONNECTION_READABLE) {		b = &connection->in;		head = connection->in.head;		if (head < b->tail) {			iov[0].iov_base = b->data + head;			iov[0].iov_len = b->tail - head;			count = 1;		} else {			size = ARRAY_LENGTH(b->data) - head;			iov[0].iov_base = b->data + head;			iov[0].iov_len = size;			iov[1].iov_base = b->data;			iov[1].iov_len = b->tail;			count = 2;		}		len = readv(connection->fd, iov, count);		if (len < 0) {			fprintf(stderr,				"read error from connection %p: %m (%d)/n",				connection, errno);			return -1;		} else if (len == 0) {			/* FIXME: Handle this better? */			return -1;		} else if (head + len <= ARRAY_LENGTH(b->data)) {			b->head += len;		} else {			b->head = head + len - ARRAY_LENGTH(b->data);		}		/* We know we have data in the buffer at this point,		 * so if head equals tail, it means the buffer is		 * full. */		available = b->head - b->tail;		if (available == 0)			available = sizeof b->data;		else if (available < 0)			available += ARRAY_LENGTH(b->data);	} else {		available = 0;	}		if (mask & WL_CONNECTION_WRITABLE) {		b = &connection->out;		tail = b->tail;		if (tail < b->head) {			iov[0].iov_base = b->data + tail;			iov[0].iov_len = b->head - tail;			count = 1;		} else {			size = ARRAY_LENGTH(b->data) - tail;			iov[0].iov_base = b->data + tail;			iov[0].iov_len = size;			iov[1].iov_base = b->data;			iov[1].iov_len = b->head;			count = 2;		}		len = writev(connection->fd, iov, count);		if (len < 0) {			fprintf(stderr, "write error for connection %p: %m/n", connection);			return -1;		} else if (tail + len <= ARRAY_LENGTH(b->data)) {			b->tail += len;		} else {			b->tail = tail + len - ARRAY_LENGTH(b->data);		}		/* We just took data out of the buffer, so at this		 * point if head equals tail, the buffer is empty. */		if (b->tail == b->head)			connection->update(connection,					   WL_CONNECTION_READABLE,					   connection->data);	}	return available;}
开发者ID:qiuTED,项目名称:wayland,代码行数:85,


示例2: ngx_linux_sendfile_chain

//.........这里部分代码省略.........            ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,                           "sendfile: @%O %uz", file->file_pos, file_size);            rc = sendfile(c->fd, file->file->fd, &offset, file_size);            if (rc == -1) {                err = ngx_errno;                switch (err) {                case NGX_EAGAIN:                    break;                case NGX_EINTR:                    eintr = 1;                    break;                default:                    wev->error = 1;                    ngx_connection_error(c, err, "sendfile() failed");                    return NGX_CHAIN_ERROR;                }                ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, err,                               "sendfile() is not ready");            }            sent = rc > 0 ? rc : 0;            ngx_log_debug4(NGX_LOG_DEBUG_EVENT, c->log, 0,                           "sendfile: %d, @%O %O:%uz",                           rc, file->file_pos, sent, file_size);        } else {            rc = writev(c->fd, header.elts, header.nelts);            if (rc == -1) {                err = ngx_errno;                switch (err) {                case NGX_EAGAIN:                    break;                case NGX_EINTR:                    eintr = 1;                    break;                default:                    wev->error = 1;                    ngx_connection_error(c, err, "writev() failed");                    return NGX_CHAIN_ERROR;                }                ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, err,                               "writev() not ready");            }            sent = rc > 0 ? rc : 0;            ngx_log_debug(NGX_LOG_DEBUG_EVENT, c->log, 0, "writev: %O, fd:%d", sent, c->fd);        }        if (send - prev_send == sent) {            complete = 1;        }        c->sent += sent;
开发者ID:zgbkny,项目名称:nginx,代码行数:67,


示例3: write_file

void write_file(iface_t *ifa){    struct if_file *ifc = (struct if_file *) ifa->info;    senblk_t *sptr;    int usereturn=flag_test(ifa,F_NOCR)?0:1;    int data=0;    int cnt=1;    struct iovec iov[2];    /* ifc->fd will only be < 0 if we're opening a FIFO.     */    if (ifc->fd < 0) {        if ((ifc->fd=open(ifc->filename,O_WRONLY)) < 0) {            logerr(errno,"Failed to open FIFO %s for writing/n",ifc->filename);            iface_thread_exit(errno);        }        if ((ifa->q =init_q(ifc->qsize)) == NULL) {            logerr(errno,"Could not create queue for FIFO %s",ifc->filename);            iface_thread_exit(errno);        }    }    if (ifa->tagflags) {        if ((iov[0].iov_base=malloc(TAGMAX)) == NULL) {                logerr(errno,"Disabing tag output on interface id %u (%s)",                        ifa->id,(ifa->name)?ifa->name:"unlabelled");                ifa->tagflags=0;        } else {            cnt=2;            data=1;        }    }    for(;;)  {        if ((sptr = next_senblk(ifa->q)) == NULL) {            break;        }        if (senfilter(sptr,ifa->ofilter)) {            senblk_free(sptr,ifa->q);            continue;        }        if (!usereturn) {            sptr->data[sptr->len-2] = '/n';            sptr->len--;        }        if (ifa->tagflags)            if ((iov[0].iov_len = gettag(ifa,iov[0].iov_base,sptr)) == 0) {                logerr(errno,"Disabing tag output on interface id %u (%s)",                        ifa->id,(ifa->name)?ifa->name:"unlabelled");                ifa->tagflags=0;                cnt=1;                data=0;                free(iov[0].iov_base);            }        iov[data].iov_base=sptr->data;        iov[data].iov_len=sptr->len;        if (writev(ifc->fd,iov,cnt) <0) {            if (!(flag_test(ifa,F_PERSIST) && errno == EPIPE) )                break;            if ((ifc->fd=open(ifc->filename,O_WRONLY)) < 0)                break;        }        senblk_free(sptr,ifa->q);    }    if (cnt == 2)        free(iov[0].iov_base);    iface_thread_exit(errno);}
开发者ID:bakerkj,项目名称:kplex,代码行数:75,


示例4: sdp_register_service

int32_tsdp_register_service(void *xss, uint16_t uuid, bdaddr_p const bdaddr,		uint8_t const *data, uint32_t datalen, uint32_t *handle){	sdp_session_p	ss = (sdp_session_p) xss;	struct iovec	iov[4];	sdp_pdu_t	pdu;	int32_t		len;	if (ss == NULL)		return (-1);	if (bdaddr == NULL || data == NULL ||	    datalen == 0 || !(ss->flags & SDP_SESSION_LOCAL)) {		ss->error = EINVAL;		return (-1);	}	if (sizeof(pdu)+sizeof(uuid)+sizeof(*bdaddr)+datalen > SDP_LOCAL_MTU) {		ss->error = EMSGSIZE;		return (-1);	}	pdu.pid = SDP_PDU_SERVICE_REGISTER_REQUEST;	pdu.tid = htons(++ss->tid);	pdu.len = htons(sizeof(uuid) + sizeof(*bdaddr) + datalen);	uuid = htons(uuid);	iov[0].iov_base = (void *) &pdu;	iov[0].iov_len = sizeof(pdu);	iov[1].iov_base = (void *) &uuid;	iov[1].iov_len = sizeof(uuid);	iov[2].iov_base = (void *) bdaddr;	iov[2].iov_len = sizeof(*bdaddr);	iov[3].iov_base = (void *) data;	iov[3].iov_len = datalen;	do {		len = writev(ss->s, iov, sizeof(iov)/sizeof(iov[0]));	} while (len < 0 && errno == EINTR);	if (len < 0) {		ss->error = errno;		return (-1);	}	len = sdp_receive_error_pdu(ss);	if (len < 0)		return (-1);	if (len != sizeof(pdu) + sizeof(uint16_t) + sizeof(uint32_t)) {		ss->error = EIO;		return (-1);	}	if (handle != NULL) {		*handle  = (uint32_t) ss->rsp[--len];		*handle |= (uint32_t) ss->rsp[--len] << 8;		*handle |= (uint32_t) ss->rsp[--len] << 16;		*handle |= (uint32_t) ss->rsp[--len] << 24;	}	return (0);}
开发者ID:hmatyschok,项目名称:MeshBSD,代码行数:65,


示例5: replay_thread

//.........这里部分代码省略.........			if (thr->nhdr >= sizeof thr->hdr / sizeof *thr->hdr) {				thr->bogus = 1;			} else {				thr->hdr[thr->nhdr++] = trimline(thr, ptr);				if (isprefix(ptr, "connection:", &next))					thr->conn = trimline(thr, next);			}			break;		default:			break;		}		freez(msg->ptr);		freez(msg);		if (tag != SLT_ReqEnd)			continue;		if (!thr->method || !thr->url || !thr->proto) {			thr->bogus = 1;		} else if (strcmp(thr->method, "GET") != 0 &&		    strcmp(thr->method, "HEAD") != 0) {			thr->bogus = 1;		} else if (strcmp(thr->proto, "HTTP/1.0") == 0) {			reopen = !(thr->conn &&			    strcasecmp(thr->conn, "keep-alive") == 0);		} else if (strcmp(thr->proto, "HTTP/1.1") == 0) {			reopen = (thr->conn &&			    strcasecmp(thr->conn, "close") == 0);		} else {			thr->bogus = 1;		}		if (thr->bogus) {			thread_log(1, 0, "bogus");			goto clear;		}		if (thr->sock == -1) {			for (;;) {				thread_log(1, 0, "sleeping before connect...");				usleep(1000 * (thr->fd % 3001));				if ((thr->sock = VSS_connect(addr_info)) >= 0)					break;				thread_log(0, errno, "connect failed");			}		}		thread_log(1, 0, "%s %s %s", thr->method, thr->url, thr->proto);		iov[0].iov_base = thr->method;		iov[0].iov_len = strlen(thr->method);		iov[2].iov_base = thr->url;		iov[2].iov_len = strlen(thr->url);		iov[4].iov_base = thr->proto;		iov[4].iov_len = strlen(thr->proto);		iov[1].iov_base = iov[3].iov_base = space;		iov[1].iov_len = iov[3].iov_len = 1;		iov[5].iov_base = crlf;		iov[5].iov_len = 2;		if (writev(thr->sock, iov, 6) == -1) {			thread_log(0, errno, "writev()");			goto close;		}		for (i = 0; i < thr->nhdr; ++i) {			thread_log(2, 0, "%d %s", i, thr->hdr[i]);			iov[0].iov_base = thr->hdr[i];			iov[0].iov_len = strlen(thr->hdr[i]);			iov[1].iov_base = crlf;			iov[1].iov_len = 2;			if (writev(thr->sock, iov, 2) == -1) {				thread_log(0, errno, "writev()");				goto close;			}		}		if (write(thr->sock, crlf, 2) == -1) {			thread_log(0, errno, "writev()");			goto close;		}		if (receive_response(thr) || reopen) {close:			thread_log(1, 0, "close");			assert(thr->sock != -1);			close(thr->sock);			thr->sock = -1;		}		sleep(1);clear:		/* clean up */		thread_clear(thr);	}	/* leftovers */	thread_clear(thr);	return (0);}
开发者ID:attisan,项目名称:Varnish-Least-Busy-Director,代码行数:101,


示例6: apr_socket_sendfile

apr_status_t apr_socket_sendfile(apr_socket_t *sock, apr_file_t *file,                                 apr_hdtr_t *hdtr, apr_off_t *offset,                                 apr_size_t *len, apr_int32_t flags){    int i;    apr_ssize_t rc;    apr_size_t nbytes = *len, headerlen, trailerlen;    struct iovec hdtrarray[2];    char *headerbuf, *trailerbuf;    if (!hdtr) {        hdtr = &no_hdtr;    }    /* Ignore flags for now. */    flags = 0;    /* HP-UX can only send one header iovec and one footer iovec; try to     * only allocate storage to combine input iovecs when we really have to     */    switch(hdtr->numheaders) {    case 0:        hdtrarray[0].iov_base = NULL;        hdtrarray[0].iov_len = 0;        break;    case 1:        hdtrarray[0] = hdtr->headers[0];        break;    default:        headerlen = 0;        for (i = 0; i < hdtr->numheaders; i++) {            headerlen += hdtr->headers[i].iov_len;        }        /* XXX:  BUHHH? wow, what a memory leak! */        headerbuf = hdtrarray[0].iov_base = apr_palloc(sock->cntxt, headerlen);        hdtrarray[0].iov_len = headerlen;        for (i = 0; i < hdtr->numheaders; i++) {            memcpy(headerbuf, hdtr->headers[i].iov_base,                   hdtr->headers[i].iov_len);            headerbuf += hdtr->headers[i].iov_len;        }    }    switch(hdtr->numtrailers) {    case 0:        hdtrarray[1].iov_base = NULL;        hdtrarray[1].iov_len = 0;        break;    case 1:        hdtrarray[1] = hdtr->trailers[0];        break;    default:        trailerlen = 0;        for (i = 0; i < hdtr->numtrailers; i++) {            trailerlen += hdtr->trailers[i].iov_len;        }        /* XXX:  BUHHH? wow, what a memory leak! */        trailerbuf = hdtrarray[1].iov_base = apr_palloc(sock->cntxt, trailerlen);        hdtrarray[1].iov_len = trailerlen;        for (i = 0; i < hdtr->numtrailers; i++) {            memcpy(trailerbuf, hdtr->trailers[i].iov_base,                   hdtr->trailers[i].iov_len);            trailerbuf += hdtr->trailers[i].iov_len;        }    }    do {        if (nbytes) {       /* any bytes to send from the file? */            rc = sendfile(sock->socketdes,      /* socket  */                          file->filedes,        /* file descriptor to send */                          *offset,              /* where in the file to start */                          nbytes,               /* number of bytes to send from file */                          hdtrarray,            /* Headers/footers */                          flags);               /* undefined, set to 0 */        }        else {              /* we can't call sendfile() with no bytes to send from the file */            rc = writev(sock->socketdes, hdtrarray, 2);        }    } while (rc == -1 && errno == EINTR);    while (rc == -1 &&            (errno == EAGAIN || errno == EWOULDBLOCK) &&            apr_is_option_set(sock->netmask, APR_SO_TIMEOUT)) {        apr_status_t arv = apr_wait_for_io_or_timeout(NULL, sock, 0);        if (arv != APR_SUCCESS) {            *len = 0;            return arv;        }        else {            do {                if (nbytes) {                    rc = sendfile(sock->socketdes,    /* socket  */                                  file->filedes,      /* file descriptor to send */                                  *offset,            /* where in the file to start *///.........这里部分代码省略.........
开发者ID:kheradmand,项目名称:Break,代码行数:101,


示例7: uv__write

/* On success returns NULL. On error returns a pointer to the write request * which had the error. */static void uv__write(uv_stream_t* stream) {  uv_write_t* req;  struct iovec* iov;  int iovcnt;  ssize_t n;  if (stream->flags & UV_CLOSING) {    /* Handle was closed this tick. We've received a stale     * 'is writable' callback from the event loop, ignore.     */    return;  }start:  assert(stream->fd >= 0);  /* Get the request at the head of the queue. */  req = uv_write_queue_head(stream);  if (!req) {    assert(stream->write_queue_size == 0);    return;  }  assert(req->handle == stream);  /*   * Cast to iovec. We had to have our own uv_buf_t instead of iovec   * because Windows's WSABUF is not an iovec.   */  assert(sizeof(uv_buf_t) == sizeof(struct iovec));  iov = (struct iovec*) &(req->bufs[req->write_index]);  iovcnt = req->bufcnt - req->write_index;  /*   * Now do the actual writev. Note that we've been updating the pointers   * inside the iov each time we write. So there is no need to offset it.   */  if (req->send_handle) {    struct msghdr msg;    char scratch[64];    struct cmsghdr *cmsg;    int fd_to_send = req->send_handle->fd;    assert(fd_to_send >= 0);    msg.msg_name = NULL;    msg.msg_namelen = 0;    msg.msg_iov = iov;    msg.msg_iovlen = iovcnt;    msg.msg_flags = 0;    msg.msg_control = (void*) scratch;    msg.msg_controllen = CMSG_LEN(sizeof(fd_to_send));    cmsg = CMSG_FIRSTHDR(&msg);    cmsg->cmsg_level = SOL_SOCKET;    cmsg->cmsg_type = SCM_RIGHTS;    cmsg->cmsg_len = msg.msg_controllen;    /* silence aliasing warning */    {      void* pv = CMSG_DATA(cmsg);      int* pi = pv;      *pi = fd_to_send;    }    do {      n = sendmsg(stream->fd, &msg, 0);    }    while (n == -1 && errno == EINTR);  } else {    do {      if (iovcnt == 1) {        n = write(stream->fd, iov[0].iov_base, iov[0].iov_len);      } else {        n = writev(stream->fd, iov, iovcnt);      }    }    while (n == -1 && errno == EINTR);  }  if (n < 0) {    if (errno != EAGAIN && errno != EWOULDBLOCK) {      /* Error */      req->error = errno;      stream->write_queue_size -= uv__write_req_size(req);      uv__write_req_finish(req);      return;    } else if (stream->flags & UV_STREAM_BLOCKING) {      /* If this is a blocking stream, try again. */      goto start;    }  } else {    /* Successful write *///.........这里部分代码省略.........
开发者ID:IAmAnubhavSaini,项目名称:node,代码行数:101,


示例8: log_thread_function

void* log_thread_function(void* arg){	log_item* item;		int len;	int done;	int total_size;	time_t now;	char* p = NULL;	char* time_str;	struct iovec iv[3];		char end = '/n';	char log_type_info[6][12] = {{"LOG_INFO/t"}, {"LOG_WARING/t"}, {"LOG_NOTICE/t"}, {"LOG_ERROR/t"}, {"LOG_DEBUG/t"}, {"LOG_CRIT/t"}};	syslog(LOG_DEBUG, "log thread start/n");		assert(log_que.fd > 0 && log_que.buf);	while(1) {		pthread_mutex_lock(&log_que.buf_lock);		while(log_que.curr == 0)			pthread_cond_wait(&log_que.log_cond, &log_que.buf_lock);				done = 0;		while(done < log_que.curr) {			p = log_que.buf + done;			item = (log_item*)p;					now = time(NULL);			time_str = ctime(&now);			len = strlen(time_str);				// 去掉时间字符串最后的那个/n			time_str[len-1] = '/0';			strcat(time_str, "/t");			iv[0].iov_len = len;			iv[0].iov_base = (void*)time_str;				iv[1].iov_len = strlen(log_type_info[item->type]);			iv[1].iov_base = (void*)log_type_info[item->type];				iv[2].iov_len = item->len;			iv[2].iov_base = p + sizeof(log_item);						if(iv[2].iov_len <= 0) {				iv[2].iov_len = 1;				iv[2].iov_base = &end;			}			total_size = iv[0].iov_len + iv[1].iov_len + iv[2].iov_len;			while(total_size > 0) {				if((len = writev(log_que.fd, iv, 3)) < 0) {					if(errno == EINTR)						continue;					syslog(LOG_WARNING, "error occured:%s when write log", strerror(errno));					pthread_mutex_unlock(&log_que.buf_lock);					return NULL;				}				total_size -= len;			}			done += sizeof(log_item) + item->len;		}				log_que.curr = 0;		pthread_mutex_unlock(&log_que.buf_lock);	}		return NULL;}
开发者ID:RechardTheGrey,项目名称:tiny_ftp,代码行数:73,


示例9: test_file

void test_file(void){    int fd, i, len, ret;    uint8_t buf[FILE_BUF_SIZE];    uint8_t buf2[FILE_BUF_SIZE];    uint8_t buf3[FILE_BUF_SIZE];    char cur_dir[1024];    struct stat st;    struct utimbuf tbuf;    struct iovec vecs[2];    DIR *dir;    struct dirent *de;    /* clean up, just in case */    unlink(TESTPATH "/file1");    unlink(TESTPATH "/file2");    unlink(TESTPATH "/file3");    rmdir(TESTPATH);    if (getcwd(cur_dir, sizeof(cur_dir)) == NULL)        error("getcwd");    chk_error(mkdir(TESTPATH, 0755));    chk_error(chdir(TESTPATH));    /* open/read/write/close/readv/writev/lseek */    fd = chk_error(open("file1", O_WRONLY | O_TRUNC | O_CREAT, 0644));    for(i=0;i < FILE_BUF_SIZE; i++)        buf[i] = i;    len = chk_error(qemu_write(fd, buf, FILE_BUF_SIZE / 2));    if (len != (FILE_BUF_SIZE / 2))        error("write");    vecs[0].iov_base = buf + (FILE_BUF_SIZE / 2);    vecs[0].iov_len = 16;    vecs[1].iov_base = buf + (FILE_BUF_SIZE / 2) + 16;    vecs[1].iov_len = (FILE_BUF_SIZE / 2) - 16;    len = chk_error(writev(fd, vecs, 2));    if (len != (FILE_BUF_SIZE / 2))     error("writev");    chk_error(close(fd));    chk_error(rename("file1", "file2"));    fd = chk_error(open("file2", O_RDONLY));    len = chk_error(read(fd, buf2, FILE_BUF_SIZE));    if (len != FILE_BUF_SIZE)        error("read");    if (memcmp(buf, buf2, FILE_BUF_SIZE) != 0)        error("memcmp");#define FOFFSET 16    ret = chk_error(lseek(fd, FOFFSET, SEEK_SET));    if (ret != 16)        error("lseek");    vecs[0].iov_base = buf3;    vecs[0].iov_len = 32;    vecs[1].iov_base = buf3 + 32;    vecs[1].iov_len = FILE_BUF_SIZE - FOFFSET - 32;    len = chk_error(readv(fd, vecs, 2));    if (len != FILE_BUF_SIZE - FOFFSET)        error("readv");    if (memcmp(buf + FOFFSET, buf3, FILE_BUF_SIZE - FOFFSET) != 0)        error("memcmp");    chk_error(close(fd));    /* access */    chk_error(access("file2", R_OK));    /* stat/chmod/utime/truncate */    chk_error(chmod("file2", 0600));    tbuf.actime = 1001;    tbuf.modtime = 1000;    chk_error(truncate("file2", 100));    chk_error(utime("file2", &tbuf));    chk_error(stat("file2", &st));    if (st.st_size != 100)        error("stat size");    if (!S_ISREG(st.st_mode))        error("stat mode");    if ((st.st_mode & 0777) != 0600)        error("stat mode2");    if (st.st_atime != 1001 ||        st.st_mtime != 1000)        error("stat time");    chk_error(stat(TESTPATH, &st));    if (!S_ISDIR(st.st_mode))        error("stat mode");    /* fstat */    fd = chk_error(open("file2", O_RDWR));    chk_error(ftruncate(fd, 50));    chk_error(fstat(fd, &st));    chk_error(close(fd));//.........这里部分代码省略.........
开发者ID:CrazyXen,项目名称:XEN_CODE,代码行数:101,


示例10: uwsgi_redis_logger

ssize_t uwsgi_redis_logger(struct uwsgi_logger *ul, char *message, size_t len) {	ssize_t ret,ret2;	struct uwsgi_redislog_state *uredislog = NULL;	if (!ul->configured) {		if (!ul->data) {			ul->data = uwsgi_calloc(sizeof(struct uwsgi_redislog_state));			uredislog = (struct uwsgi_redislog_state *) ul->data;		}		if (ul->arg != NULL) {			char *logarg = uwsgi_str(ul->arg);			char *comma1 = strchr(logarg, ',');			if (!comma1) {				uredislog->address = logarg;				goto done;			}			*comma1 = 0;			uredislog->address = logarg;			comma1++;			if (*comma1 == 0) goto done;			char *comma2 = strchr(comma1,',');			if (!comma2) {				uredislog->command = uwsgi_redis_logger_build_command(comma1);				goto done;			}			*comma2 = 0;			uredislog->command = uwsgi_redis_logger_build_command(comma1);			comma2++;			if (*comma2 == 0) goto done;			uredislog->prefix = comma2;		}done:		if (!uredislog->address) uredislog->address = uwsgi_str("127.0.0.1:6379");		if (!uredislog->command) uredislog->command = "*3/r/n$7/r/npublish/r/n$5/r/nuwsgi/r/n";		if (!uredislog->prefix) uredislog->prefix = "";		uredislog->fd = -1;		uredislog->iovec[0].iov_base = uredislog->command;		uredislog->iovec[0].iov_len = strlen(uredislog->command);		uredislog->iovec[1].iov_base = "$";		uredislog->iovec[1].iov_len = 1;		uredislog->iovec[2].iov_base = uredislog->msgsize;		uredislog->iovec[3].iov_base = "/r/n";		uredislog->iovec[3].iov_len = 2;		uredislog->iovec[4].iov_base = uredislog->prefix;		uredislog->iovec[4].iov_len = strlen(uredislog->prefix);		uredislog->iovec[6].iov_base = "/r/n";		uredislog->iovec[6].iov_len = 2;		ul->configured = 1;	}	uredislog = (struct uwsgi_redislog_state *) ul->data;	if (uredislog->fd == -1) {		uredislog->fd = uwsgi_connect(uredislog->address, uwsgi.socket_timeout, 0);	}	if (uredislog->fd == -1) return -1;	// drop newline        if (message[len-1] == '/n') len--;	uwsgi_num2str2(len + uredislog->iovec[4].iov_len, uredislog->msgsize);	uredislog->iovec[2].iov_len = strlen(uredislog->msgsize);	uredislog->iovec[5].iov_base = message;	uredislog->iovec[5].iov_len = len;		ret = writev(uredislog->fd, uredislog->iovec, 7);	if (ret <= 0) {		close(uredislog->fd);		uredislog->fd = -1;		return -1;	}again:	// read til a /n is found (ugly but fast)	ret2 = read(uredislog->fd, uredislog->response, 8);	if (ret2 <= 0) {		close(uredislog->fd);		uredislog->fd = -1;		return -1;	}	if (!memchr(uredislog->response, '/n', ret2)) {		goto again;	}//.........这里部分代码省略.........
开发者ID:comel,项目名称:uwsgi,代码行数:101,


示例11: direct_write_log_line

/* * Write a line to log file (unbuffered) */static voiddirect_write_log_line (rspamd_logger_t *rspamd_log,		void *data,		gsize count,		gboolean is_iov){	gchar errmsg[128];	struct iovec *iov;	const gchar *line;	glong r;	if (rspamd_log->enabled) {		if (!rspamd_log->no_lock) {#ifndef DISABLE_PTHREAD_MUTEX			if (rspamd_log->mtx) {				rspamd_mempool_lock_mutex (rspamd_log->mtx);			}			else {				rspamd_file_lock (rspamd_log->fd, FALSE);			}#else			rspamd_file_lock (rspamd_log->fd, FALSE);#endif		}		if (is_iov) {			iov = (struct iovec *) data;			r = writev (rspamd_log->fd, iov, count);		}		else {			line = (const gchar *) data;			r = write (rspamd_log->fd, line, count);		}		if (!rspamd_log->no_lock) {#ifndef DISABLE_PTHREAD_MUTEX			if (rspamd_log->mtx) {				rspamd_mempool_unlock_mutex (rspamd_log->mtx);			}			else {				rspamd_file_unlock (rspamd_log->fd, FALSE);			}#else			rspamd_file_unlock (rspamd_log->fd, FALSE);#endif		}		if (r == -1) {			/* We cannot write message to file, so we need to detect error and make decision */			if (errno == EINTR) {				/* Try again */				direct_write_log_line (rspamd_log, data, count, is_iov);				return;			}			r = rspamd_snprintf (errmsg,					sizeof (errmsg),					"direct_write_log_line: cannot write log line: %s",					strerror (errno));			if (errno == EFAULT || errno == EINVAL || errno == EFBIG ||				errno == ENOSPC) {				/* Rare case */				rspamd_log->throttling = TRUE;				rspamd_log->throttling_time = time (NULL);			}			else if (errno == EPIPE || errno == EBADF) {				/* We write to some pipe and it disappears, disable logging or we has opened bad file descriptor */				rspamd_log->enabled = FALSE;			}		}		else if (rspamd_log->throttling) {			rspamd_log->throttling = FALSE;		}	}}
开发者ID:moisseev,项目名称:rspamd,代码行数:78,


示例12: ttymsg

/* * Display the contents of a uio structure on a terminal.  Used by wall(1), * syslogd(8), and talkd(8).  Forks and finishes in child if write would block, * waiting up to tmout seconds.  Returns pointer to error string on unexpected * error; string is not newline-terminated.  Various "normal" errors are * ignored (exclusive-use, lack of permission, etc.). */const char *ttymsg(struct iovec *iov, int iovcnt, const char *line, int tmout){	struct iovec localiov[7];	ssize_t left, wret;	int cnt, fd;	static char device[MAXNAMLEN] = _PATH_DEV;	static char errbuf[1024];	char *p;	int forked;	forked = 0;	if (iovcnt > (int)(sizeof(localiov) / sizeof(localiov[0])))		return ("too many iov's (change code in wall/ttymsg.c)");	p = device + sizeof(_PATH_DEV) - 1;	strlcpy(p, line, sizeof(device));	if (strncmp(p, "pts/", 4) == 0)		p += 4;	if (strchr(p, '/') != NULL) {		/* A slash is an attempt to break security... */		(void) snprintf(errbuf, sizeof(errbuf),		    "Too many '/' in /"%s/"", device);		return (errbuf);	}	/*	 * open will fail on slip lines or exclusive-use lines	 * if not running as root; not an error.	 */	if ((fd = open(device, O_WRONLY|O_NONBLOCK, 0)) < 0) {		if (errno == EBUSY || errno == EACCES)			return (NULL);		(void) snprintf(errbuf, sizeof(errbuf), "%s: %s", device,		    strerror(errno));		return (errbuf);	}	for (cnt = 0, left = 0; cnt < iovcnt; ++cnt)		left += iov[cnt].iov_len;	for (;;) {		wret = writev(fd, iov, iovcnt);		if (wret >= left)			break;		if (wret >= 0) {			left -= wret;			if (iov != localiov) {				bcopy(iov, localiov, 				    iovcnt * sizeof(struct iovec));				iov = localiov;			}			for (cnt = 0; (size_t)wret >= iov->iov_len; ++cnt) {				wret -= iov->iov_len;				++iov;				--iovcnt;			}			if (wret) {				iov->iov_base = (char *)iov->iov_base + wret;				iov->iov_len -= wret;			}			continue;		}		if (errno == EWOULDBLOCK) {			int cpid;			if (forked) {				(void) close(fd);				_exit(1);			}			cpid = fork();			if (cpid < 0) {				(void) snprintf(errbuf, sizeof(errbuf),				    "fork: %s", strerror(errno));				(void) close(fd);				return (errbuf);			}			if (cpid) {	/* parent */				(void) close(fd);				return (NULL);			}			forked++;			/* wait at most tmout seconds */			(void) signal(SIGALRM, SIG_DFL);			(void) signal(SIGTERM, SIG_DFL); /* XXX */			(void) sigsetmask(0);			(void) alarm((u_int)tmout);			(void) fcntl(fd, F_SETFL, 0);	/* clear O_NONBLOCK */			continue;		}		/*		 * We get ENODEV on a slip line if we're running as root,		 * and EIO if the line just went away.//.........这里部分代码省略.........
开发者ID:coyizumi,项目名称:cs111,代码行数:101,


示例13: retry_writev

static int     /* R: bytes written, or -1 on error */retry_writev (  /* PARAMETERS */  int fd,                              /* I: fd to write on */  struct iovec *iov,                   /* U: iovec array base                                        *    modified as data written */  int iovcnt                           /* I: number of iovec entries */  /* END PARAMETERS */  ){    /* VARIABLES */    int n;                             /* return value from writev() */    int i;                             /* loop counter */    int written;                       /* bytes written so far */    static int iov_max;                        /* max number of iovec entries */    /* END VARIABLES */    /* initialization */#ifdef MAXIOV    iov_max = MAXIOV;#else /* ! MAXIOV */# ifdef IOV_MAX    iov_max = IOV_MAX;# else /* ! IOV_MAX */    iov_max = 8192;# endif /* ! IOV_MAX */#endif /* ! MAXIOV */    written = 0;    for (;;) {       while (iovcnt && iov[0].iov_len == 0) {           iov++;           iovcnt--;       }       if (!iovcnt) {           return written;       }       n = writev(fd, iov, iovcnt > iov_max ? iov_max : iovcnt);       if (n == -1) {           if (errno == EINVAL && iov_max > 10) {               iov_max /= 2;               continue;           }           if (errno == EINTR) {               continue;           }           return -1;       } else {           written += n;       }       for (i = 0; i < iovcnt; i++) {           if (iov[i].iov_len > (unsigned) n) {               iov[i].iov_base = (char *)iov[i].iov_base + n;               iov[i].iov_len -= n;               break;           }           n -= iov[i].iov_len;           iov[i].iov_len = 0;       }       if (i == iovcnt) {           return written;       }    }    /* NOTREACHED */}
开发者ID:KunZheng,项目名称:mosbench,代码行数:70,


示例14: apr_socket_sendfile

apr_status_t apr_socket_sendfile(apr_socket_t *sock, apr_file_t *file,                                 apr_hdtr_t *hdtr, apr_off_t *offset,                                 apr_size_t *len, apr_int32_t flags){    int i;    apr_ssize_t rc;    apr_size_t nbytes = *len, headerlen, trailerlen;    struct iovec hdtrarray[2];    char *headerbuf, *trailerbuf;#if APR_HAS_LARGE_FILES && defined(HAVE_SENDFILE64)    /* later HP-UXes have a sendfile64() */#define sendfile sendfile64    apr_off_t off = *offset;#elif APR_HAS_LARGE_FILES && SIZEOF_OFF_T == 4    /* HP-UX 11.00 doesn't have a sendfile64(): fail if trying to send     * past the 2Gb limit */    off_t off;    if ((apr_int64_t)*offset + *len > INT_MAX) {        return EINVAL;    }    off = *offset;#else    apr_off_t off = *offset;#endif    if (!hdtr) {        hdtr = &no_hdtr;    }    /* Ignore flags for now. */    flags = 0;    /* HP-UX can only send one header iovec and one footer iovec; try to     * only allocate storage to combine input iovecs when we really have to     */    switch(hdtr->numheaders) {    case 0:        hdtrarray[0].iov_base = NULL;        hdtrarray[0].iov_len = 0;        break;    case 1:        hdtrarray[0] = hdtr->headers[0];        break;    default:        headerlen = 0;        for (i = 0; i < hdtr->numheaders; i++) {            headerlen += hdtr->headers[i].iov_len;        }          /* XXX:  BUHHH? wow, what a memory leak! */        headerbuf = hdtrarray[0].iov_base = apr_palloc(sock->pool, headerlen);        hdtrarray[0].iov_len = headerlen;        for (i = 0; i < hdtr->numheaders; i++) {            memcpy(headerbuf, hdtr->headers[i].iov_base,                   hdtr->headers[i].iov_len);            headerbuf += hdtr->headers[i].iov_len;        }    }    switch(hdtr->numtrailers) {    case 0:        hdtrarray[1].iov_base = NULL;        hdtrarray[1].iov_len = 0;        break;    case 1:        hdtrarray[1] = hdtr->trailers[0];        break;    default:        trailerlen = 0;        for (i = 0; i < hdtr->numtrailers; i++) {            trailerlen += hdtr->trailers[i].iov_len;        }        /* XXX:  BUHHH? wow, what a memory leak! */        trailerbuf = hdtrarray[1].iov_base = apr_palloc(sock->pool, trailerlen);        hdtrarray[1].iov_len = trailerlen;        for (i = 0; i < hdtr->numtrailers; i++) {            memcpy(trailerbuf, hdtr->trailers[i].iov_base,                   hdtr->trailers[i].iov_len);            trailerbuf += hdtr->trailers[i].iov_len;        }    }    do {        if (nbytes) {       /* any bytes to send from the file? */            rc = sendfile(sock->socketdes,      /* socket  */                          file->filedes,        /* file descriptor to send */                          off,                  /* where in the file to start */                          nbytes,               /* number of bytes to send from file */                          hdtrarray,            /* Headers/footers */                          flags);               /* undefined, set to 0 */        }        else {              /* we can't call sendfile() with no bytes to send from the file */            rc = writev(sock->socketdes, hdtrarray, 2);//.........这里部分代码省略.........
开发者ID:TaoheGit,项目名称:hmi_sdl_android,代码行数:101,


示例15: ngx_writev_chain

ngx_chain_t *ngx_writev_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit){    u_char        *prev;    ssize_t        n, size, sent;    off_t          send, prev_send;    ngx_uint_t     eintr, complete;    ngx_err_t      err;    ngx_array_t    vec;    ngx_chain_t   *cl;    ngx_event_t   *wev;    struct iovec  *iov, iovs[NGX_IOVS];    wev = c->write;    if (!wev->ready) {        return in;    }#if (NGX_HAVE_KQUEUE)    if ((ngx_event_flags & NGX_USE_KQUEUE_EVENT) && wev->pending_eof) {        (void) ngx_connection_error(c, wev->kq_errno,                               "kevent() reported about an closed connection");        wev->error = 1;        return NGX_CHAIN_ERROR;    }#endif    /* the maximum limit size is the maximum size_t value - the page size */    if (limit == 0 || limit > (off_t) (NGX_MAX_SIZE_T_VALUE - ngx_pagesize)) {        limit = NGX_MAX_SIZE_T_VALUE - ngx_pagesize;    }    send = 0;    complete = 0;    vec.elts = iovs;    vec.size = sizeof(struct iovec);    vec.nalloc = NGX_IOVS;    vec.pool = c->pool;    for ( ;; ) {        prev = NULL;        iov = NULL;        eintr = 0;        prev_send = send;        vec.nelts = 0;        /* create the iovec and coalesce the neighbouring bufs */        for (cl = in; cl && vec.nelts < IOV_MAX && send < limit; cl = cl->next)        {            if (ngx_buf_special(cl->buf)) {                continue;            }#if 1            if (!ngx_buf_in_memory(cl->buf)) {                ngx_debug_point();            }#endif            size = cl->buf->last - cl->buf->pos;            if (send + size > limit) {                size = (ssize_t) (limit - send);            }            if (prev == cl->buf->pos) {                iov->iov_len += size;            } else {                iov = ngx_array_push(&vec);                if (iov == NULL) {                    return NGX_CHAIN_ERROR;                }                iov->iov_base = (void *) cl->buf->pos;                iov->iov_len = size;            }            prev = cl->buf->pos + size;            send += size;        }        n = writev(c->fd, vec.elts, vec.nelts);        if (n == -1) {            err = ngx_errno;            if (err == NGX_EAGAIN || err == NGX_EINTR) {                if (err == NGX_EINTR) {                    eintr = 1;                }                ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, err,//.........这里部分代码省略.........
开发者ID:AloneRoad,项目名称:MTS,代码行数:101,


示例16: main

intmain(int argc, char *argv[]){	int nflag;	/* if not set, output a trailing newline. */	int veclen;	/* number of writev arguments. */	struct iovec *iov, *vp; /* Elements to write, current element. */	char space[] = " ";	char newline[] = "/n";	char *progname = argv[0];	if (caph_limit_stdio() < 0 || (cap_enter() < 0 && errno != ENOSYS))		err(1, "capsicum");	/* This utility may NOT do getopt(3) option parsing. */	if (*++argv && !strcmp(*argv, "-n")) {		++argv;		--argc;		nflag = 1;	} else		nflag = 0;	veclen = (argc >= 2) ? (argc - 2) * 2 + 1 : 0;	if ((vp = iov = malloc((veclen + 1) * sizeof(struct iovec))) == NULL)		errexit(progname, "malloc");	while (argv[0] != NULL) {		size_t len;				len = strlen(argv[0]);		/*		 * If the next argument is NULL then this is this		 * the last argument, therefore we need to check		 * for a trailing /c.		 */		if (argv[1] == NULL) {			/* is there room for a '/c' and is there one? */			if (len >= 2 &&			    argv[0][len - 2] == '//' &&			    argv[0][len - 1] == 'c') {				/* chop it and set the no-newline flag. */				len -= 2;				nflag = 1;			}		}		vp->iov_base = *argv;		vp++->iov_len = len;		if (*++argv) {			vp->iov_base = space;			vp++->iov_len = 1;		}	}	if (!nflag) {		veclen++;		vp->iov_base = newline;		vp++->iov_len = 1;	}	/* assert(veclen == (vp - iov)); */	while (veclen) {		int nwrite;		nwrite = (veclen > IOV_MAX) ? IOV_MAX : veclen;		if (writev(STDOUT_FILENO, iov, nwrite) == -1)			errexit(progname, "write");		iov += nwrite;		veclen -= nwrite;	}	return 0;}
开发者ID:2trill2spill,项目名称:freebsd,代码行数:70,


示例17: bus_machine_method_get_addresses

//.........这里部分代码省略.........                return r;        r = sd_bus_message_open_container(reply, 'a', "(iay)");        if (r < 0)                return r;        switch (m->class) {        case MACHINE_HOST: {                _cleanup_free_ struct local_address *addresses = NULL;                struct local_address *a;                int n, i;                n = local_addresses(NULL, 0, AF_UNSPEC, &addresses);                if (n < 0)                        return n;                for (a = addresses, i = 0; i < n; a++, i++) {                        r = sd_bus_message_open_container(reply, 'r', "iay");                        if (r < 0)                                return r;                        r = sd_bus_message_append(reply, "i", addresses[i].family);                        if (r < 0)                                return r;                        r = sd_bus_message_append_array(reply, 'y', &addresses[i].address, FAMILY_ADDRESS_SIZE(addresses[i].family));                        if (r < 0)                                return r;                        r = sd_bus_message_close_container(reply);                        if (r < 0)                                return r;                }                break;        }        case MACHINE_CONTAINER: {                _cleanup_close_pair_ int pair[2] = { -1, -1 };                _cleanup_free_ char *us = NULL, *them = NULL;                _cleanup_close_ int netns_fd = -1;                const char *p;                siginfo_t si;                pid_t child;                r = readlink_malloc("/proc/self/ns/net", &us);                if (r < 0)                        return r;                p = procfs_file_alloca(m->leader, "ns/net");                r = readlink_malloc(p, &them);                if (r < 0)                        return r;                if (streq(us, them))                        return sd_bus_error_setf(error, BUS_ERROR_NO_PRIVATE_NETWORKING, "Machine %s does not use private networking", m->name);                r = namespace_open(m->leader, NULL, NULL, &netns_fd, NULL, NULL);                if (r < 0)                        return r;                if (socketpair(AF_UNIX, SOCK_SEQPACKET, 0, pair) < 0)                        return -errno;                child = fork();                if (child < 0)                        return sd_bus_error_set_errnof(error, errno, "Failed to fork(): %m");                if (child == 0) {                        _cleanup_free_ struct local_address *addresses = NULL;                        struct local_address *a;                        int i, n;                        pair[0] = safe_close(pair[0]);                        r = namespace_enter(-1, -1, netns_fd, -1, -1);                        if (r < 0)                                _exit(EXIT_FAILURE);                        n = local_addresses(NULL, 0, AF_UNSPEC, &addresses);                        if (n < 0)                                _exit(EXIT_FAILURE);                        for (a = addresses, i = 0; i < n; a++, i++) {                                struct iovec iov[2] = {                                        { .iov_base = &a->family, .iov_len = sizeof(a->family) },                                        { .iov_base = &a->address, .iov_len = FAMILY_ADDRESS_SIZE(a->family) },                                };                                r = writev(pair[1], iov, 2);                                if (r < 0)                                        _exit(EXIT_FAILURE);                        }                        pair[1] = safe_close(pair[1]);                        _exit(EXIT_SUCCESS);                }
开发者ID:BenjaminLefoul,项目名称:systemd,代码行数:101,


示例18: ngx_darwin_sendfile_chain

//.........这里部分代码省略.........                    eintr = 1;                    break;                default:                    wev->error = 1;                    (void) ngx_connection_error(c, err, "sendfile() failed");                    return NGX_CHAIN_ERROR;                }                ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, err,                               "sendfile() sent only %O bytes", sent);            }            if (rc == 0 && sent == 0) {                /*                 * if rc and sent equal to zero, then someone                 * has truncated the file, so the offset became beyond                 * the end of the file                 */                ngx_log_error(NGX_LOG_ALERT, c->log, 0,                              "sendfile() reported that /"%s/" was truncated",                              file->file->name.data);                return NGX_CHAIN_ERROR;            }            ngx_log_debug4(NGX_LOG_DEBUG_EVENT, c->log, 0,                           "sendfile: %d, @%O %O:%O",                           rc, file->file_pos, sent, file_size + header_size);        } else {            rc = writev(c->fd, header.elts, header.nelts);            ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,                           "writev: %d of %uz", rc, send);            if (rc == -1) {                err = ngx_errno;                switch (err) {                case NGX_EAGAIN:                    break;                case NGX_EINTR:                    eintr = 1;                    break;                default:                    wev->error = 1;                    ngx_connection_error(c, err, "writev() failed");                    return NGX_CHAIN_ERROR;                }                ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, err,                               "writev() not ready");            }            sent = rc > 0 ? rc : 0;        }        if (send - prev_send == sent) {            complete = 1;        }
开发者ID:sudorails,项目名称:e_verification,代码行数:66,


示例19: st_writev

ssize_t st_writev(_st_netfd_t *fd, const struct iovec *iov, int iov_size,		  st_utime_t timeout){  ssize_t n, rv;  size_t nleft, nbyte;  int index, iov_cnt;  struct iovec *tmp_iov;  struct iovec local_iov[_LOCAL_MAXIOV];  /* Calculate the total number of bytes to be sent */  nbyte = 0;  for (index = 0; index < iov_size; index++)    nbyte += iov[index].iov_len;  rv = (ssize_t)nbyte;  nleft = nbyte;  tmp_iov = (struct iovec *) iov;	/* we promise not to modify iov */  iov_cnt = iov_size;  while (nleft > 0) {    if (iov_cnt == 1) {      if (st_write(fd, tmp_iov[0].iov_base, nleft, timeout) != (ssize_t) nleft)	rv = -1;      break;    }    if ((n = writev(fd->osfd, tmp_iov, iov_cnt)) < 0) {      if (errno == EINTR)	continue;      if (!_IO_NOT_READY_ERROR) {	rv = -1;	break;      }    } else {      if ((size_t) n == nleft)	break;      nleft -= n;      /* Find the next unwritten vector */      n = (ssize_t)(nbyte - nleft);      for (index = 0; (size_t) n >= iov[index].iov_len; index++)	n -= iov[index].iov_len;      if (tmp_iov == iov) {	/* Must copy iov's around */	if (iov_size - index <= _LOCAL_MAXIOV) {	  tmp_iov = local_iov;	} else {	  tmp_iov = calloc(1, (iov_size - index) * sizeof(struct iovec));	  if (tmp_iov == NULL)	    return -1;	}      }      /* Fill in the first partial read */      tmp_iov[0].iov_base = &(((char *)iov[index].iov_base)[n]);      tmp_iov[0].iov_len = iov[index].iov_len - n;      index++;      /* Copy the remaining vectors */      for (iov_cnt = 1; index < iov_size; iov_cnt++, index++) {	tmp_iov[iov_cnt].iov_base = iov[index].iov_base;	tmp_iov[iov_cnt].iov_len = iov[index].iov_len;      }    }    /* Wait until the socket becomes writable */    if (st_netfd_poll(fd, POLLOUT, timeout) < 0) {      rv = -1;      break;    }  }  if (tmp_iov != iov && tmp_iov != local_iov)    free(tmp_iov);  return rv;}
开发者ID:commshare,项目名称:testST,代码行数:74,


示例20: writeData

static int writeData(void* _call){    WriterAVCallData_t* call = (WriterAVCallData_t*) _call;    int len = 0;    wma_printf(10, "/n");    if (call == NULL)    {        wma_err("call data is NULL.../n");        return 0;    }    wma_printf(10, "AudioPts %lld/n", call->Pts);    if ((call->data == NULL) || (call->len <= 0))    {        wma_err("parsing NULL Data. ignoring.../n");        return 0;    }    if (call->fd < 0)    {        wma_err("file pointer < 0. ignoring .../n");        return 0;    }    if (initialHeader) {        unsigned char  PesHeader[PES_MAX_HEADER_SIZE];        if ((call->private_size <= 0) || (call->private_data == NULL))        {            wma_err("private NULL./n");            return -1;        }	struct iovec iov[2];	iov[0].iov_base = PesHeader;	iov[0].iov_len = InsertPesHeader (PesHeader, call->private_size, MPEG_AUDIO_PES_START_CODE, 0, 0);	iov[1].iov_base = call->private_data;	iov[1].iov_len = call->private_size;        len = writev(call->fd, iov, 2);        initialHeader = 0;    }    if (len > -1 && call->len > 0 && call->data)    {        unsigned char  PesHeader[PES_MAX_HEADER_SIZE];	struct iovec iov[2];	iov[0].iov_base = PesHeader;	iov[0].iov_len = InsertPesHeader (PesHeader, call->len, MPEG_AUDIO_PES_START_CODE, call->Pts, 0);	iov[1].iov_base = call->data;	iov[1].iov_len = call->len;        ssize_t l = writev(call->fd, iov, 2);	if (l > -1)		len += l;	else		len = l;    }    wma_printf(10, "wma < %d/n", len);    return len;}
开发者ID:Firmeware,项目名称:max-tdt,代码行数:72,


示例21: dotest

//.........这里部分代码省略.........				bits[chunk / 8] |= (1 << (chunk % 8));				++count;			} else {				if (xfr != csize) {					tst_brkm(TFAIL,						 NULL,						 "/tTest[%d]: xfr=%d != %d, val read.",						 me, xfr, csize);				}				++collide;				for (i = 0; i < MAXIOVCNT; i++) {					if (memcmp					    (r_iovec[i].iov_base,					     val_iovec[i].iov_base,					     r_iovec[i].iov_len)) {						tst_resm(TFAIL,							 "/tTest[%d] bad verify @ 0x%"							 PRIx64							 " for val %d count %d xfr %d.",							 me, CHUNK(chunk), val,							 count, xfr);						ft_dumpiov(&r_iovec[i]);						ft_dumpbits(bits,							    (nchunks + 7) / 8);						tst_exit();					}				}			}			/*			 * Write it.			 */			if (lseek64(fd, -xfr, 1) < 0) {				tst_brkm(TFAIL,					 NULL, "/tTest[%d]: lseek64(1) fail at %"					 PRIx64 ", errno = %d.", me,					 CHUNK(chunk), errno);			}			if ((xfr =			     writev(fd, &val_iovec[0], MAXIOVCNT)) < csize) {				if (errno == ENOSPC) {					tst_resm(TFAIL,						 "/tTest[%d]: no space, exiting.",						 me);					fsync(fd);					tst_exit();				}				tst_brkm(TFAIL,					 NULL, "/tTest[%d]: writev fail at %" PRIx64					 "x xfr %d, errno = %d.", me,					 CHUNK(chunk), xfr, errno);			}			/*			 * If hit "misc" interval, do it.			 */			if (misc_intvl && --whenmisc <= 0) {				domisc(me, fd);				whenmisc = NEXTMISC;			}			if (count + collide > 2 * nchunks)				break;		}		/*		 * End of iteration, maybe before doing all chunks.		 */		if (count < nchunks) {			//tst_resm(TINFO, "/tTest{%d} val %d stopping @ %d, collide = {%d}.",			//              me, val, count, collide);			for (i = 0; i < nchunks; i++) {				if ((bits[i / 8] & (1 << (i % 8))) == 0) {					if (lseek64(fd, CHUNK(i), 0) <					    (off64_t) 0) {						tst_brkm(TFAIL,							 NULL, "/tTest[%d]: lseek64 fail at %"							 PRIx64							 "x, errno = %d.", me,							 CHUNK(i), errno);					}					if (writev(fd, &val_iovec[0], MAXIOVCNT)					    != csize) {						tst_brkm(TFAIL,							 NULL, "/tTest[%d]: writev fail at %"							 PRIx64							 "x, errno = %d.", me,							 CHUNK(i), errno);					}				}			}		}		fsync(fd);		++misc_cnt[m_fsync];		//tst_resm(TINFO, "/tTest[%d] val %d done, count = %d, collide = %d.",		//              me, val, count, collide);		//for (i = 0; i < NMISC; i++)		//      tst_resm(TINFO, "/t/tTest[%d]: %d %s's.", me, misc_cnt[i], m_str[i]);		val0 = val++;	}}
开发者ID:TimLand,项目名称:ltp,代码行数:101,


示例22: lock

int32_t TransportUDP::write(uint8_t* buffer, uint32_t size){  {    boost::mutex::scoped_lock lock(close_mutex_);    if (closed_)    {      ROSCPP_LOG_DEBUG("Tried to write on a closed socket [%d]", sock_);      return -1;    }  }  ROS_ASSERT((int32_t)size > 0);  const uint32_t max_payload_size = max_datagram_size_ - sizeof(TransportUDPHeader);  uint32_t bytes_sent = 0;  uint32_t this_block = 0;  if (++current_message_id_ == 0)    ++current_message_id_;  while (bytes_sent < size)  {    TransportUDPHeader header;    header.connection_id_ = connection_id_;    header.message_id_ = current_message_id_;    if (this_block == 0)    {      header.op_ = ROS_UDP_DATA0;      header.block_ = (size + max_payload_size - 1) / max_payload_size;    }    else    {      header.op_ = ROS_UDP_DATAN;      header.block_ = this_block;    }    ++this_block;#if defined(WIN32)    WSABUF iov[2];    iov[0].buf = reinterpret_cast<char*>(&header);    iov[0].len = sizeof(header);    iov[1].buf = reinterpret_cast<char*>(buffer + bytes_sent);    iov[1].len = std::min(max_payload_size, size - bytes_sent);    ssize_t num_bytes;    if (WSASend(sock_, iov, 2, reinterpret_cast<LPDWORD>(&num_bytes), 0, NULL,                NULL) == SOCKET_ERROR) {        num_bytes = -1;    }#else    struct iovec iov[2];    iov[0].iov_base = &header;    iov[0].iov_len = sizeof(header);    iov[1].iov_base = buffer + bytes_sent;    iov[1].iov_len = std::min(max_payload_size, size - bytes_sent);    ssize_t num_bytes = writev(sock_, iov, 2);#endif    //usleep(100);    if (num_bytes < 0)    {      if( last_socket_error_is_would_block() )      {        ROSCPP_LOG_DEBUG("writev() failed with error [%s]", last_socket_error_string());        close();        break;      }      else      {        num_bytes = 0;      }    }    else if (num_bytes < ssize_t(sizeof(header)))    {      ROSCPP_LOG_DEBUG("Socket [%d] short write (%d bytes), closing", sock_, int(num_bytes));      close();      break;    }    else    {      num_bytes -= sizeof(header);    }    bytes_sent += num_bytes;  }  return bytes_sent;}
开发者ID:robotambassador,项目名称:robot-ambassadors,代码行数:84,


示例23: cherokee_socket_writev

/* WARNING: all parameters MUST be valid, *          NULL pointers lead to a crash. */ret_tcherokee_socket_writev (cherokee_socket_t  *socket,			const struct iovec *vector,			uint16_t            vector_len,			size_t             *pcnt_written){	int    re;	int    i;	ret_t  ret;	size_t cnt;	*pcnt_written = 0;	/* There must be something to send, otherwise behaviour is undefined	 * and as we don't want this case, we have to enforce assertions.	 */	return_if_fail (vector != NULL && vector_len > 0, ret_error);	if (likely (socket->is_tls != TLS))	{#ifdef _WIN32		int i;		size_t total;		for (i = 0, re = 0, total = 0; i < vector_len; i++) {			if (vector[i].iov_len == 0)				continue;			do {				re = send (SOCKET_FD(socket), vector[i].iov_base, vector[i].iov_len, 0);			} while ((re == -1) && (errno == EINTR));			if (re < 0)				break;			total += re;			/* if it is a partial send, then stop sending data			 */			if (re != vector[i].iov_len)				break;		}		*pcnt_written = total;		/* if we have sent at least one byte,		 * then return OK.		 */		if (likely (total > 0))			return ret_ok;		if (re == 0) {			int err = SOCK_ERRNO();			if (i == vector_len)				return ret_ok;			/* Retry later.			 */			return ret_eagain;		}#else	/* ! WIN32 */		do {			re = writev (SOCKET_FD(socket), vector, vector_len);		} while ((re == -1) && (errno == EINTR));		if (likely (re > 0)) {			*pcnt_written = (size_t) re;			return ret_ok;		}		if (re == 0) {			int i;			/* Find out whether there was something to send or not.			 */			for (i = 0; i < vector_len; i++) {				if (vector[i].iov_base != NULL && vector[i].iov_len > 0)					break;			}			if (i < vector_len)				return ret_eagain;			/* No, nothing to send, so return ok.			 */			return ret_ok;		}#endif		if (re < 0) {			int err = SOCK_ERRNO();			switch (err) {#if defined(EWOULDBLOCK) && (EWOULDBLOCK != EAGAIN)			case EWOULDBLOCK:#endif			case EAGAIN:				return ret_eagain;			case EPIPE:#ifdef ENOTCONN			case ENOTCONN:#endif//.........这里部分代码省略.........
开发者ID:nuxleus,项目名称:cherokee-webserver,代码行数:101,


示例24: showLog

//.........这里部分代码省略.........     */    const char* end = msg + strlen(msg);    size_t numLines = 0;    const char* p = msg;    while (p < end) {        if (*p++ == '/n') numLines++;    }    if (p > msg && *(p-1) != '/n') numLines++;    /*     * Create an array of iovecs large enough to write all of     * the lines with a prefix and a suffix.     */    const size_t INLINE_VECS = 6;    const size_t MAX_LINES   = ((size_t)~0)/(3*sizeof(struct iovec*));    struct iovec stackVec[INLINE_VECS];    struct iovec* vec = stackVec;    size_t numVecs;    if (numLines > MAX_LINES)        numLines = MAX_LINES;    numVecs = numLines*3;  // 3 iovecs per line.    if (numVecs > INLINE_VECS) {        vec = (struct iovec*)malloc(sizeof(struct iovec)*numVecs);        if (vec == NULL) {            msg = "LOG: write failed, no memory";            numVecs = 3;            numLines = 1;            vec = stackVec;        }    }    /*     * Fill in the iovec pointers.     */    p = msg;    struct iovec* v = vec;    int totalLen = 0;    while (numLines > 0 && p < end) {        if (prefixLen > 0) {            v->iov_base = prefixBuf;            v->iov_len = prefixLen;            totalLen += prefixLen;            v++;        }        const char* start = p;        while (p < end && *p != '/n') p++;        if ((p-start) > 0) {            v->iov_base = (void*)start;            v->iov_len = p-start;            totalLen += p-start;            v++;        }        if (*p == '/n') p++;        if (suffixLen > 0) {            v->iov_base = suffixBuf;            v->iov_len = suffixLen;            totalLen += suffixLen;            v++;        }        numLines -= 1;    }        /*     * Write the entire message to the log file with a single writev() call.     * We need to use this rather than a collection of printf()s on a FILE*     * because of multi-threading and multi-process issues.     *     * If the file was not opened with O_APPEND, this will produce interleaved     * output when called on the same file from multiple processes.     *     * If the file descriptor is actually a network socket, the writev()     * call may return with a partial write.  Putting the writev() call in     * a loop can result in interleaved data.  This can be alleviated     * somewhat by wrapping the writev call in the Mutex.     */    for(;;) {        int cc = writev(fileno(stderr), vec, v-vec);        if (cc == totalLen) break;                if (cc < 0) {            if(errno == EINTR) continue;                            /* can't really log the failure; for now, throw out a stderr */            fprintf(stderr, "+++ LOG: write failed (errno=%d)/n", errno);            break;        } else {                /* shouldn't happen when writing to file or tty */            fprintf(stderr, "+++ LOG: write partial (%d of %d)/n", cc, totalLen);            break;        }    }    /* if we allocated storage for the iovecs, free it */    if (vec != stackVec)        free(vec);}
开发者ID:UbuntuSTE,项目名称:android_system_core,代码行数:101,


示例25: write_message

static int write_message(Server *s, const char *buf, struct ucred *ucred) {        ssize_t k;        char priority[6], pid[16];        struct iovec iovec[5];        unsigned i = 0;        char *process = NULL;        int r = 0;        int prio = LOG_USER | LOG_INFO;        assert(s);        assert(buf);        parse_syslog_priority((char**) &buf, &prio);        if (*buf == 0)                return 0;        if ((prio & LOG_FACMASK) == 0)                prio = LOG_USER | LOG_PRI(prio);        /* First, set priority field */        snprintf(priority, sizeof(priority), "<%i>", prio);        char_array_0(priority);        IOVEC_SET_STRING(iovec[i++], priority);        /* Second, skip date */        skip_date(&buf);        /* Then, add process if set */        if (read_process(&buf, &iovec[i]) > 0)                i++;        else if (ucred &&                 ucred->pid > 0 &&                 get_process_name(ucred->pid, &process) >= 0)                IOVEC_SET_STRING(iovec[i++], process);        /* Skip the stored PID if we have a better one */        if (ucred) {                snprintf(pid, sizeof(pid), "[%lu]: ", (unsigned long) ucred->pid);                char_array_0(pid);                IOVEC_SET_STRING(iovec[i++], pid);                skip_pid(&buf);                if (*buf == ':')                        buf++;                buf += strspn(buf, WHITESPACE);        }        /* Is the remaining message empty? */        if (*buf) {                /* And the rest is the message */                IOVEC_SET_STRING(iovec[i++], buf);                IOVEC_SET_STRING(iovec[i++], "/n");                if ((k = writev(s->kmsg_fd, iovec, i)) <= 0) {                        log_error("Failed to write log message to kmsg: %s", k < 0 ? strerror(errno) : "short write");                        r = k < 0 ? -errno : -EIO;                }        }        free(process);        return r;}
开发者ID:terralinux,项目名称:systemd,代码行数:67,


示例26: echo_main

//.........这里部分代码省略.........	char *arg;	char *p;#if !ENABLE_FEATURE_FANCY_ECHO	enum {		eflag = '//',		nflag = 1,  /* 1 -- print '/n' */	};	arg = *++argv;	if (!arg)		goto newline_ret;#else	char nflag = 1;	char eflag = 0;	while (1) {		arg = *++argv;		if (!arg)			goto newline_ret;		if (*arg != '-')			break;		/* If it appears that we are handling options, then make sure		 * that all of the options specified are actually valid.		 * Otherwise, the string should just be echoed.		 */		p = arg + 1;		if (!*p)	/* A single '-', so echo it. */			goto just_echo;		do {			if (!strrchr("neE", *p))				goto just_echo;		} while (*++p);		/* All of the options in this arg are valid, so handle them. */		p = arg + 1;		do {			if (*p == 'n')				nflag = 0;			if (*p == 'e')				eflag = '//';		} while (*++p);	} just_echo:#endif	while (1) {		/* arg is already == *argv and isn't NULL */		int c;		cur_io->iov_base = p = arg;		if (!eflag) {			/* optimization for very common case */			p += strlen(arg);		} else while ((c = *arg++)) {			if (c == eflag) {	/* Check for escape seq. */				if (*arg == 'c') {					/* '/c' means cancel newline and					 * ignore all subsequent chars. */					cur_io->iov_len = p - (char*)cur_io->iov_base;					cur_io++;					goto ret;				}#if !ENABLE_FEATURE_FANCY_ECHO				/* SUSv3 specifies that octal escapes must begin with '0'. */				if ( (((unsigned char)*arg) - '1') >= 7)#endif				{					/* Since SUSv3 mandates a first digit of 0, 4-digit octals					* of the form /0### are accepted. */					if (*arg == '0' && ((unsigned char)(arg[1]) - '0') < 8) {						arg++;					}					/* bb_process_escape_sequence can handle nul correctly */					c = bb_process_escape_sequence( (void*) &arg);				}			}			*p++ = c;		}		arg = *++argv;		if (arg)			*p++ = ' ';		cur_io->iov_len = p - (char*)cur_io->iov_base;		cur_io++;		if (!arg)			break;	} newline_ret:	if (nflag) {		cur_io->iov_base = (char*)"/n";		cur_io->iov_len = 1;		cur_io++;	} ret:	/* TODO: implement and use full_writev? */	return writev(1, io, (cur_io - io)) >= 0;}
开发者ID:ph4r05,项目名称:boinc,代码行数:101,


示例27: status_vprintf

int status_vprintf(const char *status, bool ellipse, bool ephemeral, const char *format, va_list ap) {        static const char status_indent[] = "         "; /* "[" STATUS "] " */        _cleanup_free_ char *s = NULL;        _cleanup_close_ int fd = -1;        struct iovec iovec[6] = {};        int n = 0;        static bool prev_ephemeral;        assert(format);        /* This is independent of logging, as status messages are         * optional and go exclusively to the console. */        if (vasprintf(&s, format, ap) < 0)                return log_oom();        fd = open_terminal("/dev/console", O_WRONLY|O_NOCTTY|O_CLOEXEC);        if (fd < 0)                return fd;        if (ellipse) {                char *e;                size_t emax, sl;                int c;                c = fd_columns(fd);                if (c <= 0)                        c = 80;                sl = status ? sizeof(status_indent)-1 : 0;                emax = c - sl - 1;                if (emax < 3)                        emax = 3;                e = ellipsize(s, emax, 50);                if (e) {                        free(s);                        s = e;                }        }        if (prev_ephemeral)                IOVEC_SET_STRING(iovec[n++], "/r" ANSI_ERASE_TO_END_OF_LINE);        prev_ephemeral = ephemeral;        if (status) {                if (!isempty(status)) {                        IOVEC_SET_STRING(iovec[n++], "[");                        IOVEC_SET_STRING(iovec[n++], status);                        IOVEC_SET_STRING(iovec[n++], "] ");                } else                        IOVEC_SET_STRING(iovec[n++], status_indent);        }        IOVEC_SET_STRING(iovec[n++], s);        if (!ephemeral)                IOVEC_SET_STRING(iovec[n++], "/n");        if (writev(fd, iovec, n) < 0)                return -errno;        return 0;}
开发者ID:arthur-c,项目名称:systemd,代码行数:64,


示例28: module_generate

void module_generate(int fd){    size_t i;    DIR* proc_listing;    /* Set up an iovec array. We'll fill this with buffers that'll     * be part of our output, growing it dynamically as necessary. */    /* The number of elements in the array that we've used. */    size_t vec_length = 0;    /* The allocate size of the array. */    size_t vec_size = 16;    /* The array of iovcec elements. */    struct iovec* vec = (struct iovec*)            xmalloc(vec_size * sizeof(struct iovec));    /* The first buffer is the HTML source for the start of the pate. */    vec[vec_length].iov_base = page_start;    vec[vec_length].iov_len = strlen(page_start);    ++vec_length;    /* Start a directory listing for /proc. */    proc_listing = opendir("/proc");    if (proc_listing == NULL) {        system_error("opendir");    }    /* Loop over directory entries in /proc. */    while (1) {        struct dirent* proc_entry;        const char* name;        pid_t pid;        char* process_info;        /* Get the next entry in /proc. */        proc_entry = readdir(proc_listing);        if (proc_entry == NULL) {            /* We've hit the end of the listing. */            break;        }        /* If this entry is not composed purely of digits, it's not a         * process directory, so skip it. */        name = proc_entry->d_name;        if (strspn(name, "0123456789") != strlen(name)) {            continue;        }        /* The name of the entry is the process ID. */        pid = (pid_t) atoi(name);        /* Generate HTML for a table row describing this process. */        process_info = format_process_info(pid);        if (process_info == NULL) {            /* Something went wrong. The process may have vanished             * while we were looking at it. Use a placeholder row             * instead. */            process_info = "    <tr><td colspan=/"5/">ERROR</td></tr>";        }        /* Make sure the iovec array is long enough to hold this buffer         * (plus one more because we'll add an extra element when we're         * done listing processes). If not, grow it to twice its current         * size. */        if (vec_length == vec_size - 1) {            vec_size *= 2;            vec = xrealloc(vec, vec_size * sizeof(struct iovec));        }        /* Store this buffer as the next element of the array. */        vec[vec_length].iov_base = process_info;        vec[vec_length].iov_len = strlen(process_info);        ++vec_length;    }    /* End the directory listing operation. */    closedir(proc_listing);    /* Add one last buffer with HTML that ends the page. */    vec[vec_length].iov_base = page_end;    vec[vec_length].iov_len = strlen(page_end);    ++vec_length;    /* Output the entire page to the client file descriptor all     * at once. */    writev(fd, vec, vec_length);    /* Deallocate the buffers we created. The first and last are     * static and should not be deallocated. */    for (i = 1; i < vec_length - 1; ++i) {        free(vec[i].iov_base);    }    /* Deallocate the iovec array. */    free(vec);}
开发者ID:pandolia,项目名称:advanced-linux-program,代码行数:98,


示例29: output_Flush

/***************************************************************************** * output_Flush *****************************************************************************/static void output_Flush( output_t *p_output ){    packet_t *p_packet = p_output->p_packets;    int i_block_cnt = output_BlockCount( p_output );    struct iovec p_iov[i_block_cnt + 2];    uint8_t p_rtp_hdr[RTP_HEADER_SIZE];    int i_iov = 0, i_payload_len, i_block;    if ( (p_output->config.i_config & OUTPUT_RAW) )    {        p_iov[i_iov].iov_base = &p_output->raw_pkt_header;        p_iov[i_iov].iov_len = sizeof(struct udprawpkt);        i_iov++;    }    if ( !(p_output->config.i_config & OUTPUT_UDP) )    {        p_iov[i_iov].iov_base = p_rtp_hdr;        p_iov[i_iov].iov_len = sizeof(p_rtp_hdr);        rtp_set_hdr( p_rtp_hdr );        rtp_set_type( p_rtp_hdr, RTP_TYPE_TS );        rtp_set_seqnum( p_rtp_hdr, p_output->i_seqnum++ );        rtp_set_timestamp( p_rtp_hdr,                           p_output->i_ref_timestamp                            + (p_packet->i_dts - p_output->i_ref_wallclock)                               * 9 / 100 );        rtp_set_ssrc( p_rtp_hdr, p_output->config.pi_ssrc );        i_iov++;    }    for ( i_block = 0; i_block < p_packet->i_depth; i_block++ )    {        /* Do pid mapping here if needed.         * save the original pid in the block.         * set the pid to the new pid         * later we re-instate the old pid for the next output         */        if ( b_do_remap || p_output->b_do_remap ) {            block_t *p_block = p_packet->pp_blocks[i_block];            uint16_t i_pid = ts_get_pid( p_block->p_ts );            p_block->tmp_pid = UNUSED_PID;            if ( p_output->pi_newpids[i_pid] != UNUSED_PID )            {                uint16_t i_newpid = p_output->pi_newpids[i_pid];                /* Need to map this pid to the new pid */                ts_set_pid( p_block->p_ts, i_newpid );                p_block->tmp_pid = i_pid;            }        }        p_iov[i_iov].iov_base = p_packet->pp_blocks[i_block]->p_ts;        p_iov[i_iov].iov_len = TS_SIZE;        i_iov++;    }    for ( ; i_block < i_block_cnt; i_block++ )    {        p_iov[i_iov].iov_base = p_pad_ts;        p_iov[i_iov].iov_len = TS_SIZE;        i_iov++;    }        if ( (p_output->config.i_config & OUTPUT_RAW) )    {        i_payload_len = 0;        for ( i_block = 1; i_block < i_iov; i_block++ ) {            i_payload_len += p_iov[i_block].iov_len;         }        p_output->raw_pkt_header.udph.len = htons(sizeof(struct udpheader) + i_payload_len);    }    if ( writev( p_output->i_handle, p_iov, i_iov ) < 0 )    {        msg_Err( NULL, "couldn't writev to %s (%s)",                 p_output->config.psz_displayname, strerror(errno) );    }    /* Update the wallclock because writev() can take some time. */    i_wallclock = mdate();    for ( i_block = 0; i_block < p_packet->i_depth; i_block++ )    {        p_packet->pp_blocks[i_block]->i_refcount--;        if ( !p_packet->pp_blocks[i_block]->i_refcount )            block_Delete( p_packet->pp_blocks[i_block] );        else if ( b_do_remap || p_output->b_do_remap ) {            /* still referenced so re-instate the orignial pid if remapped */            block_t * p_block = p_packet->pp_blocks[i_block];            if (p_block->tmp_pid != UNUSED_PID)                ts_set_pid( p_block->p_ts, p_block->tmp_pid );        }    }    p_output->p_packets = p_packet->p_next;    free( p_packet );    if ( p_output->p_packets == NULL )//.........这里部分代码省略.........
开发者ID:BATYD-Turksat,项目名称:dvblast,代码行数:101,



注:本文中的writev函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ writex函数代码示例
C++ writer函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。