00001 /** @file 00002 00003 Layout 00004 00005 @section license License 00006 00007 Licensed to the Apache Software Foundation (ASF) under one 00008 or more contributor license agreements. See the NOTICE file 00009 distributed with this work for additional information 00010 regarding copyright ownership. The ASF licenses this file 00011 to you under the Apache License, Version 2.0 (the 00012 "License"); you may not use this file except in compliance 00013 with the License. You may obtain a copy of the License at 00014 00015 http://www.apache.org/licenses/LICENSE-2.0 00016 00017 Unless required by applicable law or agreed to in writing, software 00018 distributed under the License is distributed on an "AS IS" BASIS, 00019 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00020 See the License for the specific language governing permissions and 00021 limitations under the License. 00022 00023 @section details Details 00024 00025 Part of the utils library which contains classes that use multiple 00026 components of the IO-Core to implement some useful functionality. The 00027 classes also serve as good examples of how to use the IO-Core. 00028 00029 */ 00030 00031 #ifndef _I_Layout_h 00032 #define _I_Layout_h 00033 00034 /** 00035 The Layout is a simple place holder for the distribution layout. 00036 00037 */ 00038 struct Layout 00039 { 00040 char *prefix; 00041 char *exec_prefix; 00042 char *bindir; 00043 char *sbindir; 00044 char *sysconfdir; 00045 char *datadir; 00046 char *includedir; 00047 char *libdir; 00048 char *libexecdir; 00049 char *localstatedir; 00050 char *sharedstatedir; 00051 char *runtimedir; 00052 char *logdir; 00053 char *mandir; 00054 char *infodir; 00055 char *cachedir; 00056 00057 Layout(const char *prefix = 0); 00058 ~Layout(); 00059 00060 /** 00061 Return file path relative to Layout->prefix 00062 Memory is allocated, so use ats_free() when no longer needed 00063 00064 */ 00065 char *relative(const char *file); 00066 00067 /** 00068 Return file path relative to Layout->prefix 00069 Store the path to buf. The buf should be large eough to store 00070 PATH_NAME_MAX characters 00071 00072 */ 00073 void relative(char *buf, size_t bufsz, const char *file); 00074 00075 /** 00076 Return file path relative to dir 00077 Memory is allocated, so use ats_free() when no longer needed 00078 Example usage: Layout::relative_to(default_layout()->sysconfdir, "foo.bar"); 00079 00080 */ 00081 static char *relative_to(const char *dir, const char *file); 00082 00083 /** 00084 Return file path relative to dir 00085 Store the path to buf. The buf should be large eough to store 00086 PATH_NAME_MAX characters 00087 Example usage: Layout::relative_to(default_layout()->sysconfdir, "foo.bar"); 00088 00089 */ 00090 static void relative_to(char *buf, size_t bufsz, const char *dir, const char *file); 00091 00092 /** 00093 Creates a Layout Object with the given prefix. If no 00094 prefix is given, the prefix defaults to the one specified 00095 at the compile time. 00096 00097 */ 00098 static void create(const char *prefix = 0); 00099 00100 /** 00101 Returns the Layout object created by create_default_layout(). 00102 00103 */ 00104 static Layout *get(); 00105 }; 00106 00107 #endif