Skip to content

Commit 6d6f4e6

Browse files
authored
Merge pull request #868 from kernelkit/remove-duplicates
2 parents 76ab0fe + f06a429 commit 6d6f4e6

File tree

5 files changed

+3
-217
lines changed

5 files changed

+3
-217
lines changed

src/confd/configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ PKG_PROG_PKG_CONFIG
6262
PKG_CHECK_MODULES([crypt], [libxcrypt >= 4.4.27])
6363
PKG_CHECK_MODULES([glib], [glib-2.0 >= 2.50 gio-2.0 gio-unix-2.0])
6464
PKG_CHECK_MODULES([jansson], [jansson >= 2.0.0])
65-
PKG_CHECK_MODULES([libite], [libite >= 2.5.0])
65+
PKG_CHECK_MODULES([libite], [libite >= 2.6.1])
6666
PKG_CHECK_MODULES([sysrepo], [sysrepo >= 2.2.36])
6767
PKG_CHECK_MODULES([libsrx], [libsrx >= 1.0.0])
6868

src/libsrx/src/helpers.c

Lines changed: 0 additions & 195 deletions
Original file line numberDiff line numberDiff line change
@@ -20,201 +20,6 @@ int debug; /* Sets debug level (0:off) */
2020
int vasprintf(char **strp, const char *fmt, va_list ap);
2121
#endif
2222

23-
/*
24-
* Run cmd in background after delay microseconds.
25-
*/
26-
int runbg(char *const args[], int delay)
27-
{
28-
int pid = fork();
29-
30-
if (!pid) {
31-
usleep(delay * 300);
32-
_exit(execvp(args[0], args));
33-
}
34-
35-
return pid;
36-
}
37-
38-
/*
39-
* Reap forked child from runbg()
40-
*/
41-
int run_status(int pid)
42-
{
43-
int rc;
44-
45-
/* WNOHANG */
46-
if (waitpid(pid, &rc, 0) == -1)
47-
return -1;
48-
49-
if (WIFEXITED(rc)) {
50-
errno = 0;
51-
rc = WEXITSTATUS(rc);
52-
} else if (WIFSIGNALED(rc)) {
53-
errno = EINTR;
54-
rc = -1;
55-
}
56-
57-
return rc;
58-
}
59-
60-
int fexistf(const char *fmt, ...)
61-
{
62-
va_list ap;
63-
char *file;
64-
int len;
65-
66-
va_start(ap, fmt);
67-
len = vsnprintf(NULL, 0, fmt, ap);
68-
va_end(ap);
69-
70-
file = alloca(len + 1);
71-
if (!file) {
72-
errno = ENOMEM;
73-
return -1;
74-
}
75-
76-
va_start(ap, fmt);
77-
vsnprintf(file, len + 1, fmt, ap);
78-
va_end(ap);
79-
80-
return fexist(file);
81-
}
82-
83-
FILE *popenf(const char *type, const char *cmdf, ...)
84-
{
85-
va_list ap;
86-
char *cmd;
87-
FILE *fp;
88-
int len;
89-
90-
va_start(ap, cmdf);
91-
len = vasprintf(&cmd, cmdf, ap);
92-
va_end(ap);
93-
94-
if (len < 0) {
95-
errno = ENOMEM;
96-
return NULL;
97-
}
98-
99-
fp = popen(cmd, type);
100-
free(cmd);
101-
return fp;
102-
}
103-
104-
/* XXX: -lite v2.6.0 has vfopenf() to replace this. */
105-
static FILE *open_file(const char *mode, const char *fmt, va_list ap)
106-
{
107-
va_list apc;
108-
char *file;
109-
int len;
110-
111-
va_copy(apc, ap);
112-
len = vsnprintf(NULL, 0, fmt, apc);
113-
va_end(apc);
114-
115-
file = alloca(len + 1);
116-
if (!file) {
117-
errno = ENOMEM;
118-
return NULL;
119-
}
120-
121-
va_copy(apc, ap);
122-
vsnprintf(file, len + 1, fmt, apc);
123-
va_end(apc);
124-
125-
return fopen(file, mode);
126-
}
127-
128-
int vreadllf(long long *value, const char *fmt, va_list ap)
129-
{
130-
char line[0x100];
131-
FILE *fp;
132-
133-
fp = open_file("r", fmt, ap);
134-
if (!fp)
135-
return -1;
136-
137-
if (!fgets(line, sizeof(line), fp)) {
138-
fclose(fp);
139-
return -1;
140-
}
141-
142-
fclose(fp);
143-
144-
errno = 0;
145-
*value = strtoll(line, NULL, 0);
146-
147-
return errno ? -1 : 0;
148-
}
149-
150-
int readllf(long long *value, const char *fmt, ...)
151-
{
152-
va_list ap;
153-
int rc;
154-
155-
va_start(ap, fmt);
156-
rc = vreadllf(value, fmt, ap);
157-
va_end(ap);
158-
159-
return rc;
160-
}
161-
162-
int readdf(int *value, const char *fmt, ...)
163-
{
164-
long long tmp;
165-
va_list ap;
166-
int rc;
167-
168-
va_start(ap, fmt);
169-
rc = vreadllf(&tmp, fmt, ap);
170-
va_end(ap);
171-
172-
if (rc)
173-
return rc;
174-
175-
if (tmp < INT_MIN || tmp > INT_MAX)
176-
return -1;
177-
178-
*value = tmp;
179-
return 0;
180-
}
181-
182-
/*
183-
* Write interger value to a file composed from fmt and optional args.
184-
*/
185-
int writedf(int value, const char *mode, const char *fmt, ...)
186-
{
187-
va_list ap;
188-
FILE *fp;
189-
190-
va_start(ap, fmt);
191-
fp = open_file(mode, fmt, ap);
192-
va_end(ap);
193-
if (!fp)
194-
return -1;
195-
196-
fprintf(fp, "%d\n", value);
197-
return fclose(fp);
198-
}
199-
200-
/*
201-
* Write str to a file composed from fmt and optional args.
202-
*/
203-
int writesf(const char *str, const char *mode, const char *fmt, ...)
204-
{
205-
va_list ap;
206-
FILE *fp;
207-
208-
va_start(ap, fmt);
209-
fp = open_file(mode, fmt, ap);
210-
va_end(ap);
211-
if (!fp)
212-
return -1;
213-
214-
fprintf(fp, "%s\n", str);
215-
return fclose(fp);
216-
}
217-
21823
char *unquote(char *buf)
21924
{
22025
char q = buf[0];

src/libsrx/src/helpers.h

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,6 @@
77

88
int vasprintf(char **strp, const char *fmt, va_list ap);
99

10-
int runbg(char *const args[], int delay);
11-
int run_status(int pid);
12-
13-
int fexistf(const char *fmt, ...)
14-
__attribute__ ((format (printf, 1, 2)));
15-
FILE *popenf(const char *type, const char *cmdf, ...)
16-
__attribute__ ((format (printf, 2, 3)));
17-
18-
int vreadllf(long long *value, const char *fmt, va_list ap);
19-
int readllf(long long *value, const char *fmt, ...)
20-
__attribute__ ((format (printf, 2, 3)));
21-
int readdf(int *value, const char *fmt, ...)
22-
__attribute__ ((format (printf, 2, 3)));
23-
24-
int writedf(int value, const char *mode, const char *fmt, ...)
25-
__attribute__ ((format (printf, 3, 4)));
26-
int writesf(const char *str, const char *mode, const char *fmt, ...)
27-
__attribute__ ((format (printf, 3, 4)));
28-
2910
char *unquote(char *buf);
3011
char *fgetkey(const char *file, const char *key);
3112

src/statd/configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ AM_CONDITIONAL(CONTAINERS, [test "x$enable_containers" != "xno"])
2828
PKG_PROG_PKG_CONFIG
2929

3030
PKG_CHECK_MODULES([jansson], [jansson >= 2.0.0])
31-
PKG_CHECK_MODULES([libite], [libite >= 2.5.0])
31+
PKG_CHECK_MODULES([libite], [libite >= 2.6.1])
3232
PKG_CHECK_MODULES([libyang], [libyang >= 2.1.80])
3333
PKG_CHECK_MODULES([sysrepo], [sysrepo >= 2.2.36])
3434
PKG_CHECK_MODULES([libsrx], [libsrx >= 1.0.0])

src/statd/shared.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
#include <stdlib.h>
55
#include <jansson.h>
66
#include <net/if.h>
7+
#include <libite/lite.h>
78

89
#include <srx/common.h>
9-
#include <srx/helpers.h>
1010

1111
json_t *json_get_output(const char *cmd)
1212
{

0 commit comments

Comments
 (0)