aboutsummaryrefslogblamecommitdiff
path: root/src/espik_common_handler.c
blob: 239c69363cb9171c24001ee30584ce1f6c605b2c (plain) (tree)
1
2
3
4
5
6
7
8
9





                   
 

                              
                         
                  
                        
                      
                      
                                 
 
                        

                               
 

                                                                
 

                     
 


                                                        
 

             
 


                     
 




                                     
 




                                  
 

                                           
 

                               
 
             
 
 
  
                                                                            
 
            
            
 






                                            
 
          
   



                     
                      



                

             
 
  
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

#include <Ecore.h>

#include <readline/readline.h>

#include "espik_global.h"
#include "espik.h"
#include "espik_error.h"
#include "espik_irc.h"
#include "espik_net.h"
#include "espik_common_handler.h"

#define INPUT_LENGHT 200
  
static int  count_num_recv = 0;

int  server_data (void *data __UNUSED__, int ev_type __UNUSED__,
                  Ecore_Con_Event_Server_Data *ev)
{
  unsigned int   i;
  char          *msg;

  msg = strdup((char*)ev->data);
  //msg = convert_unicode_utf((const wchar_t*)ev->data);
  //msg = convert_utf_unicode((char*)ev->data);

  if (!msg)
    return 0;

  count_num_recv++;
  
  printf ("%s", msg);

  for (i = 0 ; i < strlen(msg) ; i++)
  {
    if (msg[i] == ' ')
      msg[i] = '\0';
  }

  if (count_num_recv >= 1)
  {
    //server_dns = strdup (msg+1);
    send_login ();
  }

  if (! (strcmp (msg, "PING")))
    espik_raw_send ("PONG guybrush.melee");

  memset (msg, 0, strlen(msg));
  free (msg);

  return (0);
}

/*
int  kb_get (void *data __UNUSED__, Ecore_Fd_Handler *fd_handler __UNUSED__)
{
  char  *kb;
  int i = 0;

  printf ("\n\n\nkb_get Called !!! \n\n\n");

while (i < 2)
{
  printf ("> ");
  fflush (stdout);
  kb = readline ("");

  if (!kb)
  {
    espik_shutdown();
    return (0);
  }

  printf ("%s\n", kb);
  irc_send (kb);
  i++;
//  free (kb);
  }

  return (1);
}
*/