home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 4 / DATAFILE_PDCD4.iso / utilities / utilsa / armedit / Code / TALK_H < prev    next >
Encoding:
Text File  |  1996-01-12  |  9.0 KB  |  268 lines

  1. /*
  2.     File        : talk.h
  3.     Date        : 12/1/96
  4.     Author        : © A.Thoukydides, 1995, 1996
  5.     Description    : Communications with the RISC OS ARMEdit module. This
  6.                   provides an interface to the services provided by that
  7.                   module without requiring any knowledge of the underlying
  8.                   interface.
  9. */
  10.  
  11. // Only include header file once
  12. #ifndef TALK_H
  13. #define TALK_H
  14.  
  15. // Include system header files
  16. #include <stdlib.h>
  17.  
  18. // RISC OS scrap directory to use
  19. #define TALK_SCRAP "<ARMEdit$ScrapDir>"
  20.  
  21. // ARM registers used on entry and exit from SWIs
  22. typedef struct
  23. {
  24.     long r[10];                            // Only R0 to R9 matter for SWIs
  25. } talk_swi_regs;
  26.  
  27. // A RISC OS style error block
  28. typedef struct
  29. {
  30.     long errnum;                        // Error number
  31.     char errmess[252];                    // Error message (zero terminated)
  32. } talk_error;
  33.  
  34. #ifdef __cplusplus
  35. extern "C" {
  36. #endif
  37.  
  38. /*
  39.     Paramaters    : no            - The number of the SWI to call.
  40.                   in            - Pointer to the values for the ARM registers
  41.                                   on entry to the SWI.
  42.                   out            - Pointer to the values that the ARM
  43.                                   registers contained on exit from the SWI.
  44.     Returns        : talk_error    - A pointer to a RISC OS style error block
  45.                                   (in PC memory), or NULL if there was no
  46.                                   error.
  47.     Description    : Call the specified RISC OS SWI. The SWI is always called
  48.                   with the X bit set.
  49. */
  50. const talk_error *talk_swi(long no, const talk_swi_regs *in,
  51.                            talk_swi_regs *out);
  52.  
  53. /*
  54.     Parameters    : buf            - Pointer to buffer to receive data.
  55.                   len            - The number of bytes to read.
  56.                   start            - The start ARM memory address.
  57.     Returns        : talk_error    - A pointer to a RISC OS style error block
  58.                                   (in PC memory), or NULL if there was no
  59.                                   error.
  60.     Description    : Read up to 16372 bytes of ARM memory.
  61. */
  62. const talk_error *talk_read(void *buf, size_t len, long start);
  63.  
  64. /*
  65.     Parameters    : buf            - Pointer to buffer containing data.
  66.                   len            - The number of bytes to write.
  67.                   start            - The start ARM memory address.
  68.     Returns        : talk_error    - A pointer to a RISC OS style error block
  69.                                   (in PC memory), or NULL if there was no
  70.                                   error.
  71.     Description    : Write up to 16372 bytes of ARM memory.
  72. */
  73. const talk_error *talk_write(const void *buf, size_t len, long start);
  74.  
  75. /*
  76.     Parameters    : len            - Amount of memory to allocate.
  77.                   buf            - Variable to contain address of memory.
  78.     Returns        : talk_error    - A pointer to a RISC OS style error block
  79.                                   (in PC memory), or NULL if there was no
  80.                                   error.
  81.     Description    : Claim the specified amount of ARM memory.
  82. */
  83. const talk_error *talk_malloc(size_t len, long *buf);
  84.  
  85. /*
  86.     Parameters    : buf            - Address of block of memory to free.
  87.     Returns        : talk_error    - A pointer to a RISC OS style error block
  88.                                   (in PC memory), or NULL if there was no
  89.                                   error.
  90.     Description    : Free a block of memory previously claimed using talk_alloc.
  91. */
  92. const talk_error *talk_free(long buf);
  93.  
  94. /*
  95.     Parameters    : ext            - A file extension.
  96.                   type            - Variable to receive the filetype.
  97.     Returns        : talk_error    - A pointer to a RISC OS style error block
  98.                                   (in PC memory), or NULL if there was no
  99.                                   error.
  100.     Description    : Convert a DOS file extension into a RISC OS filetype.
  101. */
  102. const talk_error *talk_ext_to_filetype(const char *ext, int *type);
  103.  
  104. /*
  105.     Parameters    : type            - A RISC OS filetype.
  106.                   ext            - Variable to receive file extension.
  107.     Returns        : talk_error    - A pointer to a RISC OS style error block
  108.                                   (in PC memory), or NULL if there was no
  109.                                   error.
  110.     Description    : Convert a RISC OS filetype into a DOS file extension.
  111. */
  112. const talk_error *talk_filetype_to_ext(int type, char *ext);
  113.  
  114.  
  115. /*
  116.     Parameters    : name            - The name of the file to open.
  117.                   size            - The initial size of the file, or -1 to open
  118.                                   an existing file.
  119.                   del            - Should the file be deleted when closed.
  120.                   handle        - Variable to receive the file handle.
  121.     Returns        : talk_error    - A pointer to a RISC OS style error block
  122.                                   (in PC memory), or NULL if there was no
  123.                                   error.
  124.     Description    : Open a RISC OS file.
  125. */
  126. const talk_error *talk_file_open(const char *name, long size, int del,
  127.                                  long *handle);
  128.  
  129. /*
  130.     Parameters    : handle        - Handle of the file to close.
  131.     Returns        : talk_error    - A pointer to a RISC OS style error block
  132.                                   (in PC memory), or NULL if there was no
  133.                                   error.
  134.     Description    : Close a RISC OS file.
  135. */
  136. const talk_error *talk_file_close(long handle);
  137.  
  138. /*
  139.     Parameters    : handle        - Handle of the file to read from.
  140.                   ptr            - Sequential file pointer position to read
  141.                                   from, or -1 to use current position.
  142.                   size            - Number of bytes to read.
  143.                   buf            - Buffer to receive the data.
  144.                   done            - Variable to receive number of bytes read.
  145.     Returns        : talk_error    - A pointer to a RISC OS style error block
  146.                                   (in PC memory), or NULL if there was no
  147.                                   error.
  148.     Description    : Read from a RISC OS file.
  149. */
  150. const talk_error *talk_file_read(long handle, long ptr, long size,
  151.                                  void *buf, long *done);
  152.  
  153. /*
  154.     Parameters    : handle        - Handle of the file to write to.
  155.                   ptr            - Sequential file pointer position to write
  156.                                   at, or -1 to use current position.
  157.                   size            - Number of bytes to write.
  158.                   buf            - Buffer containing the data.
  159.     Returns        : talk_error    - A pointer to a RISC OS style error block
  160.                                   (in PC memory), or NULL if there was no
  161.                                   error.
  162.     Description    : Write to a RISC OS file.
  163. */
  164. const talk_error *talk_file_write(long handle, long ptr, long size,
  165.                                   const void *buf);
  166.  
  167. /*
  168.     Parameters    : handle        - Variable to receive the unique handle for
  169.                                   this task. This should be used with all
  170.                                   future communications.
  171.     Returns        : talk_error    - A pointer to a RISC OS style error block
  172.                                   (in PC memory), or NULL if there was no
  173.                                   error.
  174.     Description    : Register a communications client.
  175. */
  176. const talk_error *talk_comms_start(long *handle);
  177.  
  178. /*
  179.     Parameters    : handle        - The previously allocated handle for this
  180.                                   client.
  181.     Returns        : talk_error    - A pointer to a RISC OS style error block
  182.                                   (in PC memory), or NULL if there was no
  183.                                   error.
  184.     Description    : Deregister a communications client.
  185. */
  186. const talk_error *talk_comms_end(long handle);
  187.  
  188. /*
  189.     Parameters    : handle        - The previously allocated client handle for
  190.                                   this task.
  191.                   dest            - The destination task ID or handle.
  192.                   buf            - The message to send.
  193.     Returns        : talk_error    - A pointer to a RISC OS style error block
  194.                                   (in PC memory), or NULL if there was no
  195.                                   error.
  196.     Description    : Send a message to one or more other clients.
  197. */
  198. const talk_error *talk_comms_tx(long handle, long dest, const void *buf);
  199.  
  200. /*
  201.     Parameters    : handle        - The previously allocated client handle for
  202.                                   this task.
  203.                   src_id        - The ID of the sending task.
  204.                   src_handle    - The handle of the sending task.
  205.                   buf            - The buffer to receive the message in.
  206.     Returns        : talk_error    - A pointer to a RISC OS style error block
  207.                                   (in PC memory), or NULL if there was no
  208.                                   error.
  209.     Description    : Check for any waiting messages, and read the next one if
  210.                   possible. Note that this (currently) returns an error if
  211.                   there is no message to read.
  212. */
  213. const talk_error *talk_comms_rx(long handle, long *src_id, long *src_handle,
  214.                                 void *buf);
  215.  
  216. /*
  217.     Parameters    : handle        - The unique handle allocated for this
  218.                                   client.
  219.     Returns        : talk_error    - A pointer to a RISC OS style error block
  220.                                   (in PC memory), or NULL if there was no
  221.                                   error.
  222.     Description    : Register a communications client.
  223. */
  224. const talk_error *talk_comms_start(long *handle);
  225.  
  226. /*
  227.     Parameters    : handle        - The unique handle previously allocated to
  228.                                   this client.
  229.     Returns        : talk_error    - A pointer to a RISC OS style error block
  230.                                   (in PC memory), or NULL if there was no
  231.                                   error.
  232.     Description    : Deregister a communications client.
  233. */
  234. const talk_error *talk_comms_end(long handle);
  235.  
  236. /*
  237.     Parameters    : handle        - The unique handle previously allocated to
  238.                                   this client.
  239.                   dest            - The destination ID or handle.
  240.                   msg            - The message to send.
  241.     Returns        : talk_error    - A pointer to a RISC OS style error block
  242.                                   (in PC memory), or NULL if there was no
  243.                                   error.
  244.     Description    : Transmit a message to another client.
  245. */
  246. const talk_error *talk_comms_tx(long handle, long dest, const void *msg);
  247.  
  248. /*
  249.     Parameters    : handle        - The unique handle previously allocated to
  250.                                   this client.
  251.                   src_id        - The ID of the sending task.
  252.                   src_handle    - The handle of the sending task.
  253.                   msg            - The buffer to receive the message.
  254.     Returns        : talk_error    - A pointer to a RISC OS style error block
  255.                                   (in PC memory), or NULL if there was no
  256.                                   error.
  257.     Description    : Receive a message from another task. Note that an error is
  258.                   returned if no message is available.
  259. */
  260. const talk_error *talk_comms_rx(long handle, long *src_id, long *src_handle,
  261.                                 void *msg);
  262.  
  263. #ifdef __cplusplus
  264. }
  265. #endif
  266.  
  267. #endif
  268.