On 07/19/23 04:20PM, Sergey Matveev wrote: > >Which DNS server do you recommend to use? > > https://github.com/janmojzis/dq is pretty lightweight and simple.
I respect the endeavour but this author seems to dine pretty heavy on thick paint chips. Before returning from strtoip4, he does the following: int strtoip4(unsigned char *ip, const char *x) ... byte_copy(ip, 12, "\0\0\0\0\0\0\0\0\0\0\377\377"); return 1; } And here is byte_copy: void byte_copy(void *yv, long long ylen, const void *xv) { long long i; const char *x = xv; char *y = yv; for (i = 0; i < ylen; ++i) y[i] = x[i]; } Of course, byte_copy is superior to memcpy & strncpy here because he's copying some pretty long(!) strings. Also, your binary IPv4 address buffer needs to be at 16-bytes long so the author can populate the first 12-bytes with a mysterious string literal. Another excerpt: #define X(e,s) if (i == e) return s; const char *e_str(int i) { X(0,"no error"); X(EINTR,"interrupted system call") X(ENOMEM,"out of memory") X(ENOENT,"file does not exist") X(ETXTBSY,"text busy") X(EIO,"input/output error") ... return "unknown error"; } Maybe this is just comedy? In all seriousness, this project seems moreso exploratory than lightweight & simple. Either that or I do not understand the author's objectives here. Jeremy