home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / a / armedit / Code / TALK_H < prev   
Text File  |  1997-02-21  |  14KB  |  323 lines

  1. /*
  2.     File        : talk.h
  3.     Date        : 21-Feb-97
  4.     Author      : © A.Thoukydides, 1995, 1996, 1997
  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. // OSCLI status codes
  22. #define TALK_OSCLI_ACTIVE 0x00
  23. #define TALK_OSCLI_FINISHED 0x01
  24. #define TALK_OSCLI_WAITING 0x02
  25.  
  26. // ARM registers used on entry and exit from SWIs
  27. typedef struct
  28. {
  29.     long r[10];                         // Only R0 to R9 matter for SWIs
  30. } talk_swi_regs;
  31.  
  32. // A RISC OS style error block
  33. typedef struct
  34. {
  35.     long errnum;                        // Error number
  36.     char errmess[252];                  // Error message (zero terminated)
  37. } talk_error;
  38.  
  39. // A RISC OS date and time
  40. typedef char talk_date[5];
  41.  
  42. #ifdef __cplusplus
  43. extern "C" {
  44. #endif
  45.  
  46. /*
  47.     Paramaters  : no            - The number of the SWI to call.
  48.                   in            - Pointer to the values for the ARM registers
  49.                                   on entry to the SWI.
  50.                   out           - Pointer to the values that the ARM
  51.                                   registers contained on exit from the SWI.
  52.     Returns     : talk_error    - A pointer to a RISC OS style error block
  53.                                   (in PC memory), or NULL if there was no
  54.                                   error.
  55.     Description : Call the specified RISC OS SWI. The SWI is always called
  56.                   with the X bit set.
  57. */
  58. const talk_error *talk_swi(long no, const talk_swi_regs *in,
  59.                            talk_swi_regs *out);
  60.  
  61. /*
  62.     Parameters  : buf           - Pointer to buffer to receive data.
  63.                   len           - The number of bytes to read.
  64.                   start         - The start ARM memory address.
  65.     Returns     : talk_error    - A pointer to a RISC OS style error block
  66.                                   (in PC memory), or NULL if there was no
  67.                                   error.
  68.     Description : Read up to 16372 bytes of ARM memory.
  69. */
  70. const talk_error *talk_read(void *buf, size_t len, long start);
  71.  
  72. /*
  73.     Parameters  : buf           - Pointer to buffer containing data.
  74.                   len           - The number of bytes to write.
  75.                   start         - The start ARM memory address.
  76.     Returns     : talk_error    - A pointer to a RISC OS style error block
  77.                                   (in PC memory), or NULL if there was no
  78.                                   error.
  79.     Description : Write up to 16372 bytes of ARM memory.
  80. */
  81. const talk_error *talk_write(const void *buf, size_t len, long start);
  82.  
  83. /*
  84.     Parameters  : len           - Amount of memory to allocate.
  85.                   buf           - Variable to contain address of memory.
  86.     Returns     : talk_error    - A pointer to a RISC OS style error block
  87.                                   (in PC memory), or NULL if there was no
  88.                                   error.
  89.     Description : Claim the specified amount of ARM memory.
  90. */
  91. const talk_error *talk_malloc(size_t len, long *buf);
  92.  
  93. /*
  94.     Parameters  : buf           - Address of block of memory to free.
  95.     Returns     : talk_error    - A pointer to a RISC OS style error block
  96.                                   (in PC memory), or NULL if there was no
  97.                                   error.
  98.     Description : Free a block of memory previously claimed using talk_alloc.
  99. */
  100. const talk_error *talk_free(long buf);
  101.  
  102. /*
  103.     Parameters  : ext           - A file extension.
  104.                   type          - Variable to receive the filetype.
  105.     Returns     : talk_error    - A pointer to a RISC OS style error block
  106.                                   (in PC memory), or NULL if there was no
  107.                                   error.
  108.     Description : Convert a DOS file extension into a RISC OS filetype.
  109. */
  110. const talk_error *talk_ext_to_filetype(const char *ext, int *type);
  111.  
  112. /*
  113.     Parameters  : type          - A RISC OS filetype.
  114.                   ext           - Variable to receive file extension.
  115.     Returns     : talk_error    - A pointer to a RISC OS style error block
  116.                                   (in PC memory), or NULL if there was no
  117.                                   error.
  118.     Description : Convert a RISC OS filetype into a DOS file extension.
  119. */
  120. const talk_error *talk_filetype_to_ext(int type, char *ext);
  121.  
  122.  
  123. /*
  124.     Parameters  : name          - The name of the file to open.
  125.                   size          - The initial size of the file, or -1 to open
  126.                                   an existing file.
  127.                   del           - Should the file be deleted when closed.
  128.                   handle        - Variable to receive the file handle.
  129.     Returns     : talk_error    - A pointer to a RISC OS style error block
  130.                                   (in PC memory), or NULL if there was no
  131.                                   error.
  132.     Description : Open a RISC OS file.
  133. */
  134. const talk_error *talk_file_open(const char *name, long size, int del,
  135.                                  long *handle);
  136.  
  137. /*
  138.     Parameters  : handle        - Handle of the file to close.
  139.     Returns     : talk_error    - A pointer to a RISC OS style error block
  140.                                   (in PC memory), or NULL if there was no
  141.                                   error.
  142.     Description : Close a RISC OS file.
  143. */
  144. const talk_error *talk_file_close(long handle);
  145.  
  146. /*
  147.     Parameters  : handle        - Handle of the file to read from.
  148.                   ptr           - Sequential file pointer position to read
  149.                                   from, or -1 to use current position.
  150.                   size          - Number of bytes to read.
  151.                   buf           - Buffer to receive the data.
  152.                   done          - Variable to receive number of bytes read.
  153.     Returns     : talk_error    - A pointer to a RISC OS style error block
  154.                                   (in PC memory), or NULL if there was no
  155.                                   error.
  156.     Description : Read from a RISC OS file.
  157. */
  158. const talk_error *talk_file_read(long handle, long ptr, long size,
  159.                                  void *buf, long *done);
  160.  
  161. /*
  162.     Parameters  : handle        - Handle of the file to write to.
  163.                   ptr           - Sequential file pointer position to write
  164.                                   at, or -1 to use current position.
  165.                   size          - Number of bytes to write.
  166.                   buf           - Buffer containing the data.
  167.     Returns     : talk_error    - A pointer to a RISC OS style error block
  168.                                   (in PC memory), or NULL if there was no
  169.                                   error.
  170.     Description : Write to a RISC OS file.
  171. */
  172. const talk_error *talk_file_write(long handle, long ptr, long size,
  173.                                   const void *buf);
  174.  
  175. /*
  176.     Parameters  : handle        - Variable to receive the unique handle for
  177.                                   this task. This should be used with all
  178.                                   future communications.
  179.     Returns     : talk_error    - A pointer to a RISC OS style error block
  180.                                   (in PC memory), or NULL if there was no
  181.                                   error.
  182.     Description : Register a communications client.
  183. */
  184. const talk_error *talk_comms_start(long *handle);
  185.  
  186. /*
  187.     Parameters  : handle        - The previously allocated handle for this
  188.                                   client.
  189.     Returns     : talk_error    - A pointer to a RISC OS style error block
  190.                                   (in PC memory), or NULL if there was no
  191.                                   error.
  192.     Description :