Go Back   FlashFXP Forums > >

Programming Need help with C/C++/Delphi? Ask here and make us all laugh.

Closed Thread
 
Thread Tools Rate Thread Display Modes
Old 10-02-2003, 09:22 PM   #1
darkone
Disabled
FlashFXP Registered User
ioFTPD Administrator
 
darkone's Avatar
 
Join Date: Dec 2001
Posts: 2,230
Default Module stuff

MessageVariableModule

Initializiation routine: BOOL MessageVariableInit(LPVARIABLE_MODULE)
DeInitialization routine: VOID MessageVariableDeInit(LPVARIABLE_MODULE)

Declaration for InstallMessageVariable procedure is available in
the source\include\Message.h.

szName: Name of variable
lpAllocProc: Procedure to call, when compiling variable. Returns pointer to variable.
lpFreeProc: Procedure to call, when can be freed (may be NULL)
dwRequiredData: B_ANY or combination B_USERFILE, ... (see Message.h for complete list)
dwType: For variables that do not take parameters: C_STRING_VARIABLE, C_FLOAT_VARIABLE, C_INTEGER_VARIABLE,
...: NULL terminated list of functions used for parameter parsing.


To clarify these, here are some examples from ioftpd source code:

$group
LPVOID MessageVariable_Group(LPMESSAGEDATA lpData)
{
return Gid2Group(GETOFFSET(lpData->DataOffsets, DATA_USERFILE)->Gid);
}

InstallMessageVariable("GROUP", MessageVariable_Group, NULL, B_USERFILE, C_STRING_VARIABLE, NULL);

*NOTE* GETOFFSET macro is defined in Message.h

$gid
LPVOID MessageVariable_Gid(LPMESSAGEDATA lpData)
{
return &GETOFFSET(lpData->DataOffsets, DATA_USERFILE)->Gid;
}

InstallMessageVariable("GID", MessageVariable_Gid, NULL, B_USERFILE, C_INTEGER_VARIABLE, NULL);


ip(ip #)
BOOL MessageObject_Ip(LPMESSAGEDATA lpData, INT Argc, LPOBJV Argv)
{
LPUSERFILE lpUserFile;
LPSTR szIpString;
INT i;

// Get userfile
lpUserFile = GETOFFSET(lpData->DataOffsets, DATA_USERFILE);
// Get entry #
if (! Argc ||
Object_Get_Int(lpData, &Argv[0], &i) ||
i < 1 || i > MAX_IPS)
{
i = 1;
}
// Get ip string
IszpString = lpUserFile->Ip[i - 1];
// Append result to output buffer
Put_Buffer_Format(lpData->lpOutBuffer, lpData->szFormat, szIpString);
return FALSE;
}



INT MessageObject_ConvertInteger(LPSTR szArg)
{
PCHAR pCheck;
INT Int;

Int = strtol(szArg, &pCheck, 10);
if (pCheck[0] == '\0' && pCheck != szArg) return Int;
return (ULONG)-1;
}


InstallMessageVariable("IP", MessageObject_Ip, NULL, B_USERFILE, C_STRING_VARIABLE|C_ARGS, MessageObject_ConvertInteger, NULL);

*Note* Use GetProc to find address of procedures such as Put_Buffer_Format, Object_Get_Int, etc..


EventModule

Initializatioun routine: BOO EventInit(LPEVENT_MODULE)
Deinitialization routine: VOID EventDeInit(LPEVENT_MODULE)

BOOL InstallEvent(LPSTR szName, LPVOID lpProc);

szName = Event name
lpProc = Procedure to call on event

BOOL MyEvent(LPEVENT_DATA lpEventData, LPIO_STRING Arguments);

Use ioftpd's string manipulation functions GetStringIndex, GetStringIndexStatic, GetStringRange to parse arguments.

You can either use InitDataOffsets to extract information about current user:

InitDataOffsets(&DataOffsets, lpEventData->lpData, lpEventData->dwData);

Or, use switch as:
switch (lpEventData->dwData)
{
case DT_FTPUSER;
lpFtpUser = (LPFTPUSER)lpEventData->lpData;
break;
case DT_HTTPUSER:
lpHttpUser = (LPHTTPUSER)lpEventData->lpData;
break;
case DT_TELNETUSER:
lpHttpUser = (LPTELNETUSER)lpEventData->lpData;
break;
case DT_USERFILE:
lpHttpUser = (LPUSERFILE)lpEventData->lpData;
break;
}


bleh.. it's all too complicated I should do some examples :/
darkone is offline  
Closed Thread

Tags
break;, int, null, procedure, return

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 11:00 PM.

Parts of this site powered by vBulletin Mods & Addons from DragonByte Technologies Ltd. (Details)