The Boston Diaries

The ongoing saga of a programmer who doesn't live in Boston, nor does he even like Boston, but yet named his weblog/journal “The Boston Diaries.”

Go figure.

Thursday, April 29, 2004

Alive and well on Ganymede

It was a quiet week, and surprisingly, The Kids have been back nearly a week now and it's still quiet. Well, not as quiet as it was when they were off with their father driving through Florida, but still, after a year, the concept of “quiet” seems to have percolated down into their psyche and they are quieter now then they were this time last year.

Woot!

I've also been somewhat busy over the past two weeks. One task I've been working on is a “Getting Started Guide” for Seminole, Mark'a webserver. As Seminole is an embedable webserver, the guide is geared towards programmers who need to link Seminole into a larger project, and as writing assignments go, it is bloody difficult.

The problem I have is that I simply don't want to parrot in English what the demonstration code (which I'm also writing) is doing. I think I rewrote the CGI chapter two or three times and hating each revision, and I'm still not fully satisified with the results, but hey, that chapter is done (for the most part), and besides, what can one say about the following code?

bool DemoCgiHandler::Handle(HttpdRequest *p_req)
{
  assert(p_req != NULL);

  if (IsMe(p_req))
  {
    //-------------------------------------------------------
    // we only accept POST methods in this handler, which is
    // the most common method of handling HTML forms.
    //-------------------------------------------------------

    if (strcmp(p_req->Method(),HttpdUtilities::mPostRequest) != 0)
    {
      p_req->Respond(HTTPD_RESP_METHOD_NOT_ALLOWED);
      return(true);
    }

    //----------------------------------------------------------
    // This call collects the parameters into an array for us
    // to use.  If there is no Content-type passed in, or it's of
    // the wrong type, then HttpdCgiParameter::ParsePostData()
    // will return NULL.
    //----------------------------------------------------------

    HttpdCgiParameter *list = HttpdCgiParameter::ParsePostData(p_req);
    if (list == NULL)
    {
      p_req->Respond(HTTPD_RESP_SRV_ERROR);
      return(true);
    }

    //---------------------------------------------------------
    // We accept three parameters, "name", "title" and "age".
    // We don't do much with the data, other than print it out,
    // but this is the basics of getting CGI data from the client.
    //------------------------------------------------------------

    HttpdDynamicOutput output(p_req,false);
    p_req->Respond(HTTPD_RESP_OK);

    const char *name  = list->Find("name");
    const char *title = list->Find("title");
    const char *age   = list->Find("age");

    output.Header("Content-Type","text/plain");
    output.HeaderComplete();

    output.Body()->Printf(
                           "Name:  %s\r\n"
                           "Title: %s\r\n"
                           "Age:   %s\r\n",
                           name  ? name  : "none given",
                           title ? title : "none given",
                           age   ? age   : "none given"
                         );
    return(true);
  }

  return(false);
}

(I don't think Mark will be too upset for me posting the code here—this is, after all, just a demonstration of how to use Seminole and the code (at least to me) is fairly obvious in what it does).

If the CGI chapter was bad, the template system was even worse. The demo code for that was about the size of the CGI demo, and just as drop dead simple (well, as simple as C++ code can be).

I guess part of the problem is that I'm having a hard time placing myself into the mindset of an embedded programmer (which I'm not) who has to learn how to use Seminole (which I am, mostly by going through the source code to Seminole, and following the few examples written by Mark) and knows C++ (which I'm learning) but might not know how this web stuff works (which I know all too well). So yes, it's kind of hard to get into the right mindset to write this guide.

But I'm forging ahead anyway.

One thing I did learn this week is how to pipe highlighted text from joe (the editor I use) through an external program (and I've been using joe for how long now? I'm not going to bother answering that). What this means is that I can now embed code, highlight it, and run it through a filter to convert certain characters like “<” or “&” into “&lt;” and “&amp;” (which is required since the documentation is in XML) or to indent the block or even (much to Mark's delight) expand tabs to spaces (to Mark, tabs are eeeeeeeeeeeeeeeeeeeeeevil).

Another thing I learned this week—how to hard boil eggs. I've learned that fresh eggs are important to the success of hard boiled eggs.

Obligatory Picture

An abstract representation of where you're coming from]

Obligatory Contact Info

Obligatory Feeds

Obligatory Links

Obligatory Miscellaneous

Obligatory AI Disclaimer

No AI was used in the making of this site, unless otherwise noted.

You have my permission to link freely to any entry here. Go ahead, I won't bite. I promise.

The dates are the permanent links to that day's entries (or entry, if there is only one entry). The titles are the permanent links to that entry only. The format for the links are simple: Start with the base link for this site: https://boston.conman.org/, then add the date you are interested in, say 2000/08/01, so that would make the final URL:

https://boston.conman.org/2000/08/01

You can also specify the entire month by leaving off the day portion. You can even select an arbitrary portion of time.

You may also note subtle shading of the links and that's intentional: the “closer” the link is (relative to the page) the “brighter” it appears. It's an experiment in using color shading to denote the distance a link is from here. If you don't notice it, don't worry; it's not all that important.

It is assumed that every brand name, slogan, corporate name, symbol, design element, et cetera mentioned in these pages is a protected and/or trademarked entity, the sole property of its owner(s), and acknowledgement of this status is implied.

Copyright © 1999-2024 by Sean Conner. All Rights Reserved.