blob: c2087e10f2d8ac8dd438d29ba77ab0a64fbeb42a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
#include "utils.h"
#include <stdlib.h>
#include <string.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;
}
char* stringedArgument(int argc, char** argv)
{
int numberOfTotalPackages = argc - 2;
char* arg = (char *) calloc(((numberOfTotalPackages * 80) + numberOfTotalPackages), sizeof(char));
for( int i = 2; i < argc; i++ )
{
strcat(arg, argv[i]);
strcat(arg, " ");
}
return arg;
}
|