| 234 | }) |
| 235 | |
| 236 | static bool write_file(const char* file, const char* what, ...) |
| 237 | { |
| 238 | char buf[1024]; |
| 239 | va_list args; |
| 240 | va_start(args, what); |
| 241 | vsnprintf(buf, sizeof(buf), what, args); |
| 242 | va_end(args); |
| 243 | buf[sizeof(buf) - 1] = 0; |
| 244 | int len = strlen(buf); |
| 245 | int fd = open(file, O_WRONLY | O_CLOEXEC); |
| 246 | if (fd == -1) |
| 247 | return false; |
| 248 | if (write(fd, buf, len) != len) { |
| 249 | close(fd); |
| 250 | return false; |
| 251 | } |
| 252 | close(fd); |
| 253 | return true; |
| 254 | } |
| 255 | |
| 256 | struct nlmsg { |
| 257 | char* pos; |
no outgoing calls
no test coverage detected