• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
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 #ifndef __SECUREPRINTOUTPUT_H__E950DA2C_902F_4B15_BECD_948E99090D9C
17 #define __SECUREPRINTOUTPUT_H__E950DA2C_902F_4B15_BECD_948E99090D9C
18 #include "securecutil.h"
19 
20 #if SECUREC_IN_KERNEL == 0
21 
22 /* flag definitions */
23 /* Using macros instead of enumerations is because some of the enumerated types under the compiler are 16bit. */
24 #define SECUREC_FLAG_SIGN           0x00001U
25 #define SECUREC_FLAG_SIGN_SPACE     0x00002U
26 #define SECUREC_FLAG_LEFT           0x00004U
27 #define SECUREC_FLAG_LEADZERO       0x00008U
28 #define SECUREC_FLAG_LONG           0x00010U
29 #define SECUREC_FLAG_SHORT          0x00020U
30 #define SECUREC_FLAG_SIGNED         0x00040U
31 #define SECUREC_FLAG_ALTERNATE      0x00080U
32 #define SECUREC_FLAG_NEGATIVE       0x00100U
33 #define SECUREC_FLAG_FORCE_OCTAL    0x00200U
34 #define SECUREC_FLAG_LONG_DOUBLE    0x00400U
35 #define SECUREC_FLAG_WIDECHAR       0x00800U
36 #define SECUREC_FLAG_LONGLONG       0x01000U
37 #define SECUREC_FLAG_CHAR           0x02000U
38 #define SECUREC_FLAG_POINTER        0x04000U
39 #define SECUREC_FLAG_I64            0x08000U
40 #define SECUREC_FLAG_PTRDIFF        0x10000U
41 #define SECUREC_FLAG_SIZE           0x20000U
42 #ifdef  SECUREC_COMPATIBLE_LINUX_FORMAT
43 #define SECUREC_FLAG_INTMAX         0x40000U
44 #endif
45 
46 /* state definitions */
47 typedef enum {
48     STAT_NORMAL,
49     STAT_PERCENT,
50     STAT_FLAG,
51     STAT_WIDTH,
52     STAT_DOT,
53     STAT_PRECIS,
54     STAT_SIZE,
55     STAT_TYPE,
56     STAT_INVALID
57 } SecFmtState;
58 
59 #ifdef SECUREC_STACK_SIZE_LESS_THAN_1K
60 /* SECUREC_BUFFER_SIZE Can not be less than 23 ,
61  *the length of the octal representation of 64-bit integers with zero lead
62  */
63 #define SECUREC_BUFFER_SIZE    256
64 #else
65 #define SECUREC_BUFFER_SIZE    512
66 #endif
67 
68 #define SECUREC_MAX_PRECISION  SECUREC_BUFFER_SIZE
69 /* max. # bytes in multibyte char  ,see MB_LEN_MAX */
70 #define SECUREC_MB_LEN 16
71 
72 #ifdef __cplusplus
73 extern "C" {
74 #endif
75 
76     extern int SecOutputS(SecPrintfStream *stream, const char *cformat, va_list arglist);
77     extern int SecOutputSW(SecPrintfStream *stream, const wchar_t *cformat, va_list arglist);
78 
79 #ifdef __cplusplus
80 }
81 #endif
82 
83 #endif
84 
85 #endif
86 
87 
88