Subversion Repositories SvarDOS

Rev

Rev 1364 | Rev 1413 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1409 mateusz.vi 1
/*
2
 * Functions interacting with DOS
3
 *
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.
6
 *
7
 * Copyright (C) 2014-2023 Mateusz Viste
8
 *
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
11
 * deal in the Software without restriction, including without limitation the
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
14
 * furnished to do so, subject to the following conditions:
15
 *
16
 * The above copyright notice and this permission notice shall be included in
17
 * all copies or substantial portions of the Software.
18
 *
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,
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
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
25
 * IN THE SOFTWARE.
26
 */
27
 
28
#ifndef MDR_DOS_H
29
#define MDR_DOS_H
30
 
31
#include <time.h> /* time_t */
32
 
33
/* returns a far pointer to the current process PSP structure */
34
void far *mdr_dos_psp(void);
35
 
36
/* returns a far pointer to the environment block of the current process */
37
char far *mdr_dos_env(void);
38
 
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
41
 * (reslimit exceeded). returns result on success.
42
 * NOTE: this function performs case-sensitive matches */
43
char *mdr_dos_getenv(char *result, const char *varname, unsigned short reslimit);
44
 
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
47
 * always terminated with a backslash separator, unless it is an empty string */
48
unsigned char mdr_dos_exepath(char *path);
49
 
50
/* returns a far pointer to the full path and filename of the running program.
51
 * returns NULL on error. */
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);
71
 
72
/* converts a "DOS format" 16-bit packed date into a standard (time_t)
73
 * unix timestamp. A DOS date is a 16-bit value:
74
 * YYYYYYYM MMMDDDDD
75
 *
76
 * day of month is always within 1-31 range;
77
 * month is always within 1-12 range;
78
 * year starts at 1980 and continues for 127 years */
79
time_t mdr_dos_date2unix(unsigned short d);
80
 
81
/* converts a "DOS format" 16-bit packed time into hours, minutes and seconds
82
 *
83
 * A DOS time is a 16-bit value:
84
 * HHHHHMMM MMMSSSSS
85
 *
86
 * HHHHH  = hours, always within 0-23 range
87
 * MMMMMM = minutes, always within 0-59 range
88
 * SSSSS  = seconds/2 (always within 0-29 range) */
89
void mdr_dos_time2hms(unsigned char *h, unsigned char *m, unsigned char *s, unsigned short t);
90
 
91
#endif