A T T E N Z I O N E

Questo software non e' piu' supportato dalla UDA'Software ed eventuali riferimenti ad indirizzi E-Mail o links contenuti nella documentazione o nel programma stesso, potrebbero non essere piu' validi.

Per informazioni si consiglia di scrivere sempre al seguente indirizzo: budus@hotmail.it


StarBl4Zer C++ X-Chat Plugin Interface

starbl4zer.html version 3.2 - Last Update: Venerdi 23 Febbraio 2004

StarBl4Zer e' una classe C++ che permette di creare in modo semplice un plug-in per X-Chat, il client IRC per Linux/Windows GPL.

La classe ripercorre esattamente l'interfaccia plug-in descritta nel documento http://xchat.org/docs/plugin20.html e descrive un oggetto Plugin avente i seguenti Metodi:

Tramite questi metodi e' possibile creare e distruggere un plugin, ottenere informazioni, agganciare eventi di xchat e del server, creare uno o piu' timer, eseguire comandi, stampare stringhe, gestire i contesti, creare le liste dati con le informazioni ricavate dai contesti, ecc...

E' inoltre disponibile la classe UserData che puo' essere utilizzata per gestire i dati base di un utente; viene inoltre utilizzata da alcuni metodi della classe Plugin per ritornare gli utenti presenti nel database di X-Chat 2.

I metodi disponibili per la classe UserData sono:



Piuttosto che scrivere una guida enorme dalla quale si capirebbe poco, ho preferito creare alcuni esempi che mostrano come creare un plugin in modo semplice. Gli esempi disponibili sono:

Per compilare gli esempi e' possibile usare un makefile come quello di esempio.

Commenti, correzzioni e suggerimenti costruttivi sono graditi a budus@hotmail.it

Il pacchetto contenente questo documento e i sorgenti e' scaricabile da qui.


// Begin $Header: /home/uda/src/c/buduscript/plugin.h,v 1.26 2004/01/23 20:15:53 uda Exp $
// UDA'Software 2003
// $Date: 2003/08/19 13:24:42 $
// $Revision: 1.25 $

/*
 * PLUGIN.H : Questa classe ha il compito di gestire l'interfaccia
 * verso il client X-Chat2, offrendo tutti gli oggetti necessari a
 * facilitare l'uso delle varie funzioni offerte dalla libreria base
 * scritta in C Ansi.
*/

/*

  Copyright (C) 1988 Free Software Foundation, Inc.

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 1, or (at your option)
  any later version.

  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
  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

*/

// //////////////////////////////////////////////////////////////////////////////////////////////////////////
//___________________________________________________________________________________________________________
#ifndef HEADER_PLUGIN
#define HEADER_PLUGIN

// Include la libreria per la gestione dei plug-in.
#include <src/common/xchat-plugin.h>

// Include le librerie standard
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <ctype.h>

// Include la libreria GLIB
#include <glib.h>

#define	DONT_FREE_PREVIOUS_LIST	1

// //////////////////////////////////////////////////////////////////////////////////////////////////////////
//___________________________________________________________________________________________________________
#define IGNORED_NO		0
#define IGNORED_YES		1

/*
 * Definisce una classe User che serve per manipolare gli utenti
 * quando si effettuano delle ricerche all'interno del database del
 * client attraverso l'interfaccia della classe Plugin.
 *
 */
class UserData {
  char		*psNickname;
  char		*psHost;
  char		*psPrefix;
  char		*psChannel;
  char		*psServer;
  xchat_context	*pCTX;
  int		bIgnored;
  
 public:
  
  // Il costruttore
  UserData(const char		*Nickname = NULL, 
	   const char		*Host = NULL, 
	   const char		*Prefix = NULL, 
	   const char		*Channel = NULL, 
	   const char		*Server = NULL, 
	   xchat_context	*CTX = NULL, 
	   int			Ignored = IGNORED_NO) :
    pCTX(CTX), 
    bIgnored(Ignored)
    {
      if (Nickname)
	psNickname = strdup(Nickname);
      
      if (Host)
	psHost = strdup(Host);
      
      if (Prefix)
	psPrefix = strdup(Prefix);
      
      if (Channel)
	psChannel = strdup(Channel);
      
      if (Server)
	psServer = strdup(Server);
    }

  
  // Il costruttore di copia.
  UserData(const UserData &user) {
    psNickname = strdup(user.psNickname);
    psHost = strdup(user.psHost);
    psPrefix = strdup(user.psPrefix);
    psChannel = strdup(user.psChannel);
    psServer = strdup(user.psServer);
    pCTX = user.pCTX;
    bIgnored = user.bIgnored;
  }

  
  // Il distruttore
  ~UserData() {
    delete psNickname; psNickname = NULL;
    delete psHost; psHost = NULL;
    delete psPrefix; psPrefix = NULL;
    delete psChannel; psChannel = NULL;
    delete psServer; psServer = NULL;
    pCTX = NULL;
    bIgnored = 0;
  }
  
  
  // Funzioni che ritornano i dati.
  inline const char*	GetNickname()	{return psNickname;}
  inline const char*	GetHost()	{return psHost;}
  inline const char*	GetPrefix()	{return psPrefix;}
  inline const char*	GetChannel()	{return psChannel;}
  inline const char*	GetServer()	{return psServer;}
  inline xchat_context*	GetCTX()	{return pCTX;}
  inline int		GetIgnored()	{return bIgnored;}

  
  // Funzione che imposta il flag dell'ignore.
  int SetIgnored(const char *mask);

  
  // Overloading dell'operatore == .
  int operator == (const UserData user) {
    if (psNickname && user.psNickname && !strcasecmp(psNickname, user.psNickname)) {
      if (psHost && user.psHost && !strcasecmp(psHost, user.psHost)) {
	if (psPrefix && user.psPrefix && !strcasecmp(psPrefix, user.psPrefix)) {
	  if (psChannel && user.psChannel && !strcasecmp(psChannel, user.psChannel)) {
	    if (psServer && user.psServer && !strcasecmp(psServer, user.psServer))
	      return 1;
	  }
	}
      }
    }

    return 0;
  }
    
  
  // Overloading dell'operatore != .
  int operator != (const UserData user) {
    if (*this == user) {
      return 0;
    }
    
    // Ritorna fallimento.
    return 1;
  }
    
  
  // Overloading dell'operatore < .
  int operator < (const UserData user) {
    if (psNickname && user.psNickname && strcasecmp(psNickname, user.psNickname) < 0) {
      return 1;
    }
    
    // Ritorna fallimento.
    return 0;
  }
    
  
  // Overloading dell'operatore <=.
  int operator <= (const UserData user) {
    if (psNickname && user.psNickname && strcasecmp(psNickname, user.psNickname) <= 0) {
      return 1;
    }
    
    // Ritorna fallimento.
    return 0;
  }
    
  
  // Overloading dell'operatore > .
  int operator > (const UserData user) {
    if (psNickname && user.psNickname && strcasecmp(psNickname, user.psNickname) > 0) {
      return 1;
    }
    
    // Ritorna fallimento.
    return 0;
  }
    
  
  // Overloading dell'operatore >= .
  int operator >= (const UserData user) {
    if (psNickname && user.psNickname && strcasecmp(psNickname, user.psNickname) >= 0) {
      return 1;
    }
    
    // Ritorna fallimento.
    return 0;
  }
};

// //////////////////////////////////////////////////////////////////////////////////////////////////////////
//___________________________________________________________________________________________________________
typedef int (xchat_cmd_cb)	(char *word[], char *word_eol[], void *user_data);
typedef int (xchat_serv_cb)	(char *word[], char *word_eol[], void *user_data);
typedef int (xchat_print_cb)	(char *word[], void *user_data);
typedef int (xchat_fd_cb)	(int fd, int flags, void *user_data);
typedef int (xchat_timer_cb)	(void *user_data);

/*
 * Deve dichiarare delle strutture dati e delle enumerazioni
 * appartenenti al modulo plugin.c di X-Chat 2 perche' non sono
 * altrimenti accessibili.
 *
 */
struct _xchat_list {
  int type;		/* LIST_* */
  GSList *pos;		/* current pos */
  GSList *next;		/* next pos */
  GSList *head;
};

enum {
  LIST_CHANNELS,
  LIST_DCC,
  LIST_IGNORE,
  LIST_USERS
};

// //////////////////////////////////////////////////////////////////////////////////////////////////////////
//___________________________________________________________________________________________________________
/*
 * Questa funzione ha il compito di convertire i comandi %C, %B, %U,
 * %O e %R nei rispettivi codici.
 *
 */
void
check_special_chars (char *cmd, int do_ascii) {
  int	occur = 0;
  int	len = strlen (cmd);
  char	*buf, *utf;
  char	tbuf[4];
  int	i = 0, j = 0;
  gsize	utf_len;

  if (!len)
    return;

  buf = new char[len + 1];

  if (buf) {
      while (cmd[j]) {
	  switch (cmd[j]) {
	  case '%':
	    occur++;
	    if (do_ascii &&
		j + 3 < len &&
		(isdigit (cmd[j + 1]) && isdigit (cmd[j + 2]) &&
		 isdigit (cmd[j + 3]))) {
	      tbuf[0] = cmd[j + 1];
	      tbuf[1] = cmd[j + 2];
	      tbuf[2] = cmd[j + 3];
	      tbuf[3] = 0;
	      buf[i] = atoi (tbuf);
	      utf = g_locale_to_utf8 (buf + i, 1, 0, &utf_len, 0);
	      if (utf) {
		memcpy (buf + i, utf, utf_len);
		g_free (utf);
		i += (utf_len - 1);
	      }
	      j += 3;
	    } else {
	      switch (cmd[j + 1]) {
	      case 'R':
		buf[i] = '\026';
		break;
	      case 'U':
		buf[i] = '\037';
		break;
	      case 'B':
		buf[i] = '\002';
		break;
	      case 'C':
		buf[i] = '\003';
		break;
	      case 'O':
		buf[i] = '\017';
		break;
	      case '%':
		buf[i] = '%';
		break;
	      default:
		buf[i] = '%';
		j--;
		break;
	      }
	      j++;
	      break;
	    default:
	      buf[i] = cmd[j];
	    }
	  }
	  j++;
	  i++;
      }
      buf[i] = 0;
      if (occur)
	strcpy (cmd, buf);
      
      delete buf;
  }
}
 
// //////////////////////////////////////////////////////////////////////////////////////////////////////////
//___________________________________________________________________________________________________________
/*
 * Queste funzioni servono per convertire in minuscolo un carattere
 * (rispettando l'RFC) e per verificare se una stringa corrisponde ad
 * una data maschera (controllo dell'ignore).
 *
 */
 
#define rfc_tolower(c)		(rfc_tolowertab[(unsigned char)(c)])

const unsigned char rfc_tolowertab[] = {
  0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa,
  0xb, 0xc, 0xd, 0xe, 0xf, 0x10, 0x11, 0x12, 0x13, 0x14,
  0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d,
  0x1e, 0x1f,
  ' ', '!', '"', '#', '$', '%', '&', 0x27, '(', ')',
  '*', '+', ',', '-', '.', '/',
  '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
  ':', ';', '<', '=', '>', '?',
  '@', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
  'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
  't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~',
  '_',
  '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
  'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
  't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~',
  0x7f,
  0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89,
  0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
  0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99,
  0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
  0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9,
  0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
  0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9,
  0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
  0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9,
  0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
  0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9,
  0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
  0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9,
  0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
  0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9,
  0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
};

int match_mask(const char *mask,	// La maschera
	       const char *string) {	// La stringa
  register const char	*m = mask, *s = string;
  register char		ch;
  const char		*bm, *bs;

  while ((ch = *m++) && (ch != '*'))
    switch (ch) {
    case '\\':
      if (*m == '?' || *m == '*')
	ch = *m++;
    default:
      if (rfc_tolower(*s) != rfc_tolower(ch))
	return 0;
    case '?':
      if (!*s++)
	return 0;
    };

  if (!ch)
    return !(*s);

 got_star:
  bm = m;
  while ((ch = *m++))
    switch (ch) {
    case '?':
      if (!*s++)
	return 0;
    case '*':
      bm = m;
      continue;
    case '\\':
      if (*m == '?' || *m == '*')
	ch = *m++;

    default:
      goto break_while;
    };

 break_while:
  if (!ch)
    return 1;

  ch = rfc_tolower(ch);
  while (rfc_tolower(*s++) != ch)
    if (!*s)
      return 0;
  
  bs = s;

  while ((ch = *m++)) {
    switch (ch) {
    case '*':
      goto got_star;
    case '\\':
      if (*m == '?' || *m == '*')
	ch = *m++;
      
    default:
      if (rfc_tolower(*s) != rfc_tolower(ch)) {
	m = bm;
	s = bs;
	
	goto got_star;
      };
    case '?':
      if (!*s++)
	return 0;
    };
  };

  if (*s) {
    m = bm;
    s = bs;
    goto got_star;
  };

  return 1;
}

// //////////////////////////////////////////////////////////////////////////////////////////////////////////
//___________________________________________________________________________________________________________
/*
 * Definisce la funzione che imposta il flag dell'ignore nella classe
 * UserData.
 *
 * (lo fa dopo la definizione della funzione match_mask() necessaria
 * allo scopo).
 *
 */
int
UserData::SetIgnored(const char *mask) {
  if (mask &&		// La maschera deve essere valida
      mask[0] != '\0' && 
      psNickname &&	// Il nickname deve essere valido
      psHost) {		// L'host deve essere valido
    char	*string = new char[strlen(psNickname) + strlen(psHost) + 2];

    sprintf(string, "%s!%s", psNickname, psHost);
    bIgnored = match_mask(mask, string);
    
    delete string; string = NULL;

    return bIgnored;
  }

  return -1;
}

// //////////////////////////////////////////////////////////////////////////////////////////////////////////
//___________________________________________________________________________________________________________
class Plugin {
  xchat_plugin	*hPlugin;		// Handle del plug-in
  xchat_list	*hlData;		// Lista dei dati
  char		*psNome;		// Nome del plug-in
  char		*psDescrizione;		// Descrizione del plug-in
  char		*psVersione;		// Versione del plug-in
  char		*psArgomenti;		// Argomenti passati al plug-in
  int		eListStatus;		// Stato nella gestione delle liste

 public:
  enum {list_ERROR, list_OK};		// Enumerazione sullo stato della lista

  
  // Costruttore
  Plugin(xchat_plugin *hP = NULL,
	 char *Nome = "",
	 char *Descrizione = "",
	 char *Versione = "",
	 char *Argomenti = "") :
    hPlugin(hP), 
    hlData(NULL)
    {
      psNome = NULL;
      psDescrizione = NULL;
      psVersione = NULL;
      psArgomenti = NULL;
      
      if (Nome)
	psNome = strdup(Nome);
      
      if (Descrizione)
	psDescrizione = strdup(Descrizione);
      
      if (Versione)
	psVersione = strdup(Versione);

      if (Argomenti)
	psArgomenti = strdup(Argomenti);

      eListStatus = list_ERROR;
    }
  
  
  // Costruttore di Copia (necessario per una classe con puntatori)
  Plugin(const Plugin &plugin) {
    hPlugin = plugin.hPlugin;
    hlData = plugin.hlData;

      psNome = NULL;
      psDescrizione = NULL;
      psVersione = NULL;
      psArgomenti = NULL;
      
      if (plugin.psNome)
	psNome = strdup(plugin.psNome);
      
      if (plugin.psDescrizione)
	psDescrizione = strdup(plugin.psDescrizione);
      
      if (plugin.psVersione)
	psVersione = strdup(plugin.psVersione);

      if (plugin.psArgomenti)
	psArgomenti = strdup(plugin.psArgomenti);

      eListStatus = plugin.eListStatus;
  }
  
  
  // Ritorna il puntatore al plugin.
  xchat_plugin	*GetPlugin() {
    return hPlugin;
  }

  
  // Ritorna il Nome del plugin.
  const char	*GetNome() {
    return psNome;
  }

  
  // Ritorna la Versione.
  const char	*GetVersione() {
    return psVersione;
  }

  
  // Ritorna la lista dei dati.
  xchat_list	*GetList() {
    if (eListStatus == list_OK)
      return hlData;
    else
      return 0;
  }

  
  // Ritorna lo stato della lista dati.
  int		GetListStatus() {
    return eListStatus;
  }

  
  // Aggiunge un nuovo comando.
  xchat_hook	*hook_command(char *name,			// Nome del comando
			      xchat_cmd_cb *callb,		// Funzione da invocare
			      char *help_text = NULL,		// Guida
			      void *userdata = NULL) {		// Puntatore passato alla funzione
    // Verifica che i dati passati siano corretti.
    if (name && name[0] != '\0') {
      return xchat_hook_command(hPlugin, 
				name, 
				XCHAT_PRI_NORM, 
				callb, 
				help_text, 
				userdata);
    }

    return NULL;
  }

  
  // Aggancia un Socket o un Descrittore file.
  xchat_hook	*hook_fd(int fd,				// Il File Descriptor
			 // Flag: XCHAT_FD_READ, XCHAT_FD_WRITE, XCHAT_FD_EXCEPTION
			 int flags, 
			 xchat_fd_cb *callb,			// Funzione da invocare
			 void *userdata = NULL) {		// Puntatore passato alla funzione
    return xchat_hook_fd(hPlugin, 
			 fd, 
			 flags, 
			 callb, 
			 userdata);
  }

  
  // Aggancia un evento tra quelli dell'Event Text di X-Chat o tra
  // quelli speciali.
  /*
   * Lista Eventi Speciali:
   * "Open Context" - Chiamata quando un nuovo xchat_context e' creato.
   * "Close Context" - Chiamata quando un puntatore xchat_context e' chiuso.
   * "Focus Tab" - Chiamata quando una Tab riceve il focus.
   * "Focus Window" - Chiamata quando la finestra principale riceve il focus.
   * "DCC Chat Text" - Chiamata quando si riceve un DCC. L'array
   * word[] viene cosi' riempito:
   * word[1] Address 
   * word[2] Port 
   * word[3] Nick 
   * word[4] The Message
   */
  xchat_hook	*hook_print(char *name,				// Nome dell'Event Text
			    xchat_print_cb *callb,		// Funzione da invocare
			    void *userdata = NULL) {		// Puntatore passato alla funzione
    // Controlla che il parametro passato sia valido.
    if (name && name[0] != '\0') {
      return xchat_hook_print(hPlugin, 
			      name, 
			      XCHAT_PRI_NORM, 
			      callb, 
			      userdata);
    }

    return NULL;
  }

  
  // Aggancia un Evento del Server.
  xchat_hook	*hook_server(char *name,			// Nome dell'evento
			     xchat_serv_cb *callb,		// Funziona da invocare
			     void *userdata = NULL) {		// Puntatore passato alla funzione
    // Controlla che il parametro passato sia valido.
    if (name && name[0] != '\0') {
      return xchat_hook_server(hPlugin, 
			       name, 
			       XCHAT_PRI_NORM, 
			       callb, 
			       userdata);
    }

    return NULL;
  }

  
  // Attiva un Timer.
  xchat_hook	*hook_timer(int timeout,			// Tempo del timer in millisecondi
			    xchat_timer_cb *callb,		// Funzione da invocare
			    void *userdata = NULL) {		// Puntatore passato alla funzione
    if (timeout > 0)
      return xchat_hook_timer(hPlugin, 
			      timeout, 
			      callb, 
			      userdata);

    return NULL;
  }

  
  // Disattiva un evento agganciato.
  void		unhook(xchat_hook **hook) {			// Puntatore all'Hook da eliminare
    if (hook) {
      xchat_unhook(hPlugin, (*hook));
      (*hook) = NULL;
    }
  }

  
  // Esegue un comando X-Chat.
  void		command(char *command) {
    if (command && command[0] != '\0') {
      check_special_chars(command, 1);
      xchat_command(hPlugin, command);
    }
  }

  
  // Esegue un comando X-Chat composto.
  void		commandf(char *format, ...) {
    va_list args;
    char *buf;
    
    va_start(args, format);
    buf = new char[vprintf(format, args) + 1];
    vsprintf(buf, format, args);
    va_end(args);
    
    check_special_chars(buf, 1);
    xchat_command(hPlugin, buf);

    delete buf;
  }

  
  // Stampa una stringa.
  void		print(char *text) {
    if (text && text[0] != '\0') {
      xchat_print(hPlugin, text);
    }
  }

  
  // Stampa una stringa composta.
  void		printf(char *format, ...) {
    va_list args;
    char *buf;
    
    va_start(args, format);
    buf = new char[vprintf(format, args) + 1];
    vsprintf(buf, format, args);
    va_end(args);
    
    check_special_chars(buf, 1);
    xchat_print(hPlugin, buf);
    delete buf;
  }

  
  // Genera un Evento.
  void		emit_print(char *event_name, 
			   ...) {
    if (event_name && event_name[0] != '\0') {
      va_list args;
      char	*argv[4];
      int	i = 0;

      memset (&argv, 0, sizeof (argv));
      va_start (args, event_name);
      
      while(1)	{
	argv[i] = va_arg (args, char *);
	if (!argv[i])
	  break;
	i++;
	if (i >= 4)
	  break;
      }
      
      xchat_emit_print(hPlugin, event_name, argv[0], argv[1], argv[2], argv[3]);
      
      va_end (args);
    }
  }

  
  // Restituisce il contesto in base al server/canale.
  xchat_context	*find_context(char *servname = NULL,	// Server nel quale cercare
			      char *channel = NULL) {	// Canale da cercare
    return xchat_find_context(hPlugin, servname, channel);
  }

  
  // Cerca un oggetto della classe Utente in base al: Nickname
  UserData	*find_user_nickname(const char *Nickname) {
    static xchat_list	*cUserData_list;
    UserData		*pcUserData = NULL;

    if (Nickname && Nickname[0] != '\0') {
      // Se la lista non e' gia' stata creata, provvede a farlo.
      if (!cUserData_list)
	cUserData_list = Plugin::list_get_cUserData();

      // Verifica se e' riuscito a crare la lista.
      if (cUserData_list) {
	while(Plugin::list_next_cUserData(cUserData_list)) {
	  pcUserData = Plugin::list_cUserData(cUserData_list);
	  
	  if (!strcasecmp(Nickname, pcUserData->GetNickname()))
	    return pcUserData;
	  
	  delete pcUserData;
	}
	
	Plugin::list_free_cUserData(&cUserData_list);
      }
    }
    
    return NULL;
  }

  
  // Cerca un oggetto della classe Utente in base al: Host
  UserData	*find_user_host(const char *Host) {
    static xchat_list	*cUserData_list;
    UserData		*pcUserData = NULL;

    if (Host && Host[0] != '\0') {
      // Se la lista non e' gia' stata creata, provvede a farlo.
      if (!cUserData_list)
	cUserData_list = Plugin::list_get_cUserData();

      // Verifica se e' riuscito a crare la lista.
      if (cUserData_list) {
	while(Plugin::list_next_cUserData(cUserData_list)) {
	  pcUserData = Plugin::list_cUserData(cUserData_list);
	  
	  if (!strcasecmp(Host, pcUserData->GetHost()))
	    return pcUserData;
	  
	  delete pcUserData;
	}
	
	Plugin::list_free_cUserData(&cUserData_list);
      }
    }
    
    return NULL;
  }

  
  // Cerca un oggetto della classe Utente in base al: Prefix
  UserData	*find_user_prefix(const char *Prefix) {
    static xchat_list	*cUserData_list;
    UserData		*pcUserData = NULL;

    if (Prefix && Prefix[0] != '\0') {
      // Se la lista non e' gia' stata creata, provvede a farlo.
      if (!cUserData_list)
	cUserData_list = Plugin::list_get_cUserData();

      // Verifica se e' riuscito a crare la lista.
      if (cUserData_list) {
	while(Plugin::list_next_cUserData(cUserData_list)) {
	  pcUserData = Plugin::list_cUserData(cUserData_list);
	  
	  if (!strcasecmp(Prefix, pcUserData->GetPrefix()))
	    return pcUserData;
	  
	  delete pcUserData;
	}
	
	Plugin::list_free_cUserData(&cUserData_list);
      }
    }
    
    return NULL;
  }

  
  // Cerca un oggetto della classe Utente in base al: Channel
  UserData	*find_user_channel(const char *Channel) {
    static xchat_list	*cUserData_list;
    UserData		*pcUserData = NULL;

    if (Channel && Channel[0] != '\0') {
      // Se la lista non e' gia' stata creata, provvede a farlo.
      if (!cUserData_list)
	cUserData_list = Plugin::list_get_cUserData();

      // Verifica se e' riuscito a crare la lista.
      if (cUserData_list) {
	while(Plugin::list_next_cUserData(cUserData_list)) {
	  pcUserData = Plugin::list_cUserData(cUserData_list);
	  
	  if (!strcasecmp(Channel, pcUserData->GetChannel()))
	    return pcUserData;
	  
	  delete pcUserData;
	}
	
	Plugin::list_free_cUserData(&cUserData_list);
      }
    }
    
    return NULL;
  }

  
  // Cerca un oggetto della classe Utente in base al: Server
  UserData	*find_user_server(const char *Server) {
    static xchat_list	*cUserData_list;
    UserData		*pcUserData = NULL;

    if (Server && Server[0] != '\0') {
      // Se la lista non e' gia' stata creata, provvede a farlo.
      if (!cUserData_list)
	cUserData_list = Plugin::list_get_cUserData();

      // Verifica se e' riuscito a crare la lista.
      if (cUserData_list) {
	while(Plugin::list_next_cUserData(cUserData_list)) {
	  pcUserData = Plugin::list_cUserData(cUserData_list);
	  
	  if (!strcasecmp(Server, pcUserData->GetServer()))
	    return pcUserData;
	  
	  delete pcUserData;
	}
	
	Plugin::list_free_cUserData(&cUserData_list);
      }
    }
    
    return NULL;
  }

  
  // Cerca un oggetto della classe Utente in base al: Contesto
  UserData	*find_user_CTX(const xchat_context *CTX) {
    static xchat_list	*cUserData_list;
    UserData		*pcUserData = NULL;

    if (CTX) {      
      // Se la lista non e' gia' stata creata, provvede a farlo.
      if (!cUserData_list)
	cUserData_list = Plugin::list_get_cUserData();

      // Verifica se e' riuscito a crare la lista.
      if (cUserData_list) {
	while(Plugin::list_next_cUserData(cUserData_list)) {
	  pcUserData = Plugin::list_cUserData(cUserData_list);
	  
	  if (CTX == pcUserData->GetCTX())
	    return pcUserData;
	  
	  delete pcUserData;
	}
	
	Plugin::list_free_cUserData(&cUserData_list);
      }
    }
    
    return NULL;
  }

  
  // Cerca un oggetto della classe Utente in base al flag: Ignored
  UserData	*find_user_ignored(int Ignored) {
    static xchat_list	*cUserData_list;
    UserData		*pcUserData = NULL;

    // Se la lista non e' gia' stata creata, provvede a farlo.
    if (!cUserData_list)
      cUserData_list = Plugin::list_get_cUserData();
    
    // Verifica se e' riuscito a crare la lista.
    if (cUserData_list) {
      while(Plugin::list_next_cUserData(cUserData_list)) {
	pcUserData = Plugin::list_cUserData(cUserData_list);
	
	if (Ignored == pcUserData->GetIgnored())
	  return pcUserData;
	
	delete pcUserData;
      }
      
      Plugin::list_free_cUserData(&cUserData_list);
    }
    
    return NULL;
  }

  
  // Cerca un oggetto della classe Utente in base ai dati passati come
  // parametri.
  /*
   * I parametri che vengono passati "non nulli" devono essere
   * verificati completamente (cioe' il relativo dato dell'oggetto
   * UserData deve essere identico anche se con case insensitive)
   * affinche' l'oggetto UserData venga ritornato, viceversa, vengono
   * ignorati (in questo modo e' possibile fare ricerche "incrociate"
   * solo su alcuni dati).
   *
   */
  UserData	*find_user_cmp(const char *Nickname = NULL, 
			       const char *Host = NULL, 
			       const char *Prefix = NULL, 
			       const char *Channel = NULL, 
			       const char *Server = NULL, 
			       const xchat_context *CTX = NULL, 
			       int Ignored = -1) {
    static xchat_list	*cUserData_list;
    UserData		*pcUserData = NULL;

    // Se la lista non e' gia' stata creata, provvede a farlo.
    if (!cUserData_list)
      cUserData_list = Plugin::list_get_cUserData();
    
    // Verifica se e' riuscito a crare la lista.
    if (cUserData_list) {
      while(Plugin::list_next_cUserData(cUserData_list)) {
	pcUserData = Plugin::list_cUserData(cUserData_list);
	
	if (!Nickname || 
	    !Plugin::nickcmp(Nickname, 
			     pcUserData->GetNickname() ? 
			     pcUserData->GetNickname() : 
			     "")) {
	  if (!Host || 
	      !Plugin::nickcmp(Host, 
			       pcUserData->GetHost() ? 
			       pcUserData->GetHost() : 
			       "")) {
	    if (!Prefix || 
		!Plugin::nickcmp(Prefix, 
				 pcUserData->GetPrefix() ? 
				 pcUserData->GetPrefix() : 
				 "")) {
	      if (!Channel || 
		  !Plugin::nickcmp(Channel, 
				   pcUserData->GetChannel() ? 
				   pcUserData->GetChannel() : 
				   "")) {
		if (!Server || 
		    !Plugin::nickcmp(Server, 
				     pcUserData->GetServer() ? 
				     pcUserData->GetServer() : 
				     "")) {
		  if (!CTX || 
		      CTX == pcUserData->GetCTX()) {
		    if (Ignored == -1 || 
			Ignored == pcUserData->GetIgnored())
		      return pcUserData;
		  }
		}
	      }
	    }
	  }
	}
	
	delete pcUserData;
      }
      
      Plugin::list_free_cUserData(&cUserData_list);
    }
    
    return NULL;
  }

  
  // Cerca un oggetto della classe Utente in base ai dati passati come
  // parametri.
  /*
   * I parametri che vengono passati "non nulli" possono essere
   * verificati anche parzialmente (cioe' il relativo dato
   * dell'oggetto UserData deve essere simile anche se con case
   * sensitive) affinche' l'oggetto UserData venga ritornato,
   * viceversa, vengono ignorati (in questo modo e' possibile fare
   * ricerche "incrociate" solo su alcuni dati).
   *
   */
  UserData	*find_user_str(const char *Nickname = NULL, 
			       const char *Host = NULL, 
			       const char *Prefix = NULL, 
			       const char *Channel = NULL, 
			       const char *Server = NULL, 
			       const xchat_context *CTX = NULL, 
			       int Ignored = -1) {
    static xchat_list	*cUserData_list;
    UserData		*pcUserData = NULL;

    // Se la lista non e' gia' stata creata, provvede a farlo.
    if (!cUserData_list)
      cUserData_list = Plugin::list_get_cUserData();
    
    // Verifica se e' riuscito a crare la lista.
    if (cUserData_list) {
      while(Plugin::list_next_cUserData(cUserData_list)) {
	pcUserData = Plugin::list_cUserData(cUserData_list);
	
	if (!Nickname || 
	    strstr(Nickname, 
		   pcUserData->GetNickname() ? 
		   pcUserData->GetNickname() : 
		   " ") || 
	    strstr(pcUserData->GetNickname() ? 
		   pcUserData->GetNickname() : 
		   " ", 
		   Nickname)) {
	  if (!Host || 
	      strstr(Host, 
		     pcUserData->GetHost() ? 
		     pcUserData->GetHost() : 
		     " ") || 
	      strstr(pcUserData->GetHost() ? 
		     pcUserData->GetHost() : 
		     " ", 
		     Host)) {
	    if (!Prefix || 
		strstr(Prefix, 
		       pcUserData->GetPrefix() ? 
		       pcUserData->GetPrefix() : 
		       " ") || 
		strstr(pcUserData->GetPrefix() ? 
		       pcUserData->GetPrefix() : 
		       " ", 
		       Prefix)) {
	      if (!Channel || 
		  strstr(Channel, 
			 pcUserData->GetChannel() ? 
			 pcUserData->GetChannel() : 
			 " ") || 
		  strstr(pcUserData->GetChannel() ? 
			 pcUserData->GetChannel() : 
			 " ", 
			 Channel)) {
		if (!Server || 
		    strstr(Server, 
			   pcUserData->GetServer() ? 
			   pcUserData->GetServer() : 
			   " ") || 
		    strstr(pcUserData->GetServer() ? 
			   pcUserData->GetServer() : 
			   " ", 
			   Server)) {
		  if (!CTX || 
		      CTX == pcUserData->GetCTX()) {
		    if (Ignored == -1 || 
			Ignored == pcUserData->GetIgnored())
		      return pcUserData;
		  }
		}
	      }
	    }
	  }
	}
	
	delete pcUserData;
      }
      
      Plugin::list_free_cUserData(&cUserData_list);
    }
    
    return NULL;
  }

  
  // Restituisce il contesto corrente.
  xchat_context	*get_context() {
    return xchat_get_context(hPlugin);
  }

  
  // Ritorna informazioni sul contesto corrente.
  const char	*get_info(char *id) {			// Stringa identificativa
    if (id && id[0] != '\0') {
      return xchat_get_info(hPlugin, id);
    }

    return NULL;
  }

  
  // Ritorna informazioni sullo stato di AWAY dell'utente locale,
  // compreso l'eventuale motivo.
  const char	*get_info_away() {
    return xchat_get_info(hPlugin, "away");
  }

  
  // Ritorna il nome del canale corrente.
  const char	*get_info_channel() {
    return xchat_get_info(hPlugin, "channel");
  }

  
  // Ritorna il nome dell'Host corrente.
  const char	*get_info_host() {
    return xchat_get_info(hPlugin, "host");
  }

  
  // Ritorna il nome del network corrente.
  const char	*get_info_network() {
    return xchat_get_info(hPlugin, "network");
  }

  
  // Ritorna il nickname corrente dell'utente locale.
  const char	*get_info_nick() {
    return xchat_get_info(hPlugin, "nick");
  }

  
  // Ritorna il nome del server corrente.
  const char	*get_info_server() {
    return xchat_get_info(hPlugin, "server");
  }

  
  // Ritorna il topic del canale corrente.
  const char	*get_info_topic() {
    return xchat_get_info(hPlugin, "topic");
  }

  
  // Ritorna la versione di X-Chat.
  const char	*get_info_version() {
    return xchat_get_info(hPlugin, "version");
  }

  
  // Ritorna la directory di configurazione di X-Chat.
  const char	*get_info_xchatdir() {
    return xchat_get_info(hPlugin, "xchatdir");
  }

  
  // Restituisce la configurazione di una variabile di X-Chat.
  // 0-Fallimento 1-Ritorna una stringa 2-Ritorna un Intero
  // 3-Ritorna un Booleano.
  int		get_prefs(const char *name,	// Nome della preferenza
			  const char **string,	// &stringa
			  int *integer) {	// &intero
    if (name && name[0] != '\0')
      return xchat_get_prefs(hPlugin, name, string, integer);
    else
      return 0;
  }

  
  // Imposta come corrente il contesto passato.
  int		set_context(xchat_context *ctx) {
    if (ctx)
      return xchat_set_context(hPlugin, ctx);
    
    return 0;
  }

  
  // Ottiene le informazioni richieste inserendole in una lista.
  /*
   * I possibili valori di name sono:
   *
   * channels
   * dcc
   * ignore
   * users
   *
   */
  /*
   *  Se, come secondo parametro, viene passata la define
   *  "DONT_FREE_PREVIOUS_LIST", la lista precedente non viene
   *  eliminata.
   *
   */
  xchat_list	*list_get(const char *name, 
			  int fFreePreviousList = 1) {
    // Se necessario, libera la lista corrente.
    if (name && name[0] != '\0') {
      if (hlData && fFreePreviousList) {
	xchat_list_free(hPlugin, hlData);
	hlData = NULL;
      }
      
      hlData = xchat_list_get(hPlugin, name);
      eListStatus = list_OK;
      
      if (!hlData || 
	  !Plugin::list_next(hlData)) {
	eListStatus = list_ERROR;
	
	return NULL;
      }
      
      return hlData;
    }
    
    eListStatus = list_ERROR;
    
    return 0;
  }

  
  // Ottiene le informazioni sui canali.
  xchat_list	*list_get_channels(int fFreePreviousList = 1) {
    return Plugin::list_get("channels", fFreePreviousList);
  }

  
  // Ottiene le informazioni sui dcc.
  xchat_list	*list_get_dcc(int fFreePreviousList = 1) {
    return Plugin::list_get("dcc", fFreePreviousList);
  }

  
  // Ottiene le informazioni sugli ignore.
  xchat_list	*list_get_ignore(int fFreePreviousList = 1) {
    return Plugin::list_get("ignore", fFreePreviousList);
  }

  
  // Ottiene le informazioni sugli utenti.
  xchat_list	*list_get_users(int fFreePreviousList = 1) {
    return Plugin::list_get("users", fFreePreviousList);
  }

  
  // Genera la lista utenti sfruttando la classe UserData.
  xchat_list	*list_get_cUserData() {
    // Dichiara le liste
    xchat_list		*list = NULL;
    GSList		*cUserData_list = NULL;
    xchat_list		*user_list = NULL;
    xchat_list		*ctx_list = NULL;
    xchat_context	*ctx = NULL;
    xchat_list		*ignore_list = NULL;
    UserData		*pcUserDataInsert = NULL;
    int			bIgnoreListEmpty = 0;
    
    // Memorizza il contesto corrente.
    xchat_context	*ctxCurrent = xchat_get_context(hPlugin);
    
    list = (xchat_list*)malloc(sizeof(struct _xchat_list));
    if (list) {
      list->pos = NULL;
      list->type = LIST_USERS;
      
      // Esegue un ciclo iterativo per ogni contesto esistente.
      ctx_list = xchat_list_get(hPlugin, "channels");
      if (ctx_list) {
	while(xchat_list_next(hPlugin, ctx_list)) {
	  ctx = (xchat_context*)xchat_list_str(hPlugin, ctx_list, "context");
	  
	  // Se il contesto intercettato e' valido, provvede ad
	  // impostarlo come corrente.
	  if (ctx && xchat_set_context(hPlugin, ctx)) {
	    // Se il contesto individuato e' un Canale, provvede ad
	    // inserire tutti gli utenti presenti in quest'ultimo. Fa
	    // la stessa cosa anche se si tratta di un
	    // Dialog. L'inserimento avviene solo se l'utente non e'
	    // gia' inserito.
	    user_list = xchat_list_get(hPlugin, "users");
	    
	    if (user_list) {
	      while(xchat_list_next(hPlugin, user_list)) {
		// Crea un utente da inserire nella GSList.
		pcUserDataInsert = new UserData(xchat_list_str(hPlugin, user_list, "nick"), 
						xchat_list_str(hPlugin, user_list, "host"), 
						xchat_list_str(hPlugin, user_list, "prefix"), 
						xchat_list_str(hPlugin, ctx_list, "channel"), 
						xchat_list_str(hPlugin, ctx_list, "server"), 
						ctx);

		if (pcUserDataInsert) {
		  // Se la lista degli ignore non e' risultata vuota in
		  // precedenza, provvede ad effettuare il controllo.
		  if (!bIgnoreListEmpty) {
		    // Ora deve verificare se l'utente estrapolato
		    // corrisponde ad una delle eventuali maschere di
		    // ignore; se combacia, imposta il relativo flag.
		    ignore_list = xchat_list_get(hPlugin, "ignore");
		    
		    if (ignore_list) {
		      while(xchat_list_next(hPlugin, ignore_list) && 
			    !pcUserDataInsert->
			    SetIgnored(xchat_list_str(hPlugin, 
						      ignore_list, 
						      "mask"))) {}
		      
		      // Ora puo' liberare la lista, non piu'
		      // indispensabile.
		      xchat_list_free(hPlugin, ignore_list); ignore_list = NULL;
		    } else
		      bIgnoreListEmpty = 1;
		  }
		  
		  // Se la lista degli utenti e' vuota, inserisce l'utente
		  // creato.
		  if (!cUserData_list) {
		    cUserData_list = g_slist_alloc();
		    cUserData_list->data = (void*)pcUserDataInsert;
		  } else {
		    // Appende l'utente nella lista.
		    g_slist_append(cUserData_list, 
				   pcUserDataInsert);
		  }
		}
	      }
	      
	      // Ora puo' liberare la lista, non piu'
	      // indispensabile.
	      xchat_list_free(hPlugin, user_list); user_list = NULL;
	    }
	  }
	}
	
	// Ora puo' liberare la lista, non piu'
	// indispensabile.
	xchat_list_free(hPlugin, ctx_list); ctx_list = NULL;
      }

      xchat_set_context(hPlugin, ctxCurrent);
      
      if (cUserData_list) {
	// ritorna la lista creata.
	list->head = list->next = cUserData_list;
	
	eListStatus = list_OK;
      } else {
	free(list); list = NULL;
	eListStatus = list_ERROR;
      }
    }	// list: ok
    
    return list;
  }

  
  // Elimina la lista utenti creata sfruttando la classe UserData.
  void		list_free_cUserData(xchat_list **xlist) {
    if ((*xlist)) {
      xchat_list_free(hPlugin, (*xlist));
      (*xlist) = NULL;
    }
  }

  
  // Ritorna gli elementi della lista formata da elementi di classe
  // UserData.
  UserData	*list_cUserData(xchat_list *xlist) {
    if (xlist && xlist->pos)
      return (UserData*)xlist->pos->data;
    
    eListStatus = list_ERROR;
    
    // Evita di ritornare il nulla.
    UserData	*pUser = new UserData();
    return pUser;
  }

  
  // Punta all'elemento successivo della lista formata da elementi di
  // classe UserData.
  int		list_next_cUserData(xchat_list *xlist) {
    if (xlist) {
      if (xlist->next == NULL)
	return 0;
      
      xlist->pos = xlist->next;
      xlist->next = xlist->pos->next;
      
      return 1;
    }
    
    return 0;
  }
  
  
  // Elimina la lista passata come parametro, oppure, quella globale
  // se la prima risulta nulla.
  void		list_free(xchat_list **xlist) {
    if ((*xlist) == hlData) {
      hlData = NULL;
    }
    
    if ((*xlist)) {
      xchat_list_free(hPlugin, (*xlist));
      (*xlist) = NULL;
    } else
      Plugin::list_free();
  }

  // Elimina la lista.
  void		list_free() {
    if (hlData) {
      xchat_list_free(hPlugin, hlData);
      hlData = NULL;
    }
  }

  
  // Punta all'elemento successivo della lista.
  int		list_next(xchat_list *xlist = NULL) {
    if (xlist == NULL)
      xlist = hlData;

    if (xlist && 
	xchat_list_next(hPlugin, xlist))
      return 1;

    return 0;
  }

  
  // Ritorna la tipologia dei campi.
  /*
   * I possibili valori di name sono:
   *
   * channels
   * dcc
   * ignore
   * users
   * lists
   *
   */
  const char	**list_fields(const char *name) {
    if (name && name[0] != '\0')
      return xchat_list_fields(hPlugin, name);

    return NULL;
  }

  
  // Ritorna la stringa appartenente al campo specificato.
  /*
   * I possibili valori di name sono:
   *
   * channel
   * context (meglio usare list_channels_context_ctx() )
   * server
   * destfile
   * file
   * nick
   * mask
   * host
   * prefix
   *
   */
  const char	*list_str(const char *name, 
			  xchat_list *xlist = NULL) {
    if (xlist == NULL)
      xlist = hlData;

    if (xlist && 
	name && 
	name[0] != '\0') {
      return xchat_list_str(hPlugin, xlist, name);
    }

    return NULL;
  }

  
  // Ritorna la lista dei canali "joinati".
  const char	*list_channels_channel_str(xchat_list *xlist = NULL) {
    const char	*pData = NULL;

    if (xlist == NULL)
      xlist = hlData;
    
    if (!xlist)
      xlist = Plugin::list_get("channels");
    
    if (eListStatus) {
      pData = xchat_list_str(hPlugin, xlist, "channel");
      
      if (!Plugin::list_next(xlist))    
	eListStatus = list_ERROR;
    } else {
      Plugin::list_free(&xlist);
    }
    
    return pData;
  }

  
  // Ritorna il puntatore ai contesti "joinati".
  const xchat_context*
    list_channels_context_ctx(xchat_list *xlist = NULL) {
    xchat_context	*pContext = NULL;

    if (xlist == NULL)
      xlist = hlData;
    
    if (!xlist)
      xlist = Plugin::list_get("channels");
    
    if (eListStatus) {
      pContext = (xchat_context*)xchat_list_str(hPlugin, xlist, "context");
      
      if (!Plugin::list_next(xlist))    
	eListStatus = list_ERROR;
    } else {
      Plugin::list_free(&xlist);
    }
    
    return pContext;
  }

  
  // Ritorna la lista dei servers collegati.
  const char	*list_channels_server_str(xchat_list *xlist = NULL) {
    const char	*pData = NULL;

    if (xlist == NULL)
      xlist = hlData;
    
    if (!xlist)
      xlist = Plugin::list_get("channels");
    
    if (eListStatus) {
      pData = xchat_list_str(hPlugin, xlist, "server");
      
      if (!Plugin::list_next(xlist))    
	eListStatus = list_ERROR;
    } else {
      Plugin::list_free(&xlist);
    }
    
    return pData;
  }

  
  // Ritorna la lista dei nomi dei files destinazione nelle
  // trasmissioni DCC.
  const char	*list_dcc_destfile_str(xchat_list *xlist = NULL) {
    const char	*pData = NULL;

    if (xlist == NULL)
      xlist = hlData;
    
    if (!xlist)
      xlist = Plugin::list_get("dcc");
    
    if (eListStatus) {
      pData = xchat_list_str(hPlugin, xlist, "destfile");
      
      if (!Plugin::list_next(xlist))    
	eListStatus = list_ERROR;
    } else {
      Plugin::list_free(&xlist);
    }
    
    return pData;
  }

  
  // Ritorna la lista dei nomi dei files spediti/ricevuti nelle
  // trasmissioni DCC.
  const char	*list_dcc_file_str(xchat_list *xlist = NULL) {
    const char	*pData = NULL;

    if (xlist == NULL)
      xlist = hlData;
    
    if (!xlist)
      xlist = Plugin::list_get("dcc");
    
    if (eListStatus) {
      pData = xchat_list_str(hPlugin, xlist, "file");
      
      if (!Plugin::list_next(xlist))    
	eListStatus = list_ERROR;
    } else {
      Plugin::list_free(&xlist);
    }
    
    return pData;
  }

  
  // Ritorna la lista dei nick delle trasmissioni DCC.
  const char	*list_dcc_nick_str(xchat_list *xlist = NULL) {
    const char	*pData = NULL;

    if (xlist == NULL)
      xlist = hlData;
    
    if (!xlist)
      xlist = Plugin::list_get("dcc");
    
    if (eListStatus) {
      pData = xchat_list_str(hPlugin, xlist, "nick");
      
      if (!Plugin::list_next(xlist))    
	eListStatus = list_ERROR;
    } else {
      Plugin::list_free(&xlist);
    }
    
    return pData;
  }

  
  // Ritorna la lista delle maschere degli utenti ignorati.
  const char	*list_ignore_mask_str(xchat_list *xlist = NULL) {
    const char	*pData = NULL;

    if (xlist == NULL)
      xlist = hlData;
    
    if (!xlist)
      xlist = Plugin::list_get("ignore");
    
    if (eListStatus) {
      pData = xchat_list_str(hPlugin, xlist, "mask");
      
      if (!Plugin::list_next(xlist))    
	eListStatus = list_ERROR;
    } else {
      Plugin::list_free(&xlist);
    }
    
    return pData;
  }

  
  // Ritorna la lista dei nick degli utenti contenuti nel canale
  // corrente.
  const char	*list_users_nick_str(xchat_list *xlist = NULL) {
    const char	*pData = NULL;

    if (xlist == NULL)
      xlist = hlData;
    
    if (!xlist)
      xlist = Plugin::list_get("users");
    
    if (eListStatus) {
      pData = xchat_list_str(hPlugin, xlist, "nick");
      
      if (!Plugin::list_next(xlist))    
	eListStatus = list_ERROR;
    } else {
      Plugin::list_free(&xlist);
    }
    
    return pData;
  }

  
  // Ritorna la lista degli host degli utenti contenuti nel canale
  // corrente.
  const char	*list_users_host_str(xchat_list *xlist = NULL) {
    const char	*pData = NULL;

    if (xlist == NULL)
      xlist = hlData;
    
    if (!xlist)
      xlist = Plugin::list_get("users");
    
    if (eListStatus) {
      pData = xchat_list_str(hPlugin, xlist, "host");
      
      if (!Plugin::list_next(xlist))    
	eListStatus = list_ERROR;
    } else {
      Plugin::list_free(&xlist);
    }
    
    return pData;
  }

  
  // Ritorna la lista dei prefissi (@, %, +) eventualmente associati
  // agli utenti presenti nel canale corrente.
  const char	*list_users_prefix_str(xchat_list *xlist = NULL) {
    const char	*pData = NULL;

    if (xlist == NULL)
      xlist = hlData;
    
    if (!xlist)
      xlist = Plugin::list_get("users");
    
    if (eListStatus) {
      pData = xchat_list_str(hPlugin, xlist, "prefix");
      
      if (!Plugin::list_next(xlist))    
	eListStatus = list_ERROR;
    } else {
      Plugin::list_free(&xlist);
    }
    
    return pData;
  }

  
  // Ritorna il numero appartenente al campo specificato.
  /*
   * I possibili valori di name sono:
   *
   * type
   * address32
   * cps
   * port
   * pos
   * resume
   * size
   * status
   * type
   * flags
   *
   */
  int		list_int(const char *name, 
			 xchat_list *xlist = NULL) {
    if (xlist == NULL)
      xlist = hlData;

    if (xlist && 
	name && 
	name[0] != '\0') {
      return xchat_list_int(hPlugin, xlist, name);
    }
    
    return 0;
  }

  
  // Ritorna la lista delle tipologie delle sessioni create.
  int		list_channels_type_int(xchat_list *xlist = NULL) {
    int		iData = 0;

    if (xlist == NULL)
      xlist = hlData;
    
    if (!xlist)
      xlist = Plugin::list_get("channel");
    
    if (eListStatus) {
      iData = xchat_list_int(hPlugin, xlist, "type");
      
      if (!Plugin::list_next(xlist))    
	eListStatus = list_ERROR;
    } else {
      Plugin::list_free(&xlist);
    }
    
    return iData;
  }

  
  // Ritorna la lista degli indirizzi ipv4 delle trasmissioni DCC.
  int		list_dcc_address32_int(xchat_list *xlist = NULL) {
    int		iData = 0;

    if (xlist == NULL)
      xlist = hlData;
    
    if (!xlist)
      xlist = Plugin::list_get("dcc");
    
    if (eListStatus) {
      iData = xchat_list_int(hPlugin, xlist, "address32");
      
      if (!Plugin::list_next(xlist))    
	eListStatus = list_ERROR;
    } else {
      Plugin::list_free(&xlist);
    }
    
    return iData;
  }

  
  // Ritorna la lista delle velocita' delle trasmissioni DCC.
  int		list_dcc_cps_int(xchat_list *xlist = NULL) {
    int		iData = 0;

    if (xlist == NULL)
      xlist = hlData;
    
    if (!xlist)
      xlist = Plugin::list_get("dcc");
    
    if (eListStatus) {
      iData = xchat_list_int(hPlugin, xlist, "cps");
      
      if (!Plugin::list_next(xlist))    
	eListStatus = list_ERROR;
    } else {
      Plugin::list_free(&xlist);
    }
    
    return iData;
  }

  
  // Ritorna la lista delle porte usate nelle trasmissioni DCC.
  int		list_dcc_port_int(xchat_list *xlist = NULL) {
    int		iData = 0;

    if (xlist == NULL)
      xlist = hlData;
    
    if (!xlist)
      xlist = Plugin::list_get("dcc");
    
    if (eListStatus) {
      iData = xchat_list_int(hPlugin, xlist, "port");
      
      if (!Plugin::list_next(xlist))    
	eListStatus = list_ERROR;
    } else {
      Plugin::list_free(&xlist);
    }
    
    return iData;
  }

  
  // Ritorna la lista delle posizioni di resume delle trasmissioni
  // DCC.
  int		list_dcc_pos_int(xchat_list *xlist = NULL) {
    int		iData = 0;

    if (xlist == NULL)
      xlist = hlData;
    
    if (!xlist)
      xlist = Plugin::list_get("dcc");
    
    if (eListStatus) {
      iData = xchat_list_int(hPlugin, xlist, "pos");
      
      if (!Plugin::list_next(xlist))    
	eListStatus = list_ERROR;
    } else {
      Plugin::list_free(&xlist);
    }
    
    return iData;
  }

  
  // Ritorna la lista dei resume delle trasmissioni DCC.
  int		list_dcc_resume_int(xchat_list *xlist = NULL) {
    int		iData = 0;

    if (xlist == NULL)
      xlist = hlData;
    
    if (!xlist)
      xlist = Plugin::list_get("dcc");
    
    if (eListStatus) {
      iData = xchat_list_int(hPlugin, xlist, "resume");
      
      if (!Plugin::list_next(xlist))    
	eListStatus = list_ERROR;
    } else {
      Plugin::list_free(&xlist);
    }
    
    return iData;
  }

  
  // Ritorna la lista delle dimensioni delle trasmissioni DCC.
  int		list_dcc_size_int(xchat_list *xlist = NULL) {
    int		iData = 0;

    if (xlist == NULL)
      xlist = hlData;
    
    if (!xlist)
      xlist = Plugin::list_get("dcc");
    
    if (eListStatus) {
      iData = xchat_list_int(hPlugin, xlist, "size");
      
      if (!Plugin::list_next(xlist))    
	eListStatus = list_ERROR;
    } else {
      Plugin::list_free(&xlist);
    }
    
    return iData;
  }

  
  // Ritorna la lista dello stato delle trasmissioni DCC.
  int		list_dcc_status_int(xchat_list *xlist = NULL) {
    int		iData = 0;

    if (xlist == NULL)
      xlist = hlData;
    
    if (!xlist)
      xlist = Plugin::list_get("dcc");
    
    if (eListStatus) {
      iData = xchat_list_int(hPlugin, xlist, "status");
      
      if (!Plugin::list_next(xlist))    
	eListStatus = list_ERROR;
    } else {
      Plugin::list_free(&xlist);
    }
    
    return iData;
  }

  
  // Ritorna la lista delle tipologie delle trasmissioni DCC.
  int		list_dcc_type_int(xchat_list *xlist = NULL) {
    int		iData = 0;

    if (xlist == NULL)
      xlist = hlData;
    
    if (!xlist)
      xlist = Plugin::list_get("dcc");
    
    if (eListStatus) {
      iData = xchat_list_int(hPlugin, xlist, "type");
      
      if (!Plugin::list_next(xlist))    
	eListStatus = list_ERROR;
    } else {
      Plugin::list_free(&xlist);
    }
    
    return iData;
  }

  
  // Ritorna la lista dei flags relativa agli ignore attivi.
  int		list_ignore_flags_int(xchat_list *xlist = NULL) {
    int		iData = 0;

    if (xlist == NULL)
      xlist = hlData;
    
    if (!xlist)
      xlist = Plugin::list_get("ignore");
    
    if (eListStatus) {
      iData = xchat_list_int(hPlugin, xlist, "flags");
      
      if (!Plugin::list_next(xlist))    
	eListStatus = list_ERROR;
    } else {
      Plugin::list_free(&xlist);
    }
    
    return iData;
  }

  
  // Esegue un confronto tra due stringhe (nickname/canale) seguendo
  // le direttive della RFC1459.
  int		nickcmp(const char *s1, const char *s2) {
    int		result = -2;
    char	*s1cpy, *s2cpy;

    if (s1 && s2 && 
	s1[0] != '\0' && s2[0] != '\0') {
      s1cpy = strdup(s1);
      s2cpy = strdup(s2);
      result = xchat_nickcmp(hPlugin, s1cpy, s2cpy);
      free(s1cpy);
      free(s2cpy);
    }
    
    return result;
  }
};


// ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ #endif // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ // End $Source: /home/uda/src/c/buduscript/plugin.h,v $ // UDA'Software 2003 // File: autoop.cpp /* * Questo script di esempio in C++ serve per "oppare" in automatico * gli utenti che entrano nei canali dove e' presente l'utente locale * (il quale, ovviamente, deve essere operatore). * * Si abilita/disabilita digitando il comando: * * /autooptoggle * * alla riga dei comandi di X-Chat 2. * */ /* * Include la libreria C++ per la gestione degli X-Chat Plug-in. * */ #include "plugin.h" /* * Dichiara a livello globale l'Oggetto Plugin. * * L'oggetto ingloba tutte le Proprieta' e le Azioni necessarie per la * gestione di un plug-in. * */ static Plugin PluginObj; /* * Dichiara e inizializza una variabile flag che ha il compito di * determinare se l'AutoOP deve funzionare o meno; per default e' * attivo (1). * */ static int enable = 1; /* * Definisce la funzione cb_Join(), la callback che ha il compito di * "oppare" l'utente avente il nickname contenuto nella seconda * (word[1]) posizione del vettore "word" passato come parametro. * * Questa funzione viene invocata automaticamente ogni volta che un * utente entra in un canale nel quale e' presente l'utente locale. * */ static int cb_Join(char *word[], void *userdata) { // Se l'autoOP e' abilitato ... if (enable) { // ... provvede ad eseguire un comando IRC del tipo: /OP nickname PluginObj.commandf("OP %s", word[1]); /* * word[1] rappresenta il nickname e lo si capisce guardando in * Settings->Lists->EventTexts le variabili associate all'evento * "Join". * */ } /* * Il valore di ritorno della funzione e' molto importante e * determina se X-Chat dovra' invocare eventuali altre callback * coinvolte nell'evento oppure no. * * I valori possibili sono: * * XCHAT_EAT_NONE : Non "mangia" l'evento, quindi lascia che altre * callback possano gestirlo (in genere e' la scelta migliore). * * XCHAT_EAT_ALL : "mangia" l'evento, impedendo a qualsiasi altra * funzione di poterlo gestire (la cosa puo' anche essere * pericolosa, se usata male, perche' impedisce un corretto * funzionamento del client o di altri scripts). * */ return XCHAT_EAT_NONE; } /* * Definisce la funzione cb_AutoOpToggle(), che viene invocata ogni * volta che l'utente lancia il comando: /autooptoggle * */ static int cb_AutoOpToggle(char *word[], char *word_eol[], void *userdata) { if (!enable) { // Se l'autoOP e' disabilitato lo abilita enable = 1; // Comunica all'utente (lo leggera' solo l'utente locale) che e' // stato attivato l'autoop. PluginObj.print("AutoOping now enabled!\n"); } else { // L'autoOP e' abilitato e quindi lo disabilita. enable = 0; PluginObj.print("AutoOping now disabled!\n"); } /* * In questo caso e' giusto "mangiare" l'evento perche' nessun'altro * script deve poter gestire questo comando. * */ return XCHAT_EAT_ALL; } /* * Definisce la funzione di inizializzazione xchat_plugin_init(). * * Si tratta della prima funzione che viene automaticamente invocata * all'atto del caricamento del plug-in da parte del client X-Chat. * * I Parametri passati sono rispettivamente: * * - Un puntatore al plugin in memoria (necessario per la gestione del plug-in stesso). * * - Un riferimento a puntatore che dovra' contenere il Nome del plugin (da configurare nella funzione stessa). * * - Un riferimento a puntatore che dovra' contenere la Descrizione del plugin (da configurare nella funzione stessa). * * - Un riferimento a puntatore che dovra' contenere la Versione del plugin (da configurare nella funzione stessa). * * - Gli argomenti passati ad X-Chat dalla linea di comando. * */ extern "C" { int xchat_plugin_init(xchat_plugin *plugin_handle, char **plugin_name, char **plugin_desc, char **plugin_version, char *arg) { // Configura i parametri base del plugin. *plugin_name = "AutoOp"; *plugin_desc = "Auto Op a chiunque entri nel canale"; *plugin_version = "0.1"; // Inizializza l'Oggetto plugin con i parametri base configurati. PluginObj = Plugin(plugin_handle, (*plugin_name), (*plugin_desc), (*plugin_version), arg); // Aggancia il comando "autooptoggle", in modo che ogni volta che // l'utente lancia suddetto venga eseguita la callback // cb_AutoOpToggle(). PluginObj.hook_command("AutoOpToggle", cb_AutoOpToggle, "Usage: AUTOOPTOGGLE, Turns OFF/ON Auto Oping"); // Aggancia l'Evento "Join" in modo che venga automaticamente // invocata la callback "cb_Join()". PluginObj.hook_print("Join", cb_Join); // Comunica che il plugin e' stato caricato in memoria con // successo. PluginObj.print("AutoOp Plugin loaded successfully!\n"); PluginObj.print("Usage: /AUTOOPTOGGLE"); return 1; /* ritorna 1 per successo */ } }

// UDA'Software 2003 // File: getinfo.cpp /* * Questo script di esempio in C++ serve per mostrare come si * ottengono informazioni generiche sull'attuale sessione. * * Si utilizza digitando il comando: * * /getinfo * * alla riga dei comandi di X-Chat 2. * */ /* * Include la libreria C++ per la gestione degli X-Chat Plug-in. * */ #include "plugin.h" /* * Dichiara a livello globale l'Oggetto Plugin. * * L'oggetto ingloba tutte le Proprieta' e le Azioni necessarie per la * gestione di un plug-in. * */ static Plugin PluginObj; /* * Definisce la funzione cb_GetInfo(), che viene invocata ogni * volta che l'utente lancia il comando: /getinfo * */ static int cb_GetInfo(char *word[], char *word_eol[], void *userdata) { // Le informazioni vengono inviate al canale/dialog corrente. Se non // si e' collegati, verranno emessi altrettanti messaggi di errore. PluginObj.commandf("SAY %%C4X-Chat 2:%%C5 GetInfo Plugin Sample"); PluginObj.commandf("SAY %%C8Data:"); PluginObj.commandf("SAY %%C9Nickname :%%B%20s", PluginObj.get_info_nick()); PluginObj.commandf("SAY %%C9Away :%%B%20s", PluginObj.get_info_away()); PluginObj.commandf("SAY %%C9Server :%%B%20s", PluginObj.get_info_server()); PluginObj.commandf("SAY %%C9Host :%%B%20s", PluginObj.get_info_host()); PluginObj.commandf("SAY %%C9Network :%%B%20s", PluginObj.get_info_network()); PluginObj.commandf("SAY %%C9Channel :%%B%20s", PluginObj.get_info_channel()); PluginObj.commandf("SAY %%C9Topic :%%B%20s", PluginObj.get_info_topic()); PluginObj.commandf("SAY %%C9Version :%%B%20s", PluginObj.get_info_version()); PluginObj.commandf("SAY %%C9X-Chat Dir:%%B%20s", PluginObj.get_info_xchatdir()); /* * In questo caso e' giusto "mangiare" l'evento perche' nessun'altro * script deve poter gestire questo comando. * */ return XCHAT_EAT_ALL; } /* * Definisce la funzione di inizializzazione xchat_plugin_init(). * * Si tratta della prima funzione che viene automaticamente invocata * all'atto del caricamento del plug-in da parte del client X-Chat. * * I Parametri passati sono rispettivamente: * * - Un puntatore al plugin in memoria (necessario per la gestione del plug-in stesso). * * - Un riferimento a puntatore che dovra' contenere il Nome del plugin (da configurare nella funzione stessa). * * - Un riferimento a puntatore che dovra' contenere la Descrizione del plugin (da configurare nella funzione stessa). * * - Un riferimento a puntatore che dovra' contenere la Versione del plugin (da configurare nella funzione stessa). * * - Gli argomenti passati ad X-Chat dalla linea di comando. * */ extern "C" { int xchat_plugin_init(xchat_plugin *plugin_handle, char **plugin_name, char **plugin_desc, char **plugin_version, char *arg) { // Configura i parametri base del plugin. *plugin_name = "GetInfo"; *plugin_desc = "Ottiene informazioni da X-Chat"; *plugin_version = "0.1"; // Inizializza l'Oggetto plugin con i parametri base configurati. PluginObj = Plugin(plugin_handle, (*plugin_name), (*plugin_desc), (*plugin_version), arg); // Aggancia il comando "getinfo", in modo che ogni volta che // l'utente lancia suddetto venga eseguita la callback // cb_GetInfo(). PluginObj.hook_command("GETINFO", cb_GetInfo, "Usage: GETINFO <preference>"); // Comunica che il plugin e' stato caricato in memoria con // successo. PluginObj.print("GetInfo Plugin loaded successfully!\n"); PluginObj.print("Usage: /GETINFO"); return 1; /* ritorna 1 per successo */ } }

// UDA'Software 2003 // File: getprefs.cpp /* * Questo script di esempio in C++ serve per mostrare come si * ottengono informazioni relative al setup di X-Chat 2. * * Si utilizza digitando il comando: * * /getprefs <preference> * * alla riga dei comandi di X-Chat 2, dove <preference> rappresenta la * stringa che identifica ogni singola impostazione del client. La * lista delle parole chiave disponibili si ottiene con il comando * "/set" fornito dal client stesso. * */ /* * Include la libreria C++ per la gestione degli X-Chat Plug-in. * */ #include "plugin.h" /* * Dichiara a livello globale l'Oggetto Plugin. * * L'oggetto ingloba tutte le Proprieta' e le Azioni necessarie per la * gestione di un plug-in. * */ static Plugin PluginObj; /* * Definisce la funzione cb_GetPrefs(), che viene invocata ogni * volta che l'utente lancia il comando: /getprefs * */ static int cb_GetPrefs(char *word[], char *word_eol[], void *userdata) { // Dichiara le due variabili che conterranno i dati ritornati dal // client. const char *psPrefs = 0; int iPrefs = 0; int iTypePrefs = 0; if (word[2][0] == 0) { /* * L'utente non ha specificato quale preferenza desidera ottenere, * quindi, verra' mostrata la lista delle preferenze attuale e * opportuno messaggio di errore. * */ PluginObj.command("SET"); PluginObj.print("\002 Il secondo argomento deve essere la Preferenza !\n"); } else { iTypePrefs = PluginObj.get_prefs(word[2], &psPrefs, &iPrefs); switch (iTypePrefs) { case 0: // Ha ritornato errore PluginObj.print("\002 Il secondo argomento deve essere una Preferenza valida !\n"); break; case 1: // Ha ritornato una stringa PluginObj.printf("--- \0033Variabile\0038 %s\0033 impostata a\0037 %s", word[2], psPrefs); break; case 2: // Ha ritornato un intero PluginObj.printf("--- \0033Variabile\0038 %s\0033 impostata a\0037 %d", word[2], iPrefs); break; case 3: // Ha ritornato un booleano PluginObj.printf("--- \0033Variabile\0038 %s\0033 impostata a\0037 %s", word[2], iPrefs ? "ON" : "OFF"); break; default: PluginObj.print("\002 OOPS, Internal Error !\n"); } } /* * In questo caso e' giusto "mangiare" l'evento perche' nessun'altro * script deve poter gestire questo comando. * */ return XCHAT_EAT_ALL; } /* * Definisce la funzione di inizializzazione xchat_plugin_init(). * * Si tratta della prima funzione che viene automaticamente invocata * all'atto del caricamento del plug-in da parte del client X-Chat. * * I Parametri passati sono rispettivamente: * * - Un puntatore al plugin in memoria (necessario per la gestione del plug-in stesso). * * - Un riferimento a puntatore che dovra' contenere il Nome del plugin (da configurare nella funzione stessa). * * - Un riferimento a puntatore che dovra' contenere la Descrizione del plugin (da configurare nella funzione stessa). * * - Un riferimento a puntatore che dovra' contenere la Versione del plugin (da configurare nella funzione stessa). * * - Gli argomenti passati ad X-Chat dalla linea di comando. * */ extern "C" { int xchat_plugin_init(xchat_plugin *plugin_handle, char **plugin_name, char **plugin_desc, char **plugin_version, char *arg) { // Configura i parametri base del plugin. *plugin_name = "GetPrefs"; *plugin_desc = "Ottiene informazioni sul setup di X-Chat"; *plugin_version = "0.1"; // Inizializza l'Oggetto plugin con i parametri base configurati. PluginObj = Plugin(plugin_handle, (*plugin_name), (*plugin_desc), (*plugin_version), arg); // Aggancia il comando "getprefs", in modo che ogni volta che // l'utente lancia suddetto venga eseguita la callback // cb_Getprefs(). PluginObj.hook_command("GETPREFS", cb_GetPrefs, "Usage: GETPREFS <preference>"); // Comunica che il plugin e' stato caricato in memoria con // successo. PluginObj.print("Getprefs Plugin loaded successfully!\n"); PluginObj.print("Usage: /GETPREFS <preference>"); return 1; /* ritorna 1 per successo */ } }

// UDA'Software 2003 // File: hookprint.cpp /* * Questo script di esempio in C++ serve per mostrare come gestire * tutti gli eventi supportati dal client e come ottenere informazioni * generali da quest'ultimo. * * Si abilita/disabilita digitando il comando: * * /hookprint * * alla riga dei comandi di X-Chat 2. * */ // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ /* * Include la libreria C++ per la gestione degli X-Chat Plug-in. * */ #include "plugin.h" // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ /* * Dichiara a livello globale l'Oggetto Plugin. * * L'oggetto ingloba tutte le Proprieta' e le Azioni necessarie per la * gestione di un plug-in. * */ static Plugin PluginObj; /* * Dichiara e inizializza una variabile flag che ha il compito di * disattivare l'utput del plugin; per default l'output e' attivo (0). * */ short fDisablePrintEvents = 0; // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ /* * Definisce una funzione che viene invocata da tutte le callback che * reagiscono ai vari Eventi agganciati in modo da stampare i dati che * ogni singola callback riceve. * */ void PrintEvents(char *psFunctionName, // Nome della callback, passato da se stessa. char *word[]) { // Dati della callback, passati da se stessa. if (!fDisablePrintEvents) { PluginObj.printf("\0034Function\0033 %s\0034:", psFunctionName); /* * Esegue un ciclo iterativo per tutti gli elementi contenuti nel * vettore, che al massimo possono essere 8; se ce ne sono meno, * interrompe il ciclo. * */ for (unsigned int i = 0; i < 8; i++) { if (word[i] && word[i][0] != '\0') { PluginObj.printf("|_\0034Word[\0036 %d \0034]:\0037 %s", i, word[i]); } else { i = 8; } } } } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ /* * cb_RAWLINE() e' una callback speciale perche' viene invocata per * ogni messaggio che il server IRC spedisce al client. * */ static int cb_RAWLINE(char *word[], char *word_eol[], void *userdata) { unsigned int uiWordCount = 1; if (!fDisablePrintEvents) { PluginObj.printf("\0034Function\0033 %s\0034:", "cb_RAWLINE"); while(word[uiWordCount] && word[uiWordCount][0] != '\0') { ++uiWordCount; } uiWordCount -= 1; PluginObj.printf("|_\0034Word_eol[\0036 %d \0034]:\0037 %s", uiWordCount, word_eol[1]); } return XCHAT_EAT_NONE; /* don't eat this event, xchat needs to see it! */ } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ /* * DA QUI IN POI SONO DEFINITE LE CALLBACK INVOCATE IN BASE AGLI * EVENTI "NORMALI". * */ // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_AddNotify(char *word[], void *userdata) { PrintEvents("cb_AddNotify", word); // $1 added to notify list. // $1 Nickname return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_BanList(char *word[], void *userdata) { PrintEvents("cb_BanList", word); // $1 Banlist: $4 $2 $3 // $1 Channel // $2 Banmask // $3 Who set the ban // $4 Ban time return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_Banned(char *word[], void *userdata) { PrintEvents("cb_Banned", word); // Cannot join $1 (You are banned). // $1 Channel Name return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_ChangeNick(char *word[], void *userdata) { PrintEvents("cb_ChangeNick", word); // $1 is now known as $2 // $1 Old nickname // $2 New nickname return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_ChannelAction(char *word[], void *userdata) { PrintEvents("cb_ChannelAction", word); // *$1 $2 // $1 Nickname // $2 The action return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_ChannelActionHilight(char *word[], void *userdata) { PrintEvents("cb_ChannelActionHilight", word); // *$1 $2 // $1 Nickname // $2 The action return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_ChannelBan(char *word[], void *userdata) { PrintEvents("cb_ChannelBan", word); // $1 sets ban on $2 // $1 The nick of the person who did the banning // $2 The ban mask return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_ChannelCreation(char *word[], void *userdata) { PrintEvents("cb_ChannelCreation", word); // Channel $1 created on $2 // $1 The channel // $2 The time return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_ChannelDeHalfOp(char *word[], void *userdata) { PrintEvents("cb_ChannelDeHalfOp", word); // $1 removes channel half-operator status from $2 // $1 The nick of the person of did the dehalfop'ing // $2 The nick of the person who has been dehalfop'ed return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_ChannelDeOp(char *word[], void *userdata) { PrintEvents("cb_ChannelDeOp", word); // $1 removes channel operator status from $2 // $1 The nick of the person of did the deop'ing // $2 The nick of the person who has been deop'ed return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_ChannelDeVoice(char *word[], void *userdata) { PrintEvents("cb_ChannelDeVoice", word); // $1 removes voice from $2 // $1 The nick of the person of did the devoice'ing // $2 The nick of the person who has been devoice'ed return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_ChannelExempt(char *word[], void *userdata) { PrintEvents("cb_ChannelExempt", word); // $1 sets exempt on $2 // $1 The nick of the person who did the exempt // $2 The exempt mask return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_ChannelHalf_Operator(char *word[], void *userdata) { PrintEvents("cb_ChannelHalf_Operator", word); // $1 gives channel half-operator status to $2 // $1 The nick of the person who has been halfop'ed // $2 The nick of the person who did the halfop'ing return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_ChannelINVITE(char *word[], void *userdata) { PrintEvents("cb_ChannelINVITE", word); // $1 sets invite on $2 // $1 The nick of the person who did the invite // $2 The invite mask return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_ChannelList(char *word[], void *userdata) { PrintEvents("cb_ChannelList", word); // Channel Users Topic return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_ChannelMessage(char *word[], void *userdata) { PrintEvents("cb_ChannelMessage", word); // <$1>$2 // $1 Nickname // $2 The text // $3 Mode char return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_ChannelModeGeneric(char *word[], void *userdata) { PrintEvents("cb_ChannelModeGeneric", word); // $1 sets mode $2$3 $4 // $1 The nick of the person setting the mode // $2 The mode's sign (+/-) // $3 The mode letter // $4 The channel it's being set on return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_ChannelModes(char *word[], void *userdata) { PrintEvents("cb_ChannelModes", word); // Channel $1 modes: $2 // $1 Channel name // $2 Modes string return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_ChannelMsgHilight(char *word[], void *userdata) { PrintEvents("cb_ChannelMsgHilight", word); // <$1>$2 return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_ChannelNotice(char *word[], void *userdata) { PrintEvents("cb_ChannelNotice", word); // -$1/$2-$3 // $1 Who it's from // $2 The Channel it's going to // $3 The message return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_ChannelOperator(char *word[], void *userdata) { PrintEvents("cb_ChannelOperator", word); // $1 gives channel operator status to $2 // $1 The nick of the person who did the op'ing // $2 The nick of the person who has been op'ed return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_ChannelRemoveExempt(char *word[], void *userdata) { PrintEvents("cb_ChannelRemoveExempt", word); // $1 removes exempt on $2 // $1 The nick of the person removed the exempt // $2 The exempt mask return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_ChannelRemoveInvite(char *word[], void *userdata) { PrintEvents("cb_ChannelRemoveInvite", word); // $1 removes invite on $2 // $1 The nick of the person removed the invite // $2 The invite mask return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_ChannelRemoveKeyword(char *word[], void *userdata) { PrintEvents("cb_ChannelRemoveKeyword", word); // $1 removes user limit // $1 The nick who removed the key return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_ChannelRemoveLimit(char *word[], void *userdata) { PrintEvents("cb_ChannelRemoveLimit", word); // $1 sets channel keyword to $2 // $1 The nick who removed the limit return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_ChannelSetKey(char *word[], void *userdata) { PrintEvents("cb_ChannelSetKey", word); // $1 sets channel limit to $2 // $1 The nick of the person who set the key // $2 The key return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_ChannelSetLimit(char *word[], void *userdata) { PrintEvents("cb_ChannelSetLimit", word); // $1 sets channel limit to $2 // $1 The nick of the person who set the limit // $2 The limit return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_ChannelUnBan(char *word[], void *userdata) { PrintEvents("cb_ChannelUnBan", word); // $1 removes ban on $2 // $1 The nick of the person of did the unban'ing // $2 The ban mask return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_ChannelVoice(char *word[], void *userdata) { PrintEvents("cb_ChannelVoice", word); // $1 gives voice to $2 // $1 The nick of the person who did the voice'ing // $2 The nick of the person who has been voice'ed return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_Connected(char *word[], void *userdata) { PrintEvents("cb_Connected", word); // Connected. Now logging in.. return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_Connecting(char *word[], void *userdata) { PrintEvents("cb_Connecting", word); // Connecting to $1 ($2) port $3.. // $1 Host // $2 IP // $3 Port return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_ConnectionFailed(char *word[], void *userdata) { PrintEvents("cb_ConnectionFailed", word); // Connection failed. Error: $1 // $1 Error String return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_CTCPGeneric(char *word[], void *userdata) { PrintEvents("cb_CTCPGeneric", word); // Received a CTCP $1 from $2 // $1 The CTCP event // $2 The nick of the person return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_CTCPGenerictoChannel(char *word[], void *userdata) { PrintEvents("cb_CTCPGenerictoChannel", word); // Received a CTCP $1 from $2 (to $3) // $1 The CTCP event // $2 The nick of the person // $3 The Channel it's going to return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_CTCPSend(char *word[], void *userdata) { PrintEvents("cb_CTCPSend", word); // >$1<CTCP $2 // $1 Receiver // $2 Message return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_CTCPSound(char *word[], void *userdata) { PrintEvents("cb_CTCPSound", word); // Received a CTCP Sound $1 from $2 // $1 The sound // $2 The nick of the person return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_DCCCHATAbort(char *word[], void *userdata) { PrintEvents("cb_DCCCHATAbort", word); // DCC CHAT to $1 aborted. // $1 Nickname return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_DCCCHATConnect(char *word[], void *userdata) { PrintEvents("cb_DCCCHATConnect", word); // DCC CHAT connection established to $1 [$2] // $1 Nickname // $2 IP address return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_DCCCHATFailed(char *word[], void *userdata) { PrintEvents("cb_DCCCHATFailed", word); // DCC CHAT to $1 lost. $4. // $1 Nickname // $2 IP address // $3 Port // $4 Error name return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_DCCCHATOffer(char *word[], void *userdata) { PrintEvents("cb_DCCCHATOffer", word); // Received a DCC CHAT offer from $1 // $1 Nickname return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_DCCCHATOffering(char *word[], void *userdata) { PrintEvents("cb_DCCCHATOffering", word); // Offering DCC CHAT to $1 // $1 Nickname return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_DCCCHATReoffer(char *word[], void *userdata) { PrintEvents("cb_DCCCHATReoffer", word); // Already offering CHAT to $1 // $1 Nickname return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_DCCConectionFailed(char *word[], void *userdata) { PrintEvents("cb_DCCConectionFailed", word); // DCC $1 connect attempt to $2 failed (err=$3). // $1 DCC Type // $2 Nickname // $3 Error string return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_DCCGenericOffer(char *word[], void *userdata) { PrintEvents("cb_DCCGenericOffer", word); // Received '$1' from $2 // $1 DCC String // $2 Nickname return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_DCCHeader(char *word[], void *userdata) { PrintEvents("cb_DCCHeader", word); // Type To/From Status Size Pos File ---------------------------------------------------- return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_DCCMalformed(char *word[], void *userdata) { PrintEvents("cb_DCCMalformed", word); // Received a malformed DCC request from $1.Contents of packet: $2 // $1 Nickname // $2 The Packet return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_DCCOffer(char *word[], void *userdata) { PrintEvents("cb_DCCOffer", word); // Offering $1 to $2 // $1 Filename // $2 Nickname // $3 Pathname return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_DCCOfferNotValid(char *word[], void *userdata) { PrintEvents("cb_DCCOfferNotValid", word); // No such DCC offer. return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_DCCRECVAbort(char *word[], void *userdata) { PrintEvents("cb_DCCRECVAbort", word); // DCC RECV $2 to $1 aborted. // $1 Nickname // $2 Filename return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_DCCRECVComplete(char *word[], void *userdata) { PrintEvents("cb_DCCRECVComplete", word); // DCC RECV $1 from $3 complete [$4 cps]. // $1 Filename // $2 Destination filename // $3 Nickname // $4 CPS return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_DCCRECVConnect(char *word[], void *userdata) { PrintEvents("cb_DCCRECVConnect", word); // DCC RECV connection established to $1 [$2] // $1 Nickname // $2 IP address // $3 Filename return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_DCCRECVFailed(char *word[], void *userdata) { PrintEvents("cb_DCCRECVFailed", word); // DCC RECV $1 from $3 failed. $4. // $1 Filename // $2 Destination filename // $3 Nickname // $4 Error name return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_DCCRECVFileOpenError(char *word[], void *userdata) { PrintEvents("cb_DCCRECVFileOpenError", word); // DCC RECV: Cannot open $1 for writing - aborting. // $1 Filename return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_DCCRename(char *word[], void *userdata) { PrintEvents("cb_DCCRename", word); // The file $1 already exists, saving it as $2 instead. // $1 Old Filename // $2 New Filename return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_DCCRESUMERequest(char *word[], void *userdata) { PrintEvents("cb_DCCRESUMERequest", word); // $1 has requested to resume $2 from $3. // $1 Nickname // $2 Filename // $3 Position return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_DCCSENDAbort(char *word[], void *userdata) { PrintEvents("cb_DCCSENDAbort", word); // DCC SEND $2 to $1 aborted. return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_DCCSENDComplete(char *word[], void *userdata) { PrintEvents("cb_DCCSENDComplete", word); // DCC SEND $1 to $2 complete [$3 cps]. // $1 Filename // $2 Nickname // $3 CPS return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_DCCSENDConnect(char *word[], void *userdata) { PrintEvents("cb_DCCSENDConnect", word); // DCC SEND connection established to $1 [$2] return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_DCCSENDFailed(char *word[], void *userdata) { PrintEvents("cb_DCCSENDFailed", word); // DCC SEND $1 to $2 failed. $3 // $1 Filename // $2 Nickname // $3 Error name return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_DCCSENDOffer(char *word[], void *userdata) { PrintEvents("cb_DCCSENDOffer", word); // $1 has offered $2 ($3 bytes) // $1 Nickname // $2 Filename // $3 Size // $4 IP address return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_DCCStall(char *word[], void *userdata) { PrintEvents("cb_DCCStall", word); // DCC $1 $2 to $3 stalled - aborting. // $1 DCC Type // $2 Filename // $3 Nickname return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_DCCTimeout(char *word[], void *userdata) { PrintEvents("cb_DCCTimeout", word); // DCC $1 $2 to $3 timed out - aborting. return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_DeleteNotify(char *word[], void *userdata) { PrintEvents("cb_DeleteNotify", word); // $1 deleted from notify list. return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_Disconnected(char *word[], void *userdata) { PrintEvents("cb_Disconnected", word); // Disconnected ($1). // $1 Error return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_FoundIP(char *word[], void *userdata) { PrintEvents("cb_FoundIP", word); // Found your IP: [$1] // $1 IP return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_IgnoreAdd(char *word[], void *userdata) { PrintEvents("cb_IgnoreAdd", word); // $1 added to ignore list. // $1 Hostmask return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_IgnoreChanged(char *word[], void *userdata) { PrintEvents("cb_IgnoreChanged", word); // Ignore on $1 changed. return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_IgnoreFooter(char *word[], void *userdata) { PrintEvents("cb_IgnoreFooter", word); return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_IgnoreHeader(char *word[], void *userdata) { PrintEvents("cb_IgnoreHeader", word); // Hostmask PRIV NOTI CHAN CTCP INVI UNIG return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_IgnoreRemove(char *word[], void *userdata) { PrintEvents("cb_IgnoreRemove", word); // $1 removed from ignore list. // $1 Hostmask return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_IgnorelistEmpty(char *word[], void *userdata) { PrintEvents("cb_IgnorelistEmpty", word); // Ignore list is empty. return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_Invite(char *word[], void *userdata) { PrintEvents("cb_Invite", word); // Cannot join $1 (Channel is invite only). return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_Invited(char *word[], void *userdata) { PrintEvents("cb_Invited", word); // You have been invited to $1 by $2 ($3) // $1 Channel Name // $2 Nick of person who invited you // $3 Server Name return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_Join(char *word[], void *userdata) { PrintEvents("cb_Join", word); // $1 ($3) has joined $2 // $1 The nick of the joining person // $2 The channel being joined // $3 The host of the person return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_Keyword(char *word[], void *userdata) { PrintEvents("cb_Keyword", word); // Cannot join $1 (Requires keyword). // $1 Channel Name return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_Kick(char *word[], void *userdata) { PrintEvents("cb_Kick", word); // <--$1 has kicked $2 from $3 ($4) // $1 The nickname of the kicker // $2 The person being kicked // $3 The channel // $4 The reason return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_Killed(char *word[], void *userdata) { PrintEvents("cb_Killed", word); // You have been killed by $1 ($2) // $1 Nickname // $2 Reason return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_MessageSend(char *word[], void *userdata) { PrintEvents("cb_MessageSend", word); // >$1<$2 return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_Motd(char *word[], void *userdata) { PrintEvents("cb_Motd", word); // $1 return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_MOTDSkipped(char *word[], void *userdata) { PrintEvents("cb_MOTDSkipped", word); // MOTD Skipped. return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_NickClash(char *word[], void *userdata) { PrintEvents("cb_NickClash", word); // $1 already in use. Retrying with $2.. // $1 Nickname in use // $2 Nick being tried return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_NickFailed(char *word[], void *userdata) { PrintEvents("cb_NickFailed", word); // Nickname already in use. Use /NICK to try another. return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_NoDCC(char *word[], void *userdata) { PrintEvents("cb_NoDCC", word); // No such DCC. return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_NoRunningProcess(char *word[], void *userdata) { PrintEvents("cb_NoRunningProcess", word); // No process is currently running return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_Notice(char *word[], void *userdata) { PrintEvents("cb_Notice", word); // -$1-$2 // $1 Who it's from // $2 The message return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_NoticeSend(char *word[], void *userdata) { PrintEvents("cb_NoticeSend", word); // >$1<$2 return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_NotifyEmpty(char *word[], void *userdata) { PrintEvents("cb_NotifyEmpty", word); // Notify list is empty. return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_NotifyHeader(char *word[], void *userdata) { PrintEvents("cb_NotifyHeader", word); // -- Notify List --------------- return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_NotifyNumber(char *word[], void *userdata) { PrintEvents("cb_NotifyNumber", word); // $1 users in notify list. // $1 Number of notify items return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_NotifyOffline(char *word[], void *userdata) { PrintEvents("cb_NotifyOffline", word); // Notify: $1 is offline ($2). // $1 Nickname // $2 Channel name return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_NotifyOnline(char *word[], void *userdata) { PrintEvents("cb_NotifyOnline", word); // Notify: $1 is online ($2). // $1 Nickname // $2 Channel name return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_Part(char *word[], void *userdata) { PrintEvents("cb_Part", word); // <--$1 ($2) has left $3 // $1 The nick of the person leaving // $2 The host of the person // $3 The channel return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_PartwithReason(char *word[], void *userdata) { PrintEvents("cb_PartwithReason", word); // <--$1 ($2) has left $3 ($4) // $1 The nick of the person leaving // $2 The host of the person // $3 The channel // $4 The reason return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_PingReply(char *word[], void *userdata) { PrintEvents("cb_PingReply", word); // Ping reply from $1 : $2 second(s) // $1 Who it's from // $2 The time in x.x format (see below) return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_PingTimeout(char *word[], void *userdata) { PrintEvents("cb_PingTimeout", word); // No ping reply for $1 seconds, disconnecting. // $1 Seconds return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_PrivateMessage(char *word[], void *userdata) { PrintEvents("cb_PrivateMessage", word); // *$1*$2 // $1 Nickname // $2 The message return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_PrivateMessagetoDialog(char *word[], void *userdata) { PrintEvents("cb_PrivateMessagetoDialog", word); // <$1>$2 // $1 Nickname // $2 The message return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_ProcessAlreadyRunning(char *word[], void *userdata) { PrintEvents("cb_ProcessAlreadyRunning", word); // A process is already running return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_Quit(char *word[], void *userdata) { PrintEvents("cb_Quit", word); // <--$1 has quit ($2) // $1 Nick // $2 Reason // $3 Host return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_RawModes(char *word[], void *userdata) { PrintEvents("cb_RawModes", word); // $1 sets modes [$2] // $1 Nickname // $2 Modes string return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_ReceiveWallops(char *word[], void *userdata) { PrintEvents("cb_ReceiveWallops", word); // -$1/Wallops-$2 // $1 Nickname // $2 The message return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_ResolvingUser(char *word[], void *userdata) { PrintEvents("cb_ResolvingUser", word); // Looking up IP number for $1.. // $1 Nickname // $2 Hostname return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_ServerConnected(char *word[], void *userdata) { PrintEvents("cb_ServerConnected", word); // Connected. return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_ServerError(char *word[], void *userdata) { PrintEvents("cb_ServerError", word); // $1 // $1 Text return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_ServerLookup(char *word[], void *userdata) { PrintEvents("cb_ServerLookup", word); // Looking up $1.. // $1 Servername return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_ServerNotice(char *word[], void *userdata) { PrintEvents("cb_ServerNotice", word); // $1 // $1 Text // $2 Server Name return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_ServerText(char *word[], void *userdata) { PrintEvents("cb_ServerText", word); // $1 // $1 Text // $2 Server Name return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_StopConnection(char *word[], void *userdata) { PrintEvents("cb_StopConnection", word); // Stopped previous connection attempt (pid=$1) // $1 PID return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_Topic(char *word[], void *userdata) { PrintEvents("cb_Topic", word); // Topic for $1 is $2 // $1 Channel // $2 Topic return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_TopicCreation(char *word[], void *userdata) { PrintEvents("cb_TopicCreation", word); // Topic for $1 set by $2 at $3 // $1 The channel // $2 The creator // $3 The time return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_TopicChange(char *word[], void *userdata) { PrintEvents("cb_TopicChange", word); // $1 has changed the topic to: $2 // $1 Nick of person who changed the topic // $2 Topic // $3 Channel return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_UnknownHost(char *word[], void *userdata) { PrintEvents("cb_UnknownHost", word); // Unknown host. Maybe you misspelled it? return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_UserLimit(char *word[], void *userdata) { PrintEvents("cb_UserLimit", word); // Cannot join $1 (User limit reached). // $1 Channel Name return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_UsersOnChannel(char *word[], void *userdata) { PrintEvents("cb_UsersOnChannel", word); // Users on $1: $2 // $1 Channel Name // $2 Users return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_WhoIsAwayLine(char *word[], void *userdata) { PrintEvents("cb_WhoIsAwayLine", word); // [$1] is away ($2) // $1 Nickname // $2 Away reason return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_WhoIsChannel_OperLine(char *word[], void *userdata) { PrintEvents("cb_WhoIsChannel_OperLine", word); // [$1] $2 // $1 Nickname // $2 Channel Membership/\"is an IRC operator\" return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_WhoIsEnd(char *word[], void *userdata) { PrintEvents("cb_WhoIsEnd", word); // [$1] End of WHOIS list. // $1 Nickname return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_WhoIsIdleLine(char *word[], void *userdata) { PrintEvents("cb_WhoIsIdleLine", word); // [$1] idle $2 // $1 Nickname // $2 Idle time return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_WhoIsIdleLinewithSignon(char *word[], void *userdata) { PrintEvents("cb_WhoIsIdleLinewithSignon", word); // [$1] idle $2, signon: $3 // $1 Nickname // $2 Idle time // $3 Signon time return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_WhoIsNameLine(char *word[], void *userdata) { PrintEvents("cb_WhoIsNameLine", word); // [$1] ($2@$3) : $4 // $1 Nickname // $2 Username // $3 Host // $4 Full name return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_WhoIsServerLine(char *word[], void *userdata) { PrintEvents("cb_WhoIsServerLine", word); // [$1] $2 // $1 Nickname // $2 Server Information return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_YouJoin(char *word[], void *userdata) { PrintEvents("cb_YouJoin", word); // -->You are now talking on $2 // $1 The nick of the joining person // $2 The channel being joined // $3 The host of the person return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_YouPart(char *word[], void *userdata) { PrintEvents("cb_YouPart", word); // You have left channel $3 // $1 The nick of the person leaving // $2 The host of the person // $3 The channel return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_YouPartwithReason(char *word[], void *userdata) { PrintEvents("cb_YouPartwithReason", word); // You have left channel $3 ($4) // $1 The nick of the person leaving // $2 The host of the person // $3 The channel // $4 The reason return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_YouKicked(char *word[], void *userdata) { PrintEvents("cb_YouKicked", word); // You have been kicked from $2 by $3 ($4) // $1 The person being kicked // $2 The channel // $3 The nickname of the kicker // $4 The reason return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_YourInvitation(char *word[], void *userdata) { PrintEvents("cb_YourInvitation", word); // You're inviting $1 to $2 ($3) // $1 Nick of person who have been invited // $2 Channel Name // $3 Server Name return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_YourMessage(char *word[], void *userdata) { PrintEvents("cb_YourMessage", word); // <$1>$2 // $1 Nickname // $2 The text // $3 Mode char return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_YourNickChanging(char *word[], void *userdata) { PrintEvents("cb_YourNickChanging", word); // You are now known as $2 // $1 Old nickname // $2 New nickname return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_OpenContext(char *word[], void *userdata) { PrintEvents("cb_OpenContext", word); return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_CloseContext(char *word[], void *userdata) { //PrintEvents("cb_CloseContext", word); /* * Di questo evento non e' possibile fare il "print", pena il crash * del client. E' tuttavia possibile gestirlo. * */ return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_FocusTab(char *word[], void *userdata) { PrintEvents("cb_FocusTab", word); return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_FocusWindow(char *word[], void *userdata) { PrintEvents("cb_FocusWindow", word); return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ static int cb_DCCChatText(char *word[], void *userdata) { PrintEvents("cb_DCCChatText", word); // $1 Address // $2 Port // $3 Nick // $4 The Message return XCHAT_EAT_NONE; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ /* * Definisce la funzione cb_HookPrint(), che viene invocata ogni * volta che l'utente lancia il comando: /hookprint * */ static int cb_HookPrint(char *word[], char *word_eol[], void *userdata) { if (fDisablePrintEvents) { PluginObj.print("---\002 Hook Print: \003Enabled\017."); fDisablePrintEvents = 0; } else { PluginObj.print("---\002 Hook Print: \002Disabled\017."); fDisablePrintEvents = 1; } return XCHAT_EAT_ALL; } // ////////////////////////////////////////////////////////////////////////////////////////////////////////// //___________________________________________________________________________________________________________ /* * Definisce la funzione di inizializzazione xchat_plugin_init(). * * Si tratta della prima funzione che viene automaticamente invocata * all'atto del caricamento del plug-in da parte del client X-Chat. * * I Parametri passati sono rispettivamente: * * - Un puntatore al plugin in memoria (necessario per la gestione del plug-in stesso). * * - Un riferimento a puntatore che dovra' contenere il Nome del plugin (da configurare nella funzione stessa). * * - Un riferimento a puntatore che dovra' contenere la Descrizione del plugin (da configurare nella funzione stessa). * * - Un riferimento a puntatore che dovra' contenere la Versione del plugin (da configurare nella funzione stessa). * * - Gli argomenti passati ad X-Chat dalla linea di comando. * */ extern "C" { int xchat_plugin_init(xchat_plugin *plugin_handle, char **plugin_name, char **plugin_desc, char **plugin_version, char *arg) { // Configura i parametri base del plugin. *plugin_name = "HookPrint"; *plugin_desc = "Stampa il contenuto dei dati ricevuti da ogni singolo evento gestito."; *plugin_version = "0.1"; // Inizializza l'Oggetto plugin con i parametri base configurati. PluginObj = Plugin(plugin_handle, (*plugin_name), (*plugin_desc), (*plugin_version), arg); // Aggancia l'evento "RAW LINE". Ogni messaggio proveniente dal // server IRC verra spedito alla callback cb_RAWLINE(). PluginObj.hook_server("RAW LINE", cb_RAWLINE); /* * Qui vengono agganciati tutti glie eventi gestiti dal client, * che sono anche contenuti nella lista ottenibile dalla finestra: * Settings->Lists->Text Events... * */ PluginObj.hook_print("Add Notify", cb_AddNotify); PluginObj.hook_print("Ban List", cb_BanList); PluginObj.hook_print("Banned", cb_Banned); PluginObj.hook_print("Change Nick", cb_ChangeNick); PluginObj.hook_print("Channel Action", cb_ChannelAction); PluginObj.hook_print("Channel Action Hilight", cb_ChannelActionHilight); PluginObj.hook_print("Channel Ban", cb_ChannelBan); PluginObj.hook_print("Channel Creation", cb_ChannelCreation); PluginObj.hook_print("Channel DeHalfOp", cb_ChannelDeHalfOp); PluginObj.hook_print("Channel DeOp", cb_ChannelDeOp); PluginObj.hook_print("Channel DeVoice", cb_ChannelDeVoice); PluginObj.hook_print("Channel Exempt", cb_ChannelExempt); PluginObj.hook_print("Channel Half-Operator", cb_ChannelHalf_Operator); PluginObj.hook_print("Channel INVITE", cb_ChannelINVITE); PluginObj.hook_print("Channel List", cb_ChannelList); PluginObj.hook_print("Channel Message", cb_ChannelMessage); PluginObj.hook_print("Channel Mode Generic", cb_ChannelModeGeneric); PluginObj.hook_print("Channel Modes", cb_ChannelModes); PluginObj.hook_print("Channel Msg Hilight", cb_ChannelMsgHilight); PluginObj.hook_print("Channel Notice", cb_ChannelNotice); PluginObj.hook_print("Channel Operator", cb_ChannelOperator); PluginObj.hook_print("Channel Remove Exempt", cb_ChannelRemoveExempt); PluginObj.hook_print("Channel Remove Invite", cb_ChannelRemoveInvite); PluginObj.hook_print("Channel Remove Keyword", cb_ChannelRemoveKeyword); PluginObj.hook_print("Channel Remove Limit", cb_ChannelRemoveLimit); PluginObj.hook_print("Channel Set Key", cb_ChannelSetKey); PluginObj.hook_print("Channel Set Limit", cb_ChannelSetLimit); PluginObj.hook_print("Channel UnBan", cb_ChannelUnBan); PluginObj.hook_print("Channel Voice", cb_ChannelVoice); PluginObj.hook_print("Connected", cb_Connected); PluginObj.hook_print("Connecting", cb_Connecting); PluginObj.hook_print("Connection Failed", cb_ConnectionFailed); PluginObj.hook_print("CTCP Generic", cb_CTCPGeneric); PluginObj.hook_print("CTCP Generic to Channel", cb_CTCPGenerictoChannel); PluginObj.hook_print("CTCP Send", cb_CTCPSend); PluginObj.hook_print("CTCP Sound", cb_CTCPSound); PluginObj.hook_print("DCC CHAT Abort", cb_DCCCHATAbort); PluginObj.hook_print("DCC CHAT Connect", cb_DCCCHATConnect); PluginObj.hook_print("DCC CHAT Failed", cb_DCCCHATFailed); PluginObj.hook_print("DCC CHAT Offer", cb_DCCCHATOffer); PluginObj.hook_print("DCC CHAT Offering", cb_DCCCHATOffering); PluginObj.hook_print("DCC CHAT Reoffer", cb_DCCCHATReoffer); PluginObj.hook_print("DCC Conection Failed", cb_DCCConectionFailed); PluginObj.hook_print("DCC Generic Offer", cb_DCCGenericOffer); PluginObj.hook_print("DCC Header", cb_DCCHeader); PluginObj.hook_print("DCC Malformed", cb_DCCMalformed); PluginObj.hook_print("DCC Offer", cb_DCCOffer); PluginObj.hook_print("DCC Offer Not Valid", cb_DCCOfferNotValid); PluginObj.hook_print("DCC RECV Abort", cb_DCCRECVAbort); PluginObj.hook_print("DCC RECV Complete", cb_DCCRECVComplete); PluginObj.hook_print("DCC RECV Connect", cb_DCCRECVConnect); PluginObj.hook_print("DCC RECV Failed", cb_DCCRECVFailed); PluginObj.hook_print("DCC RECV File Open Error", cb_DCCRECVFileOpenError); PluginObj.hook_print("DCC Rename", cb_DCCRename); PluginObj.hook_print("DCC RESUME Request", cb_DCCRESUMERequest); PluginObj.hook_print("DCC SEND Abort", cb_DCCSENDAbort); PluginObj.hook_print("DCC SEND Complete", cb_DCCSENDComplete); PluginObj.hook_print("DCC SEND Connect", cb_DCCSENDConnect); PluginObj.hook_print("DCC SEND Failed", cb_DCCSENDFailed); PluginObj.hook_print("DCC SEND Offer", cb_DCCSENDOffer); PluginObj.hook_print("DCC Stall", cb_DCCStall); PluginObj.hook_print("DCC Timeout", cb_DCCTimeout); PluginObj.hook_print("Delete Notify", cb_DeleteNotify); PluginObj.hook_print("Disconnected", cb_Disconnected); PluginObj.hook_print("Found IP", cb_FoundIP); PluginObj.hook_print("Ignore Add", cb_IgnoreAdd); PluginObj.hook_print("Ignore Changed", cb_IgnoreChanged); PluginObj.hook_print("Ignore Footer", cb_IgnoreFooter); PluginObj.hook_print("Ignore Header", cb_IgnoreHeader); PluginObj.hook_print("Ignore Remove", cb_IgnoreRemove); PluginObj.hook_print("Ignorelist Empty", cb_IgnorelistEmpty); PluginObj.hook_print("Invite", cb_Invite); PluginObj.hook_print("Invited", cb_Invited); PluginObj.hook_print("Join", cb_Join); PluginObj.hook_print("Keyword", cb_Keyword); PluginObj.hook_print("Kick", cb_Kick); PluginObj.hook_print("Killed", cb_Killed); PluginObj.hook_print("Message Send", cb_MessageSend); PluginObj.hook_print("Motd", cb_Motd); PluginObj.hook_print("MOTD Skipped", cb_MOTDSkipped); PluginObj.hook_print("Nick Clash", cb_NickClash); PluginObj.hook_print("Nick Failed", cb_NickFailed); PluginObj.hook_print("No DCC", cb_NoDCC); PluginObj.hook_print("No Running Process", cb_NoRunningProcess); PluginObj.hook_print("Notice", cb_Notice); PluginObj.hook_print("Notice Send", cb_NoticeSend); PluginObj.hook_print("Notify Empty", cb_NotifyEmpty); PluginObj.hook_print("Notify Header", cb_NotifyHeader); PluginObj.hook_print("Notify Number", cb_NotifyNumber); PluginObj.hook_print("Notify Offline", cb_NotifyOffline); PluginObj.hook_print("Notify Online", cb_NotifyOnline); PluginObj.hook_print("Part", cb_Part); PluginObj.hook_print("Part with Reason", cb_PartwithReason); PluginObj.hook_print("Ping Reply", cb_PingReply); PluginObj.hook_print("Ping Timeout", cb_PingTimeout); PluginObj.hook_print("Private Message", cb_PrivateMessage); PluginObj.hook_print("Private Message to Dialog", cb_PrivateMessagetoDialog); PluginObj.hook_print("Process Already Running", cb_ProcessAlreadyRunning); PluginObj.hook_print("Quit", cb_Quit); PluginObj.hook_print("Raw Modes", cb_RawModes); PluginObj.hook_print("Receive Wallops", cb_ReceiveWallops); PluginObj.hook_print("Resolving User", cb_ResolvingUser); PluginObj.hook_print("Server Connected", cb_ServerConnected); PluginObj.hook_print("Server Error", cb_ServerError); PluginObj.hook_print("Server Lookup", cb_ServerLookup); PluginObj.hook_print("Server Notice", cb_ServerNotice); PluginObj.hook_print("Server Text", cb_ServerText); PluginObj.hook_print("Stop Connection", cb_StopConnection); PluginObj.hook_print("Topic", cb_Topic); PluginObj.hook_print("Topic Creation", cb_TopicCreation); PluginObj.hook_print("Topic Change", cb_TopicChange); PluginObj.hook_print("Unknown Host", cb_UnknownHost); PluginObj.hook_print("User Limit", cb_UserLimit); PluginObj.hook_print("Users On Channel", cb_UsersOnChannel); PluginObj.hook_print("WhoIs Away Line", cb_WhoIsAwayLine); PluginObj.hook_print("WhoIs Channel/Oper Line", cb_WhoIsChannel_OperLine); PluginObj.hook_print("WhoIs End", cb_WhoIsEnd); PluginObj.hook_print("WhoIs Idle Line", cb_WhoIsIdleLine); PluginObj.hook_print("WhoIs Idle Line with Signon", cb_WhoIsIdleLinewithSignon); PluginObj.hook_print("WhoIs Name Line", cb_WhoIsNameLine); PluginObj.hook_print("WhoIs Server Line", cb_WhoIsServerLine); PluginObj.hook_print("You Join", cb_YouJoin); PluginObj.hook_print("You Part", cb_YouPart); PluginObj.hook_print("You Part with Reason", cb_YouPartwithReason); PluginObj.hook_print("You Kicked", cb_YouKicked); PluginObj.hook_print("Your Invitation", cb_YourInvitation); PluginObj.hook_print("Your Message", cb_YourMessage); PluginObj.hook_print("Your Nick Changing", cb_YourNickChanging); /* * Aggancia gli eventi "Speciali" * */ PluginObj.hook_print("Open Context", cb_OpenContext); PluginObj.hook_print("Close Context", cb_CloseContext); PluginObj.hook_print("Focus Tab", cb_FocusTab); PluginObj.hook_print("Focus Window", cb_FocusWindow); PluginObj.hook_print("DCC Chat Text", cb_DCCChatText); /* * Aggancia i comandi del plug-in * */ PluginObj.hook_command("HOOKPRINT", cb_HookPrint, "Usage: HOOKPRINT, Turns OFF/ON Hook Print"); /* * Comunica il caricamento del plug-in e quali comandi sono stati * aggiunti. * */ PluginObj.print("HookPrint Plugin loaded successfully !\n"); PluginObj.printf("%s", "Command %BHOOKPRINT%O added.\n"); return 1; /* ritorna 1 per successo */ } /* * Definisce la funzione di de-inizializzazione del plug-in. Viene * invocata ogni volta che il modulo viene scaricato dalla memoria. * */ int xchat_plugin_deinit(xchat_plugin *plugin_handle) { PluginObj.print("Hook-plugin unloaded successfully !\n"); return 1; /* ritorna 1 per successo */ } }

// UDA'Software 2003 // File: listdata.cpp /* * Questo script di esempio in C++ serve per ottenere informazioni * dalla sessione corrente; in particolare, vengono mostrati i vari * metodi per accedere alle "Liste" dell'interfaccia Plugin. * * Si ottiene l'output digitando il comando: * * /listdata * * alla riga dei comandi di X-Chat 2. * */ /* * Include la libreria C++ per la gestione degli X-Chat Plug-in. * */ #include "plugin.h" /* * Dichiara a livello globale l'Oggetto Plugin. * * L'oggetto ingloba tutte le Proprieta' e le Azioni necessarie per la * gestione di un plug-in. * */ static Plugin PluginObj; /* * Definisce la funzione cb_ListData(), che viene invocata ogni * volta che l'utente lancia il comando: /listdata * */ static int cb_ListData(char *word[], char *word_eol[], void *userdata) { /* * Esegue un ciclo iterativo che ha il compito di listare tutte le * sessioni attualmente attive. (Ogni sessione rappresenta una Tab * di X-Chat). * * Per fare questo viene utilizzata l'azione * list_channels_channel_str() ("_str" identifica che ritorna un * puntatore stringa) che ha la facolta' di fare piu' cose * contemporaneamente, ovvero: * * o) La prima volta che viene invocata crea la lista delle sessioni * (channels) e punta al primo elemento della lista, ritornandolo. * * o) La seconda volta che viene invocata, punta all'elemento * successivo della lista precedentemente creata e lo ritorna. * * o) Quando raggiunge la fine della lista, ritorna NULL e cancella * la lista. * * Da qui se ne deduce che, tramite questo tipo di azioni, e' * possibile ottenere solo un dato per singola lista; per ottenere * piu' dati per singola lista, vedere gli esempi successivi. * * (tutte le funzioni dell'Oggetto Plugin che terminano con "_str" e * "_int" funzionano in questo modo). * */ PluginObj.print("List Session:"); const char *psSessionName = 0; while((psSessionName = PluginObj.list_channels_channel_str())) { PluginObj.printf(" |_%%C4Session:%%B%%C3 %10s", psSessionName); } /* * Nel caso in cui sia invece necessario accedere a piu' dati della * stessa lista (ad esempio si vuole sapere, oltre al nome della * sessione, anche la tipologia) e' necessario procedere come segue: * * NB: Funziona solo con X-Chat uguale o superiore alla versione * 2.0.2 perche' questa funzionalita' e' stata introdotta dal team * del client solo da li' in poi. * */ xchat_list *pxc_list = PluginObj.list_get("channels"); // Era usabile anche una cosa di questo tipo: // xchat_list *pxc_list = PluginObj.list_get_channels() const char *psSessionServer = 0; int iSessionType = 0; // Deve verificare che l'oggetto sia valido, potrebbe non esserlo. if (pxc_list) { PluginObj.print("List Session / Server / Type:"); do { psSessionName = PluginObj.list_str("channel", pxc_list); psSessionServer = PluginObj.list_str("server", pxc_list); iSessionType = PluginObj.list_int("type", pxc_list); PluginObj.printf(" |_%%C4Session:%%B%%C3 %10s%%C8 : %10s : %7s", psSessionName, psSessionServer, iSessionType == 3 ? "%C7Dialog" : (iSessionType == 2 ? "%C6Channel" : (iSessionType == 1 ? "%C5Server" : "Error!"))); } while(PluginObj.list_next(pxc_list)); } else PluginObj.print("---\002 OOPS, no session !"); /* * L'esempio dei dati sul DCC e' praticamente identico a quello * riportato nella documentazione dell'interfaccia plug-in di * X-Chat, salvo per il fatto che qui e' implementato in C++ usando * l'oggetto Plugin, appunto. * */ pxc_list = PluginObj.list_get_dcc(); if(pxc_list) { PluginObj.print("--- DCC LIST ------------------\n" "File To/From KB/s Position\n"); do { PluginObj.printf("%6s %10s %.2f %d\n", PluginObj.list_str("file", pxc_list), PluginObj.list_str("nick", pxc_list), PluginObj.list_int("cps", pxc_list) / 1024, PluginObj.list_int("pos", pxc_list)); } while(PluginObj.list_next(pxc_list)); // Nell'esempio la lista veniva liberata e qui facciamo // altrettanto. PluginObj.list_free(&pxc_list); } else PluginObj.print("---\002 OOPS, no DCC Data !"); /* * Ecco come ottenere la IGNORE LIST. * * Per default l'azione list_get() elimina le eventuali liste * precedenti; per evitare questo comportamento e' necessario * invocarla in questo modo: * * PluginObj.list_get("ignore", DONT_FREE_PREVIOUS_LIST); * * Comunque non e' il caso attuale, dove invece e' necessario * liberare quella vecchia (usata per i channels). * */ pxc_list = PluginObj.list_get_ignore(); const char *psIgnoreMask = 0; int iIgnoreFlags = 0; // Deve verificare che l'oggetto sia valido, potrebbe non esserlo. if (pxc_list) { PluginObj.print("List Ignore Mask / Flags:"); do { psIgnoreMask = PluginObj.list_str("mask", pxc_list); iIgnoreFlags = PluginObj.list_int("flags", pxc_list); PluginObj.printf(" |_%%C4Ignore Mask:%%B%%C3 %10s : %d", psIgnoreMask, iIgnoreFlags); } while(PluginObj.list_next(pxc_list)); // Liberiamo la lista. PluginObj.list_free(&pxc_list); } else PluginObj.print("---\002 OOPS, no Ingore Mask !"); /* * La lista degli utenti presenti nella sessione corrente si ottiene * in questo modo: * */ // Notare che, a differenza dei precedenti esempi, non si usa la // variabile pxc_list; infatti l'oggetto Plugin e' in grado di // gestire anche internamente le liste, in modo da ottenere un vero // comportamento Object Orientend. PluginObj.list_get_users(); const char *psUserNick = 0; const char *psUserHost = 0; const char *psUserPrefix = 0; // Deve verificare che l'oggetto sia valido, potrebbe non esserlo. if (PluginObj.GetList()) { PluginObj.print("Users in current Channel:"); do { psUserNick = PluginObj.list_str("nick"); psUserHost = PluginObj.list_str("host"); psUserPrefix = PluginObj.list_str("prefix"); PluginObj.printf(" |_>%%B%%C3 %16s%%O at%%B%%C6 %s%%O (%%B%%C7%s%%O)", psUserNick, psUserHost, psUserPrefix); } while(PluginObj.list_next()); // Liberiamo la lista. PluginObj.list_free(); } else PluginObj.print("---\002 OOPS, no user in this Session !"); /* * Un metodo avanzato per ottenere la lista di tutti gli utenti * presenti nel "database" di X-Chat2 (cioe' una lista completa, * indipendentemente dal numero di server/canali/dialog attualmente * attivi e non solo in quello corrente, come invece fanno i metodi * precedenti) e' dato dalle aggiunte funzionalita' della classe * Plugin a quelle che sono le normali operazioni invece offerte * dalle funzioni di base offerte dal client. * * In particolare e' presente un meccanismo che, pur funzionando in * modo analogo a quanto mostrato sopra, sfrutta una classe UserData * (vedere plugin.h) che consente di manipolare un oggetto che gia' * ingloba molte delle informazioni che normalmente sono utilizzate, * come ad esempio: nickname, hostname, prefisso, canale, server, * contesto e stato di ignore; tutto questo per ogni singolo utente. * */ /* * Come prima cosa crea la lista di utenti; questa lista conterra' * tanti utenti di classe UserData per ogni utente presente nel * "database" di X-Chat 2. * */ xchat_list *cUserData_list = PluginObj.list_get_cUserData(); UserData *pcUserData = NULL; // Verifica se e' riuscito a crare la lista. if (cUserData_list) { PluginObj.print("Users in X-Chat 2 Database:"); while(PluginObj.list_next_cUserData(cUserData_list)) { pcUserData = PluginObj.list_cUserData(cUserData_list); PluginObj.printf(" ._\002\0033Nickname = \0038%60s", pcUserData->GetNickname()); PluginObj.printf(" |_\002\0033Host = \0038%60s", pcUserData->GetHost()); PluginObj.printf(" |_\002\0033Prefix = \0038%60s", pcUserData->GetPrefix()); PluginObj.printf(" |_\002\0033Channel = \0038%60s", pcUserData->GetChannel()); PluginObj.printf(" |_\002\0033Server = \0038%60s", pcUserData->GetServer()); PluginObj.printf(" |_\002\0033CTX = \0038%60p", pcUserData->GetCTX()); PluginObj.printf(" |_\002\0033Ignored = \0038%60s", pcUserData->GetIgnored() ? "YES" : "NO"); // Quando l'oggetto non serve piu', va eliminato altrimenti // rimane comunque allocata la memoria !!! delete pcUserData; pcUserData = NULL; } // E' assolutamente necessario eliminare la lista quando non e' // piu' necessaria. PluginObj.list_free_cUserData(&cUserData_list); } else PluginObj.print("---\002 OOPS, I can't create the class User's list."); /* * Un'altra peculiarita' della classe Plugin, per quanto riguarda le * liste dati, e' la possibilita' di cercare un utente in base al * nickname, host, prefisso, canale, server, contesto e stato di * ignore. * * Ad esempio potremmo voler estrapolare tutti gli utenti ignorati, * oppure quelli appartenenti ad un certo canale e cosi' via. * * Ecco di seguito qualche esempio di utilizzo. * */ PluginObj.printf("Find\002 %s\017 nickname:", PluginObj.get_info_nick()); while((pcUserData = PluginObj.find_user_nickname(PluginObj.get_info_nick()))) { PluginObj.printf(" ._\002\0033Nickname = \0038%60s", pcUserData->GetNickname()); PluginObj.printf(" |_\002\0033Host = \0038%60s", pcUserData->GetHost()); PluginObj.printf(" |_\002\0033Prefix = \0038%60s", pcUserData->GetPrefix()); PluginObj.printf(" |_\002\0033Channel = \0038%60s", pcUserData->GetChannel()); PluginObj.printf(" |_\002\0033Server = \0038%60s", pcUserData->GetServer()); PluginObj.printf(" |_\002\0033CTX = \0038%60p", pcUserData->GetCTX()); PluginObj.printf(" |_\002\0033Ignored = \0038%60s", pcUserData->GetIgnored() ? "YES" : "NO"); // Quando l'oggetto non serve piu', va eliminato altrimenti // rimane comunque allocata la memoria !!! delete pcUserData; pcUserData = NULL; } PluginObj.print("Find\002 ignored\017 users:"); while((pcUserData = PluginObj.find_user_ignored(IGNORED_YES))) { PluginObj.printf(" ._\002\0033Nickname = \0038%60s", pcUserData->GetNickname()); PluginObj.printf(" |_\002\0033Host = \0038%60s", pcUserData->GetHost()); PluginObj.printf(" |_\002\0033Ignored = \0038%60s", pcUserData->GetIgnored() ? "YES" : "NO"); // Quando l'oggetto non serve piu', va eliminato altrimenti // rimane comunque allocata la memoria !!! delete pcUserData; pcUserData = NULL; } /* * E' da sottolineare, infine, la possibilita' di effettuare * ricerche basandosi su piu' dati contemporaneamente. * * Ad esempio se si volessero estrapolare tutti gli utenti ignorati * presenti in un determinato canale: * */ PluginObj.printf("Find\002 ignored\017 users on channel \002%s\017:", PluginObj.get_info_channel()); while((pcUserData = PluginObj.find_user_cmp(0, // Nickname 0, // Host 0, // Prefix PluginObj.get_info_channel(), 0, // Server 0, // Context IGNORED_YES))) { PluginObj.printf(" ._\002\0033Nickname = \0038%60s", pcUserData->GetNickname()); PluginObj.printf(" |_\002\0033Host = \0038%60s", pcUserData->GetHost()); PluginObj.printf(" |_\002\0033Channel = \0038%60s", pcUserData->GetChannel()); PluginObj.printf(" |_\002\0033Ignored = \0038%60s", pcUserData->GetIgnored() ? "YES" : "NO"); // Quando l'oggetto non serve piu', va eliminato altrimenti // rimane comunque allocata la memoria !!! delete pcUserData; pcUserData = NULL; } /* * In questo caso e' giusto "mangiare" l'evento perche' nessun'altro * script deve poter gestire questo comando. * */ return XCHAT_EAT_ALL; } /* * Definisce la funzione di inizializzazione xchat_plugin_init(). * * Si tratta della prima funzione che viene automaticamente invocata * all'atto del caricamento del plug-in da parte del client X-Chat. * * I Parametri passati sono rispettivamente: * * - Un puntatore al plugin in memoria (necessario per la gestione del plug-in stesso). * * - Un riferimento a puntatore che dovra' contenere il Nome del plugin (da configurare nella funzione stessa). * * - Un riferimento a puntatore che dovra' contenere la Descrizione del plugin (da configurare nella funzione stessa). * * - Un riferimento a puntatore che dovra' contenere la Versione del plugin (da configurare nella funzione stessa). * * - Gli argomenti passati ad X-Chat dalla linea di comando. * */ extern "C" { int xchat_plugin_init(xchat_plugin *plugin_handle, char **plugin_name, char **plugin_desc, char **plugin_version, char *arg) { // Configura i parametri base del plugin. *plugin_name = "List"; *plugin_desc = "Lista i dati contenuti in X-Chat"; *plugin_version = "0.2"; // Inizializza l'Oggetto plugin con i parametri base configurati. PluginObj = Plugin(plugin_handle, (*plugin_name), (*plugin_desc), (*plugin_version), arg); // Aggancia il comando "autooptoggle", in modo che ogni volta che // l'utente lancia suddetto venga eseguita la callback // cb_ListData(). PluginObj.hook_command("ListData", cb_ListData, "Usage: LISTDATA, List internal Data of X-Chat"); // Comunica che il plugin e' stato caricato in memoria con // successo. PluginObj.print("ListData Plugin loaded successfully!\n"); PluginObj.print("Usage: /LISTDATA"); return 1; /* ritorna 1 per successo */ } }

// UDA'Software 2003 // File: onotice.cpp /* * Questo script di esempio in C++ serve per spedire un messaggio agli * operatori di tutti i canali nei quali e' presente l'utente locale. * * Lo si utilizza digitando il comando: * * /onotice <message> * * alla riga dei comandi di X-Chat 2 dove <message> rappresenta il * testo del messaggio da spedire, ex: * * /onotice Io sto usando X-Chat con un plugin ! * */ /* * Include la libreria C++ per la gestione degli X-Chat Plug-in. * */ #include "plugin.h" /* * Dichiara a livello globale l'Oggetto Plugin. * * L'oggetto ingloba tutte le Proprieta' e le Azioni necessarie per la * gestione di un plug-in. * */ static Plugin PluginObj; /* * Definisce la funzione cb_Onotice(), che viene invocata ogni * volta che l'utente lancia il comando: /onotice * */ static int cb_Onotice(char *word[], char *word_eol[], void *userdata) { /* * Verifica se e' stato passato "il secondo parametro". * * word_eol[], a differenza di word[], rappresenta un vettore di * stringhe a "End Of Line"; ad esempio se abbiamo il vettore word[] * riempito in questo modo: * * word[1] = onotice * word[2] = Messaggio * word[3] = spedito * word[4] = a * word[5] = tutti * word[6] = gli * word[7] = operatori * word[8] = dei * word[9] = miei * word[10] = canali * * il corrispondente word_eol[] risultera': * * word_eol[1] = onotice Messaggio spedito a tutti gli operatori dei miei canali * word_eol[2] = Messaggio spedito a tutti gli operatori dei miei canali * word_eol[3] = spedito a tutti gli operatori dei miei canali * word_eol[4] = a tutti gli operatori dei miei canali * word_eol[5] = tutti gli operatori dei miei canali * word_eol[6] = gli operatori dei miei canali * word_eol[7] = operatori dei miei canali * word_eol[8] = dei miei canali * word_eol[9] = miei canali * word_eol[10] = canali * */ if(word_eol[2][0] == 0) { PluginObj.printf("\002 Il secondo argomento deve essere il Messaggio !\n"); } else { PluginObj.commandf("NOTICE @%s :%s", PluginObj.get_info_channel(), word_eol[2]); } /* * In questo caso e' giusto "mangiare" l'evento perche' nessun'altro * script deve poter gestire questo comando. * */ return XCHAT_EAT_ALL; } /* * Definisce la funzione di inizializzazione xchat_plugin_init(). * * Si tratta della prima funzione che viene automaticamente invocata * all'atto del caricamento del plug-in da parte del client X-Chat. * * I Parametri passati sono rispettivamente: * * - Un puntatore al plugin in memoria (necessario per la gestione del plug-in stesso). * * - Un riferimento a puntatore che dovra' contenere il Nome del plugin (da configurare nella funzione stessa). * * - Un riferimento a puntatore che dovra' contenere la Descrizione del plugin (da configurare nella funzione stessa). * * - Un riferimento a puntatore che dovra' contenere la Versione del plugin (da configurare nella funzione stessa). * * - Gli argomenti passati ad X-Chat dalla linea di comando. * */ extern "C" { int xchat_plugin_init(xchat_plugin *plugin_handle, char **plugin_name, char **plugin_desc, char **plugin_version, char *arg) { // Configura i parametri base del plugin. *plugin_name = "Onotice"; *plugin_desc = "Invia un messaggio a tutti gli Operatori dei canali joinati"; *plugin_version = "0.1"; // Inizializza l'Oggetto plugin con i parametri base configurati. PluginObj = Plugin(plugin_handle, (*plugin_name), (*plugin_desc), (*plugin_version), arg); // Aggancia il comando "onotice", in modo che ogni volta che // l'utente lancia suddetto venga eseguita la callback // cb_Onotice(). PluginObj.hook_command("Onotice", cb_Onotice, "Usage: ONOTICE <message>"); // Comunica che il plugin e' stato caricato in memoria con // successo. PluginObj.print("Onotice Plugin loaded successfully!\n"); PluginObj.print("Usage: /ONOTICE <message>"); return 1; /* ritorna 1 per successo */ } }

// UDA'Software 2003 // File: timer.cpp /* * Questo script di esempio in C++ serve per "oppare" in automatico * gli utenti che entrano nei canali dove e' presente l'utente locale * (il quale, ovviamente, deve essere operatore). * * Si abilita/disabilita digitando il comando: * * /timertoggle * * alla riga dei comandi di X-Chat 2. * */ /* * Include la libreria C++ per la gestione degli X-Chat Plug-in. * */ #include "plugin.h" /* * Dichiara a livello globale l'Oggetto Plugin. * * L'oggetto ingloba tutte le Proprieta' e le Azioni necessarie per la * gestione di un plug-in. * */ static Plugin PluginObj; /* * Dichiara e inizializza un puntatore hook per il timer. * */ static xchat_hook *pxhTimer; /* * Definisce la funzione cb_Timeout(), la callback che viene invocata * ogni tot secondi dal timer. * */ static int cb_Timeout(void *userdata) { PluginObj.print("Ti annoio ogni 5 secondi con questo messaggio ! Usa /STOP per fermarmi.\n"); return 1; } /* * Definisce la funzione cb_Stop(), che viene invocata ogni * volta che l'utente lancia il comando: /stop * */ static int cb_Stop(char *word[], char *word_eol[], void *userdata) { /* * Se il puntatore all'hook del timer e' valido, provvede ad * eliminarlo. * */ if (pxhTimer != NULL) { PluginObj.unhook(&pxhTimer); pxhTimer = NULL; PluginObj.print("Timer \0033Rimosso !\n"); } /* * In questo caso e' giusto "mangiare" l'evento perche' nessun'altro * script deve poter gestire questo comando. * */ return XCHAT_EAT_ALL; } /* * Definisce la funzione di inizializzazione xchat_plugin_init(). * * Si tratta della prima funzione che viene automaticamente invocata * all'atto del caricamento del plug-in da parte del client X-Chat. * * I Parametri passati sono rispettivamente: * * - Un puntatore al plugin in memoria (necessario per la gestione del plug-in stesso). * * - Un riferimento a puntatore che dovra' contenere il Nome del plugin (da configurare nella funzione stessa). * * - Un riferimento a puntatore che dovra' contenere la Descrizione del plugin (da configurare nella funzione stessa). * * - Un riferimento a puntatore che dovra' contenere la Versione del plugin (da configurare nella funzione stessa). * * - Gli argomenti passati ad X-Chat dalla linea di comando. * */ extern "C" { int xchat_plugin_init(xchat_plugin *plugin_handle, char **plugin_name, char **plugin_desc, char **plugin_version, char *arg) { // Configura i parametri base del plugin. *plugin_name = "Timer"; *plugin_desc = "Funzionamento del Timer"; *plugin_version = "0.1"; // Inizializza l'Oggetto plugin con i parametri base configurati. PluginObj = Plugin(plugin_handle, (*plugin_name), (*plugin_desc), (*plugin_version), arg); // Aggancia il comando "timertoggle", in modo che ogni volta che // l'utente lancia suddetto venga eseguita la callback // cb_Stop(). PluginObj.hook_command("Stop", cb_Stop, "Usage: STOP, Turns OFF Timer"); // Comunica che il plugin e' stato caricato in memoria con // successo. PluginObj.print("Timer Plugin loaded successfully!\n"); // Installa un timer che invoca la callback cb_Timeout() ogni 5000 // millisecondi (5 sec). pxhTimer = PluginObj.hook_timer(5000, cb_Timeout); // Comunica che ha installato un timer. PluginObj.print("Timer \0034Installato\n"); return 1; /* ritorna 1 per successo */ } }

# Makefile dei plugin di esempio CPPFLAGS = -g -Wall -lc XCHATFLAGS = -I .. -I /usr/local/xchat-2.0.4 GLIBFLAGS = -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -lglib-2.0 CG = g++ CPPFILES =\ autoop.cpp\ listdata.cpp\ onotice.cpp\ hookprint.cpp\ timer.cpp\ getinfo.cpp\ getprefs.cpp CPP_PLUGIN = $(CPPFILES:.cpp=.so) .SUFFIXES: .cpp .so .cpp.so: $(CG) $(CPPFLAGS) -shared -Wl,-soname,$@ -o $@ $< $(XCHATFLAGS) $(GLIBFLAGS) all: $(CPP_PLUGIN) ls -l *.so clean: rm -f *~ *.o *.so # end

UDA'Software 2003