This source file includes following definitions.
- isonum_711
- isonum_712
- isonum_721
- isonum_722
- isonum_723
- isonum_731
- isonum_732
- isonum_733
- iso_date
1
2
3
4
5
6
7
8
9
10
11
12 #ifdef MODULE
13 #include <linux/module.h>
14 #endif
15
16
17 int
18 isonum_711 (char * p)
19 {
20 return (*p & 0xff);
21 }
22
23 int
24 isonum_712 (char * p)
25 {
26 int val;
27
28 val = *p;
29 if (val & 0x80)
30 val |= 0xffffff00;
31 return (val);
32 }
33
34 int
35 isonum_721 (char * p)
36 {
37 return ((p[0] & 0xff) | ((p[1] & 0xff) << 8));
38 }
39
40 int
41 isonum_722 (char * p)
42 {
43 return (((p[0] & 0xff) << 8) | (p[1] & 0xff));
44 }
45
46 int
47 isonum_723 (char * p)
48 {
49 #if 0
50 if (p[0] != p[3] || p[1] != p[2]) {
51 fprintf (stderr, "invalid format 7.2.3 number\n");
52 exit (1);
53 }
54 #endif
55 return (isonum_721 (p));
56 }
57
58 int
59 isonum_731 (char * p)
60 {
61 return ((p[0] & 0xff)
62 | ((p[1] & 0xff) << 8)
63 | ((p[2] & 0xff) << 16)
64 | ((p[3] & 0xff) << 24));
65 }
66
67 int
68 isonum_732 (char * p)
69 {
70 return (((p[0] & 0xff) << 24)
71 | ((p[1] & 0xff) << 16)
72 | ((p[2] & 0xff) << 8)
73 | (p[3] & 0xff));
74 }
75
76 int
77 isonum_733 (char * p)
78 {
79 #if 0
80 int i;
81
82 for (i = 0; i < 4; i++) {
83 if (p[i] != p[7-i]) {
84 fprintf (stderr, "bad format 7.3.3 number\n");
85 exit (1);
86 }
87 }
88 #endif
89 return (isonum_731 (p));
90 }
91
92
93
94
95
96 int iso_date(char * p, int flag)
97 {
98 int year, month, day, hour ,minute, second, tz;
99 int crtime, days, i;
100
101 year = p[0] - 70;
102 month = p[1];
103 day = p[2];
104 hour = p[3];
105 minute = p[4];
106 second = p[5];
107 if (flag == 0) tz = p[6];
108 else tz = 0;
109
110 if (year < 0) {
111 crtime = 0;
112 } else {
113 int monlen[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
114 days = year * 365;
115 if (year > 2)
116 days += (year+1) / 4;
117 for (i = 1; i < month; i++)
118 days += monlen[i-1];
119 if (((year+2) % 4) == 0 && month > 2)
120 days++;
121 days += day - 1;
122 crtime = ((((days * 24) + hour) * 60 + minute) * 60)
123 + second;
124
125
126 if (tz & 0x80)
127 tz |= (-1 << 8);
128
129
130 if (-48 <= tz && tz <= 52)
131 crtime += tz * 15 * 60;
132 }
133 return crtime;
134 }
135