-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathlinux.cpp
More file actions
124 lines (95 loc) · 2 KB
/
linux.cpp
File metadata and controls
124 lines (95 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#include "_ldefs.h"
FILE *_fsopen (char *name, char *mode, int shflags)
{
shflags = shflags;
return (fopen (name, mode));
}
char *strlwr (char *s)
{
char *p = s;
while (*p != '\0') {
*p = (char)tolower (*p);
p++;
}
return (s);
}
char *strupr (char *s)
{
char *p = s;
while (*p != '\0') {
*p = (char)toupper (*p);
p++;
}
return (s);
}
void chsize (int fd, long size)
{
fd = fd;
size = size;
}
int strnicmp (char *s1, char *s2, size_t maxlen)
{
int i = maxlen;
do {
if (toupper (*s1) != toupper (*s2))
return ((int)(toupper (*s1) - toupper (*s2)));
s1++;
s2++;
} while (--maxlen > 0);
return (0);
}
int stricmp (char *s1, char *s2)
{
while (*s1 != '\0' && *s2 != '\0') {
if (toupper (*s1) != toupper (*s2))
return ((int)(toupper (*s1) - toupper (*s2)));
s1++;
s2++;
}
if (toupper (*s1) != toupper (*s2))
return ((int)(toupper (*s1) - toupper (*s2)));
return (0);
}
void _dos_getdate (struct dosdate_t *ddate)
{
time_t t;
struct tm *ltm;
t = time (NULL);
ltm = localtime (&t);
ddate->day = (unsigned char)ltm->tm_mday;
ddate->month = (unsigned char)(ltm->tm_mon + 1);
ddate->year = (unsigned int)(ltm->tm_year + 1900);
ddate->dayofweek = (unsigned char)ltm->tm_wday;
}
void _dos_gettime (struct dostime_t *dtime)
{
time_t t;
struct tm *ltm;
t = time (NULL);
ltm = localtime (&t);
dtime->hour = (unsigned char)ltm->tm_hour;
dtime->minute = (unsigned char)ltm->tm_min;
dtime->second = (unsigned char)ltm->tm_sec;
dtime->hsecond = 0;
}
long filelength (int fd)
{
long retval = -1L;
struct stat buf;
if (fd != -1) {
fstat (fd, &buf);
retval = buf.st_size;
}
return (retval);
}
long tell (int fd)
{
long retval = -1L;
if (fd != -1)
retval = lseek (fd, 0L, SEEK_CUR);
return (retval);
}
int sopen (char *file, int flags, int shmode, int mode)
{
return (open (file, flags|shmode, mode));
}