• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 GOODIX.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <stdarg.h>
17 #include <stdio.h>
18 #include "securec.h"
19 
20 #define BUFSIZE  256
21 
22 
printf(const char * __restrict __format,...)23 int printf(const char *__restrict __format, ...)
24 {
25     char buf[BUFSIZE] = { 0 };
26     int len;
27     va_list ap;
28     va_start(ap, __format);
29     len = vsnprintf_s(buf, sizeof(buf), BUFSIZE - 1, __format, ap);
30     if (len < 0) {
31         return len;
32     }
33 
34     va_end(ap);
35     if (len > 0) {
36         char const *s = buf;
37         while (*s) {
38             _putchar(*s++);
39         }
40     }
41     return len;
42 }
43 
44 /*
45 int sprintf(char *buf, const char *fmt, ...)
46 {
47     va_list args;
48     int val;
49 
50     va_start(args, fmt);
51     val = vsprintf_s(buf, fmt, args);
52     va_end(args);
53 
54     return val;
55 }
56 */
57