home *** CD-ROM | disk | FTP | other *** search
/ back2roots/padua / padua.7z / padua / ftp.vapor.com / amirc / AmIRC31SDK.lha / amirc_plugin.h < prev   
Encoding:
C/C++ Source or Header  |  1999-08-04  |  31.2 KB  |  971 lines

  1. #ifndef AMIRC_PLUGIN_H
  2. #define AMIRC_PLUGIN_H
  3.  
  4. /*
  5. ** AmIRC Plugin definitions
  6. ** ========================
  7. **
  8. ** (C) 1997-99 Oliver Wagner <owagner@vapor.com>
  9. ** All Rights Reserved
  10. **
  11. ** Revision 1 (22-11-97)
  12. ** ---------------------
  13. ** - initial version
  14. **
  15. ** Revision 2 (30-11-97)
  16. ** ---------------------
  17. ** - modified by Simone Tellini for
  18. **   GCC/StormC-compatibility
  19. ** - added note to not store the
  20. **   function table pointer globally.
  21. **
  22. ** Revision 3 (30-11-97)
  23. ** ---------------------
  24. ** - now all hook functions are
  25. **   called with a pointer to the
  26. **   functable, to overcome
  27. **   compiler which don't support
  28. **   unique data segments per opener.
  29. **
  30. ** Revision 4 (02-01-98)
  31. ** ---------------------
  32. ** - added new DCC handling functions
  33. ** - added sound function
  34. ** - added userdata field
  35. **
  36. ** Revision 5 (03-01-98)
  37. ** ---------------------
  38. ** - added color code definitions
  39. ** - added AMIPLUGATTR_ for Alias, Ignore and Hilite list
  40. ** - added amiplug_malloc()
  41. ** - added amiplug_getstring()
  42. ** - added amirc_stringnode and amirc_ignore definitions
  43. ** - modified amiplug_get(dcc)attr() prototype to use
  44. **   APTR for the storage pointer
  45. ** - added AMIPLUGATTR_StartupCFG, _FKeyStrings,
  46. **   _Catalog and _MemPool
  47. ** - added DCC state definitions
  48. **
  49. ** Revision 6 (04-01-98)
  50. ** ---------------------
  51. ** - added amiplug_queueline() function
  52. **
  53. ** Revision 7 (06-01-98)
  54. ** ---------------------
  55. ** - added AMIPLUGDCCATR_UserData
  56. **
  57. ** Revision 8 (08-01-98)
  58. ** ---------------------
  59. ** - added AMIPLUG_Query_CustomCTCP and related stuff
  60. **
  61. ** Revision 9 (06-08-98)
  62. ** ---------------------
  63. ** - added amiplug_getserver() function
  64. ** - added amiplug_getexename() function
  65. **
  66. ** Revision 10 (27-12-98)
  67. ** ---------------------
  68. ** - added amiplug_sendrxmsg() function
  69. ** - added AMIPLUG_Query_Hook_FinalSetup and related stuff
  70. **
  71. ** Revision 11 (01-05-99)
  72. ** ----------------------
  73. ** (Done by Jamie "Entity" van den Berge)
  74. ** - AMIPLUG_Setup() can now return NULL to make AmIRC skip
  75. **   the plugin.
  76. ** - added AMIPLUGATTR_Target, _Channels,
  77. **   _ServerChannelModes, _ServerUserModes.
  78. ** - added AMIPLUG_Query_Hook_Input and related stuff
  79. ** - added AMIPLUG_Query_CustomRexx and related stuff
  80. ** - added amiplug_getchanattr() function and tags
  81. ** - added AMIPLUGATTR_Version
  82. **
  83. ** Revision 12 (20-05-99)
  84. ** ----------------------
  85. ** (Done by Jamie "Entity" van den Berge)
  86. ** - added AMIPLUG_Query_Hook_Prefs and related stuff
  87. **
  88. ** Revision 13 (16-06-99)
  89. ** ----------------------
  90. ** (Done by Jamie "Entity" van den Berge)
  91. ** - added amiplug_free() function to free memory allocated
  92. **   with amiplug_malloc()
  93. ** - added AMIPLUG_Query_Hook_DCCChat and related stuff
  94. ** - added amiplug_senddccmsg() function
  95. ** - added amiplug_fakerawline() function
  96. **
  97. ** Revision 14 (30-07-99)
  98. ** ----------------------
  99. ** (Done by Jamie "Entity" van den Berge)
  100. ** - added amiplug_out_infowin() function
  101. ** - added AMIPLUG_Query_Hook_Rawline2 and _NumericMsg2 tags
  102. **   and related stuffs
  103. ** - added AMIPLUGPREFSPATH define. Please use this path for
  104. **   any datafiles your plugin needs/creates.
  105. ** - added AMIPLUGCHANATTR_Topic
  106. ** 
  107. */
  108.  
  109. #ifndef _reg
  110. #ifdef _DCC
  111. #define _reg(x) __ ## x
  112. #else
  113. #define _reg(x) register __ ## x
  114. #endif
  115. #endif
  116.  
  117. #ifndef PLFUNC
  118. #if defined __MAXON__ || defined __STORM__ || defined _DCC
  119. #define PLFUNC
  120. #else
  121. #define PLFUNC __asm
  122. #endif
  123. #endif
  124.  
  125. #ifndef SAVEDS
  126. #ifdef __MAXON__
  127. #define SAVEDS
  128. #endif
  129. #if defined __STORM__ || defined __SASC
  130. #define SAVEDS __saveds
  131. #endif
  132. #if defined _GCC || defined _DCC
  133. #define SAVEDS __geta4
  134. #endif
  135. #endif
  136.  
  137. #include <exec/types.h>
  138. #ifdef __STORM__
  139. #include <exec/libraries.h>
  140. #endif
  141. /* ^ needed for the #pragma libbase below  */
  142.  
  143. #include <utility/tagitem.h>
  144. #include <utility/hooks.h>
  145.  
  146.  
  147. #define AMIPLUG_TAGBASE (TAG_USER+0x87c12)
  148.  
  149. /*
  150. ** AMIPLUG_Setup() is supposed to return a static TagList
  151. ** which describes the ability and requirements of
  152. ** a plugin, or NULL if some crucial initialisation in your
  153. ** plugin failed and don't want the plugin to be loaded.
  154. **
  155. ** Upon startup, AmIRC will scan PROGDIR:Plugins/#?.AMIPlug,
  156. ** OpenLibrary() anything it finds and call upon AMIPLUG_Setup()
  157. ** to get information.
  158. ** 
  159. */
  160.  
  161. #define AMIPLUG_QUERYBASE (AMIPLUG_TAGBASE+100)
  162.  
  163. #define AMIPLUG_Query_Version (AMIPLUG_QUERYBASE+0)            /* ULONG version */
  164. #define AMIPLUG_Query_Revision (AMIPLUG_QUERYBASE+1)        /* ULONG revision */
  165. #define AMIPLUG_Query_Copyright (AMIPLUG_QUERYBASE+2)        /* STRPTR copyright information */
  166. #define AMIPLUG_Query_Infostring (AMIPLUG_QUERYBASE+3)        /* STRPTR generic info string */
  167.  
  168. /* ULONG
  169.    Here you can specifiy the minimum AmIRC version
  170.    required for this plugin. AmIRC versions below
  171.    this one will simply skip the plugin during load.
  172.    The version is specified as a longword with the
  173.    high 16 bit word specifying the version, and the low
  174.    16 bit word specifying the revision. Example:
  175.    If the plugin requires a minimum AmIRC version of
  176.    2.1, the value would be 0x00020001
  177. */
  178. #define AMIPLUG_Query_MinAmIRCVersion (AMIPLUG_QUERYBASE+4)             /* ULONG */
  179.  
  180. /* LONG
  181.    Plugin priority, ranging from -128 (lowest) to 127
  182.    (highest). After AMIPLUG_Setup(), your plugin will
  183.    always be called before all others with a priority
  184.    lower than specified here.
  185. */
  186. #define AMIPLUG_Query_Priority (AMIPLUG_QUERYBASE+17)
  187.  
  188. /* BOOL
  189.    If this is TRUE, AmIRC will call the plugin's 
  190.    AMIPLUG_Hook_Rawline() function for every raw line received
  191.    from the server. What AmIRC does next after you're done
  192.    can be influenced by returning a value composed of the EF_
  193.    flags below. Beware: be very very sure to not eat up any
  194.    WHOIS or NAMES or other server responses this way, otherwise
  195.    you may mess up AmIRC's internal processing big time.
  196. */
  197. #define AMIPLUG_Query_Hook_Rawline (AMIPLUG_QUERYBASE+10)
  198.  
  199. /* LONGBITS
  200.    Using this tag instead of AMIPLUG_Query_Hook_Rawline
  201.    will make AmIRC interpret the returncode of the hook
  202.    differently. You can use the EF_ values below to tell
  203.    AmIRC how to handle the line next.
  204. */
  205. #define AMIPLUG_Query_Hook_Rawline2 (AMIPLUG_QUERYBASE+23)
  206.  
  207. /* BOOL
  208.    If this is TRUE, AmIRC will call the plugin's 
  209.    AMIPLUG_Hook_DCC() function for every update of the DCC list
  210.    windows. The plugin can then call upon amiplug_getdccattr()
  211.    to find out more about about the DCC connection in question.
  212. */
  213. #define AMIPLUG_Query_Hook_DCC (AMIPLUG_QUERYBASE+14)
  214.  
  215. /* BOOL
  216.    If this is TRUE, AmIRC will call the plugin's 
  217.    AMIPLUG_Hook_NumericMsg() function for every raw line received
  218.    from the server which is a numeric message code. If the function
  219.    returns a non-zero value, AmIRC will *NOT* further process the
  220.    line. Beware -- be very very sure to not eat up any WHOIS or
  221.    NAMES or other server responses this way, otherwise you may
  222.    mess up AmIRC's internal processing big time.
  223. */
  224. #define AMIPLUG_Query_Hook_NumericMsg (AMIPLUG_QUERYBASE+12)
  225.  
  226. /* LONGBITS
  227.    Using this tag instead of AMIPLUG_Query_Hook_NumericMsg
  228.    will make AmIRC interpret the returncode of the hook
  229.    differently. You can use the EF_ values below to tell
  230.    AmIRC how to handle the line next.
  231. */
  232. #define AMIPLUG_Query_Hook_NumericMsg2 (AMIPLUG_QUERYBASE+22)
  233.  
  234. /* BOOL
  235.    If TRUE, AmIRC will call the plugin's AMIPLUG_Hook_Input()
  236.    function everytime you hit enter in a channel- or query-
  237.    window's input gadget. This function should return one of
  238.    the following things:
  239.  
  240.      String pointer:
  241.        Pointer to buffer containing replacement string.
  242.        If you don't want to modify the string, or modified
  243.        it in-place, return the pointer that was passed to you.
  244.  
  245.      NULL:
  246.        If you don't want AmIRC or any other plugins with an
  247.        input hook to process the string. BEWARE: Be very sure
  248.        not to return NULL in all cases, for obvious reasons.
  249.  
  250.    Note that the string you pass back may get changed by other
  251.    plugins with an input hook. When modifying in-place, do not
  252.    go beyond the end of the string.
  253. */
  254. #define AMIPLUG_Query_Hook_Input (AMIPLUG_QUERYBASE+18)
  255.  
  256. /* struct amiplug_cmd *
  257.    This tag may appear several times. It specifies a 
  258.    custom command which will appear to the user as a
  259.    "normal" command. If the command parser hits one
  260.    of the user commands, it calls upon the plugin's
  261.    AMIPLUG_DoCommand() function.
  262.    See below for a description of amiplug_cmd.
  263. */
  264. #define AMIPLUG_Query_CustomCommand (AMIPLUG_QUERYBASE+11)
  265.  
  266. /* struct amiplug_menu *
  267.    This tag may appear several times. It specifies a 
  268.    custom menu item in the "Plugins" section. If the user
  269.    selects the menu item, the plugin's AMIPLUG_DoMenu() 
  270.    function is called.
  271.    See below for a description of amiplug_menu
  272. */
  273. #define AMIPLUG_Query_CustomMenu (AMIPLUG_QUERYBASE+13)
  274.  
  275. /* struct amiplug_ctcp *
  276.    This tag may appear several times. It specifies a 
  277.    custom ctcp command which will appear to the user as a
  278.    "normal" ctcp command. If a user request one
  279.    of the custom ctcp commands, it calls upon the plugin's
  280.    AMIPLUG_DoCTCP() function.
  281.    See below for a description of amiplug_ctcp.
  282. */
  283. #define AMIPLUG_Query_CustomCTCP (AMIPLUG_QUERYBASE+15)
  284.  
  285. /* struct amiplug_rexxcmd *
  286.    This tag may appear several times. It specifies a
  287.    custom rexx command which will be added to AmIRC's
  288.    internal rexx commands. If this command is called by
  289.    REXX, it callsupon the plugin's AMIPLUG_DoRexx()
  290.    function. You cannot override internal or already
  291.    defined commands. You can get a pointer to the RexxMsg
  292.    in the usual way by get'ing MUIA_Application_RexxMsg.
  293.    See below for a description of amiplug_rexxcmd.
  294. */
  295. #define AMIPLUG_Query_CustomRexx (AMIPLUG_QUERYBASE+19)
  296.  
  297. /* BOOL
  298.    If this is TRUE, AmIRC will call the plugin's 
  299.    AMIPLUG_FinalSetup() function after everything
  300.    is set up.
  301. */
  302. #define AMIPLUG_Query_Hook_FinalSetup (AMIPLUG_QUERYBASE+16)
  303.  
  304. /* BOOL
  305.    If TRUE, AmIRC will call the _Hook_Prefs() function of
  306.    the plugin to build and maintain a custom preferences
  307.    page in AmIRC's Setup window. See the AMIPLUGPREFS_
  308.    methodid's below.
  309. */ 
  310. #define AMIPLUG_Query_Hook_Prefs (AMIPLUG_QUERYBASE+20)
  311.  
  312. /* BOOL
  313.    If TRUE, AmIRC will call the _Hook_DCCChat() function
  314.    of the plugin for each line received via a DCC CHAT
  315.    connection. If the function returns a non-zero value,
  316.    AmIRC will NOT further process the line. You may use
  317.    amiplug_getdccattr() on the dccid passed to the hook
  318.    function.
  319. */ 
  320. #define AMIPLUG_Query_Hook_DCCChat (AMIPLUG_QUERYBASE+21)
  321.  
  322. /* Next available tag: 24 */
  323.  
  324.  
  325. /* If your plugin needs to save/use data, please use the
  326.    following directory for your data file(s). This way the
  327.    plugin and amirc directories won't clutter up with all
  328.    sorts of config/data files.
  329. */
  330. #define AMIPLUGPREFSPATH "PROGDIR:Plugins/Data"
  331.  
  332.  
  333.  
  334.  
  335. /*
  336. ** Magic 'Eat' flags, to be used as returncodes of
  337. ** AMIPLUG_Hook_Rawline and _NumericMsg, but ONLY when
  338. ** the AMIPLUG_Query_Hook_Rawline2 resp. _NumericMsg2
  339. ** tags were used to enable the hooks.
  340. ** You can specify any of these in return() ('OR' them
  341. ** together), but some effects may not be relevant in
  342. ** combination with others. returning TRUE instead of
  343. ** a special returncode eats the rawline as usual and
  344. ** is the same as returning EF_Eat)
  345. */
  346. #define EF_Eat_AmIRC        (1<<1) // Don't let AmIRC handle this line
  347. #define EF_Eat_Plugins        (1<<2) // Don't let following plugins handle this line
  348. #define EF_Eat                (EF_Eat_AmIRC|EF_Eat_Plugins)
  349.  
  350. #define EF_NoOutput_AmIRC    (1<<8) // Don't eat line but suppress AmIRC output for it
  351. #define EF_NoOutput_Plugins    (1<<9) // Don't eat line but suppress other PLUGIN output for it
  352. #define EF_NoOutput            (EF_NoOutput_AmIRC|EF_NoOutput_Plugins)
  353.  
  354. #define EF_NoSound_AmIRC    (1<<10) // Suppress any sounds played by AmIRC for this line
  355. #define EF_NoSound_Plugins    (1<<11) // Suppress any sounds played by other PLUGINS for this line
  356. #define EF_NoSound            (EF_NoSound_AmIRC|EF_NoSound_Plugins)
  357.  
  358.  
  359. /*
  360. ** Structure describing a command.
  361. ** "name" is the command name (without trailing "/")
  362. ** "template" is the template given when the user types
  363. **   /? command
  364. ** "minimumparms" is the minimum number of parameters
  365. **   required for this command
  366. ** "needchannel" specifies that the first parameter
  367. **   has to be a channel name.
  368. */
  369. struct amiplug_cmd {
  370.         struct MinNode n;
  371.         char *name;
  372.         char *template;
  373.         ULONG commandid;
  374.         ULONG minimumparms;
  375.         ULONG needchannel;
  376. };
  377.  
  378. /*
  379. ** This structure is handed to a custom command
  380. ** when it is called.
  381. ** The "parms" pointers point to the start of
  382. ** the first, second and third command parts;
  383. ** parms2b and parms3b point to the WSP between
  384. ** the second and third command token. Example:
  385. ** If you want to split out the first command word,
  386. ** do a "*parms2b = 0;"
  387. */
  388. struct amiplug_cmdparm {
  389.         char *cmdline;
  390.         char *channelname;
  391.         char *parms, *parms2, *parms3;
  392.         char *parms2b, *parms3b;
  393.         APTR muiapp;
  394. };
  395.  
  396. /*
  397. ** Menu item specifier
  398. */
  399. struct amiplug_menu {
  400.         struct MinNode n;
  401.         APTR link;
  402.         char *label;
  403.         ULONG commandid;
  404. };
  405.  
  406. /*
  407. ** Custom CTCP command specifier
  408. */
  409. struct amiplug_ctcp {
  410.         struct MinNode n;
  411.         char *name;
  412.         ULONG commandid;
  413. };
  414.  
  415. /*
  416. ** Custom ARexx command specifier
  417. **
  418. ** "name" is the name of the ARexx function (should be lowercase)
  419. ** "template" is the ReadArgs() template used by AmIRC to verify
  420. ** usage and to parse the arguments, NULL is legal here. A pointer
  421. ** to the args array is passed to the AMIPLUG_DoRexx() function.
  422. ** "parameters" MUST equal the number of parameters in the template!
  423. ** Note: you cannot override internal or previously defined commands.
  424. */
  425. struct amiplug_rexxcmd {
  426.         struct MinNode n;
  427.         char *name;
  428.         char *template;
  429.         ULONG parameters;
  430.         ULONG commandid;
  431. };
  432.  
  433.  
  434. /*
  435. ** amiplug_getattr() can be used to get information
  436. ** an various internal states. It's used similiar
  437. ** to BOOPSI GetAttr(), and it returns a BOOL
  438. ** TRUE/FALSE value which designates whether
  439. ** the storage location is valid or not.
  440. **
  441. */
  442.  
  443. enum {
  444.     AMIPLUGATTR_first = 1,
  445.     AMIPLUGATTR_IsConnected,        /* ULONG: currently connected */
  446.     AMIPLUGATTR_CurrentNick,        /* STRPTR: Current nickname */
  447.     AMIPLUGATTR_CurrentServer,        /* STRPTR: Current server */
  448.     AMIPLUGATTR_CurrentServerPort,    /* ULONG: Current server port */
  449.     AMIPLUGATTR_ConnectTime,        /* time_t: When connection was established */
  450.     AMIPLUGATTR_AppObject,            /* APTR: MUI application object */
  451.     AMIPLUGATTR_AliasList,            /* struct MinList* list of amirc_stringnodes */
  452.     AMIPLUGATTR_HiliteList,            /* struct MinList* list of amirc_stringnodes */
  453.     AMIPLUGATTR_IgnoreList,            /* struct MinList* list of amirc_ignorenodes */
  454.     AMIPLUGATTR_StartupCFG,            /* STRPTR: name of startup cfg file */
  455.     AMIPLUGATTR_MemPool,            /* APTR: general AmIRC memory pool */
  456.     AMIPLUGATTR_FKeyStrings,        /* STRPTR[30]: function key strings*/
  457.     AMIPLUGATTR_Catalog,            /* APTR: catalog in use (may be NULL!) */
  458.  
  459.     /* V11 attributes */
  460.  
  461.     AMIPLUGATTR_Target,             /* STRPTR: channel/nickname of current window */
  462.     AMIPLUGATTR_Channels,           /* STRPTR *: NULL terminated array of channels joined */
  463.     AMIPLUGATTR_ServerChannelModes,    /* STRPTR: Available channel modes on current server */
  464.     AMIPLUGATTR_ServerUserModes,    /* STRPTR: Available user modes on current server */
  465.     AMIPLUGATTR_Version,            /* ULONG: AmIRC version: 0xvvrraaaa vv = version,
  466.                                               rr = revision, aaaa = alpha rev. */
  467.  
  468. };
  469.  
  470. /*
  471. ** amiplug_dccgetattr() can be used to get information
  472. ** about DCC connections. Returns FALSE if the DCCID
  473. ** could not be found, or the attribute was invalid.
  474. ** [SRC] shows whether the attribute is valid for
  475. ** Sends, Receives and Chats respectively.
  476. **
  477. */
  478.  
  479. enum {
  480.     AMIPLUGDCCATTR_first = 8192,
  481.     AMIPLUGDCCATTR_Type,                /* [SRC] ULONG: 0 = Send, 1 = Receive, 2 = Chat */
  482.     AMIPLUGDCCATTR_Nick,                /* [SRC] STPRTR: nickname */
  483.     AMIPLUGDCCATTR_Filename,            /* [SR.] STPRTR: filename with path */
  484.     AMIPLUGDCCATTR_State,                /* [SRC] ULONG: state */
  485.     AMIPLUGDCCATTR_RemoteHostname,        /* [SRC] STRPTR: remote hostname */
  486.     AMIPLUGDCCATTR_RemoteIP,            /* [SRC] ULONG: remote IP */
  487.     AMIPLUGDCCATTR_Starttime,            /* [SR.] time_t: when transfer was started */
  488.     AMIPLUGDCCATTR_Filelen,                /* [SR.] ULONG: total filelen */
  489.     AMIPLUGDCCATTR_Filedone,            /* [SR.] ULONG: how much is transfered */
  490.     AMIPLUGDCCATTR_Startoffset,            /* [SR.] ULONG: startoffset, for resumes/moves */
  491.     AMIPLUGDCCATTR_IsMove,                /* [SR.] ULONG: whether this is a DCC MOVE */
  492.     AMIPLUGDCCATTR_IsTurbo,                /* [.R.] ULONG: whether this is a DCC TSEND */
  493.     AMIPLUGDCCATTR_IsStalled,            /* [SR.] ULONG: transfer stalled? */
  494.     AMIPLUGDCCATTR_IsSecure,            /* [..C] ULONG: encrypted SCHAT? */
  495.     AMIPLUGDCCATTR_UserData,            /* [..C] ULONG*: Pointer (!) to Userdata */
  496. };
  497.  
  498.  
  499. /* [V11]
  500. ** amiplug_getchanattr() can be used to get various information
  501. ** about a channel. Returns FALSE if the channel could not be
  502. ** found or the attribute was invalid.
  503. */
  504.  
  505. enum {
  506.     AMIPLUGCHANATTR_first = 4096,
  507.     AMIPLUGCHANATTR_Modes,                /* LONGBITS: channel modes (CMF_ defines) */
  508.     AMIPLUGCHANATTR_Keyword,            /* STRPTR: channel keyword */
  509.     AMIPLUGCHANATTR_Userlimit,            /* ULONG: channel user limit */
  510.     AMIPLUGCHANATTR_CurrentStatus,        /* ULONG: status on channel, 0 = nothing, 1 = op, 2 = voice */
  511.  
  512.     /* [V14] */
  513.     AMIPLUGCHANATTR_Topic,                /* STRPTR: channel topic */
  514. };
  515.  
  516.  
  517. /*
  518. ** holds your plugin's custom preference page information
  519. ** A pointer to this structure, which is already allocated for you 
  520. ** by AmIRC, is passed to the AMIPLUG_Hook_Prefs() function.
  521. */
  522. struct amiplug_prefs {
  523.     char *label;            /* list item label, defaults to plugin name */
  524.     struct BitMap *bitmap;    /* 24x14 list icon bitmap, defaults to plugin image */
  525.     APTR colormap;            /* bitmap's colormap, defaults to MWB palette (8 col.) */
  526.     APTR object;            /* preferences object */
  527.     ULONG reserved[8];        /* reserved for future expansion, don't touch */
  528. }; // size: 48
  529.  
  530. /* [V12]
  531. ** These are the methods you are expected to handle in _Hook_Prefs()
  532. ** whenever AmIRC wants to know or do stuff with your prefs.
  533. ** The description of the method id is what AmIRC expects you to
  534. ** do or what to return when it is requested.
  535. */
  536. enum {
  537.     AMIPLUGPREFS_first = 16384,
  538.  
  539.     /* Setup stuff
  540.        Do whatever setup you need to do during this method. This can be eg.
  541.        setting default prefs, filling the prefs structure with the prefs
  542.        label, bitmap and colormap, etc. This method is called only once,
  543.        directly after AMIPLUG_Setup() (or AMIPLUG_FinalSetup() if you have
  544.        one).
  545.     */
  546.     AMIPLUGPREFS_Setup,
  547.  
  548.  
  549.     /* Cleanup stuff
  550.        This method is performed only once, just before AMIPLUG_Cleanup().
  551.     */
  552.     AMIPLUGPREFS_Cleanup,
  553.  
  554.     /* Create prefsobject.
  555.        You should create your prefs object here and put that in prefs->object.
  556.        Don't check for success, AmIRC will do that for you and perform an
  557.        AMIPLUGPREFS_Dispose if anything went wrong. If you specify NULL as
  558.        bitmap pointer, AmIRC will use the default (plugin) image and colormap
  559.        for the list entry. Note: Make sure your prefs object is sizable in all
  560.        directions or you'll annoy your user!
  561.        Note: You could also set up the label, bitmap, etc, here instead of
  562.        _Setup, as they only need to be valid between _Create and _Dispose.
  563.     */
  564.     AMIPLUGPREFS_Create,
  565.  
  566.     /* You should dispose of the prefsobject during this method.
  567.        You don't NEED to dispose, ie. you can let your object linger around
  568.        if you wish, but it's better to dispose it though. If you don't dispose
  569.        your stuff, then don't forget to get rid of it during the _Cleanup
  570.        method!
  571.     */
  572.     AMIPLUGPREFS_Dispose,
  573.  
  574.     /* Take settings from prefsobject and make those the new current
  575.        settings. This method is performed when the user wants to let his/her
  576.        changes take effect.
  577.     */
  578.     AMIPLUGPREFS_Use,
  579.  
  580.     /* Load preferences, and make those the new current settings.
  581.        Beware: Do NOT use the prefs object for this! Don't update or check
  582.        its status, just LOAD the prefs and let THOSE prefs take effect.
  583.        This method is (also) performed after AMIPLUGPREFS_Setup method!
  584.     */
  585.     AMIPLUGPREFS_Load,
  586.  
  587.     /* Save preferences. You should save the current settings during
  588.        this method. Again, don't use the settings in the prefs object,
  589.        just save the currently used settings.
  590.     */
  591.     AMIPLUGPREFS_Save,
  592. };
  593.  
  594.  
  595. /* ModeFlags for AMIPLUGCHANATTR_Modes */
  596.  
  597. #define CMF_T   1    /* Topic protection */
  598. #define CMF_N   2    /* No messaging */
  599. #define CMF_S   4    /* Secret */
  600. #define CMF_I   8    /* Invite-Only */
  601. #define CMF_P  16    /* Private */
  602. #define CMF_M  32    /* Moderated */
  603. #define CMF_L  64    /* user Limit */
  604. #define CMF_K 128    /* Keyword protected */
  605.  
  606.  
  607. /*
  608. ** Color codes for text output functions.
  609. ** These correspond to user defined settings.
  610. */
  611. enum AMIRC_TEXTCOLS {
  612.     amirc_tc_normal = 0,
  613.     amirc_tc_highlite,
  614.     amirc_tc_private,
  615.     amirc_tc_server,
  616.     amirc_tc_mode,
  617.     amirc_tc_dcc,
  618.     amirc_tc_local
  619. };
  620.  
  621. /*
  622. ** Alias and Ignore lists are build of these nodes
  623. ** If you add your own, use amiplug_malloc() to
  624. ** obtain the memory, extending "string" to fit
  625. ** the string length, including (!) the zero terminator.
  626. */
  627. struct amirc_stringnode {
  628.     struct MinNode n;
  629.     char string[ 0 ];
  630. };
  631.  
  632. /*
  633. ** Structure used for Ignorelist. This may
  634. ** be subject for change in later versions.
  635. ** If you add your own, use amiplug_malloc() to
  636. ** obtain the memory, extending "string" to fit
  637. ** the string length, including (!) the zero terminator.
  638. */
  639. struct amirc_ignorenode {
  640.     struct MinNode n;
  641.     ULONG what;
  642.     ULONG count;
  643.     ULONG transient;
  644.     char userhost[ 0 ];
  645. };
  646. #define IGNF_TEXT 1
  647. #define IGNF_PRIV 2
  648. #define IGNF_CTCP 4
  649.  
  650. /*
  651. ** amiplug_getserver() returns a mcc_listtree object.
  652. ** tn_user of the treenodes of this object point to
  653. ** the following structure:
  654. */
  655.  
  656. struct amirc_server {
  657.     char name[á128 ];        // Internet hostname
  658.     char comment[ 76 ];        // Some info
  659.     char password[á32 ];    // Optional password
  660.     ULONG port;                // Port to connect to
  661.     char autojoin[á128 ];    // Channels to join
  662. };    
  663.  
  664. /*
  665. ** DCC states
  666. */
  667.  
  668. /* Receive */
  669. #define DCCRS_WAITING 0
  670. #define DCCRS_CONNECTING 1
  671. #define DCCRS_RECEIVING 2
  672. #define DCCRS_COMPLETE 3
  673. #define DCCRS_FAILED 4
  674. #define DCCRS_NOCONNECT 5
  675. #define DCCRS_ABORTED 6
  676. #define DCCRS_NOSOCK 7
  677. #define DCCRS_NOHOST 8
  678. #define DCCRS_NOFILE 9
  679. #define DCCRS_WRITEERROR 10
  680.  
  681. /* Chat */
  682. #define DCCCS_WAITING 0
  683. #define DCCCS_CONNECTING 1
  684. #define DCCCS_CONNECTED 2
  685. #define DCCCS_WAITINGFOR 3
  686. #define DCCCS_CLOSED 4
  687. #define DCCCS_NOCONNECT 5
  688. #define DCCCS_NOSOCK 6
  689. #define DCCCS_ABORTED 7
  690.  
  691. /* Send */
  692. #define DCCSS_WAITINGFOR 0
  693. #define DCCSS_ABORTED 1
  694. #define DCCSS_SENDING 2
  695. #define DCCSS_COMPLETE 3
  696. #define DCCSS_FAILED 4
  697. #define DCCSS_NOSOCK 5
  698. #define DCCSS_NOFILE 6
  699. #define DCCSS_READERROR 7
  700. #define DCCSS_CALCCHECK 8
  701.  
  702.  
  703. /*
  704. ** All hook functions also receives a pointer to a table of
  705. ** functions which the plugin can call to have AmIRC perform
  706. ** certain operations. *NOTE* You *MUST NOT* store this
  707. ** function pointer globally, as it will be a different
  708. ** table for every new opener of the plugin library.
  709. ** If you use SAS/C, you can use libinitr.o to have
  710. ** the compiler create a new data segment for every
  711. ** opener; this also allows you to use global
  712. ** variables in the code easily.
  713. **
  714. ** Note that all functions have to follow register
  715. ** calling conventions.
  716. **
  717. ** The table also contains (hidden) context information,
  718. ** so it's necessary to pass it back to most of the functions
  719. ** you can call. Confusing? Nah :)
  720. **
  721. */
  722.  
  723. struct amiplug_functable {
  724.         int             amiplug_functabversion;
  725.  
  726.         /* Send raw data to the server */
  727.         int (PLFUNC * amiplug_sendraw)                  
  728.                 ( _reg(a0) struct amiplug_functable *ctx, _reg(a1) APTR data, _reg(d0) ULONG len );       
  729.  
  730.         /* find the user@host for a given nick */
  731.         char * (PLFUNC *amiplug_findnickuserhost)
  732.                 ( _reg(a0) struct amiplug_functable *ctx, _reg(a1) STRPTR nick );
  733.  
  734.         /* like findnickuserhost, but will print a warning message
  735.         if the userhost can't be found */
  736.         char * (PLFUNC *amiplug_findnickuserhost_warn)
  737.                 ( _reg(a0) struct amiplug_functable *ctx, _reg(a1) STRPTR nick );
  738.  
  739.         /* The following functions are for outputting text to
  740.            any of the AmIRC windows */
  741.         /* Default window */
  742.         void (PLFUNC *amiplug_out_defwin)
  743.                 ( _reg(a0) struct amiplug_functable *ctx, _reg(d0) int color, _reg(a1) STRPTR prefix, _reg(a2) STRPTR txt );
  744.  
  745.         /* Output to a query window, if it exists, otherwise def window */
  746.         void (PLFUNC *amiplug_out_userwin)
  747.                 ( _reg(a0) struct amiplug_functable *ctx, _reg(d0) int color, _reg(a1) STRPTR prefix, _reg(a2) STRPTR txt, _reg(a3) STRPTR nick );
  748.  
  749.         /* Output to a channel window, if it exists, otherwise def window */
  750.         void (PLFUNC *amiplug_out_channelwin)
  751.                 ( _reg(a0) struct amiplug_functable *ctx, _reg(d0) int color, _reg(a1) STRPTR prefix, _reg(a2) STRPTR txt, _reg(a3) STRPTR channel );
  752.  
  753.         /* Get a pointer to the MUI userlist object of a certain channel */
  754.         APTR (PLFUNC *amiplug_getuserlv)
  755.                 ( _reg(a0) struct amiplug_functable *ctx, _reg(a1) STRPTR channel );
  756.  
  757.         /* Get some information from various AmIRC states. See
  758.            AMIPLUGATTR_ definitions above */
  759.         int (PLFUNC *amiplug_getattr)
  760.                 ( _reg(a0) struct amiplug_functable *ctx, _reg(d0) ULONG attrid, _reg(a1) APTR storage );
  761.  
  762.         /* Execute "line" as if the user entered it in the default
  763.            window. Similiar to AmIRC's "SAY" Rexx command. Returns FALSE
  764.            if the line couldn't be executed for some reason, TRUE otherwise */
  765.         int (PLFUNC *amiplug_say)
  766.                 ( _reg(a0) struct amiplug_functable *ctx, _reg(a1) STRPTR line );
  767.  
  768.         /* Play either a vanilla sound file or a event sound (if soundfile is NULL) */
  769.         int (PLFUNC *amiplug_playsound)
  770.                 ( _reg(a0) struct amiplug_functable *ctx, _reg(a1) STRPTR soundfile, _reg(d0) ULONG event );
  771.  
  772.         /* Add a DCC send request. Returns ID. method is 0 for DCC SEND,
  773.            1 for DCC MOVE. delay is in ticks, before the DCC offer is
  774.            send to the nick
  775.         */
  776.         ULONG (PLFUNC *amiplug_adddcc_send)
  777.                 ( _reg(a0) struct amiplug_functable *ctx, 
  778.                   _reg(a1) STRPTR nick ,
  779.                   _reg(a2) STRPTR filename,
  780.                   _reg(d0) ULONG method,
  781.                   _reg(d1) ULONG delay
  782.         );
  783.  
  784.         /* Add a DCC receive request. ip and port show where
  785.            to connect to, "ismove" specifies whether this
  786.            is a DCC MOVE instead of a DCC SEND, "fileexists"
  787.            specifies the amount of "filename" already
  788.            there (locally), "isturbo" flags whether this is
  789.            a (PIRCH) TSEND, DCC SEND without ACKs. Returns
  790.            the DCC ID.
  791.         */
  792.         ULONG (PLFUNC *amiplug_adddcc_recv)
  793.                 ( _reg(a0) struct amiplug_functable *ctx, 
  794.                   _reg(a1) STRPTR nick ,
  795.                   _reg(a2) STRPTR filename,
  796.                   _reg(d0) ULONG len,
  797.                   _reg(d1) ULONG ip,
  798.                   _reg(d2) ULONG port,
  799.                   _reg(d3) ULONG ismove,
  800.                   _reg(d4) ULONG fileexists,
  801.                   _reg(d5) ULONG isturbo
  802.         );
  803.         /* Add a DCC CHAT request to "nick". */
  804.         ULONG (PLFUNC *amiplug_adddcc_chat)
  805.                 ( _reg(a0) struct amiplug_functable *ctx, 
  806.                   _reg(a1) STRPTR nick ,
  807.                   _reg(d0) ULONG secure
  808.         );
  809.  
  810.         /* Get some information about a DCC connection. Returns
  811.            FALSE if the DCCID could not be found, or the attribute
  812.            was invalid. See AMIPLUGDCCATTR_ definitions above */
  813.         int (PLFUNC *amiplug_dccgetattr)
  814.                 ( _reg(a0) struct amiplug_functable *ctx, 
  815.                   _reg(d0) ULONG dccid,
  816.                   _reg(d1) ULONG attrid,
  817.                   _reg(a1) APTR storage
  818.         );
  819.  
  820.         /* Abort DCC connection */
  821.         int (PLFUNC *amiplug_dccabort)
  822.             ( _reg(a0) struct amiplug_functable *ctx, 
  823.               _reg(d0) ULONG dccid
  824.         );
  825.  
  826.         APTR userdata; /* Do with that whatever you want */
  827.  
  828.         /* Allocate some memory from AmIRC internal
  829.            pools. Used to manipulate Alias/Hilite/Ignorelists */
  830.         APTR (PLFUNC *amiplug_malloc)
  831.                 ( _reg(a0) struct amiplug_functable *ctx, 
  832.                   _reg(d0) ULONG size
  833.         );
  834.  
  835.         /* Get a string from the internal catalog */
  836.         STRPTR (PLFUNC *amiplug_getstring)
  837.                 ( _reg(a0) struct amiplug_functable *ctx, 
  838.                   _reg(d0) ULONG stringid
  839.         );
  840.  
  841.         /* Queue a line into AmIRC's throttled output queue */
  842.         void (PLFUNC *amiplug_queueline)
  843.                 ( _reg(a0) struct amiplug_functable *ctx, 
  844.                   _reg(a1) STRPTR line
  845.         );
  846.  
  847.         /* Return pointer to the server list Listtree object */
  848.         APTR (PLFUNC *amiplug_getserver)( void );
  849.  
  850.         /* Return pointer to AmIRC exe name (including path) */
  851.         STRPTR (PLFUNC *amiplug_getexename)( void );
  852.  
  853.         /* V10 */
  854.  
  855.         /* Send off a rexx command to REXX. Doesn't wait for reply */
  856.         void (PLFUNC *amiplug_sendrxmsg)
  857.                 ( _reg(a0) struct amiplug_functable *ctx, 
  858.                   _reg(a1) STRPTR cmd
  859.         );
  860.  
  861.  
  862.         /* V11 */
  863.  
  864.         /* Get information about a channel. Returns FALSE if channel
  865.            could not be found or the attribute was invalid */
  866.         int (PLFUNC *amiplug_getchanattr)
  867.             ( _reg(a0) struct amiplug_functable *ctx,
  868.               _reg(a1) STRPTR channel,
  869.               _reg(d0) ULONG attrid,
  870.               _reg(a2) APTR storage
  871.         );
  872.  
  873.  
  874.         /* V13 */
  875.  
  876.         /* Free memory allocated by amiplug_malloc() */
  877.         void (PLFUNC *amiplug_free)
  878.             ( _reg(a0) APTR what );
  879.  
  880.         /* Send a line via a DCC chat connection. A newline
  881.            character ('\n') will be appended.
  882.            Note: be careful when using this function on a chat
  883.            connection with yourself :^) */
  884.         int (PLFUNC *amiplug_senddccmsg)
  885.             ( _reg(d0) ULONG dccid,
  886.               _reg(a0) STRPTR line
  887.         );
  888.  
  889.         /* Push a rawline into input stream. Line is copied to a
  890.            private buffer and treated as if it was received from
  891.            the server the next time AmIRC reads lines from the
  892.            server. The line MUST NOT end with or contain "\r\n".
  893.            Returns FALSE if the push failed. Warning: Know what
  894.            you're doing! Be sure not to mess up AmIRC's internal
  895.            processing with this function.
  896.         */
  897.         int (PLFUNC *amiplug_fakerawline)
  898.             ( _reg(a0) STRPTR line, _reg(d0) LONGBITS flags );
  899.  
  900.  
  901.         /* V14 */
  902.  
  903.         /* Output to Info window */
  904.         void (PLFUNC *amiplug_out_infowin)
  905.                 ( _reg(d0) int color, _reg(a0) STRPTR prefix, _reg(a1) STRPTR txt );
  906.  
  907.         APTR context; /* ***PRIVATE!!! DO NOT TOUCH!!!*** */
  908.  
  909. };
  910.  
  911. #define AMIPLUG_FUNCTAB_VERSION 14
  912.  
  913.  
  914. /*
  915. ** Flags for amiplug_fakerawline()
  916. ** (default action is to queue the line after the other queued fakes)
  917. */
  918.  
  919. #define FRLF_PUSH    1    // Line is inserted BEFORE the other fakes
  920.  
  921.  
  922. /*
  923. ** Library defintions
  924. */
  925.  
  926. #ifndef BUILDPLUGIN
  927.  
  928. #ifndef __STORM__
  929.  
  930. #ifndef NO_PRAGMAS
  931. #pragma libcall classlib AMIPLUG_Setup                1e       801
  932. #pragma libcall classlib AMIPLUG_Cleanup            24       801
  933. #pragma libcall classlib AMIPLUG_Hook_Rawline        2a     09803
  934. #pragma libcall classlib AMIPLUG_Hook_NumericMsg    30 C1BA09807
  935. #pragma libcall classlib AMIPLUG_DoCommand            36     90803
  936. #pragma libcall classlib AMIPLUG_DoMenu                3c     90803
  937. #pragma libcall classlib AMIPLUG_Hook_DCC            42      0802
  938. #pragma libcall classlib AMIPLUG_DoCTCP                48   BA90805
  939. #pragma libcall classlib AMIPLUG_FinalSetup            4e       801
  940. #pragma libcall classlib AMIPLUG_Hook_Input            54     09803
  941. #pragma libcall classlib AMIPLUG_DoRexx                5a    A90804
  942. #pragma libcall classlib AMIPLUG_Hook_Prefs            60     90803
  943. #pragma libcall classlib AMIPLUG_Hook_DCCChat        66   1A90805
  944. #endif
  945.  
  946. #else
  947.  
  948. #pragma libbase Library;
  949.  
  950. #endif
  951.  
  952. #ifndef NO_PROTOS
  953. struct TagItem *AMIPLUG_Setup    ( struct amiplug_functable *ctx );
  954. void  AMIPLUG_Cleanup            ( struct amiplug_functable *ctx );
  955.  int  AMIPLUG_Hook_Rawline        ( struct amiplug_functable *ctx, STRPTR line, ULONG len );
  956.  int  AMIPLUG_Hook_NumericMsg    ( struct amiplug_functable *ctx, STRPTR line, ULONG numericcode, STRPTR prefix, STRPTR dest, ULONG numargs, STRPTR *args );
  957. void  AMIPLUG_DoCommand            ( struct amiplug_functable *ctx, ULONG commandid, struct amiplug_cmdparm *parmpacket );
  958. void  AMIPLUG_DoMenu            ( struct amiplug_functable *ctx, ULONG commandid, APTR muiapp );
  959. void  AMIPLUG_Hook_DCC            ( struct amiplug_functable *ctx, ULONG dccid );
  960. void  AMIPLUG_DoCTCP            ( struct amiplug_functable *ctx, ULONG commandid, STRPTR from, STRPTR rest, STRPTR to );
  961. void  AMIPLUG_FinalSetup        ( struct amiplug_functable *ctx );
  962. char *AMIPLUG_Hook_Input        ( struct amiplug_functable *ctx, STRPTR string, ULONG len );
  963.  int  AMIPLUG_DoRexx            ( struct amiplug_functable *ctx, ULONG commandid, STRPTR *args, APTR muiapp );
  964. void  AMIPLUG_Hook_Prefs        ( struct amiplug_functable *ctx, ULONG methodid, struct amiplug_prefs *prefs );
  965.  int  AMIPLUG_Hook_DCCChat        ( struct amiplug_functable *ctx, ULONG dccid, STRPTR nick, STRPTR line, ULONG len );
  966. #endif
  967.  
  968. #endif
  969.  
  970. #endif
  971.