From Buff Owl, 7 Years ago, written in C.
- go back
Embed
Viewing differences between and Untitled
  1. static inline char *switch_get_hex_bytes(switch_byte_t *buf, switch_size_t datalen, char *new_buf, switch_size_t new_datalen)
  2. {
  3.         switch_byte_t *p, *e;
  4.         char *pp, *ee;
  5.         int ret;
  6.         e = buf + datalen;
  7.         ee = new_buf + new_datalen;
  8.         pp = new_buf;
  9.  
  10.         for (p = buf; p < e && pp < ee - 4; p++) {
  11.                 ret = snprintf(pp, 4, "%.2x ", (int)*p);
  12.                 pp += 3;
  13.         }
  14.         *(pp-1) = '\0';
  15.  
  16.         return new_buf;
  17. }