View Issue Details

IDProjectCategoryView StatusLast Update
0002153unrealmodule apipublic2007-04-27 05:35
ReporterXuefer Assigned To 
PrioritynormalSeverityfeatureReproducibilityalways
Status closedResolutionno change required 
PlatformallOSallOS Version-
Product Version3.2.2 
Summary0002153: custom var for Client and Channel (maybe others)
Descriptionfor 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
TagsNo tags attached.
3rd party modules

Relationships

related to 0001978 closedsyzop Saving module data during a /rehash 

Activities

codemastr

2004-11-06 12:55

reporter   ~0008260

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.

Issue History

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 codemastr Note Added: 0008260
2007-04-27 05:35 stskeeps Status new => closed
2007-04-27 05:35 stskeeps Resolution open => no change required
2017-01-06 15:48 syzop Category module => module api