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 09-08-2003, 08:57 PM   #1
Mouton
Posse Member
Ultimate Scripter
ioFTPD Administrator
 
Join Date: Dec 2002
Posts: 1,956
Default b5 shmem questions

ULONG ulClientIp;
how does one convert that to a string ?

A: struct in_addr temp; temp.s_addr = pOnlineData->OnlineData.ulClientIp; strcpy(ip, inet_ntoa(temp));

-----

using DC_GET_ONLINEDATA, i get a ONLINEDATA struct containing only the Uid. What's the easiest way to get the primary group of that user ? I see only opening userfile and checking there..?

A: DC_USERFILE_OPEN, pUserFile->Gid, DC_USERFILE_CLOSE

-----

How can I know what local offsets needs to be set and what local offsets will contain the resulting struct after a SendMessage for each of the DC_xxx messages ?
I tried divination, like for my DC_GET_ONLINEDATA, I used:

PDC_ONLINEDATA pOnlineData = (PDC_ONLINEDATA)lpMessage->lpContext;
lpMessage->dwIdentifier = DC_GET_ONLINEDATA;
pOnlineData->iOffset = 0;
pOnlineData->dwSharedMemorySize = 4096;

but how do i know how i need to fill the pOnlineData->dwSharedMemorySize ?? This number is a random choice of a multiple of 2!
and my guess that the pOnlineData returned is at lpContext is pretty obvious here, since it's the only thing it should return, but how about the other messages ..?

-----

dwReturn = SendMessage(hIoFTPD, WM_KILL, iPos, (LPARAM)hMemory);

this returns 1 :\ should return 0... how can i use that message ?

-----

how can i get all the users on the site using shmem ? atm, i open UserIdTable and fetch all users from there.

-----
Mouton is offline  
Old 09-09-2003, 09:05 AM   #2
darkone
Disabled
FlashFXP Registered User
ioFTPD Administrator
 
darkone's Avatar
 
Join Date: Dec 2001
Posts: 2,230
Default

1) Create temporary in_addr type structure;

InAddr.s_addr = ulClientIp;
strcpy(ip, inet_ntoa(InAddr));

2) Yes, open the userfile (one should create local cache, so you don't have to open same userfile more than once [it's possible, but uses more resources])

3) dwSharedMemorySize contains amount of memory your shared memory chunk contains (you must fill it yourself). If you have too little memory & paths don't fit, dwReturn value will be equal to amount of memory required to complete action successfully.

4) WM_KILL message is executed instantly by message handler thread (it's not dispatched to worker threads like datacopy messages are) - it returns 0 if client was killed, 1 on error
darkone is offline  
Old 09-09-2003, 09:55 AM   #3
Mouton
Posse Member
Ultimate Scripter
ioFTPD Administrator
 
Join Date: Dec 2002
Posts: 1,956
Default

Code:
// Initial setup for DC_GET_ONLINEDATA
lpMessage->dwIdentifier	= DC_GET_ONLINEDATA;
PDC_ONLINEDATA pOnlineData = (PDC_ONLINEDATA)lpMessage->lpContext;
pOnlineData->iOffset = iPos;
pOnlineData->dwSharedMemorySize = 4096;

char username[64]="Unknown",pwd[_MAX_PWD + 1];

// Send Message
dwReturn = SendMessage(hIoFTPD, WM_SHMEM, NULL, (LPARAM)hMemory);
if (!dwReturn) {
	// Wait until processed (5 secs)
	WaitForSingleObject(hEvent, 5000);

	if (nPos == 1024) {
		printf("Error on kill: %i.\n",iPos);fflush(stdout);
		return 1;
	}

	strcpy(pwd,pOnlineData->OnlineData.szVirtualPath);
	resolveUidToName(pOnlineData->OnlineData.Uid,username);

	dwReturn = SendMessage(hIoFTPD, WM_KILL, iPos, (LPARAM)hMemory);
	if (!dwReturn) {
		printf("%s was kicked from %s\n",username,pwd);
	} else {
		printf("Error on kill: couldn't kill #%i (%s).\n",iPos,username);fflush(stdout);
		return 1;
	}
}
I get: Error on kill: couldn't kill #0 (nomaster).
What's wrong ? How can i debug that ?
Mouton is offline  
Old 09-09-2003, 10:47 AM   #4
darkone
Disabled
FlashFXP Registered User
ioFTPD Administrator
 
darkone's Avatar
 
Join Date: Dec 2001
Posts: 2,230
Default

there was minor bug it seems
darkone is offline  
Closed Thread

Tags
local, messages, ponlinedata, return, struct

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 02:16 PM.

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