diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Makefile | 5 | ||||
-rw-r--r-- | pkg.c | 12 | ||||
-rw-r--r-- | utils.c | 45 | ||||
-rw-r--r-- | utils.h | 17 |
5 files changed, 80 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5fff1d9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +pkg diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1ece297 --- /dev/null +++ b/Makefile @@ -0,0 +1,5 @@ +all: clean + gcc -o pkg pkg.c utils.c + +clean: + rm -rf pkg @@ -0,0 +1,12 @@ +#include "utils.h" + +/* + ********************************************************** + * All in One Package Manager for easier "Distro Hopping" * + ********************************************************** +*/ + +int main(int argc, char **argv) +{ + return 0; +} @@ -0,0 +1,45 @@ +#include "utils.h" +#include <unistd.h> + +int checkIfFileExists(char *path) +{ + return access(path, F_OK); +} + +int detectOsType() +{ + int exists = ERROR; + for ( int i = 0; i < ENUMSIZE || exists == ERROR; i++ ) + { + switch (i) + { + case pacman: + if ( checkIfFileExists("/usr/bin/pacman") == 0 ) + { + exists = i; + } + break; + + case apt: + if ( checkIfFileExists("/usr/bin/apt") == 0 ) + { + exists = i; + } + break; + + case emerge: + if ( checkIfFileExists("/usr/bin/emerge") == 0 ) + { + exists = i; + } + break; + + case xbps: + if ( checkIfFileExists("/usr/bin/xbps-install") == 0 ) + { + exists = i; + } + } + } + return exists; +} @@ -0,0 +1,17 @@ +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +#define ERROR -1 + +enum os +{ + pacman, + apt, + emerge, + xbps, + ENUMSIZE +}; + +int checkIfFileExists(char *path); +int detectOsType(); |