added Info.plist
[TestXSLT.git] / libsablot / src / engine / uri.h
1 /* 
2  * The contents of this file are subject to the Mozilla Public
3  * License Version 1.1 (the "License"); you may not use this file
4  * except in compliance with the License. You may obtain a copy of
5  * the License at http://www.mozilla.org/MPL/
6  * 
7  * Software distributed under the License is distributed on an "AS
8  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
9  * implied. See the License for the specific language governing
10  * rights and limitations under the License.
11  * 
12  * The Original Code is the Sablotron XSLT Processor.
13  * 
14  * The Initial Developer of the Original Code is Ginger Alliance Ltd.
15  * Portions created by Ginger Alliance are Copyright (C) 2000-2002
16  * Ginger Alliance Ltd. All Rights Reserved.
17  * 
18  * Contributor(s):
19  * 
20  * Alternatively, the contents of this file may be used under the
21  * terms of the GNU General Public License Version 2 or later (the
22  * "GPL"), in which case the provisions of the GPL are applicable 
23  * instead of those above.  If you wish to allow use of your 
24  * version of this file only under the terms of the GPL and not to
25  * allow others to use your version of this file under the MPL,
26  * indicate your decision by deleting the provisions above and
27  * replace them with the notice and other provisions required by
28  * the GPL.  If you do not delete the provisions above, a recipient
29  * may use your version of this file under either the MPL or the
30  * GPL.
31  */
32
33 /*****************************************************************
34     uri.h
35     Sablotron XSLT processor project
36     
37 This module does the work related to retrieving data in answer to
38 a URI request.
39 *****************************************************************/
40
41 #ifndef UriHIncl
42 #define UriHIncl
43
44 // GP; clean
45
46 #include "base.h"
47 #include "shandler.h"
48 #include "datastr.h"
49
50 /*  URIScheme
51     possible URI schemes for a DataLine 
52         - file
53         - arg for access to named buffers
54         - other scheme to by handled by an extension (a SchemeHandler)
55 */
56 typedef enum
57 {
58     URI_FILE, URI_ARG, URI_EXTENSION, URI_NONE
59 } URIScheme;
60
61 /*****************************************************************
62 makeAbsoluteURI()
63
64   merges a (possibly relative) URI reference with a base URI.
65 ARGS
66   uri       the URI reference
67   base      the base URI
68 RETURNS
69   absolute  the result
70 *****************************************************************/
71
72
73 URIScheme makeAbsoluteURI(Sit S, const char* uri,
74                           const char* base, Str& absolute);
75 URIScheme uri2SchemePath(Sit S, const char *absolute, Str& scheme, Str& rest);
76
77
78 /*  DLAccessMode
79     possible access modes for a DataLine
80 */
81
82 typedef enum
83 {
84     DLMODE_NONE, DLMODE_READ, DLMODE_WRITE, DLMODE_CLOSED
85 } DLAccessMode;
86
87 /*****************************************************************  
88 DataLine
89     a class associated to any data source or destination at a given URI; 
90     - can be open for reading or for writing
91     - 'Processor' class has a list of open DataLines 
92         together with the associated trees (serving as a cache)
93 *****************************************************************/
94
95 class StrStrList;
96
97 class DataLine
98 {
99 public:
100     DataLine();
101     ~DataLine();
102     // opens the resource at _uri for reading/writing based on _mode:
103     eFlag open(Sit S, const char *_uri, DLAccessMode _mode, 
104                StrStrList* argList_, Bool ignoreErr = FALSE);
105     eFlag close(Sit S);
106     // sends data to the resource
107     eFlag save(Sit S, const char *data, int len);
108     int get(Sit S, char *where, int maxcount);
109     DynBlock* getOutBuffer();
110     Str fullUri;
111     DLAccessMode mode;
112     URIScheme scheme;
113     eFlag setURIAndClose(Sit S, const char *_uri);
114 private:
115     FILE *f;
116     char *buffer;
117     DynBlock *outBuf;
118     int bufCurr;
119     SchemeHandler *handler;
120     void *handlerUD;
121     int handle;
122     Bool 
123         fileIsStd,
124         utf16Encoded,
125         gotWholeDocument;
126     void report(Sit S, MsgType type, MsgCode code, const Str& arg1, const Str& arg2);   
127 };
128     
129 #endif