1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 by Daniel Stenberg
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 ****************************************************************************/
28 /* Format a large-range value for output, using the appropriate unit so that
29 * the displayed value is in the range 1 <= display < 1000 (1024 for "binary"
30 * units) if possible, and 3 significant digits are shown. If a buffer is
31 * given, the result is snprintf()'d into that buffer, otherwise the result is
33 char *output_dyn_value(char *buf
, int buf_size
, int value
,
34 const unsigned char **units
, bool bin_scale
);
36 /* Create a filename with a number part in a way that the number is 1
37 * higher than the highest numbered file matching the same pattern.
38 * It is allowed that buffer and path point to the same memory location,
39 * saving a strcpy(). Path must always be given without trailing slash.
41 * "num" can point to an int specifying the number to use or NULL or a value
42 * less than zero to number automatically. The final number used will also
43 * be returned in *num. If *num is >= 0 then *num will be incremented by
45 #if defined(HAVE_RECORDING) && (CONFIG_RTC == 0)
46 /* this feature is needed by recording without a RTC to prevent disk access
47 when changing files */
48 #define IF_CNFN_NUM_(...) __VA_ARGS__
51 #define IF_CNFN_NUM_(...)
53 char *create_numbered_filename(char *buffer
, const char *path
,
54 const char *prefix
, const char *suffix
,
55 int numberlen
IF_CNFN_NUM_(, int *num
));
57 /* Format time into buf.
59 * buf - buffer to format to.
60 * buf_size - size of buffer.
61 * t - time to format, in milliseconds.
63 void format_time(char* buf
, int buf_size
, long t
);
66 /* Create a filename with a date+time part.
67 It is allowed that buffer and path point to the same memory location,
68 saving a strcpy(). Path must always be given without trailing slash.
69 unique_time as true makes the function wait until the current time has
71 char *create_datetime_filename(char *buffer
, const char *path
,
72 const char *prefix
, const char *suffix
,
74 #endif /* CONFIG_RTC */
76 /* Ask the user if they really want to erase the current dynamic playlist
77 * returns true if the playlist should be replaced */
78 bool warn_on_pl_erase(void);
80 /* Read (up to) a line of text from fd into buffer and return number of bytes
81 * read (which may be larger than the number of bytes stored in buffer). If
82 * an error occurs, -1 is returned (and buffer contains whatever could be
83 * read). A line is terminated by a LF char. Neither LF nor CR chars are
86 int read_line(int fd
, char* buffer
, int buffer_size
);
87 int fast_readline(int fd
, char *buf
, int buf_size
, void *parameters
,
88 int (*callback
)(int n
, const char *buf
, void *parameters
));
90 #ifdef HAVE_LCD_BITMAP
91 /* Save a .BMP file containing the current screen contents. */
92 void screen_dump(void);
93 void screen_dump_set_hook(void (*hook
)(int fh
));
96 /* Make BMP colour map entries from R, G, B triples, without and with blending.
97 * Not within HAVE_LCD_BITMAP because it is also used for the Player sim */
98 #define RED_CMP(c) (((c) >> 16) & 0xff)
99 #define GREEN_CMP(c) (((c) >> 8) & 0xff)
100 #define BLUE_CMP(c) ((c) & 0xff)
102 #define BMP_COLOR(c) BLUE_CMP(c), GREEN_CMP(c), RED_CMP(c), 0
103 #define BMP_COLOR_MIX(c1, c2, num, den) \
104 (BLUE_CMP(c2) - BLUE_CMP(c1)) * (num) / (den) + BLUE_CMP(c1), \
105 (GREEN_CMP(c2) - GREEN_CMP(c1)) * (num) / (den) + GREEN_CMP(c1), \
106 (RED_CMP(c2) - RED_CMP(c1)) * (num) / (den) + RED_CMP(c1), 0
108 bool settings_parseline(char* line
, char** name
, char** value
);
109 long default_event_handler_ex(long event
, void (*callback
)(void *), void *parameter
);
110 long default_event_handler(long event
);
111 bool list_stop_handler(void);
112 void car_adapter_mode_init(void);
113 extern int show_logo(void);
115 #if CONFIG_CODEC == SWCODEC
116 /* Return current ReplayGain mode a file should have (REPLAYGAIN_TRACK or
117 * REPLAYGAIN_ALBUM) if ReplayGain processing is enabled, or -1 if no
118 * information present.
120 int get_replaygain_mode(bool have_track_gain
, bool have_album_gain
);
123 int open_utf8(const char* pathname
, int flags
);
126 #if !defined(USB_NONE) && !defined(USB_IPODSTYLE)
127 void check_bootfile(bool do_rolo
);
131 /* check range, set volume and save settings */
134 #ifdef HAVE_LCD_COLOR
135 int hex_to_rgb(const char* hex
, int* color
);
138 char* strrsplt(char* str
, int c
);
139 char* skip_whitespace(char* const str
);
140 bool file_exists(const char *file
);
141 bool dir_exists(const char *path
);
144 * removes the extension of filename (if it doesn't start with a .)
145 * puts the result in buffer
147 char *strip_extension(char* buffer
, int buffer_size
, const char *filename
);
149 /* A simplified scanf */
151 * Checks whether the value at position 'position' was really read
152 * during a call to 'parse_list'
153 * - position: 0-based number of the value
154 * - valid_vals: value after the call to 'parse_list'
156 #define LIST_VALUE_PARSED(setvals, position) ((setvals)&(1<<(position)))
157 const char* parse_list(const char *fmt
, uint32_t *set_vals
,
158 const char sep
, const char* str
, ...);