Esempio n. 1
0
static ErlDrvData 
wxe_driver_start(ErlDrvPort port, char *buff)
{      
   wxe_data *data;
   data = (wxe_data *) malloc(sizeof(wxe_data));
   wxe_debug = 0;
   
   if (data == NULL) {
      fprintf(stderr, " Couldn't alloc mem\r\n");
      return(ERL_DRV_ERROR_GENERAL);  /* ENOMEM */      
   } else {
      set_port_control_flags(port, PORT_CONTROL_FLAG_BINARY);
      data->driver_data = NULL;
      data->bin = NULL; 
      data->port = port;
      if(WXE_DRV_PORT == 0) {
	 WXE_DRV_PORT = port;
	 wxe_master = data;
	 if(!(start_native_gui(data) == 1))
	    return(ERL_DRV_ERROR_GENERAL);  /* ENOMEM */
      } else {
	 meta_command(CREATE_PORT,data);
      }
      return (ErlDrvData) data;	 
   }
}
Esempio n. 2
0
static void
wxe_driver_unload(void) 
{
   // fprintf(stderr, "%s:%d: UNLOAD \r\n", __FILE__,__LINE__);
   meta_command(WXE_SHUTDOWN, wxe_master);
   stop_native_gui(wxe_master);
   unload_native_gui();
   free(wxe_master);
   wxe_master = NULL;
}
Esempio n. 3
0
static void
wxe_driver_stop(ErlDrvData handle) 
{  
   wxe_data *sd = ((wxe_data *)handle);
   if(sd->port != WXE_DRV_PORT) {
      // fprintf(stderr, "%s:%d: STOP \r\n", __FILE__,__LINE__);
      meta_command(DELETE_PORT,sd);
      free(handle);
   }
}
Esempio n. 4
0
void
server_command(struct sockaddr_in *from, char *cmd)
{
    Server	*s;
    
    if (cmd[0] == '*') {
	meta_command(from, cmd); 
    } else {
	s = serv_addr2server(from);
	  /* quietly ignore messages from unconnected servers */
	if (s && s->connected) {
	    receive_message(s->id, cmd);
	}
    }
}
Esempio n. 5
0
void stop_native_gui(wxe_data *sd)
{
    if(wxe_status == WXE_INITIATED) {
        meta_command(WXE_SHUTDOWN, sd);
    }
#ifdef __DARWIN__
    erl_drv_stolen_main_thread_join(wxe_thread, NULL);
#else
    erl_drv_thread_join(wxe_thread, NULL);
#endif
    erl_drv_mutex_destroy(wxe_status_m);
    erl_drv_cond_destroy(wxe_status_c);
    erl_drv_mutex_destroy(wxe_batch_locker_m);
    erl_drv_cond_destroy(wxe_batch_locker_c);
}
Esempio n. 6
0
static int wxe_driver_call(ErlDrvData handle, unsigned int command, 
			   char *buf, int len, char **res, int rlen, unsigned int *flags)
{
   wxe_data *sd = ((wxe_data *)handle);
   if(command == WXE_DEBUG_DRIVER) {
      if(*buf) 
	 wxe_debug = 1;
      else
	 wxe_debug = 0;
   } else {
      meta_command(PING_PORT,sd);
   }
   if (len > rlen)
      *res = driver_alloc(len);
   memcpy((void *) *res, (void *) buf, len);
   return len;   
}