blob: 3dd8b671330c9e3bf94c434d826c9bab9f69f9f0 (
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
|
/* ISC license. */
#include <stdint.h>
#include <string.h>
#include <skalibs/djbunix.h>
#include <s6-rc/s6rc-db.h>
#include <s6-rc/s6rc-utils.h>
int s6rc_live_state_size (char const *live, uint32_t *nlong, uint32_t *nshort)
{
s6rc_db_t db ;
int fd ;
size_t livelen = strlen(live) ;
char fn[livelen + 10] ;
memcpy(fn, live, livelen) ;
memcpy(fn + livelen, "/compiled", 10) ;
fd = openc_readb(fn) ;
if (fd == -1) return 0 ;
if (!s6rc_db_read_sizes(fd, &db))
{
fd_close(fd) ;
return 0 ;
}
fd_close(fd) ;
*nlong = db.nlong ;
*nshort = db.nshort ;
return 1 ;
}
|