]>
Commit | Line | Data |
---|---|---|
cde1c287 BP |
1 | /* |
2 | * Copyright (c) 2013 Nicira, Inc. | |
3 | * | |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | * you may not use this file except in compliance with the License. | |
6 | * You may obtain a copy of the License at: | |
7 | * | |
8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
15 | */ | |
16 | ||
17 | #include <config.h> | |
18 | ||
19 | #include <stdio.h> | |
f69aa256 | 20 | #include <sys/types.h> |
cde1c287 BP |
21 | |
22 | #ifdef _WIN32 | |
23 | #undef snprintf | |
24 | #undef vsnprintf | |
25 | ||
26 | int | |
27 | ovs_snprintf(char *s, size_t n, const char *format, ... ) | |
28 | { | |
29 | va_list args; | |
30 | int len; | |
31 | ||
32 | va_start(args, format); | |
33 | len = ovs_vsnprintf(s, n, format, args); | |
34 | va_end(args); | |
35 | ||
36 | return len; | |
37 | } | |
38 | ||
39 | int | |
40 | ovs_vsnprintf(char *s, size_t n, const char *format, va_list args) | |
41 | { | |
42 | int needed = _vscprintf(format, args); | |
43 | if (s && n) { | |
44 | vsnprintf(s, n, format, args); | |
45 | s[n - 1] = '\0'; | |
46 | } | |
47 | return needed; | |
48 | } | |
f69aa256 GS |
49 | |
50 | int | |
51 | fseeko(FILE *stream, off_t offset, int whence) | |
52 | { | |
53 | int error; | |
54 | error = _fseeki64(stream, offset, whence); | |
55 | if (error) { | |
56 | return -1; | |
57 | } | |
58 | return error; | |
59 | } | |
cde1c287 | 60 | #endif /* _WIN32 */ |