ON_PARSE_COMMAND
ON_PARSE_COMMAND( FnName**,** mapClass**,** Args )
Parameters
FnName
The name of the member function. Also the name of the command.
mapClass
The class name to map the function to.
Args
The arguments that map to the parameter’s FnName. See Remarks for a list of symbols.
Remarks
The ON_PARSE_COMMAND macro is used in a parse map to define a command to a CHttpServer object from a client.
The member function identified by FnName must take a pointer to the CHttpServerContext as its first parameter. FnName is of the type LPSTR, and is identified by the symbol ITS_LPSTR in the parse map; that is, FnName points to a string containing the member function in class mapClass.
The parameter Args can take one of the following values:
Symbol | Type or Comment |
ITS_EMPTY | Args cannot be blank. Use ITS_EMPTY if you have no arguments. |
ITS_PSTR | A pointer to a string. |
ITS_RAW | The exact, raw data sent to the ISAPI extension. Do not use ITS_RAW with any other parameter type; to do so will cause an ASSERT. See Remarks for an example. |
ITS_I2 | a short |
ITS_I4 | a long |
ITS_R4 | a float |
ITS_R8 | a double |
Examples
// The following example Illustrates extracting
// a string and a short sent to the server:
BEGIN_PARSE_MAP(CDerivedClass, CHttpServer)
DEFAULT_PARSE_COMMAND(Myfunc, CDerivedClass)
ON_PARSE_COMMAND(Myfunc, CDerivedClass, ITS_PSTR
ITS_I2)
ON_PARSE_COMMAND_PARAMS("string integer=42")
ON_PARSE_COMMAND(Myfunc2, CDerivedClass, ITS_PSTR
ITS_I2 ITS_PSTR)
ON_PARSE_COMMAND_PARAMS("string integer
string2='Default value'")
END_PARSE_MAP(CDerivedClass)
Note Use single quotes if you incorporate spaces into the default values for optional ITS_PSTRs.
void Myfunc(CHttpServerContext* pCtxt, LPTSTR pszName, int nNumber);
void Myfunc2(CHttpServerContext* pCtxt, LPTSTR pszName, int nNumber, LPTSTR pszTitle);
// The following example Illustrates extracting
// raw data sent to the server:
BEGIN_PARSE_MAP(CDerivedClass, CHttpServer)
DEFAULT_PARSE_COMMAND(Myfunc, CDerivedClass)
ON_PARSE_COMMAND(Myfunc, CDerivedClass, ITS_RAW)
END_PARSE_MAP(CDerivedClass)
with the function prototype as follows:
void CDerivedClass::Myfunc(CHttpServerContext* pCtxt, void* pVoid, DWORD dwBytes);
In the second example above, the pVoid
pointer points to the data sent to your extension. The dwBytes
parameter has a count of bytes at pVoid
. If dwBytes
is zero, pVoid
may not point to anything.
Note The handlers for a parse map command must take a pointer to a CHttpServerContext as the first parameter, and the parameters must be declared in the same order in which they're defined in ON_PARSE_COMMAND.
See Also BEGIN_PARSE_MAP, END_PARSE_MAP, ON_PARSE_COMMAND_PARAMS, DEFAULT_PARSE_COMMAND, CHttpServer