summaryrefslogtreecommitdiff
path: root/utils.c
diff options
context:
space:
mode:
authorrafa_99 <rafa99@protonmail.com>2020-12-31 13:21:44 +0000
committerrafa_99 <rafa99@protonmail.com>2020-12-31 13:24:04 +0000
commit271fefa2916f65d5964e21c7c752bea2e6d1689b (patch)
treeaff5606b0292efc6f390d684264869613c9fb7c0 /utils.c
parent06d4de9cfb6596f636f060410d4481623043dfe7 (diff)
Updated Clang Format Style and Replaced APT order due to gentoo emerge-select java
Diffstat (limited to 'utils.c')
-rw-r--r--utils.c60
1 files changed, 32 insertions, 28 deletions
diff --git a/utils.c b/utils.c
index 181b4c2..ad09c4f 100644
--- a/utils.c
+++ b/utils.c
@@ -4,85 +4,89 @@
#include <string.h>
#include <unistd.h>
-int checkIfFileExists(char *path)
+int
+checkIfFileExists (char *path)
{
- return access(path, F_OK);
+ return access (path, F_OK);
}
-int detectOsType()
+int
+detectOsType ()
{
int exists = ERROR;
- for ( int i = 0; i < ENUMSIZE && exists == ERROR; i++ )
+ for (int i = 0; i < ENUMSIZE && exists == ERROR; i++)
{
switch (i)
{
- case apt:
- if ( checkIfFileExists("/usr/bin/apt" ) == 0 )
- {
- exists = i;
- }
- break;
-
case dnf:
- if ( checkIfFileExists("/usr/bin/dnf" ) == 0 )
+ if (checkIfFileExists ("/usr/bin/dnf") == 0)
{
exists = i;
}
break;
case emerge:
- if ( checkIfFileExists("/usr/bin/emerge" ) == 0 )
+ if (checkIfFileExists ("/usr/bin/emerge") == 0)
{
exists = i;
}
break;
case pacman:
- if ( checkIfFileExists("/usr/bin/pacman" ) == 0 )
+ if (checkIfFileExists ("/usr/bin/pacman") == 0)
{
exists = i;
}
break;
case xbps:
- if ( checkIfFileExists("/usr/bin/xbps-install" ) == 0 )
+ if (checkIfFileExists ("/usr/bin/xbps-install") == 0)
{
exists = i;
}
break;
case zypper:
- if ( checkIfFileExists("/usr/bin/zypper" ) == 0 )
+ if (checkIfFileExists ("/usr/bin/zypper") == 0)
+ {
+ exists = i;
+ }
+ break;
+
+ case apt:
+ if (checkIfFileExists ("/usr/bin/apt") == 0)
{
exists = i;
}
break;
default:
- puts("Unrecognized Package Manager" );
+ puts ("Unrecognized Package Manager");
}
}
return exists;
}
-char* stringedArgument(int argc, char** argv)
+char *
+stringedArgument (int argc, char **argv)
{
int numberOfTotalPackages = argc - 2;
- char* arg = (char *) calloc((numberOfTotalPackages * 80), sizeof(char));
+ char *arg = (char *)calloc ((numberOfTotalPackages * 80), sizeof (char));
- for( int i = 2; i < argc; i++ )
+ for (int i = 2; i < argc; i++)
{
- strcat(arg, argv[i]);
- strcat(arg, " ");
+ strcat (arg, argv[i]);
+ strcat (arg, " ");
}
return arg;
}
-void commandProcessor(char* packages, char* initCommand)
+void
+commandProcessor (char *packages, char *initCommand)
{
- char* command = (char *) calloc(strlen(packages) + 80, sizeof(char));
- strcpy(command, initCommand);
- strcat(command, packages);
- system(command);
- free(command);
+ char *command = (char *)calloc (strlen (packages) + 80, sizeof (char));
+ strcpy (command, initCommand);
+ strcat (command, packages);
+ system (command);
+ free (command);
}