2002-11-22 13:00:10 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002 by Daniel Stenberg
|
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2002-11-22 13:00:10 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
2004-07-05 11:15:50 +00:00
|
|
|
#ifndef MISC_H
|
|
|
|
#define MISC_H
|
2002-11-22 13:00:10 +00:00
|
|
|
|
2006-11-06 18:07:30 +00:00
|
|
|
#include <stdbool.h>
|
2008-06-07 09:35:57 +00:00
|
|
|
#include <inttypes.h>
|
2009-01-29 21:05:13 +00:00
|
|
|
#include "config.h"
|
2009-06-07 21:27:05 +00:00
|
|
|
#include "system.h"
|
2008-08-02 20:39:03 +00:00
|
|
|
|
2009-10-17 13:40:42 +00:00
|
|
|
extern const unsigned char * const byte_units[];
|
|
|
|
extern const unsigned char * const * const kbyte_units;
|
|
|
|
|
2005-01-31 00:39:20 +00:00
|
|
|
/* Format a large-range value for output, using the appropriate unit so that
|
|
|
|
* the displayed value is in the range 1 <= display < 1000 (1024 for "binary"
|
|
|
|
* units) if possible, and 3 significant digits are shown. If a buffer is
|
|
|
|
* given, the result is snprintf()'d into that buffer, otherwise the result is
|
|
|
|
* voiced.*/
|
2006-11-06 18:07:30 +00:00
|
|
|
char *output_dyn_value(char *buf, int buf_size, int value,
|
2009-10-17 13:40:42 +00:00
|
|
|
const unsigned char * const *units, bool bin_scale);
|
2003-05-04 02:04:31 +00:00
|
|
|
|
2007-02-17 13:36:44 +00:00
|
|
|
/* Format time into buf.
|
|
|
|
*
|
|
|
|
* buf - buffer to format to.
|
|
|
|
* buf_size - size of buffer.
|
|
|
|
* t - time to format, in milliseconds.
|
|
|
|
*/
|
|
|
|
void format_time(char* buf, int buf_size, long t);
|
|
|
|
|
2008-05-01 10:13:12 +00:00
|
|
|
/* Ask the user if they really want to erase the current dynamic playlist
|
|
|
|
* returns true if the playlist should be replaced */
|
|
|
|
bool warn_on_pl_erase(void);
|
|
|
|
|
2003-05-04 02:04:31 +00:00
|
|
|
/* Read (up to) a line of text from fd into buffer and return number of bytes
|
|
|
|
* read (which may be larger than the number of bytes stored in buffer). If
|
|
|
|
* an error occurs, -1 is returned (and buffer contains whatever could be
|
|
|
|
* read). A line is terminated by a LF char. Neither LF nor CR chars are
|
|
|
|
* stored in buffer.
|
|
|
|
*/
|
|
|
|
int read_line(int fd, char* buffer, int buffer_size);
|
2006-10-21 20:37:33 +00:00
|
|
|
int fast_readline(int fd, char *buf, int buf_size, void *parameters,
|
|
|
|
int (*callback)(int n, const char *buf, void *parameters));
|
2004-06-30 13:31:14 +00:00
|
|
|
|
2004-07-05 11:15:50 +00:00
|
|
|
bool settings_parseline(char* line, char** name, char** value);
|
2005-02-07 22:56:37 +00:00
|
|
|
long default_event_handler_ex(long event, void (*callback)(void *), void *parameter);
|
|
|
|
long default_event_handler(long event);
|
2007-04-09 13:39:37 +00:00
|
|
|
bool list_stop_handler(void);
|
2005-04-06 11:12:22 +00:00
|
|
|
void car_adapter_mode_init(void);
|
2005-09-02 05:39:09 +00:00
|
|
|
extern int show_logo(void);
|
2004-07-05 11:15:50 +00:00
|
|
|
|
2006-11-15 20:26:33 +00:00
|
|
|
#if CONFIG_CODEC == SWCODEC
|
|
|
|
/* Return current ReplayGain mode a file should have (REPLAYGAIN_TRACK or
|
|
|
|
* REPLAYGAIN_ALBUM) if ReplayGain processing is enabled, or -1 if no
|
|
|
|
* information present.
|
|
|
|
*/
|
|
|
|
int get_replaygain_mode(bool have_track_gain, bool have_album_gain);
|
|
|
|
#endif
|
|
|
|
|
2008-08-02 20:39:03 +00:00
|
|
|
int open_utf8(const char* pathname, int flags);
|
|
|
|
|
2007-03-30 21:54:48 +00:00
|
|
|
#ifdef BOOTFILE
|
2009-02-21 17:56:31 +00:00
|
|
|
#if !defined(USB_NONE) && !defined(USB_HANDLED_BY_OF)
|
2007-03-30 21:54:48 +00:00
|
|
|
void check_bootfile(bool do_rolo);
|
|
|
|
#endif
|
2007-03-30 23:36:10 +00:00
|
|
|
#endif
|
2007-03-30 21:54:48 +00:00
|
|
|
|
2007-05-30 17:57:32 +00:00
|
|
|
/* check range, set volume and save settings */
|
|
|
|
void setvol(void);
|
|
|
|
|
2007-06-17 21:16:34 +00:00
|
|
|
#ifdef HAVE_LCD_COLOR
|
2008-03-21 13:41:35 +00:00
|
|
|
int hex_to_rgb(const char* hex, int* color);
|
2007-06-17 21:16:34 +00:00
|
|
|
#endif
|
|
|
|
|
2007-11-18 14:12:01 +00:00
|
|
|
char* strrsplt(char* str, int c);
|
2009-02-08 11:09:55 +00:00
|
|
|
char* skip_whitespace(char* const str);
|
2007-11-21 21:28:27 +00:00
|
|
|
bool file_exists(const char *file);
|
|
|
|
bool dir_exists(const char *path);
|
|
|
|
|
2008-01-18 10:02:03 +00:00
|
|
|
/*
|
|
|
|
* removes the extension of filename (if it doesn't start with a .)
|
|
|
|
* puts the result in buffer
|
|
|
|
*/
|
2008-02-06 19:51:19 +00:00
|
|
|
char *strip_extension(char* buffer, int buffer_size, const char *filename);
|
2007-11-21 21:28:27 +00:00
|
|
|
|
2008-03-21 13:41:35 +00:00
|
|
|
/* A simplified scanf */
|
2008-06-07 09:01:02 +00:00
|
|
|
/*
|
|
|
|
* Checks whether the value at position 'position' was really read
|
|
|
|
* during a call to 'parse_list'
|
|
|
|
* - position: 0-based number of the value
|
|
|
|
* - valid_vals: value after the call to 'parse_list'
|
|
|
|
*/
|
2009-06-07 21:27:05 +00:00
|
|
|
#define LIST_VALUE_PARSED(setvals, position) ((setvals) & BIT_N(position))
|
2008-06-07 09:12:23 +00:00
|
|
|
const char* parse_list(const char *fmt, uint32_t *set_vals,
|
2008-06-05 08:20:39 +00:00
|
|
|
const char sep, const char* str, ...);
|
2008-03-21 13:41:35 +00:00
|
|
|
|
2006-11-06 18:07:30 +00:00
|
|
|
#endif /* MISC_H */
|