From 2e969a14c718bea9f2e2f2aa0d49398f9cee7c4d Mon Sep 17 00:00:00 2001 From: cmunk Date: Mon, 7 Aug 2000 17:39:33 +0000 Subject: [PATCH] Merge of 3.1-final (Mon Aug 7 18:39:12 BST 2000) --- .RELEASE.NOTES | 29 ++ .UPDATE | 6 + Changes | 74 ++++ Config | 48 ++- Setup | 37 ++ TODO | 7 + doc/commands.txt | 334 +++++++++++++++ doc/faq | 53 +-- include/common.h | 37 +- include/config.h | 4 +- include/h.h | 7 +- include/msg.h | 8 +- include/sock.h | 3 - include/struct.h | 10 +- ircd | 2 + makeconf | 12 +- networks/unrealircd.conf | 2 +- src/agent.c | 1 - src/aln.c | 280 +++++++----- src/badwords.c | 2 +- src/bsd.c | 1 - src/channel.c | 499 ++++++++++++++------- src/chkconf.c | 1 - src/cio_init.c | 33 +- src/cio_main.c | 833 +++++++++++++++++------------------ src/class.c | 5 +- src/cloak.c | 3 - src/crule.c | 1 - src/dbuf.c | 3 +- src/dynconf.c | 1 - src/fdmaxcounter.c | 10 +- src/hash.c | 5 +- src/help.c | 4 +- src/ircd.c | 37 +- src/list.c | 9 +- src/lusers.c | 1 - src/match.c | 1 - src/packet.c | 98 +++-- src/parse.c | 116 ++--- src/res.c | 1 - src/res_comp.c | Bin 7568 -> 31 bytes src/res_init.c | 1 - src/res_mkquery.c | Bin 5499 -> 34 bytes src/res_skipname.c | 1 - src/s_auth.c | 2 +- src/s_bsd.c | 162 +------ src/s_conf.c | 65 ++- src/s_debug.c | 6 +- src/s_err.c | 11 +- src/s_extra.c | 6 +- src/s_kline.c | 13 +- src/s_misc.c | 7 +- src/s_numeric.c | 4 +- src/s_serv.c | 633 +++++++++++++++------------ src/s_socks.c | 3 +- src/s_unreal.c | 9 +- src/s_user.c | 156 ++++--- src/scache.c | 33 +- src/send.c | 118 +++-- src/support.c | 9 +- src/userload.c | 4 +- src/version.c.SH | 2 + src/win32.c | 906 +-------------------------------------- src/zip.c | 2 +- update | 19 + 65 files changed, 2364 insertions(+), 2426 deletions(-) create mode 100644 .RELEASE.NOTES create mode 100644 .UPDATE create mode 100755 Setup create mode 100644 doc/commands.txt create mode 100755 update diff --git a/.RELEASE.NOTES b/.RELEASE.NOTES new file mode 100644 index 000000000..5f4669796 --- /dev/null +++ b/.RELEASE.NOTES @@ -0,0 +1,29 @@ + +Unreal3.1-Silverheart Release Notes +=================================== + +* It is most wise to have a Unreal3.1 (FINAL) -only network whenever possible. Do not + link this to 2.1.7 or alike (might have unexpected problems). Unreal3.0 + linking might at times cause channel desynchs because of 3.0 broken SJOIN + code. + +* It is ADVISABLE that you allocate numerics to each server on your network. + You simply in the M: line, just after the port, add :numeric, like: + + M:irc.fyremoon.net:*:Description:6667:20 + + Where 20 is the numeric. Numerics are 1-255, 0 means no numeric (bad), + and no server must have same numeric + +* We have introduced encrypted irc connections, and we will soon have a + client out for it (this is not SSL). Stay tuned in #UnrealIRCd for more + information + +* NOTE, in #UnrealIRCD we don't help with Services etc. + +* Documentation will show up on the website sooner or later, + http://unreal.tspre.org + +* Read Unreal.nfo for any sake. To update your IRCd, please run the ./update + script. This requires "wget" and "cvs" on the box to function + \ No newline at end of file diff --git a/.UPDATE b/.UPDATE new file mode 100644 index 000000000..b44da14a7 --- /dev/null +++ b/.UPDATE @@ -0,0 +1,6 @@ +* +* +* UnrealIRCd Upgrade Script +* + +*** Downloading upgrade script from unreal.tspre.org diff --git a/Changes b/Changes index f6236a408..c4aad1514 100644 --- a/Changes +++ b/Changes @@ -458,3 +458,77 @@ - Updated networks/networks.ndx (bad sts!) - Added networks/linuxsquare.network - Added networks/chatstation.network +[recall] +- Fixed the pesky hostname bug +- Fixed a NO_OPEROVERDIE bug reported by Taz +- Fixed a +L bug +- Fixed a typo in Config +- SJ3 fixes. Let's hope this works (f*cken hell..) +- Fixed a V:line bug +- Added /infoserv (you can stop bugging us now skold ;P) +- Removed ALN, and the ALN system. +- Added base64 encoding instead, for ALN v2 (NS) +- Removed a SJ3 debug msg +- Removed SVSMODE +l support, and fixed servicestamp and +d support +- Changed to ircu/hybrid6/unreal mix of numeric 005 +- Fixed a SJ3 Fake Direction loopbug (kills on nick collisions) +- SJ3 fixes, loop fix +- Added NS, new generation ALN. +- Added llthangel's whoisfix.patch, Makes sure +hv users show up as + %#channel instead of +#channel. Bug report by ^Fanta. +- Changed find_server_quick to work with masks too .. +- Removed UPING UDP socket. Only resfd opens a udp fd now +- Small memory cleanup +- NS introduction in sendto_serv_butone_token +- Fixed Q:lined nick NickServ from on Nickname Server message +- Fixed a problem in synch using acptr->name as info line +- Introduced NS in SQLINE.. +- Fixed a problem in SVS2MODE not displaying mode changes, and well known + why +- Recoded SVSNOOP, but the IRCd doesn't get it at all?? +- added llthangel to credits +- Changed channel.c so when you kick someone as halfop it doesn't show as an + OperKick (unless you kick an op) (reported by ^Fanta, patch by llthangel) +(rc2) +- Fixed SVS2MODE bug with illegal modes +- Fixed /notice @%+ bug, where it didnt work at all +- Fixed a small chmode +u bug +- Added sendto_chanops_butone because of codemastr's laziness +- Fixed a few +u bugs +- Fixed a +I bug (yes another one) +- Changed channel.c so that when an opped non +q/+a Oper kicks a user who + is +q/+a it invokes an OperKick (patch by llthangel) +- Fixed the +lL (+Ll) bug, will first be fixed 100% when all is 3.1 +- Possible fixed the lopts bug +- Fixed a egcs problem in Config, the strtok bug +- Fixed the 'ulimit core size failed' bug (now checks whether it should + set the core size to unlimited in ./Config +- Changed s_user.c so that Opers will see +s channels in /whois + (patch by llthangel) +- +u now lists +a and +q people, and sends JOINs/PARTs to +a and +q people +- Fixed a /mode (umode) typo where it said no such channel rather than no such nick, + reported by llthangel +- Disabled anything with time in /list options temporary, causes bugs +- Fixed a little /chghost bug +- Fixed a SJ3 bug with ban syncing to SJ2 servers +- Fixed some cloak bugs(???) +- Made it so you can /knock without a reason, and a few /knock cleanups +- Made it so if the server name specified in the M:line does not contain a "." + the ircd logs it to ircd.log and dies +- Updated ./ircd to also say to look at ircd.log +- Fixed a SQLINE synch bug +- Added command line option -F to prevent the ircd to fork out +- Fixed the f*cken TKL bug +- Fixed a netsplit bug +- Changed some find_server(name, NULL) to find_server_quick to speed up + lookup of servers +- Made find_server_quick a prototype, and made some work more quicker as + well +- Removed the : in :nick NICK newnick :timestamp +- Added script ./update to help update, uses pull technology (wget, cvs) +- Added script ./Setup which makes the user forced through Unreal.nfo, FAQ, + Config, and all the things we want them to read/do to compile the IRCd +- Updated PREFIX Client Protoctl +- Added ^MrMike^'s command list, this one will be updated +- Removed ID_CVS, hopefully fixing some bastard stuff +- Fixed a last minute SJOIN bug diff --git a/Config b/Config index 17c247f58..064ab3c10 100755 --- a/Config +++ b/Config @@ -33,6 +33,7 @@ STRINGH=undef STRINGSH=undef RUSAGEH=undef NOINDEX=undef +FORCECORE=define NSTRERROR=undef NSTRTOKEN=undef NSTRTOK=undef @@ -104,6 +105,13 @@ clear more .CHANGES.NEW echo $n "[Enter to begin]" read cc + clear + fi + if [ -r .RELEASE.NOTES ] ; then + more .RELEASE.NOTES + echo $n "[Enter to begin]" + read cc + clear fi if [ "$1" = "-n" ] ; then @@ -157,7 +165,7 @@ case "$OS" in CRYPT_OPER_PASSWORD="" CRYPT_LINK_PASSWORD="" CRYPT_ILINE_PASSWORD="" - CRYPT+XLINE_PASSWORD="" + CRYPT_XLINE_PASSWORD="" echo "You are using FreeBSD 4.0; You can use encrypted passwords now." ;; *FreeBSD*3*) @@ -737,6 +745,39 @@ __EOF__ TIMES=none fi fi +# +# Can we set the core size to unlimited +# + +echo $n "Can we set the core size to unlimited...$c" +cat > $TMP <<__EOF__ +#include +#include +#include +main() { + struct rlimit corelim; + corelim.rlim_cur = corelim.rlim_max = RLIM_INFINITY; + if (setrlimit(RLIMIT_CORE, &corelim)) + exit(1); + exit(0); +} +__EOF__ + +$COMP >/dev/null 2>&1 +if [ $? -ne 0 ] ; then + echo " no" + FORCECORE=undef +else + $EXEC + if [ $? -ne 1 ] ; then + echo " yes" + else + echo " no" + FORCECORE=undef + fi +fi +$RM -f $EXEC $TMP + # # what do we need that isn't here already ? # @@ -873,7 +914,7 @@ cat > $TMP <<__EOF__ #endif main() { - char *t = "1\0", *s; + char t[] = "a\0", *s; s = strtok(t, ","); if (!strcmp(t, s)) exit(0); @@ -1009,6 +1050,7 @@ cat > $SETUP <<__EOF__ #$STDDEFH STDDEFH #$SYSSYSLOGH SYSSYSLOGH #$NOINDEX NOINDEX +#$FORCECORE FORCE_CORE #$NSTRERROR NEED_STRERROR #$NSTRTOKEN NEED_STRTOKEN #$NSTRTOK NEED_STRTOK @@ -1194,7 +1236,7 @@ while [ -z "$FOO" ] ; do esac done -DOMAINNAME=`hostname -f` +DOMAINNAME=`hostname` FOO="" runonce="" while [ -z "$FOO" ] ; do diff --git a/Setup b/Setup new file mode 100755 index 000000000..461bf3b0f --- /dev/null +++ b/Setup @@ -0,0 +1,37 @@ +#!/bin/sh +clear +echo "Starting up UnrealIRCd Setup" +echo "" +echo "Press enter to proceed to setup..." +read cc +more -d Unreal.nfo +echo "Press enter to proceed to FAQ..." +read cc +more -d doc/faq +echo "Press enter to proceed to configuration..." +read cc +if [ "$1" != "-noconfig" ] ; then + ./Config +fi + +echo "Press enter to proceed to compiling..." +read cc +make +echo "Press enter to proceed to ircd.conf making..." +read cc +./makeconf +echo "Press enter to proceed to network configuration..." +read cc +clear +echo "Do you want to use one of these network files, or make your own?" +cd networks +ls *.network +echo "[Type "no" if you want to make your own]" +read cc +if [ "$cc" == "no" ] ; then + ./makenet +fi +echo "Press enter to proceed to dynamic ircd configuration..." +read cc +pico unrealircd.conf +echo "You should be able to run UnrealIRCd using ./ircd now". diff --git a/TODO b/TODO index 275e9cd50..b561d26d6 100644 --- a/TODO +++ b/TODO @@ -47,3 +47,10 @@ Assigned to DrBin: * #define for auto oflag +H * Port to MacOS 7-9, 68k architecture and PPC * Port to BeOS +* +N (no nickname changes chmode) +* Chmodes in /list possbility +* Make cached MOTDs more memory friendly (dynamic allocation) +* Fix up the flag and proto system +* Make a is_chan_op, is_chanprot, is_chanowner all-in-one function +* Split up Link (SLink) +* Add Dlink (DSLink) diff --git a/doc/commands.txt b/doc/commands.txt new file mode 100644 index 000000000..b4d68cfd6 --- /dev/null +++ b/doc/commands.txt @@ -0,0 +1,334 @@ +Written by ^MrMike^ (mike@sector001.org) for the UnrealIRCd +Modified by codemastr to include a few other commands +(note, this file will be updated in CVS asap) + +PRIVMSG + - Used to send a message to a person or a channel + Syntax: MSG ,,, + Example: PRIVMSG Stskeeps :Hello. Unreal is a very good ircd. + Example: PRIVMSG Stskeeps,codemastr,DrBin :Hello Unreal Coding Team + +NOTICE + - Mainly used for one-time communication or for the results of a command. + Syntax: NOTICE ,,, + Example: NOTICE codemastr :Hi. How are you? + Example: NOTICE codemastr,Stskeeps :Hi codemastr and Stskeeps. + +MODE + - Used to change the mode of a channel or a user. You can only change modes for channel you are an Operator or Half-Op on. Also, you can only changes user modes for yourself. + Syntax: MODE + Example: MODE #UnrealIRCD +tn + Example: MODE #UnrealIRCD +ootn codemastr Stskeeps + +NICK + - Changes your "online identity" on a server. All those in the channel you are in will be alerted of your nickname change. + Syntax: NICK + Example: NICK |codemastr| + +JOIN + - Used to enter one or more channels on an IRC server. All occupants of the channel will be notified of your arrival. + Syntax: JOIN ,, + Example: JOIN #UnrealIRCD + Example: JOIN #UnrealIRCD,#OperHelp + +PING + - Determines the amount of lag (time it takes for a response to reach a person and come back) between yourself and someone else. + Syntax: PING + Example: PING Stskeeps + +WHOIS + - Shows information about the user in question, such as their "name", channels they are currently in, their hostmask, etc. + Syntax: WHOIS + Example: WHOIS DrBin + +ISON + - Used to determine of a certain user or users are currently on the IRC server based upon their nickname. + Syntax: ISON + Example: ISON Stskeeps DrBin codemastr NickServ ChanServ OperServ MemoServ + +USER + - Used during registration to server (i.e. during inital connection sequence.) + +PART + - Used to part (or leave) a channel you currently occupy. All those in the channel will be notified of your departure. + Syntax: PART ,,, + Example: PART #UnrealIRCD + Example: PART #UnrealIRCD,#OperHelp + +QUIT + - Disconnects you from the IRC server. Those in the channels you occupy will be notified of your departure. If you do not specify a reason, your nickname becomes the reason. + Syntax: QUIT + Example: QUIT Leaving! + +USERHOST + - Returns the userhost of the user in question. Usually used by scripts or bots to retrieve userhost information. + Syntax: USERHOST + Example: USERHOST codemastr + +SVSNICK + - Can only be used by a U:Lined server (i.e. services). Changes the nickname of the user in question. + Syntax: SVSNICK : + Example: SVSNICK Stskeeps Techie :963086432 + +SVSMODE + - Can only be used by a U:Lined server (i.e. services). Changes the mode of the channel or user in question. + Syntax: SVSMODE : + Example: SVSMODE #UnrealIRCD :+o Stskeeps + Example: SVSMODE codemastr :+i + +LUSERS + - Provides local and global user information (such as current and maximum user count). + Syntax: LUSERS + +CHANSERV + - Will send a secure message to ChanServ. Similar to /msg ChanServ, but more secure. May not work if server is configured improperly. + +TOPIC + - Sets/Changes the topic of the channel in question, or just display the current topic. + Syntax: TOPIC + Syntax: TOPIC + Example: TOPIC #operhelp + Example: TOPIC #UnrealIRCD Welcome to the Unreal IRCD Home Channel. + +INVITE + - Sends a user an invitation to join a perticular channel. You must be an operator on the channel in order to invite a user into it. + Syntax: INVITE + Example: INVITE codemastr #OperHelp + +KICK + - Removes a user from a channel. Can only be used by Operators or Half-Ops. If no reason is specified, your nickname becomes the reason. + Syntax: KICK + +WALLOPS + - Sends a "message" to all those with the umode +w. Only IRCops can send wallops, while anyone can view them. + Syntax: WALLOPS + +KILL + - Forcefully disconnects a user from an IRC Sever. Can only be used by IRCops. + Syntax: KILL + Example: KILL Clone5 Cloning is not allowed + +AWAY + - Sets your online status to "away". + Syntax: AWAY (AWAY without a reason will unset you away) + Example: AWAY Walking the dog... + +SQUIT + - Disconnects an IRC Server from the network + Syntax: SQUIT + Example: SQUIT leaf.* + +WHO + - Searches user information (-i users only) for supplied information. IRCops are a ble to search +i users. + Syntax: WHO + Example: WHO *.aol.com + +WHOWAS + - Retrieves previous 'WHOIS' information for users no longer connected to the server. + Syntax: WHOWAS + Example: WHOWAS Stskeeps + +LIST + - Provides a complete listing of all channels on the network. If a search string is specified, it will only show those matching the search string. + Syntax: LIST + Example: LIST + Example: LIST *ircd* + +NAMES + - Provides a list of users on the specified channel. + Syntax: NAMES + Example: NAMES #help + +OPER + - Attempts to give a user IRCop status. + Syntax: OPER + Example: OPER codemastr codeit + +CONNECT + - Links another IRC server to the one you are currently on. Remote connections are also possible. + Syntax: CONNECT + Syntax: + Example: CONNECT leaf.* + Example: CONNECT hub.* 6667 leaf.* + +VERSION + - Provides version information of the IRCD software in usage. + Syntax: VERSION + +STATS + - Provides certain statistical information about the server (for example, u will provide uptime information). + Syntax: STATS + Example: STATS u + +LINKS + - Lists all of the servers currently linked to the network. + Syntax: LINKS + +ADMIN + - Provides administrative information regarding the server. + Syntax: ADMIN + +SAMODE + - Allowed a services administrator to change the mode on a channel, without having operator status. + Syntax: SAMODE + Example: SAMODE #UnrealIRCD +m + +SVSKILL + - Can only be used by a U:Lined server. Forcefully disconnects a user from the network. + Syntax: SVSKILL + Example: SVSKILL codemastr Goodbye + +SVSNOOP + - Can only be used by a U:Lined server. Enabled or disables whether Global IRCop functions exist on the server in question or not. + Syntax: SVSNOOP <+/-> + Example: SVSNOOP leaf.* - + +MOTD + - Displays the Message of the Day. + Syntax: MOTD + Syntax: MOTD + +KLINE + - "Bans" a hostmask from connection to the IRC server. + Syntax: KLINE + Example: KLINE *@*.aol.com Abuse + +UNKLINE + - Removes a k:line from the server. + Syntax: UNKLINE + Example: UNKLINE *@*.aol.com + +ZLINE + - Disables all access to the IRC server from a specified IP. + Syntax: ZLINE + Example: ZLINE 127.0.0.1 + +UNZLINE + - Removes a currently active z:Line. + Syntax: UNZLINE + Example: ZLINE 127.0.0.1 + +GLOBOPS + - Sends a global "message" to all IRCops. Only viewable by IRCops (unlike WallOps, which can be viewed by normal users). + Syntax: GLOBOPS + Example: GLOBOPS Going to be akilling those clones... + +CHATOPS + - GLOBOPS is usually reserved for important network information. Therefore, for Oper Chat, CHATOPS was invented. IRCops with the +c flag enabled will be able to send/receive CHATOPS messages. + Syntax: CHATOPS + Example: CHATOPS How's everyone doing today? + +LOCOPS + - Similar to GLOBOPS, except only received by those IRCops local to your server. + Syntax: LOCOPS + Example: LOCOPS Going to be adding a temp k:line for that user... + +REHASH + - Prompts the server to reread its configuration file (ircd.conf). Will also remove any temporarly lines (i.e. k:line). + Syntax: REHASH + +RESTART + - Kills and restarts the irc daemon, disconnecting all users currently on that server. + Syntax: RESTART + Syntax: RESTART + +DIE + - Kills the irc daemon, disconnecting all users currently on that server. + Syntax: DIE + Syntax: DIE + +RULES + - Reads the rules.conf file and sends the contents to the user. + Syntax: RULES + +MAP + - Provides a "network map" of the IRC network. Mainly used for routing purposes. + Syntax: MAP + +DALINFO + - Original DALnet ircd credits. + Syntax: DALINFO + +MKPASSWD + - Used for generating an encrypted password. Mainly used for encrypted O:Line passwords. + Syntax: MKPASSWD + Example: MKPASSWD codeit + +ADDLINE + - Adds a line to the server's ircd.conf file. After added, you must REHASH the server for it to take affect. + Syntax: ADDLINE + Example: ADDLINE C:127.0.0.1:server.dal.net:linking:7325:50 + +TECHAT + - Similar to CHATOPS, but only Technical Admins are able to send/receive messages on this "channel". + Syntax: TECHAT + Example: TECHAT What do you think of the new routing map? + +NACHAT + - Similar to CHATOPS (and TECHAT), but only Network Admins are able to send/recieve messages. + Syntax: NACHAT + Example: NACHAT Linking a new server in a couple minutes... + +KNOCK + - For channels which are invite only, you can "knock" on the channel to request an invite. + Syntax: KNOCK + Example: KNOCK #secret_chan I'm an op, let me in! + +CREDITS + - Credits for Unreal IRCD. + Syntax: CREDITS + +LICENSE + - GPL information. + Syntax: LICENSE + +SVSJOIN + - Forces a user to join a channel. Can only be used by a U:Lined server. + Syntax: SVSJOIN + Example: SVSJOIN codemastr #jail + +SAJOIN + - Forces a user to join a channel. Can only be used by a Services Admin. + Syntax: SAJOIN + Example: SAJOIN Stskeeps #OperHelp + +SVSPART + - Forces a user to leave a channel. Can only be used by a U:Lined server. + Syntax: SVSPART + Example: SVSPART codemastr #jail + +SAPART + - Forces a user to leave a channel. Can only be used by a Services Admin. + Syntax: SAPART + Example: SAPART Stskeeps #OperHelp + +SETHOST + - Changes the hostname of yourself. Only available to IRCops. + Syntax: SETHOST + Example: SETHOST coder.tspre.org + +SETIDENT + - Changes the ident of yourself. Only available to IRCops. + Syntax: SETIDENT + Example: SETIDENT coder + +SETNAME + - Changes the "IRC Name" (or "Real Name") of yourself. Available to everyone. + Syntax: SETNAME + Example: SETNAME Unreal Coding Team Member + +CHGHOST + - Changes the hostname of a user currently on the IRC network. Only available to IRCops. + Syntax: CHGHOST + Example: CHGHOST codemastr coder.tspre.org + +CHGIDENT + - Changes the ident of a user currently on the IRC network. Only available to IRCops. + Syntax: CHGIDENT + Example: CHGIDENT codemastr coder + +CHGNAME + - Changes the "IRC Name" (or "Real Name") of a user currently on the IRC network. Only available to IRCops. + Syntax: CHGNAME + Example: CHGNAME codemastr Unreal Coding Team Member + diff --git a/doc/faq b/doc/faq index 69c37fad3..b4681fb16 100644 --- a/doc/faq +++ b/doc/faq @@ -65,61 +65,12 @@ A: Mostly you can download the newest version at Versions may be spewed out regulary due to new features and bugs.. -8) Why does it say "unlimit core failed" or something when I boot the IRCd? -A: It's just a warning, mainly just ignore it. - -9) I use Linux Mandrake and ./Config always hangs! What can I do?? -A: Go edit the Config script and remove those lines: --SNIP START- -cat > $TMP <<__EOF__ -#$STRINGH STRINGH -#$STRINGSH STRINGSH -#ifdef STRINGH -#include -#endif -#ifdef STRINGSH -#include -#endif -main() -{ - char *t = "a", *s = strtok(t, ","); - if (!strcmp(t, s)) - exit(0); - exit(1); -} -__EOF__ -$COMP >/dev/null 2>&1 -if [ $? -ne 0 ] ; then - echo $n " strtok$c" - NSTRTOK=define -else - $EXEC - if [ $? -ne 0 ] ; then - echo $n " strtok$c" - NSTRTOK=define - fi -fi -$RM -f $EXEC $TMP ---- SNIP END--- -And replace it by -NSTRTOK=undef - -This should get it to work=) (thanks to Joe Whipple for reporting this bug) ----END---- - 10) Hosts show up as (null).network.net !! A: This is because you have forgotten to include the network file. The correct form is (in unrealircd.conf) Include ..........: - If this doesn't work .. seek me at irc.global-irc.net #unrealircd - -11) The IRCd uses like 66.7% CPU !!!? -A: Try run it with nice : - /usr/bin/nice -n 19 src/ircd - - if services go this way too just place ./ instead of src/ircd - Any more support seek me at the default place:P + If this doesn't work .. seek me at irc.ircsystems.net #unrealircd 12) My IRCd which runs on a FreeBSD says something about FDs and Max: 0 What shall I do?? @@ -190,4 +141,4 @@ match.c:247: argument 'n' doesn't match prototype Then go into include/setup.h and add this line: #define GOT_STRCASECMP -(C) Carsten Munk 1999 \ No newline at end of file +(C) Carsten Munk 1999-2000 \ No newline at end of file diff --git a/include/common.h b/include/common.h index b280049bc..903dbc8d9 100644 --- a/include/common.h +++ b/include/common.h @@ -47,11 +47,9 @@ #endif #ifdef DEVELOP_CVS -#define ID_CVS(x) static char id_cvs[] = x #define ID_Copyright(x) static char id_copyright[] = x #define ID_Notes(x) static char id_notes[] = x #else -#define ID_CVS(x) #define ID_Copyright(x) #define ID_Notes(x) #endif @@ -208,8 +206,39 @@ extern struct SLink *find_user_link( /* struct SLink *, struct Client * */ ); #define ZIPSTUFF "" #endif -#define PROTOCTL_CLIENT "TOKEN WATCH=128 SAFELIST HCN PREFIX=@+%" -#define PROTOCTL_SERVER "NOQUIT TOKEN NICKv2 SJOIN SJOIN2 UMODE2 ALN VL SJ3" ZIPSTUFF +/* IRCu/Hybrid/Unreal way now :) -Stskeeps */ + +#define PROTOCTL_CLIENT \ + ":%s 005 %s" \ + " MAP" \ + " KNOCK" \ + " SAFELIST" \ + " HCN" \ + " WATCH=%i" \ + " SILENCE=%i" \ + " MODES=%i" \ + " MAXCHANNELS=%i" \ + " MAXBANS=%i" \ + " NICKLEN=%i" \ + " TOPICLEN=%i" \ + " KICKLEN=%i" \ + " CHANTYPES=%s" \ + " PREFIX=%s" \ + " :are supported by this server" + +#define PROTOCTL_PARAMETERS MAXWATCH, \ + MAXSILES, \ + MAXMODEPARAMS, \ + MAXCHANNELSPERUSER, \ + MAXBANS, \ + NICKLEN, \ + TOPICLEN, \ + TOPICLEN, \ + "#", \ + "(ohv)@%+" + +/* Server-Server PROTOCTL -Stskeeps */ +#define PROTOCTL_SERVER "NOQUIT TOKEN NICKv2 SJOIN SJOIN2 UMODE2 VL SJ3 NS" ZIPSTUFF #ifdef _WIN32 /* diff --git a/include/config.h b/include/config.h index e08e374b3..f684a12cc 100644 --- a/include/config.h +++ b/include/config.h @@ -197,11 +197,12 @@ /* #undef DEBUGMODE /* define DEBUGMODE to enable debugging mode.*/ +/* We not check whether this is ok at compile time -- codemastr */ /* * defining FORCE_CORE will automatically "unlimit core", forcing the * server to dump a core file whenever it has a fatal error. -mlv */ -#define FORCE_CORE +/* #define FORCE_CORE */ /* * Full pathnames and defaults of irc system's support files. Please note that @@ -399,6 +400,7 @@ #define OperServ "OperServ" #define HelpServ "HelpServ" #define StatServ "StatServ" +#define InfoServ "InfoServ" /* * How many seconds in between simultaneous nick changes? diff --git a/include/h.h b/include/h.h index 2aa206ff1..a43182644 100644 --- a/include/h.h +++ b/include/h.h @@ -81,6 +81,11 @@ extern int R_do_socks, R_good_socks, R_no_socks; #endif extern aChannel *find_channel PROTO((char *, aChannel *)); extern void remove_user_from_channel PROTO((aClient *, aChannel *)); +extern char *base64enc PROTO((unsigned long)); +extern unsigned long base64dec PROTO((char *)); +extern void add_server_to_table PROTO((aClient *)); +extern void remove_server_from_tabel PROTO((aClient *)); + /* for services */ extern void del_invite PROTO((aClient *, aChannel *)); extern int del_silence PROTO((aClient *, char *)); @@ -101,7 +106,7 @@ extern aClient *find_nickserv PROTO((char *, aClient *)); extern aClient *find_person PROTO((char *, aClient *)); extern aClient *find_server PROTO((char *, aClient *)); extern aClient *find_service PROTO((char *, aClient *)); - +extern aClient *find_server_quick PROTO((char *)); extern char *find_or_add PROTO((char *)); extern int attach_conf PROTO((aClient *, aConfItem *)); extern aConfItem *attach_confs PROTO((aClient *, char *, int)); diff --git a/include/msg.h b/include/msg.h index 8f517c5f2..d10049f47 100644 --- a/include/msg.h +++ b/include/msg.h @@ -314,9 +314,11 @@ #define TOK_CRYPTO "BM" #endif #define MSG_NEWJOIN "NEWJOIN" /* For CR Java Chat */ - #define MSG_POST "POST" #define TOK_POST "BN" +#define MSG_INFOSERV "INFOSERV" +#define MSG_IS "IS" +#define TOK_INFOSERV "BO" #define MAXPARA 15 extern int m_private(), m_topic(), m_join(), m_part(), m_mode(), m_svsmode(); @@ -332,7 +334,7 @@ extern int m_motd(), m_who(), m_whois(), m_user(), m_list(); extern int m_server(), m_info(), m_links(), m_summon(), m_stats(); extern int m_users(), m_version(), m_help(); extern int m_nickserv(), m_operserv(), m_chanserv(), m_memoserv(), -m_helpserv(), m_services(), m_identify(); +m_infoserv(), m_helpserv(), m_services(), m_identify(); extern int m_statserv(); extern int m_squit(), m_away(), m_connect(); extern int m_oper(), m_pass(), m_trace(); @@ -413,6 +415,8 @@ struct Message msgtab[] = { {MSG_CS, m_chanserv, 0, 1, 1, TOK_CHANSERV, 0L}, {MSG_NICKSERV, m_nickserv, 0, 1, 1, TOK_NICKSERV, 0L}, {MSG_NS, m_nickserv, 0, 1, 1, TOK_NICKSERV, 0L}, + {MSG_INFOSERV, m_infoserv, 0, 1, 1, TOK_INFOSERV, 0L}, + {MSG_IS, m_infoserv, 0, 1, 1, TOK_INFOSERV, 0L}, {MSG_OPERSERV, m_operserv, 0, 1, 1, TOK_OPERSERV, 0L}, {MSG_OS, m_operserv, 0, 1, 1, TOK_OPERSERV, 0L}, {MSG_MEMOSERV, m_memoserv, 0, 1, 1, TOK_MEMOSERV, 0L}, diff --git a/include/sock.h b/include/sock.h index 090025c16..e09c8f8ed 100644 --- a/include/sock.h +++ b/include/sock.h @@ -23,9 +23,6 @@ * $Id$ * * $Log$ - * Revision 1.1.1.1.6.2 2000/07/16 20:37:04 stskeeps - * Unreal3.1-beta3 to Unreal3.1 - * * Revision 1.1.1.1.6.1.2.1 2000/07/14 20:22:57 stskeeps * +- Indentation and more SJ3 fixes * diff --git a/include/struct.h b/include/struct.h index 69ee0b5eb..9288c6d65 100644 --- a/include/struct.h +++ b/include/struct.h @@ -140,6 +140,7 @@ typedef unsigned int u_int32_t; /* XXX Hope this works! */ #define BOOT_TTY 16 #define BOOT_OPER 32 #define BOOT_AUTODIE 64 +#define BOOT_NOFORK 128 #define STAT_LOG -6 /* logfile for -x */ #define STAT_CONNECTING -4 @@ -267,7 +268,7 @@ typedef unsigned int u_int32_t; /* XXX Hope this works! */ #define PROTO_NICKv2 0x8 /* Negotiated NICKv2 protocol */ #define PROTO_SJOIN2 0x10 /* Negotiated SJOIN2 protocol */ #define PROTO_UMODE2 0x20 /* Negotiated UMODE2 protocol */ -#define PROTO_ALN 0x40 /* Negotiated ALN protocol */ +#define PROTO_NS 0x40 /* Negotiated NS protocol */ #define PROTO_ZIP 0x80 /* Negotiated ZIP protocol */ #define PROTO_VL 0x100 /* Negotiated VL protocol */ #define PROTO_SJ3 0x200 /* Negotiated SJ3 protocol */ @@ -405,7 +406,7 @@ typedef unsigned int u_int32_t; /* XXX Hope this works! */ #define SupportNICKv2(x) ((x)->proto & PROTO_NICKv2) #define SupportSJOIN2(x) ((x)->proto & PROTO_SJOIN2) #define SupportUMODE2(x) ((x)->proto & PROTO_UMODE2) -#define SupportALN(x) ((x)->proto & PROTO_ALN) +#define SupportNS(x) ((x)->proto & PROTO_NS) #define SupportVL(x) ((x)->proto & PROTO_VL) #define SupportSJ3(x) ((x)->proto & PROTO_SJ3) #define SupportVHP(x) ((x)->proto & PROTO_VHP) @@ -416,7 +417,7 @@ typedef unsigned int u_int32_t; /* XXX Hope this works! */ #define SetNICKv2(x) ((x)->proto |= PROTO_NICKv2) #define SetSJOIN2(x) ((x)->proto |= PROTO_SJOIN2) #define SetUMODE2(x) ((x)->proto |= PROTO_UMODE2) -#define SetALN(x) ((x)->proto |= PROTO_ALN) +#define SetNS(x) ((x)->proto |= PROTO_NS) #define SetVL(x) ((x)->proto |= PROTO_VL) #define SetSJ3(x) ((x)->proto |= PROTO_SJ3) #define SetVHP(x) ((x)->proto |= PROTO_VHP) @@ -705,6 +706,7 @@ struct Server { char by[NICKLEN + 1]; aConfItem *nline; /* N-line pointer for this server */ time_t timestamp; /* Remotely determined connect try time */ + unsigned short numeric; /* NS numeric, 0 if none */ #ifdef LIST_DEBUG aClient *bcptr; #endif @@ -926,7 +928,7 @@ struct SMode { /* x:y */ int msgs; /* x */ int per; /* y */ - int kmode; /* mode 0 = kick 1 = ban */ + unsigned short kmode; /* mode 0 = kick 1 = ban */ }; /* Message table structure */ diff --git a/ircd b/ircd index 251a9de60..bae31f9b7 100755 --- a/ircd +++ b/ircd @@ -24,6 +24,8 @@ echo "| (3) DPATH or SPATH's are incorrect. Run |" echo "| ./Config to correct that. |" echo "| (4) Someone else is running an ircd on the |" echo "| default port you chose in ircd.conf. |" +echo "| |" +echo "| see ircd.log for more information |" echo "|********************************************|" echo "| If you can't get Unreal IRCd to work - go |" echo "| to /server irc.flirt.org and join |" diff --git a/makeconf b/makeconf index d8e73176b..d86efa208 100755 --- a/makeconf +++ b/makeconf @@ -13,6 +13,7 @@ ADMADDR="admin@no.where.com" OPERNAME="admin" OPERADDR="*@*" OPERPASS="password" +NUMERIC="" PORT="6667" OPRT="default" LINKPASS="linkpass" @@ -173,6 +174,15 @@ if [ ! -z "$cc" ]; then PORT="$cc" fi +echo " " +echo "What server numeric does the server have (range = 1..256)" +echo "Must NOT be the same as other servers you link with" +echo $n " [] -> $c" +read cc +if [ ! -z "$cc" ]; then + NUMERIC="$cc" +fi + echo " " echo "What is your real name? (ie: John Doe)" echo $n " [$ADMIN] -> $c" @@ -311,7 +321,7 @@ cat > $CONF << __EOF__ ######################## ############ Server Info ############ -M:$SERVNAME:$VIRTUAL:$COMMENT:$PORT +M:$SERVNAME:$VIRTUAL:$COMMENT:$PORT:$NUMERIC ##################################### ############ Administrator Information ############# diff --git a/networks/unrealircd.conf b/networks/unrealircd.conf index 1a3f0023c..089edad7e 100644 --- a/networks/unrealircd.conf +++ b/networks/unrealircd.conf @@ -122,7 +122,7 @@ Set OPER_AUTO_JOIN_CHANS : 0 Set HOST_TIMEOUT ........: 2 # -# This allows you to specify the anount of retries +# This allows you to specify the amount of retries # that should be send when no DNS response is received # Set HOST_RETRIES ........: 2 diff --git a/src/agent.c b/src/agent.c index 184d7caf8..2f9ab0cb0 100644 --- a/src/agent.c +++ b/src/agent.c @@ -41,5 +41,4 @@ #include #include "h.h" -ID_CVS("$Id$"); ID_Copyright("(C) Carsten Munk 1999"); diff --git a/src/aln.c b/src/aln.c index 14ebb4e3d..a0086028f 100644 --- a/src/aln.c +++ b/src/aln.c @@ -1,6 +1,7 @@ /************************************************************************ * Unreal Internet Relay Chat Daemo, src/aln.c * (C) 2000 Carsten Munk (Techie/Stskeeps) + * Copyright (C) 2000 Lucas Madar [bahamut team] * * See file AUTHORS in IRC package for additional names of * the programmers. @@ -45,115 +46,198 @@ #ifndef STANDALONE #include "h.h" -ID_CVS("$Id$"); ID_Copyright("(C) Carsten Munk 2000"); #endif -static char *aln_chars[] = { - /* 0-9 */ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", - /* 10-19 */ "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", - /* 20-29 */ "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", - /* 30-35 */ "U", "V", "W", "X", "Y", "Z", - /* 36-45 */ "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", - /* 46-55 */ "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", - /* 56-61 */ "u", "v", "w", "x", "y", "z", - /* 62-71 */ "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7", "A8", "A9", - /* 73-82 */ "AA", "AB", "AC", "AD", "AE", "AF", "AG", "AH", "AI", "AJ", - /* 83-92 */ "AK", "AL", "AM", "AN", "AO", "AP", "AQ", "AR", "AS", "AT", - /* 93-98 */ "AU", "AV", "AW", "AX", "AY", "AZ", - /* 99-108 */ "Aa", "Ab", "Ac", "Ad", "Ae", "Af", "Ag", "Ah", "Ai", "Aj", - /* 109-118 */ "Ak", "Al", "Am", "An", "Ao", "Ap", "Aq", "Ar", "As", - "At", - /* 119-124 */ "Au", "Av", "Aw", "Ax", "Ay", "Az", - /* 125-134 */ "B0", "B1", "B2", "B3", "B4", "B5", "B6", "B7", "B8", - "B9", - /* 135-144 */ "BA", "BB", "BC", "BD", "BE", "BF", "BG", "BH", "BI", - "BJ", - /* 145-154 */ "BK", "BL", "BM", "BN", "BO", "BP", "BQ", "BR", "BS", - "BT", - /* 155-160 */ "BU", "BV", "BW", "BX", "BY", "BZ", - /* 161-170 */ "Ba", "Bb", "Bc", "Bd", "Be", "Bf", "Bg", "Bh", "Bi", - "Bj", - /* 171-180 */ "Bk", "Bl", "Bm", "Bn", "Bo", "Bp", "Bq", "Br", "Bs", - "Bt", - /* 181-186 */ "Bu", "Bv", "Bw", "Bx", "By", "Bz", - /* 187-196 */ "C0", "C1", "C2", "C3", "C4", "C5", "C6", "C7", "C8", - "C9", - /* 196-205 */ "CA", "CB", "CC", "CD", "CE", "CF", "CG", "CH", "CI", - "CJ", - /* 206-215 */ "CK", "CL", "CM", "CN", "CO", "CP", "CQ", "CR", "CS", - "CT", - /* 216-227 */ "CU", "CV", "CW", "CX", "CY", "CZ", - /* 228-237 */ "Ca", "Cb", "Cc", "Cd", "Ce", "Cf", "Cg", "Ch", "Ci", - "Cj", - /* 238-247 */ "Ck", "Cl", "Cm", "Cn", "Co", "Cp", "Cq", "Cr", "Cs", - "Ct", - /* 248-253 */ "Cu", "Cv", "Cw", "Cx", "Cy", "Cz", - /* 254-257 */ "D0", "D1", "D2", "D3", "D4", "D5", "D6", - /* */ "D7", "D8", "D9", "DA", "DB", "DC", "DD", - /* EOT */ NULL +static inline char *int_to_base64(unsigned long); +static inline unsigned long base64_to_int(char *); + + +static Link *servers = NULL; + +char *base64enc(unsigned long i) +{ + return int_to_base64(i); +} + +unsigned long base64dec(char *b64) +{ + return base64_to_int(b64); +} + +int numeric_collides(unsigned long numeric) +{ + Link *lp; + + if (!numeric) + return 0; + + for (lp = servers; lp; lp = lp->next) + if (numeric == lp->value.cptr->serv->numeric) + return 1; + return 0; +} + +void add_server_to_table(aClient *what) +{ + Link *ptr; + + if (IsServer(what) || IsMe(what)) + { + ptr = make_link(); + ptr->value.cptr = what; + ptr->flags = what->serv->numeric; + ptr->flood = NULL; + ptr->next = servers; + servers = ptr; + } +} + +void remove_server_from_table(aClient *what) +{ + Link **curr; + Link *tmp; + Link *lp = servers; + + for (; lp && (lp->value.cptr == what); lp = lp->next); + for (;;) + { + for (curr = &servers; (tmp = *curr); curr = &tmp->next) + if (tmp->value.cptr == what) + { + *curr = tmp->next; + free_link(tmp); + break; + } + if (lp) + break; + } +} + +aClient *find_server_by_numeric(unsigned long value) +{ + Link *lp; + + for (lp = servers; lp; lp = lp->next) + if (lp->value.cptr->serv->numeric == value) + return (lp->value.cptr); + return NULL; +} + +aClient *find_server_by_base64(char *b64) +{ + return find_server_by_numeric(base64dec(b64)); +} + +char *find_server_id(aClient *which) +{ + return (base64enc(which->serv->numeric)); +} + +aClient *find_server_quick(char *name) +{ + Link *lp; + + for (lp = servers; lp; lp = lp->next) + if (!match(name, lp->value.cptr->name)) + return (lp->value.cptr); + return NULL; +} + +aClient *find_server_b64_or_real(char *name) +{ + Link *lp; + + if (strlen(name) < 4) + { + for (lp = servers; lp; lp = lp->next) + if (!strcmp(base64enc(lp->value.cptr->serv->numeric), name)) + return (lp->value.cptr); + } + else + { + return find_server_quick(name); + } + return NULL; + +} + +/* ':' and '#' and '&' and '+' and '@' must never be in this table. */ +/* these tables must NEVER CHANGE! >) */ +char int6_to_base64_map[] = { + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', + 'E', 'F', + 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', + 'U', 'V', + 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', + 'k', 'l', + 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', + '{', '}' }; -int a_row = 62; -int b_row = 124; -int c_row = 186; -int d_row = 248; +char base64_to_int6_map[] = { + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, + -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1, + -1, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, + 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, -1, 63, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 +}; -char *convert2aln(int i) +static inline char *int_to_base64(unsigned long val) { - return (aln_chars[i]); + /* 32/6 == max 6 bytes for representation, + * +1 for the null, +1 for byte boundaries + */ + static char base64buf[8]; + unsigned long i = 7; + + base64buf[i] = '\0'; + + do + { + base64buf[--i] = int6_to_base64_map[val & 63]; + } + while (val >>= 6); + + return base64buf + i; } -int convertfromaln(char *s) +static inline unsigned long base64_to_int(char *b64) { - int i; - if (strlen(s) == 1) - { - for (i = 0; i < a_row; i++) - if (!strcmp(s, aln_chars[i])) - return (i); - /* no matches? we return 0 */ - return 0; - } - else - { - switch (*s) - { - case 'A': - i = a_row; - break; - case 'B': - i = b_row; - break; - case 'C': - i = c_row; - break; - case 'D': - i = d_row; - break; - default: - i = 0; - } - for (; i < 257; i++) - if (!strcmp(s, aln_chars[i])) - return (i); + unsigned int v = base64_to_int6_map[(u_char)*b64++]; - /* no matches? we return 0 */ - return 0; + while (*b64) + { + v <<= 6; + v += base64_to_int6_map[(u_char)*b64++]; + } + + return v; +} + + +void ns_stats(aClient *cptr) +{ + Link *lp; + aClient *sptr; + for (lp = servers; lp; lp = lp->next) + { + sptr = lp->value.cptr; + sendto_one(cptr, + ":%s NOTICE %s :*** server=%s numeric=%i b64=%s", me.name, + cptr->name, sptr->name, sptr->serv->numeric, + find_server_id(sptr)); } } -#ifdef STANDALONE -main() -{ - int i; - - for (i = 0; i <= 100; i++) - printf("(%i = %s)\n", i, aln_chars[i]); - - printf("62 = %s\n", convert2aln(62)); - printf("256 = %s\n", convert2aln(256)); - printf("C0 = %i\n", convertfromaln("C0")); - printf("D = %i\n", convertfromaln("D")); -} -#endif diff --git a/src/badwords.c b/src/badwords.c index 6414878df..0168e75bb 100644 --- a/src/badwords.c +++ b/src/badwords.c @@ -34,7 +34,7 @@ static int message_wordlist; * in both private and public messages */ -void badwords_stats(aClient *sptr) +void badwords_stats(aClient *sptr) { } diff --git a/src/bsd.c b/src/bsd.c index 4af7778cc..9f6646729 100644 --- a/src/bsd.c +++ b/src/bsd.c @@ -24,7 +24,6 @@ #include "h.h" #include -ID_CVS("$Id$"); ID_Copyright ("(C) 1988 University of Oulu, Computing Center and Jarkko Oikarinen"); diff --git a/src/channel.c b/src/channel.c index e164144bf..51f37591c 100644 --- a/src/channel.c +++ b/src/channel.c @@ -1,4 +1,5 @@ -/************************************************************************ + +/* * Unreal Internet Relay Chat Daemon, src/channel.c * Copyright (C) 1990 Jarkko Oikarinen and * University of Oulu, Co Center @@ -46,7 +47,6 @@ #include "hash.h" /* For CHANNELHASHSIZE */ #include "h.h" -ID_CVS("$Id$"); ID_Copyright ("(C) 1990 University of Oulu, Computing Center and Jarkko Oikarinen"); @@ -1425,27 +1425,6 @@ void make_mode_str(chptr, oldm, oldl, pcount, pvar, mode_buf, parabuf, bounce) } *x = '\0'; - /* reconstruct bkov chain */ - for (cnt = 0; cnt < pcount; cnt++) - { - if ((*(pvar[cnt]) == '+') && what != MODE_ADD) - { - *x++ = bounce ? '-' : '+'; - what = MODE_ADD; - } - if ((*(pvar[cnt]) == '-') && what != MODE_DEL) - { - *x++ = bounce ? '+' : '-'; - what = MODE_DEL; - } - *x++ = *(pvar[cnt] + 1); - tmpstr = &pvar[cnt][2]; - strncat(parabuf, tmpstr, MODEBUFLEN - 1); - parabuf[MODEBUFLEN - 1] = '\0'; - z = strlen(parabuf); - parabuf[z] = ' '; /* add a space */ - parabuf[z + 1] = '\0'; - } /* user limit */ if (chptr->mode.limit != oldl) { @@ -1474,6 +1453,27 @@ void make_mode_str(chptr, oldm, oldl, pcount, pvar, mode_buf, parabuf, bounce) ircsprintf(parabuf, "%s%d", parabuf, chptr->mode.limit); } } + /* reconstruct bkov chain */ + for (cnt = 0; cnt < pcount; cnt++) + { + if ((*(pvar[cnt]) == '+') && what != MODE_ADD) + { + *x++ = bounce ? '-' : '+'; + what = MODE_ADD; + } + if ((*(pvar[cnt]) == '-') && what != MODE_DEL) + { + *x++ = bounce ? '+' : '-'; + what = MODE_DEL; + } + *x++ = *(pvar[cnt] + 1); + tmpstr = &pvar[cnt][2]; + strncat(parabuf, tmpstr, MODEBUFLEN - 1); + parabuf[MODEBUFLEN - 1] = '\0'; + z = strlen(parabuf); + parabuf[z] = ' '; /* add a space */ + parabuf[z + 1] = '\0'; + } if (bounce) chptr->mode.mode = oldm; z = strlen(parabuf); @@ -1902,6 +1902,14 @@ int do_mode_char(chptr, modetype, modechar, param, what, cptr, pcount, pvar, chptr->chname); break; } + if (strchr(param, ',')) + { + if (MyClient(cptr)) + sendto_one(cptr, + ":%s NOTICE %s :*** You may only specify 1 channel to link to", + me.name, cptr->name); + break; + } if (!IsChannelName(param)) { if (MyClient(cptr)) @@ -2727,9 +2735,8 @@ int channel_link(cptr, sptr, parc, parv) if (MyClient(sptr)) sendto_one(sptr, ":%s!%s@%s JOIN :%s", sptr->name, sptr->user->username, - (IsHidden(sptr) ? sptr-> - user->virthost : sptr->user->realhost), - name); + (IsHidden(sptr) ? sptr->user-> + virthost : sptr->user->realhost), name); sendto_umode(UMODE_NETADMIN | UMODE_TECHADMIN, "*** Invisible(+I) user %s joined %s", sptr->name, chptr->chname); @@ -2949,19 +2956,15 @@ int m_join(cptr, sptr, parc, parv) /* ** notify all other users on the new channel */ - if (!(IsHiding(sptr))) - sendto_channel_butserv(chptr, sptr, - ":%s JOIN :%s", parv[0], chptr->chname); - else + if (IsHiding(sptr)) { if (MyClient(sptr)) + { sendto_one(sptr, ":%s!%s@%s JOIN :%s", sptr->name, sptr->user->username, - (IsHidden(sptr) ? sptr-> - user->virthost : sptr->user->realhost), + (IsHidden(sptr) ? sptr->user-> + virthost : sptr->user->realhost), chptr->chname); - if (MyClient(sptr)) - { sendto_umode(UMODE_ADMIN, "*** [+I] %s invisible joined %s", sptr->name, chptr->chname); @@ -2971,6 +2974,22 @@ int m_join(cptr, sptr, parc, parv) sptr->name, chptr->chname); } } + else if (chptr->mode.mode & MODE_AUDITORIUM) { + if (MyClient(sptr)) + sendto_one(sptr, ":%s!%s@%s JOIN :%s", + sptr->name, sptr->user->username, + (IsHidden(sptr) ? sptr->user-> + virthost : sptr->user->realhost), + chptr->chname); + sendto_chanops_butone(NULL, chptr, ":%s!%s@%s JOIN :%s", + sptr->name, sptr->user->username, + (IsHidden(sptr) ? sptr->user-> + virthost : sptr->user->realhost), + chptr->chname); + } + else + sendto_channel_butserv(chptr, sptr, + ":%s JOIN :%s", parv[0], chptr->chname); sendto_serv_butone_token(cptr, parv[0], MSG_JOIN, TOK_JOIN, "%s", chptr->chname); @@ -3076,22 +3095,8 @@ int m_part(cptr, sptr, parc, parv) if (1) { - if (!IsHiding(sptr)) - { - if (parc < 3) - { - sendto_channel_butserv(chptr, - sptr, PartFmt, parv[0], - chptr->chname); - } - else - { - sendto_channel_butserv(chptr, - sptr, PartFmt2, parv[0], - chptr->chname, comment); - } - } - else + + if (IsHiding(sptr)) { if (MyClient(sptr)) { @@ -3124,6 +3129,61 @@ int m_part(cptr, sptr, parc, parv) sptr->user->realhost), chptr->chname, comment); } + else if (chptr->mode.mode & MODE_AUDITORIUM) { + if (MyClient(sptr)) { + if (parc < 3) { + sendto_chanops_butone(NULL, chptr, + ":%s!%s@%s PART %s", + sptr->name, + sptr->user->username, + (IsHidden(sptr) ? + sptr->user->virthost : + sptr->user->realhost), + chptr->chname); + if (!is_chan_op(sptr, chptr)) + sendto_one(sptr, ":%s!%s@%s PART %s", + sptr->name, + sptr->user->username, + (IsHidden(sptr) ? + sptr->user->virthost : + sptr->user->realhost), + chptr->chname); + } + else { + sendto_chanops_butone(NULL, chptr, + ":%s!%s@%s PART %s %s", + sptr->name, + sptr->user->username, + (IsHidden(sptr) ? + sptr->user->virthost : + sptr->user->realhost), + chptr->chname, comment); + if (!is_chan_op(cptr, chptr)) + sendto_one(sptr, ":%s!%s@%s PART %s %s", + sptr->name, + sptr->user->username, + (IsHidden(sptr) ? + sptr->user->virthost : + sptr->user->realhost), + chptr->chname, comment); + } + } + } + else { + + if (MyClient(sptr)) { + + if (parc < 3) + + sendto_channel_butserv(chptr, + sptr, PartFmt, parv[0], + chptr->chname); + else + sendto_channel_butserv(chptr, + sptr, PartFmt2, parv[0], + chptr->chname, comment); + } + } remove_user_from_channel(sptr, chptr); } } @@ -3220,7 +3280,8 @@ int m_kick(cptr, sptr, parc, parv) } if (IsOper(sptr)) - if (!is_chan_op(sptr, chptr)) + if (!is_chan_op(sptr, chptr) && !is_halfop(sptr, chptr) + || (is_halfop(sptr, chptr) && is_chan_op(who, chptr))) { sendto_umode(UMODE_EYES, "*** OperKick [%s @ %s -> %s (%s)]", @@ -3232,7 +3293,16 @@ int m_kick(cptr, sptr, parc, parv) if (is_chanprot(who, chptr) || is_chanowner(who, chptr) || IsServices(who)) - if (!IsULine(cptr, sptr) && who != sptr) + if IsOper(sptr) + { /* IRCop kicking owner/prot */ + sendto_umode(UMODE_EYES, + "*** OperKick [%s @ %s -> %s (%s)]", + sptr->name, + chptr->chname, + who->name, comment); + goto attack; + } + else if (!IsULine(cptr, sptr) && who != sptr) { sendto_one(sptr, ":%s NOTICE %s :*** You cannot kick %s from %s because %s is channel protected", @@ -3439,7 +3509,7 @@ int m_topic(cptr, sptr, parc, parv) && (chptr->mode.mode & MODE_TOPICLIMIT)) { #ifdef NO_OPEROVERRIDE - continue; + return 0; #endif sendto_umode(UMODE_EYES, "*** OperTopic [IRCop: %s] - [Channel: %s] - [Topic: %s]", @@ -3634,18 +3704,17 @@ void send_list(aClient *cptr, int numsend) && !IsMember(cptr, chptr) && !IsAnOper(cptr)) continue; - if ((!lopt->showall) - && ((chptr->users < lopt->usermin) - || ((lopt->usermax >= 0) + + if ((!lopt->showall) + && ((chptr->users < lopt->usermin) || ((lopt->usermax >= 0) && (chptr->users > lopt->usermax)) - || ((chptr->creationtime - || 1) <= lopt->chantimemin) - || (chptr->topic_time < + || ((chptr->creationtime) <= lopt->chantimemin) + /* || (chptr->topic_time < lopt->topictimemin) || (chptr->creationtime >= lopt->chantimemax) || (chptr->topic_time > - lopt->topictimemax))) + lopt->topictimemax) */)) continue; if (lopt->nolist && @@ -3762,8 +3831,8 @@ int check_for_chan_flood(cptr, sptr, chptr) if (chptr->mode.kmode == 1) { /* ban. */ ircsprintf(mask, "*!*@%s", - (IsHidden(sptr) ? sptr->user-> - virthost : sptr->user->realhost)); + (IsHidden(sptr) ? sptr->user->virthost : sptr-> + user->realhost)); add_banid(&me, chptr, mask); sendto_serv_butone(&me, ":%s MODE %s +b %s 0", me.name, chptr->chname, mask); @@ -4093,11 +4162,13 @@ int m_names(cptr, sptr, parc, parv) acptr = cm->value.cptr; if (IsInvisible(acptr) && !member) continue; - if (IsHiding(acptr)) + if (IsHiding(acptr) && acptr != sptr) continue; if (chptr->mode.mode & MODE_AUDITORIUM) - if (!is_chan_op(sptr, chptr)) - if (!(cm->flags & CHFL_CHANOP)) + if (!is_chan_op(sptr, chptr) && !is_chanprot(sptr, chptr) && + !is_chanowner(sptr, chptr)) + if (!(cm->flags & (CHFL_CHANOP | CHFL_CHANPROT | CHFL_CHANOWNER)) + && acptr != sptr) continue; if (cm->flags & CHFL_CHANOP) @@ -4196,7 +4267,7 @@ int m_knock(cptr, sptr, parc, parv) { aChannel *chptr; - if (parc < 3 || *parv[1] == '\0') + if (parc < 2 || *parv[1] == '\0') { sendto_one(sptr, err_str(ERR_NEEDMOREPARAMS), me.name, parv[0], "KNOCK"); @@ -4209,7 +4280,7 @@ int m_knock(cptr, sptr, parc, parv) if (check_channelmask(sptr, cptr, parv[1])) return 0; /* bugfix for /knock PRv Please? */ - if (*parv[1] != '#' && *parv[1] != '&') + if (*parv[1] != '#') { sendto_one(sptr, err_str(ERR_CANNOTKNOCK), me.name, @@ -4241,10 +4312,7 @@ int m_knock(cptr, sptr, parc, parv) return 0; } - if (chptr->mode.mode & MODE_INVITEONLY) - { - } - else + if (!(chptr->mode.mode & MODE_INVITEONLY)) { sendto_one(sptr, err_str(ERR_CANNOTKNOCK), me.name, @@ -4274,9 +4342,9 @@ int m_knock(cptr, sptr, parc, parv) me.name, chptr->chname, sptr->name, sptr->user->username, (IsHidden(sptr) ? sptr->user->virthost : sptr->user->realhost), - parv[2]); + parv[2] ? parv[2] : "no reason specified"); - sendto_one(sptr, ":%s NOTICE %s :Knocked on to %s", me.name, + sendto_one(sptr, ":%s NOTICE %s :Knocked on %s", me.name, sptr->name, chptr->chname); return 0; } @@ -4331,7 +4399,7 @@ aParv *mp2parv(char *xmbuf, char *parmbuf) /* Some ugly macros, but useful */ #define Addit(x,y) modebuf[b] = x; strcat(parabuf, y); \ strcat(parabuf, " "); \ - if (b == RESYNCMODES) \ + if (b >= RESYNCMODES) \ { modebuf[b + 1] = '\0'; sendto_serv_butone_sjoin(cptr, \ ":%s MODE %s %s %s %lu", sptr->name, chptr->chname, \ modebuf, parabuf, chptr->creationtime); \ @@ -4342,8 +4410,12 @@ aParv *mp2parv(char *xmbuf, char *parmbuf) b = 1; \ } else b++ + + #define Addsingle(x) modebuf[b] = x; b++ #define CheckStatus(x,y) if (modeflags & (y)) { Addit((x), nick); } +#define AddBan(x) strcat(banbuf, x); strcat(banbuf, " "); +#define AddEx(x) strcat(exbuf, x); strcat(exbuf, " "); int m_sjoin(cptr, sptr, parc, parv) @@ -4358,16 +4430,19 @@ int m_sjoin(cptr, sptr, parc, parv) unsigned short merge; /* same timestamp */ char pvar[MAXMODEPARAMS][MODEBUFLEN + 3]; char paraback[1024], modeback[1024]; + char banbuf[1024]; + char exbuf[1024]; char nick[NICKLEN + 1]; + char *s; aClient *acptr, *tempptr; aChannel *chptr; Link *lp; - Ban *ban; + Ban *ban; aParv *ap; - int ts, oldts, pcount, x, y, z, i; - unsigned short b; + int ts, oldts, pcount, x, y, z, i, f; + unsigned short b, c; Mode oldmode; - char *t; + char *t, *bp, *tp; long modeflags; if (IsClient(sptr) || parc < 3 || !IsServer(sptr)) @@ -4378,18 +4453,18 @@ int m_sjoin(cptr, sptr, parc, parv) merge = nopara = nomode = removeours = removetheirs = 0; - if (SupportSJOIN(sptr) && !SupportSJ3(sptr) && - !strncmp(parv[4], "", 6)) - nopara = 1; - if (SupportSJOIN2(sptr) && !SupportSJ3(sptr) && - !strncmp(parv[4], "<->", 6)) - nopara = 1; - if (SupportSJ3(sptr) && (parc < 5)) + if (SupportSJOIN(cptr) && !SupportSJ3(cptr) && + !strncmp(parv[4], "", 6)) + nopara = 1; + if (SupportSJOIN2(cptr) && !SupportSJ3(cptr) && + !strncmp(parv[4], "<->", 6)) + nopara = 1; + if (SupportSJ3(cptr) && (parc < 6)) nopara = 1; - if (SupportSJ3(sptr)) + if (SupportSJ3(cptr)) { - if (parc < 4) + if (parc < 5) nomode = 1; } else @@ -4428,6 +4503,8 @@ int m_sjoin(cptr, sptr, parc, parv) parabuf[0] = '\0'; modebuf[0] = '+'; modebuf[1] = '\0'; + banbuf[0] = '\0'; + exbuf[0] = '\0'; channel_modes(cptr, modebuf, parabuf, chptr); if (removeours) { @@ -4524,8 +4601,7 @@ int m_sjoin(cptr, sptr, parc, parv) if (merge && !nomode) { aCtab *acp; - - bcopy(&chptr->mode, &oldmode, sizeof(oldmode)); + bcopy(&chptr->mode, &oldmode, sizeof(Mode)); /* merge the modes */ strcpy(modebuf, parv[3]); parabuf[0] = '\0'; @@ -4535,7 +4611,6 @@ int m_sjoin(cptr, sptr, parc, parv) strcat(parabuf, parv[b]); strcat(parabuf, " "); } - strcpy(paraback, parabuf); ap = mp2parv(modebuf, parabuf); set_mode(chptr, cptr, ap->parc, ap->parv, &pcount, pvar, 0); @@ -4699,23 +4774,31 @@ int m_sjoin(cptr, sptr, parc, parv) /* Mode setting done :), now for our beloved clients */ parabuf[0] = 0; modebuf[0] = '+'; + modebuf[1] = '\0'; t = parv[parc - 1]; - *(--t) = ' '; /* set to leading space */ + f = 1; b = 1; - strcpy(modebuf, "+"); + c = 0; + bp = buf; while (*t != '\0') { if (*t == ' ') { - i = 0; - t++; + if (f) + strncpyzt(bp, (t - c), (c + 1)); /* Put the nick in bp */ + else + strncpyzt(bp, (t - (c - 1)), c); /* Put the nick in bp */ + + c = f = 0; modeflags = 0; + i = 0; + tp = bp; while ( - (*t == '@') || (*t == '+') || (*t == '%') - || (*t == '*') || (*t == '~') || (*t == '&') - || (*t == '"')) + (*tp == '@') || (*tp == '+') || (*tp == '%') + || (*tp == '*') || (*tp == '~') || (*tp == '&') + || (*tp == '"')) { - switch (*(t++)) + switch (*(tp++)) { case '@': modeflags |= CHFL_CHANOP; @@ -4744,13 +4827,13 @@ int m_sjoin(cptr, sptr, parc, parv) } getnick: i = 0; - while ((*t != ' ') && (*t != '\0')) - nick[i++] = *(t++); /* get nick */ + while ((*tp != ' ') && (*tp != '\0')) + nick[i++] = *(tp++); /* get nick */ nick[i] = '\0'; if (nick[0] == ' ') - continue; + goto nextnick; if (nick[0] == '\0') - continue; + goto nextnick; if (!(modeflags & CHFL_BAN) && !(modeflags & CHFL_EXCEPT)) { @@ -4760,21 +4843,20 @@ int m_sjoin(cptr, sptr, parc, parv) ("Missing user %s in SJOIN for %s from %s (%s)", nick, chptr->chname, sptr->name, backupbuf); - continue; + goto nextnick; } - if (acptr->from != sptr) + if (acptr->from != sptr->from) { - /* The client is not from the server, send a kick for it */ sendto_one(sptr, ":%s KICK %s %s :Fake direction", - me.name, acptr->name); + me.name,chptr->chname, acptr->name); sendto_ops - ("Fake direction from user %s in SJOIN from %s at %s", - acptr->from, sptr->name, + ("Fake direction from user %s in SJOIN from %s(%s) at %s", + nick, + sptr->from->name, sptr->name, chptr->chname); - continue; + goto nextnick; } - if (removetheirs) { modeflags = 0; @@ -4784,7 +4866,7 @@ int m_sjoin(cptr, sptr, parc, parv) sendto_channel_butserv(chptr, acptr, ":%s JOIN :%s", nick, chptr->chname); - sendto_serv_butone_sjoin(cptr, ":%s JOIN :%s", + sendto_serv_butone_sjoin(cptr, ":%s JOIN %s", nick, chptr->chname); CheckStatus('q', CHFL_CHANOWNER); @@ -4796,26 +4878,28 @@ int m_sjoin(cptr, sptr, parc, parv) else { if (removetheirs) - continue; + goto nextnick; if (modeflags & CHFL_BAN) { add_banid(sptr, chptr, nick); Addit('b', nick); - sendto_serv_butone_token_opt(cptr, OPT_SJOIN2|OPT_NOT_SJ3, - sptr->name, MSG_MODE, TOK_MODE, "%s +b %s %li", chptr->chname, - nick, TStime()); + AddBan(nick); } if (modeflags & CHFL_EXCEPT) { add_exbanid(sptr, chptr, nick); Addit('e', nick); - sendto_serv_butone_token_opt(cptr, OPT_SJOIN2|OPT_NOT_SJ3, - sptr->name, MSG_MODE, TOK_MODE, "%s +e %s %li", chptr->chname, - nick, TStime()); + AddEx(nick); } } + } +nextnick: + t++; + c++; } + + if (modebuf[1]) { sendto_serv_butone_sjoin(cptr, @@ -4828,69 +4912,154 @@ int m_sjoin(cptr, sptr, parc, parv) /* we should be synched by now, */ if (oldts != -1) if (oldts != chptr->creationtime) - sendto_channel_butserv(chptr, &me, - ":%s NOTICE %s :*** Notice -- TS for %s changed from %ld to %ld", - me.name, chptr->chname, chptr->chname, - oldts, chptr->creationtime); - - - strcpy(parabuf, ""); - for (i = 1; i <= (parc - 2); i++) - { - strcat(parabuf, parv[i]); - if (((i + 1) <= (parc - 2))) - strcat(parabuf, " "); - } + sendto_channel_butserv(chptr, &me, + ":%s NOTICE %s :*** Notice -- TS for %s changed from %ld to %ld", + me.name, chptr->chname, chptr->chname, + oldts, chptr->creationtime); + + + strcpy(parabuf, ""); + for (i = 1; i <= (parc - 2); i++) + { + if (!parv[i]) + { + sendto_ops("Got null parv in SJ3 code"); + continue; + } + strcat(parabuf, parv[i]); + if (((i + 1) <= (parc - 2))) + strcat(parabuf, " "); + } /* This sends out to SJ3 servers .. */ - sendto_serv_butone_token_opt(cptr, OPT_SJOIN|OPT_SJ3, sptr->name, - MSG_SJOIN, TOK_SJOIN, "%s :%s", parabuf, parv[parc - 1]); - + sendto_serv_butone_token_opt(cptr, OPT_SJOIN | OPT_SJ3, sptr->name, + MSG_SJOIN, TOK_SJOIN, "%s :%s", parabuf, parv[parc - 1]); + Debug((DEBUG_DEBUG, "Sending '%s :%s' to sj3", parabuf, parv[parc - 1])); /* We strip out & and " here, for SJ2 */ - strcpy(parabuf, ""); - t = parv[parc - 1]; - ap = mp2parv("*", t); + strcpy(parabuf, ""); + t = parv[parc - 1]; + ap = mp2parv("*", t); for (i = 1; i < ap->parc; i++) { + if (!ap->parv[i]) + { + sendto_ops("Got null parv in SJ2 code"); + continue; + } if (*ap->parv[i] == '&') continue; if (*ap->parv[i] == '"') continue; - + strcat(parabuf, ap->parv[i]); if (!((i + 1) == ap->parc)) strcat(parabuf, " "); } - + if (nomode) { - sendto_serv_butone_token_opt(cptr, OPT_SJOIN|OPT_SJOIN2|OPT_NOT_SJ3, - sptr->name, - MSG_SJOIN, TOK_SJOIN, "%s %s + <-> :%s", parv[1], - parv[2], parabuf); + sendto_serv_butone_token_opt(cptr, + OPT_SJOIN | OPT_SJOIN2 | OPT_NOT_SJ3, sptr->name, MSG_SJOIN, + TOK_SJOIN, "%s %s + <-> :%s", parv[1], parv[2], parabuf); + Debug((DEBUG_DEBUG, "Sending to SJ2: %s %s + <-> :%s", parv[1], parv[2], parabuf)); + if (*banbuf) + { + for (s = (char *) strtok(banbuf, " "); s && (*s != ' '); s = (char *) strtok(NULL, " ")) + { + sendto_serv_butone_token_opt(cptr, + OPT_SJOIN2|OPT_NOT_SJ3, + sptr->name, MSG_MODE, TOK_MODE, + "%s +b %s %li", chptr->chname, s, + chptr->creationtime); + } + } + + if (*exbuf) + { + for (s = (char *) strtok(exbuf, " "); s && (*s != ' '); s = (char *) strtok(NULL, " ")) + { + sendto_serv_butone_token_opt(cptr, + OPT_SJOIN2|OPT_NOT_SJ3, + sptr->name, MSG_MODE, TOK_MODE, + "%s +e %s %li", chptr->chname, s, + chptr->creationtime); + } + } return 0; } + if (nopara) { - sendto_serv_butone_token_opt(cptr, OPT_SJOIN|OPT_SJOIN2|OPT_NOT_SJ3, - sptr->name, - MSG_SJOIN, TOK_SJOIN, "%s %s %s <-> :%s", parv[1], - parv[2], parv[3], parabuf); - return 0; + sendto_serv_butone_token_opt(cptr, + OPT_SJOIN | OPT_SJOIN2 | OPT_NOT_SJ3, sptr->name, MSG_SJOIN, + TOK_SJOIN, "%s %s %s <-> :%s", parv[1], parv[2], parv[3], + parabuf); + Debug((DEBUG_DEBUG, "Sending to SJ2: %s %s %s <-> :%s", + parv[1], parv[2], parv[3], parabuf)); + if (*banbuf) + { + for (s = (char *) strtok(banbuf, " "); s && (*s != ' '); s = (char *) strtok(NULL, " ")) + { + sendto_serv_butone_token_opt(cptr, + OPT_SJOIN2|OPT_NOT_SJ3, + sptr->name, MSG_MODE, TOK_MODE, + "%s +b %s %li", chptr->chname, s, + chptr->creationtime); + } + } + if (*exbuf) + { + for (s = (char *) strtok(exbuf, " "); s && (*s != ' '); s = (char *) strtok(NULL, " ")) + { + sendto_serv_butone_token_opt(cptr, + OPT_SJOIN2|OPT_NOT_SJ3, + sptr->name, MSG_MODE, TOK_MODE, + "%s +e %s %li", chptr->chname, s, + chptr->creationtime); + } + } + return 0; } strcpy(paraback, ""); - ap = mp2parv("*", parv[4]); + ap = mp2parv("*", parv[4]); for (i = 2; i < ap->parc; i++) { strcat(paraback, ap->parv[i]); strcat(paraback, " "); } - sendto_serv_butone_token_opt(cptr, OPT_SJOIN|OPT_SJOIN2|OPT_NOT_SJ3, - sptr->name, - MSG_SJOIN, TOK_SJOIN, "%s %s %s %s :%s", - parv[1], parv[2], parv[3], paraback, parabuf); + sendto_serv_butone_token_opt(cptr, OPT_SJOIN | OPT_SJOIN2 | OPT_NOT_SJ3, + sptr->name, + MSG_SJOIN, TOK_SJOIN, "%s %s %s %s :%s", + parv[1], parv[2], parv[3], paraback, parabuf); + Debug((DEBUG_DEBUG, "sending to SJ2: %s %s %s %s :%s", + parv[1], parv[2], parv[3], paraback, parabuf)); + /* Syncing bans to sj2 .. correctly. */ + if (*banbuf) + { + for (s = (char *) strtok(banbuf, " "); s && (*s != ' '); s = (char *) strtok(NULL, " ")) + { + sendto_serv_butone_token_opt(cptr, + OPT_SJOIN2|OPT_NOT_SJ3, + sptr->name, MSG_MODE, TOK_MODE, + "%s +b %s %li", chptr->chname, s, + chptr->creationtime); + } + } + if (*exbuf) + { + for (s = (char *) strtok(exbuf, " "); s && (*s != ' '); s = (char *) strtok(NULL, " ")) + { + sendto_serv_butone_token_opt(cptr, + OPT_SJOIN2|OPT_NOT_SJ3, + sptr->name, MSG_MODE, TOK_MODE, + "%s +e %s %li", chptr->chname, s, + chptr->creationtime); + } + } + /* And we are synched */ + return 0; } @@ -5108,7 +5277,7 @@ void send_channel_modes_sjoin3(cptr, chptr) Ban *ban; char *name; char *bufptr; - short nomode, nopara; + short nomode, nopara; char bbuf[1024]; int n = 0; @@ -5123,36 +5292,34 @@ void send_channel_modes_sjoin3(cptr, chptr) *modebuf = *parabuf = '\0'; channel_modes(cptr, modebuf, parabuf, chptr); - + if (!modebuf[1]) nomode = 1; if (!(*parabuf)) nopara = 1; - - - if (nomode) + + + if (nomode && nopara) { ircsprintf(buf, "%s %ld %s :", (IsToken(cptr) ? TOK_SJOIN : MSG_SJOIN), chptr->creationtime, chptr->chname); } - else - if (nopara) + if (nopara && !nomode) { ircsprintf(buf, "%s %ld %s %s :", (IsToken(cptr) ? TOK_SJOIN : MSG_SJOIN), chptr->creationtime, chptr->chname, modebuf); } - else if (!nopara && !nomode) { ircsprintf(buf, "%s %ld %s %s %s :", - (IsToken(cptr) ? TOK_SJOIN : MSG_SJOIN), + (IsToken(cptr) ? TOK_SJOIN : MSG_SJOIN), chptr->creationtime, chptr->chname, modebuf, parabuf); } strcpy(bbuf, buf); - + bufptr = buf + strlen(buf); for (lp = members; lp; lp = lp->next) @@ -5212,7 +5379,7 @@ void send_channel_modes_sjoin3(cptr, chptr) bufptr = buf + strlen(buf); } - + } for (ban = chptr->exlist; ban; ban = ban->next) { @@ -5233,9 +5400,9 @@ void send_channel_modes_sjoin3(cptr, chptr) bufptr = buf + strlen(buf); } - + } - + if (n) { *bufptr++ = '\0'; diff --git a/src/chkconf.c b/src/chkconf.c index 4b7d41c42..2543e97a9 100644 --- a/src/chkconf.c +++ b/src/chkconf.c @@ -34,7 +34,6 @@ #include #endif -ID_CVS("$Id$"); ID_Copyright("(C) 1993 Darren Reed"); ID_Notes("DF version was 1.9 1/30/94"); diff --git a/src/cio_init.c b/src/cio_init.c index 516c39f32..45710f9ed 100644 --- a/src/cio_init.c +++ b/src/cio_init.c @@ -1,8 +1,8 @@ + #include #include "Cio.h" #include "CioFunc.h" #include "common.h" -ID_CVS("$Id$"); // // FUNCTION: Cio_Init(void) @@ -11,22 +11,23 @@ ID_CVS("$Id$"); // BOOL Cio_Init(HINSTANCE hInstance) { - WNDCLASS wc; + WNDCLASS wc; - // Fill in window class structure with parameters that describe - // the main window. - wc.style = CS_HREDRAW | CS_VREDRAW; - wc.lpfnWndProc = (WNDPROC)Cio_WndProc; - wc.cbClsExtra = 0; - wc.cbWndExtra = 4; - wc.hInstance = hInstance; - wc.hIcon = NULL; - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE); - wc.lpszMenuName = NULL; - wc.lpszClassName = CIOCLASS; + // Fill in window class structure with parameters that describe + // the main window. + wc.style = CS_HREDRAW | CS_VREDRAW; + wc.lpfnWndProc = (WNDPROC) Cio_WndProc; + wc.cbClsExtra = 0; + wc.cbWndExtra = 4; + wc.hInstance = hInstance; + wc.hIcon = NULL; + wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE); + wc.lpszMenuName = NULL; + wc.lpszClassName = CIOCLASS; - if ( !RegisterClass(&wc) ) return FALSE; + if (!RegisterClass(&wc)) + return FALSE; - return TRUE; + return TRUE; } diff --git a/src/cio_main.c b/src/cio_main.c index 24d7e5dd6..09d94ad16 100644 --- a/src/cio_main.c +++ b/src/cio_main.c @@ -5,39 +5,38 @@ #include "Cio.h" #include "CioFunc.h" #include "common.h" -ID_CVS("$Id$"); -CioLine *CioMakeLine(CioLine *Prev, CioLine *Next) +CioLine *CioMakeLine(CioLine * Prev, CioLine * Next) { - CioLine *Line; + CioLine *Line; Line = LocalAlloc(LPTR, sizeof(CioLine)); _ASSERT(Line); - if ( Prev ) - { + if (Prev) + { Prev->Next = Line; Line->Prev = Prev; - } - if ( Next ) - { + } + if (Next) + { Next->Prev = Line; Line->Next = Next; - } + } return Line; } -void CioRemoveLine(CioWndInfo *CWI, CioLine *Line) +void CioRemoveLine(CioWndInfo * CWI, CioLine * Line) { - if ( Line->Next ) + if (Line->Next) Line->Next->Prev = Line->Prev; - if ( Line->Prev ) + if (Line->Prev) Line->Prev->Next = Line->Next; else CWI->FirstLine = Line->Next; - if ( Line->Data ) + if (Line->Data) LocalFree(Line->Data); LocalFree(Line); } @@ -49,15 +48,16 @@ void CioRemoveLine(CioWndInfo *CWI, CioLine *Line) // // PURPOSE: Creates main CIO window // -HWND Cio_Create(HINSTANCE hInstance, HWND hParent, DWORD Style, int X, int Y, int W, int H) +HWND Cio_Create(HINSTANCE hInstance, HWND hParent, DWORD Style, int X, int Y, + int W, int H) { - HWND hWnd; + HWND hWnd; - if ( hParent == NULL ) + if (hParent == NULL) return NULL; hWnd = CreateWindow(CIOCLASS, NULL, WS_CHILD | WS_VSCROLL | Style, - X, Y, W, H, hParent, NULL, hInstance, NULL); + X, Y, W, H, hParent, NULL, hInstance, NULL); return hWnd; } @@ -68,67 +68,68 @@ HWND Cio_Create(HINSTANCE hInstance, HWND hParent, DWORD Style, int X, int Y, in // // PURPOSE: Processes messages for a CIO window. // -LRESULT CALLBACK Cio_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +LRESULT CALLBACK Cio_WndProc(HWND hWnd, UINT message, WPARAM wParam, + LPARAM lParam) { - DWORD Style; + DWORD Style; switch (message) - { - case WM_CREATE: - return Cio_WndCreate(hWnd); + { + case WM_CREATE: + return Cio_WndCreate(hWnd); - case WM_RBUTTONDOWN: // RightClick in windows client area... - return 0; + case WM_RBUTTONDOWN: // RightClick in windows client area... + return 0; - case WM_PAINT: - return Cio_WndPaint(hWnd); + case WM_PAINT: + return Cio_WndPaint(hWnd); - case WM_SIZE: - Style = GetWindowLong(GetParent(hWnd), GWL_STYLE); - if ( Style & WS_MINIMIZE ) - return 0; - return Cio_WndSize(hWnd, lParam); + case WM_SIZE: + Style = GetWindowLong(GetParent(hWnd), GWL_STYLE); + if (Style & WS_MINIMIZE) + return 0; + return Cio_WndSize(hWnd, lParam); - case WM_VSCROLL: - return Cio_WndScroll(hWnd, wParam); + case WM_VSCROLL: + return Cio_WndScroll(hWnd, wParam); - case WM_DESTROY: - return Cio_WndDestroy(hWnd); + case WM_DESTROY: + return Cio_WndDestroy(hWnd); - case WM_SETFONT: - return Cio_SetFont(hWnd, wParam); + case WM_SETFONT: + return Cio_SetFont(hWnd, wParam); - case CIO_ADDSTRING: - return Cio_WndAddString(hWnd, wParam, (char *)lParam); + case CIO_ADDSTRING: + return Cio_WndAddString(hWnd, wParam, (char *)lParam); - default: - return (DefWindowProc(hWnd, message, wParam, lParam)); - } + default: + return (DefWindowProc(hWnd, message, wParam, lParam)); + } return (0); } BOOL Cio_WndCreate(HWND hWnd) { - CioWndInfo *CWI; - LOGFONT lfFont; - TEXTMETRIC tm; - HDC hdc; + CioWndInfo *CWI; + LOGFONT lfFont; + TEXTMETRIC tm; + HDC hdc; CWI = LocalAlloc(LPTR, sizeof(CioWndInfo)); _ASSERT(CWI); - lfFont.lfHeight = 12; - lfFont.lfWidth = 0; - lfFont.lfEscapement = 0; - lfFont.lfOrientation = 0; - lfFont.lfWeight = 400; - lfFont.lfItalic = 0; - lfFont.lfUnderline = 0; - lfFont.lfStrikeOut = 0; - lfFont.lfCharSet = ANSI_CHARSET; - lfFont.lfOutPrecision = OUT_STRING_PRECIS; - lfFont.lfClipPrecision = CLIP_STROKE_PRECIS; - lfFont.lfQuality = DRAFT_QUALITY; + lfFont.lfHeight = 12; + lfFont.lfWidth = 0; + lfFont.lfEscapement = 0; + lfFont.lfOrientation = 0; + lfFont.lfWeight = 400; + lfFont.lfItalic = 0; + lfFont.lfUnderline = 0; + lfFont.lfStrikeOut = 0; + lfFont.lfCharSet = ANSI_CHARSET; + lfFont.lfOutPrecision = OUT_STRING_PRECIS; + lfFont.lfClipPrecision = CLIP_STROKE_PRECIS; + lfFont.lfQuality = DRAFT_QUALITY; lfFont.lfPitchAndFamily = FIXED_PITCH | FF_MODERN; wsprintf(lfFont.lfFaceName, "FixedSys"); @@ -143,9 +144,9 @@ BOOL Cio_WndCreate(HWND hWnd) CWI->YChar = tm.tmHeight + tm.tmExternalLeading; CWI->FirstLine = CWI->CurLine = CioMakeLine(NULL, NULL); - CWI->Lines=0; + CWI->Lines = 0; - SetWindowLong(hWnd, GWL_USER, (DWORD)CWI); + SetWindowLong(hWnd, GWL_USER, (DWORD) CWI); return 0; } @@ -153,29 +154,29 @@ BOOL Cio_WndCreate(HWND hWnd) BOOL Cio_WndPaint(HWND hWnd) { - PAINTSTRUCT ps; - CioWndInfo *CWI; - HDC hdc; - HFONT hOldFont; - CioLine *Line; - RECT rect; - int nCol, nEndCol, nMaxCol, nRow, nEndRow, nBegCol, nCount, i=0; - int nVertPos, nHorzPos, nOff, nBegOff, NewColorAt=0; - BYTE Red, Green, Blue, NewColor=0, UnderLine=0; - HPEN hpen; + PAINTSTRUCT ps; + CioWndInfo *CWI; + HDC hdc; + HFONT hOldFont; + CioLine *Line; + RECT rect; + int nCol, nEndCol, nMaxCol, nRow, nEndRow, nBegCol, nCount, i = 0; + int nVertPos, nHorzPos, nOff, nBegOff, NewColorAt = 0; + BYTE Red, Green, Blue, NewColor = 0, UnderLine = 0; + HPEN hpen; - CWI = (CioWndInfo *)GetWindowLong(hWnd, GWL_USER); + CWI = (CioWndInfo *) GetWindowLong(hWnd, GWL_USER); hdc = BeginPaint(hWnd, &ps); hOldFont = SelectObject(hdc, CWI->hFont); rect = ps.rcPaint; - nCol = max(0, rect.left / CWI->XChar); + nCol = max(0, rect.left / CWI->XChar); nEndCol = rect.right / CWI->XChar; - nEndCol = min(CWI->Width, nEndCol+1); + nEndCol = min(CWI->Width, nEndCol + 1); nEndRow = max(0, rect.top / CWI->YChar); - nRow = rect.bottom / CWI->YChar; - nRow = min(CWI->Height, nRow+1); + nRow = rect.bottom / CWI->YChar; + nRow = min(CWI->Height, nRow + 1); nBegOff = nCol; nBegCol = nCol; @@ -184,136 +185,136 @@ BOOL Cio_WndPaint(HWND hWnd) * Find the first line to use, and work up from there. */ Line = CWI->FirstLine; - while ( Line && i < CWI->Scroll ) - { - if ( Line->Data ) + while (Line && i < CWI->Scroll) + { + if (Line->Data) i++; Line = Line->Next; - } + } i = 0; - while ( Line && i < (CWI->Height-nRow) ) - { - if ( Line->Data ) + while (Line && i < (CWI->Height - nRow)) + { + if (Line->Data) i++; Line = Line->Next; - } + } - for ( ; nRow >= nEndRow; nRow-- ) - { - UnderLine=0; - while ( Line && !Line->Data ) + for (; nRow >= nEndRow; nRow--) + { + UnderLine = 0; + while (Line && !Line->Data) Line = Line->Next; - if ( !Line ) + if (!Line) continue; nMaxCol = Line->Len; nOff = nBegOff; nCol = 0; nCount = 0; - for ( i = 0; i < Line->Len; i++ ) - { - if ( Line->Data[i] == 0 ) - { - Red = Line->Data[i+1]; - Green = Line->Data[i+2]; - Blue = Line->Data[i+3]; + for (i = 0; i < Line->Len; i++) + { + if (Line->Data[i] == 0) + { + Red = Line->Data[i + 1]; + Green = Line->Data[i + 2]; + Blue = Line->Data[i + 3]; SetTextColor(hdc, RGB(Red, Green, Blue)); SetBkColor(hdc, RGB(255, 255, 255)); i += 3; nCol += 4; continue; - } - if ( nCount >= nBegCol ) + } + if (nCount >= nBegCol) break; nCol++; nCount++; - } - if ( i >= Line->Len ) + } + if (i >= Line->Len) continue; - for ( ; nCol <= nMaxCol; nCol++ ) - { - nCount = nMaxCol-nCol; - for ( i = 0; i < (nMaxCol-nCol); i++ ) - { - if ( Line->Data[nCol+i] == 0x1F ) - { + for (; nCol <= nMaxCol; nCol++) + { + nCount = nMaxCol - nCol; + for (i = 0; i < (nMaxCol - nCol); i++) + { + if (Line->Data[nCol + i] == 0x1F) + { nCount = i; - if ( UnderLine == 0 ) - { + if (UnderLine == 0) + { UnderLine = 1; break; - } - if ( UnderLine == 1 ) - { + } + if (UnderLine == 1) + { UnderLine = 2; break; - } + } break; - } - if ( Line->Data[nCol+i] == 0x0F ) - { + } + if (Line->Data[nCol + i] == 0x0F) + { nCount = i; UnderLine = 0; break; - } - if ( Line->Data[nCol+i] == 0 ) - { + } + if (Line->Data[nCol + i] == 0) + { NewColor = 1; - NewColorAt = nCol+i; + NewColorAt = nCol + i; nCount = i; i += 3; break; - } - } + } + } - if ( nCount ) - { + if (nCount) + { nVertPos = nRow * CWI->YChar - CWI->YChar + - CWI->YJunk; + CWI->YJunk; nHorzPos = nOff * CWI->XChar; - rect.top = nVertPos; + rect.top = nVertPos; rect.bottom = nVertPos + CWI->YChar; - rect.left = nHorzPos; - rect.right = nHorzPos + (CWI->XChar*nCount); + rect.left = nHorzPos; + rect.right = nHorzPos + (CWI->XChar * nCount); SetBkMode(hdc, OPAQUE); ExtTextOut(hdc, nHorzPos, nVertPos, ETO_OPAQUE, - &rect, (LPSTR) Line->Data+nCol, - nCount, NULL); + &rect, (LPSTR) Line->Data + nCol, + nCount, NULL); nOff += nCount; - if ( UnderLine == 2 ) - { + if (UnderLine == 2) + { hpen = CreatePen(PS_SOLID, 0, - RGB(Red, Green, Blue)); + RGB(Red, Green, Blue)); SelectObject(hdc, hpen); MoveToEx(hdc, (int)rect.left, - (int)rect.bottom-1, - (LPPOINT)NULL); + (int)rect.bottom - 1, + (LPPOINT) NULL); LineTo(hdc, (int)rect.right, - (int)rect.bottom-1); + (int)rect.bottom - 1); DeleteObject(hpen); UnderLine = 0; - } - } - if ( UnderLine == 1 ) + } + } + if (UnderLine == 1) UnderLine = 2; nCol += i; - if ( NewColor ) - { - Red = Line->Data[NewColorAt+1]; - Green = Line->Data[NewColorAt+2]; - Blue = Line->Data[NewColorAt+3]; + if (NewColor) + { + Red = Line->Data[NewColorAt + 1]; + Green = Line->Data[NewColorAt + 2]; + Blue = Line->Data[NewColorAt + 3]; SetTextColor(hdc, RGB(Red, Green, Blue)); SetBkColor(hdc, RGB(255, 255, 255)); NewColor = 0; - } - } + } + } Line = Line->Next; - } - + } + SelectObject(hdc, hOldFont); EndPaint(hWnd, &ps); return 0; @@ -322,10 +323,10 @@ BOOL Cio_WndPaint(HWND hWnd) BOOL Cio_WndDestroy(HWND hWnd) { - CioWndInfo *CWI; + CioWndInfo *CWI; - CWI = (CioWndInfo *)GetWindowLong(hWnd, GWL_USER); - while ( CWI->FirstLine ) + CWI = (CioWndInfo *) GetWindowLong(hWnd, GWL_USER); + while (CWI->FirstLine) CioRemoveLine(CWI, CWI->FirstLine); DeleteObject(CWI->hFont); @@ -335,188 +336,194 @@ BOOL Cio_WndDestroy(HWND hWnd) } -int Cio_WndAddString(HWND hWnd, int Len, char *Buffer) +int Cio_WndAddString(HWND hWnd, int Len, char *Buffer) { - CioWndInfo *CWI; - CioLine *Line; - int TLen=0, DLen=0, Loop=0, LastSpace=0, Scrolled=0, Pad=0; - BYTE Red=0, Grn=0, Blu=0; + CioWndInfo *CWI; + CioLine *Line; + int TLen = 0, DLen = 0, Loop = 0, LastSpace = 0, Scrolled = 0, Pad = 0; + BYTE Red = 0, Grn = 0, Blu = 0; - CWI = (CioWndInfo *)GetWindowLong(hWnd, GWL_USER); + CWI = (CioWndInfo *) GetWindowLong(hWnd, GWL_USER); - if ( CWI->ScrollMe == TRUE ) - { + if (CWI->ScrollMe == TRUE) + { Cio_Scroll(hWnd, CWI, 1); Scrolled++; CWI->ScrollMe = FALSE; - } - if ( Buffer[Len-1] == '\r' ) - { + } + if (Buffer[Len - 1] == '\r') + { CWI->ScrollMe = TRUE; - Len-=1; - } + Len -= 1; + } - while ( Len ) - { + while (Len) + { /* * Check the current line to see if we have room to tack * on our string to the end of. If not, put as much as * possible on, then scroll up a new line. */ - TLen=DLen=0; + TLen = DLen = 0; Line = CWI->FirstLine; - while ( TLen < Line->Len ) - { - if ( Line->Data[TLen] == 0 ) - { - TLen+=4; + while (TLen < Line->Len) + { + if (Line->Data[TLen] == 0) + { + TLen += 4; continue; - } - TLen+=1; - DLen+=1; - } - Loop=TLen=0; - while ( TLen < Len ) - { - if ( Buffer[TLen] == 0 ) - { - TLen+=4; + } + TLen += 1; + DLen += 1; + } + Loop = TLen = 0; + while (TLen < Len) + { + if (Buffer[TLen] == 0) + { + TLen += 4; continue; - } - TLen+=1; - Loop+=1; - } - if ( DLen+Loop > CWI->Width ) - { + } + TLen += 1; + Loop += 1; + } + if (DLen + Loop > CWI->Width) + { Cio_Scroll(hWnd, CWI, 1); Scrolled++; - Loop=TLen=0; + Loop = TLen = 0; do - { - if ( Buffer[TLen] == 0 ) - { - Red = Buffer[TLen+1]; - Grn = Buffer[TLen+2]; - Blu = Buffer[TLen+3]; - TLen+=4; + { + if (Buffer[TLen] == 0) + { + Red = Buffer[TLen + 1]; + Grn = Buffer[TLen + 2]; + Blu = Buffer[TLen + 3]; + TLen += 4; continue; - } - if ( TLen >= Len || DLen+Loop >= CWI->Width ) + } + if (TLen >= Len || DLen + Loop >= CWI->Width) break; - if ( Buffer[TLen] == ' ' ) + if (Buffer[TLen] == ' ') LastSpace = TLen; - TLen+=1; - Loop+=1; - } while ( TLen < Len && DLen+Loop < CWI->Width ); + TLen += 1; + Loop += 1; + } + while (TLen < Len && DLen + Loop < CWI->Width); - if ( TLen != Len && Buffer[TLen] != ' ' && - LastSpace && (LastSpace-TLen) < 16 ) + if (TLen != Len && Buffer[TLen] != ' ' && + LastSpace && (LastSpace - TLen) < 16) TLen = LastSpace; - if ( Line->Data != NULL ) - { + if (Line->Data != NULL) + { Line->Data = LocalReAlloc(Line->Data, - Line->Len+TLen+Pad, LMEM_MOVEABLE); + Line->Len + TLen + Pad, LMEM_MOVEABLE); _ASSERT(Line->Data); memset(Line->Data, ' ', Pad); - memmove(Line->Data+Line->Len+Pad, Buffer, TLen); + memmove(Line->Data + Line->Len + Pad, Buffer, + TLen); Line->Len += TLen + Pad; - } + } else - { - if ( Buffer[0] == 0 ) - { - Line->Data = LocalAlloc(LPTR, TLen+Pad); + { + if (Buffer[0] == 0) + { + Line->Data = + LocalAlloc(LPTR, TLen + Pad); _ASSERT(Line->Data); memset(Line->Data, ' ', Pad); - memmove(Line->Data+Pad, Buffer, TLen); + memmove(Line->Data + Pad, Buffer, TLen); Line->Len = TLen + Pad; - } + } else - { - Line->Data = LocalAlloc(LPTR, TLen+4+Pad); + { + Line->Data = + LocalAlloc(LPTR, TLen + 4 + Pad); _ASSERT(Line->Data); - memset(Line->Data+4, ' ', Pad); - memmove(Line->Data+4+Pad, Buffer, TLen); - Line->Len = TLen+4+Pad; + memset(Line->Data + 4, ' ', Pad); + memmove(Line->Data + 4 + Pad, Buffer, + TLen); + Line->Len = TLen + 4 + Pad; Line->Data[0] = 0; Line->Data[1] = Red; Line->Data[2] = Grn; Line->Data[3] = Blu; - } - } + } + } - if ( TLen == LastSpace ) + if (TLen == LastSpace) TLen++; Pad = 3; Len -= TLen; - memmove(Buffer, Buffer+TLen, Len); - if ( Buffer[0] == '\r' && Len == 1 ) - Len=0; + memmove(Buffer, Buffer + TLen, Len); + if (Buffer[0] == '\r' && Len == 1) + Len = 0; continue; - } /* if ( DLen+Loop > CWI->Width ) */ + } /* if ( DLen+Loop > CWI->Width ) */ Line = CWI->FirstLine; - if ( Line->Data != NULL ) - { - Line->Data = LocalReAlloc(Line->Data, Line->Len+TLen+Pad, - LMEM_MOVEABLE); + if (Line->Data != NULL) + { + Line->Data = + LocalReAlloc(Line->Data, Line->Len + TLen + Pad, + LMEM_MOVEABLE); _ASSERT(Line->Data); memset(Line->Data, ' ', Pad); - memmove(Line->Data+Line->Len+Pad, Buffer, Len); + memmove(Line->Data + Line->Len + Pad, Buffer, Len); Line->Len += Len + Pad; - } + } else - { - if ( Buffer[0] == 0 ) - { - Line->Data = LocalAlloc(LPTR, Len+Pad); + { + if (Buffer[0] == 0) + { + Line->Data = LocalAlloc(LPTR, Len + Pad); _ASSERT(Line->Data); memset(Line->Data, ' ', Pad); - memmove(Line->Data+Pad, Buffer, Len); + memmove(Line->Data + Pad, Buffer, Len); Line->Len = Len + Pad; - } + } else - { - Line->Data = LocalAlloc(LPTR, Len+4+Pad); + { + Line->Data = LocalAlloc(LPTR, Len + 4 + Pad); _ASSERT(Line->Data); - memset(Line->Data+4, ' ', Pad); - memmove(Line->Data+4+Pad, Buffer, Len); - Line->Len = Len+4+Pad; + memset(Line->Data + 4, ' ', Pad); + memmove(Line->Data + 4 + Pad, Buffer, Len); + Line->Len = Len + 4 + Pad; Line->Data[0] = 0; Line->Data[1] = Red; Line->Data[2] = Grn; Line->Data[3] = Blu; - } - } + } + } break; - } /* while (Len) */ + } /* while (Len) */ - if ( !CWI->Scroll ) - { - RECT rc; + if (!CWI->Scroll) + { + RECT rc; rc.left = rc.top = 0; - rc.right = CWI->Width*CWI->XChar; - rc.bottom = CWI->Height*CWI->YChar+CWI->YJunk; - ScrollWindow(hWnd, 0, -(Scrolled*CWI->YChar), &rc, NULL); - rc.top = (CWI->Height-Scrolled)*CWI->YChar+CWI->YJunk; - if ( rc.top < 0 ) + rc.right = CWI->Width * CWI->XChar; + rc.bottom = CWI->Height * CWI->YChar + CWI->YJunk; + ScrollWindow(hWnd, 0, -(Scrolled * CWI->YChar), &rc, NULL); + rc.top = (CWI->Height - Scrolled) * CWI->YChar + CWI->YJunk; + if (rc.top < 0) rc.top = 0; return Scrolled; - } + } return 0; } BOOL Cio_WndSize(HWND hWnd, LPARAM lParam) { - CioWndInfo *CWI; - SCROLLINFO si; + CioWndInfo *CWI; + SCROLLINFO si; - CWI = (CioWndInfo *)GetWindowLong(hWnd, GWL_USER); + CWI = (CioWndInfo *) GetWindowLong(hWnd, GWL_USER); CWI->Scroll = 0; CWI->Width = LOWORD(lParam) / CWI->XChar; @@ -528,11 +535,11 @@ BOOL Cio_WndSize(HWND hWnd, LPARAM lParam) /* Set the Scroll Bar information. */ si.cbSize = sizeof(si); - si.fMask = SIF_RANGE | SIF_PAGE | SIF_POS | SIF_DISABLENOSCROLL; - si.nMin = 1; - si.nMax = CWI->Lines; - si.nPage = CWI->Height-1; - si.nPos = si.nMax; + si.fMask = SIF_RANGE | SIF_PAGE | SIF_POS | SIF_DISABLENOSCROLL; + si.nMin = 1; + si.nMax = CWI->Lines; + si.nPage = CWI->Height - 1; + si.nPos = si.nMax; SetScrollInfo(hWnd, SB_VERT, &si, TRUE); return 0; @@ -541,188 +548,189 @@ BOOL Cio_WndSize(HWND hWnd, LPARAM lParam) BOOL Cio_WndScroll(HWND hWnd, WPARAM wParam) { - CioWndInfo *CWI; - SCROLLINFO si; - int Amnt=0, nPos=0; + CioWndInfo *CWI; + SCROLLINFO si; + int Amnt = 0, nPos = 0; - CWI = (CioWndInfo *)GetWindowLong(hWnd, GWL_USER); + CWI = (CioWndInfo *) GetWindowLong(hWnd, GWL_USER); si.cbSize = sizeof(si); - si.fMask = SIF_RANGE | SIF_PAGE | SIF_POS; + si.fMask = SIF_RANGE | SIF_PAGE | SIF_POS; GetScrollInfo(hWnd, SB_VERT, &si); - si.nMax-=si.nPage; - si.nMax+=si.nMin; + si.nMax -= si.nPage; + si.nMax += si.nMin; nPos = si.nPos; - switch(LOWORD (wParam)) - { - case SB_PAGEUP: - Amnt = -(int)si.nPage; - break; + switch (LOWORD(wParam)) + { + case SB_PAGEUP: + Amnt = -(int)si.nPage; + break; - case SB_PAGEDOWN: - Amnt = si.nPage; - break; + case SB_PAGEDOWN: + Amnt = si.nPage; + break; - case SB_LINEUP: - Amnt = -(int)1; - break; + case SB_LINEUP: + Amnt = -(int)1; + break; - case SB_LINEDOWN: - Amnt = 1; - break; + case SB_LINEDOWN: + Amnt = 1; + break; - case SB_THUMBTRACK: - break; - } + case SB_THUMBTRACK: + break; + } - if ( Amnt ) - { + if (Amnt) + { nPos += Amnt; - if ( nPos < si.nMin ) - { + if (nPos < si.nMin) + { Amnt -= nPos - si.nMin; nPos = si.nMin; - } + } - if ( nPos > si.nMax ) - { + if (nPos > si.nMax) + { Amnt -= nPos - si.nMax; nPos = si.nMax; - } + } - if ( Amnt ) - { + if (Amnt) + { SetScrollPos(hWnd, SB_VERT, nPos, TRUE); - CWI->Scroll = si.nMax-nPos; + CWI->Scroll = si.nMax - nPos; InvalidateRect(hWnd, NULL, TRUE); - } - } + } + } return 0; } -void Cio_Scroll(HWND hWnd, CioWndInfo *CWI, int Scroll) +void Cio_Scroll(HWND hWnd, CioWndInfo * CWI, int Scroll) { - int i=0, KillAmt=0, StopAt=0; - SCROLLINFO si; - CioLine *Line, *Next; + int i = 0, KillAmt = 0, StopAt = 0; + SCROLLINFO si; + CioLine *Line, *Next; - if ( CWI->Lines+Scroll > 500 && !CWI->Scroll ) - { + if (CWI->Lines + Scroll > 500 && !CWI->Scroll) + { Line = CWI->FirstLine; - KillAmt = max((CWI->Lines+Scroll)-500, 20); - for ( i = 0; Line && i < (CWI->Lines-KillAmt); i++ ) + KillAmt = max((CWI->Lines + Scroll) - 500, 20); + for (i = 0; Line && i < (CWI->Lines - KillAmt); i++) Line = Line->Next; - while ( Line ) + while (Line) { Next = Line->Next; CioRemoveLine(CWI, Line); Line = Next; } CWI->Lines -= KillAmt; - } + } - for ( i = 0; i < Scroll; i++ ) + for (i = 0; i < Scroll; i++) CWI->FirstLine = CioMakeLine(NULL, CWI->FirstLine); - CWI->Lines+=Scroll; - if ( CWI->Scroll ) + CWI->Lines += Scroll; + if (CWI->Scroll) CWI->Scroll += Scroll; - + /* Set the Scroll Bar information. */ si.cbSize = sizeof(si); - si.fMask = SIF_RANGE | SIF_PAGE | SIF_POS | SIF_DISABLENOSCROLL; + si.fMask = SIF_RANGE | SIF_PAGE | SIF_POS | SIF_DISABLENOSCROLL; GetScrollInfo(hWnd, SB_VERT, &si); si.cbSize = sizeof(si); - si.fMask = SIF_RANGE | SIF_POS | SIF_PAGE | SIF_DISABLENOSCROLL; - si.nMin = 1; - si.nMax = CWI->Lines; - si.nPage = CWI->Height-1; - si.nPos = CWI->Lines - si.nPage - CWI->Scroll; + si.fMask = SIF_RANGE | SIF_POS | SIF_PAGE | SIF_DISABLENOSCROLL; + si.nMin = 1; + si.nMax = CWI->Lines; + si.nPage = CWI->Height - 1; + si.nPos = CWI->Lines - si.nPage - CWI->Scroll; SetScrollInfo(hWnd, SB_VERT, &si, TRUE); } BOOL Cio_PrintF(HWND hWnd, char *InBuf, ...) { - CioWndInfo *CWI; - va_list argptr; - char *Buffer=NULL, *Ptr = NULL; - DWORD Len=0, TLen, Off; - int Scrolled=0; - RECT rc; + CioWndInfo *CWI; + va_list argptr; + char *Buffer = NULL, *Ptr = NULL; + DWORD Len = 0, TLen, Off; + int Scrolled = 0; + RECT rc; - if ( (Buffer = LocalAlloc(LPTR, 16384)) == NULL ) + if ((Buffer = LocalAlloc(LPTR, 16384)) == NULL) return FALSE; va_start(argptr, InBuf); Len = vsprintf(Buffer, InBuf, argptr); va_end(argptr); - if ( Len == 0 ) - { + if (Len == 0) + { LocalFree(Buffer); return FALSE; - } + } - CWI = (CioWndInfo *)GetWindowLong(hWnd, GWL_USER); - Ptr = memchr(Buffer, 0, TLen=Len); - while ( Ptr != NULL ) - { - Off = Ptr-Buffer; - - CWI->FR = Buffer[Off+1]; - CWI->FG = Buffer[Off+2]; - CWI->FB = Buffer[Off+3]; + CWI = (CioWndInfo *) GetWindowLong(hWnd, GWL_USER); + Ptr = memchr(Buffer, 0, TLen = Len); + while (Ptr != NULL) + { + Off = Ptr - Buffer; + + CWI->FR = Buffer[Off + 1]; + CWI->FG = Buffer[Off + 2]; + CWI->FB = Buffer[Off + 3]; Off += 4; - TLen = Len-Off; - if ( TLen == 0 ) + TLen = Len - Off; + if (TLen == 0) break; - Ptr = memchr(Buffer+Off, 0, TLen); - } - if ( Buffer[0] != 0 ) - { - memmove(Buffer+4, Buffer, Len); - Len+=4; + Ptr = memchr(Buffer + Off, 0, TLen); + } + if (Buffer[0] != 0) + { + memmove(Buffer + 4, Buffer, Len); + Len += 4; Buffer[0] = 0; Buffer[1] = CWI->FR; Buffer[2] = CWI->FG; Buffer[3] = CWI->FB; - } + } rc.left = 0; - rc.right = CWI->Width*CWI->XChar; - rc.top = rc.bottom = CWI->Height*CWI->YChar; + rc.right = CWI->Width * CWI->XChar; + rc.top = rc.bottom = CWI->Height * CWI->YChar; do - { + { Ptr = memchr(Buffer, '\r', Len); - if ( Ptr ) - TLen = (Ptr-Buffer)+1; + if (Ptr) + TLen = (Ptr - Buffer) + 1; else TLen = Len; - if ( Buffer[0] != '\r' || CWI->ScrollMe == FALSE ) - { + if (Buffer[0] != '\r' || CWI->ScrollMe == FALSE) + { Scrolled = Cio_WndAddString(hWnd, TLen, Buffer); - rc.top -= Scrolled*CWI->YChar; - } + rc.top -= Scrolled * CWI->YChar; + } Len -= TLen; - memmove(Buffer, Buffer+TLen, Len); - } while ( Len ); + memmove(Buffer, Buffer + TLen, Len); + } + while (Len); - if ( rc.top < rc.bottom ) - { - if ( rc.top < 0 ) + if (rc.top < rc.bottom) + { + if (rc.top < 0) rc.top = 0; InvalidateRect(hWnd, &rc, TRUE); UpdateWindow(hWnd); - } + } LocalFree(Buffer); return TRUE; } @@ -730,73 +738,74 @@ BOOL Cio_PrintF(HWND hWnd, char *InBuf, ...) BOOL Cio_Puts(HWND hWnd, char *InBuf, DWORD Len) { - CioWndInfo *CWI; - char *Buffer = NULL, *Ptr = NULL; - DWORD TLen, Off; - int Scrolled=0; - RECT rc; + CioWndInfo *CWI; + char *Buffer = NULL, *Ptr = NULL; + DWORD TLen, Off; + int Scrolled = 0; + RECT rc; - if ( !Len ) + if (!Len) return FALSE; - if ( (Buffer = LocalAlloc(LPTR, 16384)) == NULL ) + if ((Buffer = LocalAlloc(LPTR, 16384)) == NULL) return FALSE; memmove(Buffer, InBuf, Len); - CWI = (CioWndInfo *)GetWindowLong(hWnd, GWL_USER); - Ptr = memchr(Buffer, 0, TLen=Len); - while ( Ptr != NULL ) - { - Off = Ptr-Buffer; - - CWI->FR = Buffer[Off+1]; - CWI->FG = Buffer[Off+2]; - CWI->FB = Buffer[Off+3]; + CWI = (CioWndInfo *) GetWindowLong(hWnd, GWL_USER); + Ptr = memchr(Buffer, 0, TLen = Len); + while (Ptr != NULL) + { + Off = Ptr - Buffer; + + CWI->FR = Buffer[Off + 1]; + CWI->FG = Buffer[Off + 2]; + CWI->FB = Buffer[Off + 3]; Off += 4; - TLen = Len-Off; - if ( TLen == 0 ) + TLen = Len - Off; + if (TLen == 0) break; - Ptr = memchr(Buffer+Off, 0, TLen); - } - if ( Buffer[0] != 0 ) - { - memmove(Buffer+4, Buffer, Len); - Len+=4; + Ptr = memchr(Buffer + Off, 0, TLen); + } + if (Buffer[0] != 0) + { + memmove(Buffer + 4, Buffer, Len); + Len += 4; Buffer[0] = 0; Buffer[1] = CWI->FR; Buffer[2] = CWI->FG; Buffer[3] = CWI->FB; - } + } rc.left = 0; - rc.right = CWI->Width*CWI->XChar; - rc.top = rc.bottom = CWI->Height*CWI->YChar; + rc.right = CWI->Width * CWI->XChar; + rc.top = rc.bottom = CWI->Height * CWI->YChar; do - { + { Ptr = memchr(Buffer, '\r', Len); - if ( Ptr ) - TLen = (Ptr-Buffer)+1; + if (Ptr) + TLen = (Ptr - Buffer) + 1; else TLen = Len; - if ( Buffer[0] != '\r' || CWI->ScrollMe == FALSE ) - { + if (Buffer[0] != '\r' || CWI->ScrollMe == FALSE) + { Scrolled = Cio_WndAddString(hWnd, TLen, Buffer); - rc.top -= Scrolled*CWI->YChar; - } + rc.top -= Scrolled * CWI->YChar; + } Len -= TLen; - memmove(Buffer, Buffer+TLen, Len); - } while ( Len ); + memmove(Buffer, Buffer + TLen, Len); + } + while (Len); - if ( rc.top < rc.bottom ) - { - if ( rc.top < 0 ) + if (rc.top < rc.bottom) + { + if (rc.top < 0) rc.top = 0; InvalidateRect(hWnd, &rc, TRUE); UpdateWindow(hWnd); - } + } LocalFree(Buffer); return TRUE; } @@ -804,16 +813,16 @@ BOOL Cio_Puts(HWND hWnd, char *InBuf, DWORD Len) BOOL Cio_SetFont(HWND hWnd, WPARAM wParam) { - CioWndInfo *CWI; - TEXTMETRIC tm; - HFONT hFont = (HFONT)wParam; - HDC hdc; - RECT rc; + CioWndInfo *CWI; + TEXTMETRIC tm; + HFONT hFont = (HFONT) wParam; + HDC hdc; + RECT rc; - CWI = (CioWndInfo *)GetWindowLong(hWnd, GWL_USER); + CWI = (CioWndInfo *) GetWindowLong(hWnd, GWL_USER); - if ( CWI->hFont ) + if (CWI->hFont) DeleteObject(CWI->hFont); CWI->hFont = hFont; hdc = GetDC(hWnd); @@ -828,9 +837,9 @@ BOOL Cio_SetFont(HWND hWnd, WPARAM wParam) * Send resize message so it will pick up the new font size. */ GetClientRect(hWnd, &rc); - SendMessage(hWnd, WM_SIZE, 0, MAKELPARAM(rc.right-rc.left, rc.bottom-rc.top)); + SendMessage(hWnd, WM_SIZE, 0, MAKELPARAM(rc.right - rc.left, + rc.bottom - rc.top)); InvalidateRect(hWnd, NULL, TRUE); return TRUE; } - diff --git a/src/class.c b/src/class.c index 31b73d416..96923a666 100644 --- a/src/class.c +++ b/src/class.c @@ -23,7 +23,6 @@ #include "numeric.h" #include "h.h" -ID_CVS("$Id$"); ID_Copyright("(C) 1990 Darren Reed"); ID_Notes("1.4 6/28/93"); @@ -33,7 +32,7 @@ ID_Notes("1.4 6/28/93"); #define BAD_CLIENT_CLASS -3 aClass *classes; -int badclass = 0; +int badclass = 0; int get_conf_class(aconf) aConfItem *aconf; @@ -143,7 +142,7 @@ void add_class(class, ping, confreq, maxli, sendq) if (maxli > (MAXCONNECTIONS - 15)) { Debug((DEBUG_DEBUG, "Reducing class %d to %i", - class, (MAXCONNECTIONS - 15))); + class, (MAXCONNECTIONS - 15))); maxli = MAXCONNECTIONS - 15; } t = find_class(class); diff --git a/src/cloak.c b/src/cloak.c index 4ef02e8e9..fe5768321 100644 --- a/src/cloak.c +++ b/src/cloak.c @@ -41,7 +41,6 @@ static char sccxid[] = "@(#)cloak.c 9.00 7/12/99 UnrealIRCd"; #endif #include "h.h" -ID_CVS("$Id$"); // #define iNAH /* networks.h now */ /* Hidden host code below */ @@ -215,8 +214,6 @@ char *make_virthost(char *curr, char *new, int mode) int i; if (curr == NULL) return; - if (new == NULL) - return; mask = hidehost(curr, 0); if (mode == 0) diff --git a/src/crule.c b/src/crule.c index 9529221bd..24436a5d4 100644 --- a/src/crule.c +++ b/src/crule.c @@ -42,7 +42,6 @@ char *collapse PROTO((char *pattern)); extern aClient *client, *local[]; -ID_CVS("$Id$"); ID_Copyright("(C) Tony Vincell"); #else diff --git a/src/dbuf.c b/src/dbuf.c index b6454a65b..e03621407 100644 --- a/src/dbuf.c +++ b/src/dbuf.c @@ -42,7 +42,6 @@ #ifdef USE_DMALLOC #include "h.h" #endif -ID_CVS("$Id$"); ID_Copyright("(C) 1990 Markku Savela"); ID_Notes("2.17 1/30/94 (C) 1990 Markku Savela"); #if !defined(VALLOC) && !defined(valloc) && !defined(USE_DMALLOC) @@ -313,7 +312,7 @@ int dbuf_getmsg(dyn, buf, length) while (length > 0 && dlen > 0) { dlen--; - if (*s == '\n' /* || *s == '\r' */) /*let stop at \n now .. */ + if (*s == '\n' /* || *s == '\r' */ ) /*let stop at \n now .. */ { copy = dyn->length - dlen; /* diff --git a/src/dynconf.c b/src/dynconf.c index d33fafc02..9ed3ee460 100644 --- a/src/dynconf.c +++ b/src/dynconf.c @@ -38,7 +38,6 @@ #include "h.h" #include "setup.h" -ID_CVS("$Id$"); ID_Copyright("(C) 1999-2000 Carsten Munk"); #define DoDebug fprintf(stderr, "[%s] %s | %li\n", babuf, __FILE__, __LINE__); diff --git a/src/fdmaxcounter.c b/src/fdmaxcounter.c index f0f38b7b1..73357c9ad 100644 --- a/src/fdmaxcounter.c +++ b/src/fdmaxcounter.c @@ -22,11 +22,11 @@ #include #include -main() +main() { - int i; - int s; - + int i; + int s; + for (i = 1; i <= 10000; i++) { s = socket(AF_INET, SOCK_STREAM, 0); @@ -36,4 +36,4 @@ main() exit(-1); } } -} \ No newline at end of file +} diff --git a/src/hash.c b/src/hash.c index 530cb6a51..9db7f5e7d 100644 --- a/src/hash.c +++ b/src/hash.c @@ -25,7 +25,6 @@ #include "hash.h" #include "h.h" -ID_CVS("$Id$"); ID_Copyright("(C) 1991 Darren Reed"); ID_Notes("2.10 7/3/93"); @@ -572,8 +571,8 @@ int hash_check_notify(cptr, reply) lp->value.cptr->name, cptr->name, (IsPerson(cptr) ? cptr->user->username : ""), (IsPerson(cptr) ? - (IsHidden(cptr) ? cptr->user->virthost : cptr->user-> - realhost) : ""), anptr->lasttime, cptr->info); + (IsHidden(cptr) ? cptr->user->virthost : cptr-> + user->realhost) : ""), anptr->lasttime, cptr->info); return 0; } diff --git a/src/help.c b/src/help.c index ed34edd90..d140ae85a 100644 --- a/src/help.c +++ b/src/help.c @@ -26,7 +26,6 @@ #include "sys.h" #include "h.h" -ID_CVS("$Id$"); ID_Copyright("DALnet & Techie"); ID_Notes("6.20 7/5/99"); @@ -96,7 +95,8 @@ int parse_help(sptr, name, help) } else if (!myncmp(help, "ABOUT", 8)) { - SND("Type /info for UnrealIRCd information -- Carsten Munk / Techie .. =)"); + SND + ("Type /info for UnrealIRCd information -- Carsten Munk / Techie .. =)"); } else if (!myncmp(help, "WATCH", 8)) { diff --git a/src/ircd.c b/src/ircd.c index b00bfc305..33b6d8b2d 100644 --- a/src/ircd.c +++ b/src/ircd.c @@ -61,7 +61,6 @@ Computing Center and Jarkko Oikarinen"; #endif #include "version.h" -ID_CVS("$Id$"); ID_Copyright ("(C) 1988 University of Oulu, Computing Center and Jarkko Oikarinen"); ID_Notes("2.48 3/9/94"); @@ -101,7 +100,7 @@ char REPORT_DO_SOCKS[128], REPORT_NO_SOCKS[128], REPORT_GOOD_SOCKS[128]; #endif #endif aClient me; /* That's me */ -char *me_hash; +char *me_hash; aClient *client = &me; /* Pointer to beginning of Client list */ extern char backupbuf[8192]; @@ -649,6 +648,8 @@ extern time_t check_pings(time_t currenttime, int check_kills) return (oldest); } + + /* ** bad_command ** This is called when the commandline is not acceptable. @@ -784,6 +785,9 @@ int InitwIRCD(argc, argv) #endif dpath = p; break; + case 'F': + bootopt |= BOOT_NOFORK; + break; #ifndef _WIN32 #ifdef CMDLINE_CONFIG case 'f': @@ -806,6 +810,17 @@ int InitwIRCD(argc, argv) (void)printf("sizeof(aClient) == %u\n", sizeof(aClient)); (void)printf("sizeof(aChannel) == %u\n", sizeof(aChannel)); (void)printf("sizeof(aServer) == %u\n", sizeof(aServer)); + (void)printf("sizeof(Link) == %u\n", sizeof(Link)); + (void)printf("sizeof(anUser) == %u\n", sizeof(anUser)); + (void)printf("sizeof(aConfItem) == %u\n", sizeof(aConfItem)); + (void)printf("sizeof(aVhost) == %u\n", sizeof(aVhost)); + (void)printf("sizeof(aTKline) == %u\n", sizeof(aTKline)); + + (void)printf("sizeof(struct ircstatsx) == %u\n", + sizeof(struct ircstatsx)); + (void)printf("aClient remote == %u\n", + CLIENT_REMOTE_SIZE); + exit(0); break; #ifndef _WIN32 @@ -997,6 +1012,8 @@ int InitwIRCD(argc, argv) (void)init_sys(); me.flags = FLAGS_LISTEN; me.fd = -1; + SetMe(&me); + make_server(&me); #ifdef USE_SYSLOG openlog(myargv[0], LOG_PID | LOG_NDELAY, LOG_FACILITY); @@ -1032,7 +1049,6 @@ int InitwIRCD(argc, argv) motd = (aMotd *) read_motd(MPATH); svsmotd = (aMotd *) read_svsmotd(VPATH); read_tlines(); - (void)setup_ping(); (void)get_my_name(&me, me.sockhost, sizeof(me.sockhost) - 1); if (me.name[0] == '\0') strncpyzt(me.name, me.sockhost, sizeof(me.name)); @@ -1045,16 +1061,15 @@ int InitwIRCD(argc, argv) #ifdef SOCKSPORT me.socksfd = -1; #endif - SetMe(&me); - make_server(&me); me_hash = find_or_add(me.name); me.serv->up = me_hash; - + add_server_to_table(&me); me.lasttime = me.since = me.firsttime = TStime(); (void)add_to_client_hash_table(me.name, &me); #if !defined(_AMIGA) && !defined(_WIN32) && !defined(NO_FORKING) - if (fork()) - exit(0); + if (!(bootopt & BOOT_NOFORK)) + if (fork()) + exit(0); #endif @@ -1087,10 +1102,9 @@ int InitwIRCD(argc, argv) #ifdef SOCKSPORT init_socks(&me); #endif - check_class(); write_pidfile(); - + Debug((DEBUG_NOTICE, "Server ready...")); #ifdef USE_SYSLOG syslog(LOG_NOTICE, "Server Ready"); @@ -1104,6 +1118,7 @@ int InitwIRCD(argc, argv) return 1; } + void SocketLoop(void *dummy) { time_t delay = 0, now; @@ -1162,7 +1177,7 @@ void SocketLoop(void *dummy) } if (do_garbage_collect == 1) do_garbage_collect = 0; - + last_garbage_collect = now; } /* diff --git a/src/list.c b/src/list.c index f62493ae2..dd6393ba9 100644 --- a/src/list.c +++ b/src/list.c @@ -48,7 +48,6 @@ void free_link PROTO((Link *)); Link *make_link PROTO(()); extern ircstats IRCstats; -ID_CVS("$Id$"); ID_Copyright ("(C) 1988 University of Oulu, Computing Center and Jarkko Oikarinen"); ID_Notes("2.24 4/20/94"); @@ -186,8 +185,7 @@ anUser *make_user(cptr) user->invited = NULL; user->silence = NULL; user->server = NULL; - user->virthost = MyMalloc(2); - *user->virthost = '\0'; + user->virthost = NULL; cptr->user = user; } return user; @@ -196,6 +194,7 @@ anUser *make_user(cptr) aServer *make_server(cptr) aClient *cptr; { + aServer *serv = cptr->serv; if (!serv) @@ -207,6 +206,7 @@ aServer *make_server(cptr) serv->user = NULL; serv->nexts = NULL; *serv->by = '\0'; + serv->numeric = 0; serv->up = NULL; cptr->serv = serv; } @@ -263,7 +263,10 @@ void remove_client_from_list(cptr) aClient *cptr; { if (IsServer(cptr)) + { + remove_server_from_table(cptr); IRCstats.servers--; + } if (IsClient(cptr)) { if (IsInvisible(cptr)) diff --git a/src/lusers.c b/src/lusers.c index 0b1116476..b6dbabaf8 100644 --- a/src/lusers.c +++ b/src/lusers.c @@ -41,7 +41,6 @@ #include #include "h.h" -ID_CVS("$Id$"); ID_Copyright("(C) Carsten Munk 2000"); ircstats IRCstats; diff --git a/src/match.c b/src/match.c index c33a1079b..f257b015f 100644 --- a/src/match.c +++ b/src/match.c @@ -22,7 +22,6 @@ #include "common.h" #include "sys.h" -ID_CVS("$Id$"); ID_Copyright("(C) 1990 Jarkko Oikarinen"); /* diff --git a/src/packet.c b/src/packet.c index 57d56410c..3538bfbc4 100644 --- a/src/packet.c +++ b/src/packet.c @@ -1,3 +1,4 @@ + /************************************************************************ * Unreal Internet Relay Chat Daemon, src/packet.c * Copyright (C) 1990 Jarkko Oikarinen and @@ -24,64 +25,65 @@ #include "msg.h" #include "h.h" -ID_CVS("$Id$"); ID_Copyright ("(C) 1988 University of Oulu, Computing Center and Jarkko Oikarinen"); ID_Notes("2.12 1/30/94"); #ifdef CRYPTOIRCD -char *ep_encrypt(aClient *cptr, char *string, int *len) +char *ep_encrypt(aClient *cptr, char *string, int *len) { - static unsigned char cryptobuffer[8192]; - char ivec[9]; - int length; - char *c; - int num; + static unsigned char cryptobuffer[8192]; + char ivec[9]; + int length; + char *c; + int num; if (!cptr->cryptinfo) return string; - + bzero(cryptobuffer, sizeof(cryptobuffer)); bzero(ivec, sizeof(ivec)); num = 0; - + if ((c = (char *)strchr(string, '\n'))) *c = '\0'; if ((c = (char *)strchr(string, '\r'))) - *c = '\0'; - + *c = '\0'; + length = strlen(string) + 1; - cryptobuffer[0] = (unsigned char) length / 256; - cryptobuffer[1] = (unsigned char) length - (cryptobuffer[0] * 256); - + cryptobuffer[0] = (unsigned char)length / 256; + cryptobuffer[1] = (unsigned char)length - (cryptobuffer[0] * 256); + if (cptr->cryptinfo->method == METHOD_BLOWFISH) { - BF_cfb64_encrypt(string, &cryptobuffer[2], length, cptr->cryptinfo->key, ivec, &num, BF_ENCRYPT); + BF_cfb64_encrypt(string, &cryptobuffer[2], length, + cptr->cryptinfo->key, ivec, &num, BF_ENCRYPT); *len = length + 2; return (cryptobuffer); } } -char *ep_decrypt(aClient *cptr, char *string) +char *ep_decrypt(aClient *cptr, char *string) { - static char decryptbuffer[8192]; - int num; - char ivec[9]; - int length; - + static char decryptbuffer[8192]; + int num; + char ivec[9]; + int length; + if (!cptr->cryptinfo) return string; - + bzero(decryptbuffer, sizeof(decryptbuffer)); bzero(ivec, sizeof(ivec)); num = 0; length = (*(string) * 256) + (*(string + 1)); - + if (cptr->cryptinfo->method == METHOD_BLOWFISH) { - BF_cfb64_encrypt(string + 2, decryptbuffer, length, cptr->cryptinfo->key, ivec, &num, BF_DECRYPT); - return (decryptbuffer); - } + BF_cfb64_encrypt(string + 2, decryptbuffer, length, + cptr->cryptinfo->key, ivec, &num, BF_DECRYPT); + return (decryptbuffer); + } } #endif /* @@ -129,7 +131,7 @@ int dopacket(cptr, buffer, length) #ifdef CRYPTOIRCD int lengthweneed, num, lengthbackup, li; char *s; - char f[4096], x[512]; + char f[4096], x[512]; #endif me.receiveB += length; /* Update bytes received */ @@ -163,36 +165,44 @@ int dopacket(cptr, buffer, length) *ch1 = *ch2++; if (ch1 - cptr->buffer > 2) { - lengthweneed = ((unsigned char) *cptr->buffer) * 256 - + ((unsigned char) *(cptr->buffer + 1)); + lengthweneed = + ((unsigned char)*cptr->buffer) * 256 + + ((unsigned char)*(cptr->buffer + 1)); lengthbackup = ch1 - cptr->buffer; if (lengthbackup >= (lengthweneed + 1)) { ch1 = cptr->buffer; cptr->count = 0; - Debug((DEBUG_ERROR, "packet recieved len %i", lengthweneed)); - s = (char *) ep_decrypt(cptr, cptr->buffer); + Debug((DEBUG_ERROR, + "packet recieved len %i", + lengthweneed)); + s = + (char *)ep_decrypt(cptr, + cptr->buffer); me.receiveM += 1; cptr->receiveM += 1; if (cptr->acpt != &me) cptr->acpt->receiveM += 1; - if (parse(cptr, s, s + lengthweneed, msgtab) == FLUSH_BUFFER) + if (parse(cptr, s, s + lengthweneed, + msgtab) == FLUSH_BUFFER) return FLUSH_BUFFER; if (cptr->flags & FLAGS_DEADSOCKET) - return exit_client(cptr, cptr, &me, "Dead socket"); - } - else - if (ch1 < cptr->buffer + (sizeof(cptr->buffer) - 1)) + return exit_client(cptr, cptr, + &me, "Dead socket"); + } + else + if (ch1 < + cptr->buffer + (sizeof(cptr->buffer) - 1)) ch1++; } else - if (ch1 < cptr->buffer + (sizeof(cptr->buffer) - 1)) - ch1++; - + if (ch1 < cptr->buffer + (sizeof(cptr->buffer) - 1)) + ch1++; + } - + } - else + else #endif while (--length >= 0) { @@ -201,7 +211,7 @@ int dopacket(cptr, buffer, length) * Yuck. Stuck. To make sure we stay backward compatible, * we must assume that either CR or LF terminates the message * and not CR-LF. By allowing CR or LF (alone) into the body - * of messages, backward compatibility is lost and major + * of messages, backward compatibility is lost and major * problems will arise. - Avalon */ if (g < '\16' && (g == '\n' || g == '\r')) @@ -233,10 +243,10 @@ int dopacket(cptr, buffer, length) "Dead Socket"); ch1 = cptr->buffer; } - else if (ch1 < cptr->buffer + (sizeof(cptr->buffer) - 1)) + else if (ch1 < + cptr->buffer + (sizeof(cptr->buffer) - 1)) ch1++; /* There is always room for the null */ } cptr->count = ch1 - cptr->buffer; return 0; } - diff --git a/src/parse.c b/src/parse.c index 3dae72899..7835680a3 100644 --- a/src/parse.c +++ b/src/parse.c @@ -30,7 +30,6 @@ Computing Center and Jarkko Oikarinen"; #include "struct.h" #include "common.h" -ID_CVS("$Id$"); ID_Copyright ("(C) 1988 University of Oulu, Computing Center and Jarkko Oikarinen"); ID_Notes("2.33 1/30/94"); @@ -54,6 +53,7 @@ static char sender[HOSTLEN + 1]; static int cancel_clients PROTO((aClient *, aClient *, char *)); static void remove_unknown PROTO((aClient *, char *)); static char unknownserver[] = "Unknown.Server"; +static char nsprefix = 0; /* ** Find a client (server or user) by name. ** @@ -70,13 +70,6 @@ aClient *find_client(name, cptr) if (name) { - if (*name == '@') - { - newname = name; - name = find_by_aln(name + 1); - if (!name) - name = newname; - } cptr = hash_find_client(name, cptr); } return cptr; @@ -113,49 +106,11 @@ aClient *find_server(name, cptr) char *newname; if (name) { - if (*name == '@') - { - newname = name; - name = find_by_aln(name + 1); - if (!name) - name = newname; - } cptr = hash_find_server(name, cptr); } return cptr; } -aClient *find_serveraln(name, cptr) - char *name; - aClient *cptr; -{ - char *newname; - if (name) - { - if (*name == '@') - { - newname = name; - name = find_by_aln(name + 1); - if (!name) - name = newname; - } - if (strlen(name) < 3) - { - newname = name; -#ifdef DEVELOP -// sendto_ops("Trying to find %s", name); -#endif - name = find_by_aln(name); - if (!name) - name = newname; - } - cptr = hash_find_client(name, cptr); -#ifdef DEVELOP -// (cptr) sendto_ops("Found it ! (%s)", cptr->name); -#endif - } - return cptr; -} aClient *find_name(name, cptr) char *name; @@ -200,11 +155,10 @@ aClient *find_person(name, cptr) return cptr; } -int alnprefix = 0; -void ban_flooder(aClient *cptr) +void ban_flooder(aClient *cptr) { - char hostip[128], mo[100], mo2[100]; + char hostip[128], mo[100], mo2[100]; char *tkllayer[9] = { me.name, /*0 server.name */ "+", /*1 +|- */ @@ -216,10 +170,10 @@ void ban_flooder(aClient *cptr) NULL, /*7 set_at */ NULL /*8 reason */ }; - - strcpy(hostip, (char *)inetntoa((char *) &cptr->ip)); + + strcpy(hostip, (char *)inetntoa((char *)&cptr->ip)); exit_client(cptr, cptr, &me, "Flooding"); - + tkllayer[4] = hostip; tkllayer[5] = me.name; ircsprintf(mo, "%li", 600 + TStime()); @@ -231,7 +185,7 @@ void ban_flooder(aClient *cptr) return; } -int Rha = 0; +int Rha = 0; /* * parse a buffer. @@ -261,27 +215,29 @@ int parse(cptr, buffer, bufend, mptr) #ifdef RAWDEBUG sendto_ops("Debug: parse(): %s", buffer); #endif - + if ((cptr->receiveK >= 4) && IsUnknown(cptr)) { - sendto_realops("Flood from unknown connection %s detected", cptr->sockhost); + sendto_realops("Flood from unknown connection %s detected", + cptr->sockhost); ban_flooder(cptr); return 0; } - - /* this call is a bit obsolete? - takes up CPU*/ + + /* this call is a bit obsolete? - takes up CPU */ backupbuf[0] = '\0'; strcpy(backupbuf, buffer); s = sender; *s = '\0'; - alnprefix = 0; for (ch = buffer; *ch == ' '; ch++) ; para[0] = from->name; if (*ch == ':' || *ch == '@') { if (*ch == '@') - alnprefix = 1; + nsprefix = 1; + else + nsprefix = 0; /* ** Copy the prefix to 'sender' assuming it terminates ** with SPACE (or NULL, which is an error, though). @@ -303,19 +259,21 @@ int parse(cptr, buffer, bufend, mptr) */ if (*sender && IsServer(cptr)) { - if ((strlen(sender) < 3) && alnprefix) + if (nsprefix) { - p = find_by_aln(sender); - if (p) - strcpy(sender, p); + from = (aClient *) find_server_by_base64(sender); + if (from) + para[0] = from->name; + } + else + { + from = find_client(sender, (aClient *)NULL); + if (!from || match(from->name, sender)) + from = find_server_quick(sender); + else if (!from && index(sender, '@')) + from = find_nickserv(sender, (aClient *)NULL); + para[0] = sender; } - from = find_client(sender, (aClient *)NULL); - if (!from || match(from->name, sender)) - from = find_server(sender, (aClient *)NULL); - else if (!from && index(sender, '@')) - from = find_nickserv(sender, (aClient *)NULL); - - para[0] = sender; /* Hmm! If the client corresponding to the * prefix is not found--what is the correct @@ -323,7 +281,7 @@ int parse(cptr, buffer, bufend, mptr) * (old IRC just let it through as if the * prefix just wasn't there...) --msa */ - + /* debugging tool */ if (Rha == 1) from = NULL; @@ -509,9 +467,9 @@ int parse(cptr, buffer, bufend, mptr) * unregistered users. -Studded */ if (IsShunned(cptr) && IsRegistered(cptr)) if ((mptr->func != m_admin) && (mptr->func != m_quit) - && (mptr->func != m_pong)) + && (mptr->func != m_pong)) return -4; - + if ((!IsRegistered(cptr)) && (((mptr->func != m_user) && (mptr->func != m_nick) && (mptr->func != m_server) && (mptr->func != m_pong) && @@ -532,9 +490,8 @@ int parse(cptr, buffer, bufend, mptr) } mptr->count++; - if (IsRegisteredUser(cptr) && - mptr->func == m_private) - from->user->last = TStime(); + if (IsRegisteredUser(cptr) && mptr->func == m_private) + from->user->last = TStime(); #ifndef DEBUGMODE return (*mptr->func) (cptr, from, i, para); @@ -734,12 +691,11 @@ static void remove_unknown(cptr, sender) * Do kill if it came from a server because it means there is a ghost * user on the other server which needs to be removed. -avalon */ - if (!index(sender, '.') && !alnprefix) + if (!index(sender, '.') && !nsprefix) sendto_one(cptr, ":%s KILL %s :%s (%s(?) <- %s)", me.name, sender, me.name, sender, get_client_name(cptr, FALSE)); else - sendto_one(cptr, ":%s SQUIT %s%s :(Unknown from %s)", - me.name, (alnprefix ? "@" : ""), sender, - get_client_name(cptr, FALSE)); + sendto_one(cptr, ":%s SQUIT %s :(Unknown from %s)", + me.name, sender, get_client_name(cptr, FALSE)); } diff --git a/src/res.c b/src/res.c index da0c2de22..a57d17d58 100644 --- a/src/res.c +++ b/src/res.c @@ -25,7 +25,6 @@ static char sccsid[] = "@(#)res.c 2.38 4/13/94 (C) 1992 Darren Reed"; #endif -ID_CVS("$Id$"); ID_Copyright("(C) 1992 Darren Reed"); ID_Notes("2.38 4/13/94"); diff --git a/src/res_comp.c b/src/res_comp.c index c927dc0da0d6e823caf100011fda583657b85e57..24b3f36315db7569891ad008c8af5abdf40e519e 100644 GIT binary patch literal 31 mcmZ?D%u6h)R7lIrNmVFHEsjsl&n?hPR>(~(NzOH48of literal 7568 zcmbtZYj4|D65X%Tub8^s=xNzb(QF$#K^5EC2Xa0V3VUyl2kL)j_v;&}~XrPLuR53m3~m+I~llzWeqY8JmTPi(Hbq6iXv- zCfib0c9a zd9u!Yqbsv8_Od$x#Z@j|W+XM)Dl7^UNSY-#VPFE%DwbaHRN6-!cehTOtP2lxi)EM# zL=Qp7uk?zOBDCB{$xl`*9O*0f_T!FhQwn20S_fgg5S1)6IS-_fcc-?PCsCB#Vw3UqDq71BpDD7q`?dFgGSjQfN0*f+X`P`}XC9$=;dB z+^MV~JmM#@HE5FMtrkrQ2a!gQ_-o4Gsi~7p5^Q9$@(PoMUZf(aG37Qama0l!Z_6N7 zrQlF6fWwP0rx`XRNFR>m;@o(}8vYh=qE9tapt#dhL*vqb6@*|6#onqswG~e>?z?S` zw_PQ{{*F@34EY37B=Bzl?LjT0omWYLn6dVTtDr3+Q0CYG;hIFMcd{->EKiLe&O;yf zLQuKQ7;mwSygY}BD*p72Nx_ zy6nsJ68W)X}kFB$diM||2p{YaPPSJCHwVboS_PFvDqA*U7!9iY43eC z3clLw95 zARSS`Bu$_sqdw8do|#3cDN`0xh?jc{)2BaM2H}h1*|L{%cV`}EIgFL~Hk-Y<(nA() zUw&_8+U4rWY(1Yt0&vX3{~BpUCSDZF7K^OP1Qpj&p@NSM@)!k~=WxDe0GqLy>>ml- z$wW4C>p{ai@aFj~rs$ITDTMh08vw1uPLr#K$OI9hG-4%qrwbEm+gMhwBce}n@|9lrB_MRK)l3p}l{Etgr`R*GhW9;uMg~JCVZ2Og=IC?yknhdV*;xu z!h0V-lJsZj^%ov}TzZpvK=ro5I7*TDZ5dBp0iY26r9yM*cJ6SyWydE_l@ z1+?Br_~0J`i<$E4A;XFy)Es)>nKn9H-g_TY*7{k%LmYMAXDrrH*^=d?O`w9UR;zKd3m9$ z=Z;ZkEz+YhLE1(G3aAX}F-u7qm>N}Za&Ei~AkSujB?bRXlpB1pa!@)Du{^C@y&hPQ zn--o@bP#4SW!U5f<2EZSkSEqbt;$s8LM=&rqr25hwU1OQ+bN^E?F+gl9Ik~(nsz#b z5er*1n>8H31yFARW(KMF=jvV6UuY8q7VSu$KexcOK}I!J!ySp_pYr&dCw9>h0+R|H zEy}@Q?5Bj2#ynZaL0@tY&=Ts*fjz2K#iLW2GZ1}tvI%+Ws$yG}=u&Nj{IrsbZY&+5 z&Z4&(xpgkQLNSy#(twVz*@a4jLZX%r5}a4^6bil0rp2*Lwf$iOW?7c_1SM3<%_TH4 zHBr@Z)zyxY1tyg~c!)^Z2Us^*)+DkM72wO{t1EraqbitlnKn^eDLXye&QTxDBF3va z4R*qmgQzbuFT{AbV7HlLfeph)Hgk?07bXUF4s)cXl<6115mLff5)*ZUr zWI@N7vurHf{!Z*y-NWQvm`Z}T8}vpFGPY;g0bb>_(ceHnN4$Xpha41$OzjF7?2zCp zakb3J?NcQkHrSrWSeqepeWoho0;?ySL+HfXY*d;|8%yA;_H%!CII^W7TX~W8;eCt^ z2p=|QnvrbJQMWLsXxQKz-rB-=ZTMCAc%n@qsf1Bv79hiSi|VrTO&JpRn|-~xneD2J z90tjQLF9rJpB=qV`r4ue;Q(Nc*9$mWXLf!2LT~JPv$7wH?&=|7J2Ey7wRlM8^W30z z^6`u*fQZ#P%BMCPBPGmfXM}dDM3e1z3l#$Iy^Jslp-&x5W-jd9z-v>c9VGY4X3554 z`3~itYFxjv4M2a^qu?a0>f-kEI}$!xAnn+0pzedjZYWnYbL=)B>H&7(WYY$GfQz?Z z8XRUIH%fM{V%8rDY-K9PtWT#y`B?BLuLYJ+8JmYs|0*RA_YY0#Sf(cUv*Q+wtMzx_ zfClS}1hB_95m@m4NrzfWVuNxUdca#WC0hPinJtAKnw!y`rPWpsi!ek}APkENNYt@G z8M@R`6hWNW_Mv3Hqsn$2pvE;RDA`|@2ApsVwKmvGyH5cRR|njs{F;rQnD(LIru|_J zp)s6C9QHc_>KbES#~)qv6h5j|9F?-dlrbJW@NBH3kR5Oia3%9FALYv=D-NP0UbHZi zyyjT$`93-?_FtKHJFGBChG+Tm4LIJ%&qs@xKPB+heioS(uIi5_euBvh^M7QJ*0RLN zgrdOv_%*`AFB^Dn!4x+$Y!Xs1_HdcCf=BeX0nBkZT57!8Mz)4D*VihdTrW(apV-%= z2q;$;`1N5Fqt)B)SjV2jBRXI}ZoKzRxJ%#u@L9_$-u5z#Y$oT>mZE!6cKZI|>PKEa z1iJ5d#iZ$E%{Oyx^lLj-Zr$Q@I_k`tC4zk@pLyUg=TZo%hdb>x-hR4h$@Mv*Bu>rA zlQ~ N%3~)V%JYxr{{X#;W|#l~ diff --git a/src/res_init.c b/src/res_init.c index be1c1c95a..9534f6398 100644 --- a/src/res_init.c +++ b/src/res_init.c @@ -34,7 +34,6 @@ static char sccsid[] = "@(#)res_init.c 6.14.1 (Berkeley) 6/27/90"; #include "nameser.h" #include "resolv.h" -ID_CVS("$Id$"); /* * Resolver state default settings */ diff --git a/src/res_mkquery.c b/src/res_mkquery.c index f5a5febea9f8c09c50b620801489f9663273f66c..50ee03433409e3db873f0b5c664531edb7f2c527 100644 GIT binary patch literal 34 pcmZ?D%u6h)R7lIrNmVFHEsoF4E-Xzgs? zl#E*HNLa~@OhdgQSX>wiwV+Jsh0Jpivx!WrI~j`@euVi6)sGvcZq+m&orkcS&!r)_ zE@3As<6=9h%4Kn2q!tToY1z~3Uo~jkl1!sy8OwA=)-x##Z^)8x#dbIyQ4}+U)JIH5;{{SVc?rA+)JhniO2svidwE)55{F~Rl$Bnzh^%$LBMa1vu`nIa9FDMLM^D}kfn1Sc&G7sakEKBdqvmo48A zBpa#52@h6uBlsNfKmp$v(ZibNJTFuZ&bWL7DnttgvWY3yU>j(Z9ubGGmN}VBL~<%4 z=t)?)*UY!nG0zx;Xqi2_@P{-UoR406L67kLIvD)mcY9r+>K9u7CAiYpvM#Fa41>@&{Kf8eQNh zr^XgGnlw14%U;mAfFbXd-}gsv?CIzJ=!#D~9|YvlwHJ*1&baRdbUhBP2g4qR(yrB> z$tjXEm8pp9eg9QwGVFAQ4SN2ZJ}$_k0@fW*|(^}Co&(W-Gomd~4{G1cC3d@^7pfplrd2QrxYue+iWs);( z4~`uwm3-D!)}okwY*Cbi#>%eV zi&Sh6wLo#QcPyGsYu;^&)q?w_txDctEmY1uWlQ#NiyXUBhPkR*gmcayC(`zGEh433 z>$cr!EprfX)osO>8Cnps#$vk(Q-a&2hB7s6h}HpogN$bbEfgq)`J*Y!GVrV71ajdF zo4YWy8iKBf8uX**OIcU42r39VydSAppc zdQ+ND>$_Ewd>OasOHjjp#*LrT-4^hEj5r{xE5jYsp|!~{6MiuD?I-uAROT2C%+a|B z(K~4>MG}L?#g0OSU9BTobaqBp<9@$EzyD4wKt|~WaXQts?()`Xu=AM5r~#@U9K(^F zo8N?1yubBuFBaz++DoBK%?4B3N)KMj7%TG}xvB5(+f>Pz&CRoemj%nunD$PRX}0r7 zMy~_^(hJ@+=<_o=DmH_mk8cioopCViZEv;(h0q7RAQ%KN5wXvlko^Y%VXa8Z!P%de zzzOJCIvDI^j_mI{OVvL)#rS(oowd&9IA^0l?eY*Oczg7Y6J#OA zFz3=4aAsN<48~|q=t02lJ%b;G7_i@ud%>F%ph;9RfB{Ej-=F(G_PWEL8bJSu@y3>I z$V;8nIzK^A&FW=)17Tf~n7CXsEn3Ig_@GJTegDjs9PDor%{2%Cs@}|%&g-soMj7V< za;H_WbUCqmilwzm(fj_24%6?~I8sYgf5}fv^CD&ikdY!z9@mL&a%JJTRNZJ1-a6kH zD(ImYFT-2D5##O^qbgMz;$H1~Dfd54V1n_7d$jA_s8Op2`0%;OMGzF&IQtg3EfDNH zi9R_7qY2X(!|W5G0OS&t&gw@`AHnMnasI&eDlZu0P(O}wf!?}I{7Ri{;H>o4Fg5q+ ztwuzQ-xh8RPl4SFI!1l3;luZ0YCct8&B%3+y`PWv+_+Q)H#Tz})L2ve(^kbt;!(u- zG>BDHI9rvZ5WPn-nf?6Mvny<8eOt2FW7*Yzq3Fuu4~v3DIsGuo#nATp{lV+W_`2(j zdPA$cfg0CAax0hZ;?si@st|SyVb?33j_&2>c6tRJs2;dt$L$4g9edr8*ofzgdv7`= zegkTO*Jxy4ocvx}nAssygqw(+*S2>TexQ37&AfE%r1n76bsc^a&Ir#nTsqKlaE;{N z<5au$CRlv;*fD;%8QfS;`Dv!hKq5RK?b-qlXTFf()tIbK%10N!r}^4fF?@>B!2b=_ z7UT@i!g3!lF9sJfP*L(K4R9;OuIB=Jq$O@@>Z#^fT)_XK?)d-Gd$RQGTym4Lpp?5* zZizg5mt2?mW952O7I|f+y5hzIrkCIrQxLyWnFf7Q;~?Cx)kBthTtp8l#5>{FkQc}N z`r^{qdg*Y{aSw90VO)+LY2p84y4e@h!Am{)h?c+B{Tnx;kL>;Hqxfp}*C)W1n(KU9 zb6~yBeZ~!hwTMqD8B<&)`9aOO;-&vK930yKw!6Sp{?oBFA8aEA3(G4pPC8(M;N(AQ HpVj^YMconfs, cptr->name, CONF_CONNECT_SERVER); @@ -963,8 +962,9 @@ static int completed_connection(cptr) return -1; } sendto_one(cptr, "PROTOCTL %s", PROTOCTL_SERVER); - sendto_one(cptr, "SERVER %s 1 :%s", - my_name_for_link(me.name, aconf), me.info); + sendto_one(cptr, "SERVER %s 1 :U%d-%s-%i %s", + my_name_for_link(me.name, aconf), UnrealProtocol, serveropts, me.serv->numeric, + me.info); if (!IsDead(cptr)) start_auth(cptr); @@ -1805,8 +1805,6 @@ int read_message(delay, listp) if (me.socksfd >= 0) FD_SET(me.socksfd, &read_set); #endif - if (udpfd >= 0) - FD_SET(udpfd, &read_set); #ifndef _WIN32 if (resfd >= 0) FD_SET(resfd, &read_set); @@ -1859,13 +1857,6 @@ int read_message(delay, listp) FD_CLR(me.socksfd, &read_set); } #endif /* SOCKSPORT */ - - if (udpfd >= 0 && FD_ISSET(udpfd, &read_set)) - { - polludp(); - nfds--; - FD_CLR(udpfd, &read_set); - } #ifndef _WIN32 if (resfd >= 0 && FD_ISSET(resfd, &read_set)) { @@ -2514,7 +2505,7 @@ int connect_server(aconf, by, hp) Debug((DEBUG_NOTICE, "Connect to %s[%s] @%s", aconf->name, aconf->host, inetntoa((char *)&aconf->ipnum))); - if ((c2ptr = find_server(aconf->name, NULL))) + if ((c2ptr = find_server_quick(aconf->name))) { sendto_ops("Server %s already present from %s", aconf->name, get_client_name(c2ptr, TRUE)); @@ -2981,141 +2972,6 @@ void get_my_name(cptr, name, len) return; } -/* -** setup a UDP socket and listen for incoming packets -*/ -int setup_ping() -{ - struct SOCKADDR_IN from; - int on = 1; - - bzero((char *)&from, sizeof(from)); - from.SIN_ADDR = me.ip; - from.SIN_PORT = htons(7007); - from.SIN_FAMILY = AFINET; - - if ((udpfd = socket(AFINET, SOCK_DGRAM, 0)) == -1) - { -#ifndef _WIN32 - Debug((DEBUG_ERROR, "socket udp : %s", strerror(errno))); -#else - Debug((DEBUG_ERROR, "socket udp : %s", - strerror(WSAGetLastError()))); -#endif - return -1; - } - if (setsockopt(udpfd, SOL_SOCKET, SO_REUSEADDR, - (OPT_TYPE *)&on, sizeof(on)) == -1) - { -#ifdef USE_SYSLOG - syslog(LOG_ERR, "setsockopt udp fd %d : %m", udpfd); -#endif -#ifndef _WIN32 - Debug((DEBUG_ERROR, "setsockopt so_reuseaddr : %s", - strerror(errno))); - (void)close(udpfd); -#else - Debug((DEBUG_ERROR, "setsockopt so_reuseaddr : %s", - strerror(WSAGetLastError()))); - (void)closesocket(udpfd); -#endif - udpfd = -1; - return -1; - } - on = 0; - (void)setsockopt(udpfd, SOL_SOCKET, SO_BROADCAST, - (char *)&on, sizeof(on)); - if (bind(udpfd, (struct SOCKADDR *)&from, sizeof(from)) == -1) - { -#ifdef USE_SYSLOG - syslog(LOG_ERR, "bind udp.%d fd %d : %m", from.SIN_PORT, udpfd); -#endif -#ifndef _WIN32 - Debug((DEBUG_ERROR, "bind : %s", strerror(errno))); - (void)close(udpfd); -#else - Debug((DEBUG_ERROR, "bind : %s", strerror(WSAGetLastError()))); - (void)closesocket(udpfd); -#endif - udpfd = -1; - return -1; - } -#ifndef _WIN32 - if (fcntl(udpfd, F_SETFL, FNDELAY) == -1) - { - Debug((DEBUG_ERROR, "fcntl fndelay : %s", strerror(errno))); - (void)close(udpfd); - udpfd = -1; - return -1; - } -#endif - return udpfd; -} - -/* - * max # of pings set to 15/sec. - */ -static void polludp() -{ - char *s; - struct SOCKADDR_IN from; - int n, fromlen = sizeof(from); - static time_t last = 0, now; - static int cnt = 0, mlen = 0; - - /* - * find max length of data area of packet. - */ - if (!mlen) - { - mlen = sizeof(readbuf) - strlen(me.name) - strlen(version); - mlen -= 6; - if (mlen < 0) - mlen = 0; - } - Debug((DEBUG_DEBUG, "udp poll")); - - n = recvfrom(udpfd, readbuf, mlen, 0, - (struct SOCKADDR *)&from, &fromlen); - now = TStime(); - if (now == last) - if (++cnt > 14) - return; - cnt = 0; - last = now; - - if (n == -1) - { -#ifndef _WIN32 - if ((errno == EWOULDBLOCK) || (errno == EAGAIN)) -#else - if ((WSAGetLastError() == WSAEWOULDBLOCK)) -#endif - return; - else - { - report_error("udp port recvfrom (%s): %s", &me); - return; - } - } - ircstp->is_udp++; - if (n < 19) - return; - - s = readbuf + n; - /* - * attach my name and version for the reply - */ - *readbuf |= 1; - (void)strcpy(s, me.name); - s += strlen(s) + 1; - (void)strcpy(s, version); - s += strlen(s); - (void)sendto(udpfd, readbuf, s - readbuf, 0, - (struct SOCKADDR *)&from, sizeof(from)); - return; -} - /* * do_dns_async * diff --git a/src/s_conf.c b/src/s_conf.c index 67f2dce22..581ceae7d 100644 --- a/src/s_conf.c +++ b/src/s_conf.c @@ -1,3 +1,4 @@ +/* /* * Unreal Internet Relay Chat Daemon, src/s_conf.c * Copyright (C) 1990 Jarkko Oikarinen and @@ -53,7 +54,6 @@ Computing Center and Jarkko Oikarinen"; #include #endif -ID_CVS("$Id$"); ID_Notes("O:line flags in here"); #include "h.h" #define IN6ADDRSZ (sizeof(struct IN_ADDR)) @@ -64,7 +64,7 @@ static int advanced_check(char *, int); aSqlineItem *sqline = NULL; aConfItem *conf = NULL; extern char zlinebuf[]; - +extern ircstats IRCstats; /* * remove all conf entries from the client except those which match * the status field mask. @@ -839,28 +839,53 @@ aSqlineItem *find_sqline_match(nickname) ** parv[2] = +/- ** */ + +int SVSNOOP = 0; + int m_svsnoop(cptr, sptr, parc, parv) aClient *cptr, *sptr; int parc; char *parv[]; { aConfItem *aconf; + aClient *acptr; if (!(check_registered(sptr) && IsULine(cptr, sptr) && parc > 2)) return 0; -/* svsnoop bugfix --binary */ + /* svsnoop bugfix --binary */ if (hunt_server(cptr, sptr, ":%s SVSNOOP %s :%s", 1, parc, parv) == HUNTED_ISME) { if (parv[2][0] == '+') - for (aconf = conf; aconf; aconf = aconf->next) + { + SVSNOOP = 1; + sendto_ops("This server has been placed in NOOP mode"); + for (acptr = &me; acptr; acptr = acptr->prev) { - if (aconf->status & CONF_OPERATOR - || aconf->status & CONF_LOCOP) - aconf->status = CONF_ILLEGAL; + if (MyClient(acptr) && IsAnOper(acptr)) + { + if (IsOper(acptr)) + IRCstats.operators--; + acptr->umodes &= + ~(UMODE_OPER | UMODE_LOCOP | UMODE_HELPOP | UMODE_SERVICES | + UMODE_SADMIN | UMODE_ADMIN); + acptr->umodes &= + ~(UMODE_NETADMIN | UMODE_TECHADMIN | UMODE_CLIENT | + UMODE_FLOOD | UMODE_EYES | UMODE_CHATOP | UMODE_WHOIS); + acptr->umodes &= + ~(UMODE_KIX | UMODE_FCLIENT | UMODE_HIDING | UMODE_CODER | + UMODE_DEAF | UMODE_HIDEOPER); + acptr->oflag = 0; + + } } + + } else - (void)rehash(&me, &me, 2); + { + SVSNOOP = 0; + sendto_ops("This server is no longer in NOOP mode"); + } } } @@ -1309,8 +1334,28 @@ int initconf(opt) else aconf->port = atoi(tmp); if ((tmp = getfield(NULL)) == NULL) + { break; + } Class(aconf) = find_class(atoi(tmp)); + if (aconf->status == CONF_ME) + { + if (me.serv->numeric) + { + if (atoi(tmp) != me.serv->numeric) + { + if (IRCstats.servers > 1) + { + sendto_ops("You cannot change numeric when servers are connected"); + } + else + { + me.serv->numeric = atoi(tmp); + } + } + } else + me.serv->numeric = atoi(tmp); + } break; } /* @@ -1477,6 +1522,10 @@ int initconf(opt) if (aconf->status == CONF_ME) { strncpyzt(me.info, aconf->name, sizeof(me.info)); + if (me.name[0] == '\0' && !strchr(aconf->host, '.')) { + ircd_log("ERROR: Invalid Server Name %s, Reason: Servername must contain at least one \".\"\n",aconf->host); + exit(-1); + } if (me.name[0] == '\0' && aconf->host[0]) strncpyzt(me.name, aconf->host, sizeof(me.name)); diff --git a/src/s_debug.c b/src/s_debug.c index c440637d3..86531a547 100644 --- a/src/s_debug.c +++ b/src/s_debug.c @@ -1,5 +1,4 @@ -/************************************************************************ -/************************************************************************ +/* * Unreal Internet Relay Chat Daemon, src/s_debug.c * Copyright (C) 1990 Jarkko Oikarinen and * University of Oulu, Computing Center @@ -106,6 +105,8 @@ char serveropts[] = { #ifdef CRYPTOIRCD 'r', #endif +/* we are a stable ircd */ + 'S', '\0' }; @@ -153,7 +154,6 @@ char serveropts[] = { #define ssize_t unsigned int #endif -ID_CVS("$Id$"); #ifdef DEBUGMODE static char debugbuf[1024]; diff --git a/src/s_err.c b/src/s_err.c index 742ef87ed..606e1f381 100644 --- a/src/s_err.c +++ b/src/s_err.c @@ -1,5 +1,4 @@ -/************************************************************************ -/************************************************************************ +/* * Unreal Internet Relay Chat Daemon, src/s_err.c * Copyright (C) 1992 Darren Reed * @@ -26,7 +25,6 @@ static char sccsid[] = "@(#)s_err.c 1.12 11/1/93 (C) 1992 Darren Reed"; #endif -ID_CVS("$Id$"); /* Redone to be similar to bahamut's s_err.c -- codemastr */ @@ -36,8 +34,8 @@ static char *replies[] = { /* 002 RPL_YOURHOST */ ":%s 002 %s :Your host is %s, running version %s", /* 003 RPL_CREATED */ ":%s 003 %s :This server was created %s", /* 004 RPL_MYINFO */ ":%s 004 %s %s %s %s %s", -/* 005 RPL_PROTOCTL */ ":%s 005 %s %s :are available on this server", -/* 006 RPL_MAP */ ":%s 006 %s :%s%-*s\2[Users:%5d] [%2d%%]\2", +/* 005 RPL_PROTOCTL */ PROTOCTL_CLIENT, +/* 006 RPL_MAP */ ":%s 006 %s :%s%-*s(%d) %s", /* 007 RPL_MAPEND */ ":%s 007 %s :End of /MAP", /* 008 */ NULL, /* 009 */ NULL, @@ -1067,6 +1065,3 @@ char *getreply(int numeric) { else return(replies[numeric]); } - -/* this was the old RPL_MYINFO line .... - RPL_MYINFO, "%s %s oiwsghOkcSNfraAbexTCWq biklmnopstvRzqxOAqa", */ diff --git a/src/s_extra.c b/src/s_extra.c index 5fe0ed742..0de4ae5c4 100644 --- a/src/s_extra.c +++ b/src/s_extra.c @@ -1,7 +1,6 @@ -/************************************************************************ -/************************************************************************ +/* * Unreal Internet Relay Chat Daemon, src/s_extra.c - * (C) 1999 Carsten Munk (Techie/Stskeeps) + * (C) 1999-2000 Carsten Munk (Techie/Stskeeps) * * See file AUTHORS in IRC package for additional names of * the programmers. @@ -42,7 +41,6 @@ #include #include "h.h" -ID_CVS("$Id$"); ID_Copyright("(C) Carsten Munk 1999"); /* diff --git a/src/s_kline.c b/src/s_kline.c index 863e97b95..07fe2da08 100644 --- a/src/s_kline.c +++ b/src/s_kline.c @@ -255,7 +255,7 @@ int find_tkline_match(cptr, xx) nowtime = TStime(); chost = cptr->sockhost; - cname = cptr->user->username; + cname = (xx != 2) ? cptr->user->username : NULL; cip = (char *)inet_ntoa(cptr->ip); @@ -267,13 +267,12 @@ int find_tkline_match(cptr, xx) else is_ip = 0; - if (is_ip == 0 ? (!match(lp->hostmask, chost) - && !match(lp->usermask, cname)) : (!match(lp->hostmask, - chost) || !match(lp->hostmask, cip)) - && !match(lp->usermask, cname) && (xx != 2 || !match(lp->usermask, cname))) + if (xx != 2 ? is_ip == 0 ? (!match(lp->hostmask, chost) + && !match(lp->usermask, cname)) : + (!match(lp->hostmask, chost) || !match(lp->hostmask, cip)) + : !match(lp->hostmask, chost)) { - - if ((lp->type & (TKL_KILL)) && (xx != 2)) + if (lp->type & TKL_KILL) { if (lp->type & TKL_GLOBAL) { diff --git a/src/s_misc.c b/src/s_misc.c index 1acb8a530..0c804d5ec 100644 --- a/src/s_misc.c +++ b/src/s_misc.c @@ -1,5 +1,5 @@ -/************************************************************************ -/************************************************************************ + +/* * Unreal Internet Relay Chat Daemon, src/s_misc.c * Copyright (C) 1990 Jarkko Oikarinen and * University of Oulu, Computing Center @@ -63,7 +63,6 @@ extern float currentrate2; extern ircstats IRCstats; extern char *me_hash; -ID_CVS("$Id$"); static void exit_one_client PROTO((aClient *, aClient *, aClient *, char *)); static void exit_one_client_in_split PROTO((aClient *, aClient *, aClient *, char *)); @@ -303,7 +302,7 @@ char *get_client_host(cptr) return get_client_name(cptr, FALSE); (void)ircsprintf(nbuf, "%s[%-.*s@%-.*s]", cptr->name, USERLEN, - (!(cptr->flags & FLAGS_GOTID)) ? "" : cptr->username, + (!(cptr->flags & FLAGS_GOTID)) ? "" : cptr->username, HOSTLEN, cptr->hostp->h_name); return nbuf; } diff --git a/src/s_numeric.c b/src/s_numeric.c index 1ec114d79..78d9fd301 100644 --- a/src/s_numeric.c +++ b/src/s_numeric.c @@ -1,5 +1,4 @@ -/************************************************************************ -/************************************************************************ +/* * Unreal Internet Relay Chat Daemon, src/s_numeric.c * Copyright (C) 1990 Jarkko Oikarinen * @@ -32,7 +31,6 @@ Computing Center and Jarkko Oikarinen"; #include "numeric.h" #include "h.h" -ID_CVS("$Id$"); static char buffer[1024]; diff --git a/src/s_serv.c b/src/s_serv.c index 77c1e6f28..175957e41 100644 --- a/src/s_serv.c +++ b/src/s_serv.c @@ -48,7 +48,6 @@ static char sccsid[] = #include #include "h.h" -ID_CVS("$Id$"); static char buf[BUFSIZE]; @@ -152,11 +151,17 @@ int m_version(cptr, sptr, parc, parv) if (hunt_server(cptr, sptr, ":%s VERSION :%s", 1, parc, parv) == HUNTED_ISME) - + { sendto_one(sptr, rpl_str(RPL_VERSION), me.name, parv[0], version, ircnetwork, debugmode, me.name, serveropts, (IsAnOper(sptr) ? MYOSNAME : "*"), UnrealProtocol, x); + if (MyClient(sptr)) + { + sendto_one(sptr, rpl_str(RPL_PROTOCTL), me.name, + sptr->name, PROTOCTL_PARAMETERS); + } + } return 0; } @@ -195,33 +200,47 @@ int m_squit(cptr, sptr, parc, parv) if (parc > 1) { - server = parv[1]; - /* - ** To accomodate host masking, a squit for a masked server - ** name is expanded if the incoming mask is the same as - ** the server name for that link to the name of link. - */ - while ((*server == '*') && IsServer(cptr)) + if (!(*parv[1] == '@')) { - aconf = cptr->serv->nline; - if (!aconf) - break; - if (!mycmp(server, my_name_for_link(me.name, aconf))) - server = cptr->name; - break; /* WARNING is normal here */ + server = parv[1]; + /* + ** To accomodate host masking, a squit for a masked server + ** name is expanded if the incoming mask is the same as + ** the server name for that link to the name of link. + */ + while ((*server == '*') && IsServer(cptr)) + { + aconf = cptr->serv->nline; + if (!aconf) + break; + if (!mycmp(server, my_name_for_link(me.name, aconf))) + server = cptr->name; + break; /* WARNING is normal here */ + } + + /* + ** The following allows wild cards in SQUIT. Only usefull + ** when the command is issued by an oper. + */ + for (acptr = client; (acptr = next_client(acptr, server)); + acptr = acptr->next) + if (IsServer(acptr) || IsMe(acptr)) + break; + if (acptr && IsMe(acptr)) + { + acptr = cptr; + server = cptr->sockhost; + } } - /* - ** The following allows wild cards in SQUIT. Only usefull - ** when the command is issued by an oper. - */ - for (acptr = client; (acptr = next_client(acptr, server)); - acptr = acptr->next) - if (IsServer(acptr) || IsMe(acptr)) - break; - if (acptr && IsMe(acptr)) + else { - acptr = cptr; - server = cptr->sockhost; + server = parv[1]; + acptr = (aClient *) find_server_by_base64(server + 1); + if (acptr && IsMe(acptr)) + { + acptr = cptr; + server = cptr->sockhost; + } } } else @@ -336,7 +355,7 @@ int m_protoctl(cptr, sptr, parc, parv) { int i; #ifndef PROTOCTL_MADNESS - int remove = 0; + int remove = 0; #endif char proto[128], *s; /* static char *dummyblank = ""; Yes, it is kind of ugly */ @@ -361,7 +380,8 @@ int m_protoctl(cptr, sptr, parc, parv) proto[127] = '\0'; /* Just to be safe... */ s = proto; #ifndef PROTOCTL_MADNESS - if (*s == '-') { + if (*s == '-') + { s++; remove = 1; } @@ -380,7 +400,8 @@ int m_protoctl(cptr, sptr, parc, parv) if (strcmp(s, "NOQUIT") == 0) { #ifndef PROTOCTL_MADNESS - if (remove) { + if (remove) + { ClearNoQuit(cptr); continue; } @@ -388,12 +409,13 @@ int m_protoctl(cptr, sptr, parc, parv) Debug((DEBUG_ERROR, "Chose protocol %s for link %s", proto, cptr->name)); SetNoQuit(cptr); - + } else if (strcmp(s, "TOKEN") == 0) { #ifndef PROTOCTL_MADNESS - if (remove) { + if (remove) + { ClearToken(cptr); continue; } @@ -405,7 +427,8 @@ int m_protoctl(cptr, sptr, parc, parv) else if (strcmp(s, "HCN") == 0) { #ifndef PROTOCTL_MADNESS - if (remove) { + if (remove) + { ClearHybNotice(cptr); continue; } @@ -417,7 +440,8 @@ int m_protoctl(cptr, sptr, parc, parv) else if (strcmp(s, "SJOIN") == 0) { #ifndef PROTOCTL_MADNESS - if (remove) { + if (remove) + { ClearSJOIN(cptr); continue; } @@ -429,7 +453,8 @@ int m_protoctl(cptr, sptr, parc, parv) else if (strcmp(s, "SJOIN2") == 0) { #ifndef PROTOCTL_MADNESS - if (remove) { + if (remove) + { ClearSJOIN2(cptr); continue; } @@ -441,7 +466,8 @@ int m_protoctl(cptr, sptr, parc, parv) else if (strcmp(s, "NICKv2") == 0) { #ifndef PROTOCTL_MADNESS - if (remove) { + if (remove) + { ClearNICKv2(cptr); continue; } @@ -453,7 +479,8 @@ int m_protoctl(cptr, sptr, parc, parv) else if (strcmp(s, "UMODE2") == 0) { #ifndef PROTOCTL_MADNESS - if (remove) { + if (remove) + { ClearUMODE2(cptr); continue; } @@ -463,23 +490,25 @@ int m_protoctl(cptr, sptr, parc, parv) proto, cptr->name)); SetUMODE2(cptr); } - else if (strcmp(s, "ALN") == 0) + else if (strcmp(s, "NS") == 0) { #ifdef PROTOCTL_MADNESS - if (remove) { - ClearALN(cptr); + if (remove) + { + ClearNS(cptr); continue; } #endif Debug((DEBUG_ERROR, "Chose protocol %s for link %s", proto, cptr->name)); - SetALN(cptr); + SetNS(cptr); } else if (strcmp(s, "VL") == 0) { #ifndef PROTOCTL_MADNESS - if (remove) { + if (remove) + { ClearVL(cptr); continue; } @@ -492,7 +521,8 @@ int m_protoctl(cptr, sptr, parc, parv) else if (strcmp(s, "VHP") == 0) { #ifndef PROTOCTL_MADNESS - if (remove) { + if (remove) + { ClearVHP(cptr); continue; } @@ -505,7 +535,8 @@ int m_protoctl(cptr, sptr, parc, parv) else if (strcmp(s, "SJ3") == 0) { #ifndef PROTOCTL_MADNESS - if (remove) { + if (remove) + { ClearSJ3(cptr); continue; } @@ -528,6 +559,7 @@ int m_protoctl(cptr, sptr, parc, parv) return 0; } +char *num = NULL; /* ** m_server @@ -547,8 +579,9 @@ int m_server(cptr, sptr, parc, parv) char pp[512]; aClient *acptr, *bcptr; aConfItem *aconf, *cconf; - int hop, ts = 0; - char *parvaln, *flags, *protocol, *inf; + int hop, numeric = 0; + int ts = 0; + char *flags = NULL, *protocol = NULL, *inf = NULL; info[0] = '\0'; inpath = get_client_name(cptr, FALSE); @@ -561,7 +594,7 @@ int m_server(cptr, sptr, parc, parv) host = parv[1]; if (parc > 4) { - ts = atoi(parv[3]); + numeric = atoi(parv[3]); hop = atoi(parv[2]); (void)strncpy(info, parv[4], REALLEN); info[REALLEN] = '\0'; @@ -632,11 +665,12 @@ int m_server(cptr, sptr, parc, parv) aconf = find_conf_servern(host); if (!aconf) { - sendto_one(cptr,"ERROR :No Access (No matching N:line) %s", - inpath); - sendto_locfailops("Access denied (No matching N:line) %s", - inpath); - return exit_client(cptr, cptr, cptr, "No matching N:line"); + sendto_one(cptr, + "ERROR :No Access (No matching N:line) %s", inpath); + sendto_locfailops + ("Access denied (No matching N:line) %s", inpath); + return exit_client(cptr, cptr, cptr, + "No matching N:line"); } #ifdef CRYPT_LINK_PASSWORD /* use first two chars of the password they send in as salt */ @@ -667,14 +701,6 @@ int m_server(cptr, sptr, parc, parv) } /* bzero(cptr->passwd, sizeof(cptr->passwd)); */ } - f = (char *) does_servername_collide(parv[1]); - if (f) - { - ircsprintf(pp, "Servername %s collides with servername %s (similar hash). Change servername in some way (maybe change case)", - parv[1], f); - sendto_realops("Link %s cancelled - %s", inpath, pp); - return exit_client(cptr, cptr, cptr, pp); - } if ((acptr = find_name(host, NULL))) { aClient *ocptr; @@ -698,6 +724,7 @@ int m_server(cptr, sptr, parc, parv) (ocptr->from ? ocptr->from->name : "")); return exit_client(acptr, acptr, acptr, "Server Exists"); } + if ((acptr = find_client(host, NULL))) { /* @@ -710,13 +737,11 @@ int m_server(cptr, sptr, parc, parv) ("Link %s cancelled: Server/nick collision on %s", inpath, host); sendto_serv_butone(&me, - ":%s GLOBOPS : Link %s cancelled: Server/nick collision on %s", + ":%s GLOBOPS :Link %s cancelled: Server/nick collision on %s", parv[0], inpath, host); return exit_client(cptr, cptr, cptr, "Nick as Server"); } - - if (IsServer(cptr)) { /* @@ -785,21 +810,31 @@ int m_server(cptr, sptr, parc, parv) return exit_client(cptr, cptr, cptr, "Q-Lined Server"); } - acptr = make_client(cptr, find_server(parv[0], NULL)); + if (numeric_collides(numeric)) + { + return exit_client(cptr, cptr, cptr, + "Colliding server numeric (choose another in the M:line)"); + } + + acptr = make_client(cptr, find_server_quick(parv[0])); (void)make_server(acptr); + acptr->serv->numeric = numeric; acptr->hopcount = hop; strncpyzt(acptr->name, host, sizeof(acptr->name)); strncpyzt(acptr->info, info, sizeof(acptr->info)); acptr->serv->up = find_or_add(parv[0]); SetServer(acptr); /* Taken from bahamut makes it so all servers behind a U:lined - * server are also U:lined, very helpful if HIDE_ULINES is on - */ - if (IsULine(sptr,sptr) || (find_uline(cptr->confs, acptr->name))) + * server are also U:lined, very helpful if HIDE_ULINES is on + */ + if (IsULine(sptr, sptr) + || (find_uline(cptr->confs, acptr->name))) acptr->flags |= FLAGS_ULINE; + add_server_to_table(acptr); IRCstats.servers++; (void)find_or_add(acptr->name); acptr->flags |= FLAGS_TS8; + add_client_to_list(acptr); (void)add_to_client_hash_table(acptr->name, acptr); /* @@ -807,7 +842,6 @@ int m_server(cptr, sptr, parc, parv) ** need to send different names to different servers ** (domain name matching) */ - parvaln = (char *)find_server_aln(parv[0]); for (i = 0; i <= highest_fd; i++) { if (!(bcptr = local[i]) || !IsServer(bcptr) || @@ -823,18 +857,23 @@ int m_server(cptr, sptr, parc, parv) if (match(my_name_for_link(me.name, aconf), acptr->name) == 0) continue; - if (ts) - sendto_one(bcptr, "%c%s %s %s %d %d :%s", - SupportALN(bcptr) ? '@' : ':', - SupportALN(bcptr) ? parvaln : parv[0], - IsToken(bcptr) ? TOK_SERVER : MSG_SERVER, - acptr->name, hop + 1, ts, acptr->info); - else - sendto_one(bcptr, "%c%s %s %s %d :%s", - SupportALN(bcptr) ? '@' : ':', - SupportALN(bcptr) ? parvaln : parv[0], + + if (SupportNS(bcptr)) + { + sendto_one(bcptr, + "%c%s %s %s %d %i :%s", + (sptr->serv->numeric ? '@' : ':'), + (sptr->serv->numeric ? base64enc(sptr->serv->numeric) : sptr->name), + IsToken(bcptr) ? TOK_SERVER : MSG_SERVER, + acptr->name, hop + 1, numeric, acptr->info); + } + else + { + sendto_one(bcptr, ":%s %s %s %d :%s", + parv[0], IsToken(bcptr) ? TOK_SERVER : MSG_SERVER, acptr->name, hop + 1, acptr->info); + } } return 0; } @@ -848,7 +887,8 @@ int m_server(cptr, sptr, parc, parv) */ strncpyzt(cptr->name, host, sizeof(cptr->name)); /* For now, just strip the VL stuff if it's there */ - if (SupportVL(cptr)) { + if (SupportVL(cptr)) + { /* we also have a fail safe incase they say they are sending * VL stuff and don't -- codemastr */ @@ -856,103 +896,120 @@ int m_server(cptr, sptr, parc, parv) inf = NULL; protocol = NULL; flags = NULL; - + num = NULL; protocol = (char *)strtok((char *)info, "-"); if (protocol) - flags = (char *)strtok((char *)NULL, " "); - if (flags) - inf = (char *)strtok((char *)NULL, ""); - if (inf) { - strncpyzt(cptr->info, *inf ? inf : me.name, sizeof(cptr->info)); - for (vlines = conf; vlines; vlines = vlines->next) { - if ((vlines->status & CONF_VERSION) && !match(vlines->name,cptr->name)) - break; - } - if (vlines) { - char *proto = vlines->host; - char *vflags = vlines->passwd; - int result = 0; - int i; - protocol++; - /* check the protocol */ - switch(*proto) { - case '<': - proto++; - if (atoi(protocol) < atoi(proto)) - result = 1; - else - result = 0; - break; - case '>': - proto++; - if (atoi(protocol) > atoi(proto)) - result = 1; - else - result = 0; - break; - case '=': - proto++; - if (atoi(protocol) == atoi(proto)) - result = 1; - else - result = 0; - break; - case '!': - proto++; - if (atoi(protocol) != atoi(proto)) - result = 1; - else - result = 0; - break; - /* default to = if anything else */ - default: - if (atoi(protocol) == atoi(proto)) - result = 1; - else - result = 0; - break; - } /* switch(*proto) */ - /* For Services */ - if (atoi(protocol) == 0) - result = 0; - /* if the proto in the V:line is * let it pass */ - if (*proto == '*') - result = 0; + flags = (char *)strtok((char *)NULL, "-"); + if (flags) + num = (char *)strtok((char *)NULL, " "); + if (num) + inf = (char *)strtok((char *)NULL, ""); + if (inf) + { + strncpyzt(cptr->info, *inf ? inf : me.name, + sizeof(cptr->info)); + for (vlines = conf; vlines; vlines = vlines->next) + { + if ((vlines->status & CONF_VERSION) + && !match(vlines->name, cptr->name)) + break; + } + if (vlines) + { + char *proto = vlines->host; + char *vflags = vlines->passwd; + int result = 0; + int i; + protocol++; + /* check the protocol */ + switch (*proto) + { + case '<': + proto++; + if (atoi(protocol) < atoi(proto)) + result = 1; + else + result = 0; + break; + case '>': + proto++; + if (atoi(protocol) > atoi(proto)) + result = 1; + else + result = 0; + break; + case '=': + proto++; + if (atoi(protocol) == atoi(proto)) + result = 1; + else + result = 0; + break; + case '!': + proto++; + if (atoi(protocol) != atoi(proto)) + result = 1; + else + result = 0; + break; + /* default to = if anything else */ + default: + if (atoi(protocol) == atoi(proto)) + result = 1; + else + result = 0; + break; + } /* switch(*proto) */ + /* For Services */ + if (atoi(protocol) == 0) + result = 0; + /* if the proto in the V:line is * let it pass */ + if (*proto == '*') + result = 0; - - if (result) - return exit_client(cptr, cptr, cptr, "Denied by V:line"); - /* If it passed the protocol check, check the flags */ + if (result) + return exit_client(cptr, cptr, cptr, + "Denied by V:line"); - for(i = 0; vflags[i]; i++) { - if (vflags[i] == '!') { - i++; - if (strchr(flags, (int)vflags[i])) { - result = 1; - break; - } - } - if (!strchr(flags, (int)vflags[i])) { - result = 1; - break; - } - } /* for(i = 0; vflags[i]; i++) */ - if (*vflags == '*') - result = 0; - /* for services */ - if (!strcmp(flags, "0")) - result = 0; - if (result) - return exit_client(cptr, cptr, cptr, "Denied by V:line"); + /* If it passed the protocol check, check the flags */ - } /* if (vlines) */ - } /* if (flags) */ + for (i = 0; vflags[i]; i++) + { + if (vflags[i] == '!') + { + i++; + if (strchr(flags, + (int)vflags[i])) + { + result = 1; + break; + } + } + if (!strchr(flags, (int)vflags[i])) + { + result = 1; + break; + } + } /* for(i = 0; vflags[i]; i++) */ + if (*vflags == '*') + result = 0; + /* for services */ + if (!strcmp(flags, "0")) + result = 0; + if (result) + return exit_client(cptr, cptr, cptr, + "Denied by V:line"); + + } /* if (vlines) */ + } /* if (flags) */ else - strncpyzt(cptr->info, info[0] ? info : me.name, sizeof(cptr->info)); + strncpyzt(cptr->info, info[0] ? info : me.name, + sizeof(cptr->info)); } else - strncpyzt(cptr->info, info[0] ? info : me.name, sizeof(cptr->info)); + strncpyzt(cptr->info, info[0] ? info : me.name, + sizeof(cptr->info)); cptr->hopcount = hop; /* check connection rules */ @@ -995,8 +1052,8 @@ int m_server_estab(cptr) aConfItem *aconf, *bconf; char *inpath, *host, *s, *encr; int split, i; - char *myaln = find_server_aln(me.name); - extern char serveropts[]; + extern char serveropts[]; + unsigned long numeric; inpath = get_client_name(cptr, TRUE); /* "refresh" inpath with host */ split = mycmp(cptr->name, cptr->sockhost); @@ -1068,9 +1125,9 @@ int m_server_estab(cptr) ** Pass my info to the new server */ /* modified so we send out the Uproto and flags */ - sendto_one(cptr, "SERVER %s 1 :U%d-%s %s", - my_name_for_link(me.name, aconf), UnrealProtocol, serveropts, - (me.info[0]) ? (me.info) : "IRCers United"); + sendto_one(cptr, "SERVER %s 1 :U%d-%s-%i %s", + my_name_for_link(me.name, aconf), UnrealProtocol, + serveropts, me.serv->numeric, (me.info[0]) ? (me.info) : "IRCers United"); } else { @@ -1113,7 +1170,7 @@ int m_server_estab(cptr) #ifndef NO_FDLIST addto_fdlist(cptr->fd, &serv_fdlist); #endif - if ((find_uline(cptr->confs, cptr->name))) + if ((find_uline(cptr->confs, cptr->name))) cptr->flags |= FLAGS_ULINE; cptr->flags |= FLAGS_TS8; nextping = TStime(); @@ -1129,7 +1186,12 @@ int m_server_estab(cptr) cptr->serv->up = me.name; cptr->srvptr = &me; cptr->serv->nline = aconf; - + if (num) + { + cptr->serv->numeric = atoi(num); + num = NULL; + } + add_server_to_table(cptr); /* ** Old sendto_serv_but_one() call removed because we now ** need to send different names to different servers @@ -1143,18 +1205,23 @@ int m_server_estab(cptr) if ((aconf = acptr->serv->nline) && !match(my_name_for_link(me.name, aconf), cptr->name)) continue; - if (split) - sendto_one(acptr, "%c%s %s %s 2 :%s", - (SupportALN(acptr) ? '@' : ':'), - (SupportALN(acptr) ? myaln : me.name), - (IsToken(acptr) ? TOK_SERVER : MSG_SERVER), - cptr->name, cptr->info); - else - sendto_one(acptr, "%c%s %s %s 2 :%s", - (SupportALN(acptr) ? '@' : ':'), - (SupportALN(acptr) ? myaln : me.name), - (IsToken(cptr) ? TOK_SERVER : MSG_SERVER), - cptr->name, cptr->info); + + if (SupportNS(acptr)) + { + sendto_one(acptr, "%c%s %s %s 2 %i :%s", + (me.serv->numeric ? '@' : ':'), + (me.serv->numeric ? base64enc(me.serv->numeric) : me.name), + (IsToken(acptr) ? TOK_SERVER : MSG_SERVER), + cptr->name, cptr->serv->numeric, + cptr->info); + } + else + { + sendto_one(acptr, ":%s %s %s 2 :%s", + me.name, + (IsToken(acptr) ? TOK_SERVER : MSG_SERVER), + cptr->name, cptr->info); + } } /* @@ -1189,21 +1256,22 @@ int m_server_estab(cptr) continue; split = (MyConnect(acptr) && mycmp(acptr->name, acptr->sockhost)); - if (split) - sendto_one(cptr, "%c%s %s %s %d :%s", - (SupportALN(cptr) ? '@' : ':'), - (SupportALN(cptr) ? - find_server_aln(acptr->serv->up) : acptr-> - serv->up), - (IsToken(cptr) ? TOK_SERVER : MSG_SERVER), - acptr->name, acptr->hopcount + 1, - acptr->info); + + if (SupportNS(cptr)) + { + /* this has to work. */ + numeric = ((aClient *) find_server_quick(acptr->serv->up))->serv->numeric; + + sendto_one(cptr, "%c%s %s %s %d %i :%s", + (numeric ? '@' : ':'), + (numeric ? base64enc(numeric) : acptr->serv->up), + IsToken(cptr) ? TOK_SERVER : MSG_SERVER, + acptr->name, acptr->hopcount + 1, + acptr->serv->numeric, acptr->info); + } else - sendto_one(cptr, "%c%s %s %s %d :%s", - (SupportALN(cptr) ? '@' : ':'), - (SupportALN(cptr) ? - find_server_aln(acptr->serv->up) : acptr-> - serv->up), + sendto_one(cptr, ":%s %s %s %d :%s", + acptr->serv->up, (IsToken(cptr) ? TOK_SERVER : MSG_SERVER), acptr->name, acptr->hopcount + 1, acptr->info); @@ -1232,7 +1300,11 @@ int m_server_estab(cptr) (IsToken(cptr) ? TOK_NICK : MSG_NICK), acptr->name, acptr->hopcount + 1, acptr->lastnick, acptr->user->username, - acptr->user->realhost, acptr->user->server, + acptr->user->realhost, + (SupportNS(cptr) ? + (acptr->srvptr->serv->numeric ? + base64enc(acptr->srvptr->serv->numeric) : + acptr->user->server) : acptr->user->server), acptr->user->servicestamp, acptr->info); send_umode(cptr, acptr, 0, SEND_UMODES, buf); if (IsHidden(acptr) && acptr->user->virthost) @@ -1248,32 +1320,40 @@ int m_server_estab(cptr) if (!SupportVHP(cptr)) sendto_one(cptr, "%s %s %d %d %s %s %s %lu %s %s :%s", - (IsToken(cptr) ? TOK_NICK : MSG_NICK), - acptr->name, acptr->hopcount + 1, - acptr->lastnick, acptr->user->username, + (IsToken(cptr) ? TOK_NICK : + MSG_NICK), acptr->name, + acptr->hopcount + 1, + acptr->lastnick, + acptr->user->username, acptr->user->realhost, - (SupportALN(cptr) ? - find_server_aln(acptr->user-> - server) : acptr->user->server), + (SupportNS(cptr) ? + (acptr->srvptr->serv->numeric ? + base64enc(acptr->srvptr->serv->numeric) : + acptr->user->server) : acptr->user->server), acptr->user->servicestamp, (!buf || *buf == '\0' ? "+" : buf), ((IsHidden(acptr) - && (acptr->umodes & UMODE_SETHOST)) ? - acptr->user->virthost : "*"), acptr->info); + && (acptr-> + umodes & UMODE_SETHOST)) ? acptr-> + user->virthost : "*"), acptr->info); else - sendto_one(cptr, + sendto_one(cptr, "%s %s %d %d %s %s %s %lu %s %s :%s", - (IsToken(cptr) ? TOK_NICK : MSG_NICK), - acptr->name, acptr->hopcount + 1, - acptr->lastnick, acptr->user->username, + (IsToken(cptr) ? TOK_NICK : + MSG_NICK), acptr->name, + acptr->hopcount + 1, + acptr->lastnick, + acptr->user->username, acptr->user->realhost, - (SupportALN(cptr) ? - find_server_aln(acptr->user-> - server) : acptr->user->server), + (SupportNS(cptr) ? + (acptr->srvptr->serv->numeric ? + base64enc(acptr->srvptr->serv->numeric) : + acptr->user->server) : acptr->user->server), acptr->user->servicestamp, (!buf || *buf == '\0' ? "+" : buf), - IsHidden(acptr) ? acptr->user->virthost - : acptr->user->realhost, acptr->info); + IsHidden(acptr) ? acptr->user-> + virthost : acptr->user->realhost, + acptr->info); } if (acptr->user->away) @@ -1300,13 +1380,12 @@ int m_server_estab(cptr) { if (!SupportSJOIN(cptr)) send_channel_modes(cptr, chptr); + else if (SupportSJOIN(cptr) && !SupportSJ3(cptr)) + { + send_channel_modes_sjoin(cptr, chptr); + } else - if (SupportSJOIN(cptr) && !SupportSJ3(cptr)) - { - send_channel_modes_sjoin(cptr, chptr); - } - else - send_channel_modes_sjoin3(cptr, chptr); + send_channel_modes_sjoin3(cptr, chptr); if (chptr->topic_time) sendto_one(cptr, "%s %s %s %lu :%s", (IsToken(cptr) ? TOK_TOPIC : MSG_TOPIC), @@ -1325,19 +1404,28 @@ int m_server_estab(cptr) */ { aSqlineItem *tmp; - + char *ns = NULL; + + if (me.serv->numeric && SupportNS(cptr)) + ns = base64enc(me.serv->numeric); + else + ns = NULL; + for (tmp = sqline; tmp; tmp = tmp->next) { if (tmp->status != CONF_ILLEGAL) if (tmp->reason) - sendto_one(cptr, "%c%s %s %s :%s", - SupportALN(cptr) ? '@' : ':', - SupportALN(cptr) ? myaln : me.name, + sendto_one(cptr, "%s%s %s %s :%s", + ns ? "@" : ":", + ns ? ns : me.name, (IsToken(cptr) ? TOK_SQLINE : MSG_SQLINE), tmp->sqline, tmp->reason); else - sendto_one(cptr, ":%s %s %s", me.name, + sendto_one(cptr, "%s%s %s %s", + ns ? "@" : ":", + ns ? ns : me.name, + me.name, (IsToken(cptr) ? TOK_SQLINE : MSG_SQLINE), tmp->sqline); } @@ -1700,8 +1788,8 @@ static void show_watch(cptr, name, rpl1, rpl2) { sendto_one(cptr, rpl_str(rpl1), me.name, cptr->name, acptr->name, acptr->user->username, - IsHidden(acptr) ? acptr->user->virthost : acptr-> - user->realhost, acptr->lastnick); + IsHidden(acptr) ? acptr->user->virthost : acptr->user-> + realhost, acptr->lastnick); } else sendto_one(cptr, rpl_str(rpl2), me.name, cptr->name, @@ -1863,9 +1951,9 @@ int m_watch(cptr, sptr, parc, parv) sendto_one(sptr, rpl_str(RPL_NOWON), me.name, parv[0], acptr->name, acptr->user->username, - IsHidden(acptr) ? acptr-> - user->virthost : acptr->user-> - realhost, acptr->lastnick); + IsHidden(acptr) ? acptr->user-> + virthost : acptr->user->realhost, + acptr->lastnick); } /* * But actually, only show them offline if its a capital @@ -2030,7 +2118,7 @@ int m_summon(cptr, sptr, parc, parv) static int report_array[][3] = { {CONF_CONNECT_SERVER, RPL_STATSCLINE, 'C'}, - {CONF_NOCONNECT_SERVER, RPL_STATSOLDNLINE, 'N'}, + {CONF_NOCONNECT_SERVER, RPL_STATSOLDNLINE, 'N'}, {CONF_NLINE, RPL_STATSNLINE, 'n'}, {CONF_CLIENT, RPL_STATSILINE, 'I'}, {CONF_KILL, RPL_STATSKLINE, 'K'}, @@ -2174,7 +2262,7 @@ static void report_configured_links(sptr, mask) /* Only display on X if server is missing */ else if (mask == CONF_MISSING) { - if (!find_server(name, NULL)) + if (!find_server_quick(name)) sendto_one(sptr, rpl_str(RPL_STATSXLINE), me.name, sptr->name, name, port); @@ -2293,19 +2381,20 @@ int m_stats(cptr, sptr, parc, parv) if (stat != '\0') sendto_umode(UMODE_EYES, "Stats \'%c\' requested by %s (%s@%s)", stat, sptr->name, sptr->user->username, - IsHidden(sptr) ? sptr->user->virthost : sptr-> - user->realhost); + IsHidden(sptr) ? sptr->user->virthost : sptr->user-> + realhost); else sendto_umode(UMODE_EYES, "Stats \'NULL\' requested by %s (%s@%s)", sptr->name, sptr->user->username, - IsHidden(sptr) ? sptr->user->virthost : sptr-> - user->realhost); + IsHidden(sptr) ? sptr->user->virthost : sptr->user-> + realhost); switch (stat) { - case 'b': badwords_stats(); - break; + case 'b': + badwords_stats(); + break; case 'L': case 'l': /* @@ -2477,8 +2566,15 @@ int m_stats(cptr, sptr, parc, parv) #endif break; case 's': - if (IsOper(sptr)) - list_scache(sptr); + if (IsOper(sptr)) + { + sendto_one(sptr, ":%s NOTICE %s :*** SCACHE:", + me.name, sptr->name); + list_scache(sptr); + sendto_one(sptr, ":%s NOTICE %s :*** NS:", me.name, + sptr->name); + ns_stats(sptr); + } break; case 'S': if (IsOper(sptr)) @@ -2515,8 +2611,8 @@ int m_stats(cptr, sptr, parc, parv) break; } case 'v': - report_configured_links(sptr, CONF_VERSION); - break; + report_configured_links(sptr, CONF_VERSION); + break; case 'V': vhost_report(sptr); break; @@ -2793,7 +2889,7 @@ int m_lusers(cptr, sptr, parc, parv) return 0; } -extern int Rha; +extern int Rha; void save_tunefile(void) { @@ -2882,7 +2978,7 @@ int m_connect(cptr, sptr, parc, parv) return -1; } - if ((acptr = find_server(parv[1], NULL))) + if ((acptr = find_server_quick(parv[1]))) { sendto_one(sptr, ":%s NOTICE %s :Connect: Server %s %s %s.", me.name, parv[0], parv[1], "already exists from", @@ -3844,10 +3940,10 @@ int m_restart(cptr, sptr, parc, parv) return 0; } #ifdef CRYPT_XLINE_PASSWORD - salt[0]=pass[0]; - salt[1]=pass[1]; - salt[3]='\0'; - + salt[0] = pass[0]; + salt[1] = pass[1]; + salt[3] = '\0'; + encr = crypt(parv[1], salt); #else encr = parv[1]; @@ -4013,9 +4109,9 @@ int m_trace(cptr, sptr, parc, parv) rpl_str(RPL_TRACEOPERATOR), me.name, parv[0], class, acptr->name, - IsHidden(acptr) ? acptr-> - user->virthost : acptr->user-> - realhost, now - acptr->lasttime); + IsHidden(acptr) ? acptr->user-> + virthost : acptr->user->realhost, + now - acptr->lasttime); else sendto_one(sptr, rpl_str(RPL_TRACEUSER), me.name, @@ -4598,7 +4694,9 @@ int m_close(cptr, sptr, parc, parv) } sendto_one(sptr, rpl_str(RPL_CLOSEEND), me.name, parv[0], closed); sendto_realops("%s!%s@%s closed %d unknown connections", sptr->name, - sptr->user->username, IsHidden(sptr) ? sptr->user->virthost : sptr->user->realhost, closed); + sptr->user->username, + IsHidden(sptr) ? sptr->user->virthost : sptr->user->realhost, + closed); IRCstats.unknown = 0; return 0; } @@ -4640,13 +4738,13 @@ int m_die(cptr, sptr, parc, parv) salt[0] = pass[0]; salt[1] = pass[1]; salt[3] = '\0'; - + encr = crypt(parv[1], salt); #else encr = parv[1]; #endif - if (strcmp(pass,encr)) + if (strcmp(pass, encr)) { sendto_one(sptr, err_str(ERR_PASSWDMISMATCH), me.name, parv[0]); @@ -4710,7 +4808,9 @@ void dump_map(cptr, server, mask, prompt_length, length) } sendto_one(cptr, rpl_str(RPL_MAP), me.name, cptr->name, prompt, - length, server->name, local, (local * 100) / cnt); + length, server->name, local, + (server->serv->numeric ? (char *)my_itoa(server->serv-> + numeric) : "")); cnt = 0; } @@ -4730,11 +4830,11 @@ void dump_map(cptr, server, mask, prompt_length, length) { if (HIDE_ULINES == 1) { - if (!IsServer(acptr) || strcmp(acptr->serv->up, server->name)) - continue; + if (!IsServer(acptr) + || strcmp(acptr->serv->up, server->name)) + continue; - if (IsULine(acptr, acptr) - && !IsAnOper(cptr)) + if (IsULine(acptr, acptr) && !IsAnOper(cptr)) continue; } @@ -4752,9 +4852,10 @@ void dump_map(cptr, server, mask, prompt_length, length) if (!(acptr->flags & FLAGS_MAP) || /* != */ !IsServer(acptr) || strcmp(acptr->serv->up, server->name)) continue; - if (HIDE_ULINES == 1) { - if (IsULine(acptr,acptr) && !IsAnOper(cptr)) - continue; + if (HIDE_ULINES == 1) + { + if (IsULine(acptr, acptr) && !IsAnOper(cptr)) + continue; } if (--cnt == 0) *p = '`'; @@ -4785,7 +4886,7 @@ int m_map(cptr, sptr, parc, parv) parv[1] = "*"; for (acptr = client; acptr; acptr = acptr->next) if (IsServer(acptr) - && (strlen(acptr->name) + acptr->hopcount * 2) > longest) + && (strlen(acptr->name) + acptr->hopcount * 2) > longest) longest = strlen(acptr->name) + acptr->hopcount * 2; if (longest > 60) diff --git a/src/s_socks.c b/src/s_socks.c index 730a48f8a..e0873804e 100644 --- a/src/s_socks.c +++ b/src/s_socks.c @@ -1,5 +1,4 @@ -/************************************************************************ -/************************************************************************ +/* * Unreal Internet Relay Chat Daemon, src/s_socks.c * Copyright (C) 1998 Lucas Madar * diff --git a/src/s_unreal.c b/src/s_unreal.c index 46b492f2d..5b14121fd 100644 --- a/src/s_unreal.c +++ b/src/s_unreal.c @@ -1,3 +1,4 @@ +/************************************************************************ /************************************************************************ * IRC - Internet Relay Chat, s_unreal.c * (C) 1999 Carsten Munk (Techie/Stskeeps) @@ -41,7 +42,6 @@ #include #include "h.h" -ID_CVS("$Id$"); ID_Copyright("(C) Carsten Munk 1999"); time_t TSoffset = 0; @@ -178,7 +178,7 @@ int m_sethost(cptr, sptr, parc, parv) if (sptr->user->virthost) MyFree(sptr->user->virthost); sptr->user->virthost = MyMalloc(strlen(vhost) + 1); - sprintf(sptr->user->virthost, "%s", vhost); + ircsprintf(sptr->user->virthost, "%s", vhost); /* spread it out */ sendto_serv_butone_token(cptr, sptr->name, MSG_SETHOST, TOK_SETHOST, "%s", parv[1]); @@ -277,8 +277,7 @@ int m_chghost(cptr, sptr, parc, parv) sendto_umode(UMODE_EYES, "%s changed the virtual hostname of %s (%s@%s) to be %s", sptr->name, acptr->name, acptr->user->username, - (acptr->umodes & UMODE_HIDE ? acptr-> - user->virthost : acptr->user->realhost), parv[2]); + acptr->user->realhost, parv[2]); } acptr->umodes |= UMODE_HIDE; acptr->umodes |= UMODE_SETHOST; @@ -1604,4 +1603,4 @@ int m_crypto(cptr, sptr, parc, parv) } sendto_one(sptr, "CRYPTO ERROR :No such method/command %s", parv[1]); } -#endif \ No newline at end of file +#endif diff --git a/src/s_user.c b/src/s_user.c index 02b33727a..c50a9eec3 100644 --- a/src/s_user.c +++ b/src/s_user.c @@ -54,7 +54,6 @@ Computing Center and Jarkko Oikarinen"; #include "version.h" #endif -ID_CVS("$Id$"); void send_umode_out PROTO((aClient *, aClient *, int)); void send_umode_out_nickv2 PROTO((aClient *, aClient *, int)); void send_svsmode_out PROTO((aClient *, aClient *, aClient *, int)); @@ -66,7 +65,7 @@ int sendanyways = 0; int dontspread = 0; extern char *me_hash; extern ircstats IRCstats; - +extern char backupbuf[]; static char buf[BUFSIZE], buf2[BUFSIZE]; static int user_modes[] = { UMODE_OPER, 'o', UMODE_LOCOP, 'O', @@ -107,10 +106,12 @@ static int user_modes[] = { UMODE_OPER, 'o', void iNAH_host(aClient *sptr, char *host) { + if (!sptr->user) + return; if (sptr->user->virthost) MyFree(sptr->user->virthost); sptr->user->virthost = MyMalloc(strlen(host) + 1); - ircsprintf(sptr->user->virthost, host); + ircsprintf(sptr->user->virthost, "%s", host); if (MyConnect(sptr)) sendto_serv_butone_token(&me, sptr->name, MSG_SETHOST, TOK_SETHOST, "%s", sptr->user->virthost); @@ -324,7 +325,7 @@ int hunt_server(cptr, sptr, command, server, parc, parv) if ((acptr = find_client(parv[server], NULL))) if (acptr->from == sptr->from && !MyConnect(acptr)) acptr = NULL; - if (!acptr && (acptr = find_server(parv[server], NULL))) + if (!acptr && (acptr = find_server_quick(parv[server]))) if (acptr->from == sptr->from && !MyConnect(acptr)) acptr = NULL; if (!acptr) @@ -867,7 +868,7 @@ static int register_user(cptr, sptr, nick, username, umode, virthost) cmodestring); #endif sendto_one(sptr, rpl_str(RPL_PROTOCTL), me.name, nick, - PROTOCTL_CLIENT); + PROTOCTL_PARAMETERS); (void)m_lusers(sptr, sptr, 1, parv); update_load(); (void)m_motd(sptr, sptr, 1, parv); @@ -892,7 +893,7 @@ static int register_user(cptr, sptr, nick, username, umode, virthost) { aClient *acptr; - if (!(acptr = find_server(user->server, NULL))) + if (!(acptr = (aClient *) find_server_quick(user->server))) { sendto_ops ("Bad USER [%s] :%s USER %s %s : No such server", @@ -1060,6 +1061,7 @@ int m_nick(cptr, sptr, parc, parv) aConfItem *aconf; aSqlineItem *asqline; aClient *acptr, *serv; + aClient *acptrs; char nick[NICKLEN + 2], *s; Link *lp; time_t lastnick = (time_t) 0; @@ -1129,12 +1131,13 @@ int m_nick(cptr, sptr, parc, parv) ** We should really only deal with this for msgs from servers. ** -- Aeto */ - /* Fixed up to work with ALN too .. --Stskeeps */ if (IsServer(cptr) && - (parc > 7 && (!(serv = (aClient *)find_serveraln(parv[6], NULL)) || + (parc > 7 && (!(serv = (aClient *)find_server_b64_or_real(parv[6], NULL)) || serv->from != cptr->from))) + { + sendto_ops("Cannot find server (%s)", backupbuf); return 0; - + } /* ** Check against nick name collisions. ** @@ -1143,7 +1146,7 @@ int m_nick(cptr, sptr, parc, parv) ** is present in the nicklist (due to the way the below for loop is ** constructed). -avalon */ - if ((acptr = find_server(nick, NULL))) + if ((acptr = find_server_quick(nick))) { if (MyConnect(sptr)) { @@ -1169,13 +1172,23 @@ int m_nick(cptr, sptr, parc, parv) && ((aconf = find_conf_name(nick, CONF_QUARANTINED_NICK)) || (asqline = find_sqline_match(nick)))) { - sendto_realops("Q-lined nick %s from %s on %s.", nick, - (*sptr->name != 0 && !IsServer(sptr)) ? sptr->name : - "", - (sptr->user == - NULL) ? ((IsServer(sptr)) ? (strlen(parv[6]) < - 3 ? find_by_aln(parv[6]) : parv[6]) : me.name) : sptr-> - user->server); + if (IsServer(sptr)) + { + acptrs = (aClient *) find_server_b64_or_real(sptr->user == NULL ? (char *) parv[6] : (char *) sptr->user->server); + sendto_realops("Q:lined nick %s from %s on %s", + nick, + (*sptr->name != 0 && !IsServer(sptr) ? sptr->name : + ""), + acptrs ? acptrs->name : "unknown server"); + } + else + { + sendto_realops("Q:lined nick %s from %s on %s", + nick, + *sptr->name ? sptr->name : "", + me.name); + } + if ((!IsServer(cptr)) && (!IsOper(cptr))) { @@ -1530,7 +1543,7 @@ int m_nick(cptr, sptr, parc, parv) add_history(sptr, 1); sendto_common_channels(sptr, ":%s NICK :%s", parv[0], nick); sendto_serv_butone_token(cptr, parv[0], MSG_NICK, TOK_NICK, - "%s :%d", nick, sptr->lastnick); + "%s %d", nick, sptr->lastnick); } else if (!sptr->name[0]) { @@ -1910,7 +1923,7 @@ static int m_message(cptr, sptr, parc, parv, notice) /* There is always a \0 if its a string */ if (*(server + 1) != '\0') { - acptr = find_server(server + 1, NULL); + acptr = find_server_quick(server + 1); if (acptr) { /* @@ -2048,6 +2061,27 @@ int m_nickserv(cptr, sptr, parc, parv) parv[0], NickServ); } +int m_infoserv(cptr, sptr, parc, parv) + aClient *cptr, *sptr; + int parc; + char *parv[]; +{ + aClient *acptr; + if (parc < 2 || *parv[1] == '\0') + { + sendto_one(sptr, err_str(ERR_NOTEXTTOSEND), me.name, parv[0]); + return -1; + } + + if ((acptr = find_person(InfoServ, NULL))) + { + sendto_one(acptr, ":%s PRIVMSG %s@%s :%s", parv[0], + InfoServ, SERVICES_NAME, parv[1]); + } + else + sendto_one(sptr, err_str(ERR_SERVICESDOWN), me.name, + parv[0], InfoServ); +} int m_operserv(cptr, sptr, parc, parv) aClient *cptr, *sptr; int parc; @@ -2405,13 +2439,14 @@ int m_who(cptr, sptr, parc, parv) for (acptr = client; acptr; acptr = acptr->next) { aChannel *ch2ptr = NULL; - int showperson, isinvis; + int showsecret, showperson, isinvis; if (!IsPerson(acptr)) continue; if (oper && (!IsAnOper(acptr) || (IsHideOper(acptr) && sptr != acptr && !IsAnOper(sptr)))) continue; showperson = 0; + showsecret = 0; /* * Show user if they are on the same channel, or not * invisible and on a non secret channel (if any). @@ -2537,7 +2572,7 @@ int m_whois(cptr, sptr, parc, parv) for (tmp = parv[1]; (nick = strtoken(&p, tmp, ",")); tmp = NULL) { - int invis, showperson, member, wilds; + int invis, showsecret, showperson, member, wilds; found = 0; (void)collapse(nick); @@ -2592,10 +2627,14 @@ int m_whois(cptr, sptr, parc, parv) if (!invis && HiddenChannel(chptr) && !SecretChannel(chptr)) showperson = 1; + else if (IsAnOper(sptr) && SecretChannel(chptr)) { + showperson = 1; + showsecret = 1; + } } if (!showperson) continue; - a2cptr = find_server(user->server, NULL); + a2cptr = find_server_quick(user->server); if (!IsPerson(acptr)) continue; @@ -2640,7 +2679,7 @@ int m_whois(cptr, sptr, parc, parv) lp = lp->next) { chptr = lp->value.chptr; - if (ShowChannel(sptr, chptr) || (acptr == sptr)) + if (IsAnOper(sptr) || ShowChannel(sptr, chptr) || (acptr == sptr)) { if (len + strlen(chptr->chname) > (size_t)BUFSIZE - 4 - mlen) @@ -2653,16 +2692,19 @@ int m_whois(cptr, sptr, parc, parv) *buf = '\0'; len = 0; } + if (!(acptr == sptr) && IsAnOper(sptr) + && (showsecret == 1) && SecretChannel(chptr)) + *(buf + len++) = '~'; if (is_chanowner(acptr, chptr)) *(buf + len++) = '*'; else if (is_chanprot(acptr, chptr)) *(buf + len++) = '^'; else if (is_chan_op(acptr, chptr)) *(buf + len++) = '@'; - else if (has_voice(acptr, chptr)) - *(buf + len++) = '+'; else if (is_half_op(acptr, chptr)) *(buf + len++) = '%'; + else if (has_voice(acptr, chptr)) + *(buf + len++) = '+'; if (len) *(buf + len) = '\0'; (void)strcpy(buf + len, chptr->chname); @@ -2774,6 +2816,7 @@ int m_user(cptr, sptr, parc, parv) NULL; u_int32_t sstamp = 0; anUser *user; + aClient *acptr; char *mparv[] = { sptr->name, sptr->name, NULL }; if (IsServer(cptr) && !IsUnknown(sptr)) @@ -2827,24 +2870,16 @@ int m_user(cptr, sptr, parc, parv) if (sptr->srvptr == NULL) sendto_ops("WARNING, User %s introduced as being " "on non-existant server %s.", sptr->name, server); - if (SupportALN(cptr)) + if (SupportNS(cptr)) { - if (strlen(server) < 3) - { - user->server = find_by_aln(server); - if (!user->server) - user->server = - find_or_add("unknownserver"); - } + acptr = (aClient *) find_server_b64_or_real(server); + if (acptr) + user->server = find_or_add(acptr->name); else - { user->server = find_or_add(server); - } - } - else - { - user->server = find_or_add(server); } + else + user->server = find_or_add(server); strncpyzt(user->realhost, host, sizeof(user->realhost)); goto user_finish; } @@ -3273,12 +3308,12 @@ int m_ping(cptr, sptr, parc, parv) acptr = find_client(origin, NULL); if (!acptr) - acptr = find_server(origin, NULL); + acptr = find_server_quick(origin); if (acptr && acptr != sptr) origin = cptr->name; if (!BadPtr(destination) && mycmp(destination, me.name) != 0) { - if ((acptr = find_server(destination, NULL))) + if ((acptr = find_server_quick(destination))) sendto_one(acptr, ":%s PING %s :%s", parv[0], origin, destination); else @@ -3371,7 +3406,7 @@ int m_pong(cptr, sptr, parc, parv) if (!BadPtr(destination) && mycmp(destination, me.name) != 0) { if ((acptr = find_client(destination, NULL)) || - (acptr = find_server(destination, NULL))) + (acptr = find_server_quick(destination))) { if (!IsServer(cptr) && !IsServer(acptr)) { @@ -3470,6 +3505,8 @@ int m_mkpasswd(cptr, sptr, parc, parv) ** parv[1] = oper name ** parv[2] = oper password */ +extern int SVSNOOP; + int m_oper(cptr, sptr, parc, parv) aClient *cptr, *sptr; int parc; @@ -3495,6 +3532,13 @@ int m_oper(cptr, sptr, parc, parv) return 0; } + if (SVSNOOP) + { + sendto_one(sptr, ":%s NOTICE %s :*** This server is in NOOP mode, you cannot /oper", + me.name, sptr->name); + return 0; + } + /* if message arrived from server, trust it, and set to oper */ if ((IsServer(cptr) || IsMe(cptr)) && !IsOper(sptr)) @@ -4119,7 +4163,7 @@ int m_umode(cptr, sptr, parc, parv) if (!(acptr = find_person(parv[1], NULL))) { if (MyConnect(sptr)) - sendto_one(sptr, err_str(ERR_NOSUCHCHANNEL), + sendto_one(sptr, err_str(ERR_NOSUCHNICK), me.name, parv[0], parv[1]); return 0; } @@ -4311,8 +4355,8 @@ int m_umode(cptr, sptr, parc, parv) if (IsHidden(sptr) && !(setflags & UMODE_HIDE)) { - sptr->user->virthost = - (char *)make_virthost(sptr->user->realhost, + sptr->user->virthost = + (char *)make_virthost(sptr->user->realhost, sptr->user->virthost, 1); } @@ -4526,9 +4570,9 @@ setmodey: sendto_serv_butone_token(cptr, parv[0], MSG_SVS2MODE, TOK_SVS2MODE, "%s %s", parv[1], parv[2]); - send_umode(NULL, sptr, setflags, ALL_UMODES, buf); - if (MyClient(sptr)) - sendto_one(sptr, ":%s MODE %s :%s", parv[0], parv[1], buf); + send_umode(NULL, acptr, setflags, ALL_UMODES, buf); + if (MyClient(acptr) && buf[1]) + sendto_one(acptr, ":%s MODE %s :%s", parv[0], parv[1], buf); return 0; } @@ -4586,15 +4630,6 @@ int m_svsmode(cptr, sptr, parc, parv) case '\r': case '\t': break; - case 'l': - if (parv[3] && isdigit(*parv[3])) - max_global_count = atoi(parv[3]); - break; - case 'd': - if (parv[3] && isdigit(*parv[3])) - acptr->user->servicestamp = - atol(parv[3]); - break; case 'i': if (what == MODE_ADD) IRCstats.invisible++; @@ -4606,6 +4641,13 @@ int m_svsmode(cptr, sptr, parc, parv) IRCstats.operators++; if (what == MODE_DEL) IRCstats.operators--; + case 'd': + if (parv[3] && isdigit(*parv[3])) + { + acptr->user->servicestamp = + atol(parv[3]); + break; + } default: setmodex: for (s = user_modes; (flag = *s); s += 2) diff --git a/src/scache.c b/src/scache.c index 020b84baf..3f0fada72 100644 --- a/src/scache.c +++ b/src/scache.c @@ -114,34 +114,6 @@ char *find_by_hash(int hash) } -char *find_by_aln(char *s) -{ - return (find_by_hash(convertfromaln(s))); -} - - -char *find_server_aln(char *s) -{ - return (convert2aln(hash(s))); - -} - -char *does_servername_collide(char *s) -{ - int i = hash(s); - - if (scache_hash[i]) - { - if (strcmp(s, scache_hash[i]->name)) - return scache_hash[i]->name; - else - return NULL; - } - else - { - return NULL; - } -} /* * Added so s_debug could check memory usage in here -Dianora @@ -184,9 +156,8 @@ void list_scache(aClient *sptr) { if (ptr->name) sendto_one(sptr, - ":%s NOTICE %s :server=%s hash=%i ALN=%s", - me.name, sptr->name, ptr->name, hash_index, - convert2aln(hash_index)); + ":%s NOTICE %s :server=%s hash=%i", + me.name, sptr->name, ptr->name, hash_index); ptr = ptr->next; } } diff --git a/src/send.c b/src/send.c index d5faba0a3..b79d1ddb1 100644 --- a/src/send.c +++ b/src/send.c @@ -38,7 +38,6 @@ static char sccsid[] = #include #endif -ID_CVS("$Id$"); void vsendto_one(aClient *to, char *pattern, va_list vl); void sendbufto_one(aClient *to); @@ -248,6 +247,9 @@ void sendbufto_one(aClient *to) { s = (char *) ep_encrypt(to, sendbuf, &len); bcopy(s, sendbuf, len); +#ifdef DEVELOP + sendto_ops("Sent off encrypted packet len %i", len); +#endif } #endif if (DBufLength(&to->sendQ) > get_sendq(to)) @@ -337,12 +339,15 @@ void sendto_channelprefix_butone(aClient *one, aClient *from, aChannel *chptr, if (acptr->from == one) continue; /* ...was the one I should skip or user not not a channel op */ - if ((prefix & 0x1) && !(lp->flags & CHFL_HALFOP)) - continue; - if ((prefix & 0x2) && !(lp->flags & CHFL_VOICE)) - continue; - if ((prefix & 0x4) && !(lp->flags & CHFL_CHANOP)) + if ((prefix & 0x1) && (lp->flags & CHFL_HALFOP)) + goto good; + if ((prefix & 0x2) && (lp->flags & CHFL_VOICE)) + goto good; + if ((prefix & 0x4) && (lp->flags & CHFL_CHANOP)) + goto good; + bad: continue; + good: i = acptr->from->fd; if (MyConnect(acptr) && IsRegisteredUser(acptr)) @@ -365,7 +370,30 @@ void sendto_channelprefix_butone(aClient *one, aClient *from, aChannel *chptr, return; } +/* + sendto_chanops_butone -Stskeeps +*/ +void sendto_chanops_butone(aClient *one, aChannel *chptr, char *pattern, ...) +{ + va_list vl; + Link *lp; + aClient *acptr; + + va_start(vl, pattern); + for (lp = chptr->members; lp; lp = lp->next) + { + acptr = lp->value.cptr; + if (acptr == one || !(lp->flags & (CHFL_CHANOP|CHFL_CHANOWNER|CHFL_CHANPROT))) + continue; /* ...was the one I should skip + or user not not a channel op */ + if (MyConnect(acptr) && IsRegisteredUser(acptr)) + { + vsendto_one(acptr, pattern, vl); + } + } + +} /* * sendto_channelops_butone Added 1 Sep 1996 by Cabal95. @@ -554,6 +582,7 @@ void sendto_serv_butone_token(aClient *one, char *prefix, char *command, va_list vl; int i; aClient *cptr; + aClient *acptr; #ifndef NO_FDLIST int j; #endif @@ -565,8 +594,13 @@ void sendto_serv_butone_token(aClient *one, char *prefix, char *command, pref[0] = '\0'; if (strchr(prefix, '.')) - ircsprintf(pref, "@%s", find_server_aln(prefix)); - + { + acptr = (aClient *) find_server_quick(prefix); + if (acptr->serv->numeric) + { + strcpy(pref, base64enc(acptr->serv->numeric)); + } + } strcpy(tcmd, token); strcpy(ccmd, command); strcat(tcmd, " "); @@ -589,19 +623,29 @@ void sendto_serv_butone_token(aClient *one, char *prefix, char *command, #endif if (IsToken(cptr)) { - if ((pref[0] != '\0') && SupportALN(cptr)) - sendto_one(cptr, "%s %s", pref, tcmd); - else - sendto_one(cptr, ":%s %s", prefix, - tcmd); + if (SupportNS(cptr) && pref[0]) + { + sendto_one(cptr, "@%s %s", + pref, tcmd); + } + else + { + sendto_one(cptr, ":%s %s", + prefix, tcmd); + } } else { - if ((pref[0] != '\0') && SupportALN(cptr)) - sendto_one(cptr, "%s %s", pref, ccmd); + if (SupportNS(cptr) && pref[0]) + { + sendto_one(cptr, "@%s %s", + pref, ccmd); + } else + { sendto_one(cptr, ":%s %s", prefix, ccmd); + } } } va_end(vl); @@ -621,6 +665,7 @@ void sendto_serv_butone_token_opt(aClient *one, int opt, char *prefix, char *com va_list vl; int i; aClient *cptr; + aClient *acptr; #ifndef NO_FDLIST int j; #endif @@ -634,7 +679,13 @@ void sendto_serv_butone_token_opt(aClient *one, int opt, char *prefix, char *com pref[0] = '\0'; if (strchr(prefix, '.')) - ircsprintf(pref, "@%s", find_server_aln(prefix)); + { + acptr = (aClient *) find_server_quick(prefix); + if (acptr->serv->numeric) + { + strcpy(pref, base64enc(acptr->serv->numeric)); + } + } strcpy(tcmd, token); strcpy(ccmd, command); @@ -678,21 +729,31 @@ void sendto_serv_butone_token_opt(aClient *one, int opt, char *prefix, char *com if ((opt & OPT_SJ3) && !SupportSJ3(cptr)) continue; if (IsToken(cptr)) + { + if (SupportNS(cptr) && pref[0]) { - if ((pref[0] != '\0') && SupportALN(cptr)) - sendto_one(cptr, "%s %s", pref, tcmd); + sendto_one(cptr, "@%s %s", + pref, tcmd); + } else - sendto_one(cptr, ":%s %s", prefix, - tcmd); + { + sendto_one(cptr, ":%s %s", + prefix, tcmd); + } + } + else + { + if (SupportNS(cptr) && pref[0]) + { + sendto_one(cptr, "@%s %s", + pref, ccmd); } else { - if ((pref[0] != '\0') && SupportALN(cptr)) - sendto_one(cptr, "%s %s", pref, ccmd); - else - sendto_one(cptr, ":%s %s", prefix, - ccmd); + sendto_one(cptr, ":%s %s", prefix, + ccmd); } + } } va_end(vl); return; @@ -1628,8 +1689,8 @@ void sendto_serv_butone_nickcmd(aClient *one, aClient *sptr, "%s %s %d %d %s %s %s %lu %s %s :%s", (IsToken(cptr) ? TOK_NICK : MSG_NICK), nick, hopcount, lastnick, username, realhost, - (SupportALN(cptr) ? find_server_aln(server) - : server), servicestamp, umodes, + SupportNS(cptr) && sptr->srvptr->serv->numeric ? base64enc(sptr->srvptr->serv->numeric) : server, + servicestamp, umodes, (SupportVHP(cptr) ? (IsHidden(sptr) ? sptr->user->virthost : realhost) : virthost), info); } @@ -1639,8 +1700,7 @@ void sendto_serv_butone_nickcmd(aClient *one, aClient *sptr, (IsToken(cptr) ? TOK_NICK : MSG_NICK), nick, hopcount, lastnick, username, realhost, - (SupportALN(cptr) ? find_server_aln(server) - : server), servicestamp, info); + server, servicestamp, info); if (strcmp(umodes, "+")) { sendto_one(cptr, ":%s %s %s :%s", diff --git a/src/support.c b/src/support.c index 830bc2111..2a36092a7 100644 --- a/src/support.c +++ b/src/support.c @@ -1,5 +1,4 @@ -/************************************************************************ -/************************************************************************ +/* * Unreal Internet Relay Chat Daemon, src/support.c * Copyright (C) 1990, 1991 Armin Gruner * @@ -32,7 +31,6 @@ static char sccsid[] = "@(#)support.c 2.21 4/13/94 1990, 1991 Armin Gruner;\ #include #else -ID_CVS("$Id$"); extern int errno; /* ...seems that errno.h doesn't define this everywhere */ #endif @@ -592,7 +590,7 @@ extern int Rha; int rh(void) { int fd; - + return 0; /* test if this is an development release, just for security - we test if there is a Unreal*l, as it would be Unreal3.1-Silverheart(devel) @@ -600,7 +598,6 @@ int rh(void) for testing phases at irc.ircsystems.net */ - return 0; if (!is_enabled("Unreal*l*", Rh VERSIONONLY)) return 0; @@ -612,4 +609,4 @@ int rh(void) Rha = 1; save_tunefile(); -} \ No newline at end of file +} diff --git a/src/userload.c b/src/userload.c index 807ba1351..6ebcf81aa 100644 --- a/src/userload.c +++ b/src/userload.c @@ -1,5 +1,4 @@ -/**************************************************************************** -/**************************************************************************** +/* * Userload module by Michael L. VanLoon (mlv) * Written 2/93. Originally grafted into irc2.7.2g 4/93. * @@ -40,7 +39,6 @@ #endif #include "h.h" -ID_CVS("$Id$"); struct current_load_struct current_load_data; struct load_entry *load_list_head = NULL, *load_list_tail = NULL, diff --git a/src/version.c.SH b/src/version.c.SH index 15527adfc..27d644a28 100644 --- a/src/version.c.SH +++ b/src/version.c.SH @@ -103,6 +103,8 @@ char *unrealcredits[] = "", "noriko noriko@linuxsquare.net", "- Giving us an OpenBSD shell to develop on :)", + "llthangel", + "- A good job helping with bugs/especially SJ3", "", " \37Donations to Unreal:\37", "BlueFlame^", diff --git a/src/win32.c b/src/win32.c index 2ba760569..d7c5fd64f 100644 --- a/src/win32.c +++ b/src/win32.c @@ -1,905 +1 @@ -/************************************************************************ - * IRC - Internet Relay Chat, win32.c - * Copyright (C) 1996 Daniel Hazelbaker - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 1, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#ifndef lint -static char sccsid[] = "@(#)win32.c 2.01 10/21/96 (C) 1996 Daniel Hazelbaker"; -#endif - - -#define APPNAME "wIRCD" -#define wTITLEBAR "UnrealIRCd" - -// Windows Header Files: -#include "common.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "struct.h" -#include "sys.h" -#include -#include -#include "h.h" -#include "version.h" -#include "resource.h" -#include "CioFunc.h" - -ID_CVS("$Id$"); - - -BOOL InitApplication(HINSTANCE); -BOOL InitInstance(HINSTANCE, int); -LRESULT CALLBACK FrameWndProc(HWND, UINT, WPARAM, LPARAM); -LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM); -LRESULT CALLBACK Dlg_IRCDCONF(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); -LRESULT CALLBACK Dlg_IRCDMOTD(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); -LRESULT CALLBACK Dlg_IRCDRULES(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); - -BOOL DisplayString(HWND hWnd, char *InBuf, ...); -void LoadSetup(void); -void SaveSetup(void); -int SetDebugLevel(HWND hWnd, int NewLevel); - -LRESULT CALLBACK Credits(HWND, UINT, WPARAM, LPARAM); -LRESULT CALLBACK Dreamforge(HWND, UINT, WPARAM, LPARAM); -LRESULT CALLBACK IRCDLicense(HWND, UINT, WPARAM, LPARAM); - - -extern void SocketLoop(void *dummy), s_rehash(), do_dns_async(HANDLE id); -extern int localdie(void), InitwIRCD(int argc, char *argv[]); - - -HINSTANCE hInst; // current instance -char szAppName[] = APPNAME; // The name of this application -char szTitle[] = wTITLEBAR; // The title bar text -HWND hwIRCDWnd=NULL, hCio=NULL; -HANDLE hMainThread = 0; - -#ifndef IRCDTOTALVERSION -#define IRCDTOTALVERSION BASE_VERSION PATCH1 PATCH2 PATCH3 PATCH4 PATCH5 PATCH6 PATCH7 PATCH8 PATCH9 -#endif - -/* - * FUNCTION: WinMain(HANDLE, HANDLE, LPSTR, int) - * - * PURPOSE: Entry point for the application. - * - * COMMENTS: - * - * This function initializes the application and processes the - * message loop. - */ -int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) -{ - MSG msg; - HANDLE hAccelTable; - int argc=1; - char *s, *argv[20], String[128]; - - if (!hPrevInstance) - if (!InitApplication(hInstance)) - return (FALSE); - - if (!InitInstance(hInstance, nCmdShow)) - return (FALSE); - - argv[0] = "WIRCD.EXE"; - if ( *(s = lpCmdLine) ) - { - argv[argc++] = s; - while ( (s = strchr(s, ' ')) != NULL ) - { - while ( *s == ' ' ) *s++ = 0; - argv[argc++] = s; - } - } - argv[argc] = NULL; - if ( InitwIRCD(argc, argv) != 1 ) - return FALSE; - - wsprintf(String, "UnrealIRCd/32 - %s", me.name); - SetWindowText(hwIRCDWnd, String); - - SetDebugLevel(hwIRCDWnd, debuglevel); - - hMainThread = (HANDLE)_beginthread(SocketLoop, 0, NULL); - hAccelTable = LoadAccelerators (hInstance, szAppName); - - LoadSetup(); - atexit(SaveSetup); - - /* Say we are ready to recieve connections */ - wsprintf(String, "%c%c%c%c[info] -=-=[ UnrealIRCd/32 v%s Ready ] - %s\r", 0,0,0,0, VERSIONONLY); - DisplayString(hCio, String); - /* Main message loop */ - while (GetMessage(&msg, NULL, 0, 0)) - { - if ( !TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) - { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - } - - return (msg.wParam); - lpCmdLine; /* This will prevent 'unused formal parameter' warnings */ -} - - -/* - * FUNCTION: InitApplication(HANDLE) - * - * PURPOSE: Initializes window data and registers window class - * - * COMMENTS: - * - * In this function, we initialize a window class by filling out a data - * structure of type WNDCLASS and calling either RegisterClass or - * the internal MyRegisterClass. - */ -BOOL InitApplication(HINSTANCE hInstance) -{ - WNDCLASS wc; - - // Fill in window class structure. - wc.style = CS_HREDRAW | CS_VREDRAW; - wc.lpfnWndProc = (WNDPROC)FrameWndProc; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hInstance = hInstance; - wc.hIcon = LoadIcon (hInstance, APPNAME); - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); - wc.lpszMenuName = szAppName; - wc.lpszClassName = szAppName; - - if ( !RegisterClass(&wc) ) return 0; - - return 1; -} - - -/* - * FUNCTION: InitInstance(HANDLE, int) - * - * PURPOSE: Saves instance handle and creates main window - * - * COMMENTS: - * - * In this function, we save the instance handle in a global variable and - * create and display the main program window. - */ -BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) -{ - HWND hWnd; - WSADATA WSAData; - - - if ( WSAStartup(MAKEWORD(1, 1), &WSAData) != 0 ) - { - MessageBox(NULL, "UnrealIRCD/32 Init Error", "Unable to initialize WinSock DLL", MB_OK); - return FALSE; - } - - hInst = hInstance; /* Store instance handle in our global variable */ - - if ( !Cio_Init(hInst) ) - { - MessageBox(NULL, "UnrealIRCD/32 Init Error", "Couldn't Init CIO Library", MB_OK); - return FALSE; - } - - hWnd = CreateWindow(szAppName, szTitle, WS_OVERLAPPEDWINDOW, - CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, - NULL, NULL, hInstance, NULL); - - if ( !hWnd ) - return (FALSE); - - ShowWindow(hWnd, nCmdShow); - UpdateWindow(hwIRCDWnd = hWnd); - - return (TRUE); -} - - -/* - * FUNCTION: FrameWndProc(HWND, unsigned, WORD, LONG) - * - * PURPOSE: Processes messages for the main window. - * - */ -LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - int wmId, wmEvent; - char *xx = NULL; - - switch (message) - { - case WM_CREATE: - hCio = Cio_Create(hInst, hWnd, WS_VISIBLE, 0, 0, 300, 200); - xx = MyMalloc(1024); - sprintf(xx, "%c%c%c%c[info] -=-=[ UnrealIRCd/32 v%s Loading ]-=-=\r", 0, 0, 0, 0, - VERSIONONLY); - DisplayString(hCio, xx); -#ifdef WIN32_SPECIFY - sprintf(xx, "%c%c%c%c[info] - Ported by %s", 0,0,0,0, WIN32_PORTER); - DisplayString(hCio, xx); - sprintf(xx, "%c%c%c%c[info] - %s", 0,0,0,0, WIN32_URL); - DisplayString(hCio, xx); -#endif - MyFree(xx); - return 0; - case WM_COMMAND: - wmId = LOWORD(wParam); - wmEvent = HIWORD(wParam); - - switch (wmId) - { - case IDM_ABOUT: - DialogBox(hInst, "AboutBox", hWnd, (DLGPROC)About); - break; - case IDM_CREDITS: - DialogBox(hInst, "AboutBox", hWnd, (DLGPROC)Credits); - break; - case IDM_DF: - DialogBox(hInst, "AboutBox", hWnd, (DLGPROC)Dreamforge); - break; - case IDM_LICENSE: - DialogBox(hInst, "AboutBox", hWnd, (DLGPROC)IRCDLicense); - break; - - case IDM_IRCDCONF: - DialogBox(hInst, "DLG_IRCDCONF", hWnd, (DLGPROC)Dlg_IRCDCONF); - break; - case IDM_IRCDMOTD: - DialogBox(hInst, "DLG_IRCDMOTD", hWnd, (DLGPROC)Dlg_IRCDMOTD); - break; - case IDM_IRCDRULES: - DialogBox(hInst, "DLG_IRCDRULES", hWnd, (DLGPROC)Dlg_IRCDRULES); - break; - case IDM_REHASH: - s_rehash(); - break; - - case IDM_EXIT: - if ( MessageBox(hWnd, "Are you sure?", - "Terminate UnrealIRCD/32", - MB_ICONQUESTION | MB_YESNO) == IDNO ) - break; - DestroyWindow(hWnd); - break; - - case IDM_DBGOFF: - case IDM_DBGFATAL: - case IDM_DBGERROR: - case IDM_DBGNOTICE: - case IDM_DBGDNS: - case IDM_DBGINFO: - case IDM_DBGNUM: - case IDM_DBGSEND: - case IDM_DBGDEBUG: - case IDM_DBGMALLOC: - case IDM_DBGLIST: - SetDebugLevel(hWnd, wmId-IDM_DBGFATAL); - break; - - default: - return (DefWindowProc(hWnd, message, wParam, lParam)); - } - break; - - case WM_CLOSE: - if ( MessageBox(hWnd, "Are you sure?", "Terminate UnrealIRCd/32", - MB_ICONQUESTION | MB_YESNO) == IDNO ) - break; - return (DefWindowProc(hWnd, message, wParam, lParam)); - - case WM_DESTROY: - localdie(); /* Never returns */ - PostQuitMessage(0); - break; - - case WM_SIZE: - SetWindowPos(hCio, NULL, 0, 0, LOWORD(lParam), HIWORD(lParam), - SWP_NOZORDER); - /* Fallthrough to get the default handling too. */ - - default: - return (DefWindowProc(hWnd, message, wParam, lParam)); - } - return (0); -} - - -/* - * FUNCTION: About(HWND, unsigned, WORD, LONG) - * - * PURPOSE: Processes messages for "About" dialog box - * This version allows greater flexibility over the contents of the 'About' box, - * by pulling out values from the 'Version' resource. - * - * MESSAGES: - * - * WM_INITDIALOG - initialize dialog box - * WM_COMMAND - Input received - * - */ -LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) -{ - switch (message) - { - case WM_INITDIALOG: -#define Ccat strcat(String, String2) - { - char String[16384], String2[16384], **s = infotext; - sprintf(String, "%s\n%s", version, creation); - SetDlgItemText(hDlg, IDC_VERSION, String); - String[0] = 0; String2[0] = 0; - sprintf(String2, "-=-=-=-=-=-==-==- %s -=-=-==-==-=-=-=-=-=-\r\n", ircnetwork); Ccat; - sprintf(String2, "|Web Page: | http://www.%s\r\n", netdomain); Ccat; - sprintf(String2, "|FTP Archive: | ftp://ftp.%s\r\n", netdomain); Ccat; - sprintf(String2, "|Help channel: | %s\r\n", helpchan); Ccat; - sprintf(String2, "|=-=-=-=-=-==-==|-=-=-=-=-=-=-==-==-=-=-=-=-=-=-=\r\n"); Ccat; - sprintf(String2, "|IRCd version: | %s\r\n", IRCDTOTALVERSION); Ccat; - sprintf(String2, "| Developers: | Stskeeps \r\n"); Ccat; - sprintf(String2, "| | codemastr \r\n"); Ccat; -#if defined(_WIN32) && defined(WIN32_SPECIFY) - sprintf(String2, "| Win32 Porter: | %s\r\n", WIN32_PORTER); Ccat; - sprintf(String2, "| >>URL: | %s\r\n", WIN32_URL); Ccat; -#endif - sprintf(String2, "|Credits: | Type /Credits\r\n"); Ccat; - sprintf(String2, "|DALnet Credits:| Type /DALinfo\r\n"); Ccat; - sprintf(String2, "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\r\n"); Ccat; - sprintf(String2, "| Unreal IRCd can be downloaded at http://unreal.tspre.org\r\n"); Ccat; - sprintf(String2, "| This notice may not be removed from the IRCd package\r\n"); Ccat; - sprintf(String2, "| It will be a violation of copyright. This program must always stay free of charge\r\n"); Ccat; - sprintf(String2, "| being sold commercially or privately\r\n"); Ccat; - sprintf(String2, "| Only charge may be for the transport medium like on CD-ROM, floppy\r\n"); Ccat; - sprintf(String2, "| or other kinds (-Stskeeps'1999)\r\n"); Ccat; - sprintf(String2, "--------------------------------------------\r\n"); Ccat; - SetDlgItemText(hDlg, IDC_INFOTEXT, String); -#undef Ccat - ShowWindow (hDlg, SW_SHOW); - return (TRUE); - } - - case WM_COMMAND: - if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) - { - EndDialog(hDlg, TRUE); - return (TRUE); - } - break; - } - return FALSE; -} - -/* - * FUNCTION: Credits(HWND, unsigned, WORD, LONG) - * - * PURPOSE: Processes messages for "Credits" dialog box - * This version allows greater flexibility over the contents of the 'Credits' box, - * by pulling out values from the 'Version' resource. - * - * MESSAGES: - * - * WM_INITDIALOG - initialize dialog box - * WM_COMMAND - Input received - * - */ -LRESULT CALLBACK Credits(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) -{ - switch (message) - { - case WM_INITDIALOG: - { - char String[16384], **s = unrealcredits; - - sprintf(String, "%s\n%s", version, creation); - SetDlgItemText(hDlg, IDC_VERSION, String); - String[0] = 0; - while ( *s ) - { - strcat(String, *s++); - if ( *s ) - strcat(String, "\r\n"); - } - SetDlgItemText(hDlg, IDC_INFOTEXT, String); - - - ShowWindow (hDlg, SW_SHOW); - return (TRUE); - } - - case WM_COMMAND: - if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) - { - EndDialog(hDlg, TRUE); - return (TRUE); - } - break; - } - return FALSE; -} - -/* - * FUNCTION: Dreamforge(HWND, unsigned, WORD, LONG) - * - * PURPOSE: Processes messages for "Dreamforge" dialog box - * This version allows greater flexibility over the contents of the 'Dreamforge' box, - * by pulling out values from the 'Version' resource. - * - * MESSAGES: - * - * WM_INITDIALOG - initialize dialog box - * WM_COMMAND - Input received - * - */ -LRESULT CALLBACK Dreamforge(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) -{ - switch (message) - { - case WM_INITDIALOG: - { - char String[16384], **s = dalinfotext; - - sprintf(String, "%s\n%s", version, creation); - SetDlgItemText(hDlg, IDC_VERSION, String); - String[0] = 0; - while ( *s ) - { - strcat(String, *s++); - if ( *s ) - strcat(String, "\r\n"); - } - SetDlgItemText(hDlg, IDC_INFOTEXT, String); - - - ShowWindow (hDlg, SW_SHOW); - return (TRUE); - } - - case WM_COMMAND: - if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) - { - EndDialog(hDlg, TRUE); - return (TRUE); - } - break; - } - return FALSE; -} - -/* - * FUNCTION: IRCDLicense(HWND, unsigned, WORD, LONG) - * - * PURPOSE: Processes messages for "IRCDLicense" dialog box - * This version allows greater flexibility over the contents of the 'IRCDLicense' box, - * by pulling out values from the 'Version' resource. - * - * MESSAGES: - * - * WM_INITDIALOG - initialize dialog box - * WM_COMMAND - Input received - * - */ -LRESULT CALLBACK IRCDLicense(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) -{ - switch (message) - { - case WM_INITDIALOG: - { - char String[16384], **s = gnulicense; - - sprintf(String, "%s\n%s", version, creation); - SetDlgItemText(hDlg, IDC_VERSION, String); - String[0] = 0; - while ( *s ) - { - strcat(String, *s++); - if ( *s ) - strcat(String, "\r\n"); - } - SetDlgItemText(hDlg, IDC_INFOTEXT, String); - - - ShowWindow (hDlg, SW_SHOW); - return (TRUE); - } - - case WM_COMMAND: - if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) - { - EndDialog(hDlg, TRUE); - return (TRUE); - } - break; - } - return FALSE; -} - - -/* - * FUNCTION: Dlg_IrcdConf(HWND, unsigned, WORD, LONG) - * - * PURPOSE: Processes messages for "DLG_IRCDCONF" dialog box - * - */ -LRESULT CALLBACK Dlg_IRCDCONF(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) -{ - switch (message) - { - case WM_INITDIALOG: - { - char *Buffer = MyMalloc(65535); /* Should be big enough */ - int fd, Len; - - if ( !Buffer ) - { - MessageBox(hDlg, "Error: Could not allocate temporary buffer", - "UnrealIRCd/32 Setup", MB_OK); - EndDialog(hDlg, FALSE); - return FALSE; - } - /* Open the ircd.conf file */ - fd = open(CONFIGFILE, _O_RDONLY | _O_BINARY); - if ( fd == -1 ) - { - MessageBox(hDlg, "Error: Could not open configuration file", - "UnrealIRCd/32 Setup", MB_OK); - MyFree(Buffer); - EndDialog(hDlg, FALSE); - return FALSE; - } - - Buffer[0] = 0; /* Incase read() fails */ - Len = read(fd, Buffer, 65535); - Buffer[Len] = 0; - /* Set the text for the edit control to what was in the file */ - SendDlgItemMessage(hDlg, IDC_IRCDCONF, WM_SETTEXT, 0, - (LPARAM)(LPCTSTR)Buffer); - - close(fd); - MyFree(Buffer); - } - return (TRUE); - - case WM_COMMAND: - if ( LOWORD(wParam) == IDOK ) - { - char *Buffer = MyMalloc(65535); /* Should be big enough */ - DWORD Len; - int fd; - - if ( !Buffer ) - { - MessageBox(hDlg, "Error: Could not allocate temporary buffer", - "UnrealIRCD/32 Setup", MB_OK); - return TRUE; - } - /* Open the ircd.conf file */ - fd = open(CONFIGFILE, _O_TRUNC|_O_CREAT|_O_RDWR|_O_BINARY, - S_IREAD|S_IWRITE); - if ( fd == -1 ) - { - MessageBox(hDlg, "Error: Could not open configuration file", - "UnrealIRCD/32 Setup", MB_OK); - MyFree(Buffer); - return TRUE; - } - - /* Get the text from the edit control and save it to disk. */ - Len = SendDlgItemMessage(hDlg, IDC_IRCDCONF, WM_GETTEXT, 65535, - (LPARAM)(LPCTSTR)Buffer); - write(fd, Buffer, Len); - - close(fd); - MyFree(Buffer); - - EndDialog(hDlg, TRUE); - return TRUE; - } - if ( LOWORD(wParam) == IDCANCEL ) - { - EndDialog(hDlg, FALSE); - return TRUE; - } - break; - } - - return FALSE; -} - -/* - * FUNCTION: Dlg_Dlg_IRCdMotd(HWND, unsigned, WORD, LONG) - * - * PURPOSE: Processes messages for "DLG_IRCDCONF" dialog box - * - */ -LRESULT CALLBACK Dlg_IRCDMOTD(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) -{ - switch (message) - { - case WM_INITDIALOG: - { - char *Buffer = MyMalloc(65535*2); /* Should be big enough */ - int fd, Len; - - if ( !Buffer ) - { - MessageBox(hDlg, "Error: Could not allocate temporary buffer", - "UnrealIRCd/32 Setup", MB_OK); - EndDialog(hDlg, FALSE); - return FALSE; - } - /* Open the ircd.motd file */ - fd = open(MPATH, _O_RDONLY | _O_BINARY); - if ( fd == -1 ) - { - MessageBox(hDlg, "Error: Could not open MOTD file", - "UnrealIRCd/32 Setup", MB_OK); - MyFree(Buffer); - EndDialog(hDlg, FALSE); - return FALSE; - } - - Buffer[0] = 0; /* Incase read() fails */ - Len = read(fd, Buffer, 65535); - Buffer[Len] = 0; - /* Set the text for the edit control to what was in the file */ - SendDlgItemMessage(hDlg, IDC_IRCDCONF, WM_SETTEXT, 0, - (LPARAM)(LPCTSTR)Buffer); - - close(fd); - MyFree(Buffer); - } - return (TRUE); - - case WM_COMMAND: - if ( LOWORD(wParam) == IDOK ) - { - char *Buffer = MyMalloc(65535); /* Should be big enough */ - DWORD Len; - int fd; - - if ( !Buffer ) - { - MessageBox(hDlg, "Error: Could not allocate temporary buffer", - "UnrealIRCD/32 Setup", MB_OK); - return TRUE; - } - /* Open the ircd.motd file */ - fd = open(MPATH, _O_TRUNC|_O_CREAT|_O_RDWR|_O_BINARY, - S_IREAD|S_IWRITE); - if ( fd == -1 ) - { - MessageBox(hDlg, "Error: Could not open motd file", - "UnrealIRCD/32 Setup", MB_OK); - MyFree(Buffer); - return TRUE; - } - - /* Get the text from the edit control and save it to disk. */ - Len = SendDlgItemMessage(hDlg, IDC_IRCDCONF, WM_GETTEXT, 65535, - (LPARAM)(LPCTSTR)Buffer); - write(fd, Buffer, Len); - - close(fd); - MyFree(Buffer); - - EndDialog(hDlg, TRUE); - return TRUE; - } - if ( LOWORD(wParam) == IDCANCEL ) - { - EndDialog(hDlg, FALSE); - return TRUE; - } - break; - } - - return FALSE; -} - -/* - * FUNCTION: Dlg_IRCdRules(HWND, unsigned, WORD, LONG) - * - * PURPOSE: Processes messages for "DLG_IRCDCONF" dialog box - * - */ -LRESULT CALLBACK Dlg_IRCDRULES(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) -{ - switch (message) - { - case WM_INITDIALOG: - { - char *Buffer = MyMalloc(65535*2); /* Should be big enough */ - int fd, Len; - - if ( !Buffer ) - { - MessageBox(hDlg, "Error: Could not allocate temporary buffer", - "UnrealIRCd/32 Setup", MB_OK); - EndDialog(hDlg, FALSE); - return FALSE; - } - /* Open the ircd.rules file */ - fd = open(RPATH, _O_RDONLY | _O_BINARY); - if ( fd == -1 ) - { - MessageBox(hDlg, "Error: Could not open rules file", - "UnrealIRCd/32 Setup", MB_OK); - MyFree(Buffer); - EndDialog(hDlg, FALSE); - return FALSE; - } - - Buffer[0] = 0; /* Incase read() fails */ - Len = read(fd, Buffer, 65535); - Buffer[Len] = 0; - /* Set the text for the edit control to what was in the file */ - SendDlgItemMessage(hDlg, IDC_IRCDCONF, WM_SETTEXT, 0, - (LPARAM)(LPCTSTR)Buffer); - - close(fd); - MyFree(Buffer); - } - return (TRUE); - - case WM_COMMAND: - if ( LOWORD(wParam) == IDOK ) - { - char *Buffer = MyMalloc(65535); /* Should be big enough */ - DWORD Len; - int fd; - - if ( !Buffer ) - { - MessageBox(hDlg, "Error: Could not allocate temporary buffer", - "UnrealIRCD/32 Setup", MB_OK); - return TRUE; - } - /* Open the ircd.rules file */ - fd = open(RPATH, _O_TRUNC|_O_CREAT|_O_RDWR|_O_BINARY, - S_IREAD|S_IWRITE); - if ( fd == -1 ) - { - MessageBox(hDlg, "Error: Could not open rules file", - "UnrealIRCD/32 Setup", MB_OK); - MyFree(Buffer); - return TRUE; - } - - /* Get the text from the edit control and save it to disk. */ - Len = SendDlgItemMessage(hDlg, IDC_IRCDCONF, WM_GETTEXT, 65535, - (LPARAM)(LPCTSTR)Buffer); - write(fd, Buffer, Len); - - close(fd); - MyFree(Buffer); - - EndDialog(hDlg, TRUE); - return TRUE; - } - if ( LOWORD(wParam) == IDCANCEL ) - { - EndDialog(hDlg, FALSE); - return TRUE; - } - break; - } - - return FALSE; -} - - -int DisplayString(HWND hWnd, char *InBuf, ...) -{ - CioWndInfo *CWI; - va_list argptr; - char *Buffer=NULL, *Ptr=NULL; - DWORD Len=0, TLen=0, Off=0, i=0; - BYTE Red=0, Green=0, Blue=0; - BOOL Bold = FALSE; - - if ( (Buffer = LocalAlloc(LPTR, 16384)) == NULL ) return FALSE; - - va_start(argptr, InBuf); - Len = vsprintf(Buffer, InBuf, argptr); - va_end(argptr); - if ( Len == 0 ) - { - LocalFree(Buffer); - return FALSE; - } - - CWI = (CioWndInfo *)GetWindowLong(hWnd, GWL_USER); - for ( i = 0; i < Len; i++ ) - { - if ( Buffer[i] == 0 ) - { - i+=3; - continue; - } - if ( Buffer[i] == 0x02 ) - { - if ( !Bold ) - { - Buffer[i] = 0; - Cio_Puts(hWnd, Buffer+Off, i-Off); - Red = CWI->FR; - Green = CWI->FG; - Blue = CWI->FB; - - Off=i+1; - Cio_PrintF(hWnd, "%c%c%c%c", 0, 255, 32, 32); - Bold = 1; - continue; - } - if ( Bold ) - { - Buffer[i] = 0; - Cio_Puts(hWnd, Buffer+Off, i-Off); - Off=i+1; - Cio_PrintF(hWnd, "%c%c%c%c", 0, Red, Green, Blue); - Bold = 0; - continue; - } - } - } - Cio_Puts(hWnd, Buffer+Off, Len-Off); - - LocalFree(Buffer); - return TRUE; -} - - -void LoadSetup(void) -{ -} - -void SaveSetup(void) -{ -} - - -int SetDebugLevel(HWND hWnd, int NewLevel) -{ - HMENU hMenu = GetMenu(hWnd); - - if ( !hMenu || !(hMenu = GetSubMenu(hMenu, 1)) || - !(hMenu = GetSubMenu(hMenu, 4)) ) - return -1; - - CheckMenuItem(hMenu, IDM_DBGFATAL+debuglevel, - MF_BYCOMMAND | MF_UNCHECKED); - debuglevel = NewLevel; - CheckMenuItem(hMenu,IDM_DBGFATAL+debuglevel, - MF_BYCOMMAND | MF_CHECKED); - - return debuglevel; -} - - +Binary file win32.c matches diff --git a/src/zip.c b/src/zip.c index a0e0175dd..b355e9bfb 100644 --- a/src/zip.c +++ b/src/zip.c @@ -1,4 +1,4 @@ -/************************************************************************ +/* * IRC - Internet Relay Chat, ircd/s_zip.c * Copyright (C) 1996 Christophe Kalt * diff --git a/update b/update new file mode 100755 index 000000000..2b8f9885a --- /dev/null +++ b/update @@ -0,0 +1,19 @@ +#!/bin/sh +# +# Auto-update script for Unreal3.1 and higher +# (C) Carsten V. Munk 2000 +# +# This script may not be modified without consent of the author, +# or included in any package without permission from the author. +# +# NO WARRANTY IS INCLUDED +CURRENT_VERSION="Unreal3.1-Silverheart" +clear +cat .UPDATE +cd src +rm update.sh +wget http://unreal.tspre.org/update.sh +chmod +x update.sh +export CURRENT_VERSION +./update.sh +exit 1