1 | #ifndef LIBINTERFACE_H
|
---|
2 | #define LIBINTERFACE_H
|
---|
3 |
|
---|
4 | #include "browse.h"
|
---|
5 | #include "queryinfo.h"
|
---|
6 | #include "mgsearch.h"
|
---|
7 | #include "display.h"
|
---|
8 | #include "gdbmclass.h"
|
---|
9 |
|
---|
10 | #ifdef __GNUG__
|
---|
11 | # include <iostream.h>
|
---|
12 | # include <map>
|
---|
13 | #else
|
---|
14 | # ifndef USE_OBJECTSPACE
|
---|
15 | # include <iostream>
|
---|
16 | # else
|
---|
17 | # include <ospace\std\iostream>
|
---|
18 | # include <ospace\std\map>
|
---|
19 | # endif
|
---|
20 | #endif
|
---|
21 |
|
---|
22 | #include "cgiargs.h"
|
---|
23 |
|
---|
24 | // This is the precedence given to various parameters
|
---|
25 | // by the display class - note that at present language
|
---|
26 | // is excluded but will be required for multi-language
|
---|
27 | // collections
|
---|
28 | #define MACROPRECEDENCE "style,collection,queryversion,version"
|
---|
29 |
|
---|
30 |
|
---|
31 | // errors related to this module
|
---|
32 | #define LI_NOERROR 0
|
---|
33 | #define LI_LOADDATABASEFAILED 1
|
---|
34 |
|
---|
35 |
|
---|
36 |
|
---|
37 | class libinterface
|
---|
38 | {
|
---|
39 | public:
|
---|
40 | libinterface ();
|
---|
41 | virtual ~libinterface() {}
|
---|
42 |
|
---|
43 | // setgsdlhome will set the macros, gdbm, index, and text homes
|
---|
44 | void setgsdlhome (const text_t &thegsdlhome);
|
---|
45 |
|
---|
46 | void setmacroshome (const text_t &themacroshome);
|
---|
47 | void setgdbmhome (const text_t &thegdbmhome);
|
---|
48 | void setindexhome (const text_t &theindexhome);
|
---|
49 |
|
---|
50 | void sethttpprefix (const text_t &thehttpprefix);
|
---|
51 | void setgwcgi (const text_t &thegwcgi);
|
---|
52 |
|
---|
53 | // init should be called after the various homes are set,
|
---|
54 | // it returns 'false' on failure and 'true' on success
|
---|
55 | bool init ();
|
---|
56 |
|
---|
57 | // examine the cgi arguments and create the appropriate page,
|
---|
58 | // outputing the page to textout and any debug information to logout
|
---|
59 | //
|
---|
60 | // returns LI_NOERROR on success, LI_LOADDATABASEFAILED on failure
|
---|
61 | virtual int getpage (const text_t &argstr, ostream &textout, ostream &logout);
|
---|
62 |
|
---|
63 | // returns the compressed arguments for the last getpage
|
---|
64 | const text_t &getlastcomparg() {return lastcomparg;}
|
---|
65 |
|
---|
66 | protected:
|
---|
67 | text_t gsdlhome;
|
---|
68 | text_t macroshome;
|
---|
69 | text_t gdbmhome;
|
---|
70 | text_t indexhome;
|
---|
71 |
|
---|
72 | text_t books;
|
---|
73 | text_t hrefs;
|
---|
74 | text_t titles;
|
---|
75 | vector<text_t> bookarr;
|
---|
76 | vector<text_t> hrefarr;
|
---|
77 | vector<text_t> titlearr;
|
---|
78 | int numbooks;
|
---|
79 |
|
---|
80 | text_t default_index;
|
---|
81 |
|
---|
82 | text_t httpprefix;
|
---|
83 | text_t gwcgi;
|
---|
84 | text_t quotedstring;
|
---|
85 |
|
---|
86 | text_t lastcomparg;
|
---|
87 |
|
---|
88 | gdbmclass gdbm;
|
---|
89 | outconvertclass text_t2ascii;
|
---|
90 | displayclass disp;
|
---|
91 |
|
---|
92 |
|
---|
93 | browseclass *browse;
|
---|
94 | mgsearchclass search;
|
---|
95 |
|
---|
96 | virtual void get_arg_config (text_t &argconfigstr);
|
---|
97 | text_t::iterator get_next_config_arg (text_t::iterator first, text_t::iterator last,
|
---|
98 | text_t &argname, text_t &defaultvalue, bool &longarg);
|
---|
99 |
|
---|
100 | virtual text_t get_compressed_args (cgiargsclass &args);
|
---|
101 | virtual void expand_compressed_args (cgiargsclass &args);
|
---|
102 | virtual void add_default_args (cgiargsclass &args);
|
---|
103 | virtual void check_args (cgiargsclass &args);
|
---|
104 |
|
---|
105 | virtual void define_general_macros (cgiargsclass &args, ostream &logout);
|
---|
106 | virtual void prepare_page (cgiargsclass &args, ostream &logout);
|
---|
107 |
|
---|
108 |
|
---|
109 | virtual void set_query_params (cgiargsclass &args, queryparamclass &queryparams);
|
---|
110 | virtual void define_query_macros (cgiargsclass &args,
|
---|
111 | queryparamclass &queryparams,
|
---|
112 | queryresultsclass &queryresults,
|
---|
113 | ostream &logout);
|
---|
114 | virtual void docLinks (cgiargsclass &args, queryresultsclass &queryresults,
|
---|
115 | ostream &logout);
|
---|
116 |
|
---|
117 | virtual int query_action (cgiargsclass &args, ostream &textout, ostream &logout);
|
---|
118 | virtual void browse_action (cgiargsclass &args, ostream &textout, ostream &logout);
|
---|
119 | virtual void document_action (cgiargsclass &args, ostream &textout, ostream &logout);
|
---|
120 | virtual void page_action (cgiargsclass &args, ostream &textout, ostream &logout);
|
---|
121 |
|
---|
122 | virtual void displayresults (cgiargsclass &args, ostream &textout, ostream &logout,
|
---|
123 | queryresultsclass &queryresults);
|
---|
124 |
|
---|
125 | virtual void define_pref_macros (cgiargsclass &args, ostream &logout);
|
---|
126 | virtual int do_query(cgiargsclass &args, queryparamclass &queryparams,
|
---|
127 | queryresultsclass &queryresults, ostream &logout);
|
---|
128 | virtual void highlighttext(vector<text_t> &termvars, ostream &textout,
|
---|
129 | ostream &logout, text_t &text);
|
---|
130 | void libinterface::format_querystring (text_t &querystring);
|
---|
131 |
|
---|
132 |
|
---|
133 |
|
---|
134 | virtual void set_default_index(void) {}
|
---|
135 | virtual text_t get_collection_name(void) {return "";}
|
---|
136 | virtual void assemble_index (cgiargsclass &args, text_t &index) {}
|
---|
137 | virtual void define_collection_macros (cgiargsclass &args, ostream &logout) {}
|
---|
138 | virtual bool collection_init(const text_t &collection) {return true;}
|
---|
139 | virtual void displaydocsummary (cgiargsclass &args, ostream &textout,
|
---|
140 | ostream &logout, queryresultsclass &queryresults,
|
---|
141 | int resultnum) {}
|
---|
142 |
|
---|
143 |
|
---|
144 | };
|
---|
145 |
|
---|
146 | #endif
|
---|