View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0002153 | unreal | module api | public | 2004-11-02 03:16 | 2007-04-27 05:35 |
Reporter | Xuefer | Assigned To | |||
Priority | normal | Severity | feature | Reproducibility | always |
Status | closed | Resolution | no change required | ||
Platform | all | OS | all | OS Version | - |
Product Version | 3.2.2 | ||||
Summary | 0002153: custom var for Client and Channel (maybe others) | ||||
Description | for a module author, it's hard to keep info for each client or channel indeed, the module can manage a standalone hashtable itself. but how could we imageine if we have 2 to 10 modules, each have its own hashtable for over 1k Clients suggestion: in ircd ------------ typedef struct ModClass ModClass; typedef struct { ModClass *next; vFP ctor; // constructor, same as c++ vFP dtor; // destructor int size; // storage size, same as c++ sizeof(aClass) int offset; // offset in storage } ModClass; typedef int ModClassHandler; #define GetClientVarPtr(cptr, class) ( (void*) (((char*)cptr->modvars) + class.offset) ); ModClassHandler RegisterClientClass(Module *m, ModClass *mc) { ModClassHandler id=install(mc); mc->offset = client_storage_size; client_storage_size += mc->size; foreach client AS cptr { cptr->modvars = realloc(cptr->modvars, client_storage_size); mc->ctor(cptr, GetClientVarPtr(cptr, (*mc))); } return id; } in module ------------ int MyClientClassCtor(aClient *cptr, void *var) { *((int*)var) = 0; return 0; } ModClass ClientClass = {MyClientClassCtor, MyClientClassDtor, sizeof(int), 0}; MOD_INIT: ModClassHandler myClientClass; myClientClass = RegisterClientClass(MyMod, &ClientClass); MOD_UNLOAD UnRegisterClientClass(myClientClass); to get/set var for client: int *myint = (int*)GetClientVarPtr(cptr, ClientClass); int a = *myint; *myint = 1; same apply to Channel the names used above is not for suggestion, just give a example for my idea there maybe better and faster implement | ||||
Tags | No tags attached. | ||||
3rd party modules | |||||
|
As http://bugs.unrealircd.org/view.php?id=1978 mentions, the problem is, how do we save the data between rehashes? If you have a suggestion for that, I'd be glad to hear it. |
Date Modified | Username | Field | Change |
---|---|---|---|
2004-11-02 03:16 | Xuefer | New Issue | |
2004-11-02 08:32 | syzop | Relationship added | related to 0001978 |
2004-11-06 12:55 |
|
Note Added: 0008260 | |
2007-04-27 05:35 |
|
Status | new => closed |
2007-04-27 05:35 |
|
Resolution | open => no change required |
2017-01-06 15:48 | syzop | Category | module => module api |