2 * Copyright (C) 2006-2011 Andre Noll <maan@systemlinux.org>
4 * Licensed under the GPL v2. For licencing details see COPYING.
7 /** \file string.h exported sybmols from string.c */
9 /** Flags that change how content is printed into the buffer. */
10 enum para_buffer_flags
{
11 /** Prefix each buffer with its length. */
15 /** A string buffer used for para_printf(). */
17 /** The buffer. May be \p NULL. */
19 /** The size of \a buf. */
21 /** The maximal size this buffer may grow. Zero means unlimited. */
23 /** \sa para_buffer_flags. */
25 /** The next para_printf() will write at this offset. */
28 * If an attempt to print into this buffer is made that would need to
29 * grow \a buf to a size larger than \a max_size, then this function is
32 int (*max_size_handler
)(char *buf
, size_t size
, void *private_data
);
33 /** Passed to max_size_handler(). */
38 * Write the contents of a status item to a para_buffer.
40 * \param b The para_buffer.
41 * \param n The number of the status item.
42 * \param f A format string.
44 * \return The return value of the underlying call to para_printf().
46 #define WRITE_STATUS_ITEM(b, n, f, ...) (\
49 if ((b)->flags & PBF_SIZE_PREFIX) { \
50 _ret = para_printf((b), "%02x:" f, n, ## __VA_ARGS__); \
52 _ret = para_printf((b), "%s: " f, status_item_list[(n)], \
59 __must_check __malloc
void *para_realloc(void *p
, size_t size
);
60 __must_check __malloc
void *para_malloc(size_t size
);
61 __must_check __malloc
void *para_calloc(size_t size
);
62 __must_check __malloc
char *para_strdup(const char *s
);
63 __must_check __malloc __printf_1_2
char *make_message(const char *fmt
, ...);
64 __must_check __malloc
char *para_strcat(char *a
, const char *b
);
65 __must_check __malloc
char *para_dirname(const char *name
);
66 __must_check
char *para_basename(const char *name
);
68 __must_check __malloc
char *para_logname(void);
69 __must_check __malloc
char *para_homedir(void);
70 __malloc
char *para_hostname(void);
71 __printf_2_3
int para_printf(struct para_buffer
*b
, const char *fmt
, ...);
72 /** Used for for_each_line() and for_each_line_ro(). */
73 typedef int line_handler_t(char *, void *);
74 int for_each_line(char *buf
, size_t size
, line_handler_t
*line_handler
,
76 int for_each_line_ro(char *buf
, size_t size
, line_handler_t
*line_handler
,
78 int para_atoi64(const char *str
, int64_t *result
);
79 int para_atoi32(const char *str
, int32_t *value
);
80 int get_loglevel_by_name(const char *txt
);
81 int read_size_header(const char *buf
);
82 int create_argv(const char *buf
, const char *delim
, char ***result
);
83 void free_argv(char **argv
);
84 int para_regcomp(regex_t
*preg
, const char *regex
, int cflags
);
85 void freep(void *arg
);