home *** CD-ROM | disk | FTP | other *** search
/ RISCWORLD 7 / RISCWORLD_VOL7.iso / Software / Issue2 / SDL.ARC / !unixlib / source / clib / unixlib / h / local < prev    next >
Encoding:
Text File  |  2004-09-07  |  8.9 KB  |  244 lines

  1. /****************************************************************************
  2.  *
  3.  * $Source: /usr/local/cvsroot/gccsdk/unixlib/source/clib/unixlib/local.h,v $
  4.  * $Date: 2004/09/07 14:05:10 $
  5.  * $Revision: 1.14 $
  6.  * $State: Exp $
  7.  * $Author: joty $
  8.  *
  9.  * This file should eventually contain most / all of the UnixLib specific
  10.  * functions.
  11.  ***************************************************************************/
  12.  
  13.  
  14. #ifndef __UNIXLIB_LOCAL_H
  15. #define __UNIXLIB_LOCAL_H 1
  16.  
  17. #ifdef __UNIXLIB_INTERNALS
  18.  
  19. #ifndef __UNIXLIB_TYPES_H
  20. #include <unixlib/types.h>
  21. #endif
  22.  
  23. #define __need_FILE
  24. #include <stdio.h>
  25.  
  26. #endif /* __UNIXLIB_INTERNALS */
  27.  
  28. #ifndef __UNIXLIB_FEATURES_H
  29. #include <unixlib/features.h>
  30. #endif
  31.  
  32. #define __need_size_t
  33. #include <stddef.h>
  34.  
  35.  
  36. __BEGIN_DECLS
  37.  
  38. #ifdef __UNIXLIB_INTERNALS
  39.  
  40. /* Generate a file serial number. This should distinguish the file from
  41.    all other files on the same device.  */
  42. extern __ino_t __get_file_ino (const char *__directory,
  43.                    const char *__filename);
  44.  
  45. /* Return the converted to canonicalised RISC OS filename, or NULL on
  46.    failure.  */
  47. extern char * __fd_to_name (int __riscos_fd, char *__buf, size_t __buflen);
  48.  
  49. /* Convert a file mode into a attribute mask suitable for
  50.    passing to RISC OS.  */
  51. extern int __set_protection (__mode_t __mode);
  52.  
  53. /* Convert a RISC OS attribute mask into a 'stat' compatible
  54.    file access mode.  */
  55. extern __mode_t __get_protection (int __attrib);
  56.  
  57. /* Return nonzero if DIR is an existent directory.  */
  58. extern int __isdir (const char *__dir);
  59.  
  60. /* Return nonzero if OBJECT exists as file, dir or image.  */
  61. extern int __object_exists (const char *__object);
  62.  
  63. /* Return nonzero if DIR is an existent directory.
  64.    Don't call __riscosify[_std] ().  */
  65. extern int __isdir_raw (const char *__dir);
  66.  
  67. /* Return nonzero if OBJECT exists as file, dir or image.
  68.    Don't call __riscosify[_std] ().  */
  69. extern int __object_exists_raw (const char *__object);
  70.  
  71. /* Convert RISC OS format 5 byte time into Unix format time.
  72.    The lowest significant 4 bytes is passed 'low' and the most
  73.    significant byte in 'high'. */
  74. extern __time_t __cvt_riscos_time (unsigned int __high, unsigned int __low);
  75.  
  76. /* Convert Unix time into RISC OS five byte time.
  77.    The lowest significant 4 bytes are returned in 'low' and the
  78.    most significant byte in 'high'.  */
  79. extern void __cvt_unix_time (__time_t __unix_time, unsigned int *__high,
  80.                  unsigned int *__low);
  81.  
  82. /* Return 0 if 'socket' is both a valid file descriptor
  83.    and refers to a socket device.  Return -1 if not.  */
  84. extern int __socket_valid (int __socket);
  85.  
  86. /* Open a file descriptor.  Returns the file descriptor on success,
  87.    -1 on failure.  */
  88. extern int __open (int __fd, const char *__file, int __oflag, int __mode);
  89.  
  90. /* Close a file descriptor.  Returns zero on success, -1 on failure.  */
  91. extern int __close (int __fd);
  92.  
  93. /* Re-open a file descriptor.  Returns the file descriptor on success,
  94.    -1 on failure.  */
  95. extern int __reopen (int __fd, const char *__file, int __oflag, ...);
  96.  
  97. /* Read a line from a file and remove any comments.  */
  98. extern char *__net_readline (FILE *__file, char *__buffer, int __length);
  99.  
  100. /* Initialise unix file name translation.  */
  101. extern void __riscosify_init (void);
  102.  
  103. extern void __sfixinit (const char *list);
  104. extern void __sdirinit (void);
  105.  
  106. /* Search special suffix list for __sfix of length __len.  Returns
  107.    NULL if suffix isn't to be used for suffix swapping, ptr to suffix
  108.    otherwise.  */
  109. extern const char *__sfixfind (const char *__sfix, size_t __len);
  110.  
  111. extern const char __filename_char_map[256];
  112.  
  113. #endif  /* __UNIXLIB_INTERNALS */
  114.  
  115. /* This bit map controls how riscosify[_std]() processes filenames.
  116.    Flags value for internal conversions (in this thread?) of UnixLib.
  117.    The default value is 0 unless user program overrules this by
  118.    defining an explicit instance of __riscosify_control of its own.
  119.      Conversion on
  120.      Do perform suffix processing
  121.      Don't create suffix dirs (open/rename functions DO create dirs).
  122.      Don't look at/react on ",xyz" filetype extensions.
  123.      Set filetype according to MimeMap.  */
  124.  
  125. extern int __riscosify_control; /* Note: this is a weak symbol.  */
  126.  
  127. /* Bits 1 - 5 (incl), 7 and 15 - 31 (incl) of __riscosify_control are not
  128.    allocated.  */
  129.  
  130. /* When set, __riscosify[_std]() won't try to recognise RISC OS filenames
  131.    but assume that all filenames are Unix based.  */
  132. #define __RISCOSIFY_STRICT_UNIX_SPECS   0x0001
  133. /* Don't actually process filenames, copy verbatim into the output buffer.
  134.    When set, this has priority over all other bits.  */
  135. #define __RISCOSIFY_NO_PROCESS        0x0040
  136.  
  137. /* Disable suffix swapping (suffix swapping is implicitly disabled for
  138.    directories).  */
  139. #define __RISCOSIFY_NO_SUFFIX        0x0100
  140.  
  141. /* Disable checking if section between two '/'s exists as directory.  */
  142. #define __RISCOSIFY_DONT_CHECK_DIR    0x0200
  143.  
  144. /* accept only if dir found above is in the suffix list.  */
  145. #define __RISCOSIFY_CHECK_DIR_IS_SUFFIX    0x0400
  146.  
  147. /* Disable reverse suffix swapping (RISC OS -> Unix).  */
  148. #define __RISCOSIFY_NO_REVERSE_SUFFIX    0x0800
  149.  
  150. /* Support file type extensions: ",xyz" at the end of the Unix filename
  151.    means that the file on creation gets the filetype xyz (3 hex nibbles).
  152.    If the filetype extension is not specified or this option isn't set,
  153.    the filetype for freshly created files is `Text' (0xfff).  */
  154. #define __RISCOSIFY_FILETYPE_EXT        0x1000
  155.  
  156. /* When set and __RISCOSIFY_FILETYPE_EXT is set, RISC OS text files
  157.    will get a ",fff" extension when translated to their Unix form.  */
  158. #define __RISCOSIFY_FILETYPE_FFF_EXT    0x2000
  159.  
  160. /* If the filename has a unix-style extension, look up the extension
  161.    using RISC OS MimeMap SWIs and set a filetype.  If the filetype
  162.    could not be found, use 0xFFF.
  163.    This is turned on by default - set this bit to turn it off. */
  164. #define __RISCOSIFY_FILETYPE_NOT_SET    0x4000
  165.  
  166. /* Mask of acceptable values. Keep other bits zero. Checks may be made.  */
  167. #define __RISCOSIFY_MASK                0x7F41
  168.  
  169. /* Value indicating that __riscosify[_std] didn't see a filetype extension
  170.    in its argument __name or that it wasn't instructed to look for one.  */
  171. #define __RISCOSIFY_FILETYPE_NOTFOUND   -1
  172.  
  173. /* Value indicating for __unixify that there is no filetype (e.g. a
  174.    directory) even when __RISCOSIFY_FILETYPE_EXT is specified as one of
  175.    the flag bits.  */
  176. #define __RISCOSIFY_FILETYPE_NOTSPECIFIED -1
  177.  
  178. /* Convert Unix filenames/pathnames to RISC OS format creating the final
  179.    directory if necessary and __create_dir is non-zero.
  180.    Pass RISC OS pathnames through unchanged (only when
  181.    __RISCOSIFY_STRICT_UNIX_SPECS is clear).
  182.    Returns pointer to terminating '\0' in buffer,
  183.    or NULL if there was a problem.  */
  184. extern char *__riscosify (const char *__name, int __create_dir,
  185.               int __riscosify_flags,
  186.               char *__buffer, size_t __buf_len,
  187.               int *__filetype);
  188.  
  189. /* Calls __riscosify() with __riscosify_flags equal to
  190.    __riscosify_control.  */
  191. extern char *__riscosify_std (const char *__name, int __create_dir,
  192.                   char *__buffer, size_t __buf_len,
  193.                   int *__filetype);
  194.  
  195. #ifdef __UNIXLIB_INTERNALS
  196.  
  197. /* Gets the __riscosify_control value which can be defined by
  198.    the global variable __riscosify_control in the user program.
  199.    Returns a copy of __riscosify_control_internal (whom its default
  200.    value is 0) when __riscosify_control is not defined.  */
  201. extern int __get_riscosify_control (void);
  202. /* Sets the __riscosify_control value when it's defined.
  203.    Otherwise __riscosify_control_internal gets written.  */
  204. extern void __set_riscosify_control (int __riscosify_flags);
  205.  
  206. #endif  /* __UNIXLIB_INTERNALS */
  207.  
  208. /* Convert __name into a Unix style pathname and store in __buffer.
  209.    If buffer is non-NULL then it is at least __buf_len long.  If __buffer
  210.    is NULL then a buffer is malloc'ed to store the Unix pathname.
  211.    Return a pointer to the result or NULL on failure.  */
  212. extern char *__unixify (const char *__name, int __unixify_flags,
  213.             char *__buffer, size_t __buf_len, int __filetype);
  214.  
  215. extern char *__unixify_std (const char *__name,
  216.                 char *__buffer, size_t __buf_len,
  217.                 int __filetype);
  218.  
  219. /* Get an object's filetype, object type, etc and do some common checks.
  220.    Returns nonzero and sets errno on error. Returns riscosified filename
  221.    in __buffer. __objtype, __ftype and __attr may be NULL if not needed. */
  222. extern int
  223. __object_get_attrs (const char *__ux_file, char *__buffer, size_t __buf_len,
  224.             int *__objtype, int *__ftype, int *__loadaddr,
  225.             int *__execaddr, int *__length, int *__attr);
  226.  
  227. #define __ATTR_NOTSPECIFIED (-1)
  228.  
  229. /* Sets an objects filetype and attributes (either can be set to
  230.    __ATTR_NOTSPECIFIED to leave unchanged).
  231.    Returns nonzero and sets errno on error.  */
  232. extern int
  233. __object_set_attrs (const char *__ux_file, char *__buffer, size_t __buf_len,
  234.             int __ftype, int __attr);
  235.  
  236. /* Returns malloced block of memory holding DDEUtils_Prefix non zero-length
  237.    string value or NULL when there isn't one set.  Caller needs to free
  238.    memory after use.  */
  239. extern const char *__get_dde_prefix (void);
  240.  
  241. __END_DECLS
  242.  
  243. #endif
  244.