1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2006 by Michael Sevakis
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
29 #if CONFIG_CODEC == SWCODEC
30 /* round a signed/unsigned 32bit value to the closest of a list of values */
31 /* returns the index of the closest value */
32 int round_value_to_list32(unsigned long value
,
33 const unsigned long list
[],
37 int make_list_from_caps32(unsigned long src_mask
,
38 const unsigned long *src_list
,
39 unsigned long caps_mask
,
40 unsigned long *caps_list
);
41 #endif /* CONFIG_CODEC == SWCODEC */
43 /* Create a filename with a number part in a way that the number is 1
44 * higher than the highest numbered file matching the same pattern.
45 * It is allowed that buffer and path point to the same memory location,
46 * saving a strcpy(). Path must always be given without trailing slash.
48 * "num" can point to an int specifying the number to use or NULL or a value
49 * less than zero to number automatically. The final number used will also
50 * be returned in *num. If *num is >= 0 then *num will be incremented by
52 #if defined(HAVE_RECORDING) && (CONFIG_RTC == 0)
53 /* this feature is needed by recording without a RTC to prevent disk access
54 when changing files */
55 #define IF_CNFN_NUM_(...) __VA_ARGS__
58 #define IF_CNFN_NUM_(...)
60 char *create_numbered_filename(char *buffer
, const char *path
,
61 const char *prefix
, const char *suffix
,
62 int numberlen
IF_CNFN_NUM_(, int *num
));
65 /* Create a filename with a date+time part.
66 It is allowed that buffer and path point to the same memory location,
67 saving a strcpy(). Path must always be given without trailing slash.
68 unique_time as true makes the function wait until the current time has
70 char *create_datetime_filename(char *buffer
, const char *path
,
71 const char *prefix
, const char *suffix
,
73 #endif /* CONFIG_RTC */
76 ** Compacted pointer lists
78 ** N-length list requires N+1 elements to ensure NULL-termination.
81 /* Find a pointer in a pointer array. Returns the addess of the element if
82 found or the address of the terminating NULL otherwise. This can be used
83 to bounds check and add items. */
84 void ** find_array_ptr(void **arr
, void *ptr
);
86 /* Remove a pointer from a pointer array if it exists. Compacts it so that
87 no gaps exist. Returns 0 on success and -1 if the element wasn't found. */
88 int remove_array_ptr(void **arr
, void *ptr
);
90 #endif /* GENERAL_H */