summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Makefile5
-rw-r--r--pkg.c12
-rw-r--r--utils.c45
-rw-r--r--utils.h17
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
diff --git a/pkg.c b/pkg.c
new file mode 100644
index 0000000..3396e44
--- /dev/null
+++ b/pkg.c
@@ -0,0 +1,12 @@
+#include "utils.h"
+
+/*
+ **********************************************************
+ * All in One Package Manager for easier "Distro Hopping" *
+ **********************************************************
+*/
+
+int main(int argc, char **argv)
+{
+ return 0;
+}
diff --git a/utils.c b/utils.c
new file mode 100644
index 0000000..d270436
--- /dev/null
+++ b/utils.c
@@ -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;
+}
diff --git a/utils.h b/utils.h
new file mode 100644
index 0000000..12b0eb1
--- /dev/null
+++ b/utils.h
@@ -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();