skin tags: fix the id3 track/disc numbers in conditionals
[maemo-rb.git] / apps / misc.h
blob994e7775d2abd091b097af51e04185c18fdbb4c0
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 "screen_access.h"
29 extern const unsigned char * const byte_units[];
30 extern const unsigned char * const * const kbyte_units;
32 /* Format a large-range value for output, using the appropriate unit so that
33 * the displayed value is in the range 1 <= display < 1000 (1024 for "binary"
34 * units) if possible, and 3 significant digits are shown. If a buffer is
35 * given, the result is snprintf()'d into that buffer, otherwise the result is
36 * voiced.*/
37 char *output_dyn_value(char *buf, int buf_size, int value,
38 const unsigned char * const *units, bool bin_scale);
40 /* Format time into buf.
42 * buf - buffer to format to.
43 * buf_size - size of buffer.
44 * t - time to format, in milliseconds.
46 void format_time(char* buf, int buf_size, long t);
48 /* Ask the user if they really want to erase the current dynamic playlist
49 * returns true if the playlist should be replaced */
50 bool warn_on_pl_erase(void);
52 /* Read (up to) a line of text from fd into buffer and return number of bytes
53 * read (which may be larger than the number of bytes stored in buffer). If
54 * an error occurs, -1 is returned (and buffer contains whatever could be
55 * read). A line is terminated by a LF char. Neither LF nor CR chars are
56 * stored in buffer.
58 int read_line(int fd, char* buffer, int buffer_size);
59 int fast_readline(int fd, char *buf, int buf_size, void *parameters,
60 int (*callback)(int n, char *buf, void *parameters));
62 bool settings_parseline(char* line, char** name, char** value);
63 long default_event_handler_ex(long event, void (*callback)(void *), void *parameter);
64 long default_event_handler(long event);
65 bool list_stop_handler(void);
66 void car_adapter_mode_init(void) INIT_ATTR;
67 extern int show_logo(void);
69 /* Unicode byte order mark sequences and lengths */
70 #define BOM_UTF_8 "\xef\xbb\xbf"
71 #define BOM_UTF_8_SIZE 3
72 #define BOM_UTF_16_LE "\xff\xfe"
73 #define BOM_UTF_16_BE "\xfe\xff"
74 #define BOM_UTF_16_SIZE 2
76 int split_string(char *str, const char needle, char *vector[], int vector_length);
77 int open_utf8(const char* pathname, int flags);
79 #ifdef BOOTFILE
80 #if !defined(USB_NONE) && !defined(USB_HANDLED_BY_OF) \
81 || defined(HAVE_HOTSWAP_STORAGE_AS_MAIN)
82 void check_bootfile(bool do_rolo);
83 #endif
84 #endif
86 /* check range, set volume and save settings */
87 void setvol(void);
89 #ifdef HAVE_LCD_COLOR
90 int hex_to_rgb(const char* hex, int* color);
91 #endif
93 char* strrsplt(char* str, int c);
94 char* skip_whitespace(char* const str);
97 * removes the extension of filename (if it doesn't start with a .)
98 * puts the result in buffer
100 char *strip_extension(char* buffer, int buffer_size, const char *filename);
102 #ifdef HAVE_LCD_BITMAP
103 bool parse_color(enum screen_type screen, char *text, int *value);
105 /* only used in USB HID and set_time screen */
106 #if defined(USB_ENABLE_HID) || (CONFIG_RTC != 0)
107 int clamp_value_wrap(int value, int max, int min);
108 #endif
109 #endif
111 enum current_activity {
112 ACTIVITY_UNKNOWN = 0,
113 ACTIVITY_MAINMENU,
114 ACTIVITY_WPS,
115 ACTIVITY_RECORDING,
116 ACTIVITY_FM,
117 ACTIVITY_PLAYLISTVIEWER,
118 ACTIVITY_SETTINGS,
119 ACTIVITY_FILEBROWSER,
120 ACTIVITY_DATABASEBROWSER,
121 ACTIVITY_PLUGINBROWSER,
122 ACTIVITY_QUICKSCREEN,
123 ACTIVITY_PITCHSCREEN,
124 ACTIVITY_OPTIONSELECT,
125 ACTIVITY_PLAYLISTBROWSER,
126 ACTIVITY_PLUGIN,
127 ACTIVITY_CONTEXTMENU,
128 ACTIVITY_SYSTEMSCREEN,
129 ACTIVITY_TIMEDATESCREEN,
130 ACTIVITY_BOOKMARKSLIST,
131 ACTIVITY_SHORTCUTSMENU,
132 ACTIVITY_ID3SCREEN
135 #if CONFIG_CODEC == SWCODEC
136 void beep_play(unsigned int frequency, unsigned int duration,
137 unsigned int amplitude);
139 enum system_sound
141 SOUND_KEYCLICK = 0,
142 SOUND_TRACK_SKIP,
143 SOUND_TRACK_NO_MORE,
146 /* Play a standard sound */
147 void system_sound_play(enum system_sound sound);
149 typedef bool (*keyclick_callback)(int action, void* data);
150 void keyclick_set_callback(keyclick_callback cb, void* data);
151 /* Produce keyclick based upon button and global settings */
152 void keyclick_click(bool rawbutton, int action);
154 /* Return current ReplayGain mode a file should have (REPLAYGAIN_TRACK or
155 * REPLAYGAIN_ALBUM) if ReplayGain processing is enabled, or -1 if no
156 * information present.
158 struct mp3entry;
159 int id3_get_replaygain_mode(const struct mp3entry *id3);
160 void replaygain_update(void);
161 #else
162 static inline void replaygain_update(void) {}
163 #endif /* CONFIG_CODEC == SWCODEC */
165 void push_current_activity(enum current_activity screen);
166 void pop_current_activity(void);
167 enum current_activity get_current_activity(void);
170 #endif /* MISC_H */