AMSv2 USB: Delay after sftdiscon should be far longer.
[kugel-rb.git] / apps / misc.h
blobfa6695680029e9e0750b8d520be9872221395add
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"
27 #include "system.h"
28 #include "screen_access.h"
30 extern const unsigned char * const byte_units[];
31 extern const unsigned char * const * const kbyte_units;
33 /* Format a large-range value for output, using the appropriate unit so that
34 * the displayed value is in the range 1 <= display < 1000 (1024 for "binary"
35 * units) if possible, and 3 significant digits are shown. If a buffer is
36 * given, the result is snprintf()'d into that buffer, otherwise the result is
37 * voiced.*/
38 char *output_dyn_value(char *buf, int buf_size, int value,
39 const unsigned char * const *units, bool bin_scale);
41 /* Format time into buf.
43 * buf - buffer to format to.
44 * buf_size - size of buffer.
45 * t - time to format, in milliseconds.
47 void format_time(char* buf, int buf_size, long t);
49 /* Ask the user if they really want to erase the current dynamic playlist
50 * returns true if the playlist should be replaced */
51 bool warn_on_pl_erase(void);
53 /* Read (up to) a line of text from fd into buffer and return number of bytes
54 * read (which may be larger than the number of bytes stored in buffer). If
55 * an error occurs, -1 is returned (and buffer contains whatever could be
56 * read). A line is terminated by a LF char. Neither LF nor CR chars are
57 * stored in buffer.
59 int read_line(int fd, char* buffer, int buffer_size);
60 int fast_readline(int fd, char *buf, int buf_size, void *parameters,
61 int (*callback)(int n, const char *buf, void *parameters));
63 bool settings_parseline(char* line, char** name, char** value);
64 long default_event_handler_ex(long event, void (*callback)(void *), void *parameter);
65 long default_event_handler(long event);
66 bool list_stop_handler(void);
67 void car_adapter_mode_init(void);
68 extern int show_logo(void);
70 int open_utf8(const char* pathname, int flags);
72 #ifdef BOOTFILE
73 #if !defined(USB_NONE) && !defined(USB_HANDLED_BY_OF) \
74 || defined(HAVE_HOTSWAP_STORAGE_AS_MAIN)
75 void check_bootfile(bool do_rolo);
76 #endif
77 #endif
79 /* check range, set volume and save settings */
80 void setvol(void);
82 #ifdef HAVE_LCD_COLOR
83 int hex_to_rgb(const char* hex, int* color);
84 #endif
86 char* strrsplt(char* str, int c);
87 char* skip_whitespace(char* const str);
90 * removes the extension of filename (if it doesn't start with a .)
91 * puts the result in buffer
93 char *strip_extension(char* buffer, int buffer_size, const char *filename);
95 #ifdef HAVE_LCD_BITMAP
96 bool parse_color(enum screen_type screen, char *text, int *value);
98 /* only used in USB HID and set_time screen */
99 #if defined(USB_ENABLE_HID) || (CONFIG_RTC != 0)
100 int clamp_value_wrap(int value, int max, int min);
101 #endif
102 #endif
104 #endif /* MISC_H */