本文整理汇总了C++中print_buf函数的典型用法代码示例。如果您正苦于以下问题:C++ print_buf函数的具体用法?C++ print_buf怎么用?C++ print_buf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了print_buf函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: test_sample
static int test_sample(uint8_t priv_a[32], uint8_t priv_b[32],
uint8_t pub_a[64], uint8_t pub_b[64],
uint8_t dhkey[32])
{
uint8_t dhkey_a[32], dhkey_b[32];
int fails = 0;
ecdh_shared_secret(pub_b, priv_a, dhkey_a);
ecdh_shared_secret(pub_a, priv_b, dhkey_b);
printf("\n");
print_buf("DHKey ", dhkey, 32);
print_buf("DHKey A", dhkey_a, 32);
print_buf("DHKey B", dhkey_b, 32);
if (memcmp(dhkey_a, dhkey, 32)) {
printf("DHKey A doesn't match!\n");
fails++;
} else {
printf("DHKey A matches :)\n");
}
if (memcmp(dhkey_b, dhkey, 32)) {
printf("DHKey B doesn't match!\n");
fails++;
} else {
printf("DHKey B matches :)\n");
}
return fails;
}
开发者ID:rymanluk,项目名称:bluez,代码行数:32,代码来源:test-ecc.c
示例2: push
int push(struct buf *buf, int val)
{
unsigned int t_head = buf->head, t_tail = buf->tail;
#ifdef DEBUG
if (buf->full_fl == true || buf->empt_fl == true) {
if (t_head != t_tail) {
del(buf);
fprintf(stderr, "buffer %p is corrupt\n", buf);
return FAIL;
}
}
print_buf(buf, "befor push");
#endif
if (buf->full_fl == true) {
return FULL;
}
if (t_tail == t_head && buf->empt_fl != true) {
buf->full_fl = true;
return FULL;
}
buf->data[t_head] = val;
t_head++;
buf->head = t_head & buf->mask;
buf->empt_fl = false;
#ifdef DEBUG
print_buf(buf, "after push");
#endif
return SUCC;
}
开发者ID:ivanria,项目名称:ring-buffer,代码行数:29,代码来源:test_ring_buf.c
示例3: nios_access
/* Buf is assumed to be NIOS_PKT_LEN bytes */
static int nios_access(struct bladerf *dev, uint8_t *buf)
{
int status;
void *driver;
struct bladerf_usb *usb = usb_backend(dev, &driver);
print_buf("NIOS II request:\n", buf, NIOS_PKT_LEN);
/* Send the command */
status = usb->fn->bulk_transfer(driver, PERIPHERAL_EP_OUT,
buf, NIOS_PKT_LEN,
PERIPHERAL_TIMEOUT_MS);
if (status != 0) {
log_debug("Failed to send NIOS II request: %s\n",
bladerf_strerror(status));
return status;
}
/* Retrieve the request */
status = usb->fn->bulk_transfer(driver, PERIPHERAL_EP_IN,
buf, NIOS_PKT_LEN,
PERIPHERAL_TIMEOUT_MS);
if (status != 0) {
log_debug("Failed to receive NIOS II response: %s\n",
bladerf_strerror(status));
}
print_buf("NIOS II response:\n", buf, NIOS_PKT_LEN);
return status;
}
开发者ID:alexf91,项目名称:bladeRF,代码行数:33,代码来源:nios_access.c
示例4: pop
int pop(struct buf *buf, int *val)
{
unsigned int t_head = buf->head, t_tail = buf->tail;
#ifdef DEBUG
if (buf->full_fl == true || buf->empt_fl == true) {
if (t_head != t_tail) {
del(buf);
fprintf(stderr, "buffer %p is corrupt\n", buf);
return FAIL;
}
}
print_buf(buf, "befor pop");
#endif
if (buf->empt_fl == true) {
return EMPT;
}
if (t_tail == t_head && buf->full_fl != true) { /*last value in the buf*/
buf->empt_fl = true;
return EMPT;
}
*val = buf->data[t_tail];
buf->data[t_tail] = 0;
t_tail++;
buf->tail = t_tail & buf->mask;
buf->full_fl = false;
#ifdef DEBUG
print_buf(buf, "after pop");
#endif
return SUCC;
}
开发者ID:ivanria,项目名称:ring-buffer,代码行数:30,代码来源:test_ring_buf.c
示例5: loop
void loop() {
delay(250);
toggleLED();
if (isButtonPressed()) {
if (servo1.attached()) detach();
else attach();
}
if (!servo1.attached()) return;
int32 average = averageAnalogReads(250);
int16 angle1 = (int16)map(average, 0, 4095, MIN_ANGLE1, MAX_ANGLE1);
int16 angle2 = (int16)map(average, 0, 4095, MIN_ANGLE2, MAX_ANGLE2);
print_buf("pot reading = %d, angle 1 = %d, angle 2 = %d.",
average, angle1, angle2);
servo1.write(angle1);
servo2.write(angle2);
int16 read1 = servo1.read();
int16 read2 = servo2.read();
print_buf("write/read angle 1: %d/%d, angle 2: %d/%d",
angle1, read1, angle2, read2);
ASSERT(abs(angle1 - read1) <= 1);
ASSERT(abs(angle2 - read2) <= 1);
print_buf("pulse width 1: %d, pulse width 2: %d",
servo1.readMicroseconds(), servo2.readMicroseconds());
Serial2.println("\n--------------------------\n");
}
开发者ID:1stsetup,项目名称:AeroQuad,代码行数:35,代码来源:test-servo.cpp
示例6: nios_access
/* Access device/module via the legacy NIOS II packet format. */
static int nios_access(struct bladerf *dev, uint8_t peripheral,
usb_direction dir, struct uart_cmd *cmd,
size_t len)
{
void *driver;
struct bladerf_usb *usb = usb_backend(dev, &driver);
int status;
size_t i;
uint8_t buf[16] = { 0 };
const uint8_t pkt_mode_dir = (dir == USB_DIR_HOST_TO_DEVICE) ?
NIOS_PKT_LEGACY_MODE_DIR_WRITE :
NIOS_PKT_LEGACY_MODE_DIR_READ;
assert(len <= ((sizeof(buf) - 2) / 2));
/* Populate the buffer for transfer, given address data pairs */
buf[0] = NIOS_PKT_LEGACY_MAGIC;
buf[1] = pkt_mode_dir | peripheral | (uint8_t)len;
for (i = 0; i < len; i++) {
buf[i * 2 + 2] = cmd[i].addr;
buf[i * 2 + 3] = cmd[i].data;
}
print_buf("NIOS II access request:\n", buf, 16);
/* Send the command */
status = usb->fn->bulk_transfer(driver, PERIPHERAL_EP_OUT,
buf, sizeof(buf),
PERIPHERAL_TIMEOUT_MS);
if (status != 0) {
log_debug("Failed to submit NIOS II request: %s\n",
bladerf_strerror(status));
return status;
}
/* Read back the ACK. The command data is only used for a read operation,
* and is thrown away otherwise */
status = usb->fn->bulk_transfer(driver, PERIPHERAL_EP_IN,
buf, sizeof(buf),
PERIPHERAL_TIMEOUT_MS);
if (dir == NIOS_PKT_LEGACY_MODE_DIR_READ && status == 0) {
for (i = 0; i < len; i++) {
cmd[i].data = buf[i * 2 + 3];
}
}
if (status == 0) {
print_buf("NIOS II access response:\n", buf, 16);
} else {
log_debug("Failed to receive NIOS II response: %s\n",
bladerf_strerror(status));
}
return status;
}
开发者ID:VergilYotov,项目名称:bladeRF,代码行数:60,代码来源:nios_legacy_access.c
示例7: flow
void flow(struct lfc *lfc, void *mydata,
struct lfc_flow *flow, void *flowdata)
{
struct flowdata *fd = flowdata;
print_buf(fd->up, fd->ups);
print_buf(fd->down, fd->downs);
}
开发者ID:VaniKandhasamy,项目名称:flowcalc,代码行数:8,代码来源:payload.c
示例8: shader_write_scale_dim
static void shader_write_scale_dim(config_file_t *conf, const char *dim,
enum gfx_scale_type type, float scale, unsigned abs, unsigned i)
{
char key[64];
print_buf(key, "scale_type_%s%u", dim, i);
config_set_string(conf, key, scale_type_to_str(type));
print_buf(key, "scale_%s%u", dim, i);
if (type == RARCH_SCALE_ABSOLUTE)
config_set_int(conf, key, abs);
else
config_set_float(conf, key, scale);
}
开发者ID:CyberShadow,项目名称:RetroArch,代码行数:13,代码来源:shader_parse.c
示例9: cmd_spi
int cmd_spi(int argc, char * const argv[])
{
struct w25qxx_init_t init;
uint32_t i, buf_size;
static uint8_t buf[256];
struct w25qxx_attr_t w25qxx;
init.delayms = DelayMs;
init.get_reamin = _get_reamin;
init.xfer = xfer;
SPI_QuickInit(SPI0_MOSI_PA7_MISO_PA6, kSPI_CPOL1_CPHA1, 100*1000);//配置PTA7为MOSI PTA6为MISO, 波特率为100K,但是实际波特率要根据匹配出来的寄存器值算,有些误差
GPIO_QuickInit(HW_GPIOA, 5, kGPIO_Mode_OPP); //PTA5 SS
GPIO_WriteBit(HW_GPIOA, 5, 1);
PORT_PinMuxConfig(HW_GPIOB,0,kPinAlt3); //PTB0 SCK
w25qxx_init(&init); //外部flash初始化
w25qxx_get_attr(&w25qxx);
buf_size = sizeof(buf);
/*读取外部flash256个字节*/
printf("reading page...\n");
w25qxx_read(0, buf, buf_size);
print_buf(buf,PAGE_SIZE);
/*擦除整个外部flash芯片*/
printf("erase all chips...\r\n");
w25qxx_erase_chip();
printf("erase complete\r\n");
/*读取外部flash256个字节*/
printf("reading page...\n");
w25qxx_read(0, buf, buf_size);
print_buf(buf,PAGE_SIZE);
/*编程外部flash256个字节*/
printf("programing a page...\n");
for(i=0;i<256;i++)
buf[i] = i;
w25qxx_write(0, buf, buf_size);
printf("clearing buffer..\n");
for(i=0;i<256;i++)
buf[i] = 0;
/*读取外部flash256个字节*/
printf("reading page...\n");
w25qxx_read(0, buf, buf_size);
print_buf(buf,PAGE_SIZE);
printf("demo end.\n");
return 0;
}
开发者ID:zwzmzd,项目名称:kl02z,代码行数:51,代码来源:spi_test.c
示例10: shader_parse_textures
static bool shader_parse_textures(config_file_t *conf,
struct gfx_shader *shader)
{
const char *id;
char *save;
char textures[1024];
if (!config_get_array(conf, "textures", textures, sizeof(textures)))
return true;
for (id = strtok_r(textures, ";", &save);
id && shader->luts < GFX_MAX_TEXTURES;
shader->luts++, id = strtok_r(NULL, ";", &save))
{
if (!config_get_array(conf, id, shader->lut[shader->luts].path,
sizeof(shader->lut[shader->luts].path)))
{
RARCH_ERR("Cannot find path to texture \"%s\" ...\n", id);
return false;
}
strlcpy(shader->lut[shader->luts].id, id,
sizeof(shader->lut[shader->luts].id));
char id_filter[64];
print_buf(id_filter, "%s_linear", id);
bool smooth = false;
if (config_get_bool(conf, id_filter, &smooth))
shader->lut[shader->luts].filter = smooth ?
RARCH_FILTER_LINEAR : RARCH_FILTER_NEAREST;
else
shader->lut[shader->luts].filter = RARCH_FILTER_UNSPEC;
char id_wrap[64];
print_buf(id_wrap, "%s_wrap_mode", id);
char wrap_mode[64];
if (config_get_array(conf, id_wrap, wrap_mode, sizeof(wrap_mode)))
shader->lut[shader->luts].wrap = wrap_str_to_mode(wrap_mode);
char id_mipmap[64];
print_buf(id_mipmap, "%s_mipmap", id);
bool mipmap = false;
if (config_get_bool(conf, id_mipmap, &mipmap))
shader->lut[shader->luts].mipmap = mipmap;
else
shader->lut[shader->luts].mipmap = false;
}
return true;
}
开发者ID:CyberShadow,项目名称:RetroArch,代码行数:50,代码来源:shader_parse.c
示例11: shader_write_fbo
static void shader_write_fbo(config_file_t *conf, const struct gfx_fbo_scale *fbo, unsigned i)
{
char key[64];
print_buf(key, "float_framebuffer%u", i);
config_set_bool(conf, key, fbo->fp_fbo);
print_buf(key, "srgb_framebuffer%u", i);
config_set_bool(conf, key, fbo->srgb_fbo);
if (!fbo->valid)
return;
shader_write_scale_dim(conf, "x", fbo->type_x, fbo->scale_x, fbo->abs_x, i);
shader_write_scale_dim(conf, "y", fbo->type_y, fbo->scale_y, fbo->abs_y, i);
}
开发者ID:zero2029,项目名称:RetroArch-1,代码行数:14,代码来源:shader_parse.c
示例12: snappy_pull_cb
static hg_return_t
snappy_pull_cb(const struct hg_bulk_cb_info *hg_bulk_cb_info)
{
struct snappy_transfer_args *snappy_transfer_args =
(struct snappy_transfer_args *) hg_bulk_cb_info->arg;
hg_return_t ret = HG_SUCCESS;
void *input;
size_t input_length;
size_t source_length = HG_Bulk_get_size(snappy_transfer_args->local_input_bulk_handle);
/* Get pointer to input buffer from local handle */
HG_Bulk_access(hg_bulk_cb_info->local_handle, 0, source_length,
HG_BULK_READ_ONLY, 1, &input, &input_length, NULL);
printf("Transferred input buffer of length: %zu\n", input_length);
print_buf(20, (int *) input);
/* Allocate compressed buffer for compressing input data */
snappy_transfer_args->compressed_length = snappy_max_compressed_length(input_length);
snappy_transfer_args->compressed = malloc(snappy_transfer_args->compressed_length);
/* Compress data */
printf("Compressing buffer...\n");
snappy_transfer_args->ret = snappy_compress(input, input_length,
snappy_transfer_args->compressed, &snappy_transfer_args->compressed_length);
printf("Return value of snappy_compress is: %d\n", snappy_transfer_args->ret);
printf("Compressed buffer length is: %zu\n", snappy_transfer_args->compressed_length);
print_buf(5, (int *) snappy_transfer_args->compressed);
/* Free bulk handles */
HG_Bulk_free(snappy_transfer_args->local_input_bulk_handle);
if (snappy_validate_compressed_buffer(snappy_transfer_args->compressed,
snappy_transfer_args->compressed_length) == SNAPPY_OK) {
printf("Compressed buffer validated: compressed successfully\n");
}
/* Now set up bulk transfer for "push to origin" callback */
HG_Bulk_create(HG_Get_info(snappy_transfer_args->handle)->hg_bulk_class, 1,
&snappy_transfer_args->compressed, &snappy_transfer_args->compressed_length,
HG_BULK_WRITE_ONLY, &snappy_transfer_args->local_compressed_bulk_handle);
HG_Bulk_transfer(HG_Get_info(snappy_transfer_args->handle)->bulk_context,
snappy_push_cb, snappy_transfer_args,
HG_BULK_PUSH, HG_Get_info(snappy_transfer_args->handle)->addr,
snappy_transfer_args->snappy_compress_input.compressed_bulk_handle, 0, /* origin */
snappy_transfer_args->local_compressed_bulk_handle, 0, /* local */
snappy_transfer_args->compressed_length, HG_OP_ID_IGNORE);
return ret;
}
开发者ID:ifadams,项目名称:mercury,代码行数:50,代码来源:example_snappy.c
示例13: deal_packet
void deal_packet( char *argc, const struct pcap_pkthdr *pcap_hdr, const char *buf)
{
uint64_t leng;
leng = pcap_hdr->len;
print_buf(buf, leng);
}
开发者ID:zbh-gitbub,项目名称:gap16g_libpcap,代码行数:7,代码来源:check.c
示例14: task_yield
void task_yield() {
disable_irq();
struct task_t *current_task = task_current();
struct list_node_t *next_task_it;
struct task_t *next_task;
if ( task_is_active(current_task) ) {
next_task_it = current_task_it->next;
}
else {
next_task_it = list_first(active_tasks);
}
next_task = (struct task_t *)next_task_it->data;
task_print("task_yield:", current_task, next_task);
if ( current_task == next_task ) {
return;
};
if ( next_task == 0 ) {
print_buf("ERROR: next_task=0\n");
};
current_task_it = next_task_it;
task_switch(¤t_task->sp, next_task->sp);
}
开发者ID:vincent10,项目名称:RaspberryPi-1,代码行数:26,代码来源:task.c
示例15: talk_notes
void talk_notes()
{
short i,item_hit;
store_num_i = 0;
for (i = 0; i < 120; i++)
if (univ.party.talk_save[i].personality != -1)
store_num_i = i + 1;
store_page_on = 0;
if (store_num_i == 0) {
ASB("Nothing in your talk journal.");
print_buf();
return;
}
make_cursor_sword();
cd_create_dialog_parent_num(960,0);
put_talk();
if (store_num_i == 1) {
cd_activate_item(960,10,0);
cd_activate_item(960,11,0);
}
item_hit = cd_run_dialog();
cd_kill_dialog(960);
}
开发者ID:PBrookfield,项目名称:cboe-msvc,代码行数:30,代码来源:boe.infodlg.cpp
示例16: print_reply_hdr
static void
print_reply_hdr (Call *call, const char *buf, int len)
{
Call_Private_Data *priv = CALL_PRIVATE_DATA (call);
const char *eoh;
if (len <= 0 || priv->done_with_reply_hdr)
return;
eoh = strstr (buf, "\r\n\r\n");
if (eoh)
{
priv->done_with_reply_hdr = 1;
eoh += 4;
}
else
{
/* no CRLFCRLF: non-conforming server */
eoh = strstr (buf, "\n\n");
if (eoh)
{
priv->done_with_reply_hdr = 1;
eoh += 2;
}
else
eoh = buf + len;
}
print_buf (call, "RH", buf, eoh - buf);
}
开发者ID:doublek,项目名称:httperf,代码行数:29,代码来源:print_reply.c
示例17: main
int main(int argc, char **argv)
{
if (argc < 2) {
printf("%s %d.%d\n", version, hd_major, hd_miner);
printf("Usage: %s [file]\n", argv[0]);
return -1;
}
FILE *fp = fopen(argv[1], "r");
if (!fp) {
printf("Failed to open file %s.\n", argv[1]);
return -1;
}
fseek(fp, 0, SEEK_END);
int size = ftell(fp);
char *buf = (char*)malloc(size);
if (!buf) {
printf("Failed to allocate memory.\n");
return -1;
}
fseek(fp, 0, SEEK_SET);
int rsize = fread(buf, sizeof(char), size, fp);
if (rsize != size) {
printf("Reading error.\n");
return -1;
}
print_buf(buf, size);
free(buf);
fclose(fp);
return 0;
}
开发者ID:matrix207,项目名称:C,代码行数:33,代码来源:hexdump.c
示例18: print_request
static void
print_request (Call *call)
{
size_t hdr_len, h_len, b_len;
int i, first, end;
char *hdr;
first = IE_CONTENT;
end = IE_CONTENT;
if ((param.print_request & PRINT_HEADER) != 0)
first = IE_METHOD;
if ((param.print_request & PRINT_BODY) != 0)
end = IE_LEN;
for (i = first; i < end; ++i)
{
hdr = call->req.iov[i].iov_base;
hdr_len = call->req.iov[i].iov_len;
if (hdr_len)
print_buf (call, (i < IE_CONTENT) ? "SH" : "SB", hdr, hdr_len);
}
for (h_len = 0, i = IE_METHOD; i < IE_CONTENT; ++i)
h_len += call->req.iov[i].iov_len;
for (b_len = 0, i = IE_CONTENT; i < IE_LEN; ++i)
b_len += call->req.iov[i].iov_len;
printf ("SS%ld: header %ld content %ld\n",
call->id, (long) h_len, (long) b_len);
}
开发者ID:doublek,项目名称:httperf,代码行数:34,代码来源:print_reply.c
示例19: deseralize
std::list<shared_buffer> length_packer::split(net_buffer &oRecvBuffer) {
std::list<shared_buffer> resPkgs;
if (oRecvBuffer.length() <= 4)
return resPkgs;
uint32_t len;
const char *pBuf = asio::buffer_cast<const char *>(oRecvBuffer.readable());
uint32_t buf_len = oRecvBuffer.length();
size_t bi = 0;
deseralize(pBuf + bi, len);
while (buf_len - bi >= sizeof(len) &&
buf_len - bi - sizeof(len) >= len) {
LOG(INFO) << "length_packer::split() buffer is "
<< print_buf(asio::buffer_cast<const char *>(oRecvBuffer.readable()),
oRecvBuffer.filled());
LOG(INFO) << "length_packer::split() " << "split pkg with len:" << len;
bi += sizeof(len);
shared_buffer sb(pBuf + bi, len);
resPkgs.push_back(sb);
bi += len;
deseralize(pBuf + bi, len);
}
oRecvBuffer.read() = bi;
if(oRecvBuffer.read() == oRecvBuffer.filled())
{
oRecvBuffer.read() = 0;
oRecvBuffer.filled() = 0;
}
return resPkgs;
}
开发者ID:AthrunArthur,项目名称:ffnet,代码行数:33,代码来源:length_packer.cpp
示例20: handle_print
static void handle_print( void )
{
static char outname[ 256 ] = { "out.txt" };
static char comment[ 256 ] = { "BinView Output" };
static int range = 0, mode = 0, flags = 7;
FILE *ofp;
int rlen, ok;
long p, plen;
ok = print_ui( outname, &range, &mode, &flags, comment );
if ( !ok ) return;
ofp = fopen( outname, mode ? "a" : "w" );
if ( !ofp ) return;
fprintf( ofp, "%s\n", comment );
p = range ? 0 : pos;
plen = range ? filesize : pagesize;
fseek( fp, p, SEEK_SET );
while ( plen ) {
rlen = fread( buf, 1, pagesize, fp );
if ( rlen <= 0 ) break;
print_buf( buf, rlen, datatype, unsign, byteorder != natorder,
linesize, p, flags, ofp );
p += rlen;
plen -= rlen;
}
fclose( ofp );
fseek( fp, pos, SEEK_SET );
}
开发者ID:DimondTheCat,项目名称:xray,代码行数:31,代码来源:window.c
注:本文中的print_buf函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论