librc: make rc_proc_getent available for all operating systems

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.
This commit is contained in:
William Hubbs 2012-02-25 15:00:03 -06:00
parent de6323ba51
commit 582c8e9868
3 changed files with 4 additions and 6 deletions

View File

@ -128,10 +128,10 @@ rc_getline(char **line, size_t *len, FILE *fp)
} }
librc_hidden_def(rc_getline) librc_hidden_def(rc_getline)
#ifdef __linux__
char * char *
rc_proc_getent(const char *ent) rc_proc_getent(const char *ent)
{ {
#ifdef __linux__
FILE *fp; FILE *fp;
char *proc, *p, *value = NULL; char *proc, *p, *value = NULL;
size_t i, len; size_t i, len;
@ -171,9 +171,11 @@ rc_proc_getent(const char *ent)
free(proc); free(proc);
return value; return value;
#else
return NULL;
#endif
} }
librc_hidden_def(rc_proc_getent) librc_hidden_def(rc_proc_getent)
#endif
RC_STRINGLIST * RC_STRINGLIST *
rc_config_list(const char *file) rc_config_list(const char *file)

View File

@ -87,9 +87,7 @@ librc_hidden_proto(rc_find_pids)
librc_hidden_proto(rc_getfile) librc_hidden_proto(rc_getfile)
librc_hidden_proto(rc_getline) librc_hidden_proto(rc_getline)
librc_hidden_proto(rc_newer_than) librc_hidden_proto(rc_newer_than)
#ifdef __linux__
librc_hidden_proto(rc_proc_getent) librc_hidden_proto(rc_proc_getent)
#endif
librc_hidden_proto(rc_older_than) librc_hidden_proto(rc_older_than)
librc_hidden_proto(rc_runlevel_exists) librc_hidden_proto(rc_runlevel_exists)
librc_hidden_proto(rc_runlevel_get) librc_hidden_proto(rc_runlevel_get)

View File

@ -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 */ * @return true if source is older than target, otherwise false */
bool rc_older_than(const char *, const char *, time_t *, char *); bool rc_older_than(const char *, const char *, time_t *, char *);
#ifdef __linux__
/*! Read variables/values from /proc/cmdline /*! Read variables/values from /proc/cmdline
* @param value * @param value
* @return pointer to the value, otherwise NULL */ * @return pointer to the value, otherwise NULL */
char *rc_proc_getent(const char *); char *rc_proc_getent(const char *);
#endif
/*! Update the cached dependency tree if it's older than any init script, /*! Update the cached dependency tree if it's older than any init script,
* its configuration file or an external configuration file the init script * its configuration file or an external configuration file the init script