-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cpp
123 lines (118 loc) · 2.24 KB
/
main.cpp
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#include <iostream>
#include <string.h>
#include <string>
#include <sstream>
#include <vector>
using namespace std;
char search_app(char apk[])
{
FILE *in;
char tmp[256];
char str[100];
string temp;
char app_list[50];
int n = 0;
int i = 0;
cout << "Searching for " << apk << endl;
in = fopen("all_apps.txt", "r");
if (in == NULL)
{
perror("Error opening input or output file ");
exit(EXIT_FAILURE);
}
while (!feof(in))
{
memset(tmp, 0x00, sizeof(tmp));
if (fgets(tmp, 255, in) != NULL)
{
if (strstr(tmp, apk) != NULL)
{
// string line = tmp;
// char arr[4];
// int i = 0;
// stringstream ssin(line);
// while (ssin.good() && i < 4)
// {
// ssin >> arr[i];
// ++i;
// }
cout << n << ". " << tmp ;
app_list[n] = *tmp;
n++;
}
}
}
fclose(in);
return 0;
return 0;
}
int install_app(char apkName[])
{
cout << "Installing " << apkName << endl;
cout << "Successfully installed " << apkName << endl;
return 0;
}
int main(int argc, char *argv[])
{
string url;
string file_path;
if (argc == 1)
{
cout << "Show Help" << endl;
}
else if (argc == 2)
{
if (strcmp(argv[1], "update") == 0)
{
cout << "Performing Update " << endl;
}
else if (strcmp(argv[1], "upgrade") == 0)
{
cout << "Performing Upgrade " << endl;
}
else if (strcmp(argv[1], "list") == 0)
{
cout << "List installed packages " << endl;
}
else if (strcmp(argv[1], "install") == 0)
{
cerr << "Usage: " << argv[0] << " install [APK_NAME]";
}
else if (strcmp(argv[1], "search") == 0)
{
cerr << "Usage: " << argv[0] << " search [APK_NAME]";
}
else
{
cout << "Show help";
}
}
else if (argc == 4)
{
if (strcmp(argv[2], "--pn") == 0)
{
cout << "Performing install " << endl;
install_app(argv[3]);
}
else
{
cout << "show help";
}
}
else
{
if (strcmp(argv[1], "install") == 0)
{
cout << "fetching repo" << endl;
}
else if (strcmp(argv[1], "search") == 0)
{
search_app(argv[2]);
}
else
{
cout << "Show help";
}
}
return 0;
}