home *** CD-ROM | disk | FTP | other *** search
- /*
- * webbot.h: definitions for custom WebBots(tm) in FrontPage 2.0
- *
- * Copyright (c) 1996 Microsoft Corporation. All rights reserved.
- *
- * Note: This header requires an ANSI-C or a C++ compiler.
- */
-
- #ifndef WEBBOT_H
- #define WEBBOT_H
-
-
- struct WebBotDict;
- typedef struct WebBotDict WebBotDict;
- struct WebBotString;
- typedef struct WebBotString WebBotString;
-
-
- #ifdef WEBBOT_V11_COMPAT
- #define DictNumValues DictOldNumValues
- #define DictGetValue DictOldGetValue
- #define DictGetValueN DictOldGetValueN
- #define DictSetValue DictOldSetValue
- #define DictNextKey DictOldNextKey
- #else
- #define DictNumValues DictNewNumValues
- #define DictGetValue DictNewGetValue
- #define DictGetValueN DictNewGetValueN
- #define DictSetValue DictNewSetValue
- #define DictSetValueN DictNewSetValueN
- #define DictNextKey DictNewNextKey
- #define DictRemoveKey DictNewRemoveKey
- #endif
-
-
- struct WebBotFuncs
- {
- /* Old Dict methods */
- long (*DictOldNumValues)
- (WebBotDict* dict,
- const char* key);
- const char* (*DictOldGetValue)
- (WebBotDict* dict,
- const char* key);
- const char* (*DictOldGetValueN)
- (WebBotDict* dict,
- const char* key,
- short valueNum);
- void (*DictOldSetValue)
- (WebBotDict* dict,
- const char* key,
- const char* value);
- void (*DictReset) /* This one is current */
- (WebBotDict* dict);
- const char* (*DictOldNextKey)
- (WebBotDict* dict);
-
- /* String methods */
- void (*StringClear)
- (WebBotString* string);
- void (*StringAppendTo)
- (WebBotString* string, const char* stringToAppend);
- const char* (*StringGetContents)
- (WebBotString* string);
-
- /* New Dict methods */
- long (*DictNewNumValues)
- (WebBotDict* dict,
- const char* key);
- const char* (*DictNewGetValue)
- (WebBotDict* dict,
- const char* key);
- const char* (*DictNewGetValueN)
- (WebBotDict* dict,
- const char* key,
- short valueNum);
- void (*DictNewSetValue)
- (WebBotDict* dict,
- const char* key,
- const char* value);
- void (*DictNewSetValueN)
- (WebBotDict* dict,
- const char* key,
- const char* value,
- short valueNum);
- const char* (*DictNewNextKey)
- (WebBotDict* dict);
- void (*DictNewRemoveKey)
- (WebBotDict* dict,
- const char* key);
- };
-
- typedef struct WebBotFuncs WebBotFuncs;
-
-
- #ifdef WIN32
- #define WEBBOT_EXPORT _declspec(dllexport)
- #else
- #define WEBBOT_EXPORT /* nothing */
- #endif
-
- #if defined(_AFXDLL) || defined(_AFXEXT)
- #define WEBBOT_MANAGE_STATE AFX_MANAGE_STATE(AfxGetStaticModuleState());
- #else
- #define WEBBOT_MANAGE_STATE /* nothing */
- #endif
-
-
- #ifdef __cplusplus
-
- class CWebBotDict
- {
- public:
- CWebBotDict
- (WebBotDict* dict,
- const WebBotFuncs* funcs)
- {
- Funcs = funcs;
- Dict = dict;
- }
-
- long NumValues
- (const char* key) const
- {
- return ((*Funcs->DictNumValues)(Dict, key));
- }
-
- const char* GetValue
- (const char* key) const
- {
- return ((*Funcs->DictGetValue)(Dict, key));
- }
-
- const char* GetValueN
- (const char* key,
- short valueNum) const
- {
- return ((*Funcs->DictGetValueN)(Dict, key, valueNum));
- }
-
- void SetValue
- (const char *key,
- const char *value)
- {
- ((*Funcs->DictSetValue)(Dict, key, value));
- }
-
- #ifndef WEBBOT_V11_COMPAT
- void SetValueN
- (const char* key,
- const char* value,
- short valueNum)
- {
- (*Funcs->DictSetValueN)(Dict, key, value, valueNum);
- }
-
- void RemoveKey(const char* key)
- {
- (*Funcs->DictRemoveKey)(Dict, key);
- }
- #endif
-
- void Reset()
- {
- (*Funcs->DictReset)(Dict);
- }
-
- const char* NextKey()
- {
- return ((*Funcs->DictNextKey)(Dict));
- }
-
- private:
- const WebBotFuncs* Funcs;
- WebBotDict* Dict;
- };
-
-
- class CWebBotString
- {
- public:
- CWebBotString
- (WebBotString* string,
- const WebBotFuncs* funcs)
- {
- Funcs = funcs;
- String = string;
- }
-
- void Clear()
- {
- (*Funcs->StringClear)(String);
- }
-
- void Append
- (const char* stringToAppend)
- {
- (*Funcs->StringAppendTo)(String, stringToAppend);
- }
-
- const char* GetContents() const
- {
- return ((*Funcs->StringGetContents)(String));
- }
-
- private:
- const WebBotFuncs* Funcs;
- WebBotString* String;
- };
-
-
- //
- // Original Bot Interface function macro in 1.1 WebBot SDK
- //
- #define BeginWebBot(botname,ret,bot,cgi,form) \
- extern "C" { \
- void WEBBOT_EXPORT botname##_Expand( \
- WebBotString* retString, \
- WebBotDict* botAttributes, \
- WebBotDict* cgiEnvironment, \
- WebBotDict* formData, \
- const WebBotFuncs* funcs) \
- { \
- CWebBotString ret(retString, funcs); \
- CWebBotDict bot(botAttributes, funcs); \
- CWebBotDict cgi(cgiEnvironment, funcs); \
- CWebBotDict form(formData, funcs);
-
- #define EndWebBot }}
-
- //
- // WebBot Expand method macro
- //
- #define BeginWebBotExpand(botname,ret,bot,cgi,form) \
- extern "C" { \
- void WEBBOT_EXPORT botname##_Expand( \
- WebBotString* retString, \
- WebBotDict* botAttributes, \
- WebBotDict* cgiEnvironment, \
- WebBotDict* formData, \
- const WebBotFuncs* funcs) \
- { \
- CWebBotString ret(retString, funcs); \
- CWebBotDict bot(botAttributes, funcs); \
- CWebBotDict cgi(cgiEnvironment, funcs); \
- CWebBotDict form(formData, funcs);
-
- #define EndWebBotExpand }}
-
- //
- // WebBot Edit method macro
- //
- #define BeginWebBotEdit(botname,bot) \
- extern "C" { \
- int WEBBOT_EXPORT botname##_Edit( \
- WebBotDict* botAttributes, \
- const WebBotFuncs* funcs) \
- { \
- WEBBOT_MANAGE_STATE \
- CWebBotDict bot(botAttributes, funcs);
-
- #define EndWebBotEdit }}
-
-
- #endif /* __cplusplus */
-
-
- #endif /* WEBBOT_H */
-