BuildSystem: Cleanup userspace directory layout

userspace programs are now in userspace/programs
userspace tests are now in userspace/tests

This makes listing userspace projects much cleaner. Libraries were
already separated to their own directory, so other programs should also.
This commit is contained in:
2024-07-03 09:15:22 +03:00
parent 5dc441c4af
commit 8ddab05ed3
107 changed files with 78 additions and 67 deletions

View File

@@ -0,0 +1,8 @@
set(SOURCES
main.cpp
)
add_executable(test-popen ${SOURCES})
banan_link_library(test-popen libc)
install(TARGETS test-popen OPTIONAL)

View File

@@ -0,0 +1,30 @@
#include <stdio.h>
#include <unistd.h>
int main(int argc, char** argv)
{
if (argc != 2)
{
fprintf(stderr, "usage: %s COMMAND\n", argv[0]);
return 1;
}
FILE* fp = popen(argv[1], "r");
if (fp == nullptr)
{
perror("popen");
return 1;
}
char buffer[128];
while (fgets(buffer, sizeof(buffer), fp) != NULL)
printf("%s", buffer);
if (pclose(fp) == -1)
{
perror("pclose");
return 1;
}
return 0;
}