home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / dev / gcc / ixemulsrc.lha / ixemul / include / sys / file.h < prev    next >
C/C++ Source or Header  |  1996-12-11  |  4KB  |  117 lines

  1. /*
  2.  *  This file is part of ixemul.library for the Amiga.
  3.  *  Copyright (C) 1991, 1992  Markus M. Wild
  4.  *
  5.  *  This library is free software; you can redistribute it and/or
  6.  *  modify it under the terms of the GNU Library General Public
  7.  *  License as published by the Free Software Foundation; either
  8.  *  version 2 of the License, or (at your option) any later version.
  9.  *
  10.  *  This library is distributed in the hope that it will be useful,
  11.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.  *  Library General Public License for more details.
  14.  *
  15.  *  You should have received a copy of the GNU Library General Public
  16.  *  License along with this library; if not, write to the Free
  17.  *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  */
  19.  
  20. #ifndef _SYS_FILE_H
  21. #define _SYS_FILE_H
  22.  
  23. #include <sys/types.h>
  24. #include <sys/fcntl.h>
  25. #include <sys/unistd.h>
  26.  
  27. #ifdef _INTERNAL_FILE
  28. #include <sys/stat.h>
  29. #include <libraries/dosextens.h>
  30.  
  31. /* this is the incore representation of a DTYPE_MEM file */
  32. struct mem_file {
  33.   int   mf_offset;
  34.   void *mf_buffer;
  35. };
  36.  
  37. /* this `glue' makes a tty a subtype of a plain file. Ie f->f_fh will work
  38.    for plain files as well as ttys. */
  39. struct tty_glue {
  40.   struct FileHandle *fh;
  41.   unsigned long ttyflags;       /* ixemul mapping of termios flags */
  42. };                /* if we run out of bits, we should */
  43.                 /* allocate a tty structure instead */
  44.  
  45. /* ixemul termios flag mappings: */
  46. #define IXTTY_INLCR        0x00000001
  47. #define IXTTY_ICRNL        0x00000002
  48. #define IXTTY_OPOST        0x00000004
  49. #define IXTTY_ONLCR        0x00000008
  50. #define IXTTY_RAW        0x00000010
  51. #define IXTTY_PKT        0x00000020  /* TIOCPKT replacement */
  52.  
  53. /* this will hold basic information about a file, but contrairy to
  54.  * Unix, it will also hold its name */
  55.  
  56. struct file {
  57.   char *f_name;         /* the name as used with open() */
  58.   int f_stb_dirty,   /* gets == 1, if changes have been made to 'stb' */
  59.       f_type,         /* can be a file or some amiga..devices */
  60.       f_flags,         /* see fcntl.h */
  61.       f_count,         /* open-count, normally 1, higher after dup() */
  62.       (*f_write)(),    /* functions to perform write,read,etc on this fd */
  63.       (*f_read)(),
  64.       (*f_ioctl)(),
  65.       (*f_select)(),
  66.       (*f_close)();
  67.   union {
  68.     struct FileHandle *fh; /* this is a CPTR to the allocated
  69.                 * FileHandle */
  70.     struct mem_file mf;       /* current data for incore files */
  71.     int so;           /* points to socket when DTYPE_SOCKET */
  72.     struct unix_socket *sock; /* points to AF_UNIX socket - DTYPE_USOCKET */
  73.     struct sock_stream *ss;
  74.     struct tty_glue tg;
  75.   } f__fh;
  76. #define f_fh  f__fh.fh
  77. #define f_mf  f__fh.mf
  78. #define f_so  f__fh.so
  79. #define f_sock    f__fh.sock
  80. #define f_ss  f__fh.ss
  81. #define f_ttyflags f__fh.tg.ttyflags
  82.   /* WARNING: if you change this struct, take care, that f_sp starts at
  83.    * long (!) alignment in the struct. The file-table will be allocated
  84.    * by AllocMem(), thus by itself it will have DOS-compatible alignment,
  85.    * if you don't follow this, you'll get some nice gurus.. */
  86.   struct StandardPacket f_sp; /* all IO is done thru the Packet-Interface,
  87.                    * not the higher-level DOS-functions */
  88.   struct StandardPacket f_select_sp; /* for the select() function */
  89.   struct stat f_stb; /* file-params at open-time, or after changes to fd */
  90.   int    f_sync_flags;    /* for process synchronization */
  91. };
  92.  
  93.  
  94. #define FSFB_LOCKED    (0)
  95. #define FSFF_LOCKED    (1<<0)    /* means the fh is in use */
  96. #define FSFB_WANTLOCK    (1)
  97. #define FSFF_WANTLOCK    (1<<1)    /* means a process is sleeping on fh to get free */
  98.  
  99. #define FSDB_MODE       (0)
  100. #define FSDF_MODE       (1<<0)  /* means fchmod() was used on the file */
  101. #define FSDB_OWNER      (1)
  102. #define FSDF_OWNER      (1<<1)  /* means fchown() was used on the file */
  103.  
  104. #endif /* _INTERNAL_FILE_H */
  105.  
  106.  
  107. #define DTYPE_FILE    1    /* 'file' is really a file */
  108. #define DTYPE_PIPE    2    /* it's an incore pipe */
  109. #define DTYPE_MEM    3    /* a RDONLY file completely buffered in memory */
  110. #define DTYPE_TASK_FILE    4    /* is a 'file', but used by a task, not a process !*/
  111. #define DTYPE_SOCKET    5    /* socket (inet.library interface) */
  112. #define DTYPE_USOCKET    6    /* socket (own socket code) */
  113. #define DTYPE_TTY    7    /* AmigaOS file, with special access functions */
  114. /* more to follow.. */
  115.  
  116. #endif /* _SYS_FILE_H */
  117.