Using addon UMODE constants in third party modules.

These are old archives. They are kept for historic purposes only.

Moderators: Gottem, Supporters

Post Reply
KeMiJohN
Posts: 14
Joined: Tue Sep 13, 2005 6:15 pm

Using addon UMODE constants in third party modules.

Post by KeMiJohN »

Hi there :)

Back on the UnrealIRCd forums, after a decade in hiatus :P
(I made some posts in 2005)

I'm making a module, where I'm trying to parse the numeric UMODE values received by HOOKTYPE_UMODE_CHANGE to a string, like "+iw-s". (112 to 101)

I have no trouble using the built-in UMODE constants, like UMODE_INVISIBLE, UMODE_OPER, etc.

The problem occurs, when I want to use the UMODE constants added by modules in modules/usermodes/, like UMODE_PRIVACY, UMODE_SHOWWHOIS, etc.

I've siphoned the source for all the addon UMODE constants, and none of them, seem to be used anywhere outside the modules in which they are defined, so I'm thinking there may be a better way to do this, than having to hardcode all these constants and string values anyway.

Right now, I'm just trying to get a complete list of UMODE numeric values for debugging purposes.
These work fine:

Code: Select all

sendnotice(sptr, "i %d", UMODE_INVISIBLE);
sendnotice(sptr, "o %d", UMODE_OPER);
sendnotice(sptr, "w %d", UMODE_WALLOP);
sendnotice(sptr, "r %d", UMODE_REGNICK);
sendnotice(sptr, "s %d", UMODE_SERVNOTICE);
sendnotice(sptr, "x %d", UMODE_HIDE);
sendnotice(sptr, "z %d", UMODE_SECURE);
sendnotice(sptr, "d %d", UMODE_DEAF);
sendnotice(sptr, "H %d", UMODE_HIDEOPER);
sendnotice(sptr, "t %d", UMODE_SETHOST);
sendnotice(sptr, "I %d", UMODE_HIDLE);
Results:

Code: Select all

i 1
o 2
w 4
r 8
s 16
x 32
z 64
d 128
H 256
t 512
I 1024
These result in errors:

Code: Select all

sendnotice(sptr, "p %d", UMODE_PRIVACY);
sendnotice(sptr, "S %d", UMODE_SERVICEBOT);
sendnotice(sptr, "W %d", UMODE_SHOWWHOIS);
sendnotice(sptr, "T %d", UMODE_NOCTCP);
sendnotice(sptr, "G %d", UMODE_CENSOR);
sendnotice(sptr, "B %d", UMODE_BOT);
sendnotice(sptr, "R %d", UMODE_REGONLYMSG);
sendnotice(sptr, "q %d", UMODE_NOKICK);
Errors:

Code: Select all

testmodule.c: In function ‘user_mode’:
testmodule.c:351:28: error: ‘UMODE_PRIVACY’ undeclared (first use in this function)
   sendnotice(sptr, "p %d", UMODE_PRIVACY);
                            ^
testmodule.c:351:28: note: each undeclared identifier is reported only once for each function it appears in
testmodule.c:352:28: error: ‘UMODE_SERVICEBOT’ undeclared (first use in this function)
   sendnotice(sptr, "S %d", UMODE_SERVICEBOT);
                            ^
testmodule.c:353:28: error: ‘UMODE_SHOWWHOIS’ undeclared (first use in this function)
   sendnotice(sptr, "W %d", UMODE_SHOWWHOIS);
                            ^
testmodule.c:354:28: error: ‘UMODE_NOCTCP’ undeclared (first use in this function)
   sendnotice(sptr, "T %d", UMODE_NOCTCP);
                            ^
testmodule.c:355:28: error: ‘UMODE_CENSOR’ undeclared (first use in this function)
   sendnotice(sptr, "G %d", UMODE_CENSOR);
                            ^
testmodule.c:356:28: error: ‘UMODE_BOT’ undeclared (first use in this function)
   sendnotice(sptr, "B %d", UMODE_BOT);
                            ^
testmodule.c:357:28: error: ‘UMODE_REGONLYMSG’ undeclared (first use in this function)
   sendnotice(sptr, "R %d", UMODE_REGONLYMSG);
                            ^
testmodule.c:358:28: error: ‘UMODE_NOKICK’ undeclared (first use in this function)
   sendnotice(sptr, "q %d", UMODE_NOKICK);
                            ^
Any hints? :)

Best regards
-John
Gottem
UnrealIRCd coder
Posts: 192
Joined: Fri Aug 19, 2016 5:26 pm
Location: NL

Re: Using addon UMODE constants in third party modules.

Post by Gottem »

I went through the source and found this bit in src/s_user.c:

Code: Select all

char *get_modestr(long umodes)
I haven't screwed with UMODE hooks myself, but seems like this is what you need. =]
If you like my modules, pls consider donating (credit card or iDEAL, use the custom job fee option in my shop) ;];]
KeMiJohN
Posts: 14
Joined: Tue Sep 13, 2005 6:15 pm

Re: Using addon UMODE constants in third party modules.

Post by KeMiJohN »

Thank you very much! :)

The for loop iterating through Usermode_Table, was exactly what I was looking for.

Code: Select all

for (i = 0; i <= Usermode_highest; i++)
	Usermode_Table[i].flag
	Usermode_Table[i].mode
Gottem
UnrealIRCd coder
Posts: 192
Joined: Fri Aug 19, 2016 5:26 pm
Location: NL

Re: Using addon UMODE constants in third party modules.

Post by Gottem »

Cool, glad to be of help. =]
If you like my modules, pls consider donating (credit card or iDEAL, use the custom job fee option in my shop) ;];]
Post Reply