Merge branch 'master' of ssh://localhost:3333/p/cdesktopenv/code
[oweals/cde.git] / cde / programs / dtsearchpath / dtsp / SearchPath.h
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* $XConsortium: SearchPath.h /main/4 1996/03/27 14:39:41 barstow $ */
24 /*******************************************************************
25 **  (c) Copyright Hewlett-Packard Company, 1990, 1991, 1992, 1993.
26 **  All rights are reserved.  Copying or other reproduction of this
27 **  program except for archival purposes is prohibited without prior
28 **  written consent of Hewlett-Packard Company.
29 ********************************************************************
30 ****************************<+>*************************************/
31
32 #ifndef _SEARCHPATH_H_
33 #define _SEARCHPATH_H_
34
35 #include "Environ.h"
36 #include "cstring.h"
37 #if defined(linux)
38 #include <iostream>
39 #else
40 #include <iostream.h>
41 #endif
42 #include <stdio.h>
43
44 class SearchPath {
45  public:
46   SearchPath() {}
47   SearchPath (CDEEnvironment *, const char *, const char *);
48   virtual ~SearchPath();
49
50   virtual void ExportPath();
51   virtual void Print();
52   virtual void AddPredefinedPath();
53
54 #if defined(linux)
55   virtual void PrettyPrint (std::ostream &) const;
56
57   friend std::ostream & operator<< (std::ostream &, const SearchPath &);
58 #else
59   virtual void PrettyPrint (ostream &) const;
60
61   friend ostream & operator<< (ostream &, const SearchPath &);
62 #endif
63
64   const char *  GetEnvVar() const    { return environment_var; }
65   CString       GetSearchPath() const { return final_search_path; }
66
67  protected:
68   void  AssembleString (const CString &);
69   void  NormalizePath();
70   void  AddToPath (const CString &);
71   void  TraversePath();
72
73   virtual void    MakePath (const CString &) {}
74   virtual CString ConstructPath (const CString &, const CString *,
75                                  unsigned char useTT = 1);
76
77   int     ParseState() const   { return parse_state; }
78   CString Separator() const    { return separator; }
79
80   virtual int validSearchPath (const CString &) const;
81   virtual int useSystemPath();
82
83   void    setSeparator (const char * sep) { separator = sep; }
84
85   CString          search_path;
86   CString          norm_search_path;
87   CString          final_search_path;
88   CDEEnvironment * user;
89
90  private:
91   const char *     environment_var;
92   int              parse_state;
93   CString          save_host;
94   CString          separator;
95 };
96
97
98 class AppSearchPath : public SearchPath {
99  public:
100   AppSearchPath (CDEEnvironment *, 
101                  const char * = "DTAPP",
102                  const char * = ",");
103   virtual ~AppSearchPath() {}
104
105   void FixUp();
106
107  protected:
108   virtual void    MakePath (const CString &);
109
110  private:
111 };
112
113
114 class IconSearchPath : public SearchPath {
115  public:
116   IconSearchPath (CDEEnvironment *,
117                   const char * = "XMICON",
118                   const char * = ".pm",
119                   const char * = ".bm",
120                   const char * = ":");
121   virtual ~IconSearchPath() {}
122
123  protected:
124   virtual void    MakePath (const CString &);
125   virtual int     validSearchPath (const CString &) const;
126
127  private:
128   CString first;
129   CString second;
130 };
131
132
133 class DatabaseSearchPath : public SearchPath {
134  public:
135   DatabaseSearchPath (CDEEnvironment *,
136                       const char * = "DTDATABASE",
137                       const char * = ",");
138   virtual ~DatabaseSearchPath() {}
139
140  protected:
141   virtual void    MakePath (const CString &);
142   virtual CString ConstructPath (const CString &, const CString *,
143                                  unsigned char useTT = 0);
144
145  private:
146 };
147
148
149 class HelpSearchPath : public SearchPath {
150  public:
151   HelpSearchPath (CDEEnvironment *, 
152                   const char * = "DTHELP",
153                   const char * = ":");
154   virtual ~HelpSearchPath() {}
155
156  protected:
157   virtual void    MakePath (const CString &);
158   virtual int     validSearchPath (const CString &) const;
159
160  private:
161 };
162
163
164 class InfoLibSearchPath : public SearchPath {
165  public:
166   InfoLibSearchPath (CDEEnvironment *, 
167                   const char * = "DTINFOLIB",
168                   const char * = ":");
169   virtual ~InfoLibSearchPath() {}
170
171  protected:
172   virtual void    MakePath (const CString &);
173   virtual int     validSearchPath (const CString &) const;
174
175  private:
176 };
177
178
179 class ManSearchPath : public SearchPath {
180  public:
181   ManSearchPath (CDEEnvironment *, 
182                  const char * = "MANPATH",
183                  const char * = ":");
184   virtual ~ManSearchPath() {}
185
186   virtual void    ExportPath ();
187   virtual void    Print();
188
189 #if defined(linux)
190   friend std::ostream & operator<< (std::ostream &, const ManSearchPath &);
191 #else
192   friend ostream & operator<< (ostream &, const ManSearchPath &);
193 #endif
194
195  protected:
196   virtual void    MakePath (const CString &);
197 #if defined(__FreeBSD__)
198   virtual int     useSystemPath();
199 #endif
200
201  private:
202 };
203
204 #endif