Don't include a database.ignore file in a font-only package.
[kugel-rb.git] / apps / misc.h
blobb5547ec38f42d794942459674eeecb63bdede78a
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>
27 #define BOM "\xef\xbb\xbf"
28 #define BOM_SIZE 3
30 /* Format a large-range value for output, using the appropriate unit so that
31 * the displayed value is in the range 1 <= display < 1000 (1024 for "binary"
32 * units) if possible, and 3 significant digits are shown. If a buffer is
33 * given, the result is snprintf()'d into that buffer, otherwise the result is
34 * voiced.*/
35 char *output_dyn_value(char *buf, int buf_size, int value,
36 const unsigned char **units, bool bin_scale);
38 /* Create a filename with a number part in a way that the number is 1
39 * higher than the highest numbered file matching the same pattern.
40 * It is allowed that buffer and path point to the same memory location,
41 * saving a strcpy(). Path must always be given without trailing slash.
43 * "num" can point to an int specifying the number to use or NULL or a value
44 * less than zero to number automatically. The final number used will also
45 * be returned in *num. If *num is >= 0 then *num will be incremented by
46 * one. */
47 #if defined(HAVE_RECORDING) && (CONFIG_RTC == 0)
48 /* this feature is needed by recording without a RTC to prevent disk access
49 when changing files */
50 #define IF_CNFN_NUM_(...) __VA_ARGS__
51 #define IF_CNFN_NUM
52 #else
53 #define IF_CNFN_NUM_(...)
54 #endif
55 char *create_numbered_filename(char *buffer, const char *path,
56 const char *prefix, const char *suffix,
57 int numberlen IF_CNFN_NUM_(, int *num));
59 /* Format time into buf.
61 * buf - buffer to format to.
62 * buf_size - size of buffer.
63 * t - time to format, in milliseconds.
65 void format_time(char* buf, int buf_size, long t);
67 #if CONFIG_RTC
68 /* Create a filename with a date+time part.
69 It is allowed that buffer and path point to the same memory location,
70 saving a strcpy(). Path must always be given without trailing slash.
71 unique_time as true makes the function wait until the current time has
72 changed. */
73 char *create_datetime_filename(char *buffer, const char *path,
74 const char *prefix, const char *suffix,
75 bool unique_time);
76 #endif /* CONFIG_RTC */
78 /* Ask the user if they really want to erase the current dynamic playlist
79 * returns true if the playlist should be replaced */
80 bool warn_on_pl_erase(void);
82 /* Read (up to) a line of text from fd into buffer and return number of bytes
83 * read (which may be larger than the number of bytes stored in buffer). If
84 * an error occurs, -1 is returned (and buffer contains whatever could be
85 * read). A line is terminated by a LF char. Neither LF nor CR chars are
86 * stored in buffer.
88 int read_line(int fd, char* buffer, int buffer_size);
89 int fast_readline(int fd, char *buf, int buf_size, void *parameters,
90 int (*callback)(int n, const char *buf, void *parameters));
92 #ifdef HAVE_LCD_BITMAP
93 /* Save a .BMP file containing the current screen contents. */
94 void screen_dump(void);
95 void screen_dump_set_hook(void (*hook)(int fh));
96 #endif
98 bool settings_parseline(char* line, char** name, char** value);
99 long default_event_handler_ex(long event, void (*callback)(void *), void *parameter);
100 long default_event_handler(long event);
101 bool list_stop_handler(void);
102 void car_adapter_mode_init(void);
103 extern int show_logo(void);
105 #if CONFIG_CODEC == SWCODEC
106 /* Return current ReplayGain mode a file should have (REPLAYGAIN_TRACK or
107 * REPLAYGAIN_ALBUM) if ReplayGain processing is enabled, or -1 if no
108 * information present.
110 int get_replaygain_mode(bool have_track_gain, bool have_album_gain);
111 #endif
113 int open_utf8(const char* pathname, int flags);
115 #ifdef BOOTFILE
116 #if !defined(USB_NONE) && !defined(USB_IPODSTYLE)
117 void check_bootfile(bool do_rolo);
118 #endif
119 #endif
121 /* check range, set volume and save settings */
122 void setvol(void);
124 #ifdef HAVE_LCD_COLOR
125 int hex_to_rgb(const char* hex, int* color);
126 #endif
128 char* strrsplt(char* str, int c);
130 bool file_exists(const char *file);
131 bool dir_exists(const char *path);
134 * removes the extension of filename (if it doesn't start with a .)
135 * puts the result in buffer
137 char *strip_extension(char* buffer, int buffer_size, const char *filename);
139 /* A simplified scanf */
141 * Checks whether the value at position 'position' was really read
142 * during a call to 'parse_list'
143 * - position: 0-based number of the value
144 * - valid_vals: value after the call to 'parse_list'
146 #define LIST_VALUE_PARSED(setvals, position) ((setvals)&(1<<(position)))
147 const char* parse_list(const char *fmt, uint32_t *set_vals,
148 const char sep, const char* str, ...);
150 #endif /* MISC_H */