rockbox/apps/misc.h
Thomas Martitz 9c0b2479f7 Rockbox as an application: add get_user_file_path().
For RaaA it evaluates user paths at runtime. For everything but codecs/plugins it will give the path under $HOME/.config/rockbox.org if write access is needed or if the file/folder in question exists there (otherwise it gives /usr/local/share/rockbox).
This allows for installing themes under $HOME as well as having config.cfg and other important files there while installing the application (and default themes) under /usr/local.

On the DAPs it's a no-op, returing /.rockbox directly.

Not converted to use get_user_file_path() are plugins themselves, because RaaA doesn't build plugins yet.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27656 a1c6a512-1295-4272-9138-f99709370657
2010-08-01 16:15:27 +00:00

103 lines
3.6 KiB
C

/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2002 by Daniel Stenberg
*
* 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.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#ifndef MISC_H
#define MISC_H
#include <stdbool.h>
#include <inttypes.h>
#include "config.h"
#include "system.h"
extern const unsigned char * const byte_units[];
extern const unsigned char * const * const kbyte_units;
/* 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.*/
char *output_dyn_value(char *buf, int buf_size, int value,
const unsigned char * const *units, bool bin_scale);
/* 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);
/* 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);
/* 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);
int fast_readline(int fd, char *buf, int buf_size, void *parameters,
int (*callback)(int n, const char *buf, void *parameters));
bool settings_parseline(char* line, char** name, char** value);
long default_event_handler_ex(long event, void (*callback)(void *), void *parameter);
long default_event_handler(long event);
bool list_stop_handler(void);
void car_adapter_mode_init(void);
extern int show_logo(void);
int open_utf8(const char* pathname, int flags);
#ifdef BOOTFILE
#if !defined(USB_NONE) && !defined(USB_HANDLED_BY_OF) \
|| defined(HAVE_HOTSWAP_STORAGE_AS_MAIN)
void check_bootfile(bool do_rolo);
#endif
#endif
/* check range, set volume and save settings */
void setvol(void);
#ifdef HAVE_LCD_COLOR
int hex_to_rgb(const char* hex, int* color);
#endif
char* strrsplt(char* str, int c);
char* skip_whitespace(char* const str);
/*
* removes the extension of filename (if it doesn't start with a .)
* puts the result in buffer
*/
char *strip_extension(char* buffer, int buffer_size, const char *filename);
#ifdef HAVE_LCD_BITMAP
bool parse_color(char *text, int *value);
/* only used in USB HID and set_time screen */
#if defined(USB_ENABLE_HID) || (CONFIG_RTC != 0)
int clamp_value_wrap(int value, int max, int min);
#endif
#endif
#endif /* MISC_H */