Implement utility functions for dynamic strings
Introduce support for strings which support concatenating the current value with a printf-style formatted value, thereby growing in size dynamically. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
@@ -601,6 +601,13 @@ struct nbar {
|
||||
pthread_mutex_t mutex;
|
||||
};
|
||||
|
||||
/* Dynamic strings. */
|
||||
struct string {
|
||||
char *buf;
|
||||
int bufsize;
|
||||
int len;
|
||||
};
|
||||
|
||||
/* Return codes for the getstring() function. */
|
||||
enum getstr {
|
||||
GETSTRING_VALID,
|
||||
@@ -982,6 +989,15 @@ unsigned sigs_set_hdlr(int, void (*)(int));
|
||||
void sigs_ignore(void);
|
||||
void sigs_unignore(void);
|
||||
|
||||
/* strings.c */
|
||||
void string_init(struct string *);
|
||||
void string_reset(struct string *);
|
||||
int string_grow(struct string *, int);
|
||||
char *string_buf(struct string *);
|
||||
int string_catf(struct string *, const char *, ...);
|
||||
int string_vcatf(struct string *, const char *, va_list);
|
||||
int string_printf(struct string *, const char *, ...);
|
||||
|
||||
/* todo.c */
|
||||
extern llist_t todolist;
|
||||
struct todo *todo_get_item(int);
|
||||
|
||||
Reference in New Issue
Block a user