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

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

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

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

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

示例1: zsend_router_id_update

/* Router-id is updated. Send ZEBRA_ROUTER_ID_ADD to client. */intzsend_router_id_update (struct zserv *client, struct prefix *p){  struct stream *s;  int blen;  /* Check this client need interface information. */  if (!client->ridinfo)    return 0;  s = client->obuf;  stream_reset (s);  /* Message type. */  zserv_create_header (s, ZEBRA_ROUTER_ID_UPDATE);  /* Prefix information. */  stream_putc (s, p->family);  blen = prefix_blen (p);  stream_put (s, &p->u.prefix, blen);  stream_putc (s, p->prefixlen);  /* Write packet size. */  stream_putw_at (s, 0, stream_get_endp (s));  return zebra_server_send_message(client);}
开发者ID:MichaelQQ,项目名称:Quagga-PE,代码行数:28,


示例2: write_pubkey_enc

static intwrite_pubkey_enc (cdk_stream_t out, cdk_pkt_pubkey_enc_t pke, int old_ctb){  size_t size;  int rc, nenc;  assert (out);  assert (pke);  if (pke->version < 2 || pke->version > 3)    return CDK_Inv_Packet;  if (!KEY_CAN_ENCRYPT (pke->pubkey_algo))    return CDK_Inv_Algo;  if (DEBUG_PKT)    _cdk_log_debug ("write_pubkey_enc:/n");  nenc = cdk_pk_get_nenc (pke->pubkey_algo);  size = 10 + calc_mpisize (pke->mpi, nenc);  rc = pkt_write_head (out, old_ctb, size, CDK_PKT_PUBKEY_ENC);  if (rc)    return rc;  rc = stream_putc (out, pke->version);  if (!rc)    rc = write_32 (out, pke->keyid[0]);  if (!rc)    rc = write_32 (out, pke->keyid[1]);  if (!rc)    rc = stream_putc (out, _cdk_pub_algo_to_pgp (pke->pubkey_algo));  if (!rc)    rc = write_mpibuf (out, pke->mpi, nenc);  return rc;}
开发者ID:ystk,项目名称:debian-gnutls26,代码行数:34,


示例3: write_head_old

static cdk_error_twrite_head_old (cdk_stream_t out, size_t size, int type){  cdk_error_t rc;  int ctb;  assert (out);  if (type < 0 || type > 16)    return CDK_Inv_Packet;  ctb = 0x80 | (type << 2);  if (!size)    ctb |= 3;  else if (size < 256)    ;  else if (size < 65536)    ctb |= 1;  else    ctb |= 2;  rc = stream_putc (out, ctb);  if (!size)    return rc;  if (!rc)    {      if (size < 256)	rc = stream_putc (out, size);      else if (size < 65536)	rc = write_16 (out, size);      else	rc = write_32 (out, size);    }  return rc;}
开发者ID:ystk,项目名称:debian-gnutls26,代码行数:34,


示例4: write_onepass_sig

static cdk_error_twrite_onepass_sig (cdk_stream_t out, cdk_pkt_onepass_sig_t sig){  cdk_error_t rc;  assert (out);  assert (sig);  if (sig->version != 3)    return CDK_Inv_Packet;  if (DEBUG_PKT)    _cdk_log_debug ("write_onepass_sig:/n");  rc = pkt_write_head (out, 0, 13, CDK_PKT_ONEPASS_SIG);  if (!rc)    rc = stream_putc (out, sig->version);  if (!rc)    rc = stream_putc (out, sig->sig_class);  if (!rc)    rc = stream_putc (out, _gnutls_hash_algo_to_pgp (sig->digest_algo));  if (!rc)    rc = stream_putc (out, _cdk_pub_algo_to_pgp (sig->pubkey_algo));  if (!rc)    rc = write_32 (out, sig->keyid[0]);  if (!rc)    rc = write_32 (out, sig->keyid[1]);  if (!rc)    rc = stream_putc (out, sig->last);  return rc;}
开发者ID:ystk,项目名称:debian-gnutls26,代码行数:31,


示例5: zapi_ipv4_route

 /*   * "xdr_encode"-like interface that allows daemon (client) to send  * a message to zebra server for a route that needs to be  * added/deleted to the kernel. Info about the route is specified  * by the caller in a struct zapi_ipv4. zapi_ipv4_read() then writes  * the info down the zclient socket using the stream_* functions.  *   * The corresponding read ("xdr_decode") function on the server  * side is zread_ipv4_add()/zread_ipv4_delete().  *  *  0 1 2 3 4 5 6 7 8 9 A B C D E F 0 1 2 3 4 5 6 7 8 9 A B C D E F  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+  * |            Length (2)         |    Command    | Route Type    |  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+  * | ZEBRA Flags   | Message Flags | Prefix length |  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+  * | Destination IPv4 Prefix for route                             |  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+  * | Nexthop count |   * +-+-+-+-+-+-+-+-+  *  *   * A number of IPv4 nexthop(s) or nexthop interface index(es) are then   * described, as per the Nexthop count. Each nexthop described as:  *  * +-+-+-+-+-+-+-+-+  * | Nexthop Type  |  Set to one of ZEBRA_NEXTHOP_*  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+  * |       IPv4 Nexthop address or Interface Index number          |  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+  *  * Alternatively, if the flags field has ZEBRA_FLAG_BLACKHOLE or  * ZEBRA_FLAG_REJECT is set then Nexthop count is set to 1, then _no_   * nexthop information is provided, and the message describes a prefix  * to blackhole or reject route.  *  * If ZAPI_MESSAGE_DISTANCE is set, the distance value is written as a 1  * byte value.  *   * If ZAPI_MESSAGE_METRIC is set, the metric value is written as an 8  * byte value.  *  * XXX: No attention paid to alignment.  */ intzapi_ipv4_route (u_char cmd, struct zclient *zclient, struct prefix_ipv4 *p,                 struct zapi_ipv4 *api){  int i;  int psize;  struct stream *s;  /* Reset stream. */  s = zclient->obuf;  stream_reset (s);    zclient_create_header (s, cmd);    /* Put type and nexthop. */  stream_putc (s, api->type);  stream_putc (s, api->flags);  stream_putc (s, api->message);  stream_putw (s, api->safi);  /* Put prefix information. */  psize = PSIZE (p->prefixlen);  stream_putc (s, p->prefixlen);  stream_write (s, (u_char *) & p->prefix, psize);  /* Nexthop, ifindex, distance and metric information. */  if (CHECK_FLAG (api->message, ZAPI_MESSAGE_NEXTHOP))    {      if (CHECK_FLAG (api->flags, ZEBRA_FLAG_BLACKHOLE))        {          stream_putc (s, 1);          stream_putc (s, ZEBRA_NEXTHOP_BLACKHOLE);          /* XXX assert(api->nexthop_num == 0); */          /* XXX assert(api->ifindex_num == 0); */        }      else        stream_putc (s, api->nexthop_num + api->ifindex_num);      for (i = 0; i < api->nexthop_num; i++)        {          stream_putc (s, ZEBRA_NEXTHOP_IPV4);          stream_put_in_addr (s, api->nexthop[i]);        }      for (i = 0; i < api->ifindex_num; i++)        {          stream_putc (s, ZEBRA_NEXTHOP_IFINDEX);          stream_putl (s, api->ifindex[i]);        }    }  if (CHECK_FLAG (api->message, ZAPI_MESSAGE_DISTANCE))    stream_putc (s, api->distance);  if (CHECK_FLAG (api->message, ZAPI_MESSAGE_METRIC))    stream_putl (s, api->metric);  /* Put length at the first point of the stream. *///.........这里部分代码省略.........
开发者ID:gvsurenderreddy,项目名称:quagga,代码行数:101,


示例6: zsend_router_id_update

/* Router-id is updated. Send ZEBRA_ROUTER_ID_ADD to client. */intzsend_router_id_update (struct zserv *client, struct prefix *p){  struct stream *s;  int blen;  /* Check this client need interface information. */  if (!client->ridinfo)    return -1;  s = client->obuf;  stream_reset (s);  /* Place holder for size. */  stream_putw (s, 0);  /* Message type. */  stream_putc (s, ZEBRA_ROUTER_ID_UPDATE);  /* Prefix information. */  stream_putc (s, p->family);  blen = prefix_blen (p);  stream_put (s, &p->u.prefix, blen);  stream_putc (s, p->prefixlen);  /* Write packet size. */  stream_putw_at (s, 0, stream_get_endp (s));  return writen (client->sock, s->data, stream_get_endp (s));}
开发者ID:OPSF,项目名称:uClinux,代码行数:31,


示例7: zsend_ipv4_import_lookup

static intzsend_ipv4_import_lookup (struct zserv *client, struct prefix_ipv4 *p){  struct stream *s;  struct rib *rib;  unsigned long nump;  u_char num;  struct nexthop *nexthop;  /* Lookup nexthop. */  rib = rib_lookup_ipv4 (p);  /* Get output stream. */  s = client->obuf;  stream_reset (s);  /* Fill in result. */  stream_putw (s, 0);  stream_putc (s, ZEBRA_IPV4_IMPORT_LOOKUP);  stream_put_in_addr (s, &p->prefix);  if (rib)    {      stream_putl (s, rib->metric);      num = 0;      nump = s->putp;      stream_putc (s, 0);      for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next)	if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB))	  {	    stream_putc (s, nexthop->type);	    switch (nexthop->type)	      {	      case ZEBRA_NEXTHOP_IPV4:		stream_put_in_addr (s, &nexthop->gate.ipv4);		break;	      case ZEBRA_NEXTHOP_IFINDEX:	      case ZEBRA_NEXTHOP_IFNAME:		stream_putl (s, nexthop->ifindex);		break;	      default:                /* do nothing */		break;	      }	    num++;	  }      stream_putc_at (s, nump, num);    }  else    {      stream_putl (s, 0);      stream_putc (s, 0);    }  stream_putw_at (s, 0, stream_get_endp (s));    zebra_server_send_message (client->sock, s->data, stream_get_endp (s));  return 0;}
开发者ID:OPSF,项目名称:uClinux,代码行数:60,


示例8: write_user_id

static cdk_error_twrite_user_id (cdk_stream_t out, cdk_pkt_userid_t id, int old_ctb,	       int pkttype){  cdk_error_t rc;  if (!out || !id)    return CDK_Inv_Value;  if (pkttype == CDK_PKT_ATTRIBUTE)    {      if (!id->attrib_img)	return CDK_Inv_Value;      rc =	pkt_write_head (out, old_ctb, id->attrib_len + 6, CDK_PKT_ATTRIBUTE);      if (rc)	return rc;      /* Write subpacket part. */      stream_putc (out, 255);      write_32 (out, id->attrib_len + 1);      stream_putc (out, 1);      rc = stream_write (out, id->attrib_img, id->attrib_len);    }  else    {      if (!id->name)	return CDK_Inv_Value;      rc = pkt_write_head (out, old_ctb, id->len, CDK_PKT_USER_ID);      if (!rc)	rc = stream_write (out, id->name, id->len);    }  return rc;}
开发者ID:ystk,项目名称:debian-gnutls26,代码行数:34,


示例9: put_opl

UINT16 put_opl(imgtool_stream *instream, imgtool_stream *outstream){	UINT16 out_size = 0;	UINT32 rec_start = stream_tell(outstream);	char *line;	// reset stream	stream_seek(instream, 0, SEEK_SET);	stream_fill(outstream, 0x00, 4);	// replace all eol with 0x00	while ((line = stream_getline(instream, 256)))	{		// replace tab with space		for (int i=0; i<strlen(line); i++)			if (line[i] == '/t') line[i] = ' ';		stream_write(outstream, line, strlen(line));		stream_putc(outstream, 0x00);		out_size += strlen(line) + 1;		free(line);	}	// end of pack	stream_fill(outstream, 0xff, 2);	// update the size in the head	stream_seek(outstream, rec_start + 2, SEEK_SET);	stream_putc(outstream, (out_size>>8) & 0xff);	stream_putc(outstream, out_size & 0xff);	return out_size + 4;}
开发者ID:bradhugh,项目名称:mame,代码行数:34,


示例10: zsend_interface_update

/* * The cmd passed to zsend_interface_update  may be ZEBRA_INTERFACE_UP or * ZEBRA_INTERFACE_DOWN. * * The ZEBRA_INTERFACE_UP message is sent from the zebra server to * the clients in one of 2 situations: *   - an if_up is detected e.g., as a result of an RTM_IFINFO message *   - a vty command modifying the bandwidth of an interface is received. * The ZEBRA_INTERFACE_DOWN message is sent when an if_down is detected. */intzsend_interface_update (int cmd, struct zserv *client, struct interface *ifp){  struct stream *s;  /* Check this client need interface information. */  if (! client->ifinfo)    return -1;  s = client->obuf;  stream_reset (s);  /* Place holder for size. */  stream_putw (s, 0);  /* Zebra command. */  stream_putc (s, cmd);  /* Interface information. */  stream_put (s, ifp->name, INTERFACE_NAMSIZ);  stream_putl (s, ifp->ifindex);  stream_putc (s, ifp->status);  stream_putl (s, ifp->flags);  stream_putl (s, ifp->metric);  stream_putl (s, ifp->mtu);  stream_putl (s, ifp->mtu6);  stream_putl (s, ifp->bandwidth);  /* Write packet size. */  stream_putw_at (s, 0, stream_get_endp (s));  zebra_server_send_message (client->sock, s->data, stream_get_endp (s));  return 0;}
开发者ID:OPSF,项目名称:uClinux,代码行数:45,


示例11: zsend_interface_delete

intzsend_interface_delete (struct zserv *client, struct interface *ifp){  struct stream *s;  /* Check this client need interface information. */  if (! client->ifinfo)    return -1;  s = client->obuf;  stream_reset (s);  /* Packet length placeholder. */  stream_putw (s, 0);  /* Interface information. */  stream_putc (s, ZEBRA_INTERFACE_DELETE);  stream_put (s, ifp->name, INTERFACE_NAMSIZ);  stream_putl (s, ifp->ifindex);  stream_putc (s, ifp->status);  stream_putl (s, ifp->flags);  stream_putl (s, ifp->metric);  stream_putl (s, ifp->mtu);  stream_putl (s, ifp->mtu6);  stream_putl (s, ifp->bandwidth);  /* Write packet length. */  stream_putw_at (s, 0, stream_get_endp (s));  zebra_server_send_message (client->sock, s->data, stream_get_endp (s));  return 0;}
开发者ID:OPSF,项目名称:uClinux,代码行数:33,


示例12: get_ob3

UINT16 get_ob3(imgtool_stream *instream, imgtool_stream *outstream, UINT8 type, UINT8 file_id){	UINT8 data, *buffer = NULL;	UINT16 size = 0;	static const char ob3_magic[3] = {'O', 'R', 'G'};	stream_read(instream, &data, 1);	if (data == 0x02)	{		stream_seek(instream, 1, SEEK_CUR);		size = get_long_rec_size(instream);		buffer = (UINT8*)malloc(size);		stream_read(instream, buffer, size);	}	stream_write(outstream, ob3_magic, 3);	stream_putc(outstream, (size>>8) & 0xff);	stream_putc(outstream, size & 0xff);	stream_putc(outstream, type | 0x80);	if (buffer)	{		stream_write(outstream, buffer, size);		free (buffer);	}	return size;}
开发者ID:bradhugh,项目名称:mame,代码行数:29,


示例13: put_odb

UINT16 put_odb(imgtool_stream *instream, imgtool_stream *outstream, UINT8 file_id){	char *line;	UINT16 out_size = 0;	// reset stream	stream_seek(instream, 0, SEEK_SET);	while ((line = stream_getline(instream, 256)))	{		UINT16 len = strlen(line);		stream_putc(outstream, (UINT8)len);		stream_putc(outstream, file_id);		stream_write(outstream, line, len);		out_size += (len + 1);		free(line);	}	// end of pack	stream_fill(outstream, 0xff, 2);	return out_size + 4;}
开发者ID:bradhugh,项目名称:mame,代码行数:26,


示例14: pkt_encode_len

static cdk_error_tpkt_encode_len (cdk_stream_t out, size_t pktlen){  cdk_error_t rc;  assert (out);  rc = 0;  if (!pktlen)    {      /* Block mode, partial bodies, with 'DEF_BLOCKSIZE' from main.h */      rc = stream_putc (out, (0xE0 | DEF_BLOCKBITS));    }  else if (pktlen < 192)    rc = stream_putc (out, pktlen);  else if (pktlen < 8384)    {      pktlen -= 192;      rc = stream_putc (out, (pktlen / 256) + 192);      if (!rc)	rc = stream_putc (out, (pktlen % 256));    }  else    {      rc = stream_putc (out, 255);      if (!rc)	rc = write_32 (out, pktlen);    }  return rc;}
开发者ID:ystk,项目名称:debian-gnutls26,代码行数:31,


示例15: write_todolist

void write_todolist(STREAM *output, TODOLIST *todolist) {  OPTION *opt = NULL;  TASK *task = NULL;  int width = 0;  stream_printf(output, "%s/n", todolist->title);  task = todolist->first;  while (task) {    stream_printf(output, "[%c] %s/n",        task->done ? 'X' : ' ', task->message);    task = task->next;  }  opt = todolist->first_option;  if (opt) {    width += stream_printf(output, "#");    while (opt) {      if (width >= 80) {        stream_printf(output, "/n#");        width = 1;      }      width += 2;      stream_putc(' ', output);      width += escape_string(output, opt->key);      stream_putc('=', output);      width += escape_string(output, opt->value);      opt = opt->next;    }    stream_printf(output, "/n");  }}
开发者ID:nielssp,项目名称:ctodo,代码行数:29,


示例16: zlog_debug

static voidrip_auth_write_leading_rte(  struct stream *s,  struct rip_interface *ri,  const u_int8_t key_id,  char *auth_str,  u_int16_t main_body_len){  u_int8_t dlen;  if (IS_RIP_DEBUG_AUTH)    zlog_debug ("writing authentication header for %uB of main body", main_body_len);  stream_putw (s, RIP_FAMILY_AUTH);  switch (ri->auth_type)  {  case RIP_AUTH_SIMPLE_PASSWORD:    {      u_int8_t padded_simple_password[RIP_AUTH_SIMPLE_SIZE] = { 0 };      memcpy (padded_simple_password, auth_str, MIN (RIP_AUTH_SIMPLE_SIZE, strlen (auth_str)));      stream_putw (s, RIP_AUTH_SIMPLE_PASSWORD);      stream_put (s, padded_simple_password, RIP_AUTH_SIMPLE_SIZE);      break;    }  case RIP_AUTH_HASH:    if (IS_RIP_DEBUG_AUTH)      zlog_debug ("hash algorithm is '%s'", LOOKUP (hash_algo_str, ri->hash_algo));    stream_putw (s, RIP_AUTH_HASH);    stream_putw (s, main_body_len);    stream_putc (s, key_id);    switch (ri->hash_algo)    {    case HASH_KEYED_MD5:      /* Auth Data Len.  Set 16 for MD5 authentication data. Older ripds       * however expect RIP_HEADER_SIZE + HASH_SIZE_MD5 so we allow for this       * to be configurable. */      dlen = ri->md5_auth_len;      break;    case HASH_HMAC_SHA1:    case HASH_HMAC_SHA256:    case HASH_HMAC_SHA384:    case HASH_HMAC_SHA512:      dlen = hash_digest_length[ri->hash_algo];      break;    default:      assert (0);    }    if (IS_RIP_DEBUG_AUTH)      zlog_debug ("declared auth data length is %uB", dlen);    stream_putc (s, dlen);    stream_putl (s, time (NULL)); /* Sequence Number (non-decreasing). */    stream_putl (s, 0); /* reserved, MBZ */    stream_putl (s, 0); /* reserved, MBZ */    break;  default:    assert (0);  }}
开发者ID:Quagga-RE,项目名称:wip-tcs-rfc6506,代码行数:59,


示例17: tipc_packet_create_header

voidtipc_packet_create_header (struct stream *s, uint16_t cmd){  /* length placeholder, caller can update */  stream_putw (s, TIPC_PACKET_HEADER_SIZE);  stream_putc (s, TIPC_PACKET_HEADER_MARKER);  stream_putc (s, TIPC_PACKET_VERSION);  stream_putw (s, cmd);}
开发者ID:kkcloudy,项目名称:daemongroup,代码行数:9,


示例18: zclient_create_header

voidzclient_create_header (struct stream *s, uint16_t command){  /* length placeholder, caller can update */  stream_putw (s, ZEBRA_HEADER_SIZE);  stream_putc (s, ZEBRA_HEADER_MARKER);  stream_putc (s, ZSERV_VERSION);  stream_putw (s, command);}
开发者ID:gvsurenderreddy,项目名称:quagga,代码行数:9,


示例19: escape_string

size_t escape_string(STREAM *output, const char *str) {  size_t l = 0;  char c;  while ((c = *str) != '/0') {    if (c == ' ' || c == '//' || c == '/n' || c == '=') {      stream_putc('//', output);    }    stream_putc(c, output);    str++;  }  return l;}
开发者ID:nielssp,项目名称:ctodo,代码行数:12,


示例20: zsend_interface_address

/* Interface address is added/deleted. Send ZEBRA_INTERFACE_ADDRESS_ADD or * ZEBRA_INTERFACE_ADDRESS_DELETE to the client.  * * A ZEBRA_INTERFACE_ADDRESS_ADD is sent in the following situations: * - in response to a 3-byte ZEBRA_INTERFACE_ADD request *   from the client, after the ZEBRA_INTERFACE_ADD has been *   sent from zebra to the client * - redistribute new address info to all clients in the following situations *    - at startup, when zebra figures out the available interfaces *    - when an interface is added (where support for *      RTM_IFANNOUNCE or AF_NETLINK sockets is available), or when *      an interface is marked IFF_UP (i.e., an RTM_IFINFO message is *      received) *    - for the vty commands "ip address A.B.C.D/M [<secondary>|<label LINE>]" *      and "no bandwidth <1-10000000>", "ipv6 address X:X::X:X/M" *    - when an RTM_NEWADDR message is received from the kernel, *  * The call tree that triggers ZEBRA_INTERFACE_ADDRESS_DELETE:  * *                   zsend_interface_address(DELETE) *                           ^                          *                           |                         *          zebra_interface_address_delete_update     *             ^                        ^      ^ *             |                        |      if_delete_update (not called on  *             |                        |                         Solaris) *         ip_address_uninstall        connected_delete_ipv4 *         [ipv6_addresss_uninstall]   [connected_delete_ipv6] *             ^                        ^ *             |                        | *             |                  RTM_NEWADDR on routing/netlink socket *             | *         vty commands: *     "no ip address A.B.C.D/M [label LINE]" *     "no ip address A.B.C.D/M secondary" *     ["no ipv6 address X:X::X:X/M"] * */intzsend_interface_address (int cmd, struct zserv *client,                          struct interface *ifp, struct connected *ifc){  int blen;  struct stream *s;  struct prefix *p;  /* Check this client need interface information. */  if (! client->ifinfo)    return -1;  s = client->obuf;  stream_reset (s);  /* Place holder for size. */  stream_putw (s, 0);  stream_putc (s, cmd);  stream_putl (s, ifp->ifindex);  /* Interface address flag. */  stream_putc (s, ifc->flags);  /* Prefix information. */  p = ifc->address;  stream_putc (s, p->family);  blen = prefix_blen (p);  stream_put (s, &p->u.prefix, blen);  /*    * XXX gnu version does not send prefixlen for ZEBRA_INTERFACE_ADDRESS_DELETE   * but zebra_interface_address_delete_read() in the gnu version    * expects to find it   */  stream_putc (s, p->prefixlen);  /* Destination. */  p = ifc->destination;  if (p)    stream_put (s, &p->u.prefix, blen);  else    stream_put (s, NULL, blen);  /* Write packet size. */  stream_putw_at (s, 0, stream_get_endp (s));  zebra_server_send_message (client->sock, s->data, stream_get_endp (s));  return 0;}
开发者ID:OPSF,项目名称:uClinux,代码行数:89,


示例21: zapi_ipv6_route

intzapi_ipv6_route (u_char cmd, struct_zclient *zclient, struct prefix_ipv6 *p,	       struct zapi_ipv6 *api){  int i;  int psize;  struct stream *s;  /* Reset stream. */  s = zclient->obuf;  stream_reset (s);  /* Length place holder. */  stream_putw (s, 0);  /* Put command, type and nexthop. */  stream_putc (s, cmd);  stream_putc (s, api->type);  stream_putc (s, api->flags);  stream_putc (s, api->message);    /* Put prefix information. */  psize = PSIZE (p->prefixlen);  stream_putc (s, p->prefixlen);  stream_write (s, (u_char *)&p->prefix, psize);  /* Nexthop, ifindex, distance and metric information. */  if (CHECK_FLAG (api->message, ZAPI_MESSAGE_NEXTHOP))    {      stream_putc (s, api->nexthop_num + api->ifindex_num);      for (i = 0; i < api->nexthop_num; i++)	{	  stream_putc (s, ZEBRA_NEXTHOP_IPV6);	  stream_write (s, (u_char *)api->nexthop[i], 16);	}      for (i = 0; i < api->ifindex_num; i++)	{	  stream_putc (s, ZEBRA_NEXTHOP_IFINDEX);	  stream_putl (s, api->ifindex[i]);	}    }  if (CHECK_FLAG (api->message, ZAPI_MESSAGE_DISTANCE))    stream_putc (s, api->distance);  if (CHECK_FLAG (api->message, ZAPI_MESSAGE_METRIC))    stream_putl (s, api->metric);  /* Put length at the first point of the stream. */  stream_putw_at (s, 0, stream_get_endp (s));  return writen (zclient->sock, s->data, stream_get_endp (s));}
开发者ID:inet-framework,项目名称:inet-quagga,代码行数:53,


示例22: zfcmap_put_name_default

/* <file> <cmap> .writecmap - */static intzfcmap_put_name_default(stream *s, const byte *str, uint size){    stream_putc(s, '/');    stream_write(s, str, size);    return 0;}
开发者ID:ststeiger,项目名称:ghostsvg,代码行数:8,


示例23: zsend_interface_update

/* * The cmd passed to zsend_interface_update  may be ZEBRA_INTERFACE_UP or * ZEBRA_INTERFACE_DOWN. * * The ZEBRA_INTERFACE_UP message is sent from the zebra server to * the clients in one of 2 situations: *   - an if_up is detected e.g., as a result of an RTM_IFINFO message *   - a vty command modifying the bandwidth of an interface is received. * The ZEBRA_INTERFACE_DOWN message is sent when an if_down is detected. */intzsend_interface_update (int cmd, struct zserv *client, struct interface_FOO *ifp){  struct stream *s;  /* Check this client need interface information. */  if (! client->ifinfo)    return 0;  s = client->obuf;  stream_reset (s);  zserv_create_header (s, cmd);  /* Interface information. */  stream_put (s, ifp->name, INTERFACE_NAMSIZ);  stream_putl (s, ifp->ifindex);  stream_putc (s, ifp->status);  stream_putq (s, ifp->flags);  stream_putl (s, ifp->metric);  stream_putl (s, ifp->mtu);  stream_putl (s, ifp->mtu6);  stream_putl (s, ifp->bandwidth);  /* Write packet size. */  stream_putw_at (s, 0, stream_get_endp (s));  return zebra_server_send_message(client);}
开发者ID:inet-framework,项目名称:inet-quagga,代码行数:39,


示例24: main

intmain (void){  struct stream *s;    s = stream_new (1024);    stream_putc (s, ham);  stream_putw (s, ham);  stream_putl (s, ham);  stream_putq (s, ham);    print_stream (s);    stream_resize (s, stream_get_endp (s));    print_stream (s);    printf ("c: 0x%hhx/n", stream_getc (s));  printf ("w: 0x%hx/n", stream_getw (s));  printf ("l: 0x%x/n", stream_getl (s));  printf ("q: 0x%" PRIu64 "/n", stream_getq (s));    return 0;}
开发者ID:AT-Corp,项目名称:quagga-atc,代码行数:25,


示例25: write_literal

static cdk_error_twrite_literal (cdk_stream_t out, cdk_pkt_literal_t pt, int old_ctb){  byte buf[BUFSIZE];  size_t size;  cdk_error_t rc;  assert (out);  assert (pt);  /* We consider a packet without a body as an invalid packet.     At least one octet must be present. */  if (!pt->len)    return CDK_Inv_Packet;  if (DEBUG_PKT)    _cdk_log_debug ("write_literal:/n");  size = 6 + pt->namelen + pt->len;  rc = pkt_write_head (out, old_ctb, size, CDK_PKT_LITERAL);  if (rc)    return rc;  rc = stream_putc (out, pt->mode);  if (rc)    return rc;  rc = stream_putc (out, pt->namelen);  if (rc)    return rc;  if (pt->namelen > 0)    rc = stream_write (out, pt->name, pt->namelen);  if (!rc)    rc = write_32 (out, pt->timestamp);  if (rc)    return rc;  while (!cdk_stream_eof (pt->buf) && !rc)    {      rc = stream_read (pt->buf, buf, DIM (buf), &size);      if (!rc)	rc = stream_write (out, buf, size);    }  wipemem (buf, sizeof (buf));  return rc;}
开发者ID:ystk,项目名称:debian-gnutls26,代码行数:47,


示例26: write_public_key

static cdk_error_twrite_public_key (cdk_stream_t out, cdk_pkt_pubkey_t pk,		  int is_subkey, int old_ctb){  int pkttype, ndays = 0;  size_t npkey = 0, size = 6;  cdk_error_t rc;  assert (out);  assert (pk);  if (pk->version < 2 || pk->version > 4)    return CDK_Inv_Packet;  if (DEBUG_PKT)    _cdk_log_debug ("write_public_key: subkey=%d/n", is_subkey);  pkttype = is_subkey ? CDK_PKT_PUBLIC_SUBKEY : CDK_PKT_PUBLIC_KEY;  npkey = cdk_pk_get_npkey (pk->pubkey_algo);  if (!npkey)    return CDK_Inv_Algo;  if (pk->version < 4)    size += 2;			/* expire date */  if (is_subkey)    old_ctb = 0;  size += calc_mpisize (pk->mpi, npkey);  if (old_ctb)    rc = pkt_write_head2 (out, size, pkttype);  else    rc = pkt_write_head (out, old_ctb, size, pkttype);  if (!rc)    rc = stream_putc (out, pk->version);  if (!rc)    rc = write_32 (out, pk->timestamp);  if (!rc && pk->version < 4)    {      if (pk->expiredate)	ndays = (u16) ((pk->expiredate - pk->timestamp) / 86400L);      rc = write_16 (out, ndays);    }  if (!rc)    rc = stream_putc (out, _cdk_pub_algo_to_pgp (pk->pubkey_algo));  if (!rc)    rc = write_mpibuf (out, pk->mpi, npkey);  return rc;}
开发者ID:ystk,项目名称:debian-gnutls26,代码行数:46,


示例27: update_opk_head

void update_opk_head(imgtool_stream *stream){	UINT16 size = stream_size(stream) - 6;	stream_seek(stream, 4, SEEK_SET);	stream_putc(stream, (size>>8) & 0xff);	stream_putc(stream, size & 0xff);}
开发者ID:bradhugh,项目名称:mame,代码行数:8,


示例28: write_v3_sig

static cdk_error_twrite_v3_sig (cdk_stream_t out, cdk_pkt_signature_t sig, int nsig){  size_t size;  cdk_error_t rc;  size = 19 + calc_mpisize (sig->mpi, nsig);  if (is_RSA (sig->pubkey_algo))    rc = pkt_write_head2 (out, size, CDK_PKT_SIGNATURE);  else    rc = pkt_write_head (out, 1, size, CDK_PKT_SIGNATURE);  if (!rc)    rc = stream_putc (out, sig->version);  if (!rc)    rc = stream_putc (out, 5);  if (!rc)    rc = stream_putc (out, sig->sig_class);  if (!rc)    rc = write_32 (out, sig->timestamp);  if (!rc)    rc = write_32 (out, sig->keyid[0]);  if (!rc)    rc = write_32 (out, sig->keyid[1]);  if (!rc)    rc = stream_putc (out, _cdk_pub_algo_to_pgp (sig->pubkey_algo));  if (!rc)    rc = stream_putc (out, _gnutls_hash_algo_to_pgp (sig->digest_algo));  if (!rc)    rc = stream_putc (out, sig->digest_start[0]);  if (!rc)    rc = stream_putc (out, sig->digest_start[1]);  if (!rc)    rc = write_mpibuf (out, sig->mpi, nsig);  return rc;}
开发者ID:ystk,项目名称:debian-gnutls26,代码行数:35,


示例29: s_write_ps_string

/* * Write a string in its shortest form ( () or <> ).  Note that * this form is different depending on whether binary data are allowed. * Currently we don't support ASCII85 strings ( <~ ~> ). */voids_write_ps_string(stream * s, const byte * str, uint size, int print_ok){    uint added = 0;    uint i;    const stream_template *template;    stream_AXE_state state;    stream_state *st = NULL;    if (print_ok & PRINT_BINARY_OK) {	/* Only need to escape (, ), /, CR, EOL. */	stream_putc(s, '(');	for (i = 0; i < size; ++i) {	    byte ch = str[i];	    switch (ch) {		case char_CR:		    stream_puts(s, "//r");		    continue;		case char_EOL:		    stream_puts(s, "//n");		    continue;		case '(':		case ')':		case '//':		    stream_putc(s, '//');	    }	    stream_putc(s, ch);	}	stream_putc(s, ')');	return;    }    for (i = 0; i < size; ++i) {	byte ch = str[i];	if (ch == 0 || ch >= 127)	    added += 3;	else if (strchr("()///n/r/t/b/f", ch) != 0)	    ++added;	else if (ch < 32)	    added += 3;    }    if (added < size || (print_ok & PRINT_HEX_NOT_OK)) {
开发者ID:MasterPlexus,项目名称:vendor_goldenve,代码行数:49,


示例30: write_mdc

static cdk_error_twrite_mdc (cdk_stream_t out, cdk_pkt_mdc_t mdc){  cdk_error_t rc;  assert (mdc);  assert (out);  if (DEBUG_PKT)    _cdk_log_debug ("write_mdc:/n");  /* This packet requires a fixed header encoding */  rc = stream_putc (out, 0xD3);	/* packet ID and 1 byte length */  if (!rc)    rc = stream_putc (out, 0x14);  if (!rc)    rc = stream_write (out, mdc->hash, DIM (mdc->hash));  return rc;}
开发者ID:ystk,项目名称:debian-gnutls26,代码行数:19,



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


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