home *** CD-ROM | disk | FTP | other *** search
- /*
- * system.cf -- non-ANSI
- *
- * Operating-system services.
- *
- * Copyright (c) 1990, MetaWare Incorporated
- */
-
- #ifndef _SYSTEM_CF
- #define _SYSTEM_CF
-
- #if ! _system_defs_included
- /* High C Interface to Xenix-DOS or Concurrent DOS 286 I/O Services. */
- /* This file makes use of a define "CDOS" that is set True under
- Concurrent DOS 286 systems. A few of the system-level routines differ
- for this OS.
- */
-
- #include <implemen.cf>
- #include <language.cf>
-
- #pragma Global_aliasing_convention(_Private_routine_prefix "%r");
- #pragma Calling_convention(PASCAL);
-
- /* Some routines are additionally aliased to prevent conflicts */
- /* with Pascal intrinsic routines Write, Read, Trunc, and Close. */
- typedef int File_handle; /* Small integer file handle. */
- typedef enum{From_beginning,From_current,From_end} Seek_method;
-
- /* For networking access: MSDOS 3.x only. */
- typedef enum{Compatibility,Deny_read_write,Deny_write,Deny_read,Deny_none}
- Sharing_mode_type;
- /* Use data pragma to share with Pascal system.pf package: */
- #pragma data(common,"?" _Private_prefix "system");
- Sharing_mode_type Sharing_mode; /* Initialized to Compatibility. */
- #pragma data;
- typedef enum{For_reading, For_writing, For_updating} Open_method;
-
- /* File attributes: */
- #define Attr_read_only 1 /* File may not be modified. */
- #define Attr_hidden 2 /* File is hidden. */
- #define Attr_system 4 /* File is a "system" file. */
- #define Attr_volume_id 8 /* File is the volume id. */
- #define Attr_directory 16 /* File is a directory. */
- #define Attr_archive 32 /* File has not been archived. */
- #if defined(CDOS)
- #define Attr_security 64 /* File has security enabled. */
- #endif
-
- #if defined(ADOS)
- typedef unsigned File_mode;/* A word set of the above bits. */
- #else
- typedef unsigned char File_mode;/* A byte set of the above bits. */
- #endif
-
- /* File class: */
- #define Disk_file 0 /* File is on disk. */
- #define Console_input 1 /* File is the keyboard. */
- #define Console_output 2 /* File is the monitor. */
- #define Printer_device 3 /* File is the printer. */
- #define Other_device 4 /* File is something else. */
- typedef unsigned char File_class;
-
- /*
- NOTE: Following every call, if an error occurred,
- the imported variable errno contains the status of the call.
- errno will contain one of the error codes specified after each
- routine declaration below.
- If no error occurred,
- the errno variable is left UNTOUCHED (it is not cleared),
- in accordance with the philosophy of the ANSI C library.
- */
-
-
- /* Return the mode of a file. */
- extern File_mode c_filemode(char *Name);
- /* Error_path_not_found. */
- /* Error_access_denied. */
- /* Error_invalid_function -- this error should never occur. */
-
- /* Return the class of a file. */
- extern File_class fileclass(File_handle F);
-
- /* Close file whose handle is "F". */
- extern void close(File_handle F);
- /* Error_invalid_handle -- file was not open, or "F" contains garbage. */
- #pragma Alias(close,_Private_routine_prefix "zclose");
- /* The Alias avoids external conflict with Pascal Close intrinsic. */
-
- /* Create file "name" and open it for writing. */
- extern File_handle c_create(char *Name, File_mode Mode);
- /* Error_access_denied. */
- /* Error_path_not_found. */
- /* Error_too_many_files - file created but not opened. */
- #if defined(CDOS)
- extern unsigned _open_and_mask, _open_or_mask;
- /* And/or the CDOS open/create flags with these values: */
- /* Flags = (Flags & _open_and_mask) | _open_or_mask; */
- /* This applies for both c_create and c_open calls. */
- /* These are initialized to 0xffff and 0x0 initially. */
- #endif
-
- /* Reposition the file pointer assoicated with "F" to location "Loc" */
- /* according to the method specified in "Method". */
- /* Return the new position. */
- extern long lseek(File_handle F, long Loc, Seek_method Method);
- /* Error_invalid_handle. */
- /* Error_invalid_function - the parameter "method" contains garbage. */
- #pragma Alias(lseek,_Private_routine_prefix "lseek");
-
- /* Make a new directory named "Name". */
- extern void c_mkdir(char *Name);
- /* Error_path_not_found. */
- /* Error_access_denied - file already exists or directory overflow. */
-
- /* Open file "Name" for reading, writing, or updating. */
- extern File_handle c_open(char *Name, Open_method Method);
- /* Error_invalid_access -- "method" parameter contains garbage */
- /* Error_file_not_found */
- /* Error_access_denied -- file is a directory, volume id or read-only */
- /* Error_too_many_files -- limit in CONFIG.SYS has been reached */
-
- /* Read "Cnt" bytes from file "F" into buffer whose address is "Bufp". */
- /* Returns the number of bytes actually read. */
- extern unsigned read(File_handle F, void *Buf, unsigned Cnt);
- /* Error_invalid_handle -- file not open. */
- /* Error_access_denied -- "F" was opened but not for reading. */
- #pragma Alias(read,_Private_routine_prefix "zread");
-
- /* Remove directory. */
- extern void c_rmdir(char *Name);
- /* Error_path_not_found. */
- /* Error_access_denied. */
- /* Error_current_directory - "Name" is the name of the current directory. */
-
- /* Erase file from directory. */
- extern void c_unlink(char *Name);
- /* Error_file_not_found. */
- /* Error_access_denied. */
-
- /* Rename a file. */
- extern void c_rename(char *Old, char *New);
- /* Error_file_not_found. */
- /* Error_not_same_device. */
- /* Error_access_denied. */
-
- /* Write "Cnt" bytes from buffer whose address is "Bufp" into file "F". */
- /* Note: If disk overflow occurs, Errno will have the value Error_disk_overflow */
- /* and Write will return with the number of bytes actually written. */
-
- extern unsigned write(File_handle F, void *Buf, unsigned Cnt);
- /* Error_invalid_handle - file not open. */
- /* Error_access_denied - file not open for writing. */
- #pragma Alias(write ,_Private_routine_prefix "zwrite");
-
- /* Truncates file at current position. */
- extern void trunc(File_handle F);
- /* Error_invalid_handle. */
- /* Error_access_denied. */
- #pragma Alias(trunc,_Private_routine_prefix "ztrunc");
-
- #if defined(CDOS)
- typedef _packed struct {
- unsigned short Year; char Month, Day, Hour, Min, Sec;
- } Time_and_date;
- #elif defined(ADOS)
- typedef struct {
- unsigned short Creation_date, Creation_time, Access_date, Access_time,
- Write_date, Write_time;
- } File_time_type;
- #endif
-
- typedef struct {
- #if defined(ADOS)
- File_time_type TD;
- long EOF_data, /* Who knows what this is? */
- Size; /* Size of file. */
- File_mode Attr;
- unsigned char Namelen; /* Length of upcoming name; redundant with nul-terminator. */
- char Name[13]; /* Includes trailing nul. */
- #elif defined(CDOS)
- long Key; /* For subsequent finds. */
- char Name[18]; /* 18 bytes of name; 0-terminated. */
- File_mode Attr; /* Attribute bits. */
- char Padding1; /* Attr is only 8 bits; CDOS supplies 16. */
- unsigned short Recsize;
- char User, Group;
- unsigned short Protection;
- char Reserved1[6];
- unsigned long Size; /* File size. */
- Time_and_date TD;
- char Reserved2;
- #else /* MS-DOS. */
- char Reserved[21];
- File_mode Attr;
- unsigned short Time, Date;
- long Size;
- char Name[13]; /* File name. */
- #endif
- } Find_buffer;
-
- extern void c_find_first(char *Path, Find_buffer *S
- #if !defined(CDOS)
- , File_mode Attr
- #if defined(ADOS)
- , unsigned *Dirhandle /* Must be presented next time. */
- #endif
- #endif
- );
- /* "Path" is a path name with wild card characters. The first file
- * encountered that matches the path name and has a subset of the
- * attributes specified in "Attr" is returned in S. (Attr is not
- * applicable for Concurrent DOS 286.)
- * This value of S must be passed to Find_next to get subsequent
- * matches.
- */
- /* Error_file_not_found -- invalid path name */
- /* Error_no_more_files -- no files matching this specification */
-
- #if defined(ADOS)
- extern void find_next(unsigned Dirhandle, Find_buffer *S);
- extern void find_close(unsigned Dirhandle); /* terminate find. */
- #elif !defined(CDOS)
- extern void find_next(Find_buffer *S);
- /* Called after Find_first to retrieve subsequent matches. */
- /* Error_no_more_files -- no more files that match. */
- #else
- extern void c_find_next(
- char *Path, /* CDOS requires the path a second time. */
- Find_buffer *S);
- /* Called after Find_first to retrieve subsequent matches. */
- /* Error_no_more_files -- no more files that match. */
- #endif
-
- #if !defined(CDOS)
- extern void switch_char(char *C, int Set_it);
- /* Set or retrieve the Switch character. */
- /* If Set_it, then set it; otherwise return it in C. */
- #endif
-
- #if !defined(CDOS)
- extern void file_times(File_handle F, unsigned short *Date, unsigned short *Time);
- #else
- extern void file_times(File_handle F, Time_and_date *TD);
- #endif
- /* Returns the date and time of an open file. */
- /* Error_invalid_handle -- file not open. */
-
- #if !defined(CDOS)
- extern void set_file_times(File_handle F, unsigned Date, unsigned Time);
- #else
- extern void set_file_times(File_handle F, Time_and_date *TD);
- #endif
- /* Sets the date/time of a file. */
- /* Error_invalid_handle -- File not open. */
-
- extern void get_date(unsigned short *Day, unsigned short *Month, unsigned short *Year);
- extern void get_time(unsigned short *Hrs, unsigned short *Mins, unsigned short *Secs);
-
- #define Clock_precision 100 /* Clock returns time in hundredths of a second. */
- extern long clock(); /* Time in 100ths of a second. */
-
- extern void dos_exit(unsigned char Return_code);
-
- /* Change the current working directory to "name". */
- extern void c_chdir(char *Name);
- /* Error_path_not_found. */
-
- /* Change mode of file "name" to "Mode". */
- extern void c_chmod(char *Name, File_mode Mode);
- /* Error_path_not_found. */
- /* Error_access_denied. */
- /* Error_invalid_function -- this error should never occur. */
-
- /* Duplicate file handle "F". */
- extern File_handle dup(File_handle F);
- /* Error_invalid_handle. */
- /* Error_too_many_open_files -- file limit of CONFIG.SYS exceeded. */
-
- /* Duplicate file handle "F" as file handle "Newfh". */
- extern void dup2(File_handle F, File_handle Newfh);
- /* Error_invalid_handle. */
-
- #pragma Global_aliasing_convention();
- #pragma Calling_convention();
- #define _system_defs_included 1
- #endif
- #endif /* _SYSTEM_CF */
-