Rename daemon_init() to daemonize().
[paraslash.git] / string.h
1 /*
2  * Copyright (C) 2006-2009 Andre Noll <maan@systemlinux.org>
3  *
4  * Licensed under the GPL v2. For licencing details see COPYING.
5  */
6
7 /** \file string.h exported sybmols from string.c */
8
9 /** A string buffer used for para_printf(). */
10 struct para_buffer {
11         /** The buffer. May be \p NULL. */
12         char *buf;
13         /** The size of \a buf. */
14         size_t size;
15         /** The maximal size this buffer may grow. Zero means unlimited. */
16         size_t max_size;
17         /** The next para_printf() will write at this offset. */
18         size_t offset;
19         /**
20          * If an attempt to print into this buffer is made that would need to
21          * grow \a buf to a size larger than \a max_size, then this function is
22          * called.
23          */
24         int (*max_size_handler)(char *buf, size_t size, void *private_data);
25         /** Passed to max_size_handler(). */
26         void *private_data;
27 };
28
29 __must_check __malloc void *para_realloc(void *p, size_t size);
30 __must_check __malloc void *para_malloc(size_t size);
31 __must_check __malloc void *para_calloc(size_t size);
32 __must_check __malloc char *para_strdup(const char *s);
33 __must_check __malloc __printf_1_2 char *make_message(const char *fmt, ...);
34 __must_check __malloc char *para_strcat(char *a, const char *b);
35 __must_check __malloc char *para_dirname(const char *name);
36 __must_check const char *para_basename(const char *name);
37 void chop(char *buf);
38 __must_check __malloc char *para_tmpname(void);
39 __must_check __malloc char *para_logname(void);
40 __must_check __malloc char *para_homedir(void);
41 __must_check unsigned split_args(char *args, char *** const argv_ptr, const char *delim);
42 __malloc char *para_hostname(void);
43 __printf_2_3 int para_printf(struct para_buffer *b, const char *fmt, ...);
44 /** Used for for_each_line() and for_each_line_ro(). */
45 typedef int line_handler_t(char *, void *);
46 int for_each_line(char *buf, size_t size, line_handler_t *line_handler,
47         void *private_data);
48 int for_each_line_ro(char *buf, size_t size, line_handler_t *line_handler,
49         void *private_data);
50 int para_atoi64(const char *str, int64_t *result);
51 int para_atoi32(const char *str, int32_t *value);