Fix rc_service_value_get() to return multiple lines as well
As introduced in bug 372547 using service_get_value() in the init scripts or using rc_service_value_get() directly will only return one line. This patch fixes it by using the new rc_getfile() function, it returns even multiple lines. We're still using a char *, so the lines will be appended instead of added into new element. X-Gentoo-Bug: 372547 X-Gentoo-Bug-URL: http://bugs.gentoo.org/372547
This commit is contained in:
parent
fdaf1c65cd
commit
a74382d9cb
@ -767,19 +767,15 @@ librc_hidden_def(rc_service_state)
|
|||||||
char *
|
char *
|
||||||
rc_service_value_get(const char *service, const char *option)
|
rc_service_value_get(const char *service, const char *option)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
char *buffer = NULL;
|
||||||
char *line = NULL;
|
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
char file[PATH_MAX];
|
char file[PATH_MAX];
|
||||||
|
|
||||||
snprintf(file, sizeof(file), RC_SVCDIR "/options/%s/%s",
|
snprintf(file, sizeof(file), RC_SVCDIR "/options/%s/%s",
|
||||||
service, option);
|
service, option);
|
||||||
if ((fp = fopen(file, "r"))) {
|
rc_getfile(file, &buffer, &len);
|
||||||
rc_getline(&line, &len, fp);
|
|
||||||
fclose(fp);
|
|
||||||
}
|
|
||||||
|
|
||||||
return line;
|
return buffer;
|
||||||
}
|
}
|
||||||
librc_hidden_def(rc_service_value_get)
|
librc_hidden_def(rc_service_value_get)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user