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 int iso_date(char * p, int flag)
89 {
90 int year, month, day, hour ,minute, second, tz;
91 int crtime, days, i;
92
93 year = p[0] - 70;
94 month = p[1];
95 day = p[2];
96 hour = p[3];
97 minute = p[4];
98 second = p[5];
99 if (flag == 0) tz = p[6];
100 else tz = 0;
101
102 if (year < 0) {
103 crtime = 0;
104 } else {
105 int monlen[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
106 days = year * 365;
107 if (year > 2)
108 days += (year+2) / 4;
109 for (i = 1; i < month; i++)
110 days += monlen[i-1];
111 if (((year+2) % 4) == 0 && month > 2)
112 days++;
113 days += day - 1;
114 crtime = ((((days * 24) + hour) * 60 + minute) * 60)
115 + second;
116
117
118 if (tz & 0x80)
119 tz |= (-1 << 8);
120
121
122 if (-48 <= tz && tz <= 52)
123 crtime += tz * 15 * 60;
124 }
125 return crtime;
126 }
127