summaryrefslogtreecommitdiff
path: root/string.h
blob: 272f107dfe8aac23a95549f5faedcf50b07493e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
 * Copyright (C) 2006-2009 Andre Noll <maan@systemlinux.org>
 *
 * Licensed under the GPL v2. For licencing details see COPYING.
 */

/** \file string.h exported sybmols from string.c */

/** A string buffer used for para_printf(). */
struct para_buffer {
	/** The buffer. May be \p NULL. */
	char *buf;
	/** The size of \a buf. */
	size_t size;
	/** The maximal size this buffer may grow. Zero means unlimited. */
	size_t max_size;
	/** The next para_printf() will write at this offset. */
	size_t offset;
	/**
	 * If an attempt to print into this buffer is made that would need to
	 * grow \a buf to a size larger than \a max_size, then this function is
	 * called.
	 */
	int (*max_size_handler)(char *buf, size_t size, void *private_data);
	/** Passed to max_size_handler(). */
	void *private_data;
};

__must_check __malloc void *para_realloc(void *p, size_t size);
__must_check __malloc void *para_malloc(size_t size);
__must_check __malloc void *para_calloc(size_t size);
__must_check __malloc char *para_strdup(const char *s);
__must_check __malloc __printf_1_2 char *make_message(const char *fmt, ...);
__must_check __malloc char *para_strcat(char *a, const char *b);
__must_check __malloc char *para_dirname(const char *name);
__must_check const char *para_basename(const char *name);
void chop(char *buf);
__must_check __malloc char *para_tmpname(void);
__must_check __malloc char *para_logname(void);
__must_check __malloc char *para_homedir(void);
unsigned split_args(char *args, char *** const argv_ptr, const char *delim);
__malloc char *para_hostname(void);
__printf_2_3 int para_printf(struct para_buffer *b, const char *fmt, ...);
/** Used for for_each_line() and for_each_line_ro(). */
typedef int line_handler_t(char *, void *);
int for_each_line(char *buf, size_t size, line_handler_t *line_handler,
	void *private_data);
int for_each_line_ro(char *buf, size_t size, line_handler_t *line_handler,
	void *private_data);
int para_atoi64(const char *str, int64_t *result);
int para_atoi32(const char *str, int32_t *value);
int get_loglevel_by_name(const char *txt);
> 2007-09-15Invalidate table pointers on shutdown.Andre Noll This caused a segfault when com_init() was invoked twice because osl was trying to close an already closed table. Also, add a bunch of error descriptions. 2007-09-15Rename osl index entry stuff.Andre Noll struct osl_table: index_entry_size -> row_index_size get_index_entry_start -> get_row_index get_index_entry -> get_cell_index update_index_entry -> update_cell_index 2007-09-15loglevel adjustments.Andre Noll 2007-09-15error.h: Add error message for E_NO_MATCH.Andre Noll 2007-09-15osl.c: Fix a bug in osl_update_object().Andre Noll In case a mapped column is being updated, we have to unmap the thing before appending to the data file. 2007-09-15com_add(): Add missing return statement.Andre Noll Duplicates were added twice in force mode. 2007-09-15Fix the privious assertion().Andre Noll It's OK to ask for the name of an audio format id < 0, as id -1 is used for "currently no audio file is open". So allow this case, and fix the upper bound which was off by one while we're at it. 2007-09-15audio_format_name(): Add an assert().Andre Noll The paraslash code should never request the name of an audio format with invalid id. Introduce the ARRAY_SIZE macro to get the proper upper bound for the number of supported audio formats. 2007-09-15ogg_afh.c: Store the bitrate in KHz rather than in Hz.Andre Noll The other audio format handlers also do it that way. 2007-09-15command.c: Fix om_help().Andre Noll It segfaulted due to a missing return statement. 2007-09-15command.c: Increase maximal command length.Andre Noll 4096 is really short if you want to pass lots of filenames. 2007-09-14More loglevel adjustments.Andre Noll 2007-09-14afs.cmd: Add documentation of com_afs_ls.Andre Noll 2007-09-14com_afs_ls(): Fix output width of duration.Andre Noll 2007-09-14loglevel adjustments.Andre Noll Adding many audio files was way to verbose.. 2007-09-14afs: com_add() fixes and improvements.Andre Noll - Simplify verify_path() - make com_add() accept paths that end with a slash. - add_one_audio_file() _always_ returns success. 2007-09-14rc4: Round up output buffer size.Andre Noll valgrind indicated that RC4() writes beyond the end of the output buffer which was was of the same size than the input buffer. Workaround this by rounding up the output buffer size to a multiple of 8. 2007-09-13aac_afh.c: Fix serious memory leak.Andre Noll Ooops. We forgot to close the AAC decoder handle... 2007-09-13Fix com_add segfault.Andre Noll We call free(obj.data) unconditionally on errors, but is is not set to NULL. Also, return always success in add_one_audio_file() in order to continue the loop. 2007-09-13ogg_afh.c: Fix a memory leak.Andre Noll In an non-ogg file is passed to the ogg audio format handler, such that the initial ogg_sync_pageout() fails, the old code leaked the memory which was allocated for the stream_in and the stream_out pointers. 2007-09-13com_add: Minor improvements.Andre Noll Continue if an audio file could not be added and print proper error message in case of errors. 2007-09-12aft.c: Fix com_add().Andre Noll callbacks shall return zero or negative, if no result is provided. So let com_ls_callback() return zero if no match was found, or if the audio file table does not contain any entries. Check for ret > 0 in com_add() instead of ret >= 0, i.e. don't use the result pointer if ret is zero. 2007-09-12afs.c: Fix com_init().Andre Noll It didn't use callbacks which worked before the paraslash merge only. 2007-09-12afs.c: Add log message, cast sizeof().Andre Noll In case the local socket could not be created, we really should tell the user that fact. The other change in this patch is casting sizeof() to unsigned long which shuts gcc up on both i386 and x86_64. 2007-09-12string.c: Use $HOME to get the home directory.Andre Noll This is actually simpler than using getpwuid(), and it shuts up a valgrind warning as well. 2007-09-12vss_init(): Use FOR_EACH_AUDIO_FORMAT() instead of open coding the loop.Andre Noll Fixes a segfault on startup in case not all three audio formats are supported. 2007-09-10Fix afs_shutdown().Andre Noll Unregister tasks as soon as we catch a terminating signal and call afs_shutdown() when sched() returns. 2007-09-10osl.c: Dereference pointer _after_ checking for NULL.Andre Noll 2007-09-10afs: Replace DATABASE_DIR by a runtime config option.Andre Noll Also, split afs_init() into two parts: The new open_afs_tables() that does what its name suggests and the remaining part that initializes the scheduler. 2007-09-10afs: Minor improvements and fixes.Andre Noll - Fix audio format handler output of ls -v. - add_one_audio_file(): Write log messages to the client fd instead of para_server's logfile. 2007-09-10Fix two typos in documentation.Andre Noll 2007-09-10Doxyfile: set EXTRACT_ALL to yes.Andre Noll Otherwise doxygen gives zillions of warnings. 2007-09-10Add a new style file.Andre Noll For v0.3 the outfit should at least change a bit ;) 2007-09-10afs com_add(): Recognize also audio formats different from mp3.Andre Noll This required adding two more callbacks: path_brother_callback() and hash_sister_callback(). These are called from add_one_audio_file() which runs from handler context and can thus not access the database directly. 2007-09-09Change the type of the argv argument of all commands.Andre Noll The new type, char * const * const argv is what the exec functions also take. This avoids some warnings. 2007-09-09Fix some format string warnings on x86_64.Andre Noll 2007-09-09Add documentation for com_add().Andre Noll 2007-09-09Makefile.in: Add afs_command_list.man to the list of server commands.Andre Noll 2007-09-09vss.c: Introduce get_audio_file_info().Andre Noll This is going to be used from within aft's com_add() which ATM only supports mp3. 2007-09-09afh.h: Kill unused SUPPORTED_AUDIO_FORMATS_ARRAY.Andre Noll 2007-09-09afs.c: Kill unused struct callback_data.Andre Noll