11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <time.h>
#import "OFStrFTime.h"
#import "OFASPrintF.h"
#import "macros.h"
static const char weekDays[7][4] = {
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
};
static const char monthNames[12][4] = {
"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct",
|
<
<
|
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#include <string.h>
#include <time.h>
#import "OFStrFTime.h"
#import "macros.h"
static const char weekDays[7][4] = {
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
};
static const char monthNames[12][4] = {
"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct",
|
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
buffer[j++] = format[i];
}
break;
case stateInConversionSpecifier:;
const char *appendFormat;
unsigned int value = 0;
char *append;
int appendLen;
switch (format[i]) {
case '%':
appendFormat = "%%";
break;
case 'a':
|
|
|
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
buffer[j++] = format[i];
}
break;
case stateInConversionSpecifier:;
const char *appendFormat;
unsigned int value = 0;
char append[5];
int appendLen;
switch (format[i]) {
case '%':
appendFormat = "%%";
break;
case 'a':
|
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
value = (value / 60) * 100 + (value % 60);
break;
default:
return 0;
}
appendLen = OFASPrintF(&append, appendFormat, value);
if (appendLen < 0)
return 0;
if (bufferLen - j < (size_t)appendLen) {
free(append);
return 0;
}
memcpy(buffer + j, append, appendLen);
j += appendLen;
free(append);
state = stateSearchConversionSpecifier;
}
}
if (j >= bufferLen)
return 0;
buffer[j] = 0;
return j;
}
|
>
|
|
>
|
<
<
<
|
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
|
value = (value / 60) * 100 + (value % 60);
break;
default:
return 0;
}
appendLen = snprintf(append, sizeof(append),
appendFormat, value);
if (appendLen < 0 ||
(size_t)appendLen >= sizeof(append))
return 0;
if (bufferLen - j < (size_t)appendLen)
return 0;
memcpy(buffer + j, append, appendLen);
j += appendLen;
state = stateSearchConversionSpecifier;
}
}
if (j >= bufferLen)
return 0;
buffer[j] = 0;
return j;
}
|