-
Notifications
You must be signed in to change notification settings - Fork 0
/
deinstaller.c
60 lines (50 loc) · 1.26 KB
/
deinstaller.c
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 <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include "install.h"
const char progname[] = "deinstaller";
void
cb_info (const char *str, void *data)
{
fprintf (stderr, "%s\n", str);
}
void
cb_warn (const char *str, void *data)
{
fprintf (stderr, "%s: warning: %s\n", progname, str);
}
int
main (int argc, char *argv[])
{
unsigned long i;
unsigned int flag;
struct install_status_t status;
argv = 0;
status = install_init ();
if (status.status != INSTALL_STATUS_OK) {
fprintf (stderr, "%s: fatal: init: %s - %s\n", progname,
status.message, install_error (errno));
exit (112);
}
install_callback_warn_set (cb_warn);
install_callback_info_set (cb_info);
flag = (argc > 1) ? INSTALL_DRYRUN : 0;
for (i = insthier_len - 1;; --i) {
status = deinstall (&insthier[i], flag);
switch (status.status) {
case INSTALL_STATUS_OK:
break;
case INSTALL_STATUS_ERROR:
fprintf (stderr, "%s: error: %s - %s\n", progname,
status.message, install_error (errno));
break;
case INSTALL_STATUS_FATAL:
fprintf (stderr, "%s: fatal: %s - %s\n", progname,
status.message, install_error (errno));
exit (112);
break;
}
if (i == 0) break;
}
return 0;
}