list: Displaying the procdef directory

Previous: File layout ] [ Top: The procdef manager ] [ Next: starter: Displaying a process start form ]

The list is the first one I'm implementing. It simply takes a URL format and builds a set of <li> lines, one for each procdef in the directory. Note that at this moment there's no mechanism for folders, or viewing permissions, or really anything sophisticated at all.
 
sprintf (sbuf, "%s%s", PROCESS_DEFINITION_REPOSITORY, "index.xml");
file = fopen (sbuf, "r");
if (!file) {
   printf ("Unable to open directory file %s\n", sbuf);
   return (1);
}

directory = xml_read (file);
fclose (file);
if (!directory) {
   printf ("Corrupt directory file.\n");
   return (1);
}

if (argc > 2) {
   format = argv[2];
} else {
   format = "edit?item=%s";
}

item = xml_firstelem (directory);
while (item) {
   if (!strcmp (item->name, "item")) {
      mark = (char *) xml_attrval (item, "title");
      if (!*mark) mark = (char *) xml_attrval (item, "id");
      printf ("<li><strong><a href=\"");
      printf (format, xml_attrval (item, "id"));
      printf ("\">%s</a></strong><br>\n", mark);
      xml_writecontent (stdout, item);
      printf ("<br>\n");
   }
   item = xml_nextelem (item);
}
Previous: File layout ] [ Top: lpml alpha ] [ Next: starter: Displaying a process start form ]


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