|
yast2-core
|
00001 /*---------------------------------------------------------------------\ 00002 | | 00003 | __ __ ____ _____ ____ | 00004 | \ \ / /_ _/ ___|_ _|___ \ | 00005 | \ V / _` \___ \ | | __) | | 00006 | | | (_| |___) || | / __/ | 00007 | |_|\__,_|____/ |_| |_____| | 00008 | | 00009 | core system | 00010 | (C) SuSE GmbH | 00011 \----------------------------------------------------------------------/ 00012 00013 File: pathsearch.h 00014 00015 Authors: Mathias Kettner <kettner@suse.de> 00016 Arvin Schnell <arvin@suse.de> 00017 Martin Vidner <mvidner@suse.cz> 00018 Maintainer: Arvin Schnell <arvin@suse.de> 00019 00020 /-*/ 00021 // -*- c++ -*- 00022 00023 /* 00024 * Search for YaST2 files at different paths. 00025 */ 00026 00027 #include <stdio.h> 00028 #include <fcntl.h> 00029 00030 #include <string> 00031 #include <list> 00032 #include <vector> 00033 00034 using std::string; 00035 using std::vector; 00036 00037 00038 class Y2PathSearch 00039 { 00040 00041 public: 00042 00046 static int numberOfComponentLevels (); 00047 00053 enum WHAT { GENERIC, EXECCOMP, PLUGIN }; 00054 00059 static string searchPath (WHAT what, int level); 00060 00065 static int currentComponentLevel (); 00066 00072 static string findy2 (string filename, int mode = R_OK, int level = -1); 00073 00084 static string findy2exe (string root, string compname, bool server, 00085 bool non_y2, int level); 00086 00091 static string findy2plugin (string name, int level); 00092 00094 static string globsubst (const string& where, 00095 const string& oldstr, const string& newstr); 00100 static string completeFilename (const string& fname); 00101 00102 protected: 00103 static bool searchPrefixWarn; 00104 00105 static vector<string> getPaths(); 00106 00107 private: 00108 static int defaultComponentLevel (); 00109 00110 static vector<string> paths; 00111 static void initializePaths(); 00112 }; 00113 00119 class YCPPathSearch : public Y2PathSearch 00120 { 00121 public: 00122 enum Kind 00123 { 00124 // would like to use all uppercase, 00125 // but the parser tokens are the allmighty #defines... 00126 Client, 00127 Include, 00128 Module, 00129 // all others: scrconf, menuentry, plugin, agent... ? 00130 num_Kind // last 00131 }; 00132 00136 static string find (Kind kind, const string& name); 00140 static string findInclude (const string& name); 00141 00148 static string findModule (string name, bool the_source = false); 00149 00155 static void addPath (Kind kind, const string& path); 00156 00162 static void clearPaths (Kind kind); 00163 00168 static void initialize (); 00169 00171 static std::list<string>::const_iterator searchListBegin (Kind kind); 00173 static std::list<string>::const_iterator searchListEnd (Kind kind); 00174 00182 static string bytecodeForFile (string file); 00183 00184 private: 00185 static bool initialized; 00186 static std::list<string> searchList[num_Kind]; 00187 static void initialize (Kind kind, const char *suffix); 00188 };
1.7.3