-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathckvold.c
More file actions
93 lines (83 loc) · 1.55 KB
/
ckvold.c
File metadata and controls
93 lines (83 loc) · 1.55 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
#module ckvold "1.0-007"
/* C K V O L D -- C-Kermit file system support for VAX/VMS V4. */
/* Edit history
* 001 22-Jan-91 wb Initial version with memcpy, memmove
* 002 24-Apr-91 wb Added memset
* 003 01-Jul-91 wb Added strstr
* 004 26-Nov-91 wb Added system
* 006 10-Nov-96 lh All needed w/ VAXCRTL 4-009 (VMS 4.4)
* Only strstr needed w/ VAXCRTL 4-013 (VMS 4.6)
* 007 05-Sep-99 wb Added fmod
*/
char *strstr(a, b)
const char *a;
const char *b;
{
int len;
if (!a || !b) return((char *)0);
if (!*b) return(a);
len = strlen(b);
while (*a) {
if (!strncmp(a, b, len)) return(a);
a++;
}
return((char *)0);
}
#ifndef VMS_V46
void *memcpy(d, s, n)
void *d, *s;
register int n;
{
register char *ss = (char *)s, *dd = (char *)d;
while (n-- > 0)
*dd++ = *ss++;
return d;
}
void *memmove(d, s, n)
void *d;
const void *s;
register int n;
{
register char *dd = (char *)d, *ss = (char *)s;
if (dd < ss || dd - ss >= n) {
while (n-- > 0)
*dd++ = *ss++;
} else if (n > 0) {
dd += n;
ss += n;
while (n-- > 0)
*--dd = *--ss;
}
return d;
}
void *memset(d, c, n)
void *d;
register int c;
register int n;
{
register char *dd = (char *)d;
while (n-- > 0)
*dd++ = c;
return d;
}
int system(s)
char *s;
{
while (*s == ' ' || *s == '$') s++;
zsyscmd(s);
return(1);
}
double fmod(x, y)
double x, y;
{
int a;
if (x == 0 || y == 0) {
a = x;
} else if ((x > 0 && y > 0) || (x < 0 && y < 0)) {
a = x - y*floor(x/y);
} else {
a = x - y*ceil(x/y);
}
return a;
}
#endif /* ! VMS_V46 */