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:
8
userspace/programs/loadkeys/CMakeLists.txt
Normal file
8
userspace/programs/loadkeys/CMakeLists.txt
Normal file
@@ -0,0 +1,8 @@
|
||||
set(SOURCES
|
||||
main.cpp
|
||||
)
|
||||
|
||||
add_executable(loadkeys ${SOURCES})
|
||||
banan_link_library(loadkeys libc)
|
||||
|
||||
install(TARGETS loadkeys OPTIONAL)
|
||||
42
userspace/programs/loadkeys/main.cpp
Normal file
42
userspace/programs/loadkeys/main.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/banan-os.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
int try_load_keymap(const char* path)
|
||||
{
|
||||
if (load_keymap(path) == -1)
|
||||
{
|
||||
perror("load_keymap");
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
if (argc != 2)
|
||||
{
|
||||
fprintf(stderr, "usage: %s KEYMAP\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
struct stat st;
|
||||
if (stat(argv[1], &st) == 0)
|
||||
return try_load_keymap(argv[1]);
|
||||
|
||||
char buffer[128];
|
||||
strcpy(buffer, "/usr/share/keymaps/");
|
||||
strcat(buffer, argv[1]);
|
||||
|
||||
if (stat(buffer, &st) == 0)
|
||||
return try_load_keymap(buffer);
|
||||
|
||||
strcat(buffer, ".keymap");
|
||||
|
||||
if (stat(buffer, &st) == 0)
|
||||
return try_load_keymap(buffer);
|
||||
|
||||
fprintf(stderr, "Keymap '%s' not found\n", argv[1]);
|
||||
return 1;
|
||||
}
|
||||
Reference in New Issue
Block a user