⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 micqcomponents.cpp

📁 聊天程序
💻 CPP
📖 第 1 页 / 共 5 页
字号:
   {
#ifdef UNIX
	  tv.tv_sec = 3;
      tv.tv_usec = 500000;
#else
	  tv.tv_sec = 0;
      tv.tv_usec = 100000;
#endif

      FD_ZERO(&readfds);
      FD_SET(sok, &readfds);

      /* don't care about writefds and exceptfds: */
      select(sok+1, &readfds, NULL, NULL, &tv);
      M_print( "Waiting for response....\n" );
      if (FD_ISSET(sok, &readfds))
      {
         s = SOCKREAD( sok, &pak.head.ver, sizeof( pak ) - 2  );
         if ( Chars_2_Word( pak.head.cmd ) == SRV_NEW_UIN )
         {
            UIN = Chars_2_DW( pak.head.UIN );
            M_print( "\nYour new UIN is %s%ld%s!\n",SERVCOL, UIN, NOCOL );
            return;
         }
         else
         {
/*            Hex_Dump( &pak.head.ver, s );*/
         }
      }
      reg_new_user( sok, passwd );
   }
}

static void Initalize_RC_File( void )
{
   FD_T rcf;
/*   time_t t; */
//   char passwd2[ sizeof(passwd) ];
   CLoginDlg LoginUser;

   strcpy( server, "icq.mirabilis.com" );

   remote_port = 4000;

#if 0   
   M_fdprint( rcf, "# This file was generated by Another Icq of %s %s\n",__TIME__,__DATE__);
   t = time( NULL );
   M_fdprint( rcf, "# This file was generated on %s", ctime( &t ) );   
#endif
   
//   M_print( "Enter UIN or 0 for new UIN: #" );
/*   fflush( stdout );
   scanf( "%ld", &UIN );
password_entry:
   M_print( "Enter password : " );
   fflush( stdout );
   Echo_Off();
   memset( passwd, 0, sizeof( passwd ) );
   M_fdnreadln(STDIN, passwd, sizeof(passwd));
   Echo_On();
*/ 
   LoginUser.DoModal();

   if ( UIN == 0 )
   {
/*      if ( 0 == passwd[0] )
      {
         M_print( "\nMust enter password!\n" );
         goto password_entry;
      }
      M_print( "\nReenter password to verify: " );
      fflush( stdout );
      Echo_Off();
      memset( passwd2, 0, sizeof( passwd2 ) );
      M_fdnreadln(STDIN, passwd2, sizeof(passwd));
      Echo_On();
      if ( strcmp( passwd, passwd2 ) )
      {
         M_print( "\nPasswords did not match reenter\n" );
         goto password_entry;
      }
*/      Init_New_User();
   }
#if 0
   M_fdprint( rcf, "UIN %d\n", UIN );
   M_fdprint( rcf, "Password %s\n", passwd );
#endif
   set_status = STATUS_ONLINE;
#if 0
   M_fdprint( rcf, "Status %d\n", STATUS_ONLINE );
   M_fdprint( rcf, "Server %s\n", server );
   M_fdprint( rcf, "Port %d\n", remote_port );
   M_fdprint( rcf, "#No_Log\n" );
   M_fdprint( rcf, "\n#Russian\n#if you want KOI8-R to CP1251 Russain translation uncomment the above line.\n" );

   M_fdprint( rcf, "\n# Below are the commands which can be changed to most anything you want :)\n" );
   M_fdprint( rcf, "message_cmd msg\n");
   M_fdprint( rcf, "info_cmd info\n");
   M_fdprint( rcf, "quit_cmd q\n");
   M_fdprint( rcf, "reply_cmd r\n");
   M_fdprint( rcf, "again_cmd a\n");
   M_fdprint( rcf, "list_cmd w\n");
   M_fdprint( rcf, "away_cmd away\n");
   M_fdprint( rcf, "auto_rep_str_away I told you I wasn't here!\n");
   M_fdprint( rcf, "na_cmd na\n");
   M_fdprint( rcf, "auto_rep_str_na Working, working always working...\n");	
   M_fdprint( rcf, "dnd_cmd dnd\n");
	M_fdprint( rcf, "auto_rep_str_dnd Don't page me, my head is hurting!\n");
   M_fdprint( rcf, "online_cmd online\n");
   
   M_fdprint( rcf, "occ_cmd occ\n");
	M_fdprint( rcf, "auto_rep_str_occ I am working on opening this beer so I am busy.\n");
   M_fdprint( rcf, "ffc_cmd ffc\n");
   M_fdprint( rcf, "inv_cmd inv\n");
	M_fdprint( rcf, "auto_rep_str_inv So you can see me, so you can't!\n");
   M_fdprint( rcf, "search_cmd search\n");
   M_fdprint( rcf, "status_cmd status\n");
   M_fdprint( rcf, "auth_cmd auth\n");
   M_fdprint( rcf, "auto_cmd auto\n");
   M_fdprint( rcf, "add_cmd add\n");
   M_fdprint( rcf, "change_cmd change\n");
	M_fdprint( rcf, "save_cmd save\n");
	M_fdprint( rcf, "alter_cmd alter\n");
	M_fdprint( rcf, "msga_cmd msga\n");
	M_fdprint( rcf, "url_cmd url\n");
	M_fdprint( rcf, "update_cmd update\n");
	 

			   
   M_fdprint( rcf, "\n# Ok now the contact list\n" );
   M_fdprint( rcf, "\n# Put a star in front of any UIN # to add them to your visible list.\n" );
   M_fdprint( rcf, "Contacts\n" );
   M_fdprint( rcf, "11300897 Linux Master\n" );
   M_fdprint( rcf, "11290140 Micq Author\n" );
   M_fdprint( rcf, "22442817 AnotherICQ Author\n");
//   M_fdprint( rcf, "alias1\n" );
//   M_fdprint( rcf, "# ^-- Alias to Micq Author\n" );
#endif
   Num_Contacts = 2;
   Contacts[ 0 ].vis_list = FALSE;
   Contacts[ 1 ].vis_list = FALSE;
   Contacts[0].uin = 11290140;
   strcpy( Contacts[0].nick, "Micq Author" );
   Contacts[0].status = STATUS_OFFLINE;
   Contacts[0].last_time = -1L;
   Contacts[0].current_ip[0] = 0xff;
   Contacts[0].current_ip[1] = 0xff;
   Contacts[0].current_ip[2] = 0xff;
   Contacts[0].current_ip[3] = 0xff;
   Contacts[ 0 ].port = 0;
   Contacts[ 0 ].sok = (SOK_T ) -1L;
/*   Contacts[1].uin = -11290140;
   strcpy( Contacts[1].nick, "alias1" );
   Contacts[1].status = STATUS_OFFLINE;
   Contacts[1].current_ip[0] = 0xff;
   Contacts[1].current_ip[1] = 0xff;
   Contacts[1].current_ip[2] = 0xff;
   Contacts[1].current_ip[3] = 0xff;
   Contacts[1].current_ip[0] = 0xff;
   Contacts[1].current_ip[1] = 0xff;
   Contacts[1].current_ip[2] = 0xff;
   Contacts[1].current_ip[3] = 0xff;
   Contacts[ 1 ].port = 0;
   Contacts[ 1 ].sok = (SOK_T ) -1L;
   */
   Contacts[1].uin = 22442817;
   strcpy( Contacts[1].nick, "AnotherICQ Author" );
   Contacts[1].status = STATUS_OFFLINE;
   Contacts[1].last_time = -1L;
   Contacts[1].current_ip[0] = 0xff;
   Contacts[1].current_ip[1] = 0xff;
   Contacts[1].current_ip[2] = 0xff;
   Contacts[1].current_ip[3] = 0xff;
   Contacts[ 1 ].port = 0;
   Contacts[ 1 ].sok = (SOK_T ) -1L;
#if 0
   close( rcf );
#endif
   
	strcpy(message_cmd, "msg");
	strcpy(info_cmd, "info");
	strcpy(add_cmd, "add");
	strcpy(quit_cmd, "q");
	strcpy(reply_cmd, "r");       
	strcpy(again_cmd, "a");
	strcpy(list_cmd, "w");
	strcpy(away_cmd, "away");
	strcpy(na_cmd, "na");
	strcpy(dnd_cmd, "dnd");   
	strcpy(online_cmd, "online");
	strcpy(occ_cmd, "occ");
	strcpy(ffc_cmd, "ffc");
	strcpy(inv_cmd, "inv");
	strcpy(status_cmd, "status");
	strcpy(auth_cmd, "auth");
	strcpy(change_cmd, "change");
	strcpy(auto_cmd, "auto");
	strcpy(search_cmd, "search");
	strcpy(save_cmd, "save");
	strcpy(alter_cmd, "alter");
	strcpy(msga_cmd, "msga");
	strcpy(url_cmd, "url");
	strcpy(update_cmd, "update");
   
   Current_Status = STATUS_ONLINE;
   
   rcf = open( rcfile, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
   if ( rcf == -1 )
   {
      perror( "Error creating config file " );
      exit( 1);
   }
   close( rcf );

   if ( Save_RC() == -1 )
   {
      perror( "Error creating config file " );
      exit( 1);
   }
}

static void Read_RC_File( FD_T rcf )
{
   char buf[450];
   char *tmp;
   int i;
	DWORD tmp_uin;
   
   message_cmd[0]='\0';/* for error checking later */
   quit_cmd[0]='\0';   /* for error checking later */
   info_cmd[0]='\0';   /* for error checking later */
   reply_cmd[0]='\0';  /* for error checking later */
   again_cmd[0]='\0';  /* for error checking later */
   add_cmd[0]='\0';    /* for error checking later */

   list_cmd[0]='\0';   /* for error checking later */
   away_cmd[0]='\0';   /* for error checking later */
   na_cmd[0]='\0';     /* for error checking later */
   dnd_cmd[0]='\0';    /* for error checking later */
   online_cmd[0]='\0'; /* for error checking later */
   occ_cmd[0]='\0';    /* for error checking later */
   ffc_cmd[0]='\0';    /* for error checking later */
   inv_cmd[0]='\0';    /* for error checking later */
   status_cmd[0]='\0'; /* for error checking later */
   auth_cmd[0]='\0';   /* for error checking later */
   auto_cmd[0]='\0';   /* for error checking later */
   change_cmd[0]='\0'; /* for error checking later */
   search_cmd[0]='\0'; /* for error checking later */
   save_cmd[0]='\0';   /* for error checking later */
   alter_cmd[0]='\0';  /* for error checking later */
	msga_cmd[0]='\0';   /* for error checking later */
	url_cmd[0]='\0';   /* for error checking later */
	update_cmd[0]='\0';   /* for error checking later */
	passwd=(char *) malloc (sizeof (char) * 100);
	passwd[0] = '\0';
   UIN = 0;
	
   Contact_List = FALSE;
   for ( i=1; !Contact_List || buf == 0; i++ )
   {
/*      M_print( "Starting Line " SERVCOL " %d" NOCOL "\n", i );*/
      M_fdnreadln( rcf, buf, sizeof( buf ) );
      if ( ( buf[0] != '#' ) && ( buf[0] != 0 ) )
      {
         tmp = strtok( buf, " " );
         if ( ! strcasecmp( tmp, "Server" ) )
            { strcpy( server, strtok( NULL, " \n\t" ) ); }
         else if ( ! strcasecmp( tmp, "Password" ) )
            { strcpy( passwd, strtok( NULL, "\n\t" ) ); }
         else if ( ! strcasecmp( tmp, "Russian" ) )
            {  Russian = TRUE; }
         else if ( ! strcasecmp( tmp, "No_Log" ) )
            { Logging = FALSE;   }
         else if ( ! strcasecmp( tmp, "UIN" ) )
            {  UIN = atoi( strtok( NULL, " \n\t" ) );         }
         else if ( ! strcasecmp( tmp, "port" ) )
            {  remote_port = atoi( strtok( NULL, " \n\t" ) ); }
         else if ( ! strcasecmp( tmp, "Status" ) )
            {  set_status = atoi( strtok( NULL, " \n\t" ) ); }
         else if ( ! strcasecmp( tmp, "Auto" ) )
            { auto_resp = TRUE; }
         ADD_COMMAND( "message_cmd", message_cmd )
         ADD_COMMAND( "info_cmd", info_cmd )
         ADD_COMMAND( "quit_cmd", quit_cmd )
         ADD_COMMAND( "reply_cmd", reply_cmd )
         ADD_COMMAND( "again_cmd", again_cmd )
         ADD_COMMAND( "list_cmd", list_cmd )
         ADD_COMMAND( "away_cmd", away_cmd )
         ADD_MESS( "auto_rep_str_away", auto_rep_str_away )
         ADD_MESS( "auto_rep_str_na", auto_rep_str_na )
         ADD_COMMAND( "na_cmd", na_cmd )
         ADD_COMMAND( "dnd_cmd", dnd_cmd )
         ADD_MESS( "auto_rep_str_dnd", auto_rep_str_dnd )
         ADD_MESS( "auto_rep_str_occ", auto_rep_str_occ )
         ADD_MESS( "auto_rep_str_inv", auto_rep_str_inv )
         ADD_COMMAND( "online_cmd", online_cmd )
         ADD_COMMAND( "occ_cmd", occ_cmd )
         ADD_COMMAND( "ffc_cmd", ffc_cmd )
         ADD_COMMAND( "inv_cmd", inv_cmd )
         ADD_COMMAND( "status_cmd", status_cmd )
         ADD_COMMAND( "auth_cmd", auth_cmd )
         ADD_COMMAND( "auto_cmd", auto_cmd )
         ADD_COMMAND( "change_cmd", change_cmd )
         ADD_COMMAND( "add_cmd", add_cmd )
         ADD_COMMAND( "search_cmd", search_cmd )
         ADD_COMMAND( "save_cmd", save_cmd )
         ADD_COMMAND( "alter_cmd", alter_cmd )
         ADD_COMMAND( "msga_cmd", msga_cmd )
         ADD_COMMAND( "update_cmd", update_cmd )
         ADD_COMMAND( "url_cmd", url_cmd )
         else if ( ! strcasecmp( tmp, "Contacts" ) )
         {
            Contact_List = TRUE;
         }
         else
         {
            M_print( SERVCOL "Unrecognized command in rc file : %s, ignored." NOCOL "\n", tmp );
         }
   	}
	}
   for ( ; ! M_fdnreadln( rcf, buf, sizeof( buf ) ); )
   {
      if ( Num_Contacts == 100 )
         break;
      if ( ( buf[0] != '#' ) && ( buf[0] != 0 ) )
      {
         if ( isdigit( (int) buf[0] ) )
         {
            Contacts[ Num_Contacts ].uin = atoi( strtok( buf, " " ) );
            Contacts[ Num_Contacts ].status = STATUS_OFFLINE;
            Contacts[ Num_Contacts ].last_time = -1L;
            Contacts[ Num_Contacts ].current_ip[0] = 0xff;
            Contacts[ Num_Contacts ].current_ip[1] = 0xff;
            Contacts[ Num_Contacts ].current_ip[2] = 0xff;
            Contacts[ Num_Contacts ].current_ip[3] = 0xff;
            tmp = strtok( NULL, "" );
            if ( tmp != NULL )
               memcpy( Contacts[ Num_Contacts ].nick, tmp, sizeof( Contacts->nick )  );
            else
               Contacts[ Num_Contacts ].nick[0] = 0;
            if ( Contacts[ Num_Contacts ].nick[19] != 0 )
               Contacts[ Num_Contacts ].nick[19] = 0;
            if ( Verbose )
               M_print( "%ld = %s\n", Contacts[ Num_Contacts ].uin, Contacts[ Num_Contacts ].nick );
            Contacts[ Num_Contacts ].vis_list = FALSE;
            Num_Contacts++;
         }
         else if ( buf[0] == '*' )
         {
            Contacts[ Num_Contacts ].uin = atoi( strtok( &buf[1], " " ) );
            Contacts[ Num_Contacts ].status = STATUS_OFFLINE;
            Contacts[ Num_Contacts ].last_time = -1L;
            Contacts[ Num_Contacts ].current_ip[0] = 0xff;
            Contacts[ Num_Contacts ].current_ip[1] = 0xff;
            Contacts[ Num_Contacts ].current_ip[2] = 0xff;
            Contacts[ Num_Contacts ].current_ip[3] = 0xff;
            tmp = strtok( NULL, "" );
            if ( tmp != NULL )
               memcpy( Contacts[ Num_Contacts ].nick, tmp, sizeof( Contacts->nick )  );
            else
               Contacts[ Num_Contacts ].nick[0] = 0;
            if ( Contacts[ Num_Contacts ].nick[19] != 0 )
               Contacts[ Num_Contacts ].nick[19] = 0;
            if ( Verbose )
               M_print( "%ld = %s\n", Contacts[ Num_Contacts ].uin, Contacts[ Num_Contacts ].nick );
            Contacts[ Num_Contacts ].vis_list = TRUE;
            Num_Contacts++;
         }
         else
         {
            tmp_uin = Contacts[ Num_Contacts - 1 ].uin;
            tmp = strtok( buf, ", \t" ); /* aliases may not have spaces */
            for ( ; tmp!=NULL; Num_Contacts++ )
            {
               Contacts[ Num_Contacts ].uin = -tmp_uin;
               Contacts[ Num_Contacts ].status = STATUS_OFFLINE;
               Contacts[ Num_Contacts ].last_time = -1L;
               Contacts[ Num_Contacts ].current_ip[0] = 0xff;
               Contacts[ Num_Contacts ].current_ip[1] = 0xff;
               Contacts[ Num_Contacts ].current_ip[2] = 0xff;
               Contacts[ Num_Contacts ].current_ip[3] = 0xff;
               Contacts[ Num_Contacts ].port = 0;
               Contacts[ Num_Contacts ].sok = (SOK_T ) -1L;
               memcpy( Contacts[ Num_Contacts ].nick, tmp, sizeof( Contacts->nick )  );
               tmp = strtok( NULL, ", \t" );
            }
         }
      }
   }
   if(message_cmd[0]=='\0')
	   strcpy(message_cmd, "msg");
   if(update_cmd[0]=='\0')
	   strcpy(update_cmd, "update");
   if(info_cmd[0]=='\0')
	   strcpy(info_cmd, "info");
   if(quit_cmd[0]=='\0')
	   strcpy(quit_cmd, "q");
   if(reply_cmd[0]=='\0')
	   strcpy(reply_cmd, "r");       
   if(again_cmd[0]=='\0')
	   strcpy(again_cmd, "a");

   if(list_cmd[0]=='\0')
	   strcpy(list_cmd, "w");
   if(away_cmd[0]=='\0')
	   strcpy(away_cmd, "away");
   if(na_cmd[0]=='\0')
	   strcpy(na_cmd, "na");
   if(dnd_cmd[0]=='\0')
	   strcpy(dnd_cmd, "dnd");   
   if(online_cmd[0]=='\0')
	   strcpy(online_cmd, "online");
   if(occ_cmd[0]=='\0')
	   strcpy(occ_cmd, "occ");
   if(ffc_cmd[0]=='\0')
	   strcpy(ffc_cmd, "ffc");
   if(inv_cmd[0]=='\0')
	   strcpy(inv_cmd, "inv");
   if(status_cmd[0]=='\0')
	   strcpy(status_cmd, "status");
   if(add_cmd[0]=='\0')
	   strcpy(add_cmd, "add");
   if(auth_cmd[0]=='\0')
	   strcpy(auth_cmd, "auth");
   if(auto_cmd[0]=='\0')
	   strcpy(auto_cmd, "auto");
   if(search_cmd[0]=='\0')
	   strcpy(search_cmd, "search");
   if(save_cmd[0]=='\0')
	   strcpy(save_cmd, "save");
   if(alter_cmd[0]=='\0')

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -