-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpkg_dev.c
More file actions
70 lines (50 loc) · 1.24 KB
/
pkg_dev.c
File metadata and controls
70 lines (50 loc) · 1.24 KB
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
#include "pkg_dev.h"
#include <cprocess.h>
#include <cfile.h>
#include <libstr.h>
#include <print.h>
#include <dirent.h>
//#include <stdlib.h>
//#include <stdio.h>
//#include <string.h>
//#include <unistd.h>
//#include <sys/types.h>
bool pkg_dev()
{
const char *cmd = "dpkg -l";
CProcessAuto *process = cprocess_new();
if (!cprocess_start(process, cmd, CP_PIPEOUT))
{
print("start failed");
return false;
}
int status = cprocess_exitstatus(process);
if (status != 0)
{
print("program returned : %d", status);
return false;
}
CString *result = cprocess_outbuff(process);
const char *start = c_str(result);
CStringAuto *line = cstr_new_size(32);
while (file_getline(&start, line))
{
char *start = c_str(line);
int count = 0;
char *result;
int len;
while (str_getpart(&start, &result, &len))
{
if (++count < 2)
continue;
result[len] = '\0';
char *coln = strchr(result, ':');
if (coln)
*coln = '\0';
if (str_endswith(result, "-dev", true))
print(result);
break;
}
}
return true;
}