本文整理汇总了C++中print_buffer函数的典型用法代码示例。如果您正苦于以下问题:C++ print_buffer函数的具体用法?C++ print_buffer怎么用?C++ print_buffer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了print_buffer函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: print_client
static void print_client(struct client *client) {
if(client == NULL)
fprintf(stderr, "NO_CLIENT");
else {
fprintf(stderr, "(%p): ", client);
switch(client->type) {
case REQ_RESP:
fprintf(stderr, "FD = '%d'; TYPE = '%s'; ARCH = '%s'; STATE = '%s'\n", client->fd,
client_type_2_str(client->type),
aconv_arch2str(client->arch),
client_state_2_str(client->state));
print_buffer(client->rbuf, "Read buffer");
print_buffer(client->wbuf, "Write buffer");
break;
case EVENT_SUB:
fprintf(stderr, "FD = '%d'; TYPE = '%s'; STATE = '%s''\n", client->fd,
client_type_2_str(client->type), client_state_2_str(client->state));
print_buffer(client->rbuf, "Read buffer");
print_buffer(client->wbuf, "Write buffer");
break;
default:
fprintf(stderr, "DATA_FD = '%d'; TYPE = '%s'; EVENT SUB FD INDEX = %d",
client->fd, client_type_2_str(client->type), client->esfd_index);
break;
}
}
}
示例2: main
int main(int argc, const char* argv[]) {
FILE *fp;
// 需从流中读或写才能建立缓冲区,获取准确的默认缓冲大小,否则会获取到0
fputs("enter to activate stdin buffer size\n", stdout);
if (getc(stdin) == EOF) {
err_sys("getc error");
}
//fputs("activate stdout\n", stderr);
print_buffer("stdin", stdin);
print_buffer("stdout", stdout);
print_buffer("stderr", stderr);
if ((fp = fopen("file.txt", "a+")) == NULL) {
err_sys("fopen error");
}
// 需从流中读或写才能建立缓冲区,获取准确的默认缓冲大小
if (putc('A', fp) == EOF) {
err_sys("putc error");
}
print_buffer("file.txt", fp);
exit(0);
}
示例3: delete_from_buffer
int delete_from_buffer(bool right) {
if(right) {
forward_buffer();
} else {
wprintf(L"\033[1D");
}
if(buffer->current == NULL) {
return RET_OK;
} else {
wprintf(L"\033[K");
}
delete_elem(buffer);
if(buffer->current == NULL) {
print_buffer(true);
wprintf(L"\033[1D");
return RET_OK;
}
if(buffer->current->next != NULL) {
forward_buffer();
print_buffer(true);
backward_buffer();
wprintf(L"\033[1D");
}
return RET_OK;
}
示例4: new_ioctl
static int new_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) {
int ret = 0;
struct iwreq *iwr = (struct iwreq *) ifr;
struct iw_request_info info;
#ifdef DEBUG
printk("dev: %s ioctl: 0x%04x\n",dev->name,cmd);
#endif
if (cmd >= SIOCIWFIRSTPRIV) {
info.cmd = cmd;
info.flags = 0;
ret = wlcompat_private_ioctl(dev, &info, &(iwr->u), (char *) &(iwr->u));
#ifdef DEBUG
} else if (cmd==SIOCDEVPRIVATE) {
wl_ioctl_t *ioc = (wl_ioctl_t *)ifr->ifr_data;
unsigned char *buf = ioc->buf;
printk(" cmd: %d buf: 0x%08x len: %d\n",ioc->cmd,&(ioc->buf),ioc->len);
printk(" send: ->");
print_buffer(ioc->len, buf);
ret = old_ioctl(dev,ifr,cmd);
printk(" recv: ->");
print_buffer(ioc->len, buf);
printk(" ret: %d\n", ret);
#endif
} else {
ret = old_ioctl(dev,ifr,cmd);
}
return ret;
}
示例5: TEST
TEST ()
{
GeglBuffer *buffer, *sub, *subsub, *foo;
GeglRectangle subrect = {5, 5, 10, 10};
GeglRectangle foor = {0, 0, 10, 10};
GeglRectangle rect = {0, 0, 20, 20};
test_start ();
buffer = gegl_buffer_new (&rect, babl_format ("Y float"));
sub = gegl_buffer_create_sub_buffer (buffer, &subrect);
vgrad (buffer);
vgrad (sub);
subsub = g_object_new (GEGL_TYPE_BUFFER,
"source", sub,
"x", 0,
"y", 0,
"width", 40,
"height", 40,
"shift-x", 0,
"shift-y", 0,
NULL);
foo = gegl_buffer_create_sub_buffer (subsub, &foor);
/*fill (subsub, 0.2);*/
print_buffer (buffer);
print_buffer (foo);
g_object_unref (sub);
g_object_unref (subsub);
g_object_unref (buffer);
g_object_unref (foo);
test_end ();
}
示例6: open_device
bool open_device( struct pclta_device * device )
{
CALL_MSG( "Starting open_device()", ++pclta_call_level );
// allocate and initialize buffers
device->rx = kmalloc( sizeof(struct pclta_packet_buffer), GFP_KERNEL );
if( device->rx == NULL ) {
RETURN_MSG( "open_device() ERROR= device->rx == NULL", pclta_call_level-- );
return false;
}
device->tx = kmalloc( sizeof(struct pclta_packet_buffer), GFP_KERNEL );
if( device->tx == NULL ) {
kfree( device->rx );
RETURN_MSG( "open_device() ERROR= device->tx == NULL", pclta_call_level-- );
return false;
}
init_buffers( device->rx );
DEBUG_MSG("RECEIVE BUFFER");
print_buffer(device->rx);
init_buffers( device->tx );
DEBUG_MSG("TRANSMIT BUFFER");
print_buffer(device->tx);
// set initial state of device
device->restart_uplink = false;
device->pclta_wait_queue = NULL;
// last_packet_read_complete=true; // for incomplete reads
RETURN_MSG( "open_device() SUCCESS", pclta_call_level-- );
return true;
}
示例7: test01
/* Test 1: Add temperature and humidity */
static void test01(lora_serialization_t *serialization)
{
puts("Test 1");
puts("Temperature and humidity");
puts("---------------------------------");
lora_serialization_reset(serialization); // Always reset
puts("- Writing temperature: 80.12");
lora_serialization_write_temperature(serialization, 80.12);
puts("- Writing humidity: 99.99");
lora_serialization_write_humidity(serialization, 99.99);
printf("- Encoded: ");
print_buffer(serialization->buffer,
LORA_SERIALIZATION_TEMPERATURE_SIZE +
LORA_SERIALIZATION_HUMIDITY_SIZE);
puts("");
printf("- Expected:");
print_buffer(test01Expected, sizeof(test01Expected));
puts("");
puts("---------------------------------");
if (memcmp(serialization->buffer, test01Expected,
sizeof(test01Expected)) != 0) {
puts("FAILED");
}
else {
puts("SUCCESS");
}
}
示例8: consume2
// Consumer 2 consumes the first node from the list if its value is even
consume2(){
int i;
for(i=0;i<10;i++){
pthread_mutex_lock(&mymutex);
printf("\nConsumer 2 Running");
if(buffer_size>1){
if(((bhead->value)%2)==0){
print_buffer();
bhead = bhead->next;
free(bhead->prev);
bhead->prev = 0;
buffer_size--;
print_buffer();
}
} else if(buffer_size==1){
if(((bhead->value)%2)==0){
print_buffer();
free(bhead);
bhead = 0;
buffer_size--;
print_buffer();
}
} else {
printf("\nBuffer underflow on Consumer 2!");
}
pthread_mutex_unlock(&mymutex);
sleep(1);
}
return;
}
示例9: produce1
// Producer 1 generates a new node at the end of the buffer with an odd value
produce1(){
int i;
for(i=0;i<10;i++){
pthread_mutex_lock(&mymutex);
if(buffer_size<BUFFER_MAX){
printf("\nProducer 1 Running");
print_buffer();
struct node* new_node = malloc(sizeof(struct node));
int new_value = rand()%39;
if((new_value%2)==0){
new_value++;
}
new_node->value = new_value;
new_node->next = 0;
// Special case if list is empty:
if(buffer_size==0){
new_node->prev = 0;
bhead = new_node;
} else {
new_node->prev = btail;
btail->next = new_node;
}
btail = new_node;
buffer_size++;
print_buffer();
} else {
printf("\nBuffer overflow on Producer 1!");
}
pthread_mutex_unlock(&mymutex);
sleep(1);
}
return;
}
示例10: test02
/* Test 2: Add GPS coordinates and unix time */
static void test02(lora_serialization_t *serialization)
{
puts("Test 2");
puts("Coordinates and unix time");
puts("---------------------------------");
lora_serialization_reset(serialization); // Always reset
puts("- Writing coordinates: -33.905052, 151.26641");
lora_serialization_write_coordinates(serialization, -33.905052, 151.26641);
puts("- Writing unix time: 1467632413");
lora_serialization_write_unix_time(serialization, 1467632413);
printf("- Encoded: ");
print_buffer(serialization->buffer,
LORA_SERIALIZATION_GPS_SIZE +
LORA_SERIALIZATION_UNIX_TIME_SIZE);
puts("");
printf("- Expected:");
print_buffer(test02Expected, sizeof(test02Expected));
puts("");
puts("---------------------------------");
if (memcmp(serialization->buffer, test02Expected,
sizeof(test02Expected)) != 0) {
puts("FAILED");
}
else {
puts("SUCCESS");
}
}
示例11: do_test_write_append_without_null
/* This test check append mode initial position (a/a+) based on POSIX defition
(BZ#6544 and BZ#13151) for buffer without null byte end. */
static int
do_test_write_append_without_null (const char *mode)
{
char buf[] = { 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55 };
char exp[] = { 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55 };
/* If '\0' is not found in buffer, POSIX states that SEEK_SET should be
the size argument. */
FILE *fp = fmemopen (buf, sizeof (buf) - 2, "a");
fflush (fp);
fputc (0x70, fp);
fseek (fp, 0, SEEK_SET);
fputc (0x70, fp);
fputc (0x70, fp);
fclose (fp);
/* POSIX also states that a write operation on the stream shall not advance
the current buffer size beyond the size given in fmemopen, so the string
should be same. */
if (memcmp (buf, exp, sizeof (buf)) != 0)
{
printf ("%s: check failed: ", __FUNCTION__);
print_buffer (buf, sizeof (buf));
printf ("!= ");
print_buffer (exp, sizeof (exp));
printf ("\n");
return 1;
}
return 0;
}
示例12: do_test_read_seek_neg
/* This test check for fseek (SEEK_END) using negative offsets (BZ#14292). The
starting position of descriptor is different base on the opening mode. */
static int
do_test_read_seek_neg (const char *mode, const char *expected)
{
char buf[] = "abcdefghijklmnopqrstuvxz0123456789";
char tmp[10];
size_t tmps = sizeof (tmps);
long offset = -11;
FILE *fp = fmemopen (buf, sizeof (buf), mode);
fseek (fp, offset, SEEK_END);
fread (tmp, tmps, 1, fp);
if (memcmp (tmp, expected, tmps) != 0)
{
printf ("%s: fmemopen(%s) - fseek (fp, %li, SEEK_END):\n",
__FUNCTION__, mode, offset);
printf (" returned: ");
print_buffer (tmp, tmps);
printf ("\n");
printf (" expected: ");
print_buffer (expected, tmps);
printf ("\n");
return 1;
}
fclose (fp);
return 0;
}
示例13: testHash
void testHash()
{
unsigned char Digest[32];
sha256_context ctx;
sha256_init( &ctx );
sha256_starts( &ctx, 0 );
sha256_update( &ctx, sha256_test_buf[0], sha256_test_buflen[0] );
sha256_finish( &ctx, Digest );
print_buffer(Digest, sizeof(Digest));
memset(Digest, 0, sizeof(Digest));
uint8 buffer[1];
sha256_init( &ctx );
sha256_starts( &ctx, 0 );
buffer[0] = 'a';
sha256_update( &ctx, buffer, 1 );
buffer[0] = 'b';
sha256_update( &ctx, buffer, 1 );
buffer[0] = 'c';
sha256_update( &ctx, buffer, 1 );
buffer[0] = '\0';
sha256_update( &ctx, buffer, 1 );
sha256_finish( &ctx, Digest );
print_buffer(Digest, sizeof(Digest));
}
示例14: TEST
TEST ()
{
GeglBuffer *buffer, *sub1, *sub2, *sub3;
GeglRectangle subrect1 = {5, 5, 10, 10};
GeglRectangle subrect2 = {8, 8, 30, 30};
GeglRectangle subrect3 = {-2, -2, 24, 24};
GeglRectangle rect = {0, 0, 20, 20};
test_start ();
buffer = gegl_buffer_new (&rect, babl_format ("Y float"));
sub1 = gegl_buffer_create_sub_buffer (buffer, &subrect1);
sub2 = gegl_buffer_create_sub_buffer (buffer, &subrect2);
sub3 = gegl_buffer_create_sub_buffer (buffer, &subrect3);
fill (sub1, 0.5);
print (("root with sub1 filled in:\n"));
print_buffer (buffer);
print (("sub2 before fill:\n"));
print_buffer (sub2);
fill (sub2, 1.0);
print (("final root:\n"));
print_buffer (buffer);
print (("final sub1:\n"));
print_buffer (sub1);
print (("final sub3:\n"));
print_buffer (sub3);
gegl_buffer_destroy (sub1);
gegl_buffer_destroy (sub2);
gegl_buffer_destroy (sub3);
gegl_buffer_destroy (buffer);
test_end ();
}
示例15: print_ia
/* prints a newline at the end of the address info */
void print_ia (struct internet_addr * ia)
{
printf ("v %d, port %d, addr ", ia->ip_version, ntohs (ia->port));
if (ia->ip_version == 4)
print_buffer (((char *) &(ia->ip)) + 12, 4, NULL, 4, 1);
else
print_buffer ((char *) &(ia->ip), 16, NULL, 16, 1);
}