Added CGI frontend structure implementation
[cascardo/atompub.git] / frontend / cgi / cgi.c
index f77fe06..3c5d72a 100644 (file)
@@ -33,7 +33,15 @@ cgi_serve_request (AtomCtx *ctx)
     return;
   if (path == NULL)
     {
-      path = atom_config_get_str (ctx, "cgi", "index");
+      if ((path = atom_config_get_str (ctx, "cgi", "index")) == NULL)
+        {
+          /* We do not want to disclose our configuration is empty.
+           * The requester cannot distinguish an empty configuration
+           * from a non-existent index.
+           */
+          fprintf (stdout, "Status: 404 Not Found\n\n");
+          return;
+        }
     }
   if (!strcmp (method, "GET"))
     {
@@ -70,3 +78,12 @@ cgi_serve_request (AtomCtx *ctx)
       fprintf (stdout, "Status: 501 Not Implemented\n\n");
     }
 }
+
+AtomFrontend *
+cgi_frontend (void)
+{
+  AtomFrontend *frontend;
+  frontend = atom_frontend_new ();
+  atom_frontend_map_entries_set (frontend, atom_map_frontend_requests);
+  return frontend;
+}