Esempio n. 1
0
char *bgpstream_record_elem_snprintf(char *buf, size_t len,
                                     const bgpstream_record_t *bs_record,
                                     const bgpstream_elem_t *elem)
{
  assert(bs_record);
  assert(elem);

  size_t written = 0; /* < how many bytes we wanted to write */
  ssize_t c = 0;      /* < how many chars were written */
  char *buf_p = buf;

  /* Record type */
  if ((c = bgpstream_record_dump_type_snprintf(
         buf_p, B_REMAIN, bs_record->attributes.dump_type)) < 0) {
    return NULL;
  }
  written += c;
  buf_p += c;
  ADD_PIPE;

  /* Elem type */
  if ((c = bgpstream_elem_type_snprintf(buf_p, B_REMAIN, elem->type)) < 0) {
    return NULL;
  }
  written += c;
  buf_p += c;
  ADD_PIPE;

  /* Record timestamp, project, collector */
  c = snprintf(buf_p, B_REMAIN, "%ld|%s|%s", bs_record->attributes.record_time,
               bs_record->attributes.dump_project,
               bs_record->attributes.dump_collector);
  written += c;
  buf_p += c;
  ADD_PIPE;

  if (B_FULL)
    return NULL;

  if (bgpstream_elem_custom_snprintf(buf_p, B_REMAIN, elem, 0) == NULL) {
    return NULL;
  }

  written += c;
  buf_p += c;

  if (B_FULL)
    return NULL;

  return buf;
}
Esempio n. 2
0
char *bgpstream_elem_snprintf(char *buf, size_t len,
                              bgpstream_elem_t const *elem)
{
  return bgpstream_elem_custom_snprintf(buf, len, elem, 1);
}