Subversion Repositories SvarDOS

Rev

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

Rev Author Line No. Line
1360 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-2022 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
 
1364 mateusz.vi 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
 
1360 mateusz.vi 54
/* converts a "DOS format" 16-bit packed date into a standard (time_t)
55
 * unix timestamp. A DOS date is a 16-bit value:
56
 * YYYYYYYM MMMDDDDD
57
 *
58
 * day of month is always within 1-31 range;
59
 * month is always within 1-12 range;
60
 * year starts at 1980 and continues for 127 years */
61
time_t mdr_dos_date2unix(unsigned short d);
62
 
63
/* converts a "DOS format" 16-bit packed time into hours, minutes and seconds
64
 *
65
 * A DOS time is a 16-bit value:
66
 * HHHHHMMM MMMSSSSS
67
 *
68
 * HHHHH  = hours, always within 0-23 range
69
 * MMMMMM = minutes, always within 0-59 range
70
 * 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);
72
 
73
#endif