pathsearch.h

Go to the documentation of this file.
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 
00033 using std::string;
00034 
00035 
00036 class Y2PathSearch
00037 {
00038 
00039 public:
00040 
00044     static int numberOfComponentLevels ();
00045 
00051     enum WHAT { GENERIC, EXECCOMP, PLUGIN };
00052 
00057     static string searchPath (WHAT what, int level);
00058 
00063     static int currentComponentLevel ();
00064 
00070     static string findy2 (string filename, int mode = R_OK, int level = -1);
00071 
00082     static string findy2exe (string root, string compname, bool server,
00083                              bool non_y2, int level);
00084 
00089     static string findy2plugin (string name, int level);
00090 
00092     static string globsubst (const string& where,
00093                              const string& oldstr, const string& newstr);
00098     static string completeFilename (const string& fname);
00099 
00100 private:
00101 
00102     static int defaultComponentLevel ();
00103 
00104 };
00105 
00111 class YCPPathSearch : public Y2PathSearch
00112 {
00113 public:
00114     enum Kind
00115     {
00116         // would like to use all uppercase,
00117         // but the parser tokens are the allmighty #defines...
00118         Client,
00119         Include,
00120         Module,
00121         // all others: scrconf, menuentry, plugin, agent... ?
00122         num_Kind // last
00123     };
00124 
00128     static string find (Kind kind, const string& name);
00132     static string findInclude (const string& name);
00133 
00140     static string findModule (string name, bool the_source = false);
00141 
00147     static void addPath (Kind kind, const string& path);
00148 
00154     static void clearPaths (Kind kind);
00155 
00160     static void initialize ();
00161     
00163     static std::list<string>::const_iterator searchListBegin (Kind kind);
00165     static std::list<string>::const_iterator searchListEnd (Kind kind);
00166 
00174     static string bytecodeForFile (string file);
00175 
00176 private:
00177     static bool initialized;
00178     static std::list<string> searchList[num_Kind];
00179     static void initialize (Kind kind, const char *suffix);
00180 };

Generated on Fri Jun 16 18:07:45 2006 for yast2-core by  doxygen 1.4.6