00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
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
00125
00126 Client,
00127 Include,
00128 Module,
00129
00130 num_Kind
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 };