Subversion Repositories SvarDOS

Rev

Rev 1364 | Rev 1413 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1364 Rev 1409
Line 1... Line 1...
1
/*
1
/*
2
 * Functions interacting with DOS
2
 * Functions interacting with DOS
3
 *
3
 *
4
 * This file is part of the Mateusz' DOS Routines (MDR): http://mdr.osdn.io
4
 * This file is part of the Mateusz' DOS Routines (MDR): http://mdr.osdn.io
5
 * Published under the terms of the MIT License, as stated below.
5
 * Published under the terms of the MIT License, as stated below.
6
 *
6
 *
7
 * Copyright (C) 2014-2022 Mateusz Viste
7
 * Copyright (C) 2014-2023 Mateusz Viste
8
 *
8
 *
9
 * Permission is hereby granted, free of charge, to any person obtaining a copy
9
 * Permission is hereby granted, free of charge, to any person obtaining a copy
10
 * of this software and associated documentation files (the "Software"), to
10
 * of this software and associated documentation files (the "Software"), to
11
 * deal in the Software without restriction, including without limitation the
11
 * deal in the Software without restriction, including without limitation the
12
 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12
 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
13
 * sell copies of the Software, and to permit persons to whom the Software is
13
 * sell copies of the Software, and to permit persons to whom the Software is
14
 * furnished to do so, subject to the following conditions:
14
 * furnished to do so, subject to the following conditions:
15
 *
15
 *
16
 * The above copyright notice and this permission notice shall be included in
16
 * The above copyright notice and this permission notice shall be included in
17
 * all copies or substantial portions of the Software.
17
 * all copies or substantial portions of the Software.
18
 *
18
 *
19
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
25
 * IN THE SOFTWARE.
25
 * IN THE SOFTWARE.
26
 */
26
 */
27
 
27
 
28
#ifndef MDR_DOS_H
28
#ifndef MDR_DOS_H
29
#define MDR_DOS_H
29
#define MDR_DOS_H
30
 
30
 
31
#include <time.h> /* time_t */
31
#include <time.h> /* time_t */
32
 
32
 
33
/* returns a far pointer to the current process PSP structure */
33
/* returns a far pointer to the current process PSP structure */
34
void far *mdr_dos_psp(void);
34
void far *mdr_dos_psp(void);
35
 
35
 
36
/* returns a far pointer to the environment block of the current process */
36
/* returns a far pointer to the environment block of the current process */
37
char far *mdr_dos_env(void);
37
char far *mdr_dos_env(void);
38
 
38
 
39
/* looks for varname in the DOS environment and fills result with its value if
39
/* looks for varname in the DOS environment and fills result with its value if
40
 * found. returns NULL if not found or if value is too big to fit in result
40
 * found. returns NULL if not found or if value is too big to fit in result
41
 * (reslimit exceeded). returns result on success.
41
 * (reslimit exceeded). returns result on success.
42
 * NOTE: this function performs case-sensitive matches */
42
 * NOTE: this function performs case-sensitive matches */
43
char *mdr_dos_getenv(char *result, const char *varname, unsigned short reslimit);
43
char *mdr_dos_getenv(char *result, const char *varname, unsigned short reslimit);
44
 
44
 
45
/* fetches directory where the program was loaded from and return its length.
45
/* fetches directory where the program was loaded from and return its length.
46
 * path string is never longer than 128 (incl. the null terminator) and it is
46
 * path string is never longer than 128 (incl. the null terminator) and it is
47
 * always terminated with a backslash separator, unless it is an empty string */
47
 * always terminated with a backslash separator, unless it is an empty string */
48
unsigned char mdr_dos_exepath(char *path);
48
unsigned char mdr_dos_exepath(char *path);
49
 
49
 
50
/* returns a far pointer to the full path and filename of the running program.
50
/* returns a far pointer to the full path and filename of the running program.
51
 * returns NULL on error. */
51
 * returns NULL on error. */
52
const char far *mdr_dos_selfexe(void);
52
const char far *mdr_dos_selfexe(void);
-
 
53
 
-
 
54
/* waits for a keypress and returns it
-
 
55
 * extended keys are returned ORed with 0x100 (example: PGUP is 0x149) */
-
 
56
int mdr_dos_getkey(void);
-
 
57
 
-
 
58
/* Same as mdr_dos_getkey(), but this call cannot be aborted by CTRL+C */
-
 
59
int mdr_dos_getkey2(void);
-
 
60
 
-
 
61
/* flush the keyboard buffer */
-
 
62
void mdr_dos_flushkeyb(void);
-
 
63
 
-
 
64
/* poll stdin status, returns 0 if no character is pending in the keyboard
-
 
65
 * buffer, non-zero otherwise */
-
 
66
int mdr_dos_keypending(void);
-
 
67
 
-
 
68
/* disables the CTRL+C handler for the running program - in other words,
-
 
69
 * after this call DOS will no longer abort the program on CTRL+C */
-
 
70
void mdr_dos_ctrlc_disable(void);
53
 
71
 
54
/* converts a "DOS format" 16-bit packed date into a standard (time_t)
72
/* converts a "DOS format" 16-bit packed date into a standard (time_t)
55
 * unix timestamp. A DOS date is a 16-bit value:
73
 * unix timestamp. A DOS date is a 16-bit value:
56
 * YYYYYYYM MMMDDDDD
74
 * YYYYYYYM MMMDDDDD
57
 *
75
 *
58
 * day of month is always within 1-31 range;
76
 * day of month is always within 1-31 range;
59
 * month is always within 1-12 range;
77
 * month is always within 1-12 range;
60
 * year starts at 1980 and continues for 127 years */
78
 * year starts at 1980 and continues for 127 years */
61
time_t mdr_dos_date2unix(unsigned short d);
79
time_t mdr_dos_date2unix(unsigned short d);
62
 
80
 
63
/* converts a "DOS format" 16-bit packed time into hours, minutes and seconds
81
/* converts a "DOS format" 16-bit packed time into hours, minutes and seconds
64
 *
82
 *
65
 * A DOS time is a 16-bit value:
83
 * A DOS time is a 16-bit value:
66
 * HHHHHMMM MMMSSSSS
84
 * HHHHHMMM MMMSSSSS
67
 *
85
 *
68
 * HHHHH  = hours, always within 0-23 range
86
 * HHHHH  = hours, always within 0-23 range
69
 * MMMMMM = minutes, always within 0-59 range
87
 * MMMMMM = minutes, always within 0-59 range
70
 * SSSSS  = seconds/2 (always within 0-29 range) */
88
 * SSSSS  = seconds/2 (always within 0-29 range) */
71
void mdr_dos_time2hms(unsigned char *h, unsigned char *m, unsigned char *s, unsigned short t);
89
void mdr_dos_time2hms(unsigned char *h, unsigned char *m, unsigned char *s, unsigned short t);
72
 
90
 
73
#endif
91
#endif