⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nprint.c

📁 wm PNE 3.3 source code, running at more than vxworks6.x version.
💻 C
📖 第 1 页 / 共 2 页
字号:
		{      		sty_puts(sty, pbuf);      		sty_printf(sty, "\t{}");		}		else		{			*ptr++ = NULL;      		/* sty_puts(sty, pbuf); */      		sty_printf(sty, "{%s}", pbuf);      		sty_printf(sty, "\t{%s}", ptr);		}	  }      else        sty_puts(sty, pbuf);    }}static void  print_obj_id(struct sty      *sty,	              OBJ_ID_T *objp){    print_obj_id_list(sty, objp->num_components, objp->component_list);}static void  print_obj_int(struct sty      *sty, 		       OBJ_ID_T *objp,                       long      val){    char pbuf[80];    if (batch_mode || alt_display)      sty_printf(sty, "%ld", val);    else {      int2string(objp->component_list, objp->num_components, val,                 pbuf, sizeof(pbuf), 1 /* verbose */);      sty_puts(sty, pbuf);    }}static int  printable(char      *s,            ALENGTH_T  len){  while (len--) {    if ((*s < 32) || (*s > 126)) {      if (!((*s == '\r') || (*s == '\n') || (*s == '\t')))        return 0;    }    s++;  }  return 1;}static void  print_ebuffer(struct sty       *sty,		       EBUFFER_T *ebp){    char *cp;    int do_colon = 0;        if (batch_mode        || printable((char *)(EBufferStart(ebp)), EBufferUsed(ebp)))      for (cp = (char *)(EBufferStart(ebp));	   cp != (char *)(EBufferNext(ebp));	   cp++)        sty_putc(sty, *cp);    else      for (cp = (char *)(EBufferStart(ebp));	   cp != (char *)(EBufferNext(ebp));	   cp++) {          sty_printf(sty, "%s%02x", do_colon ? ":" : "", (*cp) & 0xFF);          do_colon = 1;      }    if (alt_display == 0)        sty_putc(sty, '\n');}static void  print_ipaddress(struct   sty  *sty,		  unsigned char *ipa){if (alt_display)	sty_printf(sty, "%d.%d.%d.%d", ipa[0], ipa[1], ipa[2], ipa[3]);else    sty_printf(sty, "IP Address: %d.%d.%d.%d\n", ipa[0], ipa[1], ipa[2], ipa[3]);}void  print_vb(struct sty  *sty,	          VB_T *vbp){  char  pbuf[80];  if (batch_mode)    sty_putc(sty, '=');  print_obj_id(sty, &(vbp->vb_obj_id));  if (alt_display)      sty_printf(sty, "\t");  else      sty_printf(sty, "    \t");  switch (vbp->vb_data_flags_n_type) {  case VT_NUMBER:      if (alt_display) {          sty_printf(sty, "{Number} ");          sty_printf(sty, "{");          print_obj_int(sty, &(vbp->vb_obj_id),                        (long)(vbp->value_u.v_number));          sty_printf(sty, "}");          }      else {          sty_puts(sty, "Number: ");          print_obj_int(sty, &(vbp->vb_obj_id),                        (long)(vbp->value_u.v_number));          }    sty_puts(sty, "\n");    break;  case VT_COUNTER:    if (alt_display)    	sty_printf(sty, "{Counter} {%lu}\n",                    (unsigned long)(vbp->value_u.v_counter));    else        sty_printf(sty, "Counter: %lu\n",                   (unsigned long)(vbp->value_u.v_counter));    break;  case VT_GAUGE:      if (alt_display)          sty_printf(sty, "{Gauge} {%lu}\n",                      (unsigned long)(vbp->value_u.v_gauge));      else          sty_printf(sty, "Gauge: %lu\n",                     (unsigned long)(vbp->value_u.v_gauge));      break;  case VT_TIMETICKS:      if (alt_display) {          sty_printf(sty, "{TimeTicks} {%lu}\n",                      (unsigned long)(vbp->value_u.v_timeticks));          }      else {          sty_printf(sty, "Time Ticks: %lu",                     (unsigned long)(vbp->value_u.v_timeticks));          if (batch_mode)              sty_putc(sty, '\n');          else {              scale_time((unsigned long)(vbp->value_u.v_timeticks) * 10,                         pbuf, sizeof(pbuf));              sty_printf(sty, "  (%s)\n", pbuf);              }          }      break;  case VT_STRING:      if (alt_display) {          sty_printf(sty, "{String(%d)} ",                      EBufferUsed(&(vbp->value_u.v_string)));          sty_printf(sty, "{");          print_ebuffer(sty, &(vbp->value_u.v_string));          sty_printf(sty, "}\n");          }      else {          sty_printf(sty, "String(%d): ",                     EBufferUsed(&(vbp->value_u.v_string)));          print_ebuffer(sty, &(vbp->value_u.v_string));          }      break;  case VT_OPAQUE:      if (alt_display) {          sty_printf(sty, "{Opaque(%d)} ",                      EBufferUsed(&(vbp->value_u.v_string)));          sty_printf(sty, "{");          print_ebuffer(sty, &(vbp->value_u.v_string));          sty_printf(sty, "}\n");          }      else {          sty_printf(sty, "Opaque: Length=%d\n",                     EBufferUsed(&(vbp->value_u.v_string)));          print_ebuffer(sty, &(vbp->value_u.v_opaque));          }      break;  case VT_OBJECT:      if (alt_display) {          sty_printf(sty, "{ObjectID} {");          print_obj_id(sty, &(vbp->value_u.v_object));          sty_printf(sty, "}");          }      else {          sty_puts(sty, "Object ID: ");          print_obj_id(sty, &(vbp->value_u.v_object));          }      sty_puts(sty, "\n");      break;  case VT_EMPTY:      sty_puts(sty, "Empty\n");      break;  case VT_IPADDRESS:      if (alt_display) {          sty_printf(sty, "{IPAddress} {");          print_ipaddress(sty, vbp->value_u.v_network_address);          sty_printf(sty, "}\n");          }      else          print_ipaddress(sty, vbp->value_u.v_network_address);      break;  case VT_NOSUCHOBJ:      if (alt_display)          sty_puts(sty, "{noSuchObject}\n");      else          sty_puts(sty, "No such object\n");      break;  case VT_NOSUCHINS:      if (alt_display)          sty_puts(sty, "{noSuchInstance}\n");      else          sty_puts(sty, "No such instance\n");      break;  case VT_ENDOFMIB:      if (alt_display)          sty_puts(sty, "endOfMib\n");      else          sty_puts(sty, "End of mib\n");      break;/* We only include the following cases if v2 types are installed */#if (ENVOY_USE_V2_TYPES)  case VT_COUNTER64:      if (alt_display) {          sty_printf(sty, "{Counter64} {%lu:%lu}\n",                     (unsigned long)(vbp->value_u.v_counter64.high),                     (unsigned long)(vbp->value_u.v_counter64.low));          }      else          sty_printf(sty, "Counter64: %lu:%lu\n",                     (unsigned long)(vbp->value_u.v_counter64.high),                     (unsigned long)(vbp->value_u.v_counter64.low));      break;#else /* (ENVOY_USE_V2_TYPES) */  case VT_COUNTER64:      sty_puts(sty, "Attempt to use a v2 type in a v1 setting\n");      break;#endif /* (ENVOY_USE_V2_TYPES) */  default:      sty_puts(sty, "UNKNOWN\n");      break;  }#ifdef GRUNGUS  {    OBJ_ID_T    nxt_objid;    nxt_objid.num_components = 0;    nxt_objid.component_list = (unsigned int *)0;    sty_puts(sty, "Finding next...");    if (find_next_object(&(vbp->vb_obj_id), &nxt_objid) <= 0)      sty_puts(sty, "Find next failed\n");    else print_obj_id(sty, &nxt_objid);  }#endif}void  print_vblist(struct sty   *sty,	              VBL_T *vblp){  VB_T  *vbp;  int i;  if ((vbp = vblp->vblist) != 0)    for (i = 0; i < vblp->vbl_count; i++, vbp++)      print_vb(sty, vbp);}void  print_pkt(struct sty        *sty,	           SNMP_PKT_T *rp){#if INSTALL_ENVOY_SNMP_VERSION_1if (rp->pdu_type == TRAP_PDU) {   sty_puts(sty, "Enterprise id: \n");   print_obj_id(sty, &(rp->pdu.trap_pdu.enterprise_objid));   print_ipaddress(sty, rp->pdu.trap_pdu.net_address);   sty_printf(sty, "Generic trap=%ld (%lX), specific trap=%ld (%lX), ",	      rp->pdu.trap_pdu.generic_trap,	      rp->pdu.trap_pdu.generic_trap,	      rp->pdu.trap_pdu.specific_trap,	      rp->pdu.trap_pdu.specific_trap);   sty_printf(sty, "Trap time=%ld (%lX)\n",	      rp->pdu.trap_pdu.trap_time_ticks,	      rp->pdu.trap_pdu.trap_time_ticks);   print_vblist(sty, &(rp->pdu.trap_pdu.trap_vbl));   }  else#endif /* INSTALL_ENVOY_SNMP_VERSION_1 */    print_vblist(sty, &(rp->pdu.std_pdu.std_vbl));}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -