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