Constant data and pointers

This commit is contained in:
Roy Marples 2007-12-20 15:02:04 +00:00
parent 6b37d16a22
commit c474b810af
4 changed files with 32 additions and 26 deletions

View File

@ -88,21 +88,23 @@ void rc_deptree_free (rc_depinfo_t *deptree)
} }
librc_hidden_def(rc_deptree_free) librc_hidden_def(rc_deptree_free)
static rc_depinfo_t *get_depinfo (rc_depinfo_t *deptree, const char *service) static rc_depinfo_t *get_depinfo (const rc_depinfo_t *deptree,
const char *service)
{ {
rc_depinfo_t *di; const rc_depinfo_t *di;
if (! deptree || ! service) if (! deptree || ! service)
return (NULL); return (NULL);
for (di = deptree; di; di = di->next) for (di = deptree; di; di = di->next)
if (strcmp (di->service, service) == 0) if (strcmp (di->service, service) == 0)
return (di); return ((rc_depinfo_t *)di);
return (NULL); return (NULL);
} }
static rc_deptype_t *get_deptype (rc_depinfo_t *depinfo, const char *type) static rc_deptype_t *get_deptype (const rc_depinfo_t *depinfo,
const char *type)
{ {
rc_deptype_t *dt; rc_deptype_t *dt;
@ -270,7 +272,8 @@ static bool get_provided1 (const char *runlevel, struct lhead *providers,
If there are any bugs in rc-depend, they will probably be here as If there are any bugs in rc-depend, they will probably be here as
provided dependancy can change depending on runlevel state. provided dependancy can change depending on runlevel state.
*/ */
static char **get_provided (rc_depinfo_t *deptree, rc_depinfo_t *depinfo, static char **get_provided (const rc_depinfo_t *deptree,
const rc_depinfo_t *depinfo,
const char *runlevel, int options) const char *runlevel, int options)
{ {
rc_deptype_t *dt; rc_deptype_t *dt;
@ -376,9 +379,10 @@ static char **get_provided (rc_depinfo_t *deptree, rc_depinfo_t *depinfo,
return (providers.list); return (providers.list);
} }
static void visit_service (rc_depinfo_t *deptree, const char * const *types, static void visit_service (const rc_depinfo_t *deptree,
const char * const *types,
struct lhead *sorted, struct lhead *visited, struct lhead *sorted, struct lhead *visited,
rc_depinfo_t *depinfo, const rc_depinfo_t *depinfo,
const char *runlevel, int options) const char *runlevel, int options)
{ {
int i, j, k; int i, j, k;
@ -466,7 +470,7 @@ static void visit_service (rc_depinfo_t *deptree, const char * const *types,
rc_strlist_add (&sorted->list, depinfo->service); rc_strlist_add (&sorted->list, depinfo->service);
} }
char **rc_deptree_depend (rc_depinfo_t *deptree, char **rc_deptree_depend (const rc_depinfo_t *deptree,
const char *service, const char *type) const char *service, const char *type)
{ {
rc_depinfo_t *di; rc_depinfo_t *di;
@ -490,8 +494,9 @@ char **rc_deptree_depend (rc_depinfo_t *deptree,
} }
librc_hidden_def(rc_deptree_depend) librc_hidden_def(rc_deptree_depend)
char **rc_deptree_depends (rc_depinfo_t *deptree, char **rc_deptree_depends (const rc_depinfo_t *deptree,
const char **types, const char **services, const char *const *types,
const char *const *services,
const char *runlevel, int options) const char *runlevel, int options)
{ {
struct lhead sorted; struct lhead sorted;
@ -526,8 +531,8 @@ char **rc_deptree_depends (rc_depinfo_t *deptree,
} }
librc_hidden_def(rc_deptree_depends) librc_hidden_def(rc_deptree_depends)
static const const char *order_types[] = { "ineed", "iuse", "iafter", NULL }; static const char * const order_types[] = { "ineed", "iuse", "iafter", NULL };
char **rc_deptree_order (rc_depinfo_t *deptree, const char *runlevel, char **rc_deptree_order (const rc_depinfo_t *deptree, const char *runlevel,
int options) int options)
{ {
char **list = NULL; char **list = NULL;

View File

@ -109,8 +109,8 @@ typedef struct pidlist
} pidlist_t; } pidlist_t;
static pidlist_t *service_pids = NULL; static pidlist_t *service_pids = NULL;
static const char *types_n[] = { "needsme", NULL }; static const char *const types_n[] = { "needsme", NULL };
static const char *types_nua[] = { "ineed", "iuse", "iafter", NULL }; static const char *const types_nua[] = { "ineed", "iuse", "iafter", NULL };
static void cleanup (void) static void cleanup (void)
{ {

View File

@ -274,7 +274,7 @@ rc_depinfo_t *rc_deptree_load (void);
* @param type to use (keywords, etc) * @param type to use (keywords, etc)
* @param service to check * @param service to check
* @return NULL terminated list of services in order */ * @return NULL terminated list of services in order */
char **rc_deptree_depend (rc_depinfo_t *deptree, char **rc_deptree_depend (const rc_depinfo_t *deptree,
const char *type, const char *service); const char *type, const char *service);
/*! List all the services in order that the given services have /*! List all the services in order that the given services have
@ -284,8 +284,9 @@ char **rc_deptree_depend (rc_depinfo_t *deptree,
* @param services to check * @param services to check
* @param options to pass * @param options to pass
* @return NULL terminated list of services in order */ * @return NULL terminated list of services in order */
char **rc_deptree_depends (rc_depinfo_t *deptree, const char **types, char **rc_deptree_depends (const rc_depinfo_t *deptree,
const char **services, const char *runlevel, const char *const *types,
const char *const *services, const char *runlevel,
int options); int options);
/*! List all the services that should be stoppned and then started, in order, /*! List all the services that should be stoppned and then started, in order,
@ -295,7 +296,7 @@ char **rc_deptree_depends (rc_depinfo_t *deptree, const char **types,
* @param runlevel to change into * @param runlevel to change into
* @param options to pass * @param options to pass
* @return NULL terminated list of services in order */ * @return NULL terminated list of services in order */
char **rc_deptree_order (rc_depinfo_t *deptree, const char *runlevel, char **rc_deptree_order (const rc_depinfo_t *deptree, const char *runlevel,
int options); int options);
/*! Free a deptree and its information /*! Free a deptree and its information

View File

@ -99,13 +99,13 @@ static int master_tty = -1;
extern char **environ; extern char **environ;
static const char *types_b[] = { "broken", NULL }; static const char *const types_b[] = { "broken", NULL };
static const char *types_n[] = { "ineed", NULL }; static const char *const types_n[] = { "ineed", NULL };
static const char *types_nu[] = { "ineed", "iuse", NULL }; static const char *const types_nu[] = { "ineed", "iuse", NULL };
static const char *types_nua[] = { "ineed", "iuse", "iafter", NULL }; static const char *const types_nua[] = { "ineed", "iuse", "iafter", NULL };
static const char *types_m[] = { "needsme", NULL }; static const char *const types_m[] = { "needsme", NULL };
static const char *types_mua[] = { "needsme", "usesme", "beforeme", NULL }; static const char *const types_mua[] = { "needsme", "usesme", "beforeme", NULL };
#ifdef __linux__ #ifdef __linux__
static void (*selinux_run_init_old) (void); static void (*selinux_run_init_old) (void);
@ -637,7 +637,7 @@ static void svc_start (bool deps)
int i; int i;
int j; int j;
int depoptions = RC_DEP_TRACE; int depoptions = RC_DEP_TRACE;
const char *svcl[] = { applet, NULL }; const char *const svcl[] = { applet, NULL };
rc_service_state_t state; rc_service_state_t state;
state = rc_service_state (service); state = rc_service_state (service);
@ -846,7 +846,7 @@ static void svc_start (bool deps)
static void svc_stop (bool deps) static void svc_stop (bool deps)
{ {
bool stopped; bool stopped;
const char *svcl[] = { applet, NULL }; const char *const svcl[] = { applet, NULL };
rc_service_state_t state = rc_service_state (service); rc_service_state_t state = rc_service_state (service);