1 /************************************************************************
4 * (c) Copyright 2023, FSF. Inc., Hangzhou, China
5 * (c) Copyright 2023, ×ÔÓÉÈí¼þ»ù½ð»á. Inc., º¼ÖÝ, Öйú
6 ************************************************************************
8 * function: StrBuffÄ£¿é¡£
9 * createdate: 2023-06-19
10 * author: devenkong@126.com
11 * note£º it extract string buffer code in menuconfig program,
12 * and append new style interface.
14 ************************************************************************/
16 /************************************************************************
21 ************************************************************************/
23 #ifndef __STR_BUFF_H__
24 #define __STR_BUFF_H__
28 /* Type Definations */
34 * when max_width is not zero long lines in string s (if any) get
35 * wrapped not to exceed the max_width value
41 * buffer for T_WORD/T_XXX_CONST/T_WORD_QUOTES ...
43 typedef struct __tag_CACHING_STR
{
45 int text_size
, text_asize
;
46 } CACHING_STR
, *PCACHING_STR
;
48 /* Public Variables and Functions */
50 /* lxr caching buffer */
51 extern CACHING_STR strbuff
;
54 /* memory allocation function set */
55 extern struct gstr
str_new(void);
56 extern void str_free(struct gstr
*gs
);
57 extern void str_append(struct gstr
*gs
, const char *s
);
58 extern void str_printf(struct gstr
*gs
, const char *fmt
, ...);
59 extern const char *str_get(struct gstr
*gs
);
61 /* caching string buffer for T_WORD and others */
63 extern int is_empty_string (CACHING_STR
*pstr_cache
);
64 extern int is_unallocated_string (CACHING_STR
*pstr_cache
);
65 extern void init_strbuff (CACHING_STR
*pstr_cache
);
66 extern void new_string (CACHING_STR
*pstr_cache
);
67 extern void append_string (CACHING_STR
*pstr_cache
, const char *str
, int size
);
68 extern void alloc_string (CACHING_STR
*pstr_cache
, const char *str
, int size
);
69 extern int const_string (CACHING_STR
*pstr_cache
, int token
);
70 extern CACHING_STR
* dup_string (CACHING_STR
*pstr_cache
, CACHING_STR
*p_dst_str_cache
);
71 extern void free_string (CACHING_STR
*pstr_cache
);
72 extern void ln_string (CACHING_STR
*pstr_cache
);
74 #endif /* __STR_BUFF_H__ */