home *** CD-ROM | disk | FTP | other *** search
- #ifndef AMIRC_PLUGIN_H
- #define AMIRC_PLUGIN_H
-
- /*
- ** AmIRC Plugin definitions
- ** ========================
- **
- ** (C) 1997-98 Oliver Wagner <owagner@vapor.com>
- ** All Rights Reserved
- **
- ** Revision 1 (22-11-97)
- ** ---------------------
- ** - initial version
- **
- ** Revision 2 (30-11-97)
- ** ---------------------
- ** - modified by Simone Tellini for
- ** GCC/StormC-compatibility
- ** - added note to not store the
- ** function table pointer globally.
- **
- ** Revision 3 (30-11-97)
- ** ---------------------
- ** - now all hook functions are
- ** called with a pointer to the
- ** functable, to overcome
- ** compiler which don't support
- ** unique data segments per opener.
- **
- ** Revision 4 (02-01-98)
- ** ---------------------
- ** - added new DCC handling functions
- ** - added sound function
- ** - added userdata field
- **
- ** Revision 5 (03-01-98)
- ** ---------------------
- ** - added color code definitions
- ** - added AMIPLUGATTR_ for Alias, Ignore and Hilite list
- ** - added amiplug_malloc()
- ** - added amiplug_getstring()
- ** - added amirc_stringnode and amirc_ignore definitions
- ** - modified amiplug_get(dcc)attr() prototype to use
- ** APTR for the storage pointer
- ** - added AMIPLUGATTR_StartupCFG, _FKeyStrings,
- ** _Catalog and _MemPool
- ** - added DCC state definitions
- **
- ** Revision 6 (04-01-98)
- ** ---------------------
- ** - added amiplug_queueline() function
- **
- ** Revision 7 (06-01-98)
- ** ---------------------
- ** - added AMIPLUGDCCATR_UserData
- **
- ** Revision 8 (08-01-98)
- ** ---------------------
- ** - added AMIPLUG_Query_CustomCTCP and related stuff
- **
- */
-
- #ifndef _reg
- #ifdef _DCC
- #define _reg(x) __ ## x
- #else
- #define _reg(x) register __ ## x
- #endif
- #endif
-
- #ifndef PLFUNC
- #if defined __MAXON__ || defined __STORM__ || defined _DCC
- #define PLFUNC
- #else
- #define PLFUNC __asm
- #endif
- #endif
-
- #ifndef SAVEDS
- #ifdef __MAXON__
- #define SAVEDS
- #endif
- #if defined __STORM__ || defined __SASC
- #define SAVEDS __saveds
- #endif
- #if defined _GCC || defined _DCC
- #define SAVEDS __geta4
- #endif
- #endif
-
- #include <exec/types.h>
- #ifdef __STORM__
- #include <exec/libraries.h>
- #endif
- /* ^ needed for the #pragma libbase below */
- #include <utility/tagitem.h>
-
- #define AMIPLUG_TAGBASE (TAG_USER+0x87c12)
-
- /*
- ** AMIPLUG_Setup() is supposed to return a static TagList
- ** which describes the ability and requirements of
- ** a plugin.
- **
- ** Upon startup, AmIRC will scan PROGDIR:Plugins/#?.AMIPlug,
- ** OpenLibrary() anything it finds and call upon AMIPLUG_Setup()
- ** to get information.
- **
- */
-
- #define AMIPLUG_QUERYBASE (AMIPLUG_TAGBASE+100)
-
- #define AMIPLUG_Query_Version (AMIPLUG_QUERYBASE+0) /* ULONG version */
- #define AMIPLUG_Query_Revision (AMIPLUG_QUERYBASE+1) /* ULONG revision */
- #define AMIPLUG_Query_Copyright (AMIPLUG_QUERYBASE+2) /* STRPTR copyright information */
- #define AMIPLUG_Query_Infostring (AMIPLUG_QUERYBASE+3) /* STRPTR generic info string */
-
- /* ULONG
- Here you can specifiy the minimum AmIRC version
- required for this plugin. AmIRC versions below
- this one will simply skip the plugin during load.
- The version is specified as a longword with the
- high 16 bit word specifying the version, and the low
- 16 bit word specifying the revision. Example:
- If the plugin requires a minimum AmIRC version of
- 2.1, the value would be 0x00020001
- */
- #define AMIPLUG_Query_MinAmIRCVersion (AMIPLUG_QUERYBASE+4) /* ULONG */
-
- /* BOOL
- If this is TRUE, AmIRC will call the plugin's
- AMIPLUG_Hook_Rawline() function for every raw
- line received from the server. If the function
- returns a non-zero value, AmIRC will *NOT*
- further process the line. Beware -- be very
- very sure to not eat up any WHOIS or NAMES
- or other server responses this way, otherwise
- you may mess up AmIRC's internal processing
- big time.
- */
- #define AMIPLUG_Query_Hook_Rawline (AMIPLUG_QUERYBASE+10)
-
- /* BOOL
- If this is TRUE, AmIRC will call the plugin's
- AMIPLUG_Hook_DCC() function for every update of
- the DCC list windows. The plugin can then call
- upon amiplug_getdccattr() to find out more about
- about the DCC connection in question.
- */
- #define AMIPLUG_Query_Hook_DCC (AMIPLUG_QUERYBASE+14)
-
- /* BOOL
- If this is TRUE, AmIRC will call the plugin's
- AMIPLUG_Hook_NumericMsg() function for every raw
- line received from the server which is a numeric
- message code. If the function returns a non-zero value,
- AmIRC will *NOT* further process the line. Beware -- be
- very very sure to not eat up any WHOIS or NAMES
- or other server responses this way, otherwise
- you may mess up AmIRC's internal processing
- big time.
- */
- #define AMIPLUG_Query_Hook_NumericMsg (AMIPLUG_QUERYBASE+12)
-
- /* struct amiplug_cmd *
- This tag may appear several times. It specifies a
- custom command which will appear to the user as a
- "normal" command. If the command parser hits one
- of the user commands, it calls upon the plugin's
- AMIPLUG_DoCommand() function.
- See below for a description of amiplug_cmd.
- */
- #define AMIPLUG_Query_CustomCommand (AMIPLUG_QUERYBASE+11)
-
- /* struct amiplug_menu *
- This tag may appear several times. It specifies a
- custom menu item in the "Plugins" section. If the user
- selects the menu item, the plugin's AMIPLUG_DoMenu()
- function is called.
- See below for a description of amiplug_menu
- */
- #define AMIPLUG_Query_CustomMenu (AMIPLUG_QUERYBASE+13)
-
- /* struct amiplug_ctcp *
- This tag may appear several times. It specifies a
- custom ctcp command which will appear to the user as a
- "normal" ctcp command. If a user request one
- of the custom ctcp commands, it calls upon the plugin's
- AMIPLUG_DoCTCP() function.
- See below for a description of amiplug_ctcp.
- */
- #define AMIPLUG_Query_CustomCTCP (AMIPLUG_QUERYBASE+15)
-
-
- /*
- ** Structure describing a command.
- ** "name" is the command name (without trailing "/")
- ** "template" is the template given when the user types
- ** /? command
- ** "minimumparms" is the minimum number of parameters
- ** required for this command
- ** "needchannel" specifies that the first parameter
- ** has to be a channel name.
- */
- struct amiplug_cmd {
- struct MinNode n;
- char *name;
- char *template;
- ULONG commandid;
- ULONG minimumparms;
- ULONG needchannel;
- };
-
- /*
- ** This structure is handed to a custom command
- ** when it is called.
- ** The "parms" pointers point to the start of
- ** the first, second and third command parts;
- ** parms2b and parms3b point to the WSP between
- ** the second and third command token. Example:
- ** If you want to split out the first command word,
- ** do a "*parms2b = 0;"
- */
- struct amiplug_cmdparm {
- char *cmdline;
- char *channelname;
- char *parms, *parms2, *parms3;
- char *parms2b, *parms3b;
- APTR muiapp;
- };
-
- /*
- ** Menu item specifier
- */
- struct amiplug_menu {
- struct MinNode n;
- APTR link;
- char *label;
- ULONG commandid;
- };
-
- /*
- ** Custom CTCP command specifier
- */
- struct amiplug_ctcp {
- struct MinNode n;
- char *name;
- ULONG commandid;
- };
-
-
- /*
- ** amiplug_getattr() can be used to get information
- ** an various internal states. It's used similiar
- ** to BOOPSI GetAttr(), and it returns a BOOL
- ** TRUE/FALSE value which designates whether
- ** the storage location is valid or not.
- **
- */
-
- enum {
- AMIPLUGATTR_first = 1,
- AMIPLUGATTR_IsConnected, /* ULONG: currently connected */
- AMIPLUGATTR_CurrentNick, /* STRPTR: Current nickname */
- AMIPLUGATTR_CurrentServer, /* STRPTR: Current server */
- AMIPLUGATTR_CurrentServerPort, /* ULONG: Current server port */
- AMIPLUGATTR_ConnectTime, /* time_t: When connection was established */
- AMIPLUGATTR_AppObject, /* APTR: MUI application object */
- AMIPLUGATTR_AliasList, /* struct MinList* list of amirc_stringnodes */
- AMIPLUGATTR_HiliteList, /* struct MinList* list of amirc_stringnodes */
- AMIPLUGATTR_IgnoreList, /* struct MinList* list of amirc_ignorenodes */
- AMIPLUGATTR_StartupCFG, /* STRPTR: name of startup cfg file */
- AMIPLUGATTR_MemPool, /* APTR: general AmIRC memory pool */
- AMIPLUGATTR_FKeyStrings, /* STRPTR[30]: function key strings*/
- AMIPLUGATTR_Catalog, /* APTR: catalog in use (may be NULL!) */
- };
-
- /*
- ** amiplug_dccgetattr() can be used to get information
- ** about DCC connections. Returns FALSE if the DCCID
- ** could not be found, or the attribte was invalid.
- ** [SRC] shows whether the attribute is valid for
- ** Sends, Receives and Chats respectivly.
- **
- */
-
- enum {
- AMIPLUGDCCATTR_first = 8192,
- AMIPLUGDCCATTR_Type, /* [SRC] ULONG: 0 = Send, 1 = Receive, 2 = Chat */
- AMIPLUGDCCATTR_Nick, /* [SRC] STPRTR: nickname */
- AMIPLUGDCCATTR_Filename, /* [SR.] STPRTR: filename with path */
- AMIPLUGDCCATTR_State, /* [SRC] ULONG: state */
- AMIPLUGDCCATTR_RemoteHostname, /* [SRC] STRPTR: remote hostname */
- AMIPLUGDCCATTR_RemoteIP, /* [SRC] ULONG: remote IP */
- AMIPLUGDCCATTR_Starttime, /* [SR.] time_t: when transfer was started */
- AMIPLUGDCCATTR_Filelen, /* [SR.] ULONG: total filelen */
- AMIPLUGDCCATTR_Filedone, /* [SR.] ULONG: how much is transfered */
- AMIPLUGDCCATTR_Startoffset, /* [SR.] ULONG: startoffset, for resumes/moves */
- AMIPLUGDCCATTR_IsMove, /* [SR.] ULONG: whether this is a DCC MOVE */
- AMIPLUGDCCATTR_IsTurbo, /* [.R.] ULONG: whether this is a DCC TSEND */
- AMIPLUGDCCATTR_IsStalled, /* [SR.] ULONG: transfer stalled? */
- AMIPLUGDCCATTR_IsSecure, /* [..C] ULONG: encrypted SCHAT? */
- AMIPLUGDCCATTR_UserData, /* [..C] ULONG*: Pointer (!) to Userdata */
- };
-
- /*
- ** Color codes for text output functions.
- ** These correspondend to user defined
- ** settings.
- */
- enum AMIRC_TEXTCOLS {
- amirc_tc_normal = 0,
- amirc_tc_highlite,
- amirc_tc_private,
- amirc_tc_server,
- amirc_tc_mode,
- amirc_tc_dcc,
- amirc_tc_local
- };
-
- /*
- ** Alias and Ignore lists are build of these nodes
- ** If you add your own, use amiplug_malloc() to
- ** obtain the memory, extending "string" to fit
- ** the string length, including (!) the zero terminator.
- */
- struct amirc_stringnode {
- struct MinNode n;
- char string[ 0 ];
- };
-
- /*
- ** Structure used for Ignorelist. This may
- ** be subject for change in later versions.
- ** If you add your own, use amiplug_malloc() to
- ** obtain the memory, extending "string" to fit
- ** the string length, including (!) the zero terminator.
- */
- struct amirc_ignorenode {
- struct MinNode n;
- ULONG what;
- ULONG count;
- ULONG transient;
- char userhost[ 0 ];
- };
- #define IGNF_TEXT 1
- #define IGNF_PRIV 2
- #define IGNF_CTCP 4
-
-
- /*
- ** DCC states
- */
-
- /* Receive */
- #define DCCRS_WAITING 0
- #define DCCRS_CONNECTING 1
- #define DCCRS_RECEIVING 2
- #define DCCRS_COMPLETE 3
- #define DCCRS_FAILED 4
- #define DCCRS_NOCONNECT 5
- #define DCCRS_ABORTED 6
- #define DCCRS_NOSOCK 7
- #define DCCRS_NOHOST 8
- #define DCCRS_NOFILE 9
- #define DCCRS_WRITEERROR 10
-
- /* Chat */
- #define DCCCS_WAITING 0
- #define DCCCS_CONNECTING 1
- #define DCCCS_CONNECTED 2
- #define DCCCS_WAITINGFOR 3
- #define DCCCS_CLOSED 4
- #define DCCCS_NOCONNECT 5
- #define DCCCS_NOSOCK 6
- #define DCCCS_ABORTED 7
-
- /* Send */
- #define DCCSS_WAITINGFOR 0
- #define DCCSS_ABORTED 1
- #define DCCSS_SENDING 2
- #define DCCSS_COMPLETE 3
- #define DCCSS_FAILED 4
- #define DCCSS_NOSOCK 5
- #define DCCSS_NOFILE 6
- #define DCCSS_READERROR 7
- #define DCCSS_CALCCHECK 8
-
-
- /*
- ** All hook functions also receives a pointer to a table of
- ** functions which the plugin can call to have AmIRC perform
- ** certain operations. *NOTE* You *MUST NOT* store this
- ** function pointer globally, as it will be a different
- ** table for every new opener of the plugin library.
- ** If you use SAS/C, you can use libinitr.o to have
- ** the compiler create a new data segment for every
- ** opener; this also allows you to use global
- ** variables in the code easily.
- **
- ** Note that all functions have to follow register
- ** calling conventions.
- **
- ** The table also contains (hidden) context information,
- ** so it's necessary to pass it back to any function
- ** you call. Confusing? Nah :)
- **
- */
-
- struct amiplug_functable {
- int amiplug_functabversion;
-
- /* Send raw data to the server */
- int (PLFUNC * amiplug_sendraw)
- ( _reg(a0) struct amiplug_functable *ctx, _reg(a1) APTR data, _reg(d0) ULONG len );
-
- /* find the user@host for a given nick */
- char * (PLFUNC *amiplug_findnickuserhost)
- ( _reg(a0) struct amiplug_functable *ctx, _reg(a1) STRPTR nick );
- /* like findnickuserhost, but will print a warning message
- if the userhost can't be found */
- char * (PLFUNC *amiplug_findnickuserhost_warn)
- ( _reg(a0) struct amiplug_functable *ctx, _reg(a1) STRPTR nick );
-
- /* The following functions are for outputting text to
- any of the AmIRC windows */
- /* Default window */
- void (PLFUNC *amiplug_out_defwin)
- ( _reg(a0) struct amiplug_functable *ctx, _reg(d0) int color, _reg(a1) STRPTR prefix, _reg(a2) STRPTR txt );
-
- /* Output to a query window, if it exists, otherwise def window */
- void (PLFUNC *amiplug_out_userwin)
- ( _reg(a0) struct amiplug_functable *ctx, _reg(d0) int color, _reg(a1) STRPTR prefix, _reg(a2) STRPTR txt, _reg(a3) STRPTR nick );
-
- /* Output to a channel window, if it exists, otherwise def window */
- void (PLFUNC *amiplug_out_channelwin)
- ( _reg(a0) struct amiplug_functable *ctx, _reg(d0) int color, _reg(a1) STRPTR prefix, _reg(a2) STRPTR txt, _reg(a3) STRPTR channel );
-
- /* Get a pointer to the MUI userlist object of a certain channel */
- APTR (PLFUNC *amiplug_getuserlv)
- ( _reg(a0) struct amiplug_functable *ctx, _reg(a1) STRPTR channel );
-
- /* Get some information from various AmIRC states. See
- AMIPLUGATTR_ definitions above */
- int (PLFUNC *amiplug_getattr)
- ( _reg(a0) struct amiplug_functable *ctx, _reg(d0) ULONG attrid, _reg(a1) APTR storage );
-
- /* Execute "line" as if the user entered it in the default
- window. Similiar to AmIRC's "SAY" Rexx command. Returns FALSE
- if the line couldn't be executed for some reason, TRUE otherwise */
- int (PLFUNC *amiplug_say)
- ( _reg(a0) struct amiplug_functable *ctx, _reg(a1) STRPTR line );
-
- /* Play either a vanilla sound file or a event sound (if soundfile is NULL) */
- int (PLFUNC *amiplug_playsound)
- ( _reg(a0) struct amiplug_functable *ctx, _reg(a1) STRPTR soundfile, _reg(d0) ULONG event );
-
- /* Add a DCC send request. Returns ID. method is 0 for DCC SEND,
- 1 for DCC MOVE. delay is in ticks, before the DCC offer is
- send to the nick
- */
- ULONG (PLFUNC *amiplug_adddcc_send)
- ( _reg(a0) struct amiplug_functable *ctx,
- _reg(a1) STRPTR nick ,
- _reg(a2) STRPTR filename,
- _reg(d0) ULONG method,
- _reg(d1) ULONG delay
- );
- /* Add a DCC receive request. ip and port show where
- to connect to, "ismove" specifies whether this
- is a DCC MOVE instead of a DCC SEND, "fileexists"
- specifies the amount of "filename" already
- there (locally), "isturbo" flags whether this is
- a (PIRCH) TSEND, DCC SEND without ACKs. Returns
- the DCC ID.
- */
- ULONG (PLFUNC *amiplug_adddcc_recv)
- ( _reg(a0) struct amiplug_functable *ctx,
- _reg(a1) STRPTR nick ,
- _reg(a2) STRPTR filename,
- _reg(d0) ULONG len,
- _reg(d1) ULONG ip,
- _reg(d2) ULONG port,
- _reg(d3) ULONG ismove,
- _reg(d4) ULONG fileexists,
- _reg(d5) ULONG isturbo
- );
- /* Add a DCC CHAT request to "nick". */
- ULONG (PLFUNC *amiplug_adddcc_chat)
- ( _reg(a0) struct amiplug_functable *ctx,
- _reg(a1) STRPTR nick ,
- _reg(d0) ULONG secure
- );
-
- /* Get some information about a DCC connection. Returns
- FALSE if the DCCID could not be found, or the attribute
- was invalid. See AMIPLUGDCCATTR_ definitions above */
- int (PLFUNC *amiplug_dccgetattr)
- ( _reg(a0) struct amiplug_functable *ctx,
- _reg(d0) ULONG dccid,
- _reg(d1) ULONG attrid,
- _reg(a1) APTR storage
- );
-
- /* Abort DCC connection */
- int (PLFUNC *amiplug_dccabort)
- ( _reg(a0) struct amiplug_functable *ctx,
- _reg(d0) ULONG dccid
- );
-
- APTR userdata; /* Do with that whatever you want */
-
- /* Allocate some memory from AmIRC internal
- pools. Used to manipulate Alias/Hilite/Ignorelists */
- APTR (PLFUNC *amiplug_malloc)
- ( _reg(a0) struct amiplug_functable *ctx,
- _reg(d0) ULONG size
- );
-
- /* Get a string from the internal catalog */
- STRPTR (PLFUNC *amiplug_getstring)
- ( _reg(a0) struct amiplug_functable *ctx,
- _reg(d0) ULONG stringid
- );
-
- /* Queue a line into AmIRC's throttled output queue */
- void (PLFUNC *amiplug_queueline)
- ( _reg(a0) struct amiplug_functable *ctx,
- _reg(a1) STRPTR line
- );
-
- APTR context; /* ***PRIVATE!!! DO NOT TOUCH!!!*** */
- };
-
- #define AMIPLUG_FUNCTAB_VERSION 6
-
- /*
- ** Library defintions
- */
-
- #ifndef BUILDPLUGIN
-
- #ifndef __STORM__
-
- #ifndef NO_PRAGMAS
- #pragma libcall classlib AMIPLUG_Setup 1e 801
- #pragma libcall classlib AMIPLUG_Cleanup 24 801
- #pragma libcall classlib AMIPLUG_Hook_Rawline 2a 09803
- #pragma libcall classlib AMIPLUG_Hook_NumericMsg 30 C1BA09807
- #pragma libcall classlib AMIPLUG_DoCommand 36 90803
- #pragma libcall classlib AMIPLUG_DoMenu 3c 90803
- #pragma libcall classlib AMIPLUG_Hook_DCC 42 0802
- #pragma libcall classlib AMIPLUG_DoCTCP 48 BA90805
- #endif
-
- #else
-
- #pragma libbase Library;
-
- #endif
-
- #ifndef NO_PROTOS
- struct TagItem *AMIPLUG_Setup( struct amiplug_functable *ctx );
- void AMIPLUG_Cleanup( struct amiplug_functable *ctx );
- int AMIPLUG_Hook_Rawline( struct amiplug_functable *ctx, STRPTR line, ULONG len );
- int AMIPLUG_Hook_NumericMsg( struct amiplug_functable *ctx, STRPTR line, ULONG numericcode, STRPTR prefix, STRPTR dest, ULONG numargs, STRPTR *args );
- void AMIPLUG_DoCommand( struct amiplug_functable *ctx, ULONG commandid, struct amiplug_cmdparm *parmpacket );
- void AMIPLUG_DoMenu( struct amiplug_functable *ctx, ULONG commandid, APTR muiapp );
- void AMIPLUG_Hook_DCC( struct amiplug_functable *ctx, ULONG dccid );
- void AMIPLUG_DoCTCP( struct amiplug_functable *ctx, ULONG commandid, char *from, char *rest, char *to );
- #endif
-
- #endif
-
- #endif
-