use tokenlist for lexer parser.
[build-config.git] / src / config / lxrgmr-code / lib / StrBuff.h
blob3c597962168575849e715b0d8bec82ecdaef0ebf
1 /************************************************************************
2 * reglxgmr
4 * (c) Copyright 2023, FSF. Inc., Hangzhou, China
5 * (c) Copyright 2023, ×ÔÓÉÈí¼þ»ù½ð»á. Inc., º¼ÖÝ, Öйú
6 ************************************************************************
7 * filename: StrBuff.h
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 ************************************************************************/
15 /* Modify record */
16 /************************************************************************
17 * date: $DATE
18 * author: $AUTHOR
19 * note:
21 ************************************************************************/
23 #ifndef __STR_BUFF_H__
24 #define __STR_BUFF_H__
26 //#include "type.h"
28 /* Type Definations */
30 struct gstr {
31 size_t len;
32 char *s;
34 * when max_width is not zero long lines in string s (if any) get
35 * wrapped not to exceed the max_width value
37 int max_width;
41 * buffer for T_WORD/T_XXX_CONST/T_WORD_QUOTES ...
43 typedef struct __tag_STR_BUFF {
44 char *text;
45 int text_size, text_asize;
46 } STR_BUFF, *PSTR_BUFF;
48 /* Public Variables and Functions */
50 /* lxr caching buffer */
51 extern STR_BUFF 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 (STR_BUFF *pstr_cache);
64 extern int is_unallocated_string (STR_BUFF *pstr_cache);
65 extern void init_strbuff (STR_BUFF *pstr_cache);
66 extern void new_string (STR_BUFF *pstr_cache);
67 extern void append_string (STR_BUFF *pstr_cache, const char *str, int size);
68 extern void ungetc_string (STR_BUFF *pstr_cache, int size);
69 extern void alloc_string (STR_BUFF *pstr_cache, const char *str, int size);
70 extern int const_string (STR_BUFF *pstr_cache, int token);
71 extern STR_BUFF *dup_string (STR_BUFF *pstr_cache, STR_BUFF *p_dst_str_cache);
72 extern STR_BUFF *copy_string (STR_BUFF *pstr_cache, STR_BUFF *p_dst_str_cache);
73 extern void free_string (STR_BUFF *pstr_cache);
74 extern void ln_string (STR_BUFF *pstr_cache);
76 #endif /* __STR_BUFF_H__ */