Implement Server (#1)
All checks were successful
Test and Deploy / test (push) Successful in 15s
Test and Deploy / docs (push) Successful in 28s

- Generic Server struct
- TCP and UDP

Reviewed-on: #1
This commit is contained in:
2024-07-09 21:03:23 +00:00
parent 074798ed62
commit 48f773b3ab
16 changed files with 440 additions and 49 deletions

View File

@ -2,6 +2,7 @@
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <errno.h>
#ifdef __linux__
@ -121,3 +122,18 @@ void del_split(char **sp) {
void del_lines(char **lines) {
del_split(lines);
}
const char *capture_system(const char *cmd, int buf_sz) {
if (buf_sz == 0) {
buf_sz = DEFAULT_CAPTURE_SYSTEM_BUFSIZE;
}
char *buf = malloc(buf_sz);
FILE *tmp = popen(cmd, "r");
if (tmp == NULL) {
fprintf(stderr, "libflint: failed to open FILE *tmp in capture_system. Errno: %d\n", errno);
free(buf);
return NULL;
}
fgets(buf, buf_sz, tmp);
return buf;
}