当前位置: 首页>>代码示例>>C++>>正文


C++ write_buf函数代码示例

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


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

示例1: send_exclude_list

void send_exclude_list(int f)
{
	int i;
	extern int remote_version;

	if (!exclude_list) {
		write_int(f,0);
		return;
	}

	for (i=0;exclude_list[i];i++) {
		char *pattern = exclude_list[i]->pattern; 
		int l;

		l = strlen(pattern);
		if (l == 0) continue;
		if (exclude_list[i]->include) {
			if (remote_version < 19) {
				rprintf(FERROR,"remote rsync does not support include syntax - aborting\n");
				exit_cleanup(RERR_UNSUPPORTED);
			}
			write_int(f,l+2);
			write_buf(f,"+ ",2);
		} else {
			write_int(f,l);
		}
		write_buf(f,pattern,l);
	}    

	write_int(f,0);
}
开发者ID:AkankshaGovil,项目名称:Automation,代码行数:31,代码来源:exclude.c

示例2: varint_encode

int varint_encode(uint64_t source, char *buf, int size, int *written) {
    int needed = varint_encode_size(source);
    if (size < needed) {
        return 1;
    }

    *written = 0;
    int pos = 0;

    if (source < 0) {
        source = ~source;
        if (source < 0x4) {
            write_buf(buf, &pos, written, 0xFC | source);
            return 0;
        } else {
            write_buf(buf, &pos, written, 0xF8);
        }
    }


    if (source < 0x80) {
        // Need top bit clear
        write_buf(buf, &pos, written, source);
    } else if (source < 0x4000) {
        // Need top two bits clear
        write_buf(buf, &pos, written, (source >> 8) | 0x80);
        write_buf(buf, &pos, written, source & 0xFF);
    } else if (source < 0x200000) {
开发者ID:jumpandspintowin,项目名称:mumble-web-demo,代码行数:28,代码来源:util.c

示例3: send_uid_list

/* send a complete uid/gid mapping to the peer */
void send_uid_list(int f)
{
	struct idlist *list;

	if (numeric_ids) return;

	if (preserve_uid) {
		/* we send sequences of uid/byte-length/name */
		list = uidlist;
		while (list) {
			int len = strlen(list->name);
			write_int(f, list->id);
			write_byte(f, len);
			write_buf(f, list->name, len);
			list = list->next;
		}

		/* terminate the uid list with a 0 uid. We explicitly exclude
		   0 from the list */
		write_int(f, 0);
	}

	if (preserve_gid) {
		list = gidlist;
		while (list) {
			int len = strlen(list->name);
			write_int(f, list->id);
			write_byte(f, len);
			write_buf(f, list->name, len);
			list = list->next;
		}
		write_int(f, 0);
	}
}
开发者ID:AkankshaGovil,项目名称:Automation,代码行数:35,代码来源:uidlist.c

示例4: write_cmd

static int write_cmd(char *buf, int len)
{
  byte hd[2];
  enc_int16(len, hd);
  if (write_buf(1, (char *)hd, 2) != 2)
    return 0;
  if (write_buf(1, buf, len) != len)
    return 0;
  return 1;
}
开发者ID:0879dc,项目名称:ejabberd,代码行数:10,代码来源:epam.c

示例5: unix_pass_trigger

int     unix_pass_trigger(const char *service, const char *buf, ssize_t len, int timeout)
{
    const char *myname = "unix_pass_trigger";
    int     pair[2];
    struct unix_pass_trigger *up;
    int     fd;

    if (msg_verbose > 1)
	msg_info("%s: service %s", myname, service);

    /*
     * Connect...
     */
    if ((fd = unix_pass_connect(service, BLOCKING, timeout)) < 0) {
	if (msg_verbose)
	    msg_warn("%s: connect to %s: %m", myname, service);
	return (-1);
    }
    close_on_exec(fd, CLOSE_ON_EXEC);

    /*
     * Create a pipe, and send one pipe end to the server.
     */
    if (pipe(pair) < 0)
	msg_fatal("%s: pipe: %m", myname);
    close_on_exec(pair[0], CLOSE_ON_EXEC);
    close_on_exec(pair[1], CLOSE_ON_EXEC);
    if (unix_send_fd(fd, pair[0]) < 0)
	msg_fatal("%s: send file descriptor: %m", myname);

    /*
     * Stash away context.
     */
    up = (struct unix_pass_trigger *) mymalloc(sizeof(*up));
    up->fd = fd;
    up->service = mystrdup(service);
    up->pair[0] = pair[0];
    up->pair[1] = pair[1];

    /*
     * Write the request...
     */
    if (write_buf(pair[1], buf, len, timeout) < 0
	|| write_buf(pair[1], "", 1, timeout) < 0)
	if (msg_verbose)
	    msg_warn("%s: write to %s: %m", myname, service);

    /*
     * Wakeup when the peer disconnects, or when we lose patience.
     */
    if (timeout > 0)
	event_request_timer(unix_pass_trigger_event, (char *) up, timeout + 100);
    event_enable_read(fd, unix_pass_trigger_event, (char *) up);
    return (0);
}
开发者ID:abhai2k,项目名称:postfix-mongodb,代码行数:55,代码来源:unix_pass_trigger.c

示例6: locking_reset

/**
 *	locking_reset - reset the channel
 *	@rchan: the channel
 *	@init: 1 if this is a first-time channel initialization
 */
void locking_reset(struct rchan *rchan, int init)
{
    if (init)
        channel_lock(rchan) = RAW_SPIN_LOCK_UNLOCKED;
    write_buf(rchan) = rchan->buf;
    write_buf_end(rchan) = write_buf(rchan) + rchan->buf_size;
    cur_write_pos(rchan) = write_buf(rchan);
    write_limit(rchan) = write_buf_end(rchan) - rchan->end_reserve;
    in_progress_event_pos(rchan) = NULL;
    in_progress_event_size(rchan) = 0;
    interrupted_pos(rchan) = NULL;
    interrupting_size(rchan) = 0;
}
开发者ID:GodFox,项目名称:magx_kernel_xpixl,代码行数:18,代码来源:relay_locking.c

示例7: write_buf

void NRF24L01::set_local_addr(uint8_t ch,uint8_t *addr)
{
    uint8_t tmp_addr[5];
    if(0 < ch && ch < 2)
        write_buf(NRF_WRITE_REG + RX_ADDR_P0 + ch, addr, this->rx_aw);//写RX节点地址
    else if(2 <= ch && ch < 6){
        tmp_addr[0] = rx_addr_1[0];
        tmp_addr[1] = rx_addr_1[1];
        tmp_addr[2] = rx_addr_1[2];
        tmp_addr[3] = rx_addr_1[3];
        tmp_addr[4] = addr[4];
        write_buf(NRF_WRITE_REG + RX_ADDR_P0 + ch, tmp_addr, this->rx_aw);//写RX节点地址
    }
       
}
开发者ID:Hletian,项目名称:ebox_stm32,代码行数:15,代码来源:NRF24L01.cpp

示例8: sim_main

/* start simulation, program loaded, processor precise state initialized */
void
sim_main(void)
{
  fprintf(stderr, "sim: ** starting *pipe* functional simulation **\n");

  /* must have natural byte/word ordering */
  if (sim_swap_bytes || sim_swap_words)
    fatal("sim: *pipe* functional simulation cannot swap bytes or words");

  /* set up initial default next PC */
  /* maintain $r0 semantics */
  regs.regs_R[MD_REG_ZERO] = 0;
  regs.regs_PC -= sizeof(md_inst_t);
  while (TRUE)
  {
	   do_if();
     do_wb();
     do_id();
     do_ex();
     do_mem();
     print_env();
     write_buf();
     #ifndef NO_INSN_COUNT
           sim_num_insn++;
     #endif /* !NO_INSN_COUNT */
  }
}
开发者ID:ZZCer,项目名称:PISASimulator,代码行数:28,代码来源:sim-pipe.c

示例9: write_data

/* write data to destination(s)
 */
ssize_t
write_data( const struct dstream_ctx* spc,
            const char* data,
            const ssize_t len,
            int fd )
{
    ssize_t n = 0, error = IO_ERR;
    int32_t n_count = -1;

    assert( spc && data && len );
    if( fd <= 0 ) return 0;

    if( spc->flags & F_SCATTERED ) {
        n_count = spc->pkt_count;
        n = writev( fd, spc->pkt, n_count );
        if( n <= 0 ) {
            if( EAGAIN == errno ) {
                (void)tmfprintf( g_flog, "Write on fd=[%d] timed out\n", fd);
                error = IO_BLK;
            }
            mperror( g_flog, errno, "%s: writev", __func__ );
            return error;
        }
    }
    else {
        n = write_buf( fd, data, len, g_flog );
        if( n < 0 )
            error = n;
    }

    return (n > 0) ? n : error;
}
开发者ID:Einheri,项目名称:wl500g,代码行数:34,代码来源:dpkt.c

示例10: write_i64

/* write a i64 */
static int write_i64(int f, i64 v)
{
	if (write_buf(f, (uchar *)&v, 8))
		return -1;

	return 0;
}
开发者ID:epa,项目名称:lrzip,代码行数:8,代码来源:stream.c

示例11: gpfs_send_attr

void gpfs_send_attr(stat_x *sxp, int f)
{
	struct rsync_gpfs_attr	*a = sxp->gpfs_attr;

	if (a && a->buf) {
		int ndx = (use_gpfs_attr_cache) ? gpfs_find_attr(a) : -1;


		/* write 1 if it was 0; means not in cache (yet), +1 */
		/* +1 is to compress the GPFS_NDX_NOATTR better */
		write_varint(f, ndx + 1 + 1);

		if (ndx < 0) {

			write_varint(f, a->size);
			write_buf(f, a->buf, a->size);
		}
	} else {
		/* we have no attribute for this file */

		/* +1 is just because of the trivial compression
		 * of the mostly awaited GPFS_NDX_NOATTR  */
		write_varint(f, GPFS_NDX_NOATTR + 1);
	}
}
开发者ID:OrlandoRichards,项目名称:gpfsug-tools,代码行数:25,代码来源:gpfs.c

示例12: dump_program_headers

/*===========================================================================*
 *			  dump_program_headers			             *
 *===========================================================================*/
static void dump_program_headers(struct filp *f, Elf_Phdr phdrs[], int phnum)
{
  int i;

  for (i = 0; i < phnum; i++)
	write_buf(f, (char *) &phdrs[i], sizeof(Elf_Phdr));
}
开发者ID:Hooman3,项目名称:minix,代码行数:10,代码来源:coredump.c

示例13: dump_segments

/*===========================================================================*
 *			      dump_segments 			             *
 *===========================================================================*/
static void dump_segments(struct filp *f, Elf_Phdr phdrs[], int phnum)
{
  int i;
  vir_bytes len;
  off_t off, seg_off;
  int r;
  static u8_t buf[CLICK_SIZE];

  for (i = 1; i < phnum; i++) {
	len = phdrs[i].p_memsz;
	seg_off = phdrs[i].p_vaddr;

	if (len > LONG_MAX) {
		printf("VFS: segment too large to dump, truncating\n");
		len = LONG_MAX;
	}

	for (off = 0; off < (off_t) len; off += CLICK_SIZE) {
		vir_bytes p = (vir_bytes) (seg_off + off);
		r = sys_datacopy_try(fp->fp_endpoint, p,
			SELF, (vir_bytes) buf,
			(phys_bytes) CLICK_SIZE);

		if(r != OK) {
			/* memory didn't exist; write as zeroes */
			memset(buf, 0, sizeof(buf));
			continue;
		}

		write_buf(f, (char *) buf, (off + CLICK_SIZE <= (off_t) len) ?
					CLICK_SIZE : (len - off));
	}
  }
}
开发者ID:Hooman3,项目名称:minix,代码行数:37,代码来源:coredump.c

示例14: TEST_F

/** Let the intermediate write request fail. The write should be retried and
 *  finally succeed. */
TEST_F(AsyncWriteHandlerTest, IntermediateWriteFail) {
  size_t blocks = 5;
  size_t buffer_size = kBlockSize * blocks;
  size_t middle = blocks / 2;
  boost::scoped_array<char> write_buf(new char[buffer_size]());

  vector<WriteEntry> expected_front(middle);
  vector<WriteEntry> expected_tail(blocks - middle);
  for (size_t i = 0; i < middle; ++i) {
    expected_front[i] = WriteEntry(i, 0, kBlockSize);
  }

  for (size_t i = middle; i < blocks; ++i) {
    expected_tail[i - middle] = WriteEntry(i, 0, kBlockSize);
  }

  test_env.osds[0]->AddDropRule(
      new ProcIDFilterRule(xtreemfs::pbrpc::PROC_ID_WRITE,
                           new SkipMDropNRule(middle, 1)));

  ASSERT_NO_THROW(file->Write(write_buf.get(), buffer_size, 0));
  ASSERT_NO_THROW(file->Flush());

  EXPECT_TRUE(equal(expected_front.begin(),
                    expected_front.end(),
                    test_env.osds[0]->GetReceivedWrites().begin()));
  EXPECT_TRUE(equal(expected_tail.begin(),
                    expected_tail.end(),
                    test_env.osds[0]->GetReceivedWrites().end() -
                        expected_tail.size()));

  ASSERT_NO_THROW(file->Close());
}
开发者ID:2510,项目名称:xtreemfs,代码行数:35,代码来源:async_write_handler_test.cpp

示例15: draw_char

uint8_t 
draw_char(uint8_t start_row, uint8_t start_col, unsigned char ch, uint8_t fg_col, uint8_t bg_col, uint8_t width) {
	unsigned int w;
	unsigned int i, cpos, cnt;
	uint8 res = 0;
	
	// NOTE maybe print a ? or something
	if (ch > max_char) return 1;	/* We print nothing, character not encoded */
	
	cpos = char_pos[ch];		// Start of glyph bits in font_bits[]
	
	w = char_width(ch);		// Width of the character without inter character space
	if (w > width) w = width;	// w is now min(char_width(ch), width)

	// draw w columns into drawbuf
	// each column is copied (with correct color) to drawbuf directly from font_bits
	for (cnt = 0; cnt < w; cnt++, cpos+=bytes_per_col)
		store_buf(cnt, font_bits[cpos] | (font_bits[cpos+1] << 8), fg_col, bg_col);
	if ( (width - cnt) >= ic_space ){
		for (i=0; i<ic_space; i++)
			store_buf(cnt++, 0, fg_col, bg_col);		// inter character space
		res = cnt;
	};
	write_buf(start_row, start_col, cnt, font_height);
	return res;	
}
开发者ID:HerrSchrader,项目名称:McBetty,代码行数:26,代码来源:fonty.c


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