Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

procinp.c 29.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/******************************************************************************
PROCINP.C    Process all TOP commands and input.

    Copyright 1993 - 2000 Paul J. Sidorsky

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License, version 2, as
    published by the Free Software Foundation.

    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
Deucе's avatar
Deucе committed
17
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091

This module processes all TOP commands.  Many are handled right in the
process_input() function, which accounts for its size.  Others (usually
multi-word commands) are handled by separate processors in other modules which
are called from this module.
******************************************************************************/

#include "top.h"

/* This macro is used to determine where the name starts in a whisper or
   directed message.  If there is a space at the start of the string, then
   shorthand mode was used (a single character).  Otherwise, longhand mode
   was used (two full words). */
#define spacecheck(xxxx) xxxx[0] == ' ' ? &xxxx[1] : &xxxx[0]

/* process_input() - Process all TOP commands and input.
   Parameters:  string - Input string to process.
   Returns:  Nothing.
*/
void process_input(unsigned char *string)
{
/* Shorthand flags for message sent and echo GA preferences. */
char msgsent = 1, echoga = 1;
/* Private node to receive the message (not used), number of words in input
   string, counter, command length holder, result code. */
XINT priv = -1, numwds, z, cmdlen = 0, res;
/* Action used flag, no longer used.  Was used with old single-list format. */
// char auflg = 0;
/* Node the message is destined for ("done to"). */
XINT sendto;
/* Command text holder, command handle holder. */
unsigned char tmpstr[256], tmphand[256]; // Dynam with MAXSTRLEN!

/* Check incoming messages before processing.  This results in a more
   realistic order for items to be displayed on screen. */
process_messages(FALSE);
/* Refresh active nodes. */
check_nodes_used(FALSE);

/* Prepare the screen for a command response. */
if (user.pref1 & PREF1_DUALWINDOW)
	{
	// Different for AVT when I find out what the store/recv codes are.
	od_disp_emu("\x1B" "[u", TRUE);
	top_output(OUT_SCREEN, getlang("DWOutputPrefix"));
	}
else
	{
	top_output(OUT_SCREEN, getlang("ResponsePrefix"));
	}

/* Set preference aliases. */
msgsent = user.pref1 & PREF1_MSGSENT;
echoga = user.pref1 & PREF1_ECHOGA;

/* Censor the string. */
if (numcensorwords > 0)
	{
	if (censorinput(string))
		{
        /* The censor blocked the input, so don't process it. */
		return;
		}
    }

/* Split the string into words. */
numwds = split_string(string);

/* Most commands are self-explanatory and simply call other functions to
   respond to the command in detail. */

/* QUIT command (exit TOP). */
if (checkcmdmatch(get_word(0), getlang("CmdsQuit")) > 0 &&
	numwds == 1)
	{
	dispatch_message(MSG_EXIT, user.xmessage, -1, 0, 0);
	unregister_node(1);
	quit_top();
	return;
	}
/* COMMANDS command (short list of all commands). */
if (checkcmdmatch(get_word(0), getlang("CmdsCommands")) > 0 &&
	numwds == 1)
	{
	minihelp();
	return;
	}
/* HELP command. */
if (checkcmdmatch(get_word(0), getlang("CmdsHelp")) > 0)
	{
	help_proc(numwds);
	return;
	}
/* COLOURHELP command (PubColour code list). */
if (checkcmdmatch(get_word(0), getlang("CmdsColourHelp")) > 0 &&
	numwds == 1)
	{
	top_output(OUT_SCREEN, getlang("ColourHelpPrefix"));
	show_file("colhelp", SCRN_NONE);
	return;
	}
/* ACTION multi-word command. */
if (checkcmdmatch(get_word(0), getlang("CmdsAction")) > 0)
	{
	if (!cfg.allowactions)
		{
		top_output(OUT_SCREEN, getlang("ActionsNotAllowed"));
		return;
		}
	if (user.security < cfg.actionusesec)
		{
		top_output(OUT_SCREEN, getlang("NoAccActUse"));
		return;
		}
	action_proc(numwds);
	return;
	}
/* TIME command. */
if (checkcmdmatch(get_word(0), getlang("CmdsTime")) > 0 &&
	numwds == 1)
	{
	show_time();
	return;
	}
/* SCAN or WHO command (show who's in each channel). */
if (checkcmdmatch(get_word(0), getlang("CmdsWho")) > 0 &&
	numwds == 1)
	{
	scan_pub();
	return;
	}
/* CDTOTAL command.  Not used, it was used with the games and was left in
   for future upgradability.  It could also be used with BJ4TOP if BJ4TOP
   stored the cybercash in the TOP user file, as there is already space
   reserved in the file for a cybercash total. */
if (checkcmdmatch(get_word(0), getlang("CmdsCDTotal")) > 0 &&
	numwds == 1)
	{
	ultoa(user.cybercash, outnum[0], 10);
	top_output(OUT_SCREEN, getlang("CDTotal"), outnum[0],
			   user.cybercash == 1 ? getlang("CDSingular") :
									 getlang("CDPlural"));
	return;
	}
/* PROFILE command (enter the profile editor). */
if (checkcmdmatch(get_word(0), getlang("CmdsProfile")) > 0 &&
	numwds == 1)
	{
	node->task |= TASK_EDITING;
	save_node_data(od_control.od_node, node);
	dispatch_message(MSG_INEDITOR, user.handle, -1, 0, 0);
	cmi_busy();
	profile_editor();
	cmi_unbusy();
	node->task = node->task & (0xFF - TASK_EDITING);
	save_node_data(od_control.od_node, node);
	dispatch_message(MSG_OUTEDITOR, user.handle, -1, 0, 0);
	return;
	}
/* BIO command (enter the biography editor). */
if (checkcmdmatch(get_word(0), getlang("CmdsBio")) > 0 &&
    numwds == 1)
	{
	node->task |= TASK_EDITING;
	save_node_data(od_control.od_node, node);
	dispatch_message(MSG_INBIOEDITOR, user.handle, -1, 0, 0);
    cmi_busy();
    bioeditor();
    cmi_unbusy();
	node->task = node->task & (0xFF - TASK_EDITING);
	save_node_data(od_control.od_node, node);
	dispatch_message(MSG_OUTBIOEDITOR, user.handle, -1, 0, 0);
	return;
	}
/* LOOKUP command (view a user's biography. */
if (checkcmdmatch(get_word(0), getlang("CmdsLookUp")) > 0)
	{
/* Old-style (pre-bio) lookup that showed all users. */
/*    if (numwds == 1)
		{
		lookup("\0");
		return;
		}
	lookup(&word_str[word_pos[1]]);*/
    /* LOOKUP needs a user name. */
    if (numwds == 1)
		{
		show_helpfile("helplkup");
		return;
		}
	if (displaybio(&word_str[word_pos[1]]))
		{
		top_output(OUT_SCREEN, getlang("LookUpSuffix"));
		}
	return;
	}
/* USERLIST command (show list of all TOP users). */
if (checkcmdmatch(get_word(0), getlang("CmdsUserList")) > 0)
	{
	userlist();
	return;
	}
/* /LOGOFF command (quit TOP and hang up immediately). */
if (checkcmdmatch(get_word(0), getlang("CmdsLogOff")) > 0 &&
	numwds == 1)
	{
	top_output(OUT_SCREEN, getlang("DirectLogOffMsg"));
	dispatch_message(MSG_EXIT, user.xmessage, -1, 0, 0);
	unregister_node(FALSE);
	od_exit(8, TRUE);
	return;
	}
/* CHAT command (enter private chat mode). */
if (checkcmdmatch(get_word(0), getlang("CmdsPrivChat")) > 0)
	{
    /* CHAT needs a name. */
    if (numwds > 1)
		{
        /* Determine the node of the user to chat with. */
        sendto = find_node_from_name(tmpstr, tmphand,
									 &word_str[word_pos[1]]);

		if (sendto == -1)
			{
			top_output(OUT_SCREEN, getlang("NotLoggedIn"), tmphand);
			}
		if (sendto == -2)
			{
			top_output(OUT_SCREEN, getlang("NotSpecific"), tmphand);
			}
		if (sendto == -3)
			{
			top_output(OUT_SCREEN, getlang("HasForgotYou"),
					   handles[lastsendtonode].string);
			}
        /* CHAT can be done across channels. */
        if (sendto == -4)
			{
			sendto = lastsendtonode;
			}
        /* Can't chat with yourself (it would be a nightmare technically). */
        if (sendto == od_control.od_node)
			{
			top_output(OUT_SCREEN, getlang("CantDoCmdToSelf"));
			return;
			}
		if (sendto >= 0)
			{
            if (privchatin >= 0 && privchatin != sendto)
				{
                /* If somebody else is waiting to chat with this node,
                   the user can't request a chat. */
				top_output(OUT_SCREEN, getlang("PrivChatCantReq1"),
						   handles[privchatin].string);
				return;
				}
			if (privchatout >= 0)
				{
                /* If we've already requested to chat with somebody, we
                   can't request another chat. */
				top_output(OUT_SCREEN, getlang("PrivChatCantReq2"),
						   handles[privchatout].string);
				return;
				}

			if (privchatin == sendto)
				{
                /* Answer a chat request from another node, which engages
                   private chat mode. */

                /* Notify everybody else in the channel that we are going
                   into private chat mode. */
                dispatch_message(MSG_INPRIVCHAT, user.handle, -1, 0, 0);
                /* Acknowledge the private chat. */
                msgsendglobal = 1;
				dispatch_message(MSG_WANTSPRIVCHAT, user.handle,
								 privchatin, 1, 0);
				node->task |= TASK_PRIVATECHAT;
				save_node_data(od_control.od_node, node);
				cmi_busy();
				privatechat(privchatin);
				cmi_unbusy();
				node->task = node->task & (0xFF - TASK_PRIVATECHAT);
				save_node_data(od_control.od_node, node);
				dispatch_message(MSG_OUTPRIVCHAT, user.handle, -1, 0, 0);
				}
			else
				{
                /* We are sending a new request to the other node. */
				msgsendglobal = 1;
				dispatch_message(MSG_WANTSPRIVCHAT, user.handle,
								 sendto, 1, 0);
				top_output(OUT_SCREEN, getlang("PrivChatReqOK"),
						   handles[sendto].string);
				privchatout = sendto;
				}
			}
		return;
		}
	}
/* DENYCHAT command (denies a user's private chat request. */
if (checkcmdmatch(get_word(0), getlang("CmdsPrivDenyChat")) > 0 &&
	numwds == 1)
	{
	if (privchatin >= 0)
		{
        /* Deny a request if we have one. */
        msgsendglobal = 1;
		dispatch_message(MSG_DENYPRIVCHAT, user.handle, privchatin, 1, 0);
		top_output(OUT_SCREEN, getlang("PrivChatDenyOK"),
				   handles[privchatin].string);
		privchatin = -1;
		}
	else
		{
        /* No request to deny. */
		top_output(OUT_SCREEN, getlang("PrivChatCantDeny"));
		}
	return;
	}
/* NODES command (show who's on the entire BBS). */
if (checkcmdmatch(get_word(0), getlang("CmdsNodes")) > 0 &&
	numwds == 1)
	{
    /* This command only works if BBS interfacing is on. */
    if (cfg.bbstype == BBS_UNKNOWN)
		{
		top_output(OUT_SCREEN, getlang("CmdNotAvail"));
		return;
		}
	bbs_useron(TRUE);
	return;
	}
/* PAGE command (send a message to a user elsewhere on the BBS). */
if (checkcmdmatch(get_word(0), getlang("CmdsPage")) > 0)
	{
    XINT pnode = -1; /* Node to page. */
    char *pmsg = NULL; /* Text to page the node with. */

    /* This command only works if BBS interfacing is on. */
	if (cfg.bbstype == BBS_UNKNOWN)
		{
		top_output(OUT_SCREEN, getlang("CmdNotAvail"));
		return;
		}
    /* The user specified the node number with the command. */
    if (numwds > 1)
        {
        pnode = atoi(get_word(1));
        if (pnode < 1)
            {
            itoa(cfg.maxnodes - 1, outnum[0], 10);
            top_output(OUT_SCREEN, getlang("InvalidNode"), outnum[0]);
            return;
            }
        }
    /* The user specified text with the command. */
    if (numwds > 2)
        {
        pmsg = &word_str[word_pos[2]];
        }
    bbs_page(pnode, pmsg);
	return;
	}
/* FORGET command (ignores a user). */
if (cfg.allowforgetting && user.security >= cfg.forgetsec &&
	checkcmdmatch(get_word(0), getlang("CmdsForget")) > 0)
	{
    /* FORGET needs a name. */
    if (numwds > 1)
		{
        node_idx_typ fgtchk; /* Data for node to forget. */

        /* Find node of user to forget. */
        sendto = find_node_from_name(tmpstr, tmphand,
									 &word_str[word_pos[1]]);

        /* FORGET is channel-independent and does not care if the user
           has already forgotten us. */
        if (sendto == -3 || sendto == -4)
			{
			sendto = lastsendtonode;
			}

		if (sendto == -1)
			{
			top_output(OUT_SCREEN, getlang("NotLoggedIn"), tmphand);
			}
		if (sendto == -2)
			{
			top_output(OUT_SCREEN, getlang("NotSpecific"), tmphand);
			}
        /* Forgetting yourself was causing too many technical problems
           so it is restricted to other users. */
        if (sendto == od_control.od_node)
			{
			top_output(OUT_SCREEN, getlang("CantDoCmdToSelf"));
			return;
			}
		get_node_data(sendto, &fgtchk);
        /* Can't forget a user with sysop security. */
        if (fgtchk.security >= cfg.sysopsec)
			{
			top_output(OUT_SCREEN, getlang("CantDoCmdToSysop"));
			return;
			}
		if (sendto >= 0)
			{
			forgetstatus[sendto] |= FGT_FORGOTTEN;
			msgsendglobal = 1;
			dispatch_message(MSG_FORGET, "\0", sendto, 1, 0);
			top_output(OUT_SCREEN, getlang("Forgotten"),
					   handles[sendto].string);
			}
		return;
		}
	}
/* REMEMBER command (undoes a FORGET command). */
if (cfg.allowforgetting && user.security >= cfg.forgetsec &&
	checkcmdmatch(get_word(0), getlang("CmdsRemember")) > 0)
	{
    /* Find node of user to forget. */
	if (numwds > 1)
		{
		sendto = find_node_from_name(tmpstr, tmphand,
									 &word_str[word_pos[1]]);

        /* REMEMBER is channel-independent and does not care if the user
           has forgotten us. */
		if (sendto == -3 || sendto == -4)
			{
			sendto = lastsendtonode;
			}

		if (sendto == -1)
			{
			top_output(OUT_SCREEN, getlang("NotLoggedIn"), tmphand);
			}
		if (sendto == -2)
			{
			top_output(OUT_SCREEN, getlang("NotSpecific"), tmphand);
			}
        /* Technically remembering yourself does not cause any problems
           (even though forgetting yourself does) but for consistency it is
           not allowed. */
        if (sendto == od_control.od_node)
			{
			top_output(OUT_SCREEN, getlang("CantDoCmdToSelf"));
			return;
			}
		if (sendto >= 0)
			{
			forgetstatus[sendto] &= (255 - FGT_FORGOTTEN);
			msgsendglobal = 1;
			dispatch_message(MSG_REMEMBER, "\0", sendto, 1, 0);
			top_output(OUT_SCREEN, getlang("Remembered"),
					   handles[sendto].string);
			}
		return;
		}
	}
/* User hit ENTER without typing any text. */
if (string[0] == 0 || numwds == 0)
	{
    /* Show the quick list of who's online and the short help. */
	channelsummary();
	return;
	}
/* JOIN command (changes the user's current channel. */
if (checkcmdmatch(get_word(0), getlang("CmdsJoin")) > 0)
	{
    unsigned long tchan; /* Channel to join. */
    long tch; /* Channel record number. */

	if (numwds > 1)
		{
        /* Check the channel name (if one was used) is valid. */
        if ((tchan = checkchannelname(&word_str[word_pos[1]])) > 0)
			{
            /* The name is valid. */

            /* Get the data from CHANIDX.TCH. */
            tch = findchannelrec(tchan);
            if (tch > -1L)
				{
                /* Data was found. */

                if (user.security < chan[tch].minsec ||
					user.security > chan[tch].maxsec)
					{
					top_output(OUT_SCREEN, getlang("BadChannelSec"));
					}
				else
					{
                    /* Leave the current channel. */
                    res = cmi_unjoin(curchannel);
					if (res != CMI_OKAY)
						{
						top_output(OUT_SCREEN, getlang("UnJoinError"));
						}
                    /* Join the new channel. */
                    res = cmi_join(tchan);
					if (res == CMIERR_BANNED)
						{
						top_output(OUT_SCREEN, getlang("Banned"));
						}
					if (res == CMIERR_NOINV)
						{
						top_output(OUT_SCREEN, getlang("NotInvited"));
						}
					if (res != CMI_OKAY && res != CMIERR_BANNED &&
						res != CMIERR_NOINV)
						{
						top_output(OUT_SCREEN, getlang("JoinError"));
						}
					if (res == CMI_OKAY)
						{
                        /* The join was successful. */
                        if (tchan > 0UL && tchan < 4000000000UL)
							{
							top_output(OUT_SCREEN, getlang("NowInChannel"),
									   channelname(tchan));
							}
						if (tchan >= 4001000000UL)
							{
							top_output(OUT_SCREEN, getlang("NowInConference"),
									   channelname(tchan));
							}
						dispatch_message(MSG_OUTCHANNEL, "\0", -1, 0, 0);
						curchannel = tchan;
						node->channel = curchannel;
						save_node_data(od_control.od_node, node);
						dispatch_message(MSG_INCHANNEL, "\0", -1, 0, 0);
						channelsummary();
						}
					else
						{
                        /* Rejoin the previous channel since we're not
                           allowed in the new one. */
						res = cmi_join(curchannel);
						if (res != CMI_OKAY)
							{
							top_output(OUT_SCREEN, getlang("CantReJoin"));
                            od_exit(230, FALSE);
							}
						}
					}
				}
			else
				{
                /* No data was found.  Currently the only difference if this
                   occurs is that the security is not checked, but this may
                   change so the entire procedure is duplicated. */

                /* Leave the current channel. */
                res = cmi_unjoin(curchannel);
				if (res != CMI_OKAY)
					{
					top_output(OUT_SCREEN, getlang("UnJoinError"));
					}
                /* Join the new channel. */
                res = cmi_join(tchan);
				if (res == CMIERR_BANNED)
					{
					top_output(OUT_SCREEN, getlang("Banned"));
					}
				if (res == CMIERR_NOINV)
					{
					top_output(OUT_SCREEN, getlang("NotInvited"));
					}
				if (res != CMI_OKAY && res != CMIERR_BANNED &&
					res != CMIERR_NOINV)
					{
					top_output(OUT_SCREEN, getlang("JoinError"));
					}
				if (res == CMI_OKAY)
					{
                    /* The join was sucessful. */
					if (tchan > 0UL && tchan < 4000000000UL)
						{
						top_output(OUT_SCREEN, getlang("NowInChannel"),
								   channelname(tchan));
						}
					if (tchan >= 4001000000UL)
						{
						top_output(OUT_SCREEN, getlang("NowInConference"),
								   channelname(tchan));
						}
					dispatch_message(MSG_OUTCHANNEL, "\0", -1, 0, 0);
					curchannel = tchan;
					node->channel = curchannel;
					save_node_data(od_control.od_node, node);
					dispatch_message(MSG_INCHANNEL, "\0", -1, 0, 0);
					channelsummary();
					}
				else
					{
                    /* Rejoin the old channel since we're not allowed in the
                       new one. */
                    res = cmi_join(curchannel);
					if (res != CMI_OKAY)
						{
						top_output(OUT_SCREEN, getlang("CantReJoin"));
                        od_exit(230, FALSE);
						}
					}
				}
			}
		else
			{
            /* The name was invalid. */

            /* If the second word (the channel to join) is all digits, it
               is not considered a name. */
            for (z = 0; z < strlen(&word_str[word_pos[1]]); z++)
				{
				if (!isdigit(word_str[word_pos[1] + z]))
					{
					z = -1;
					break;
					}
				}

            /* Convert the string to a number. */
            tchan = strtoul(&word_str[word_pos[1]], NULL, 10);

            /* Join the channel by number. */
			if (((tchan > 0 && tchan < 4000000000UL) ||
                /* Sysops may join channel 0 for global announcements. */
                (tchan == 0 && user.security >= cfg.sysopsec)) &&
				z != -1)
				{
                /* Leave the current channel. */
                res = cmi_unjoin(curchannel);
				if (res != CMI_OKAY)
					{
					top_output(OUT_SCREEN, getlang("UnJoinError"));
					}
                /* Join the new channel. */
                res = cmi_join(tchan);
				if (res == CMIERR_BANNED)
					{
					top_output(OUT_SCREEN, getlang("Banned"));
					}
				if (res == CMIERR_NOINV)
					{
					top_output(OUT_SCREEN, getlang("NotInvited"));
					}
				if (res != CMI_OKAY && res != CMIERR_BANNED &&
					res != CMIERR_NOINV)
					{
					top_output(OUT_SCREEN, getlang("JoinError"));
					}
				if (res == CMI_OKAY)
					{
                    /* The join was successful. */
					top_output(OUT_SCREEN, getlang("NowInChannel"),
							   channelname(tchan));
					dispatch_message(MSG_OUTCHANNEL, "\0", -1, 0, 0);
					curchannel = tchan;
					node->channel = curchannel;
					save_node_data(od_control.od_node, node);
					dispatch_message(MSG_INCHANNEL, "\0", -1, 0, 0);
					channelsummary();
					}
				else
					{
                    /* Rejoin the old channel as we are not allowed in
                       the new one. */
                    res = cmi_join(curchannel);
					if (res != CMI_OKAY)
						{
						top_output(OUT_SCREEN, getlang("CantReJoin"));
                        od_exit(230, FALSE);
						}
					}
				}
			else
				{
                /* The name is invalid and it was not determined to be a
                   number, so see if it is the name of a user to join their
                   personal channel. */
                sendto = find_node_from_name(tmpstr, tmphand,
											 &word_str[word_pos[1]]);
                /* Obviously, the JOIN command is channel-independent. */
                if (sendto == -4)
					{
					sendto = lastsendtonode;
					}
				if (sendto >= 0)
					{
                    /* A user's name was found so join their personal
                       channel. */
					tchan = (long) sendto + 4000000000UL;

                    /* Leave the current channel. */
					res = cmi_unjoin(curchannel);
					if (res != CMI_OKAY)
						{
						top_output(OUT_SCREEN, getlang("UnJoinError"));
						}
                    /* Join the new one. */
                    res = cmi_join(tchan);
					if (res == CMIERR_BANNED)
						{
						top_output(OUT_SCREEN, getlang("Banned"));
						}
					if (res == CMIERR_NOINV)
						{
						top_output(OUT_SCREEN, getlang("NotInvited"));
						}
					if (res != CMI_OKAY && res != CMIERR_BANNED &&
						res != CMIERR_NOINV)
						{
						top_output(OUT_SCREEN, getlang("JoinError"));
						}
					if (res == CMI_OKAY)
						{
                        /* The join was sucessful. */
                        top_output(OUT_SCREEN, getlang("NowInUserChannel"),
								   channelname(tchan));
						dispatch_message(MSG_OUTCHANNEL, "\0", -1, 0, 0);
						curchannel = tchan;
						node->channel = curchannel;
						save_node_data(od_control.od_node, node);
						dispatch_message(MSG_INCHANNEL, "\0", -1, 0, 0);
						channelsummary();
						}
					else
						{
                        /* Rejoin the old channel as we're not allowed in
                           the new one. */
						res = cmi_join(curchannel);
						if (res != CMI_OKAY)
							{
							top_output(OUT_SCREEN, getlang("CantReJoin"));
                            od_exit(230, FALSE);
							}
						}
					}
				else
					{
                    /* Invalid channel number/name. */
					top_output(OUT_SCREEN, getlang("BadChannelName"));
					}
				}
			}
		return;
		}
	}
/* CONFLIST command (list conferences). */
if (checkcmdmatch(get_word(0), getlang("CmdsConfList")) > 0 &&
	numwds == 1)
	{
	list_channels();
	return;
	}
/* MODERATOR multi-word command. */
if (checkcmdmatch(get_word(0), getlang("CmdsModerator")) > 0)
	{
	mod_proc();
	return;
	}
/* SYSOP multi-word command. */
if (checkcmdmatch(get_word(0), getlang("CmdsSysop")) > 0 &&
	user.security >= cfg.sysopsec)
	{
	sysop_proc();
	return;
	}
/* CHANGE multi-word command. */
if (checkcmdmatch(get_word(0), getlang("CmdsChange")) > 0)
	{
	change_proc();
	return;
	}
/* General action. */
if (!(user.pref2 & PREF2_ACTIONSOFF) && cfg.allowgas &&
	checkcmdmatch(get_word(0), getlang("CmdsGA")) > 0)
	{
	if (user.security < cfg.actionusesec)
		{
		top_output(OUT_SCREEN, getlang("NoAccActUse"));
		return;
		}
    /* GAs need text after the command. */
    if (numwds > 1)
		{
		top_output(OUT_SCREEN, getlang("GASentPrefix"));
		dispatch_message(MSG_GA, &word_str[word_pos[1]], -1, 0, echoga);
		if (msgsent)
			{
			top_output(OUT_SCREEN, getlang("GASent"));
			}
		return;
		}
	top_output(OUT_SCREEN, getlang("GANotSentPrefix"));
	if (msgsent)
		{
		top_output(OUT_SCREEN, getlang("GANotSent"));
		}
	return;
	}
/* Posessive general action. */
if (!(user.pref2 & PREF2_ACTIONSOFF) && cfg.allowgas &&
	checkcmdmatch(get_word(0), getlang("CmdsGA2")) > 0)
	{
    /* This command is treated identically to a normal GA except for the
       message number sent to other nodes. */

	if (user.security < cfg.actionusesec)
		{
		top_output(OUT_SCREEN, getlang("NoAccActUse"));
		return;
		}
	if (numwds > 1)
		{
		top_output(OUT_SCREEN, getlang("GASentPrefix"));
		dispatch_message(MSG_GA2, &word_str[word_pos[1]], -1, 0, echoga);
		if (msgsent)
			{
			top_output(OUT_SCREEN, getlang("GASent"));
			}
		return;
		}
	top_output(OUT_SCREEN, getlang("GANotSentPrefix"));
	if (msgsent)
		{
		top_output(OUT_SCREEN, getlang("GANotSent"));
		}
	return;
	}

/* Game multi-word commands, not used at this time. */
if (checkcmdmatch(get_word(0), getlang("CmdsSlots")))
	{
	slots_game();
	return;
	}
/*//|if (checkcmdmatch(get_word(0), getlang("CmdsPoker")))
	{
	poker_game(numwds);
	return;
	}*///|
if (checkcmdmatch(get_word(0), getlang("CmdsMatch")))
	{
	matchgame();
	return;
	}

/* Spawn commands, not used at this time. */
/*if (check_spawn_cmds(numwds))
	{
	return;
	}*/

/* Whispers (WHISPER TO or /). */
if (cfg.allowprivmsgs &&
    /* Check both words of the long form and the single character of the
       short form. */
    ((checkcmdmatch(get_word(0), getlang("CmdsWhisperLong1")) &&
	 checkcmdmatch(get_word(1), getlang("CmdsWhisperLong2"))) ||
	 get_word_char(0, 0) == getlangchar("WhisperShortChar", 0)))
	{
	if (user.security < cfg.privmessagesec)
		{
		top_output(OUT_SCREEN, getlang("NoAccPrivMsg"));
		return;
		}

	if (get_word_char(0, 0) == getlangchar("WhisperShortChar", 0))
		{
        /* Short form was used, so the length of the command is one (a
           single character). */
		cmdlen = 1;
        /* Test if only the command letter was specified. */
        if (strlen(get_word(0)) == 1)
			{
			cmdlen = -1;
			}
		}
	else
		{
        /* Long form was used, so the command length is the length of the
           two command words (usually WHISPER TO). */
        cmdlen = word_pos[2];
        /* Test if only the two command words were specified. */
        if (numwds < 3)
			{
			cmdlen = -1;
			}
		}

	if (cmdlen >= 0)
		{
        /* Determine which node to send the whisper to. */
		sendto = find_node_from_name(tmpstr, tmphand, &string[cmdlen]);

        /* Don't send if no text was specified (i.e. just a name). */
        if ((tmpstr[0] == '\0' || tmpstr[1] == '\0') && sendto >= 0)
			{
			cmdlen = -1;
			}

		if (cmdlen >= 0)
			{
			if (sendto == -1)
				{
				top_output(OUT_SCREEN, getlang("NotLoggedIn"), tmphand);
				}
			if (sendto == -2)
				{
				top_output(OUT_SCREEN, getlang("NotSpecific"), tmphand);
				}
			if (sendto == -3)
				{
				top_output(OUT_SCREEN, getlang("HasForgotYou"),
						   handles[lastsendtonode].string);
				}
			if (sendto == -4)
				{
				top_output(OUT_SCREEN, getlang("NotInYourChannel"),
						   handles[lastsendtonode].string);
				}
			if (sendto >= 0)
				{
                /* Send the whisper. */
				top_output(OUT_SCREEN, getlang("WhisperSentPrefix"));
				dispatch_message(MSG_WHISPER, spacecheck(tmpstr), sendto,
								 1, 0);
				if (msgsent)
					{
					top_output(OUT_SCREEN, getlang("WhisperSent"),
							   handles[sendto].string);
					}
				}
			return;
			}
		}

    /* Not enough information was specified. */
    top_output(OUT_SCREEN, getlang("WhisperNotSentPref"));
	if (msgsent)
		{
		top_output(OUT_SCREEN, getlang("WhisperNotSent"));
		}
	return;
	}
/* Directed messages. */
if ( ((checkcmdmatch(get_word(0), getlang("CmdsDirectedLong1")) &&
	 checkcmdmatch(get_word(1), getlang("CmdsDirectedLong2"))) ||
	 get_word_char(0, 0) == getlangchar("DirectedShortChar", 0)))
	{
    /* Directed messages are handled identically to whispers except for the
       commands, the message sent to other nodes, and the language items
       used. */

    if (get_word_char(0, 0) == getlangchar("DirectedShortChar", 0))
		{
		cmdlen = 1;
		if (strlen(get_word(0)) == 1)
			{
			cmdlen = -1;
			}
		}
	else
		{
		cmdlen = word_pos[2];
		if (numwds < 3)
			{
			cmdlen = -1;
			}
		}

	if (cmdlen >= 0)
		{
		sendto = find_node_from_name(tmpstr, tmphand, &string[cmdlen]);
		if ((tmpstr[0] == '\0' || tmpstr[1] == '\0') && sendto >= 0)
			{
			cmdlen = -1;
			}

		if (cmdlen >= 0)
			{
			if (sendto == -1)
				{
				top_output(OUT_SCREEN, getlang("NotLoggedIn"), tmphand);
				}
			if (sendto == -2)
				{
				top_output(OUT_SCREEN, getlang("NotSpecific"), tmphand);
				}
			if (sendto == -3)
				{
				top_output(OUT_SCREEN, getlang("HasForgotYou"),
						   handles[lastsendtonode].string);
				}
			if (sendto == -4)
				{
				top_output(OUT_SCREEN, getlang("NotInYourChannel"),
						   handles[lastsendtonode].string);
				}
			if (sendto >= 0)
				{
				top_output(OUT_SCREEN, getlang("DirectedSentPrefix"));
				dispatch_message(MSG_DIRECTED, spacecheck(tmpstr), sendto,
                                 0, user.pref2 & PREF2_ECHOOWNTEXT);
				if (msgsent)
					{
					top_output(OUT_SCREEN, getlang("DirectedSent"),
							   handles[sendto].string);
					}
				}
			return;
			}
		}
	top_output(OUT_SCREEN, getlang("DirectNotSentPref"));
	if (msgsent)
		{
		top_output(OUT_SCREEN, getlang("DirectedNotSent"));
		}
	return;
	}

/* Old-style (single list) action processor. */
/*load_action_verbs();
for (z = 0; z < numactions && !auflg && !cfg.allowactions; z++)
	{
	if (!stricmp(verbs[z].string, get_word(0)) &&
		verbs[z].string[0])
		{
		process_action(z, numwds, string);
		z = numactions;
		top_output(OUT_SCREEN, getlang("ActionUseSuffix"));
		auflg = 1;
		}
	}
for (z = 0; z < 4 && !auflg && cfg.allowactions; z++)
	{
	if (!stricmp(user.persact[z].verb, get_word(0)) &&
		user.persact[z].verb[0])
		{
		process_action(-(z + 1), numwds, string);
		z = 1000;
		top_output(OUT_SCREEN, getlang("ActionUseSuffix"));
		auflg = 1;
		}
	}*/

/* Check if the user used an action. */
if (cfg.allowactions && !(user.pref2 & PREF2_ACTIONSOFF) &&
	user.security >= cfg.actionusesec)
	{
	if (action_check(numwds))
		{
		return;
		}
	}

/* Normal text. */
if (user.security < cfg.talksec)
	{
	top_output(OUT_SCREEN, getlang("NoAccTalk"));
	return;
	}
dispatch_message(MSG_TEXT, string, priv, 0,
                 user.pref2 & PREF2_ECHOOWNTEXT);
top_output(OUT_SCREEN, getlang("MsgSentPrefix"));
if (msgsent)
	{
	top_output(OUT_SCREEN, getlang("MsgSent"));
	}

}