/* CD-ROM address types */ #define CDROM_LBA 0x01 #define CDROM_MSF 0x02 /* SUB Q control bits */ #define CDROM_AUDIO_EMPHASIS 0x01 #define CDROM_COPY_PERMITTED 0x02 #define CDROM_DATA_TRACK 0x04 #define CDROM_FOUR_CHANNEL 0x08 /* The leadout track is always 0xAA, regardless of # of tracks on disc */ #define CDROM_LEADOUT 0xAA /* return value from READ SUBCHANNEL DATA */ /* Audio status not supported */ #define CDROM_AUDIO_INVALID 0x00 /* Audio play operation in progress */ #define CDROM_AUDIO_PLAY 0x11 /* Audio play operation paused */ #define CDROM_AUDIO_PAUSED 0x12 /* Audio play successfully completed */ #define CDROM_AUDIO_COMPLETED 0x13 /* Audio play stopped due to error */ #define CDROM_AUDIO_ERROR 0x14 /* No current audio status to return */ #define CDROM_AUDIO_NO_STATUS 0x15
See also: CD-ROM opcodes for Fcntl
struct cdrom_audioctrl { /* input parameters */ int16_t set; /* 0 = 0 == inquire only */ /* input/output parameters */ struct { int8_t selection; int8_t volume; } channel[4]; };
See also: CD-ROM opcodes for Fcntl
struct cdrom_mcn { int8_t mcn_audiostatus; int8_t mcn_mcn[23]; /* Media catalog number as ASCII string */ };
See also: CD-ROM opcodes for Fcntl ASCII table
struct cdrom_msf { int8_t cdmsf_min0; /* Start minute */ int8_t cdmsf_sec0; /* Start second */ int8_t cdmsf_frame0; /* Start frame */ int8_t cdmsf_min1; /* End minute */ int8_t cdmsf_sec1; /* End second */ int8_t cdmsf_frame1; /* End frame */ };
See also: CD-ROM opcodes for Fcntl
struct cdrom_read { int32_t cdread_lba; /* Logical block address */ int8_t *cdread_bufaddr; /* Buffer pointer */ int32_t cdread_buflen; /* Byte count */ };
See also: CD-ROM opcodes for Fcntl
struct cdrom_subchnl { /* input parameters */ int8_t cdsc_format; /* CDROM_MSF or CDROM_LBA */ /* output parameters */ int8_t cdsc_audiostatus; unsigned cdsc_resvd: 8; /* Reserved */ unsigned cdsc_adr : 4; unsigned cdsc_ctrl : 4; int8_t cdsc_track; /* Current track */ int8_t cdsc_ind; /* Current index */ cd_ad cdsc_absaddr; /* Absolute address */ cd_ad cdsc_reladdr; /* Track relative address */ };
See also: CD-ROM opcodes for Fcntl
struct cdrom_ti { int8_t cdti_trk0; /* Start track */ int8_t cdti_ind0; /* Start index */ int8_t cdti_trk1; /* End track */ int8_t cdti_ind1; /* End index */ };
See also: CD-ROM opcodes for Fcntl
struct cdrom_tisrc { /* input parameters */ int8_t tisrc_track; /* Track number */ /* output parameters */ int8_t tisrc_audiostatus; int8_t tisrc_tisrc[23]; /* Track International Standard Recording Code (ASCII) */ };
See also: CD-ROM opcodes for Fcntl ASCII table
struct cdrom_tocentry { /* input parameters */ int8_t cdte_track; /* Track number or CDROM_LEADOUT */ int8_t cdte_format; /* CDROM_LBA or CDROM_MSF */ /* output parameters */ unsigned cdte_adr:4; /* the SUBQ channel encodes: 0 = nothing 1 = position data 2 = MCN 3 = ISRC Else: reserved */ unsigned cdte_ctrl:4; /* Bit-0: Audio with pre-emphasis Bit-1: Digital copy permitted Bit-2: Data track Bit-3: Four channel */ int8_t cdte_datamode; /* Currently not se */ cd_ad dte_addr; /* Track start */ };
See also: CD-ROM opcodes for Fcntl
struct cdrom_tochdr { int8_t cdth_trk0; /* Start track */ int8_t cdth_trk1; /* End track */ };
See also: CD-ROM opcodes for Fcntl
struct cdrom_volctrl { int8_t channel0; /* Channel 1: Volume 0...255 */ int8_t channel1; /* Channel 2: Volume 0...255 */ int8_t channel2; /* Channel 3: Volume 0...255 */ int8_t channel3; /* Channel 4: Volume 0...255 */ };
See also: CD-ROM opcodes for Fcntl
This union is defined as follows:
typedef union { struct { int8_t reserved; /* Reserved */ int8_t minute; /* Minute */ int8_t second; /* Second */ int8_t frame; /* Frame */ } msf; int32_t lba; } cd_ad;
See also: CD-ROM opcodes for Fcntl
This structure is defined as follows:
typedef struct { uint32_t b_free; /* Number of free clusters */ uint32_t b_total; /* Total number of clusters */ uint32_t b_secsiz; /* Bytes per sektor */ uint32_t b_clsiz; /* sector per cluster */ } DISKINFO;
typedef struct { uint16_t time; /* Time like Tgettime */ uint16_t date; /* Date like Tgetdate */ } DOSTIME;
The structure of both integer values is arranged as follows:
Bit | Time |
0-4 | Seconds in units of two (0-29) |
5-10 | Minutes (0-59) |
11-15 | Hours (0-23) |
Bit | Date |
0-4 | Day of month (1-31) |
5-8 | Month (1-12) |
9-15 | Year (0-119, 0=1980) |
typedef struct { int8_t *in_dos; /* Adress of the DOS semaphore */ int16_t *dos_time; /* Adress of the DOS time */ int16_t *dos_date; /* Adress of the DOS date */ int32_t res1; /* */ int32_t res2; /* */ int32_t res3; /* is 0L */ VOID *act_pd; /* Running program */ int32_t res4; /* */ int16_t res5; /* */ VOID *res6; /* */ VOID *res7; /* Internal DOS memory list */ VOID (*resv_intmem)(); /* Extend DOS memory */ int32_t (*etv_critic)(); /* etv_critic of the GEMDOS */ int8_t * ((*err_to_str)(int8_t e)); /* Conversion code->plain text */ VOID *xaes_appls; /* */ VOID *mem_root; /* */ VOID *ur_pd; /* */ } DOSVARS;
Note: These variables are READ-ONLY !
With the aid of the function resv_intmem one can reserve memory for internal memory management (similar to using FOLDRnnnn). In contrast to TOS however this is stressed far less, so that extension is not usually necessary. If memory has to be extended, which also happens with ADDMEM, then one passes to the function resv_intmem the address in register A0, and the length of the memory block to be reserved in register D0.
The prototype for the Event Critic Handler runs:
int32_t etv_critic (int16_t errcode, int16_t drvnr)
Note that the function expects the arguments on the stack, and hence in Pure-C must be declared as cdecl.
The function err_to_str expects in register D0 a TOS error-code, and returns in registers D0 and A0 a pointer to the descriptive character string. With an invalid error-code one receives in D0 a NULL, and in A0 a pointer to the character string 'TOS error'.
As seen by KAOS 1.4.2 the structure looks like this:
typedef struct { int8_t *in_dos; /* Address of the DOS semaphores */ int16_t *dos_time; /* Address of the DOS time */ int16_t *dos_date; /* Address of the DOS date */ int32_t dos_stack; /* Stack for DOS itself */ int32_t pgm_superset; /* User-program super stack */ MD *menlist[3]; /* Address of the 3 MD lists */ VOID *act_pd; /* Running program */ FCB *fcbx; /* Files */ int16_t fcbn; /* Length of fcbx[] */ DMD *dmdx; /* Pointer to 16 DMDs */ IMB *imbx; /* Internal DOS memory list */ VOID (*resv_intmem)(); /* Extend DOS memory */ int32_t (*etv_critic)(); /* etv_critic of the GEMDOS */ int8_t * ((*err_to_str)(int8_t e)); /* Conversion code->clear text */ } DOSVARS;
See also: AESVARS Cookie of MagiC Sconfig
This structure is defined as follows:
typedef struct { int8_t d_reserved[21]; /* Reserved for GEMDOS */ uint8_t d_attrib; /* File attributes */ uint16_t d_time; /* Time */ uint16_t d_date; /* Date */ uint32_t d_length; /* File length */ int8_t d_fname[14]; /* Filename */ } DTA;
Recursive search in folders
In each DTA, all required information is stored that is required
after a Fsfirst for further Fsnext calls. That means that one should
never call Fsfirst anew for other directories/wildcards as long as
further Fsnext calls are made in the same directory.
For a recursive search one must use a new DTA for each new Fsfirst,
which must be maintained until all Fsnext for the Fsfirst have been
made. Here an example in pseudo-C:
void search_directory (int8_t *pfadname) { DTA_Record local_dta, saved_dta; saved_dta = GetDTA (); SetDTA (local_dta); err = Fsfirst (pfadname, ...); while (err == 0) { if (local_dta.attrib == subdir) { // recursive search in sub-dir search_directory (subdir-pfadname); } else { ... evaluate normal file } err = Fsnext (); } SetDTA (saved_dta); }
See also: Fgetdta Fsetdta Fsfirst Fsnext GEMDOS
typedef struct f_cookie { struct filesys *fs; /* File-system that knows this cookie */ uint16_t dev; /* Device info (e.g. Rwabs device number) */ uint16_t aux; /* Further data for the file-system */ int32_t index; /* Serves together with dev for identifying */ /* a file */ } fcookie;
See also: FILEPTR FILESYS XFS-concept in MagiC
typedef struct fileptr { int16_t links; uint16_t flags; int32_t pos; int32_t devinfo; fcookie fc; struct devdrv *dev; struct fileptr *next; } FILEPTR;
struct flock { int16_t l_type; /* Type of lock */ int16_t l_whence; /* SEEK_SET, SEEK_CUR, SEEK_END */ int32_t l_start; /* Start of the locking region */ int32_t l_len; /* Length of the locking region */ int16_t l_pid; /* PID of the locking process */ };
Note: Possible values for l_type are: 0 = Read locking, 1 = Write locking as well as 3 = No locking.
struct iovec { char *iov_base; int32_t iov_len; };
typedef struct { uint8_t maxlen; /* Maximum line length */ uint8_t actuallen; /* Current line length */ int8_t buffer[255]; /* Line buffer */ } LINE;
struct ltchars { int8_t t_suspc; int8_t t_dsuspc; int8_t t_rprntc; int8_t t_flushc; int8_t t_werasc; int8_t t_lnextc; };
See also: struct tty XFS-concept in MagiC
/* structure used with sendmsg() and recvmsg() */ struct msghdr { struct sockaddr *msg_name; int32_t msg_namelen; struct iovec *msg_iov; int32_t msg_iovlen; void *msg_accrights; int32_t msg_accrightslen; };
struct mutimbuf { uint16_t actime; /* Access time */ uint16_t acdate; /* Access date */ uint16_t modtime; /* Time of last modification */ uint16_t moddate; /* Date of last modification */ };
typedef struct pd { VOID *p_lowtpa; /* Start address of the TPA */ VOID *p_hitpa; /* First byte after the end of the TPA */ VOID *p_tbase; /* Start address of the program code */ int32_t p_tlen; /* Length of the program code */ VOID *p_dbase; /* Start address of the DATA segment */ int32_t p_dlen; /* Length of the DATA section */ VOID *p_bbase; /* Start address of the BSS segment */ int32_t p_blen; /* Length of the BSS section */ DTA *p_dta; /* Pointer to the default DTA */ /* Warning: Points first to the */ /* command line ! */ struct pd *p_parent; /* Pointer to the basepage of the */ /* calling processes */ int32_t p_resrvd0; /* Reserved */ int8_t *p_env; /* Address of the environment string */ int8_t p_resrvd1[80]; /* Reserved */ int8_t p_cmdlin[128]; /* Command line */ } PD; /* also: BASEPAGE */
Note about the command line: The number of characters is inserted in the first line. The maximum length of the command line does not amount to 127, but only to 124 characters! (This does not apply in MagiC as of Version 3 - see ARGV procedure).
See also: GEMDOS OSHEADER Pexec Program launch and TPA
typedef struct pollfd { int32_t fd; /* File descriptor to poll */ uint16_t events; /* Types of events poller cares about */ uint16_t revents; /* Types of events that actually occurred */ } POLLFD;
struct ploadinfo { int16_t fnamelen; /* Lenght from 'fname' */ int8_t *cmdlin; /* Command line of the processes (128 bytes) */ int8_t *fname; /* Complete path and filename of the processes */ };
struct sgttyb { int8_t sg_ispeed; int8_t sg_ospeed; int8_t sg_erase; int8_t sg_kill; uint16_t sg_flags; };
See also: struct tty XFS-concept in MagiC
This structure is defined as follows:
struct sigaction { void cdecl (*sa_handler)(int32_t sig); int32_t sa_mask; int16_t sa_flags; };
Note: The component sa_handler can assume various values here. A value of 0 means default signal-handling by the system, with a value of 1 the signal will be ignored; any other value will be interpreted as the address of a signal handling routine, which is then called.
The component sa_mask contains additionally (to the signal currently being processed) the signals to be masked during the signal handling. In that case mask = oldmask+(1<<sig)+sa_mask). With sa_flags one can influence the behaviour of a signal further. A value of 1 for sa_flags means in MiNT that the signal SIGCHLD is triggered only on termination and not on stopping the child; other values for sa_flags are not yet defined at the present time.
See also: Signals Signal-handler in MagiC GEMDOS Psigaction Process functions
/* generic socket address */ struct sockaddr { int16_t sa_family; char sa_data[14]; };
struct time { int32_t high_time; int32_t time; uint32_t nanoseconds; }; typedef struct stat { uint64_t dev; /* Device number */ uint32_t ino; /* File number */ uint32_t mode; /* File mode, statements for */ /* - possible filetypes */ /* - special bits */ /* - access rights */ uint32_t nlink; /* Number of links */ uint32_t uid; /* User number */ uint32_t gid; /* Group number */ uint64_t rdev; /* Actual device */ /* (e.g. for BIOS files) */ struct time atime; /* time of last access, UTC */ struct time mtime; /* time of last data modification, UTC */ struct time ctime; /* time of last file status change, UTC */ int64_t size; /* File length */ int64_t blocks; /* occupied blocks */ int32_t blksize; /* Blocksize */ uint32_t flags; /* user defined flags for file */ uint32_t gen; /* file generation number */ int32_t reserved[7]; /* reserved */ } STAT;
Note: MagiC returns for FAT file-systems the following index data:
• Directories: | Start cluster in Motorola format | ||||
• Other files: |
|
This procedure is similar to that used by Linux and Solaris. The drawback is that files alter their index during a move.
The component index is therefore a LONGword for the unambiguous identification of a file or a folder. The index must be unique within a file-system; together with the following field (dev) it completely pinpoints a file or a folder system-globally.
Under UNIX-like file-systems, index is the number of the Inode.
On Macintosh partitions, the hard file ID or the hard dir ID that the MacOS makes available is used. However, the MacOS uses FSSpec as the standard descriptors. For directories, i.e. for directory IDs, there are functions of the MacOS to calculate a FSSpec. Unfortunately the hard file IDs for normal files (i.e. not subdirectories) cannot continue to be used, as they are not processed by any function of the MacOS.
See also: XFS-concept in MagiC Fxattr Dxreaddir
Determines the file-system. On the Atari, 0..25 are the BIOS drives A: to Z:, Drive U: or other file-systems use higher numbers. On the Macintosh the 'volume ID' is used, which is assigned by the MacOS.
Possible filetypes that can be set or obtained via the STAT structure:
#define S_IFMT 0170000 /* For isolating the filetype */ #define S_IFSOCK 0010000 /* Socket file */ #define S_IFCHR 0020000 /* Special BIOS file */ #define S_IFDIR 0040000 /* Directory */ #define S_IFBLK 0060000 /* Block special file */ #define S_IFREG 0100000 /* Normal file */ #define S_IFIFO 0120000 /* FIFO (Pipe with name) */ #define S_IMEM 0140000 /* Memory block/process file */ #define S_IFLNK 0160000 /* Symbolic link */
Special bits that can be set or obtained via the STAT structure:
#define S_ISUID 04000 /* Set user ID of the owner */ #define S_ISGID 02000 /* Set group ID at call */ #define S_ISVTX 01000 /* Sticky-bit */
Note: The meaning of the sticky-bit depends on the filetype.
On DOS partitions, folders return the value 0 as their length. The actual length unfortunately cannot be ascertained due to limitations of MSDOS. Only the length of the root directory can be obtained.
On Macintosh partitions folders always have the length 0, the actual length cannot be obtained (at least under System 7).
Possible access rights that can be set or obtained via the STAT structure:
#define S_IRUSR 0400 /* Owner may read file */ #define S_IWUSR 0200 /* Owner may write */ #define S_IXUSR 0100 /* Owner members may execute */ #define S_IRGRP 0040 /* Group members may read */ #define S_IWGRP 0020 /* Group members may write */ #define S_IXGRP 0010 /* Group members may execute */ #define S_IROTH 0004 /* Others may read file */ #define S_IWOTH 0002 /* Others may write */ #define S_IXOTH 0001 /* Others may execute */
struct tchars { int8_t t_intrc; int8_t t_quitc; int8_t t_startc; int8_t t_stopc; int8_t t_eofc; int8_t t_brkc; };
See also: struct tty XFS-concept in MagiC
struct timeval { int32_t int tv_sec; int32_t int tv_usec; };
tv_sec holds the number of seconds elapsed since the epoch. The epoch is Thu, Jan 1 1970 00:00:00 UTC.
tv_usec holds the fractional part of tv_sec measured in microseconds.
struct timezone { int32_t int tz_minuteswest; int32_t int tz_dsttime; };
tz_minuteswest holds the offset to UTC in seconds. Timezones east of the zero-meridian (e.g. Eastern Europe) have a negative offset, timezones west of the zero-meridian (e.g. America) have a positive one.
tz_dsttime is non-zero if daylight savings time applies during some part of the year.
struct tty { int16_t pgrp; int16_t state; int16_t use_cnt; int16_t res1; struct sgttyb sg; struct tchars tc; struct ltchars ltc; struct winsize wsiz; int32_t rsel; int32_t wsel; int8_t *xkey; int32_t hup_ospeed; uint16_t vmin, vtime; int32_t resrvd[1]; };
See also: Dcntl dev_descr XFS-concept in MagiC
struct winsize { int16_t ws_row; int16_t ws_col; int16_t ws_xpixel; int16_t ws_ypixel; };
See also: Fcntl TIOCGWINSZ
typedef struct xattr { uint16_t mode; /* File mode, statements for */ /* - possible filetypes */ /* - special bits */ /* - access rights */ int32_t index; /* File number */ uint16_t dev; /* Device number */ uint16_t rdev; /* Actual device */ /* (e.g. for BIOS files) */ /* in MagiC however reserved */ uint16_t nlink; /* Number of links */ uint16_t uid; /* User number */ uint16_t gid; /* Group number */ int32_t size; /* File length */ int32_t blksize, nblocks; /* Blocksize/occupied blocks */ uint16_t mtime, mdate; /* Date of last modification */ uint16_t atime, adate; /* Date of the last access */ uint16_t ctime, cdate; /* Creation date */ uint16_t attr; /* TOS file attributes */ uint16_t reserved2; /* Reserviert */ int32_t reserved3[2]; /* Reserviert */ } XATTR;
Note: MagiC returns for FAT file-systems the following index data:
• Directories: | Start cluster in Motorola format | ||||
• Other files: |
|
This procedure is similar to that used by Linux and Solaris. The drawback is that files alter their index during a move.
The component index is therefore a LONGword for the unambiguous identification of a file or a folder. The index must be unique within a file-system; together with the following field (dev) it completely pinpoints a file or a folder system-globally.
Under UNIX-like file-systems, index is the number of the Inode.
On Macintosh partitions, the hard file ID or the hard dir ID that the MacOS makes available is used. However, the MacOS uses FSSpec as the standard descriptors. For directories, i.e. for directory IDs, there are functions of the MacOS to calculate a FSSpec. Unfortunately the hard file IDs for normal files (i.e. not subdirectories) cannot continue to be used, as they are not processed by any function of the MacOS.
See also: XFS-concept in MagiC Fxattr Dxreaddir
Determines the file-system. On the Atari, 0..25 are the BIOS drives A: to Z:, Drive U: or other file-systems use higher numbers. On the Macintosh the 'volume ID' is used, which is assigned by the MacOS.
Possible filetypes that can be set or obtained via the XATTR structure:
#define S_IFMT 0170000 /* For isolating the filetype */ #define S_IFCHR 0020000 /* Special BIOS file */ #define S_IFDIR 0040000 /* Directory */ #define S_IFREG 0100000 /* Normal file */ #define S_IFIFO 0120000 /* FIFO (Pipe with name) */ #define S_IMEM 0140000 /* Memory block/process file */ #define S_IFLNK 0160000 /* Symbolic link */
Special bits that can be set or obtained via the XATTR structure:
#define S_ISUID 04000 /* Set user ID of the owner */ #define S_ISGID 02000 /* Set group ID at call */ #define S_ISVTX 01000 /* Sticky-bit */
Note: The meaning of the sticky-bit depends on the filetype.
On DOS partitions, folders return the value 0 as their length. The actual length unfortunately cannot be ascertained due to limitations of MSDOS. Only the length of the root directory can be obtained.
On Macintosh partitions folders always have the length 0, the actual length cannot be obtained (at least under System 7).
Possible access rights that can be set or obtained via the XATTR structure:
#define S_IRUSR 0400 /* Owner may read file */ #define S_IWUSR 0200 /* Owner may write */ #define S_IXUSR 0100 /* Owner members may execute */ #define S_IRGRP 0040 /* Group members may read */ #define S_IWGRP 0020 /* Group members may write */ #define S_IXGRP 0010 /* Group members may execute */ #define S_IROTH 0004 /* Others may read file */ #define S_IWOTH 0002 /* Others may write */ #define S_IXOTH 0001 /* Others may execute */
Special bits that may be set or obtained via the XATTR structure:
#define S_ISUID 04000 /* Set user ID of the owner */ #define S_ISGID 02000 /* Set group ID at call */ #define S_ISVTX 01000 /* Sticky-bit */
Note: The meaning of sticky-bit depends on the filetype.
struct xkey { int16_t xk_num; int8_t xk_def[8]; };