home *** CD-ROM | disk | FTP | other *** search
/ RISC DISC 1 / RISC_DISC_1.iso / pd_share / code / oslib / h / osgbpb < prev    next >
Encoding:
Text File  |  1994-09-14  |  15.4 KB  |  542 lines

  1. #ifndef osgbpb_H
  2. #define osgbpb_H
  3.  
  4. /* C header file for OSGBPB
  5.  * written by DefMod (Sep  7 1994) on Wed Sep 14 13:18:22 1994
  6.  * Copyright © Acorn Computers Ltd, 1994
  7.  */
  8.  
  9. /*************************************************************************
  10.  * This source file was written by Acorn Computers Limited. It is part   *
  11.  * of the OSLib library for writing applications for RISC OS. It may be  *
  12.  * used freely in the creation of programs for RISC OS.                  *
  13.  *************************************************************************/
  14.  
  15. #ifndef types_H
  16.    #include "types.h"
  17. #endif
  18.  
  19. #ifndef os_H
  20.    #include "os.h"
  21. #endif
  22.  
  23. /**********************************
  24.  * SWI names and SWI reason codes *
  25.  **********************************/
  26. #undef  OS_GBPB
  27. #define OS_GBPB                                 0xC
  28. #undef  XOS_GBPB
  29. #define XOS_GBPB                                0x2000C
  30. #undef  OSGBPB_WriteAt
  31. #define OSGBPB_WriteAt                          0x1
  32. #undef  OSGBPB_Write
  33. #define OSGBPB_Write                            0x2
  34. #undef  OSGBPB_ReadAt
  35. #define OSGBPB_ReadAt                           0x3
  36. #undef  OSGBPB_Read
  37. #define OSGBPB_Read                             0x4
  38. #undef  OSGBPB_ReadDiscName
  39. #define OSGBPB_ReadDiscName                     0x5
  40. #undef  OSGBPB_ReadCSDName
  41. #define OSGBPB_ReadCSDName                      0x6
  42. #undef  OSGBPB_ReadLibName
  43. #define OSGBPB_ReadLibName                      0x7
  44. #undef  OSGBPB_CSDEntries
  45. #define OSGBPB_CSDEntries                       0x8
  46. #undef  OSGBPB_DirEntries
  47. #define OSGBPB_DirEntries                       0x9
  48. #undef  OSGBPB_DirEntriesInfo
  49. #define OSGBPB_DirEntriesInfo                   0xA
  50. #undef  OSGBPB_DirEntriesSystemInfo
  51. #define OSGBPB_DirEntriesSystemInfo             0xB
  52. #undef  OSGBPB_DirEntriesInfoStamped
  53. #define OSGBPB_DirEntriesInfoStamped            0xC
  54. #undef  GBPBV
  55. #define GBPBV                                   0xC
  56.  
  57. /************************************
  58.  * Structure and union declarations *
  59.  ************************************/
  60. typedef struct osgbpb_name                      osgbpb_name;
  61. typedef struct osgbpb_disc_name                 osgbpb_disc_name;
  62. typedef struct osgbpb_dir_name                  osgbpb_dir_name;
  63. typedef struct osgbpb_name_list                 osgbpb_name_list;
  64. typedef struct osgbpb_info                      osgbpb_info;
  65. typedef struct osgbpb_system_info               osgbpb_system_info;
  66. typedef struct osgbpb_info_stamped              osgbpb_info_stamped;
  67. typedef struct osgbpb_string_list               osgbpb_string_list;
  68. typedef struct osgbpb_info_list                 osgbpb_info_list;
  69. typedef struct osgbpb_system_info_list          osgbpb_system_info_list;
  70. typedef struct osgbpb_info_stamped_list         osgbpb_info_stamped_list;
  71.  
  72. /********************
  73.  * Type definitions *
  74.  ********************/
  75. struct osgbpb_name
  76.    {  byte count;
  77.       char c [UNKNOWN];
  78.    };
  79.  
  80. #define osgbpb_NAME(N) \
  81.    struct \
  82.       {  byte count; \
  83.          char c [N]; \
  84.       }
  85.  
  86. #define osgbpb_SIZEOF_NAME(N) \
  87.    (offsetof (osgbpb_name, c) + \
  88.          (N)*sizeof ((osgbpb_name *) NULL)->c)
  89.  
  90. struct osgbpb_disc_name
  91.    {  osgbpb_name name;
  92.    };
  93.  
  94. struct osgbpb_dir_name
  95.    {  byte reserved;
  96.       osgbpb_name name;
  97.    };
  98.  
  99. struct osgbpb_name_list
  100.    {  osgbpb_name names [UNKNOWN];
  101.    };
  102.  
  103. struct osgbpb_info
  104.    {  bits load_addr;
  105.       bits exec_addr;
  106.       int size;
  107.       bits attr;
  108.       int obj_type;
  109.       char name [UNKNOWN];
  110.    };
  111.  
  112. #define osgbpb_INFO(N) \
  113.    struct \
  114.       {  bits load_addr; \
  115.          bits exec_addr; \
  116.          int size; \
  117.          bits attr; \
  118.          int obj_type; \
  119.          char name [N]; \
  120.       }
  121.  
  122. #define osgbpb_SIZEOF_INFO(N) \
  123.    (offsetof (osgbpb_info, name) + \
  124.          (N)*sizeof ((osgbpb_info *) NULL)->name)
  125.  
  126. struct osgbpb_system_info
  127.    {  bits load_addr;
  128.       bits exec_addr;
  129.       int size;
  130.       bits attr;
  131.       int obj_type;
  132.       int sin;
  133.       os_date_and_time stamp;
  134.       char name [UNKNOWN];
  135.    };
  136.  
  137. #define osgbpb_SYSTEM_INFO(N) \
  138.    struct \
  139.       {  bits load_addr; \
  140.          bits exec_addr; \
  141.          int size; \
  142.          bits attr; \
  143.          int obj_type; \
  144.          int sin; \
  145.          os_date_and_time stamp; \
  146.          char name [N]; \
  147.       }
  148.  
  149. #define osgbpb_SIZEOF_SYSTEM_INFO(N) \
  150.    (offsetof (osgbpb_system_info, name) + \
  151.          (N)*sizeof ((osgbpb_system_info *) NULL)->name)
  152.  
  153. struct osgbpb_info_stamped
  154.    {  bits load_addr;
  155.       bits exec_addr;
  156.       int size;
  157.       bits attr;
  158.       int obj_type;
  159.       bits file_type;
  160.       char name [UNKNOWN];
  161.    };
  162.  
  163. #define osgbpb_INFO_STAMPED(N) \
  164.    struct \
  165.       {  bits load_addr; \
  166.          bits exec_addr; \
  167.          int size; \
  168.          bits attr; \
  169.          int obj_type; \
  170.          bits file_type; \
  171.          char name [N]; \
  172.       }
  173.  
  174. #define osgbpb_SIZEOF_INFO_STAMPED(N) \
  175.    (offsetof (osgbpb_info_stamped, name) + \
  176.          (N)*sizeof ((osgbpb_info_stamped *) NULL)->name)
  177.  
  178. struct osgbpb_string_list
  179.    {  char names [UNKNOWN];
  180.    };
  181.  
  182. struct osgbpb_info_list
  183.    {  osgbpb_info info [UNKNOWN];
  184.    };
  185.  
  186. struct osgbpb_system_info_list
  187.    {  osgbpb_system_info info [UNKNOWN];
  188.    };
  189.  
  190. struct osgbpb_info_stamped_list
  191.    {  osgbpb_info_stamped info [UNKNOWN];
  192.    };
  193.  
  194. /************************
  195.  * Constant definitions *
  196.  ************************/
  197. #define osgbpb_PRIVILEGE_OWNER                  ((byte) 0)
  198. #define osgbpb_PRIVILEGE_PUBLIC                 ((byte) 255)
  199. #define osgbpb_NO_MORE                          (-1)
  200.  
  201. /*************************
  202.  * Function declarations *
  203.  *************************/
  204.  
  205. #ifdef __cplusplus
  206.    extern "C" {
  207. #endif
  208.  
  209. /*************************************************************
  210.  * NOTE: The following functions provide direct access to    *
  211.  *       the SWI's noted in the function description.        *
  212.  *       Please read the relevant PRM section for more       *
  213.  *       information on their input/output parameters.       *
  214.  *************************************************************/
  215.  
  216. /* ------------------------------------------------------------------------
  217.  * Function:      osgbpb_write_at()
  218.  *
  219.  * Description:   Writes bytes to an open file at the specified file
  220.  *                pointer
  221.  *
  222.  * Input:         file - value of R1 on entry
  223.  *                data - value of R2 on entry
  224.  *                size - value of R3 on entry
  225.  *                ptr - value of R4 on entry
  226.  *
  227.  * Output:        unwritten - value of R3 on exit (X version only)
  228.  *
  229.  * Returns:       R3 (non-X version only)
  230.  *
  231.  * Other notes:   Calls SWI 0xC with R0 = 0x1.
  232.  */
  233.  
  234. extern os_error *xosgbpb_write_at (os_f file,
  235.       byte *data,
  236.       int size,
  237.       int ptr,
  238.       int *unwritten);
  239. extern int osgbpb_write_at (os_f file,
  240.       byte *data,
  241.       int size,
  242.       int ptr);
  243.  
  244. /* ------------------------------------------------------------------------
  245.  * Function:      osgbpb_write()
  246.  *
  247.  * Description:   Writes bytes to an open file
  248.  *
  249.  * Input:         file - value of R1 on entry
  250.  *                data - value of R2 on entry
  251.  *                size - value of R3 on entry
  252.  *
  253.  * Output:        unwritten - value of R3 on exit (X version only)
  254.  *
  255.  * Returns:       R3 (non-X version only)
  256.  *
  257.  * Other notes:   Calls SWI 0xC with R0 = 0x2.
  258.  */
  259.  
  260. extern os_error *xosgbpb_write (os_f file,
  261.       byte *data,
  262.       int size,
  263.       int *unwritten);
  264. extern int osgbpb_write (os_f file,
  265.       byte *data,
  266.       int size);
  267.  
  268. /* ------------------------------------------------------------------------
  269.  * Function:      osgbpb_read_at()
  270.  *
  271.  * Description:   Reads bytes from an open file at the specified file
  272.  *                pointer
  273.  *
  274.  * Input:         file - value of R1 on entry
  275.  *                buffer - value of R2 on entry
  276.  *                size - value of R3 on entry
  277.  *                ptr - value of R4 on entry
  278.  *
  279.  * Output:        unread - value of R3 on exit (X version only)
  280.  *
  281.  * Returns:       R3 (non-X version only)
  282.  *
  283.  * Other notes:   Calls SWI 0xC with R0 = 0x3.
  284.  */
  285.  
  286. extern os_error *xosgbpb_read_at (os_f file,
  287.       byte *buffer,
  288.       int size,
  289.       int ptr,
  290.       int *unread);
  291. extern int osgbpb_read_at (os_f file,
  292.       byte *buffer,
  293.       int size,
  294.       int ptr);
  295.  
  296. /* ------------------------------------------------------------------------
  297.  * Function:      osgbpb_read()
  298.  *
  299.  * Description:   Reads bytes from an open file
  300.  *
  301.  * Input:         file - value of R1 on entry
  302.  *                buffer - value of R2 on entry
  303.  *                size - value of R3 on entry
  304.  *
  305.  * Output:        unread - value of R3 on exit (X version only)
  306.  *
  307.  * Returns:       R3 (non-X version only)
  308.  *
  309.  * Other notes:   Calls SWI 0xC with R0 = 0x4.
  310.  */
  311.  
  312. extern os_error *xosgbpb_read (os_f file,
  313.       byte *buffer,
  314.       int size,
  315.       int *unread);
  316. extern int osgbpb_read (os_f file,
  317.       byte *buffer,
  318.       int size);
  319.  
  320. /* ------------------------------------------------------------------------
  321.  * Function:      osgbpb_read_disc_name()
  322.  *
  323.  * Description:   Reads the name and boot option of the disc which contains
  324.  *                the CSD (prefer OSFSControl_CanonicalisePath and/or
  325.  *                OSFSControl_ReadBootOption)
  326.  *
  327.  * Input:         disc_name - value of R2 on entry
  328.  *
  329.  * Other notes:   Calls SWI 0xC with R0 = 0x5.
  330.  */
  331.  
  332. extern os_error *xosgbpb_read_disc_name (osgbpb_disc_name *disc_name);
  333. extern void osgbpb_read_disc_name (osgbpb_disc_name *disc_name);
  334.  
  335. /* ------------------------------------------------------------------------
  336.  * Function:      osgbpb_read_csd_name()
  337.  *
  338.  * Description:   Reads the name and privilege status of the CSD (prefer
  339.  *                OSFSControl_CanonicalisePath)
  340.  *
  341.  * Input:         csd_name - value of R2 on entry
  342.  *
  343.  * Other notes:   Calls SWI 0xC with R0 = 0x6.
  344.  */
  345.  
  346. extern os_error *xosgbpb_read_csd_name (osgbpb_dir_name *csd_name);
  347. extern void osgbpb_read_csd_name (osgbpb_dir_name *csd_name);
  348.  
  349. /* ------------------------------------------------------------------------
  350.  * Function:      osgbpb_read_lib_name()
  351.  *
  352.  * Description:   Reads the name and privilege status of the library
  353.  *                (prefer OSFSControl_CanonicalisePath)
  354.  *
  355.  * Input:         lib_name - value of R2 on entry
  356.  *
  357.  * Other notes:   Calls SWI 0xC with R0 = 0x7.
  358.  */
  359.  
  360. extern os_error *xosgbpb_read_lib_name (osgbpb_dir_name *lib_name);
  361. extern void osgbpb_read_lib_name (osgbpb_dir_name *lib_name);
  362.  
  363. /* ------------------------------------------------------------------------
  364.  * Function:      osgbpb_csd_entries()
  365.  *
  366.  * Description:   Reads entries from the CSD (prefer OSGBPB_DirEntries)
  367.  *
  368.  * Input:         name_list - value of R2 on entry
  369.  *                count - value of R3 on entry
  370.  *                context - value of R4 on entry
  371.  *
  372.  * Output:        unread - value of R3 on exit
  373.  *                context_out - value of R4 on exit (X version only)
  374.  *
  375.  * Returns:       R4 (non-X version only)
  376.  *
  377.  * Other notes:   Calls SWI 0xC with R0 = 0x8.
  378.  */
  379.  
  380. extern os_error *xosgbpb_csd_entries (osgbpb_name_list *name_list,
  381.       int count,
  382.       int context,
  383.       int *unread,
  384.       int *context_out);
  385. extern int osgbpb_csd_entries (osgbpb_name_list *name_list,
  386.       int count,
  387.       int context,
  388.       int *unread);
  389.  
  390. /* ------------------------------------------------------------------------
  391.  * Function:      osgbpb_dir_entries()
  392.  *
  393.  * Description:   Reads entries from a specified directory
  394.  *
  395.  * Input:         dir_name - value of R1 on entry
  396.  *                name_list - value of R2 on entry
  397.  *                count - value of R3 on entry
  398.  *                context - value of R4 on entry
  399.  *                size - value of R5 on entry
  400.  *                entries - value of R6 on entry
  401.  *
  402.  * Output:        read_count - value of R3 on exit
  403.  *                context_out - value of R4 on exit (X version only)
  404.  *
  405.  * Returns:       R4 (non-X version only)
  406.  *
  407.  * Other notes:   Calls SWI 0xC with R0 = 0x9.
  408.  */
  409.  
  410. extern os_error *xosgbpb_dir_entries (char *dir_name,
  411.       osgbpb_string_list *name_list,
  412.       int count,
  413.       int context,
  414.       int size,
  415.       char *entries,
  416.       int *read_count,
  417.       int *context_out);
  418. extern int osgbpb_dir_entries (char *dir_name,
  419.       osgbpb_string_list *name_list,
  420.       int count,
  421.       int context,
  422.       int size,
  423.       char *entries,
  424.       int *read_count);
  425.  
  426. /* ------------------------------------------------------------------------
  427.  * Function:      osgbpb_dir_entries_info()
  428.  *
  429.  * Description:   Reads entries and file information from a specified
  430.  *                directory
  431.  *
  432.  * Input:         dir_name - value of R1 on entry
  433.  *                info_list - value of R2 on entry
  434.  *                count - value of R3 on entry
  435.  *                context - value of R4 on entry
  436.  *                size - value of R5 on entry
  437.  *                entries - value of R6 on entry
  438.  *
  439.  * Output:        read_count - value of R3 on exit
  440.  *                context_out - value of R4 on exit (X version only)
  441.  *
  442.  * Returns:       R4 (non-X version only)
  443.  *
  444.  * Other notes:   Calls SWI 0xC with R0 = 0xA.
  445.  */
  446.  
  447. extern os_error *xosgbpb_dir_entries_info (char *dir_name,
  448.       osgbpb_info_list *info_list,
  449.       int count,
  450.       int context,
  451.       int size,
  452.       char *entries,
  453.       int *read_count,
  454.       int *context_out);
  455. extern int osgbpb_dir_entries_info (char *dir_name,
  456.       osgbpb_info_list *info_list,
  457.       int count,
  458.       int context,
  459.       int size,
  460.       char *entries,
  461.       int *read_count);
  462.  
  463. /* ------------------------------------------------------------------------
  464.  * Function:      osgbpb_dir_entries_system_info()
  465.  *
  466.  * Description:   Reads entries and file information (including SIN) from a
  467.  *                specified directory
  468.  *
  469.  * Input:         dir_name - value of R1 on entry
  470.  *                info_list - value of R2 on entry
  471.  *                count - value of R3 on entry
  472.  *                context - value of R4 on entry
  473.  *                size - value of R5 on entry
  474.  *                entries - value of R6 on entry
  475.  *
  476.  * Output:        read_count - value of R3 on exit
  477.  *                context_out - value of R4 on exit (X version only)
  478.  *
  479.  * Returns:       R4 (non-X version only)
  480.  *
  481.  * Other notes:   Calls SWI 0xC with R0 = 0xB.
  482.  */
  483.  
  484. extern os_error *xosgbpb_dir_entries_system_info (char *dir_name,
  485.       osgbpb_system_info_list *info_list,
  486.       int count,
  487.       int context,
  488.       int size,
  489.       char *entries,
  490.       int *read_count,
  491.       int *context_out);
  492. extern int osgbpb_dir_entries_system_info (char *dir_name,
  493.       osgbpb_system_info_list *info_list,
  494.       int count,
  495.       int context,
  496.       int size,
  497.       char *entries,
  498.       int *read_count);
  499.  
  500. /* ------------------------------------------------------------------------
  501.  * Function:      osgbpb_dir_entries_info_stamped()
  502.  *
  503.  * Description:   Reads entries and file information (including file type)
  504.  *                from a specified directory
  505.  *
  506.  * Input:         dir_name - value of R1 on entry
  507.  *                info_list - value of R2 on entry
  508.  *                count - value of R3 on entry
  509.  *                context - value of R4 on entry
  510.  *                size - value of R5 on entry
  511.  *                entries - value of R6 on entry
  512.  *
  513.  * Output:        read_count - value of R3 on exit
  514.  *                context_out - value of R4 on exit (X version only)
  515.  *
  516.  * Returns:       R4 (non-X version only)
  517.  *
  518.  * Other notes:   Calls SWI 0xC with R0 = 0xC.
  519.  */
  520.  
  521. extern os_error *xosgbpb_dir_entries_info_stamped (char *dir_name,
  522.       osgbpb_info_stamped_list *info_list,
  523.       int count,
  524.       int context,
  525.       int size,
  526.       char *entries,
  527.       int *read_count,
  528.       int *context_out);
  529. extern int osgbpb_dir_entries_info_stamped (char *dir_name,
  530.       osgbpb_info_stamped_list *info_list,
  531.       int count,
  532.       int context,
  533.       int size,
  534.       char *entries,
  535.       int *read_count);
  536.  
  537. #ifdef __cplusplus
  538.    }
  539. #endif
  540.  
  541. #endif
  542.