home *** CD-ROM | disk | FTP | other *** search
- //
- // Copyright (c) 1996 Vermeer Technologies, Inc., a wholly owned
- // subsidiary of Microsoft Corp. All Rights Reserved
- //
- // File: wbtest2.cpp
- // DLL Custom WebBot Component Example
- //
-
- #include "stdio.h"
- #include "../webbot.h"
-
- // private utility to display a dictionary in HTML
-
- void DumpDict(
- CWebBotDict& dict,
- CWebBotString& ret)
- {
- const char* key;
-
- ret.Append("<UL>");
- while (key = dict.NextKey())
- {
- ret.Append("<LI><B>");
- ret.Append(key);
- ret.Append("</B> = ");
- long values = dict.NumValues(key);
- if (values > 1)
- {
- ret.Append("<UL>");
- for (short i = 0; i < values; i++)
- {
- char nbuf[12];
- sprintf(nbuf, "%d", i);
- ret.Append("<LI><B>[");
- ret.Append(nbuf);
- ret.Append("]</B> = ");
- ret.Append(dict.GetValueN(key, i));
- ret.Append("</LI>");
- }
- ret.Append("</UL>");
- }
- else
- ret.Append(dict.GetValue(key));
- ret.Append("</LI>");
- }
- ret.Append("</UL>");
- }
-
- ///////////////////
- // BOT: Hello2
-
- BeginWebBotExpand(Hello2,ret,bot,cgi,form)
- {
- ret.Append("\n<b>Hello World!</b>");
- }
- EndWebBotExpand
-
- ////////////////////
- // BOT: Form1
-
- BeginWebBotExpand(Form1,ret,bot,cgi,form)
- {
- ret.Append("\n<H3>Form Test 1 Input Dump</H3>");
-
- ret.Append("<H4>Bot Attributes</H4>");
- DumpDict(bot, ret);
-
- ret.Append("<H4>Form Data</H4>");
- DumpDict(form, ret);
-
- ret.Append("<H4>CGI Environment</H4>");
- DumpDict(cgi, ret);
- }
- EndWebBotExpand
-
- /////////////////////
- // BOT: Mime1
-
- BeginWebBotExpand(Mime1,ret,bot,cgi,form)
- {
- const char* value;
- if (value = bot.GetValue("S-Links"))
- {
- ret.Append("Links: ");
- ret.Append(value);
- ret.Append("\n");
- }
-
- if ((value = form.GetValue("Content-Type")) && *value)
- {
- ret.Append("Content-Type: ");
- ret.Append(value);
- ret.Append("\n\n");
- if (value = form.GetValue("Content"))
- ret.Append(value);
- }
- else if ((value = form.GetValue("Location")) && *value)
- {
- ret.Append("Location: ");
- ret.Append(value);
- ret.Append("\n\n");
- }
- else if ((value = form.GetValue("Redirect")) && *value)
- {
- ret.Append("Redirect: ");
- ret.Append(value);
- ret.Append("\n\n");
- }
- else
- ret.Append("\n<b>Hello from Mime Test 1!</b>\n");
- }
- EndWebBotExpand
-
-