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 ****************************************************************************/
27 /* Format a large-range value for output, using the appropriate unit so that
28 * the displayed value is in the range 1 <= display < 1000 (1024 for "binary"
29 * units) if possible, and 3 significant digits are shown. If a buffer is
30 * given, the result is snprintf()'d into that buffer, otherwise the result is
32 char *output_dyn_value(char *buf
, int buf_size
, int value
,
33 const unsigned char **units
, bool bin_scale
);
35 /* Create a filename with a number part in a way that the number is 1
36 * higher than the highest numbered file matching the same pattern.
37 * It is allowed that buffer and path point to the same memory location,
38 * saving a strcpy(). Path must always be given without trailing slash.
40 * "num" can point to an int specifying the number to use or NULL or a value
41 * less than zero to number automatically. The final number used will also
42 * be returned in *num. If *num is >= 0 then *num will be incremented by
44 #if defined(HAVE_RECORDING) && (CONFIG_RTC == 0)
45 /* this feature is needed by recording without a RTC to prevent disk access
46 when changing files */
47 #define IF_CNFN_NUM_(...) __VA_ARGS__
50 #define IF_CNFN_NUM_(...)
52 char *create_numbered_filename(char *buffer
, const char *path
,
53 const char *prefix
, const char *suffix
,
54 int numberlen
IF_CNFN_NUM_(, int *num
));
56 /* Format time into buf.
58 * buf - buffer to format to.
59 * buf_size - size of buffer.
60 * t - time to format, in milliseconds.
62 void format_time(char* buf
, int buf_size
, long t
);
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 */
75 /* Ask the user if they really want to erase the current dynamic playlist
76 * returns true if the playlist should be replaced */
77 bool warn_on_pl_erase(void);
79 /* Read (up to) a line of text from fd into buffer and return number of bytes
80 * read (which may be larger than the number of bytes stored in buffer). If
81 * an error occurs, -1 is returned (and buffer contains whatever could be
82 * read). A line is terminated by a LF char. Neither LF nor CR chars are
85 int read_line(int fd
, char* buffer
, int buffer_size
);
86 int fast_readline(int fd
, char *buf
, int buf_size
, void *parameters
,
87 int (*callback
)(int n
, const char *buf
, void *parameters
));
89 #ifdef HAVE_LCD_BITMAP
90 /* Save a .BMP file containing the current screen contents. */
91 void screen_dump(void);
92 void screen_dump_set_hook(void (*hook
)(int fh
));
95 bool settings_parseline(char* line
, char** name
, char** value
);
96 long default_event_handler_ex(long event
, void (*callback
)(void *), void *parameter
);
97 long default_event_handler(long event
);
98 bool list_stop_handler(void);
99 void car_adapter_mode_init(void);
100 extern int show_logo(void);
102 #if CONFIG_CODEC == SWCODEC
103 /* Return current ReplayGain mode a file should have (REPLAYGAIN_TRACK or
104 * REPLAYGAIN_ALBUM) if ReplayGain processing is enabled, or -1 if no
105 * information present.
107 int get_replaygain_mode(bool have_track_gain
, bool have_album_gain
);
110 int open_utf8(const char* pathname
, int flags
);
113 #if !defined(USB_NONE) && !defined(USB_IPODSTYLE)
114 void check_bootfile(bool do_rolo
);
118 /* check range, set volume and save settings */
121 #ifdef HAVE_LCD_COLOR
122 int hex_to_rgb(const char* hex
, int* color
);
125 char* strrsplt(char* str
, int c
);
127 bool file_exists(const char *file
);
128 bool dir_exists(const char *path
);
131 * removes the extension of filename (if it doesn't start with a .)
132 * puts the result in buffer
134 char *strip_extension(char* buffer
, int buffer_size
, const char *filename
);
136 /* A simplified scanf */
138 * Checks whether the value at position 'position' was really read
139 * during a call to 'parse_list'
140 * - position: 0-based number of the value
141 * - valid_vals: value after the call to 'parse_list'
143 #define LIST_VALUE_PARSED(setvals, position) ((setvals)&(1<<(position)))
144 const char* parse_list(const char *fmt
, uint32_t *set_vals
,
145 const char sep
, const char* str
, ...);