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

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

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

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

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

示例1: reset_main

void reset_main(void){  int fd = tty_fd();  // man 4 console_codes: reset terminal is ESC (no left bracket) c  xwrite(fd<0 ? 1 : fd, "/033c", 2);}
开发者ID:emaste,项目名称:toybox,代码行数:7,


示例2: expandhere

voidexpandhere(union node *arg, int fd){	herefd = fd;	expandarg(arg, NULL, 0);	xwrite(fd, stackblock(), expdest - stackblock());}
开发者ID:VargMon,项目名称:netbsd-cvs-mirror,代码行数:7,


示例3: snap_log_write

int snap_log_write(uint32_t idx, const char *tag, unsigned char *sha1){	int fd, ret = -1;	struct strbuf buf = STRBUF_INIT;	struct snap_log log = { .idx = idx,				.time = time(NULL) };	pstrcpy(log.tag, SD_MAX_SNAPSHOT_TAG_LEN, tag);	memcpy(log.sha1, sha1, SHA1_DIGEST_SIZE);	fd = open(snap_log_path, O_WRONLY | O_APPEND);	if (fd < 0) {		sd_err("%m");		goto out;	}	strbuf_reset(&buf);	strbuf_add(&buf, &log, sizeof(log));	ret = xwrite(fd, buf.buf, buf.len);	if (ret != buf.len)		goto out_close;	ret = 0;out_close:	close(fd);out:	strbuf_release(&buf);	return ret;}
开发者ID:SongWuCloud,项目名称:ACStor,代码行数:28,


示例4: disp_too_much

static int	disp_too_much(t_list *st_list){  char		read_buf[256];  char		line[256];  char		*buf;  if ((buf = get_set_from_list(COMPLETION_CHOICE_STR)) &&      buf[0] == '0')    return (-1);  if (_list_sz(st_list) < MAX_CHOICE_DIP)    return (-1);  memset(read_buf, 0, 256);  sprintf(line, "Display all %d possibilities ? (y||n)/n", _list_sz(st_list));  xwrite(1, line, strlen(line));  while (read_buf[0] != 'y' && read_buf[0] != 'n')    {      memset(read_buf, '/0', 256);      xread(0, read_buf, sizeof(read_buf));      if (read_buf[0] == 'y' || read_buf[0] == '/t')	return (TRUE);      else if (read_buf[0] == 'n')	{	  apply_term("up");	  return (FALSE);	}    }  return (TRUE);}
开发者ID:NegMozzie,项目名称:42sh,代码行数:28,


示例5: fwrite_sha1_file

static size_t fwrite_sha1_file(void *ptr, size_t eltsize, size_t nmemb,			       void *data){	unsigned char expn[4096];	size_t size = eltsize * nmemb;	int posn = 0;	struct object_request *obj_req = (struct object_request *)data;	do {		ssize_t retval = xwrite(obj_req->local,				       (char *) ptr + posn, size - posn);		if (retval < 0)			return posn;		posn += retval;	} while (posn < size);	obj_req->stream.avail_in = size;	obj_req->stream.next_in = ptr;	do {		obj_req->stream.next_out = expn;		obj_req->stream.avail_out = sizeof(expn);		obj_req->zret = inflate(&obj_req->stream, Z_SYNC_FLUSH);		SHA1_Update(&obj_req->c, expn,			    sizeof(expn) - obj_req->stream.avail_out);	} while (obj_req->stream.avail_in && obj_req->zret == Z_OK);	data_received++;	return size;}
开发者ID:Jatinpurohit,项目名称:git,代码行数:27,


示例6: chksum_and_xwrite

static void chksum_and_xwrite(int fd, struct tar_header_t* hp){	/* POSIX says that checksum is done on unsigned bytes	 * (Sun and HP-UX gets it wrong... more details in	 * GNU tar source) */	const unsigned char *cp;	int chksum, size;	strcpy(hp->magic, "ustar  ");	/* Calculate and store the checksum (i.e., the sum of all of the bytes of	 * the header).  The checksum field must be filled with blanks for the	 * calculation.  The checksum field is formatted differently from the	 * other fields: it has 6 digits, a null, then a space -- rather than	 * digits, followed by a null like the other fields... */	memset(hp->chksum, ' ', sizeof(hp->chksum));	cp = (const unsigned char *) hp;	chksum = 0;	size = sizeof(*hp);	do { chksum += *cp++; } while (--size);	putOctal(hp->chksum, sizeof(hp->chksum)-1, chksum);	/* Now write the header out to disk */	xwrite(fd, hp, sizeof(*hp));}
开发者ID:NuclearAndroidProject1,项目名称:android_external_busybox,代码行数:25,


示例7: snprintf

/** * 向好友请求文件数据. * @param sock tcp socket * @param pal class PalInfo * @param packetno 好友消息的包编号 * @param fileid 文件ID标识 * @param offset 文件偏移量 * @return 消息发送成功与否 */bool Command::SendAskData(int sock, PalInfo *pal, uint32_t packetno,                                 uint32_t fileid, int64_t offset){        char attrstr[35];       //8+1+8+1+16 +1 =35        struct sockaddr_in addr;        char *iptuxstr = "iptux";        snprintf(attrstr, 35, "%" PRIx32 ":%" PRIx32 ":%" PRIx64,                                         packetno, fileid, offset);        //IPMSG和Feiq的命令字段都是只有IPMSG_GETFILEDATA,使用(IPMSG_FILEATTACHOPT | IPMSG_GETFILEDATA)	//会产生一些潜在的不兼容问题,所以在发往非iptux时只使用IPMSG_GETFILEDATA        if(strstr(pal->version,iptuxstr))            CreateCommand(IPMSG_FILEATTACHOPT | IPMSG_GETFILEDATA, attrstr);        else            CreateCommand(IPMSG_GETFILEDATA, attrstr);        ConvertEncode(pal->encode);        bzero(&addr, sizeof(addr));        addr.sin_family = AF_INET;        addr.sin_port = htons(IPTUX_DEFAULT_PORT);        addr.sin_addr.s_addr = pal->ipv4;        if (((connect(sock, (struct sockaddr *)&addr, sizeof(addr)) == -1)                         && (errno != EINTR))                 || (xwrite(sock, buf, size) == -1))                return false;        return true;}
开发者ID:zdmilk,项目名称:my_iptux,代码行数:38,


示例8: write_config

static int write_config(void){	int fd, ret;	void *jd;	fd = open(config_path, O_DSYNC | O_WRONLY | O_CREAT, def_fmode);	if (fd < 0) {		eprintf("failed to open config file, %m/n");		return SD_RES_EIO;	}	jd = jrnl_begin(&config, sizeof(config), 0, config_path, jrnl_path);	if (!jd) {		eprintf("failed to write config data to journal, %m/n");		ret = SD_RES_EIO;		goto out;	}	ret = xwrite(fd, &config, sizeof(config));	if (ret != sizeof(config)) {		eprintf("failed to write config data, %m/n");		ret = SD_RES_EIO;	} else		ret = SD_RES_SUCCESS;	jrnl_end(jd);out:	close(fd);	return ret;}
开发者ID:ChrisChung,项目名称:sheepdog,代码行数:30,


示例9: expandhere

voidexpandhere(shinstance *psh, union node *arg, int fd){	psh->herefd = fd;	expandarg(psh, arg, (struct arglist *)NULL, 0);	xwrite(psh, fd, stackblock(psh), psh->expdest - stackblock(psh));}
开发者ID:dezelin,项目名称:kBuild,代码行数:7,


示例10: pipehandler

/** * Handle a signal in an async-safe fashion. The signal is written * to a pipe monitored in our main select() loop and will be handled * just as the other file descriptors there are. * @param signo the signal number */static void pipehandler(int signo){	if(signalpipe[WRITE] > -1) {		/* write is async safe. write the signal number to the pipe. */		xwrite(signalpipe[WRITE], &signo, sizeof(int));	}}
开发者ID:flysurfer28,项目名称:onkyocontrol,代码行数:13,


示例11: dopreload

static voiddopreload(){	char buf[MAXBUF], *p;	int fd, rv;		snprintf(buf, sizeof(buf), "LD_PRELOAD=/tmp/tmplibckptXXXXXX");	p = buf+strlen("LD_PRELOAD=");	fd = mkstemp(p);	if(0 > fd){		fprintf(stderr, "ckpt I/O error/n");		exit(1);	}	rv = xwrite(fd, libckpt, libckptlen);	if(0 > rv){		fprintf(stderr, "ckpt I/O error/n");		exit(1);	}	close(fd);	if(0 > putenv(buf)){		fprintf(stderr, "ckpt error/n");		exit(1);	}}
开发者ID:Federico2014,项目名称:edg4x-rose,代码行数:26,


示例12: do_internal_write_append

intdo_internal_write_append (const char *path, const char *content, size_t size){    int fd;    CHROOT_IN;    fd = open (path, O_WRONLY|O_APPEND|O_CREAT|O_NOCTTY|O_CLOEXEC, 0666);    CHROOT_OUT;    if (fd == -1) {        reply_with_perror ("open: %s", path);        return -1;    }    if (xwrite (fd, content, size) == -1) {        reply_with_perror ("write");        close (fd);        return -1;    }    if (close (fd) == -1) {        reply_with_perror ("close: %s", path);        return -1;    }    return 0;}
开发者ID:yumingfei,项目名称:libguestfs,代码行数:27,


示例13: snap_log_write

int snap_log_write(uint32_t epoch, unsigned char *sha1, int user){	int fd, ret = -1;	struct strbuf buf = STRBUF_INIT;	struct snap_log log = { .epoch = epoch,				.time = time(NULL) };	memcpy(log.sha1, sha1, SHA1_LEN);	strbuf_addstr(&buf, farm_dir);	strbuf_addf(&buf, "/%s", user ? "user_snap" : "sys_snap");	fd = open(buf.buf, O_WRONLY | O_APPEND);	if (fd < 0) {		dprintf("%m/n");		goto out;	}	strbuf_reset(&buf);	strbuf_add(&buf, &log, sizeof(log));	ret = xwrite(fd, buf.buf, buf.len);	if (ret != buf.len)		ret = -1;	close(fd);out:	strbuf_release(&buf);	return ret;}
开发者ID:Nexenta,项目名称:sheepdog,代码行数:28,


示例14: writeheader

static void writeheader(const char *path, struct stat *sb, int type){	struct tar_header_t header;	int i, sum;	memset(&header, 0, TAR_BLOCK_SIZE);	strcpy(header.name, path);	sprintf(header.mode, "%o", sb->st_mode & 0777);	/* careful to not overflow fields! */	sprintf(header.uid, "%o", sb->st_uid & 07777777);	sprintf(header.gid, "%o", sb->st_gid & 07777777);	sprintf(header.size, "%o", (unsigned)sb->st_size);	sprintf(header.mtime, "%llo", sb->st_mtime & 077777777777LL);	header.typeflag = type;	strcpy(header.magic, "ustar  "); /* like GNU tar */	/* Calculate and store the checksum (the sum of all of the bytes of	 * the header). The checksum field must be filled with blanks for the	 * calculation. The checksum field is formatted differently from the	 * other fields: it has 6 digits, a NUL, then a space -- rather than	 * digits, followed by a NUL like the other fields... */	header.chksum[7] = ' ';	sum = ' ' * 7;	for (i = 0; i < TAR_BLOCK_SIZE; i++)		sum += ((unsigned char*)&header)[i];	sprintf(header.chksum, "%06o", sum);	xwrite(STDOUT_FILENO, &header, TAR_BLOCK_SIZE);}
开发者ID:nawawi,项目名称:busybox,代码行数:29,


示例15: release_write_buf

static voidrelease_write_buf(test_data *td, struct iovec* vecs, int n_vecs){  test_state *ps = (test_state *)td->data;  assert(vecs == &ps->buffer && n_vecs == 1);  xwrite(ps->sv[0], vecs[0].iov_base, vecs[0].iov_len);}
开发者ID:smowton,项目名称:ipc-bench,代码行数:7,


示例16: convert

static void ATTRIBUTE_NORETURN convert(const smalluint flags){	size_t read_chars = 0, in_index = 0, out_index = 0, c, coded, last = -1;	for (;;) {		/* If we're out of input, flush output and read more input. */		if (in_index == read_chars) {			if (out_index) {				xwrite(STDOUT_FILENO, (char *)poutput, out_index);				out_index = 0;			}			if ((read_chars = read(STDIN_FILENO, bb_common_bufsiz1, BUFSIZ)) <= 0) {				if (write(STDOUT_FILENO, (char *)poutput, out_index) != out_index)					bb_perror_msg(bb_msg_write_error);				exit(EXIT_SUCCESS);			}			in_index = 0;		}		c = bb_common_bufsiz1[in_index++];		coded = pvector[c];		if ((flags & TR_OPT_delete) && pinvec[c])			continue;		if ((flags & TR_OPT_squeeze_reps) && last == coded &&			(pinvec[c] || poutvec[coded]))			continue;		poutput[out_index++] = last = coded;	}	/* NOTREACHED */}
开发者ID:AlickHill,项目名称:Lantern,代码行数:29,


示例17: main_loop

int     main_loop(int error, t_serv_info *servinfo, t_dest_info *dest){  fd_set		readfds;  fd_set		writefds;  int			maxfd;  int			cs1;  char			*msg;  msg = "BIENVENU/n";  FD_ZERO(&readfds);  FD_ZERO(&writefds);  if (select(servinfo->sock, &readfds, &writefds, NULL, NULL))    {      printf("lool/n");      if (FD_ISSET(servinfo->sock, &readfds))	cs1=accept(servinfo->sock, (struct sockaddr *)&servinfo->sin_client,		   (socklen_t *)&servinfo->client_len);      if (cs1 > 1)	{	  xwrite(cs1, msg, strlen(msg));	  logg(servinfo, dest);	}    }  return (0);}
开发者ID:noelq,项目名称:EpiHistory,代码行数:28,


示例18: xfclose

void	xfclose(FILE *stream){  if (fclose(stream) == EOF)    {      xwrite(2, "fclose failed/n", 14);      exit(EXIT_FAILURE);    }}
开发者ID:roughi,项目名称:my_ftp,代码行数:8,


示例19: print_outbuf

static void print_outbuf(void){	int sz = cur_outbuf - outbuf;	if (sz > 0) {		xwrite(STDOUT_FILENO, outbuf, sz);		cur_outbuf = outbuf;	}}
开发者ID:AllardJ,项目名称:Tomato,代码行数:8,


示例20: xpclose

void	xpclose(FILE *stream){  if (pclose(stream) == -1)    {      xwrite(2, "pclose failed/n", 14);      exit(EXIT_FAILURE);    }}
开发者ID:roughi,项目名称:my_ftp,代码行数:8,


示例21: chmod_file

void	chmod_file(char *buffer, struct s_static_client *br){  char	mode[CMD];  strcpy(mode, "SITE CHMOD ");  get_info_c(&(mode[11]), buffer, my_strlen(buffer));  xwrite(br->s_fd, mode, my_strlen(mode));}
开发者ID:roughi,项目名称:my_ftp,代码行数:8,


示例22: my_putstr

void		my_putstr(char *str){  int		e;  e = 0;  while (str[e++]);  xwrite(1, str, e);}
开发者ID:acotillard,项目名称:old_tech_time,代码行数:8,


示例23: write_file

int write_file(int fd, u_char type, int seq_count, ulong len, u_char * content) {    if (xwrite(fd, &type, sizeof(type)) < 0){        perror("xwrite:");        EXIT_TRACE1("xwrite type fails/n");        return -1;    }    if (xwrite(fd, &seq_count, sizeof(seq_count)) < 0){        EXIT_TRACE1("xwrite content fails/n");    }    if (xwrite(fd, &len, sizeof(len)) < 0){       EXIT_TRACE1("xwrite content fails/n");    }    if (xwrite(fd, content, len) < 0){       EXIT_TRACE1("xwrite content fails/n");    }    return 0;}
开发者ID:baskarang,项目名称:icnc,代码行数:17,


示例24: entering_passive

void		entering_passive(struct s_static_socket *br){  int		pasvsock;  size_t	port;  my_putstr("PASV Request/n");  if (br->pasv == -1 && br->ctrl == -1)    {      port = 1025;      if ((pasvsock = init_pasv_socket(&port)) > -1)	get_host_and_connect(br, pasvsock, port);      else	xwrite(br->cs, "425 Opening data connection failed/n", 35);    }  else    xwrite(br->cs, "125 Data connection already open/n", 33);}
开发者ID:roughi,项目名称:my_ftp,代码行数:17,


示例25: restore_interactive

void restore_interactive(target_context_t *tc){    char c = '!';    if(strcmp(tc->medium, "serial"))        target_set_medium(tc, "serial");    xwrite(tc->portfd, &c, 1);}
开发者ID:miettal,项目名称:armadillo420_standard_linux314,代码行数:8,


示例26: write_signature

void			write_signature(char *signature, int fd){  int			count;  count = -1;  while (++count != TWO_OCT)    xwrite(fd, &signature[count], 1);}
开发者ID:m2omou,项目名称:raytracer,代码行数:8,


示例27: notify_parent

static void notify_parent(void){	/*	 * execvp failed.  If possible, we'd like to let start_command	 * know, so failures like ENOENT can be handled right away; but	 * otherwise, finish_command will still report the error.	 */	xwrite(child_notifier, "", 1);}
开发者ID:1742314348,项目名称:git,代码行数:9,


示例28: writeFinish

void writeFinish(int fd){    u_char type = TYPE_FINISH;    if (xwrite(fd, &type, sizeof(type)) < 0){        perror("xwrite:");        EXIT_TRACE1("xwrite type fails/n");        return;    }    CLOSE(fd);}
开发者ID:baskarang,项目名称:icnc,代码行数:9,


示例29: write_ar_archive

static int write_ar_archive(archive_handle_t *handle){    struct stat st;    archive_handle_t *out_handle;    char *temp_fn = NULL;    xfstat(handle->src_fd, &st, handle->ar__name);    /* if archive exists, create a new handle for output.     * we create it in place of the old one.     */    if (st.st_size != 0) {        out_handle = init_handle();#if !ENABLE_PLATFORM_MINGW32        xunlink(handle->ar__name);        out_handle->src_fd = xopen(handle->ar__name, O_WRONLY | O_CREAT | O_TRUNC);#else        /* can't unlink open file, create temporary output file */        temp_fn = xasprintf("%sXXXXXX", handle->ar__name);        out_handle->src_fd = xmkstemp(temp_fn);#endif        out_handle->accept = handle->accept;    } else {        out_handle = handle;    }    handle->ar__out = out_handle;    xwrite(out_handle->src_fd, AR_MAGIC "/n", AR_MAGIC_LEN + 1);    out_handle->offset += AR_MAGIC_LEN + 1;    /* skip to the end of the archive if we have to append stuff */    if (st.st_size != 0) {        handle->filter = filter_replaceable;        handle->action_data = copy_data;        unpack_ar_archive(handle);    }    while (write_ar_header(out_handle) == 0)        continue;    /* optional, since we exit right after we return */    if (ENABLE_FEATURE_CLEAN_UP || ENABLE_PLATFORM_MINGW32) {        close(handle->src_fd);        if (out_handle->src_fd != handle->src_fd)            close(out_handle->src_fd);    }#if ENABLE_PLATFORM_MINGW32    if ( temp_fn != NULL ) {        xrename(temp_fn, handle->ar__name);        free(temp_fn);    }#endif    return EXIT_SUCCESS;}
开发者ID:staalmannen,项目名称:busybox-w32,代码行数:57,


示例30: soft_interrupt_handler

/** Catches thrown signals. Performs necessary cleanup to ensure database is * in a consistent state. * @param signum the thrown signal */static void soft_interrupt_handler(int signum){	if(signum == SIGINT) {		const char msg[] = "/nInterrupt signal received/n";		xwrite(STDERR_FILENO, msg, ARRAYSIZE(msg) - 1);	} else {		const char msg[] = "/nHangup signal received/n";		xwrite(STDERR_FILENO, msg, ARRAYSIZE(msg) - 1);	}	if(alpm_trans_interrupt(config->handle) == 0) {		/* a transaction is being interrupted, don't exit pacman yet. */		return;	}	alpm_unlock(config->handle);	/* output a newline to be sure we clear any line we may be on */	xwrite(STDOUT_FILENO, "/n", 1);	_Exit(128 + signum);}
开发者ID:AWhetter,项目名称:pacman,代码行数:22,



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


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