Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4973 right-hear 1
/* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */
2
/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */
3
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
4
#ifndef __dj_include_dos_h_
5
#define __dj_include_dos_h_
6
 
7
#ifndef __dj_ENFORCE_ANSI_FREESTANDING
8
 
9
#ifndef __STRICT_ANSI__
10
 
11
#ifndef _POSIX_SOURCE
12
 
13
#include 
14
 
15
int _detect_80387(void);
16
 
17
struct DWORDREGS {
18
  unsigned long edi;
19
  unsigned long esi;
20
  unsigned long ebp;
21
  unsigned long cflag;
22
  unsigned long ebx;
23
  unsigned long edx;
24
  unsigned long ecx;
25
  unsigned long eax;
26
  unsigned short eflags;
27
};
28
 
29
struct DWORDREGS_W {
30
  unsigned long di;
31
  unsigned long si;
32
  unsigned long bp;
33
  unsigned long cflag;
34
  unsigned long bx;
35
  unsigned long dx;
36
  unsigned long cx;
37
  unsigned long ax;
38
  unsigned short flags;
39
};
40
 
41
struct WORDREGS {
42
  unsigned short di, _upper_di;
43
  unsigned short si, _upper_si;
44
  unsigned short bp, _upper_bp;
45
  unsigned short cflag, _upper_cflag;
46
  unsigned short bx, _upper_bx;
47
  unsigned short dx, _upper_dx;
48
  unsigned short cx, _upper_cx;
49
  unsigned short ax, _upper_ax;
50
  unsigned short flags;
51
};
52
 
53
struct BYTEREGS {
54
  unsigned short di, _upper_di;
55
  unsigned short si, _upper_si;
56
  unsigned short bp, _upper_bp;
57
  unsigned long cflag;
58
  unsigned char bl;
59
  unsigned char bh;
60
  unsigned short _upper_bx;
61
  unsigned char dl;
62
  unsigned char dh;
63
  unsigned short _upper_dx;
64
  unsigned char cl;
65
  unsigned char ch;
66
  unsigned short _upper_cx;
67
  unsigned char al;
68
  unsigned char ah;
69
  unsigned short _upper_ax;
70
  unsigned short flags;
71
};
72
 
73
union REGS {		/* Compatible with DPMI structure, except cflag */
74
  struct DWORDREGS d;
75
#ifdef _NAIVE_DOS_REGS
76
  struct WORDREGS x;
77
#else
78
#ifdef _BORLAND_DOS_REGS
79
  struct DWORDREGS x;
80
#else
81
  struct DWORDREGS_W x;
82
#endif
83
#endif
84
  struct WORDREGS w;
85
  struct BYTEREGS h;
86
};
87
 
88
struct SREGS {
89
  unsigned short es;
90
  unsigned short ds;
91
  unsigned short fs;
92
  unsigned short gs;
93
  unsigned short cs;
94
  unsigned short ss;
95
};
96
 
97
struct ftime {
98
  unsigned ft_tsec:5;	/* 0-29, double to get real seconds */
99
  unsigned ft_min:6;	/* 0-59 */
100
  unsigned ft_hour:5;	/* 0-23 */
101
  unsigned ft_day:5;	/* 1-31 */
102
  unsigned ft_month:4;	/* 1-12 */
103
  unsigned ft_year:7;	/* since 1980 */
104
};
105
 
106
struct date {
107
  short da_year;
108
  char  da_day;
109
  char  da_mon;
110
};
111
 
112
struct time {
113
  unsigned char ti_min;
114
  unsigned char ti_hour;
115
  unsigned char ti_hund;
116
  unsigned char ti_sec;
117
};
118
 
119
struct dfree {
120
  unsigned df_avail;
121
  unsigned df_total;
122
  unsigned df_bsec;
123
  unsigned df_sclus;
124
};
125
 
126
#ifdef __cplusplus
127
extern "C" {
128
#endif
129
 
130
extern unsigned short   _osmajor, _osminor;
131
extern const    char  * _os_flavor;
132
extern int		_doserrno;
133
 
134
unsigned short _get_dos_version(int);
135
 
136
 
137
int int86(int ivec, union REGS *in, union REGS *out);
138
int int86x(int ivec, union REGS *in, union REGS *out, struct SREGS *seg);
139
int intdos(union REGS *in, union REGS *out);
140
int intdosx(union REGS *in, union REGS *out, struct SREGS *seg);
141
int bdos(int func, unsigned dx, unsigned al);
142
int bdosptr(int func, void *dx, unsigned al);
143
 
144
#define bdosptr(a, b, c) bdos(a, (unsigned)(b), c)
145
#define intdos(a, b) int86(0x21, a, b)
146
#define intdosx(a, b, c) int86x(0x21, a, b, c)
147
 
148
int getftime(int handle, struct ftime *ftimep);
149
int setftime(int handle, struct ftime *ftimep);
150
 
151
int getcbrk(void);
152
int setcbrk(int new_value);
153
 
154
void getdate(struct date *);
155
/* void gettime(struct time *); */
156
void setdate(struct date *);
157
void settime(struct time *);
158
 
159
void getdfree(unsigned char drive, struct dfree *ptr);
160
 
161
void delay(unsigned msec);
162
/* int _get_default_drive(void);
163
void _fixpath(const char *, char *); */
164
 
165
 
166
/*
167
 *  For compatibility with other DOS C compilers.
168
 */
169
 
170
#define _A_NORMAL   0x00    /* Normal file - No read/write restrictions */
171
#define _A_RDONLY   0x01    /* Read only file */
172
#define _A_HIDDEN   0x02    /* Hidden file */
173
#define _A_SYSTEM   0x04    /* System file */
174
#define _A_VOLID    0x08    /* Volume ID file */
175
#define _A_SUBDIR   0x10    /* Subdirectory */
176
#define _A_ARCH     0x20    /* Archive file */
177
 
178
#define _enable   enable
179
#define _disable  disable
180
 
181
struct _dosdate_t {
182
  unsigned char  day;       /* 1-31 */
183
  unsigned char  month;     /* 1-12 */
184
  unsigned short year;      /* 1980-2099 */
185
  unsigned char  dayofweek; /* 0-6, 0=Sunday */
186
};
187
#define dosdate_t _dosdate_t
188
 
189
struct _dostime_t {
190
  unsigned char hour;     /* 0-23 */
191
  unsigned char minute;   /* 0-59 */
192
  unsigned char second;   /* 0-59 */
193
  unsigned char hsecond;  /* 0-99 */
194
};
195
#define dostime_t _dostime_t
196
 
197
#pragma pack(push,1)
198
struct _find_t {
199
  char reserved[21];
200
  unsigned char attrib;
201
  unsigned short wr_time;
202
  unsigned short wr_date;
203
  unsigned long size;
204
  char name[256];
205
};
206
#pragma pack(pop)
207
#define find_t _find_t
208
 
209
struct _diskfree_t {
210
  unsigned short total_clusters;
211
  unsigned short avail_clusters;
212
  unsigned short sectors_per_cluster;
213
  unsigned short bytes_per_sector;
214
};
215
#define diskfree_t _diskfree_t
216
 
217
struct _DOSERROR {
218
  int  exterror;
219
  #ifdef __cplusplus
220
  char errclass;
221
  #else
222
  char class;
223
  #endif
224
  char action;
225
  char locus;
226
};
227
#define DOSERROR _DOSERROR
228
 
229
unsigned int   _dos_creat(const char *_filename, unsigned int _attr, int *_handle);
230
unsigned int   _dos_creatnew(const char *_filename, unsigned int _attr, int *_handle);
231
unsigned int   _dos_open(const char *_filename, unsigned int _mode, int *_handle);
232
unsigned int   _dos_write(int _handle, const void *_buffer, unsigned int _count, unsigned int *_result);
233
unsigned int   _dos_read(int _handle, void *_buffer, unsigned int _count, unsigned int *_result);
234
unsigned int   _dos_close(int _handle);
235
unsigned int   _dos_commit(int _handle);
236
 
237
unsigned int   _dos_findfirst(char *_name, unsigned int _attr, struct _find_t *_result);
238
unsigned int   _dos_findnext(struct _find_t *_result);
239
 
240
void           _dos_getdate(struct _dosdate_t *_date);
241
unsigned int   _dos_setdate(struct _dosdate_t *_date);
242
void           _dos_gettime(struct _dostime_t *_time);
243
unsigned int   _dos_settime(struct _dostime_t *_time);
244
 
245
unsigned int   _dos_getftime(int _handle, unsigned int *_p_date, unsigned int *_p_time);
246
unsigned int   _dos_setftime(int _handle, unsigned int _date, unsigned int _time);
247
unsigned int   _dos_getfileattr(const char *_filename, unsigned int *_p_attr);
248
unsigned int   _dos_setfileattr(const char *_filename, unsigned int _attr);
249
 
250
void           _dos_getdrive(unsigned int *_p_drive);
251
void           _dos_setdrive(unsigned int _drive, unsigned int *_p_drives);
252
unsigned int   _dos_getdiskfree(unsigned int _drive, struct _diskfree_t *_diskspace);
253
 
254
int            _dosexterr(struct _DOSERROR *_p_error);
255
#define dosexterr(_ep) _dosexterr(_ep)
256
 
257
#define int386(_i, _ir, _or)         int86(_i, _ir, _or)
258
#define int386x(_i, _ir, _or, _sr)   int86x(_i, _ir, _or, _sr)
259
 
260
#ifdef __cplusplus
261
}
262
#endif
263
 
264
#endif /* !_POSIX_SOURCE */
265
#endif /* !__STRICT_ANSI__ */
266
#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */
267
 
268
#ifndef __dj_ENFORCE_FUNCTION_CALLS
269
#endif /* !__dj_ENFORCE_FUNCTION_CALLS */
270
 
271
#ifndef _USE_LFN
272
#define _USE_LFN		(1)
273
#endif
274
 
275
#endif /* !__dj_include_dos_h_ */