Skip to content

Commit

Permalink
librc: make rc_proc_getent available for all operating systems
Browse files Browse the repository at this point in the history
This looks up an option on the kernel command line. For now, itworks on
linux and returns NULL on the bsds, but we are definitely open to
patches for that side.
  • Loading branch information
williamh committed Feb 25, 2012
1 parent de6323b commit 582c8e9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/librc/librc-misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@ rc_getline(char **line, size_t *len, FILE *fp)
}
librc_hidden_def(rc_getline)

#ifdef __linux__
char *
rc_proc_getent(const char *ent)
{
#ifdef __linux__
FILE *fp;
char *proc, *p, *value = NULL;
size_t i, len;
Expand Down Expand Up @@ -171,9 +171,11 @@ rc_proc_getent(const char *ent)
free(proc);

return value;
#else
return NULL;
#endif
}
librc_hidden_def(rc_proc_getent)
#endif

RC_STRINGLIST *
rc_config_list(const char *file)
Expand Down
2 changes: 0 additions & 2 deletions src/librc/librc.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,7 @@ librc_hidden_proto(rc_find_pids)
librc_hidden_proto(rc_getfile)
librc_hidden_proto(rc_getline)
librc_hidden_proto(rc_newer_than)
#ifdef __linux__
librc_hidden_proto(rc_proc_getent)
#endif
librc_hidden_proto(rc_older_than)
librc_hidden_proto(rc_runlevel_exists)
librc_hidden_proto(rc_runlevel_get)
Expand Down
2 changes: 0 additions & 2 deletions src/librc/rc.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -360,12 +360,10 @@ bool rc_newer_than(const char *, const char *, time_t *, char *);
* @return true if source is older than target, otherwise false */
bool rc_older_than(const char *, const char *, time_t *, char *);

#ifdef __linux__
/*! Read variables/values from /proc/cmdline
* @param value
* @return pointer to the value, otherwise NULL */
char *rc_proc_getent(const char *);
#endif

/*! Update the cached dependency tree if it's older than any init script,
* its configuration file or an external configuration file the init script
Expand Down

0 comments on commit 582c8e9

Please sign in to comment.