gentoo: use /var/run for new /run compatibility
[util-vserver.git] / lib / internal.h
1 // $Id$    --*- c++ -*--
2
3 // Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
4 //  
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; version 2 of the License.
8 //  
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 // GNU General Public License for more details.
13 //  
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
18 /** \file internal.h
19  *  \brief Declarations which are used by util-vserver internally.
20  */
21
22 #ifndef H_UTIL_VSERVER_LIB_INTERNAL_H
23 #define H_UTIL_VSERVER_LIB_INTERNAL_H
24
25 #include "fmt.h"
26 #include "vserver.h"
27
28 #include <stdlib.h>
29 #include <stdbool.h>
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35
36 #ifdef HAVE_VERSIONING
37 /* FIXME: HAVE_ASM_DOT_GLOBAL_NAME */
38 #  define _symbol_version(real, name, version) \
39      __asm__ (".symver " #real "," #name "@" #version)
40 #  define _default_symbol_version(real, name, version) \
41      __asm__ (".symver " #real "," #name "@@" #version)
42 #else
43 #  define _symbol_version(real, name, version)
44 #  define _default_symbol_version(real, name, version) \
45   extern __typeof (real) name __attribute__ ((alias (#name)));
46 #endif
47 #define symbol_version(real, name, version) \
48         _symbol_version(real, name, version)
49 #define default_symbol_version(real, name, version) \
50         _default_symbol_version(real, name, version)
51
52
53 char *  vc_getVserverByCtx_Internal(xid_t ctx, /*@null@*/vcCfgStyle *style,
54                                     /*@null@*/char const *revdir,
55                                     bool validate_result);
56
57   
58 int     utilvserver_checkCompatVersion();
59 uint_least32_t  utilvserver_checkCompatConfig();
60 bool    utilvserver_isDirectory(char const *path, bool follow_link);
61 bool    utilvserver_isFile(char const *path, bool follow_link);
62 bool    utilvserver_isLink(char const *path);
63
64 int     utilvserver_listparser_uint32(char const *str, size_t len,
65                                       char const **err_ptr, size_t *err_len,
66                                       uint_least32_t *flag,
67                                       uint_least32_t *mask,
68                                       uint_least32_t (*func)(char const*,
69                                                              size_t, bool *
70                                         )) NONNULL((1,5,7));
71   
72 int     utilvserver_listparser_uint64(char const *str, size_t len,
73                                       char const **err_ptr, size_t *err_len,
74                                       uint_least64_t *flag,
75                                       uint_least64_t *mask,
76                                       uint_least64_t (*func)(char const*,
77                                                              size_t, bool *
78                                         )) NONNULL((1,5,7));
79
80 struct Mapping_uint32 {
81     char const * const  id;
82     size_t                      len;
83     uint_least32_t              val;
84 };
85
86 struct Mapping_uint64 {
87     char const * const  id;
88     size_t                      len;
89     uint_least64_t              val;
90 };
91   
92 ssize_t utilvserver_value2text_uint32(char const *str, size_t len,
93                                       struct Mapping_uint32 const *map,
94                                       size_t map_len) NONNULL((1,3));
95
96 ssize_t utilvserver_value2text_uint64(char const *str, size_t len,
97                                       struct Mapping_uint64 const *map,
98                                       size_t map_len) NONNULL((1,3));
99
100 ssize_t utilvserver_text2value_uint32(uint_least32_t *val,
101                                       struct Mapping_uint32 const *map,
102                                       size_t map_len) NONNULL((1,2));
103   
104 ssize_t utilvserver_text2value_uint64(uint_least64_t *val,
105                                       struct Mapping_uint64 const *map,
106                                       size_t map_len) NONNULL((1,2));
107 #ifdef __cplusplus
108 }
109 #endif
110
111
112 #endif  //  H_UTIL_VSERVER_LIB_INTERNAL_H