/[baselayout]/trunk/src/librc-depend.c
Gentoo

Diff of /trunk/src/librc-depend.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 2572 Revision 2597
2 librc-depend 2 librc-depend
3 rc service dependency and ordering 3 rc service dependency and ordering
4 Copyright 2006-2007 Gentoo Foundation 4 Copyright 2006-2007 Gentoo Foundation
5 */ 5 */
6 6
7#include <sys/types.h>
8#include <sys/stat.h>
9
10#include <errno.h>
11#include <limits.h>
12#include <stdbool.h>
13#include <stdio.h>
14#include <stdlib.h>
15#include <string.h>
16
17#include "einfo.h"
18#include "rc.h" 7#include "librc.h"
19#include "rc-misc.h"
20#include "strlist.h"
21 8
22#define GENDEP RC_LIBDIR "/sh/gendepends.sh" 9#define GENDEP RC_LIBDIR "/sh/gendepends.sh"
23 10
24/* We use this so we can pass our char array through many functions */ 11/* We use this so we can pass our char array through many functions */
25struct lhead 12struct lhead
68 } 55 }
69 free (di); 56 free (di);
70 di = dip; 57 di = dip;
71 } 58 }
72} 59}
60librc_hidden_def(rc_free_deptree)
73 61
74rc_depinfo_t *rc_load_deptree (void) 62rc_depinfo_t *rc_load_deptree (void)
75{ 63{
76 FILE *fp; 64 FILE *fp;
77 rc_depinfo_t *deptree = NULL; 65 rc_depinfo_t *deptree = NULL;
156 } 144 }
157 fclose (fp); 145 fclose (fp);
158 146
159 return (deptree); 147 return (deptree);
160} 148}
149librc_hidden_def(rc_load_deptree)
161 150
162rc_depinfo_t *rc_get_depinfo (rc_depinfo_t *deptree, const char *service) 151rc_depinfo_t *rc_get_depinfo (rc_depinfo_t *deptree, const char *service)
163{ 152{
164 rc_depinfo_t *di; 153 rc_depinfo_t *di;
165 154
170 if (strcmp (di->service, service) == 0) 159 if (strcmp (di->service, service) == 0)
171 return (di); 160 return (di);
172 161
173 return (NULL); 162 return (NULL);
174} 163}
164librc_hidden_def(rc_get_depinfo)
175 165
176rc_deptype_t *rc_get_deptype (rc_depinfo_t *depinfo, const char *type) 166rc_deptype_t *rc_get_deptype (rc_depinfo_t *depinfo, const char *type)
177{ 167{
178 rc_deptype_t *dt; 168 rc_deptype_t *dt;
179 169
184 if (strcmp (dt->type, type) == 0) 174 if (strcmp (dt->type, type) == 0)
185 return (dt); 175 return (dt);
186 176
187 return (NULL); 177 return (NULL);
188} 178}
179librc_hidden_def(rc_get_deptype)
189 180
190static bool valid_service (const char *runlevel, const char *service) 181static bool valid_service (const char *runlevel, const char *service)
191{ 182{
192 return ((strcmp (runlevel, RC_LEVEL_BOOT) != 0 && 183 return ((strcmp (runlevel, RC_LEVEL_BOOT) != 0 &&
193 rc_service_in_runlevel (service, RC_LEVEL_BOOT)) || 184 rc_service_in_runlevel (service, RC_LEVEL_BOOT)) ||
454 } 445 }
455 446
456 rc_strlist_free (visited.list); 447 rc_strlist_free (visited.list);
457 return (sorted.list); 448 return (sorted.list);
458} 449}
450librc_hidden_def(rc_get_depends)
459 451
460char **rc_order_services (rc_depinfo_t *deptree, const char *runlevel, 452char **rc_order_services (rc_depinfo_t *deptree, const char *runlevel,
461 int options) 453 int options)
462{ 454{
463 char **list = NULL; 455 char **list = NULL;
508 if (reverse) 500 if (reverse)
509 rc_strlist_reverse (services); 501 rc_strlist_reverse (services);
510 502
511 return (services); 503 return (services);
512} 504}
505librc_hidden_def(rc_order_services)
513 506
514static bool is_newer_than (const char *file, const char *target) 507static bool is_newer_than (const char *file, const char *target)
515{ 508{
516 struct stat buf; 509 struct stat buf;
517 time_t mtime; 510 time_t mtime;
836 rc_free_deptree (deptree); 829 rc_free_deptree (deptree);
837 830
838 eend (retval, "Failed to update the service dependency tree"); 831 eend (retval, "Failed to update the service dependency tree");
839 return (retval); 832 return (retval);
840} 833}
834librc_hidden_def(rc_update_deptree)

Legend:
Removed from v.2572  
changed lines
  Added in v.2597

  ViewVC Help
Powered by ViewVC 1.1.20