• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ print_buffer函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了print_buffer函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
    }
  }
}
开发者ID:virtualsquare,项目名称:view-os,代码行数:27,代码来源:pollfd_info.c


示例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);
}
开发者ID:newaowen,项目名称:myapue,代码行数:25,代码来源:printf_io_buffer.c


示例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;
}
开发者ID:Jibux,项目名称:wtfshell,代码行数:30,代码来源:wtfshell.c


示例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;
}
开发者ID:anchowee,项目名称:linino,代码行数:30,代码来源:wlcompat.c


示例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 ();
}
开发者ID:AjayRamanathan,项目名称:gegl,代码行数:32,代码来源:get_shifted.c


示例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;
}
开发者ID:NhaTrang,项目名称:lon4linux,代码行数:34,代码来源:pclta.c


示例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");
    }
}
开发者ID:A-Paul,项目名称:RIOT,代码行数:33,代码来源:main.c


示例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;
}
开发者ID:jdebr,项目名称:os460,代码行数:31,代码来源:lab2.c


示例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;
}
开发者ID:jdebr,项目名称:os460,代码行数:34,代码来源:lab2.c


示例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");
    }
}
开发者ID:A-Paul,项目名称:RIOT,代码行数:33,代码来源:main.c


示例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;
}
开发者ID:RobbenBasten,项目名称:glibc,代码行数:34,代码来源:tst-fmemopen3.c


示例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;
}
开发者ID:RobbenBasten,项目名称:glibc,代码行数:31,代码来源:tst-fmemopen3.c


示例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));


}
开发者ID:dileepkella85,项目名称:trunk,代码行数:35,代码来源:crypto.c


示例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 ();
}
开发者ID:jcupitt,项目名称:gegl-vips,代码行数:33,代码来源:sub_rect_fills_and_gets.c


示例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);
}
开发者ID:abrauchli,项目名称:allnet,代码行数:9,代码来源:ai.c


示例16: TestAESCrypto

////////////////////////////////////////////////////////////////////////////
//
// AES Encryption / Decryption - ECB Blocks
//
////////////////////////////////////////////////////////////////////////////
status TestAESCrypto( void )
{
   uint8 ret;
   uint8 buffer[512]; // AES - CBC can take less than 256 bytes as input

   uint8 key[16];    // Key can be 16 bytes ~ 128 AES or 32 bytes 256 AES
   uint8 iv[16];     // iv fixed random value of 16 bytes
   uint8 updated_iv[16];

   entropy_init( &entropy );
   if( ( ctr_drbg_init( &ctr_drbg, entropy_func, &entropy,
                         (const unsigned char *) pers,
                          strlen( pers ) ) ) != 0 )
   {
      proj_printf( " failed\n  ! ctr_drbg_init returned -0x%x\n", -ret );
      return ( FAIL );
   }

   //DRBG test
   proj_printf("INF: DRBG test - generate Random number");
   PrngGenerateBytes( buffer, sizeof(buffer));
   print_buffer(buffer,sizeof(buffer));

   // Setting key, iv and buffer values
   memset(buffer, 0xA5, sizeof(buffer));
   print_buffer(buffer,sizeof(buffer));

   PrngGenerateBytes(key,sizeof(key));
   print_buffer(key,sizeof(key));

   PrngGenerateBytes(iv,sizeof(iv));
   print_buffer(iv,sizeof(iv));

   // AES -CBC test
   memcpy(updated_iv, iv, sizeof(iv));

   AESCryptCBC( key, sizeof(key), AES_ENCRYPT, updated_iv, sizeof(buffer), buffer, buffer );
   print_buffer(buffer, sizeof(buffer));

   AESCryptCBC( key, sizeof(key), AES_DECRYPT, iv, sizeof(buffer), buffer, buffer );
   print_buffer(buffer, sizeof(buffer));

   // AES - ECB
   AESCryptECB( key, sizeof(key), AES_ENCRYPT, buffer, buffer );
   print_buffer(buffer, sizeof(buffer));

   AESCryptECB( key, sizeof(key), AES_DECRYPT, buffer, buffer );
   print_buffer(buffer, sizeof(buffer));

   // AES - ECB Blocks
   AESCryptECB_Blocks( key, sizeof(key), AES_ENCRYPT, sizeof(buffer)/16, buffer, buffer );
   print_buffer(buffer, sizeof(buffer));

   AESCryptECB_Blocks( key, sizeof(key), AES_DECRYPT, sizeof(buffer)/16, buffer, buffer );
   print_buffer(buffer, sizeof(buffer));

   return ( PASS );
}
开发者ID:dileepkella85,项目名称:trunk,代码行数:63,代码来源:crypto.c


示例17: main

int main()
{
	interrupt_count = 0;
	transfer_count = 0;
	tx_count = 0;
	rx_count = 0;

	uint32_t output_count = 0;
	uint32_t sum = 0;
	
	
	init();
	// initialize buffers with some known value
	memset(tx_buffer,0x55,sizeof(tx_buffer));
	memset(rx_buffer,0x22,sizeof(rx_buffer));
	
	// configure SPI
	MAP_SPIReset(GSPI_BASE);
    MAP_SPIConfigSetExpClk(GSPI_BASE,MAP_PRCMPeripheralClockGet(PRCM_GSPI),
                     SPI_IF_BIT_RATE,SPI_MODE_SLAVE,SPI_SUB_MODE_0,
                     (SPI_HW_CTRL_CS |
                     SPI_4PIN_MODE |
                     SPI_TURBO_OFF |
                     SPI_CS_ACTIVEHIGH |
                     SPI_WL_8));	
	MAP_SPIIntRegister(GSPI_BASE,interrupt_handler);
	MAP_SPIIntEnable(GSPI_BASE,SPI_INT_RX_FULL|SPI_INT_TX_EMPTY);
	MAP_SPIEnable(GSPI_BASE);
    Message("Enabled SPI Interface in Slave Mode!\n\r");

	Message("Starting while\n\r");
    while(1)
    {

		memcpy(tx_buffer,rx_buffer,TR_BUFF_SIZE);
		// here we could also change the tx_buffer
		// e.g.	tx_buffer[TR_BUFF_SIZE - 1] = 18;
		sum = 0;
		if(output_count < transfer_count)
		{
			for(int i = 0; i < TR_BUFF_SIZE; i++)
			{
				sum += rx_buffer[i];
			}
			Report("The sum in the Rx buffer is: %d\n\r",sum);
			Report("Checksum Rx buffer is: 0x%02x\n\r",crc(rx_buffer));
			Report("interrupt: %d, tx: %d, rx: %d, transfer: %d\n\r",interrupt_count,tx_count,rx_count, transfer_count);
			Message("TX-");
			print_buffer(tx_buffer,TR_BUFF_SIZE);
			Message("RX-");
			print_buffer(rx_buffer,TR_BUFF_SIZE);
			output_count++;
		}

    }
	return 0;
}
开发者ID:HackLinux,项目名称:cc3200_dma_spi_example,代码行数:57,代码来源:slave.c


示例18: run_tests

 int run_tests() {
  int i;
  int success = 0, total = 0;
  for (i = 0; i < (sizeof(test_cases) / sizeof(test_cases[0])); i++) {
    struct in6_addr addr, correct;
    uint8_t buf[512];
    char *rv;
    uint8_t *btr = test_cases[i].buf;
    size_t len = 32;
    int ret;
    uint8_t stateful;
    ieee154_addr_t l2addr;
    total++;

    inet_pton6(test_cases[i].address, &correct);

    ieee154_parse(test_cases[i].l2addr, &l2addr);
    ieee154_print(&l2addr, buf, 512);
    printf("%s\n", buf);
    printf("in6_addr: %s\n", test_cases[i].address);
    ret = unpack_address(&addr,
                         test_cases[i].dispatch,
                         test_cases[i].context,
                         &btr,
                         &len,
                         &l2addr,
                         test_cases[i].panid,
                         &stateful);

    inet_ntop6(&addr, buf, 512);
    printf("result: %s length: %li\n", buf, 32 - len);

    if (test_cases[i].len != 32 - len) {
      printf("case %u: result len: %li expected: %i\n",
             i, 32 - len, test_cases[i].len);
      continue;
    }

    if (memcmp(&addr, &correct, 16) != 0) {
      printf("case %u: unexpected result\n", i);
      print_buffer(correct.s6_addr, 16);
      print_buffer(addr.s6_addr, 16);
      continue;
    }

    if (test_cases[i].stateful != stateful) {
      printf("case %u: stateful compression was used!\n", test_cases[i].stateful);
      continue;
    }

    success++;
  }
  printf("%s: %i/%i tests succeeded\n", __FILE__, success, total);
  if (success == total) return 0;
  return 1;
}
开发者ID:AkramAlomainy,项目名称:tinyos-main,代码行数:56,代码来源:test_unpack_address.c


示例19: check_test

int check_test(struct ip6_packet *pkt, struct lowpan_reconstruct *recon) {
  char buf[2048];
  memset(buf, 0, 2048);
  memcpy(buf, &pkt->ip6_hdr, sizeof(struct ip6_hdr));
  iov_read(pkt->ip6_data, 0, iov_len(pkt->ip6_data), &buf[sizeof(struct ip6_hdr)]);
  
  // printf("CMP: %i", memcmp(buf, recon->r_buf, recon->r_bytes_rcvd));
  print_buffer(buf, 50);
  print_buffer(recon->r_buf, 50);
  printf("CMP: %i\n", memcmp(buf, recon->r_buf, 50));
}
开发者ID:0111sandesh,项目名称:TinyOS-Sec,代码行数:11,代码来源:test_lowpan_frag_get.c


示例20: edit_vocab

void edit_vocab(vocab_t *pnodoedit, char secmea[]) {

	pantalla_t *pant = get_curses();

	char opcion = '0';

	char *str=NULL;

	str = (char *)malloc(sizeof(char)*TAM_BUF);
	if (!str) {
		exit_mem(EXIT_FAILURE, "Not enough memory.");
	}
	
	//wprintw(pant->buffer,"\n");
	print_buffer_new_line();
	while ((opcion != 'y') && (opcion != 'n')) {
		if (pnodoedit->pkanji) {
			snprintf(str, TAM_BUF, "%s (%s) -> \"%s\" ¿ok? (y/n): ",pnodoedit->pkanji,pnodoedit->phiragana,secmea);
		} else {
			snprintf(str, TAM_BUF, "%s -> %s \"¿ok?\" (y/n): ",pnodoedit->phiragana,secmea);
		}

		print_buffer(str, true);
		
		upgrade_buffer(true);
		opcion = wgetch(pant->ppal);
		print_buffer_new_line();
	}
	
	if (opcion == 'y') {
	
		if (!pnodoedit->pmeaning) {
			pnodoedit->pmeaning = (char *)malloc ((strlen(secmea)+1)*sizeof(char));
			if (!pnodoedit->pmeaning)
				exit_mem(EXIT_FAILURE,"Not enough memory.");
		} else {
			pnodoedit->pmeaning = (char *)realloc (pnodoedit->pmeaning,(strlen(secmea)+1)*sizeof(char));
			if (!pnodoedit->pmeaning)
				exit_mem(EXIT_FAILURE,"Not enough memory.");
		}
		strcpy(pnodoedit->pmeaning, secmea);
		print_buffer("\nRenaming...", true);
	} else {
		print_buffer("\nCancelling...", true);
	}
	if (str) {
		free(str);
		str=NULL;
	}
}
开发者ID:aperezm-vlex,项目名称:himitsu,代码行数:50,代码来源:vocab.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ print_cpu函数代码示例发布时间:2022-05-30
下一篇:
C++ print_buf函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap