user.c: implementation

Previous: Folder browser ] [ Top:  ] [ Next: Traversing the user/group repositories to build a directory view ]

First off is our includes. Note that local wftk includes are in the parent directory; we're compiling browse.c out of the user module directory. The localdefs.h file contains definitions local to the current installation; under Unix that typically includes the location of the various repositories (of which we need two), but under Windows that is taken care of in the Registry. However, the ending for CGI programs is also included in localdefs.h.
 
#include 
#include 
#include 
#include "user.h"
#include "xmlcgi.h"
#include "../localdefs.h"

/* ------------------------------------------------------------------ */
/* browse.c                                                           */
/* A CGI program for folder-oriented, permission-based hierarchical   */
/* browsing.  This program is part of the wftk workflow toolkit and   */
/* is distributed under the terms of the GNU license.                 */
/* Copyright (c) 2000, Vivtek: wftk@vivtek.com                        */
/* ------------------------------------------------------------------ */
 
XML * cgi;
XML * environment;
XML * input;

XML * current_user;

XML * view;

See Traversing the user/group repositories to build a directory view
See Presenting a directory view in HTML

int main (int argc, char * argv[])
{
   XML * elem;

   cgi = cgi_init ();
   environment = xml_loc (cgi, "cgicall.environment");
   input = xml_loc (cgi, "cgicall.query");

   current_user = user_authenticate (environment, AUTH_DOMAIN);
   if (!current_user) {
      printf ("<html><head><title>User authentication required</title></head>\n");
      printf ("<body><h2>User authentication required </h2><hr>\n");
      printf ("A valid user authentication response is required to access this area.\n");
      printf ("</body></html>\n");
      xml_free (cgi);
      exit(0);
   }

   view = xml_create ("dirview");
   xml_set (view, "root", xml_attrval (input, "root"));
   xml_set (view, "curuser", xml_attrval (current_user, "name"));
   xml_set (view, "state", xml_attrval (input, "state"));

   dirview_create (view, current_user);

   printf ("Content-type: text/html\n\n");
   dirview_show (stdout, view);

   xml_free (cgi);
   xml_free (current_user);
   xml_free (view);
}
Previous: Folder browser ] [ Top:  ] [ Next: Traversing the user/group repositories to build a directory view ]


This code and documentation are released under the terms of the GNU license. They are copyright (c) 2000, Vivtek. All rights reserved except those explicitly granted under the terms of the GNU license.