ui.c
资源名称:micq.tgz [点击查看]
上传用户:ai20ln
上传日期:2007-01-05
资源大小:79k
文件大小:31k
源码类别:
ICQ/即时通讯
开发平台:
Unix_Linux
- /*********************************************
- **********************************************
- This file has the "ui" functions that read input
- and send messages etc.
- This software is provided AS IS to be used in
- whatever way you see fit and is placed in the
- public domain.
- Author : Matthew Smith April 23, 1998
- Contributors : Nicolas Sahlqvist April 27, 1998
- Michael Ivey May 4, 1998
- Ulf Hedlund -- Windows Support
- Michael Holzt May 5, 1998
- Changes :
- 22-6-98 Added the save and alter command and the
- new implementation of auto
- **********************************************
- **********************************************/
- #define color_cmd "color"
- #define sound_cmd "sound"
- #include "micq.h"
- #include "datatype.h"
- #include <stdio.h>
- #include <stdlib.h>
- #ifdef _WIN32
- #include <winsock2.h>
- #else
- #include <unistd.h>
- #include <netinet/in.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <sys/time.h>
- #include <sys/socket.h>
- #include <arpa/inet.h>
- #include <netdb.h>
- #endif
- #include <fcntl.h>
- #include <time.h>
- #include <stdarg.h>
- #include <string.h>
- #include <ctype.h>
- #include <assert.h>
- #include "ui.h"
- USER_INFO_STRUCT user;
- #ifdef UNIX
- char *strdup( const char * );
- int strcasecmp( const char *, const char * );
- #endif
- BOOL Do_Multiline( SOK_T sok, char *buf )
- {
- static int offset=0;
- static char msg[1024];
- msg[ offset ] = 0;
- if ( strcmp( buf, END_MSG_STR ) == 0 )
- {
- icq_sendmsg( sok, multi_uin, msg, NORM_MESS );
- M_print( "Message sent to " );
- Print_UIN_Name( multi_uin );
- M_print( "n");
- last_uin = multi_uin;
- offset = 0;
- return FALSE;
- }
- else if ( strcmp( buf, CANCEL_MSG_STR ) == 0 )
- {
- M_print( "Message canceled!n" );
- last_uin = multi_uin;
- offset = 0;
- return FALSE;
- }
- else
- {
- if ( offset + strlen( buf ) < 450 )
- {
- strcat( msg, buf );
- strcat( msg, "rn" );
- offset += strlen( buf ) + 2;
- return TRUE;
- }
- else
- {
- M_print( "Message sent before last line buffer is fulln" );
- M_print( "Message sent to " );
- Print_UIN_Name( multi_uin );
- M_print( "n");
- icq_sendmsg( sok, multi_uin, msg, NORM_MESS );
- last_uin = multi_uin;
- offset = 0;
- return FALSE;
- }
- }
- }
- void Info_Update( SOK_T sok, char *buf )
- {
- switch ( status ) {
- case NEW_NICK:
- user.nick = strdup( (char *) buf );
- M_print ( "Enter Your New First Name : ");
- fflush(stdout);
- status++;
- break;
- case NEW_FIRST:
- user.first = strdup( (char *) buf );
- M_print ( "Enter Your New Last Name : ");
- fflush(stdout);
- status++;
- break;
- case NEW_LAST:
- user.last = strdup( (char *) buf );
- M_print ( "Enter Your New Email Address : ");
- fflush(stdout);
- status++;
- break;
- case NEW_EMAIL:
- user.email = strdup( (char *) buf );
- M_print ( "Do you want to require Mirabilis users to request your authorization? : ");
- fflush(stdout);
- status++;
- break;
- case NEW_AUTH:
- if ( ! strcasecmp( buf, NO_STR ) )
- {
- user.auth = FALSE;
- Update_User_Info( sok, &user );
- /* free( user.nick );
- free( user.last );
- free( user.first );
- free( user.email ); */
- status = 0;
- }
- else if ( ! strcasecmp( buf, YES_STR ) )
- {
- user.auth = TRUE;
- Update_User_Info( sok, &user );
- free( user.nick );
- free( user.last );
- free( user.first );
- free( user.email );
- status = 0;
- }
- else
- {
- M_print( "Please enter %s or %s.n", YES_STR, NO_STR );
- M_print( "Do you want to require Mirabilis users to request your authorization? : ");
- fflush(stdout);
- }
- break;
- }
- }
- BOOL Do_Multiline_All( SOK_T sok, char *buf )
- {
- static int offset=0;
- static char msg[1024];
- int i;
- msg[ offset ] = 0;
- if ( strcmp( buf, END_MSG_STR ) == 0 )
- {
- for ( i=0; i < Num_Contacts; i++ )
- icq_sendmsg( sok, Contacts[i].uin, msg, MRNORM_MESS );
- M_print( "Message sent!n" );
- offset = 0;
- return FALSE;
- }
- else if ( strcmp( buf, CANCEL_MSG_STR ) == 0 )
- {
- M_print( "Message canceled!n" );
- offset = 0;
- return FALSE;
- }
- else
- {
- if ( offset + strlen( buf ) < 450 )
- {
- strcat( msg, buf );
- strcat( msg, "rn" );
- offset += strlen( buf ) + 2;
- return TRUE;
- }
- else
- {
- M_print( "Message sent before last line buffer is fulln" );
- for ( i=0; i < Num_Contacts; i++ )
- icq_sendmsg( sok, Contacts[i].uin, msg, MRNORM_MESS );
- offset = 0;
- return FALSE;
- }
- }
- }
- /******************************************************
- Read a line of input and processes it.
- *******************************************************/
- void Get_Input( SOK_T sok )
- {
- char buf[1024]; /* This is hopefully enough */
- char *cmd;
- char *arg1;
- char *arg2;
- int i;
- memset( buf, 0, 1024 );
- M_fdnreadln( STDIN, buf, 1024 ); /* assumes we're line buffered input */
- buf[1023]=0; /* be safe */
- if ( status == 1 )
- {
- if ( ! Do_Multiline( sok, buf ) )
- {
- status = 2;
- } else {
- M_print ( "msg> ");
- fflush(stdout);
- }
- }
- else if ( status == 3 )
- {
- if ( ! Do_Multiline_All( sok, buf ) ) {
- status = 2;
- } else {
- M_print ( "msg all> ");
- fflush(stdout);
- }
- }
- else if ( ( status >= NEW_NICK) && ( status <= NEW_AUTH) )
- { Info_Update( sok, buf ); }
- else
- {
- if ( buf[0] != 0 )
- {
- if ( '!' == buf[0] )
- {
- system( &buf[1] );
- Prompt();
- return;
- }
- cmd = strtok( buf, " nt" );
- if ( NULL == cmd )
- {
- Prompt();
- return;
- }
- /* goto's removed and code fixed by Paul Laufer. Enjoy! */
- if ( ( strcasecmp( cmd , "quit" ) == 0 ) ||
- ( strcasecmp( cmd , "/quit" ) == 0 ) )
- { Quit = TRUE; }
- else if ( strcasecmp( cmd, quit_cmd ) == 0 )
- { Quit = TRUE; }
- else if ( strcasecmp( cmd, sound_cmd ) == 0 )
- {
- if ( SOUND_ON == Sound )
- {
- Sound = SOUND_OFF;
- M_print( "Sound" SERVCOL " OFF" NOCOL ".n" );
- }
- else if ( SOUND_OFF == Sound )
- {
- Sound = SOUND_ON;
- M_print( "Sound" SERVCOL " ON" NOCOL ".n" );
- }
- }
- else if ( strcasecmp( cmd, change_cmd ) == 0 )
- { Change_Function( sok ); }
- else if ( strcasecmp( cmd, "rand" ) == 0 )
- { Random_Function( sok ); }
- else if ( strcasecmp( cmd, "set" ) == 0 )
- { Random_Set_Function( sok ); }
- else if ( ! strcasecmp( cmd, color_cmd ) )
- {
- Color = !Color;
- if ( Color )
- {
- M_print( "Color is " MESSCOL "on" NOCOL ".n" );
- }
- else
- {
- M_print( "Color is " MESSCOL "off" NOCOL ".n" );
- }
- }
- else if ( ! strcasecmp( cmd, online_cmd ) ) /* online command */
- { CHANGE_STATUS( STATUS_ONLINE ); }
- else if ( ! strcasecmp( cmd, away_cmd ) ) /* away command */
- { CHANGE_STATUS( STATUS_AWAY ); }
- else if ( ! strcasecmp( cmd, na_cmd ) ) /* Not Available command */
- { CHANGE_STATUS( STATUS_NA ); }
- else if ( ! strcasecmp( cmd, occ_cmd ) ) /* Occupied command */
- { CHANGE_STATUS( STATUS_OCCUPIED ); }
- else if ( ! strcasecmp( cmd, dnd_cmd ) ) /* Do not Disturb command */
- { CHANGE_STATUS( STATUS_DND ); }
- else if ( ! strcasecmp( cmd, ffc_cmd ) ) /* Free For Chat command */
- { CHANGE_STATUS( STATUS_FREE_CHAT ); }
- else if ( ! strcasecmp( cmd, inv_cmd ) ) /* Invisible command */
- { CHANGE_STATUS( STATUS_INVISIBLE ); }
- else if ( ! strcasecmp( cmd, search_cmd ) )
- {
- arg1 = strtok( NULL, "n" );
- if ( arg1 == NULL )
- {
- M_print("Must enter email address.n");
- }
- else
- {
- start_search( sok, arg1, "", "", "" );
- }
- }
- else if ( ! strcasecmp( cmd, status_cmd ) )
- { Show_Status(); }
- else if ( ! strcasecmp( cmd, list_cmd ) )
- { Show_Quick_Status(); }
- else if ( ! strcasecmp( cmd, msga_cmd ) )
- {
- status = 3;
- M_print( "msg all> " );
- fflush(stdout);
- }
- else if ( ! strcasecmp( cmd, reply_cmd ) ) /* reply command */
- {
- Reply_Function( sok );
- }
- else if ( ! strcasecmp( cmd, "reg" ) )
- {
- arg1 = strtok( NULL, "" );
- if ( arg1 != NULL )
- { reg_new_user( sok, arg1 ); }
- }
- else if ( ! strcasecmp( cmd, again_cmd ) ) /* again command */
- { Again_Function( sok ); }
- else if ( ! strcasecmp( cmd, "clear"))
- { clrscr(); }
- else if ( ! strcasecmp( cmd, info_cmd ) )
- { Info_Function( sok ); }
- else if ( ! strcasecmp( cmd, "ver" ) )
- { M_print( "Micq Version : " MESSCOL MICQ_VERSION NOCOL " Compiled on "__TIME__ " " __DATE__"n" ); }
- else if ( ! strcasecmp( cmd, add_cmd ) )
- {
- arg1 = strtok( NULL, " t" );
- if ( arg1 != NULL )
- {
- uin = atoi( arg1 );
- arg1 = strtok( NULL, "" );
- if ( arg1 != NULL )
- {
- Add_User( sok, uin, arg1 );
- M_print( "%s added.n", arg1 );
- }
- }
- else
- {
- M_print( SERVCOL "Must specify a nick name" NOCOL "n" );
- }
- }
- else if ( strcasecmp( cmd, "verbose" ) == 0 )
- { Verbose_Function(); }
- else if ( strcasecmp( cmd, "rinfo" ) == 0 )
- {
- Print_UIN_Name( last_recv_uin );
- M_print( "'s IP address is " );
- Print_IP( last_recv_uin );
- M_print( "tThe port is %dn",(WORD) Get_Port( last_recv_uin ) );
- M_print( "n" );
- send_info_req( sok, last_recv_uin );
- send_ext_info_req( sok, last_recv_uin );
- }
- else if ( ( strcasecmp( cmd, "/help" ) == 0 ) ||/* Help command */
- ( strcasecmp( cmd, "help" ) == 0 ) )
- { Help_Function(); }
- else if ( strcasecmp( cmd, auth_cmd ) == 0 )
- {
- arg1 = strtok( NULL, "" );
- if ( arg1 == NULL )
- {
- M_print( "Need uin to send ton" );
- }
- else
- {
- uin = nick2uin( arg1 );
- if ( -1 == uin )
- {
- M_print( "%s not recognized as a nick namen", arg1 );
- }
- else icq_sendauthmsg( sok, uin );
- }
- }
- else if ( strcasecmp( cmd, message_cmd ) == 0 ) /* "/msg" */
- {
- Message_Function( sok );
- }
- else if ( strcasecmp( cmd, url_cmd ) == 0 ) /* "/msg" */
- {
- arg1 = strtok( NULL, " " );
- if ( arg1 == NULL )
- {
- M_print( "Need uin to send ton" );
- }
- else
- {
- uin = nick2uin( arg1 );
- if ( uin == -1 )
- {
- M_print( "%s not recognized as a nick namen", arg1 );
- }
- else
- {
- arg1 = strtok( NULL, " " );
- last_uin = uin;
- if ( arg1 != NULL )
- {
- arg2 = strtok(NULL, "");
- /* sM_print(arg1, "%s%c%s", arg1, 'xFE', arg2);*/
- icq_sendurl( sok, uin, arg1, arg2 );
- M_print( "URL sent to ");
- Print_UIN_Name( last_uin );
- M_print( "!n");
- } else {
- M_print("Need URL please.n");
- }
- }
- }
- }
- else if ( ! strcasecmp( cmd, alter_cmd ) ) /* alter command */
- { Alter_Function(); }
- else if ( ! strcasecmp( cmd, save_cmd ) ) /* save command */
- {
- i=Save_RC();
- if (i==-1)
- M_print("Sorry saving your personal reply messages went wrong!n");
- else
- M_print("Your personal settings have been saved!n");
- }
- else if ( ! strcasecmp( cmd, "update" ) )
- {
- status = NEW_NICK;
- M_print( "Enter Your New Nickname : " );
- fflush(stdout);
- }
- else if ( strcasecmp( cmd, auto_cmd ) == 0 )
- { Auto_Function( sok ); }
- else
- { M_print( "Unknown command %s, type /help for help.n", cmd ); }
- }
- }
- multi_uin = last_uin;
- if ( ( status == 0 ) || ( status == 2) )
- {
- if ( ! Quit )
- Prompt();
- }
- }
- /**************************************************************
- most detailed contact list display
- ***************************************************************/
- static void Show_Status( void )
- {
- int i;
- M_print( W_SEPERATOR );
- M_print( "Your status is " );
- Print_Status( Current_Status );
- M_print( "n" );
- /* First loop sorts thru all offline users */
- M_print( W_SEPERATOR );
- M_print( "Users offline: n" );
- for ( i=0; i< Num_Contacts; i++ )
- {
- if ( ( S_DWORD )Contacts[ i ].uin > 0 )
- {
- if ( FALSE == Contacts[ i ].invis_list )
- {
- if ( Contacts[ i ].status == STATUS_OFFLINE )
- {
- if ( Contacts[i].vis_list ) {
- M_print( "%s*%s", SERVCOL, NOCOL );
- } else {
- M_print( " " );
- }
- M_print( "%8ld=", Contacts[ i ].uin );
- M_print( CONTACTCOL "%-20st%s(", Contacts[ i ].nick, MESSCOL );
- Print_Status( Contacts[ i ].status );
- M_print( ")%s", NOCOL );
- if ( -1L != Contacts[ i ].last_time )
- {
- if ( Contacts[ i ].status == STATUS_OFFLINE )
- M_print( " Last online at %s", ctime( (time_t *) &Contacts[ i ].last_time ) );
- else
- M_print( " Online since %s", ctime( (time_t *) &Contacts[ i ].last_time ) );
- }
- else
- {
- M_print( " Last on-line unknown.n" );
- /* if time is unknow they can't be logged on cause we */
- /* set the time at login */
- }
- }
- }
- }
- }
- /* The second loop displays all the online users */
- M_print( W_SEPERATOR );
- M_print( "Users online: n" );
- for ( i=0; i< Num_Contacts; i++ )
- {
- if ( ( S_DWORD )Contacts[ i ].uin > 0 )
- {
- if ( FALSE == Contacts[ i ].invis_list )
- {
- if ( Contacts[ i ].status != STATUS_OFFLINE )
- {
- if ( Contacts[i].vis_list ) {
- M_print( "%s*%s", SERVCOL, NOCOL );
- } else {
- M_print( " " );
- }
- M_print( "%8ld=", Contacts[ i ].uin );
- M_print( CONTACTCOL "%-20st%s(", Contacts[ i ].nick, MESSCOL );
- Print_Status( Contacts[ i ].status );
- M_print( ")%s", NOCOL );
- if ( -1L != Contacts[ i ].last_time )
- {
- if ( Contacts[ i ].status == STATUS_OFFLINE )
- M_print( " Last online at %s", ctime( (time_t *) &Contacts[ i ].last_time ) );
- else
- M_print( " Online since %s", ctime( (time_t *) &Contacts[ i ].last_time ) );
- }
- else
- {
- M_print( " Last on-line unknown.n" );
- /* if time is unknow they can't be logged on cause we */
- /* set the time at login */
- }
- }
- }
- }
- }
- M_print( W_SEPERATOR );
- }
- /***************************************************************
- nice clean "w" display
- ****************************************************************/
- void Show_Quick_Status( void )
- {
- int i;
- M_print( "nn" W_SEPERATOR );
- M_print( "%lu: ", UIN );
- M_print( "Your status is " );
- Print_Status( Current_Status );
- M_print( "n" );
- /* First loop sorts thru all offline users */
- /* This comes first so that if there are many contacts */
- /* The online ones will be less likely to scroll off the screen */
- M_print( W_SEPERATOR );
- M_print( "Users offline: n" );
- for ( i=0; i< Num_Contacts; i++ )
- {
- if ( ( S_DWORD )Contacts[ i ].uin > 0 )
- {
- if ( FALSE == Contacts[ i ].invis_list )
- {
- if ( Contacts[ i ].status == STATUS_OFFLINE )
- {
- if ( Contacts[i].vis_list ) {
- M_print( "%s*%s", SERVCOL, NOCOL );
- } else {
- M_print( " " );
- }
- M_print( CONTACTCOL "%-20st" MESSCOL "(" , Contacts[ i ].nick );
- Print_Status( Contacts[ i ].status );
- M_print( ")" NOCOL "n" );
- }
- }
- }
- }
- /* The second loop displays all the online users */
- M_print( W_SEPERATOR );
- M_print( "Users online: n" );
- for ( i=0; i< Num_Contacts; i++ )
- {
- if ( ( S_DWORD )Contacts[ i ].uin > 0 )
- {
- if ( FALSE == Contacts[ i ].invis_list )
- {
- if ( Contacts[ i ].status != STATUS_OFFLINE )
- {
- if ( Contacts[i].vis_list ) {
- M_print( "%s*%s", SERVCOL, NOCOL );
- } else {
- M_print( " " );
- }
- M_print( CONTACTCOL "%-20st" MESSCOL "(", Contacts[ i ].nick );
- Print_Status( Contacts[ i ].status );
- M_print( ")" NOCOL "n" );
- }
- }
- }
- }
- M_print( W_SEPERATOR );
- }
- /***************************************************
- Do not call unless you've already made a call to strtok()
- ****************************************************/
- static void Change_Function( SOK_T sok )
- {
- char *arg1;
- arg1 = strtok( NULL, " nr" );
- if ( arg1 == NULL )
- {
- M_print( CLIENTCOL "Status modes: n" );
- M_print( "Status online %dn", STATUS_ONLINE );
- M_print( "Status Away %dn", STATUS_AWAY );
- M_print( "Status Do not Disturb %dn", STATUS_DND );
- M_print( "Status Not Available %dn", STATUS_NA );
- M_print( "Status Free for Chat %dn", STATUS_FREE_CHAT );
- M_print( "Status Occupied %dn", STATUS_OCCUPIED );
- M_print( "Status Invisible %dn", STATUS_INVISIBLE );
- M_print( NOCOL "n" );
- }
- else
- {
- icq_change_status( sok, atoi( arg1 ) );
- Print_Status( Current_Status );
- M_print( "n" );
- }
- }
- /***************************************************
- Do not call unless you've already made a call to strtok()
- ****************************************************/
- static void Random_Function( SOK_T sok )
- {
- char *arg1;
- arg1 = strtok( NULL, " nr" );
- if ( arg1 == NULL )
- {
- M_print( CLIENTCOL "Groups: n" );
- M_print( "General 1n" );
- M_print( "Romance 2n" );
- M_print( "Games 3n" );
- M_print( "Students 4n" );
- M_print( "20 something 6n" );
- M_print( "30 something 7n" );
- M_print( "40 something 8n" );
- M_print( "50+ 9n" );
- M_print( "Man chat requesting women 10n" );
- M_print( "Woman chat requesting men 11n" );
- M_print( "Micq 49 (might not work but try it)n" );
- M_print( NOCOL "n" );
- }
- else
- {
- icq_rand_user_req( sok, atoi( arg1 ) );
- M_print( "n" );
- }
- }
- /***************************************************
- Do not call unless you've already made a call to strtok()
- ****************************************************/
- static void Random_Set_Function( SOK_T sok )
- {
- char *arg1;
- arg1 = strtok( NULL, " nr" );
- if ( arg1 == NULL )
- {
- M_print( CLIENTCOL "Groups: n" );
- M_print( "None -1n" );
- M_print( "General 1n" );
- M_print( "Romance 2n" );
- M_print( "Games 3n" );
- M_print( "Students 4n" );
- M_print( "20 something 6n" );
- M_print( "30 something 7n" );
- M_print( "40 something 8n" );
- M_print( "50+ 9n" );
- M_print( "Man chat requesting women 10n" );
- M_print( "Woman chat requesting men 11n" );
- M_print( "Micq 49 (might not work but try it)n" );
- M_print( NOCOL "n" );
- }
- else
- {
- icq_rand_set( sok, atoi( arg1 ) );
- M_print( "n" );
- }
- }
- /*****************************************************************
- Displays help information.
- ******************************************************************/
- static void Help_Function( void )
- {
- M_print( MESSCOL "reg password" NOCOL "ttCreates a new UIN with the specified password.n");
- M_print( MESSCOL "verbose #" NOCOL "tSet the verbosity level ( default = 0 ).n");
- M_print( MESSCOL "%s" NOCOL "ttMark as Online.n",online_cmd);
- M_print( MESSCOL "%s" NOCOL "ttMark as Away.n",away_cmd);
- M_print( MESSCOL "%s" NOCOL "ttMark as Not Available.n",na_cmd);
- M_print( MESSCOL "%s" NOCOL "ttMark as Occupied.n",occ_cmd);
- M_print( MESSCOL "%s" NOCOL "ttMark as Do not Disturb.n",dnd_cmd);
- M_print( MESSCOL "%s" NOCOL "ttMark as Free for Chat.n",ffc_cmd);
- M_print( MESSCOL "%s" NOCOL "ttMark as Invisible.n",inv_cmd);
- M_print( MESSCOL "clear" NOCOL "ttClears the screen.n" );
- M_print( MESSCOL "%s" NOCOL"ttDisplays your autoreply statusn",auto_cmd );
- M_print( MESSCOL "%s [on|off]" NOCOL "tToggles sending messages when your status is DND, NA, etc.n",auto_cmd );
- M_print( MESSCOL "%s status message" NOCOL "tSets the message to send as an auto reply for the statusn",auto_cmd );
- M_print( MESSCOL "%s old command new command" NOCOL "tThis command allows you to alter your command set on the fly.n",alter_cmd);
- M_print( MESSCOL "%s" NOCOL "ttDisplays the current status of everyone on your contact listn",list_cmd);
- M_print( MESSCOL "%s [#]" NOCOL "tChanges your status to the status number.nttWithout a number it lists the available modes.n",change_cmd);
- M_print( MESSCOL "%s uin" NOCOL "t Displays general info on uinn", info_cmd );
- M_print( MESSCOL "%s email@host" NOCOL "tSearches for a ICQ user with the specified email address.n", search_cmd );
- M_print( MESSCOL "rand [#]" NOCOL "tFinds a random user in the specified group or lists the groups.n" );
- M_print( MESSCOL "set [#]" NOCOL "tSets your random user group.n" );
- M_print( MESSCOL "%s" NOCOL "tUpdates your basic info (email, nickname, etc.)n",update_cmd);
- M_print( MESSCOL "%st" NOCOL "tLogs off and quitsn",quit_cmd );
- M_print( MESSCOL "%stt" NOCOL "Sends a multiline message to everyone on your list.n", msga_cmd );
- M_print( MESSCOL "%s uint" NOCOL "Authorize uin to add you to their listn", auth_cmd );
- M_print( MESSCOL "%s uin/message" NOCOL "tSends a message to uinn", message_cmd );
- M_print( MESSCOL "%s uin url message" NOCOL "tSends a url and message to uinn", url_cmd );
- M_print( MESSCOL "%s uin nick" NOCOL "tAdds the uin number to your contact list with nickname.n", add_cmd );
- M_print( MESSCOL "%s message" NOCOL "tSends a message to the last person you sent a message ton", again_cmd);
- M_print( MESSCOL "%s message" NOCOL "tReplys to the last person to send you a messagen", reply_cmd);
- M_print( MESSCOL "%s" NOCOL "ttToggles beeping when recieving new messages.n", sound_cmd);
- M_print( MESSCOL "%s" NOCOL "ttToggles displaying colors.n", color_cmd);
- M_print( CLIENTCOL "tSending a blank message will put the client into multiline mode.ntUse . on a line by itself to end message." NOCOL "n" );
- #if 0
- M_print( CLIENTCOL "nHmm with the auto command try using auto status message for a change.n ");
- M_print( "The status commands are the same as you normaly use to alter your status." NOCOL "n");
- #ifdef FUNNY_MSGS
- M_print( CLIENTCOL "For me it could be auto dnd Don't disturb me! I'm drinking beer!" NOCOL "n");
- #endif
- #endif
- }
- /****************************************************
- Retrieves info a certain user
- *****************************************************/
- static void Info_Function( SOK_T sok )
- {
- char * arg1;
- arg1 = strtok( NULL, "" );
- if ( arg1 == NULL )
- {
- M_print( "Need uin to send ton" );
- return;
- }
- uin = nick2uin( arg1 );
- if ( -1 == uin )
- {
- M_print( "%s not recognized as a nick namen", arg1 );
- return;
- }
- M_print( "%s's IP address is ", arg1 );
- Print_IP( uin );
- M_print( "tThe port is %dn",(WORD) Get_Port( uin ) );
- M_print( "n" );
- send_info_req( sok, uin );
- send_ext_info_req( sok, uin );
- }
- /**********************************************************
- Handles automatic reply messages
- ***********************************************************/
- static void Auto_Function( SOK_T sok )
- {
- char *cmd;
- char *arg1;
- cmd = strtok( NULL, "" );
- if ( cmd == NULL )
- {
- M_print( "Automatic replies are %sn", auto_resp ? "On" : "Off" );
- M_print( "The Do not disturb message is: %sn", auto_rep_str_dnd );
- M_print( "The Away message is : %sn", auto_rep_str_away );
- M_print( "The Not available message is : %sn", auto_rep_str_na );
- M_print( "The Occupied message is : %sn", auto_rep_str_occ );
- M_print( "The Invisible message is : %sn", auto_rep_str_inv );
- return;
- }
- else if ( strcasecmp( cmd, "on" ) == 0 )
- {
- auto_resp = TRUE;
- M_print( "Automatic replies are on.n" );
- }
- else if ( strcasecmp( cmd, "off" ) == 0 )
- {
- auto_resp = FALSE;
- M_print( "Automatic replies are off.n" );
- }
- else
- {
- M_print( "Automatic reply settingn" );
- arg1 = strtok( cmd," ");
- if (arg1 == NULL)
- {
- M_print( "Sorry wrong syntax, can't find a status somewhere.rn");
- return;
- }
- if ( ! strcasecmp (arg1 , dnd_cmd ) )
- {
- cmd = strtok( NULL,"");
- strcpy( auto_rep_str_dnd, cmd);
- }
- else if ( !strcasecmp (arg1 ,away_cmd ))
- {
- cmd = strtok( NULL,"");
- strcpy( auto_rep_str_away,cmd);
- }
- else if ( !strcasecmp (arg1,na_cmd))
- {
- cmd =strtok(NULL,"");
- strcpy(auto_rep_str_na,cmd);
- }
- else if ( !strcasecmp (arg1,occ_cmd))
- {
- cmd = strtok(NULL,"");
- strcpy (auto_rep_str_occ,cmd);
- }
- else if (!strcasecmp (arg1,inv_cmd))
- {
- cmd = strtok(NULL,"");
- strcpy (auto_rep_str_inv,cmd);
- }
- else
- M_print ("Sorry wrong syntax. Read tha help man!rn");
- }
- }
- /*************************************************************
- Alters one of the commands
- **************************************************************/
- static void Alter_Function( void )
- {
- char * cmd;
- cmd = strtok (NULL," ");
- if ( cmd == NULL )
- {
- M_print( "Need a command to alter!n" );
- return;
- }
- if ( ! strcasecmp(cmd, auto_cmd))
- strncpy(auto_cmd,strtok(NULL," nt"),16);
- else if ( !strcasecmp(cmd ,message_cmd))
- strncpy(message_cmd,strtok(NULL," nt"),16);
- else if (!strcasecmp(cmd,add_cmd))
- strncpy(add_cmd,strtok(NULL," nt"),16);
- else if (!strcasecmp(cmd,info_cmd))
- strncpy(info_cmd,strtok(NULL," nt"),16);
- else if (!strcasecmp(cmd,quit_cmd))
- strncpy(quit_cmd,strtok(NULL," nt"),16);
- else if (!strcasecmp(cmd,reply_cmd))
- strncpy(reply_cmd,strtok(NULL," nt"),16);
- else if (!strcasecmp(cmd,again_cmd))
- strncpy(again_cmd,strtok(NULL," nt"),16);
- else if (!strcasecmp(cmd,list_cmd))
- strncpy(list_cmd,strtok(NULL," nt"),16);
- else if (!strcasecmp(cmd,away_cmd))
- strncpy(away_cmd,strtok(NULL," nt"),16);
- else if (!strcasecmp(cmd,na_cmd))
- strncpy(na_cmd,strtok(NULL," nt"),16);
- else if (!strcasecmp(cmd,dnd_cmd))
- strncpy(dnd_cmd,strtok(NULL," tn"),16);
- else if (!strcasecmp(cmd,online_cmd))
- strncpy(online_cmd,strtok(NULL," nt"),16);
- else if (!strcasecmp(cmd,occ_cmd))
- strncpy(occ_cmd,strtok(NULL," tn"),16);
- else if (!strcasecmp(cmd,ffc_cmd))
- strncpy(ffc_cmd,strtok(NULL," tn"),16);
- else if (!strcasecmp(cmd,inv_cmd))
- strncpy(inv_cmd,strtok(NULL," tn"),16);
- else if (!strcasecmp(cmd,status_cmd))
- strncpy(status_cmd,strtok(NULL," tn"),16);
- else if (!strcasecmp(cmd,auth_cmd))
- strncpy(status_cmd,strtok(NULL," nt"),16);
- else if (!strcasecmp(cmd,change_cmd))
- strncpy(change_cmd,strtok(NULL," nt"),16);
- else if (!strcasecmp(cmd,search_cmd))
- strncpy(search_cmd,strtok(NULL," tn"),16);
- else if (!strcasecmp(cmd,save_cmd))
- strncpy(save_cmd,strtok(NULL," tn"),16);
- else if (!strcasecmp(cmd,alter_cmd))
- strncpy(alter_cmd,strtok(NULL," tn"),16);
- else if (!strcasecmp(cmd,msga_cmd))
- strncpy(msga_cmd,strtok(NULL," nt"),16);
- else
- M_print("Type help to see your current command, because this one you typed wasn't one!n");
- }
- /*************************************************************
- Processes user input to send a message to a specified user
- **************************************************************/
- static void Message_Function( SOK_T sok )
- {
- char * arg1;
- arg1 = strtok( NULL, UIN_DELIMS );
- if ( arg1 == NULL )
- {
- M_print( "Need uin to send ton" );
- return;
- }
- uin = nick2uin( arg1 );
- if ( -1 == uin )
- {
- M_print( "%s not recognized as a nick namen", arg1 );
- return;
- }
- arg1 = strtok( NULL, "" );
- last_uin = uin;
- if ( arg1 != NULL )
- {
- icq_sendmsg( sok, uin, arg1, NORM_MESS );
- M_print( "Message sent to ");
- Print_UIN_Name( last_uin );
- M_print( "!n");
- }
- else
- {
- status = 1;
- M_print( "msg> " );
- fflush(stdout);
- }
- }
- /*******************************************************
- Sends a reply message to the last person to message you.
- ********************************************************/
- static void Reply_Function( SOK_T sok )
- {
- char * arg1;
- if ( last_recv_uin == 0 )
- {
- M_print( "Must receive a message firstn" );
- return;
- }
- arg1 = strtok( NULL, "" );
- last_uin = last_recv_uin;
- if ( arg1 != NULL )
- {
- icq_sendmsg( sok, last_recv_uin, arg1, NORM_MESS );
- M_print( "Message sent to " );
- Print_UIN_Name( last_recv_uin );
- M_print( "n");
- }
- else
- {
- status = 1;
- M_print( "msg> " );
- fflush(stdout);
- }
- }
- static void Again_Function( SOK_T sok )
- {
- char * arg1;
- if ( last_uin == 0 )
- {
- M_print( "Must write one message firstn" );
- return;
- }
- arg1 = strtok( NULL, "" );
- if ( arg1 != NULL )
- {
- icq_sendmsg( sok, last_uin, arg1, NORM_MESS );
- M_print( "Message sent to ");
- Print_UIN_Name( last_uin );
- M_print( "!n");
- } else {
- status = 1;
- M_print( "msg> " );
- fflush(stdout);
- }
- }
- static void Verbose_Function( void )
- {
- char * arg1;
- arg1 = strtok( NULL, "" );
- if ( arg1 != NULL )
- {
- Verbose = atoi( arg1 );
- }
- M_print( "Verbosity level is %d.n", Verbose );
- }