home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD1.iso / FileMover / HF-OM1.DMS / in.adf / OpusSDK.lha / SDK / docs / modules.doc < prev    next >
Encoding:
Text File  |  1997-02-25  |  21.6 KB  |  480 lines

  1.  
  2.                                Directory Opus 5
  3.  
  4.                           External Module Definition
  5.  
  6.  
  7.  
  8. CONTENTS
  9.  
  10. 1. Introduction
  11. 2. Main module entry point
  12. 3. Second module entry point
  13. 4. Module identification
  14. 5. Function definitions
  15. 6. Standard startup code
  16. 7. Module callback function
  17.  
  18.  
  19. 1. Directory Opus 5 supports two types of "external modules". This document
  20. describes the main type, an AmigaDos library file. The other type, ARexx
  21. modules, are described in the main Opus 5 documentation.
  22.  
  23.     Library-based modules are located in the DOpus5:Modules/ directory, and
  24. are identified by the ".module" suffix. They are standard AmigaDos libraries,
  25. with two compulsory entry points. They main contain any other entry points you
  26. want, but the first two are required to work with Opus.
  27.  
  28.     The example code supplied with the SDK illustrates how to create an Opus
  29. module. While the supplied code is designed for SAS/C, it would be easy to
  30. adapt it to any other C compiler.
  31.  
  32.  
  33. 2. The main entry point to the module is a function called Module_Entry().
  34. The prototype for this function is as follows:
  35.  
  36.         long Module_Entry(  register __a0 char *args,
  37.                             register __a1 struct Screen *screen,
  38.                             register __a2 IPCData *ipc,
  39.                             register __a3 IPCData *mainipc,
  40.                             register __d0 ULONG mod_id,
  41.                             register __d1 EXT_FUNC(callback)  );
  42.  
  43.     This function must be at offset -0x1e in the library, and take parameters
  44. in the specified registers.
  45.  
  46.     You should never call this function yourself; it is called by Opus when
  47. the user runs one of the commands in your module. The parameters to the
  48. Module_Entry() function are as follows:
  49.  
  50.         args     - null-terminated argument string, contains any arguments the
  51.                    user supplied for the command
  52.  
  53.         screen   - main Opus screen pointer, you should open any requesters
  54.                    on this screen
  55.  
  56.         ipc      - a pointer to your IPCData structure - Opus launches each
  57.                    module command as a new process
  58.  
  59.         mainipc  - a pointer to the main IPCData structure for Opus
  60.  
  61.         mod_id   - the ID code of the command selected by the user
  62.  
  63.         callback - address of Opus callback function (see below)
  64.  
  65.  
  66. 3. The second entry point is a function that the module uses to identify
  67. itself. When Opus starts up it scans the contents of the modules directory,
  68. and calls this function in each of the modules.
  69.  
  70.     The standard modinit.o module startup code supplies this function for you.
  71. It is not recommended that you change it. If you need to supply your own
  72. function, the prototype is as follows :
  73.  
  74.         APTR Module_Identify(  register __d0 long num  );
  75.  
  76.     This function must be at offset -0x24 in the library. "num" is the command
  77. ID number that Opus is enquiring about. If "num" is equal to -1, you must
  78. return a pointer to the ModuleInfo structure for the module. If "num" is equal
  79. to a valid command ID code, you must return a pointer to a description string
  80. for that command. If "num" is an invalid value, you must return 0.
  81.  
  82.  
  83. 4. The contents of the module are identified with a ModuleInfo structure. All
  84. fields of the ModuleInfo structure must be initialised. The meaning of the
  85. fields is as follows:
  86.  
  87.         ver            - Module version number (for your own use)
  88.         name           - pointer to module name, including ".module" suffix
  89.         locale_name    - name of locale catalog for the module. This is opened
  90.                          automatically by the standard modinit.o startup code,
  91.                          which you should use.
  92.         flags          - Module flags, see below
  93.         function_count - The number of functions in this module
  94.         function       - The definition of the first function
  95.  
  96.     Module flag values (for the "flags" field) are as follows:
  97.  
  98.         MODULEF_CALL_STARTUP    - If this flag is specified, Opus will run
  99.                                   your module automatically on startup, with
  100.                                   the special "mod_id" value of FUNCID_STARTUP
  101.  
  102.         MODULEF_STARTUP_SYNC    - If MODULEF_CALL_STARTUP is also specified,
  103.                                   this flag causes Opus to wait for your
  104.                                   module to return from the startup call before
  105.                                   continuing
  106.  
  107.         MODULEF_CATALOG_VERSION - If this flag is set, Opus will use the "ver"
  108.                                   field to check that the locale catalog for
  109.                                   this module is the correct version.
  110.  
  111.         MODULEF_HELP_AVAILABLE  - If this flag is set, Opus will look for an
  112.                                   AmigaGuide help file (in dopus5:help/) to
  113.                                   show help for the commands in this module.
  114.                                   The name of the help file is taken from the
  115.                                   'name' field of the ModuleInfo structure,
  116.                                   with the '.module' suffix replaced by
  117.                                   '.guide'
  118.  
  119.     The ModuleInfo structure contains room for only one function definition.
  120. If your module contains more than one function, the additional ModuleFunction
  121. structures MUST follow the ModuleInfo structure in memory. You must provide as
  122. many ModuleFunction structures are were specified in the "function_count"
  123. field of the ModuleInfo structure. For example,
  124.  
  125.         // Module definition, includes first function
  126.         ModuleInfo
  127.             module_info={
  128.                 1,                  // Version
  129.                 "example.module",   // Module name
  130.                 "example.catalog",  // Catalog name
  131.                 0,                  // Flags
  132.                 2,                  // Number of functions
  133.                 {0,"Example1",MSG_EXAMPLE1_DESC,0,0}};
  134.  
  135.         // Second function definition follows immediately on
  136.         ModuleFunction
  137.             module_func_2={
  138.                  1,"Example2",MSG_EXAMPLE2_DESC,0,0};
  139.  
  140.  
  141.  
  142. 5. The ModuleFunction structure is used to define each command that the
  143. module provides. The first function is defined with a ModuleFunction structure
  144. embedded in the ModuleInfo; additional commands must be defined after that.
  145. All fields of the ModuleFunction structure must be initialised, as follows:
  146.  
  147.         id        - command ID code. This value is passed as the "mod_id"
  148.                     parameter to the Module_Entry() function
  149.  
  150.         name      - name of the function. This is the actual command name
  151.                     that will be used to invoke this command
  152.  
  153.         desc      - locale string ID for the function description. This is the
  154.                     ID of the string in the catalog for this module that is
  155.                     used to describe this command in the popup command list.
  156.  
  157.         flags     - command flags, see below
  158.  
  159.         template  - command template (in ReadArgs() format). This string is
  160.                     displayed in the popup argument list in Opus function
  161.                     editors, but is not actually parsed by Opus. You will
  162.                     need to use the ParseArgs() routine on the "args"
  163.                     parameter in the Module_Entry() function.
  164.  
  165.     ModuleFunction flags are as follows:
  166.  
  167.         FUNCF_NEED_SOURCE    - set if your module requires a valid source
  168.                                directory - if one is not available, your
  169.                                command will not be launched
  170.  
  171.         FUNCF_NEED_DEST      - set if your module requires a valid destination
  172.                                directory
  173.  
  174.         FUNCF_NEED_FILES     - set if you need there to be selected files
  175.  
  176.         FUNCF_NEED_DIRS      - set if you need selected directories
  177.  
  178.         FUNCF_CAN_DO_ICONS   - set if you can operate on icons as well as
  179.                                normal files/directories
  180.  
  181.         FUNCF_SINGLE_SOURCE  - set if you can only operate on a single source
  182.                                lister
  183.  
  184.         FUNCF_SINGLE_DEST    - set if you can only operate on a single
  185.                                destination lister
  186.  
  187.         FUNCF_WANT_DEST      - set if you want a destination directory, but
  188.                                don't require one
  189.  
  190.         FUNCF_WANT_SOURCE    - set if you want a source directory, but don't
  191.                                require one
  192.  
  193.         FUNCF_WANT_ENTRIES   - set in conjunction with FUNCF_NEED_FILES or
  194.                                FUNCF_NEED_DIRS, to specify that you want those
  195.                                items but don't require them
  196.  
  197.         FUNCF_PRIVATE        - the function is private, it won't show up in
  198.                                the popup command list
  199.  
  200.  
  201. 6. It is highly recommended that you link with the standard module startup
  202. code (modinit.o) when creating modules. This code contains the
  203. Module_Identify() function, and automatically initialises several library bases
  204. which you may need. See the <dopus/modules.h> file for more information on
  205. this file.
  206.  
  207.  
  208. 7. The "callback" parameter to the Module_Entry() function provides the
  209. address of a callback function within Opus. This function allows you to access
  210. information that your module command may need. The callback function is
  211. defined as follows:
  212.  
  213.         ULONG callback(     register __d0 ULONG command,
  214.                             register __a0 APTR handle,
  215.                             register __a1 APTR packet   );
  216.  
  217.         command     - the callback command, see below for the list
  218.  
  219.         handle      - the callback handle. You must pass the value of
  220.                       IPCDATA(ipc) for this parameter ("ipc" is the argument
  221.                       passed to the Module_Entry() function)
  222.  
  223.         packet      - a command-specific packet
  224.  
  225.     Following is the list of callback commands. Each command takes a packet
  226. specific to it.
  227.  
  228.  
  229.         Command : EXTCMD_GET_SOURCE
  230.         Purpose : Returns the current source path
  231.         Packet  : char path[256]
  232.         Returns : struct path_node *path
  233.         Notes   : The packet is a pointer to a 256 character buffer, into
  234.                   which the current source path will be copied. The return
  235.                   value is a pointer to a path_node structure, which can be
  236.                   used with other callback commands. This structure is
  237.                   READ ONLY!
  238.  
  239.         Command : EXTCMD_END_SOURCE
  240.         Purpose : Finishes and cleans up current source path
  241.         Packet  : Set to 0
  242.         Returns : <none>
  243.         Notes   : Call this command if you are aborting early and do not
  244.                   wish to process further source paths.
  245.  
  246.         Command : EXTCMD_NEXT_SOURCE
  247.         Purpose : Gets the next source path
  248.         Packet  : char path[256]
  249.         Returns : struct path_node *path
  250.         Notes   : Call this command when you have finished with the first
  251.                   source path and want to move onto the next one. The
  252.                   return value is NULL if there are no more source paths.
  253.  
  254.         Command : EXTCMD_UNLOCK_SOURCE
  255.         Purpose : Unlock source listers
  256.         Packet  : <none>
  257.         Returns : <none>
  258.         Notes   : When your module command is called, any source listers
  259.                   are locked automatically. Call this command when you want
  260.                   to unlock them (they are unlocked automatically when
  261.                   your module returns).
  262.  
  263.         Command : EXTCMD_GET_DEST
  264.         Purpose : Returns the next destination path
  265.         Packet  : char path[256]
  266.         Returns : struct path_node *path
  267.         Notes   : The packet is a pointer to a 256 character buffer, into
  268.                   which the current destination path will be copied. The
  269.                   return value is a handle to the path, which can be used with
  270.                   other callback commands. Call this command repeatedly to
  271.                   move through the destination paths. When all the destination
  272.                   paths have been used, this command will return NULL. If you
  273.                   call this command again, it will will start again with the
  274.                   first destination path.
  275.  
  276.         Command : EXTCMD_END_DEST
  277.         Purpose : Ends the current destination path
  278.         Packet  : FALSE to abort, TRUE to continue
  279.         Returns : <none>
  280.         Notes   : You must call this command when you have finished with one
  281.                   destination path, prior to calling EXTCMD_GET_DEST.
  282.  
  283.         Command : EXTCMD_GET_ENTRY
  284.         Purpose : Get the next entry to work with
  285.         Packet  : <none>
  286.         Returns : struct function_entry {
  287.                     struct MinNode      node;   // Node
  288.                     char                *name;  // File name
  289.                     APTR                entry;  // Not used
  290.                     short               type;   // Type; <0 = file, >0 = dir
  291.                     short               flags;  // Not used
  292.                   };
  293.         Notes   : This returns a pointer to the next entry in the current
  294.                   source path. This structure is READ ONLY! Use the "name"
  295.                   field to get the entry name.
  296.  
  297.         Command : EXTCMD_END_ENTRY
  298.         Purpose : Finish with specific entry
  299.         Packet  : struct endentry_packet {
  300.                     struct function_entry   *entry;     // Entry to end
  301.                     BOOL                    deselect;   // TRUE for deselect
  302.                   };
  303.         Returns : <none>
  304.         Notes   : Call this command when you have finished working with one
  305.                   entry and wish to move on to the next. "entry" must be set
  306.                   to the pointer that was returned by EXTCMD_GET_ENTRY.
  307.                   Set "deselect" to TRUE to have the entry deselected in the
  308.                   lister.
  309.  
  310.         Command : EXTCMD_RELOAD_ENTRY
  311.         Purpose : Marks an entry to be reloaded
  312.         Packet  : struct function_entry *entry;
  313.         Returns : <none>
  314.         Notes   : This command marks the specified entry to be reloaded.
  315.                   When the function finishes, the entry will be reloaded to
  316.                   update any changes that your module might have made to
  317.                   it.
  318.  
  319.         Command : EXTCMD_REMOVE_ENTRY
  320.         Purpose : Marks an entry to be reloaded
  321.         Packet  : struct function_entry *entry;
  322.         Returns : <none>
  323.         Notes   : This command marks the specified entry to be removed.
  324.                   When the function finishes, the entry will be removed
  325.                   from the lister it is in.
  326.  
  327.         Command : EXTCMD_ENTRY_COUNT
  328.         Purpose : Returns total count of entries
  329.         Packet  : <none>
  330.         Returns : long entry_count;
  331.         Notes   : Returns the number of selected entries for the function.
  332.  
  333.         Command : EXTCMD_ADD_FILE
  334.         Purpose : Adds a file to a lister
  335.         Packet  : struct addfile_packet {
  336.                     char                 *path;     // Path to add file to
  337.                     struct FileInfoBlock *fib;      // FileInfoBlock to add
  338.                     APTR                 lister;    // Lister pointer
  339.                   };
  340.         Returns : <none>
  341.         Notes   : Allows you to add a file or directory to a lister. The path
  342.                   field points to the full path of the file to add. fib is an
  343.                   initialised FileInfoBlock which is used to create the file
  344.                   entry. The lister pointer is found in the path_node
  345.                   structure, which is obtained via a call to EXTCMD_GET_SOURCE
  346.                   or EXTCMD_GET_DEST. The display is not updated until you
  347.                   call EXTCMD_DO_CHANGES, or your function returns.
  348.  
  349.         Command : EXTCMD_DEL_FILE
  350.         Purpose : Delete a file from a lister
  351.         Packet  : struct delfile_packet {
  352.                     char    *path;      // Path file is in
  353.                     char    *name;      // Filename to delete
  354.                     APTR    lister;     // Lister pointer
  355.                   };
  356.         Returns : <none>
  357.         Notes   : This removes the specified file from any listers it is
  358.                   current shown in. The file itself is not deleted, only the
  359.                   display of it in the lister. The display is not updated
  360.                   until you call EXTCMD_DO_CHANGES, or your function returns.
  361.  
  362.         Command : EXTCMD_LOAD_FILE
  363.         Purpose : Load a new file in a lister
  364.         Packet  : struct loadfile_packet {
  365.                     char    *path;      // Path file is in
  366.                     char    *name;      // Name of file
  367.                     short   flags;      // Flags
  368.                     short   reload;     // Reload existing file
  369.                   };
  370.         Returns : <none>
  371.         Notes   : This command is similar to EXTCMD_ADD_FILE except that it
  372.                   Examines() the file and supplies the FileInfoBlock
  373.                   automatically. 'path' is the full path of the file and
  374.                   'name' is the file name. The only valid flag at this time
  375.                   is LFF_ICON, which indicates that the icon (.info) of the
  376.                   supplied file is to be loaded instead of the file itself.
  377.                   If 'reload' is set to TRUE, an existing file will be
  378.                   reloaded (ie the old entry in the lister will be removed).
  379.  
  380.         Command : EXTCMD_DO_CHANGES
  381.         Purpose : Perform file changes in listers
  382.         Packet  : <none>
  383.         Returns : <none>
  384.         Notes   : This command causes any changes made to listers by the
  385.                   EXTCMD_ADD_FILE, EXTCMD_DEL_FILE and EXTCMD_LOAD_FILE
  386.                   commands to be displayed. If your function returns without
  387.                   calling this command, the changes are displayed
  388.                   automatically.
  389.  
  390.         Command : EXTCMD_CHECK_ABORT
  391.         Purpose : Check abort status in lister
  392.         Packet  : <undefined>
  393.         Returns : BOOL
  394.         Notes   : This command returns TRUE if your 'function' has been
  395.                   aborted by the user. This could have occurred because the
  396.                   user pressed escape or clicked the close button on a lister,
  397.                   or quit the program.
  398.  
  399.         Command : EXTCMD_GET_WINDOW
  400.         Purpose : Get a lister's window pointer
  401.         Packet  : struct path_node *path
  402.         Returns : struct Window *window
  403.         Notes   : Returns a pointer to the Window for the lister specified by
  404.                   the path_node structure. This is useful if you want to open
  405.                   a requester over a lister window.
  406.  
  407.         Command : EXTCMD_GET_HELP
  408.         Purpose : Get help on a topic
  409.         Packet  : char *topic
  410.         Returns : <none>
  411.         Notes   : This command causes Opus to open the AmigaGuide help file and
  412.                   search for the named topic.
  413.  
  414.         Command : EXTCMD_GET_PORT
  415.         Purpose : Get ARexx port name
  416.         Packet  : char name[40]
  417.         Returns : <none>
  418.         Notes   : This command copies the name of the Opus ARexx port into the
  419.                   supplied buffer.
  420.  
  421.         Command : EXTCMD_GET_SCREEN
  422.         Purpose : Get public screen name
  423.         Packet  : char name[40]
  424.         Returns : <none>
  425.         Notes   : This command copies the name of the Opus public screen into
  426.                   the supplied buffer.
  427.  
  428.         Command : EXTCMD_REPLACE_REQ
  429.         Purpose : Shows a "file exists - replace?" requester
  430.         Packet  : struct replacereq_packet {
  431.                     struct Window        *window;   // Window to open over
  432.                     struct Screen        *screen;   // Screen to open on
  433.                     IPCData              *ipc;      // Process IPC pointer
  434.                     struct FileInfoBlock *file1;    // First file information
  435.                     struct FileInfoBlock *file2;    // Second file information
  436.                     short                flags;     // Set to 0 for now
  437.                   };
  438.         Returns : Result of requester; REPLACE_ABORT for abort,
  439.                   REPLACE_LEAVE for skip or REPLACE_REPLACE for replace.
  440.                   If the REPLACEF_ALL flag is set, it indicates an "All"
  441.                   gadget (eg Skip All, Replace All)
  442.  
  443.         Command : EXTCMD_GET_SCREENDATA
  444.         Purpose : Get information about the Opus display
  445.         Packet  : <none>
  446.         Returns : struct DOpusScreenData {
  447.                     struct Screen   *screen;        // Pointer to Opus screen
  448.                     struct DrawInfo *draw_info;     // DrawInfo structure
  449.                     USHORT          depth;          // Depth of screen
  450.                     USHORT          pen_alloc;      // Pen allocation flag
  451.                     USHORT          pen_array[16];  // User pen array
  452.                     USHORT          pen_count;      // Number of pens;
  453.                   };
  454.         Notes   : Returns a structure with useful information about the Opus
  455.                   screen. This structure is READ ONLY!
  456.                   Call EXTCMD_FREE_SCREENDATA to free it.
  457.  
  458.         Command : EXTCMD_FREE_SCREENDATA
  459.         Purpose : Free a DOpusScreenData structure
  460.         Packet  : struct DOpusScreenData *
  461.         Returns : <none>
  462.         Notes   : Frees the result of an EXTCMD_GET_SCREENDATA call
  463.  
  464. `       Command : EXTCMD_SEND_COMMAND
  465.         Purpose : Send an ARexx command to DOpus
  466.         Packet  : struct command_packet {
  467.                     char    *command;       // Command to send
  468.                     ULONG   flags;          // Command flags
  469.                     char    *result;        // Result pointer
  470.                     ULONG   rc;             // Result code
  471.                   };
  472.         Returns : TRUE if the message was sent
  473.         Notes   : This command allows you to send an ARexx instruction
  474.                   directly to the Opus ARexx port. Set the COMMANDF_RESULT
  475.                   flag if you want a result string returned; if one is,
  476.                   the 'result' field of the packet will contain a pointer
  477.                   to it. You MUST call FreeVec() on this pointer when you
  478.                   have finished with the result.
  479.  
  480.