-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstchk.c
75 lines (65 loc) · 1.95 KB
/
instchk.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include "ctxt.h"
#include "install.h"
static const char progname[] = "instchk";
static void
cb_info (const char *str, /*@unused@*/ void *data)
/*@globals stderr @*/
/*@modifies stderr @*/
{
(void) fprintf (stderr, "%s\n", str);
}
static void
cb_warn (const char *str, /*@unused@*/ void *data)
/*@globals stderr, progname @*/
/*@modifies stderr @*/
{
(void) fprintf (stderr, "%s: warning: %s\n", progname, str);
}
int
main (void)
/*@globals errno, insthier_len, progname, stderr, insthier, ctxt_fakeroot, install_failed @*/
/*@modifies stderr @*/
{
unsigned long index;
struct install_status_t status;
if (ctxt_fakeroot[0] != (char) 0) {
(void) fprintf (stderr, "%s: info: using fake root - %s\n", progname, ctxt_fakeroot);
install_fake_root (ctxt_fakeroot);
}
status = install_init ("conf-sosuffix");
if (status.status != INSTALL_STATUS_OK) {
assert (status.message != NULL);
(void) fprintf (stderr, "%s: fatal: init: %s - %s\n", progname,
status.message, status.error_message);
exit (EXIT_FAILURE);
}
install_callback_warn_set (cb_warn);
install_callback_info_set (cb_info);
for (index = 0; index < insthier_len; ++index) {
status = install_check (&insthier[index]);
switch (status.status) {
case INSTALL_STATUS_OK:
break;
case INSTALL_STATUS_ERROR:
assert (status.message != NULL);
(void) fprintf (stderr, "%s: error: %s - %s\n", progname,
status.message, status.error_message);
break;
case INSTALL_STATUS_FATAL:
assert (status.message != NULL);
(void) fprintf (stderr, "%s: fatal: %s - %s\n", progname,
status.message, status.error_message);
exit (EXIT_FAILURE);
}
}
if (install_failed != 0) {
(void) fprintf (stderr, "%s: %lu of %lu files failed\n", progname,
install_failed, insthier_len);
return 1;
}
return 0;
}