Mirror of :pserver:cvs@cvs.fefe.de:/cvs libowfat https://www.fefe.de/libowfat/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

16 lines
424 B

  1. #include "fmt.h"
  2. #include "rangecheck.h"
  3. #include <string.h>
  4. size_t fmt_netstring(char* dest,const char* src,size_t len) {
  5. size_t n=fmt_ulong(NULL,len);
  6. size_t m;
  7. if (!range_validbuf(src,len) || add_of(m,len,n+2)) return 0; /* n came from fmt_ulong, so it is a very small number, below 50 */
  8. if (!dest) return m;
  9. fmt_ulong(dest,len); dest+=n;
  10. *dest++=':';
  11. memcpy(dest,src,len);
  12. dest[len]=',';
  13. return m;
  14. }