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