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

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

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

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

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

示例1: screen_read_close

static void screen_read_close(void){	unsigned i, j;	int vcsa_fd;	char *data;	// Close & re-open vcsa in case they have swapped virtual consoles	vcsa_fd = xopen(G.vcsa_name, O_RDONLY);	xread(vcsa_fd, &G.remote, 4);	i = G.remote.cols * 2;	G.first_line_offset = G.y * i;	i *= G.remote.lines;	if (G.data == NULL) {		G.size = i;		G.data = xzalloc(2 * i);	}	else if (G.size != i) {		cleanup(1);	}	data = G.data + G.current;	xread(vcsa_fd, data, G.size);	close(vcsa_fd);	for (i = 0; i < G.remote.lines; i++) {		for (j = 0; j < G.remote.cols; j++, NEXT(data)) {			unsigned x = j - G.x; // if will catch j < G.x too			unsigned y = i - G.y; // if will catch i < G.y too			if (CHAR(data) < ' ')				CHAR(data) = ' ';			if (y >= G.height || x >= G.width)				DATA(data) = 0;		}	}}
开发者ID:Ayyayay,项目名称:busybox,代码行数:34,


示例2: siemens_meas_setup

static bool siemens_meas_setup(int fd, struct hdr_s* hdr){	off_t start = 0;	xseek(fd, start);	xread(fd, hdr, sizeof(struct hdr_s));	// check for VD version	bool vd = ((hdr->offset < 10000) && (hdr->nscans < 64));	if (vd) {			debug_printf(DP_INFO, "VD Header. MeasID: %d FileID: %d Scans: %d/n",					hdr->measid, hdr->fileid, hdr->nscans);		start += hdr->datoff;		xseek(fd, start);		// reread offset		xread(fd, &hdr->offset, sizeof(hdr->offset));	} else {		debug_printf(DP_INFO, "VB Header./n");		hdr->nscans = 1;	}	start += hdr->offset;	xseek(fd, start);        return vd;}
开发者ID:jaeseung16,项目名称:bart,代码行数:34,


示例3: unpackExtent

static voidunpackExtent(    Extent *const xi,  // input    Extent *const xo,  // output    f_expand *const f_decompress,    f_unfilter *f_unf){    while (xo->size) {        struct b_info h;        //   Note: if h.sz_unc == h.sz_cpr then the block was not        //   compressible and is stored in its uncompressed form.        // Read and check block sizes.        xread(xi, (char *)&h, sizeof(h));        if (h.sz_unc == 0) {                     // uncompressed size 0 -> EOF            if (h.sz_cpr != UPX_MAGIC_LE32)      // h.sz_cpr must be h->magic                err_exit(2);            if (xi->size != 0)                 // all bytes must be written                err_exit(3);            break;        }        if (h.sz_cpr <= 0) {            err_exit(4);ERR_LAB        }        if (h.sz_cpr > h.sz_unc        ||  h.sz_unc > xo->size ) {            err_exit(5);        }        // Now we have:        //   assert(h.sz_cpr <= h.sz_unc);        //   assert(h.sz_unc > 0 && h.sz_unc <= blocksize);        //   assert(h.sz_cpr > 0 && h.sz_cpr <= blocksize);        if (h.sz_cpr < h.sz_unc) { // Decompress block            nrv_uint out_len = h.sz_unc;  // EOF for lzma            int const j = (*f_decompress)((unsigned char *)xi->buf, h.sz_cpr,                (unsigned char *)xo->buf, &out_len, *(int *)(void *)&h.b_method );            if (j != 0 || out_len != (nrv_uint)h.sz_unc)                err_exit(7);            // Skip Ehdr+Phdrs: separate 1st block, not filtered            if (h.b_ftid!=0 && f_unf  // have filter            &&  ((512 < out_len)  // this block is longer than Ehdr+Phdrs              || (xo->size==(unsigned)h.sz_unc) )  // block is last in Extent            ) {                (*f_unf)((unsigned char *)xo->buf, out_len, h.b_cto8, h.b_ftid);            }            xi->buf  += h.sz_cpr;            xi->size -= h.sz_cpr;        }        else { // copy literal block            xread(xi, xo->buf, h.sz_cpr);        }        xo->buf  += h.sz_unc;        xo->size -= h.sz_unc;    }
开发者ID:tfauck,项目名称:upx,代码行数:57,


示例4: do_epoch_log_read

static int do_epoch_log_read(uint32_t epoch, struct sd_node *nodes, int len,			     time_t *timestamp){	int fd, ret, nr_nodes;	char path[PATH_MAX];	struct stat epoch_stat;	snprintf(path, sizeof(path), "%s%08u", epoch_path, epoch);	fd = open(path, O_RDONLY);	if (fd < 0) {		sd_eprintf("failed to open epoch %"PRIu32" log, %m", epoch);		goto err;	}	memset(&epoch_stat, 0, sizeof(epoch_stat));	ret = fstat(fd, &epoch_stat);	if (ret < 0) {		sd_eprintf("failed to stat epoch %"PRIu32" log, %m", epoch);		goto err;	}	if (len < epoch_stat.st_size - sizeof(*timestamp)) {		sd_eprintf("invalid epoch %"PRIu32" log", epoch);		goto err;	}	ret = xread(fd, nodes, epoch_stat.st_size - sizeof(*timestamp));	if (ret < 0) {		sd_eprintf("failed to read epoch %"PRIu32" log, %m", epoch);		goto err;	}	/* Broken epoch, just ignore */	if (ret % sizeof(struct sd_node) != 0) {		sd_eprintf("invalid epoch %"PRIu32" log", epoch);		goto err;	}	nr_nodes = ret / sizeof(struct sd_node);	if (timestamp) {		ret = xread(fd, timestamp, sizeof(*timestamp));		if (ret != sizeof(*timestamp)) {			sd_eprintf("invalid epoch %"PRIu32" log", epoch);			goto err;		}	}	close(fd);	return nr_nodes;err:	if (fd >= 0)		close(fd);	return -1;}
开发者ID:zplambert,项目名称:sheepdog,代码行数:55,


示例5: decode

void decode(int fd, dataset_t* bek_data, external_info_header_t* header, key_header_t* key_header){	memset (bek_data, 0, sizeof(dataset_t));	memset (header, 0, sizeof(external_info_header_t));	memset (key_header, 0, sizeof(key_header_t));			xread (fd, bek_data, sizeof(dataset_t));		xread (fd, header, sizeof(external_info_header_t));		xread (fd, key_header, sizeof(key_header_t));}
开发者ID:aoighost,项目名称:dislocker,代码行数:13,


示例6: unpackExtent

static voidunpackExtent(    struct Extent *const xi,  // input    struct Extent *const xo,  // output    f_expand *const f_decompress){    while (xo->size) {        struct b_info h;        //   Note: if h.sz_unc == h.sz_cpr then the block was not        //   compressible and is stored in its uncompressed form.        // Read and check block sizes.        xread(xi, (char *)&h, sizeof(h));        if (h.sz_unc == 0) {                     // uncompressed size 0 -> EOF            if (h.sz_cpr != UPX_MAGIC_LE32)      // h.sz_cpr must be h->magic                err_exit(2);            if (xi->size != 0)                 // all bytes must be written                err_exit(3);            break;        }        if (h.sz_cpr <= 0) {            err_exit(4);ERR_LAB        }        if (h.sz_cpr > h.sz_unc        ||  h.sz_unc > xo->size ) {            err_exit(5);        }        // Now we have:        //   assert(h.sz_cpr <= h.sz_unc);        //   assert(h.sz_unc > 0 && h.sz_unc <= blocksize);        //   assert(h.sz_cpr > 0 && h.sz_cpr <= blocksize);        if (h.sz_cpr < h.sz_unc) { // Decompress block            nrv_uint out_len = h.sz_unc;  // EOF for lzma            int const j = (*f_decompress)((unsigned char *)xi->buf, h.sz_cpr,                (unsigned char *)xo->buf, &out_len, *(int *)(void *)&h.b_method );            if (j != 0 || out_len != (nrv_uint)h.sz_unc)                err_exit(7);            xi->buf  += h.sz_cpr;            xi->size -= h.sz_cpr;        }        else { // copy literal block            xread(xi, xo->buf, h.sz_cpr);        }        xo->buf  += h.sz_unc;        xo->size -= h.sz_unc;    }
开发者ID:tfauck,项目名称:upx,代码行数:49,


示例7: get_char

/* wait for a character on the serial port */unsigned char get_char(void){	unsigned char c;	assert(portfd >= 0);	xread(portfd, &c, 1);	return c;}
开发者ID:korneliuszo,项目名称:shoehorn,代码行数:8,


示例8: getclust

static Ioclust*getclust(Xdata *dev, long addr, ulong tag){	Ioclust *c, *f;	f = nil;	for(c=iohead; c; c=c->next){		if(!c->busy && c->tag == tag)			f = c;		if(c->addr == addr && c->dev == dev){			c->busy++;			return c;		}	}	if(f == nil)		panic(0, "out of buffers");	f->addr = addr;	f->dev = dev;	f->busy++;	if(waserror()){		f->addr = -1;	/* stop caching */		putclust(f);		nexterror();	}	xread(f);	poperror();	return f;}
开发者ID:srk-cmu,项目名称:9problems,代码行数:30,


示例9: xmalloc

char *xreadstr(int fd){    int size = 0;    int len = 0;    char *str = NULL;    int n;    do {        if (size - len - 1 <= 0) {            str = (size == 0) ? xmalloc(CHUNKSIZE)                              : xrealloc(str, size + CHUNKSIZE);            size += CHUNKSIZE;        }        //n = xread(fd, str + len, size - len - 1);        n = xread(fd, str + len, 1);        if (n < 0)            err_exit (TRUE, "read");        if (n == 0)            err_exit (FALSE, "EOF on read");        len += n;        str[len] = '/0';    } while (len < 2 || strcmp(&str[len - 2], "/r/n") != 0);    str[len - 2] = '/0';    return str;}
开发者ID:chaos,项目名称:powerman,代码行数:26,


示例10: get_header_tar_gz

char get_header_tar_gz(archive_handle_t *archive_handle){#if BB_MMU	unsigned char magic[2];#endif	/* Can't lseek over pipes */	archive_handle->seek = seek_by_read;	/* Check gzip magic only if open_transformer will invoke unpack_gz_stream (MMU case).	 * Otherwise, it will invoke an external helper "gunzip -cf" (NOMMU case) which will	 * need the header. */#if BB_MMU	xread(archive_handle->src_fd, &magic, 2);	if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) {		bb_error_msg_and_die("invalid gzip magic");	}#endif	archive_handle->src_fd = open_transformer(archive_handle->src_fd, unpack_gz_stream, "gunzip");	archive_handle->offset = 0;	while (get_header_tar(archive_handle) == EXIT_SUCCESS)		continue;	/* Can only do one file at a time */	return EXIT_FAILURE;}
开发者ID:NikhilNJ,项目名称:screenplay-dx,代码行数:27,


示例11: strbuf_read

ssize_t strbuf_read(struct strbuf *sb, int fd, size_t hint){	size_t oldlen = sb->len;	size_t oldalloc = sb->alloc;	strbuf_grow(sb, hint ? hint : 8192);	for (;;) {		ssize_t cnt;		cnt = xread(fd, sb->buf + sb->len, sb->alloc - sb->len - 1);		if (cnt < 0) {			if (oldalloc == 0)				strbuf_release(sb);			else				strbuf_setlen(sb, oldlen);			return -1;		}		if (!cnt)			break;		sb->len += cnt;		strbuf_grow(sb, 8192);	}	sb->buf[sb->len] = '/0';	return sb->len - oldlen;}
开发者ID:AmyOrchid188,项目名称:git,代码行数:26,


示例12: send_local_file

static void send_local_file(const char *the_type, const char *name){	const char *p = git_path("%s", name);	size_t buf_alloc = 8192;	char *buf = xmalloc(buf_alloc);	int fd;	struct stat sb;	fd = open(p, O_RDONLY);	if (fd < 0)		not_found("Cannot open '%s': %s", p, strerror(errno));	if (fstat(fd, &sb) < 0)		die_errno("Cannot stat '%s'", p);	hdr_int(content_length, sb.st_size);	hdr_str(content_type, the_type);	hdr_date(last_modified, sb.st_mtime);	end_headers();	for (;;) {		ssize_t n = xread(fd, buf, buf_alloc);		if (n < 0)			die_errno("Cannot read '%s'", p);		if (!n)			break;		write_or_die(1, buf, n);	}	close(fd);	free(buf);}
开发者ID:120011676,项目名称:git,代码行数:30,


示例13: init_config_file

int init_config_file(void){	int fd, ret;	check_tmp_config();	fd = open(config_path, O_RDONLY);	if (fd < 0) {		if (errno != ENOENT) {			sd_eprintf("failed to read config file, %m");			return -1;		}		goto create;	}	ret = xread(fd, &config, sizeof(config));	if (ret == 0) {		close(fd);		goto create;	}	if (ret < 0) {		sd_eprintf("failed to read config file, %m");		goto out;	}	if (config.version != SD_FORMAT_VERSION) {		sd_eprintf("This sheep version is not compatible with"			   " the existing data layout, %d", config.version);		if (sys->upgrade) {			/* upgrade sheep store */			ret = sd_migrate_store(config.version, SD_FORMAT_VERSION);			if (ret == 0) {				/* reload config file */				ret = xpread(fd, &config, sizeof(config), 0);				if (ret != sizeof(config)) {					sd_eprintf("failed to reload config"						   " file, %m");					ret = -1;				} else					ret = 0;			}			goto out;		}		sd_eprintf("use '-u' option to upgrade sheep store");		ret = -1;		goto out;	}	ret = 0;out:	close(fd);	return ret;create:	config.version = SD_FORMAT_VERSION;	if (write_config() != SD_RES_SUCCESS)		return -1;	return 0;}
开发者ID:rdndnl,项目名称:sheepdog,代码行数:60,


示例14: qmp_read

/* * read over a non-block fd */static int qmp_read(int fd, void *buf, size_t *len){        struct pollfd pfd;        size_t tread = 0, nread;        int r;        pfd.fd = fd;        pfd.events = POLLIN;        while ((r = poll(&pfd, 1, QMP_POLL_TIMEOUT)) != 0) {                if (r == -1)                        return -1;                if (pfd.revents & POLLIN) {                        /* read at max 1k at a time */                        nread = xread(fd, buf, 1024);                        tread += nread;                        buf += nread;                }        }        *len = tread;        return 0;}
开发者ID:mv0,项目名称:qemu-qmp,代码行数:29,


示例15: get_header_tar_gz

char FAST_FUNC get_header_tar_gz(archive_handle_t *archive_handle){#if BB_MMU    uint16_t magic;#endif    /* Can't lseek over pipes */    archive_handle->seek = seek_by_read;    /* Check gzip magic only if open_transformer will invoke unpack_gz_stream (MMU case).     * Otherwise, it will invoke an external helper "gunzip -cf" (NOMMU case) which will     * need the header. */#if BB_MMU    xread(archive_handle->src_fd, &magic, 2);    /* Can skip this check, but error message will be less clear */    if (magic != GZIP_MAGIC) {        bb_error_msg_and_die("invalid gzip magic");    }#endif    open_transformer(archive_handle->src_fd, unpack_gz_stream, "gunzip");    archive_handle->offset = 0;    while (get_header_tar(archive_handle) == EXIT_SUCCESS)        continue;    /* Can only do one file at a time */    return EXIT_FAILURE;}
开发者ID:xieshaohua,项目名称:rootfs,代码行数:28,


示例16: extract_cpio_gz

static void extract_cpio_gz(int fd) {	archive_handle_t *archive_handle;	unsigned char magic[2];	/* Initialise */	archive_handle = init_handle();	archive_handle->seek = seek_by_read;	//archive_handle->action_header = header_list;	archive_handle->action_data = data_extract_all;	archive_handle->flags |= ARCHIVE_PRESERVE_DATE;	archive_handle->flags |= ARCHIVE_CREATE_LEADING_DIRS;	archive_handle->src_fd = fd;	archive_handle->offset = 0;	xread(archive_handle->src_fd, &magic, 2);	if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) {		bb_error_msg_and_die("invalid gzip magic");	}	check_header_gzip(archive_handle->src_fd);	xchdir("/"); /* Install RPM's to root */	archive_handle->src_fd = open_transformer(archive_handle->src_fd, inflate_gunzip);	archive_handle->offset = 0;	while (get_header_cpio(archive_handle) == EXIT_SUCCESS)		/* loop */;}
开发者ID:emuikernel,项目名称:WNR2000v4,代码行数:26,


示例17: snprintf

static void *read_working_object(uint64_t oid, int length){    void *buf = NULL;    char path[PATH_MAX];    int fd, ret;    snprintf(path, sizeof(path), "%s%016" PRIx64, obj_path, oid);    fd = open(path, O_RDONLY, def_fmode);    if (fd < 0) {        dprintf("object %"PRIx64" not found/n", oid);        goto out;    }    buf = malloc(length);    if (!buf) {        eprintf("no memory to allocate buffer./n");        goto out;    }    ret = xread(fd, buf, length);    if (length != ret) {        eprintf("object read error./n");        free(buf);        buf = NULL;        goto out;    }out:    if (fd > 0)        close(fd);    return buf;}
开发者ID:yaekumo,项目名称:sheepdog,代码行数:33,


示例18: _elf_read

void*_elf_read(Elf *elf, void *buffer, size_t off, size_t len) {    void *tmp;    elf_assert(elf);    elf_assert(elf->e_magic == ELF_MAGIC);    elf_assert(off >= 0 && off + len <= elf->e_size);    if (elf->e_disabled) {	seterr(ERROR_FDDISABLED);    }    else if (len) {	off += elf->e_base;	if (lseek(elf->e_fd, (off_t)off, SEEK_SET) != (off_t)off) {	    seterr(ERROR_IO_SEEK);	}	else if (!(tmp = buffer) && !(tmp = malloc(len))) {	    seterr(ERROR_IO_2BIG);	}	else if (xread(elf->e_fd, tmp, len)) {	    seterr(ERROR_IO_READ);	    if (tmp != buffer) {		free(tmp);	    }	}	else {	    return tmp;	}    }    return NULL;}
开发者ID:samgh1230,项目名称:experiment_data,代码行数:30,


示例19: assert

char *target_gets(target_context_t *tc, char *s, int size){	unsigned char c;	char *p = s;	assert(tc);	assert(s);	assert(size >= 0);	if (!size--)		return s;	while (size--) {		ssize_t nread = xread(tc->portfd, &c, 1);		if(nread == ERROR_VALUE) break;		if(nread == 0) break; //timeout		if (c == '/r')			++size;		else			*p++ = c;		if (c == '/n')			break;	}	*p = '/0';	/* report error lines */	if (ok_or_ng(s) < 0)		warnf("from target: %s", s);	return s;}
开发者ID:miettal,项目名称:armadillo420_standard_linux314,代码行数:29,


示例20: retr_opt

void		retr_opt(client_ftp_t *client_ftp, char *cmd){  FILE		*fs;  char		buff[1024];  char		put[1024];  int		nb;  int		i;  int		j;  if ((i = init_download(client_ftp, cmd)) == 1)    return;  if ((fs = fopen(cmd + 4, "w+")) == NULL)    {      printf("Failed to open file/n");      close(client_ftp->s_data);      return;    }  bzero(buff, 1024);  while ((nb = xread(client_ftp->s_data, buff, 1024)))    {      bzero(put, 1024);      for (i = 0, j = 0; i != nb; i++, j++)	put[j] = buff[i];      fwrite(put, 1, j, fs);      bzero(buff, 1024);    }  fclose(fs);  i = xrecv(client_ftp->s, buff, 1024, 0);  clean_buff(buff, i);  printf("%s/n", buff);  close(client_ftp->s_data);}
开发者ID:scalp42,项目名称:my_ftp,代码行数:32,


示例21: init_node_config_file

int init_node_config_file(void){	int fd, ret;	struct stat st;	ret = stat(node_config_path, &st);	if (ret < 0)		/* this node doesn't have a node config, do nothing */		return 0;	fd = open(node_config_path, O_RDONLY);	if (fd < 0) {		sd_err("failed to open node config (%s): %m", node_config_path);		return -1;	}	ret = xread(fd, &sys->ninfo, sizeof(sys->ninfo));	if (ret != sizeof(sys->ninfo)) {		sd_err("failed to read node config (%s): %m", node_config_path);		return -1;	}	close(fd);	return 0;}
开发者ID:clicx,项目名称:sheepdog,代码行数:25,


示例22: tun_serv_in

void tun_serv_in(int fd_udp, int fd_tun, struct tun_state *state, char *buf) {   int recvd=xread(fd_tun, buf, BUFF_SIZE);   debug_print("serv: recvd %dB from tun/n", recvd);   if (recvd > MIN_PKT_SIZE) {      /* Remove PlanetLab TUN PPI header */      if (state->planetlab) {         buf+=4;recvd-=4;      }      struct tun_rec *rec = NULL;       /* read sport for clients mapping */      int sport = (int) ntohs( *((uint16_t *)(buf+22)) );       if ( (rec = g_hash_table_lookup(state->serv, &sport)) ) {            int sent = xsendto(fd_udp, rec->sa, buf, recvd);         debug_print("serv: wrote %dB to udp/n",sent);      } else {         errno=EFAULT;         die("lookup");      }   } }
开发者ID:lxlee1102,项目名称:udptun,代码行数:25,


示例23: read_page_header

static bool read_page_header(struct urf_context *ctx){	if (!xread(ctx, ctx->page_hdr, sizeof(struct urf_page_header))) {		return false;	}	struct urf_page_header *hdr = ctx->page_hdr;	if (!hdr->bpp || hdr->bpp > 32 || hdr->bpp % 8) {		URF_SET_ERROR(ctx, "invalid bpp", -hdr->bpp);		return false;	}	if (hdr->bpp != 24) {		URF_SET_ERROR(ctx, "unsupported bpp", -hdr->bpp);		return false;	}	if (hdr->colorspace != 1) {		URF_SET_ERROR(ctx, "unsupported colorspace", -hdr->colorspace);		return false;	}	SWAP32(hdr->unknown0);	SWAP32(hdr->unknown1);	SWAP32(hdr->width);	SWAP32(hdr->height);	SWAP32(hdr->dpi);	SWAP32(hdr->unknown2);	SWAP32(hdr->unknown3);	return true;}
开发者ID:jclehner,项目名称:urftops,代码行数:33,


示例24: parent_finish

static void parent_finish(test_data* td) {  char buf;  pipe_state *ps = (pipe_state *)td->data;  xread(ps->fin_fds[0], &buf, 1);}
开发者ID:Kelimion,项目名称:ipc-bench,代码行数:7,


示例25: strbuf_addstr

void *snap_log_read(int *out_nr, int user){	struct strbuf buf = STRBUF_INIT;	struct stat st;	void *buffer = NULL;	int len, fd;	strbuf_addstr(&buf, farm_dir);	strbuf_addf(&buf, "/%s", user ? "user_snap" : "sys_snap");	fd = open(buf.buf, O_RDONLY);	if (fd < 0) {		dprintf("%m/n");		goto out;	}	if (fstat(fd, &st) < 0) {		dprintf("%m/n");		goto out_close;	}	len = st.st_size;	buffer = xmalloc(len);	len = xread(fd, buffer, len);	if (len != st.st_size) {		free(buffer);		buffer = NULL;		goto out_close;	}	*out_nr = len / sizeof(struct snap_log);out_close:	close(fd);out:	strbuf_release(&buf);	return buffer;}
开发者ID:Nexenta,项目名称:sheepdog,代码行数:35,


示例26: return

char		*get_next_line(int fd){  static int	nbread;  static char	buff[BUFF_SIZE];  char		*line;  int		pos;  for (line = 0, pos = 0; ; pos++)    {      if (begin >= nbread)        {          begin = 0;          if (!(nbread = xread(fd, buff, BUFF_SIZE)))            return (line);          pos = 0;        }      if (buff[begin + pos] == '/n')        {          line = add_line(line, buff, pos);          return (line);        }      if (begin + pos + 1 == nbread)        line = add_line(line, buff, pos + 1);    }}
开发者ID:scalp42,项目名称:my_ftp,代码行数:25,


示例27: read_chunk

int read_chunk(void) {	ssize_t s, len, offset;	chunk_no++;	len = chunk_size + spare_size;	offset = 0;	memset(chunk_data, 0xff, sizeof(chunk_data));	if (buf_len > buf_idx) {		/* copy from buffer */		s = buf_len - buf_idx;		if (s > len) s = len;		memcpy(data, buffer+buf_idx, s);		buf_idx += s; offset += s;	}	if (offset < len) {			/* read from file */		s = xread(img_file, data+offset, len-offset);		if (s < 0)			prt_err(1, errno, "Read image file");		offset += s;	}	if (offset != 0 && offset != len)	/* partial chunk */		prt_err(1, 0, "Broken image file");	return offset != 0;}
开发者ID:CyanogenGodbox,项目名称:unyaffs,代码行数:27,


示例28: open_slot

/* Open an existing cache slot and fill the cache buffer with * (part of) the content of the cache file. Return 0 on success * and errno otherwise. */static int open_slot(struct cache_slot *slot){	char *bufz;	ssize_t bufkeylen = -1;	slot->cache_fd = open(slot->cache_name, O_RDONLY);	if (slot->cache_fd == -1)		return errno;	if (fstat(slot->cache_fd, &slot->cache_st))		return errno;	slot->bufsize = xread(slot->cache_fd, slot->buf, sizeof(slot->buf));	if (slot->bufsize < 0)		return errno;	bufz = memchr(slot->buf, 0, slot->bufsize);	if (bufz)		bufkeylen = bufz - slot->buf;	if (slot->key)		slot->match = bufkeylen == slot->keylen &&		    !memcmp(slot->key, slot->buf, bufkeylen + 1);	return 0;}
开发者ID:baoson2211,项目名称:cgit,代码行数:30,


示例29: var_read_block_header

int var_read_block_header(FILE *fi, var_block_header *header){    // read block number    header->num = xread32(fi);    //TOFIX: 64 bit num ??    xread32(fi);        // read compressed size    header->in_len = xread32(fi);    // read uncompressed size    header->out_len = xread32(fi);    // empty / 64 ?    xread32(fi);        // read block method ?    header->method = xread32(fi);        // read block chk    xread(fi, header->chk, 16, 1);        // empty    xskip(fi, 56);        // read block pos    header->pos = xread64(fi);    //TOFIX: use block_pos ?    xskip(fi, 8);        return 1;}
开发者ID:fandrieu,项目名称:unvar,代码行数:32,



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


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