1 /* Monolith server-parsed pages (.msp's).
2 * - by Richard W.M. Jones <rich@annexia.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the Free
16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 * $Id: msp.c,v 1.8 2003/02/22 15:34:24 rich Exp $
27 #include "ml_window.h"
30 /*----- The following standard boilerplate code must appear -----*/
32 /* Main entry point to the app. */
33 static void app_main (ml_session);
36 handle_request (rws_request rq)
38 return ml_entry_point (rq, app_main);
41 /*----- End of standard boilerplate code -----*/
44 app_main (ml_session session)
46 pool pool = ml_session_pool (session);
49 const char *conninfo, *rootdir, *filename, *canonical_path;
52 canonical_path = ml_session_canonical_path (session);
54 /* Create the top-level window. */
55 w = new_ml_window (session, pool);
57 /* Disable the window headers. We can assume that the .msp file will
58 * supply <html>...</html>.
60 ml_window_set_headers_flag (w, 0);
62 /* Nominate this window as the main window for this application. */
63 ml_session_set_main_window (session, w);
65 /* Get the document root. */
66 rootdir = ml_cfg_get_string (session, "msp root", 0);
69 fprintf (stderr, "%s: no \"msp root\" directive in conf file.\n",
74 /* Get the database connection name. */
75 conninfo = ml_cfg_get_string (session, "msp database", 0);
77 /* Get the filename. */
78 args = ml_session_args (session);
79 if (!args || (filename = cgi_param (args, "page")) == 0)
81 fprintf (stderr, "%s: missing page parameter.\n", canonical_path);
85 /* Create the msp widget. */
86 msp = new_ml_msp (pool, session, conninfo, rootdir, filename);
91 "%s: failed to create msp widget (bad filename "
92 "or msp file contains errors?)",
95 /* Send some extra debug to the log file. */
98 "%s: rootdir = %s, filename = %s\n",
99 msg, canonical_path, rootdir, filename);
101 /* Die with an error back to the browser. */
105 /* Pack the msp widget into the window. */
106 ml_window_pack (w, msp);