Split 8-bit-to-native conversion in bmp.c into a function, add support for plugging...
[kugel-rb.git] / apps / misc.h
blob1ac63da773ac538dc12b2bdd8267026aa0b2f8c6
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
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 ****************************************************************************/
21 #ifndef MISC_H
22 #define MISC_H
24 #include <stdbool.h>
25 #include <inttypes.h>
26 #include "config.h"
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
32 * voiced.*/
33 char *output_dyn_value(char *buf, int buf_size, int value,
34 const unsigned char **units, bool bin_scale);
36 /* Format time into buf.
38 * buf - buffer to format to.
39 * buf_size - size of buffer.
40 * t - time to format, in milliseconds.
42 void format_time(char* buf, int buf_size, long t);
44 /* Ask the user if they really want to erase the current dynamic playlist
45 * returns true if the playlist should be replaced */
46 bool warn_on_pl_erase(void);
48 /* Read (up to) a line of text from fd into buffer and return number of bytes
49 * read (which may be larger than the number of bytes stored in buffer). If
50 * an error occurs, -1 is returned (and buffer contains whatever could be
51 * read). A line is terminated by a LF char. Neither LF nor CR chars are
52 * stored in buffer.
54 int read_line(int fd, char* buffer, int buffer_size);
55 int fast_readline(int fd, char *buf, int buf_size, void *parameters,
56 int (*callback)(int n, const char *buf, void *parameters));
58 bool settings_parseline(char* line, char** name, char** value);
59 long default_event_handler_ex(long event, void (*callback)(void *), void *parameter);
60 long default_event_handler(long event);
61 bool list_stop_handler(void);
62 void car_adapter_mode_init(void);
63 extern int show_logo(void);
65 #if CONFIG_CODEC == SWCODEC
66 /* Return current ReplayGain mode a file should have (REPLAYGAIN_TRACK or
67 * REPLAYGAIN_ALBUM) if ReplayGain processing is enabled, or -1 if no
68 * information present.
70 int get_replaygain_mode(bool have_track_gain, bool have_album_gain);
71 #endif
73 int open_utf8(const char* pathname, int flags);
75 #ifdef BOOTFILE
76 #if !defined(USB_NONE) && !defined(USB_HANDLED_BY_OF)
77 void check_bootfile(bool do_rolo);
78 #endif
79 #endif
81 /* check range, set volume and save settings */
82 void setvol(void);
84 #ifdef HAVE_LCD_COLOR
85 int hex_to_rgb(const char* hex, int* color);
86 #endif
88 char* strrsplt(char* str, int c);
89 char* skip_whitespace(char* const str);
90 bool file_exists(const char *file);
91 bool dir_exists(const char *path);
94 * removes the extension of filename (if it doesn't start with a .)
95 * puts the result in buffer
97 char *strip_extension(char* buffer, int buffer_size, const char *filename);
99 /* A simplified scanf */
101 * Checks whether the value at position 'position' was really read
102 * during a call to 'parse_list'
103 * - position: 0-based number of the value
104 * - valid_vals: value after the call to 'parse_list'
106 #define LIST_VALUE_PARSED(setvals, position) ((setvals)&(1<<(position)))
107 const char* parse_list(const char *fmt, uint32_t *set_vals,
108 const char sep, const char* str, ...);
110 #endif /* MISC_H */