/[baselayout]/trunk/src/rc-misc.h
Gentoo

Contents of /trunk/src/rc-misc.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3007 - (show annotations) (download) (as text)
Mon Oct 8 11:07:39 2007 UTC (7 years, 2 months ago) by uberlord
File MIME type: text/x-chdr
File size: 1954 byte(s)
Move rc_env_filter and rc_env_config out of librc and into rc
1 /*
2 rc-misc.h
3 This is private to us and not for user consumption
4 Copyright 2007 Gentoo Foundation
5 */
6
7 #ifndef __RC_MISC_H__
8 #define __RC_MISC_H__
9
10 #include <sys/stat.h>
11 #include <errno.h>
12
13 #ifndef LIB
14 # define LIB "lib"
15 #endif
16
17 #define RC_LEVEL_BOOT "boot"
18 #define RC_LEVEL_DEFAULT "default"
19
20 #define RC_LIBDIR "/" LIB "/rc"
21 #define RC_SVCDIR RC_LIBDIR "/init.d"
22 #define RC_DEPTREE RC_SVCDIR "/deptree"
23 #define RC_RUNLEVELDIR "/etc/runlevels"
24 #define RC_INITDIR "/etc/init.d"
25 #define RC_CONFDIR "/etc/conf.d"
26
27 #define RC_KSOFTLEVEL RC_SVCDIR "/ksoftlevel"
28 #define RC_STARTING RC_SVCDIR "/rc.starting"
29 #define RC_STOPPING RC_SVCDIR "/rc.stopping"
30
31 #define RC_SVCDIR_STARTING RC_SVCDIR "/starting"
32 #define RC_SVCDIR_INACTIVE RC_SVCDIR "/inactive"
33 #define RC_SVCDIR_STARTED RC_SVCDIR "/started"
34 #define RC_SVCDIR_COLDPLUGGED RC_SVCDIR "/coldplugged"
35
36 #define RC_PLUGINDIR RC_LIBDIR "/plugins"
37
38 /* Max buffer to read a line from a file */
39 #define RC_LINEBUFFER 4096
40
41 /* Good defaults just incase user has none set */
42 #define RC_NET_FS_LIST_DEFAULT "afs cifs coda davfs fuse gfs ncpfs nfs nfs4 ocfs2 shfs smbfs"
43
44 #define ERRX fprintf (stderr, "out of memory\n"); exit (1)
45
46 static inline void *rc_xmalloc (size_t size)
47 {
48 void *value = malloc (size);
49
50 if (value)
51 return (value);
52
53 ERRX;
54 }
55
56 static inline void *rc_xrealloc (void *ptr, size_t size)
57 {
58 void *value = realloc (ptr, size);
59
60 if (value)
61 return (value);
62
63 ERRX;
64 }
65
66 static inline char *rc_xstrdup (const char *str)
67 {
68 char *value;
69
70 if (! str)
71 return (NULL);
72
73 value = strdup (str);
74
75 if (value)
76 return (value);
77
78 ERRX;
79 }
80
81 #undef ERRX
82
83 static inline bool rc_exists (const char *pathname)
84 {
85 struct stat buf;
86
87 return (stat (pathname, &buf) == 0);
88 }
89
90 char **env_filter (void);
91 char **env_config (void);
92
93 #endif

  ViewVC Help
Powered by ViewVC 1.1.20