Home Download Musics Developers
API Sources Tools File Format Technicals

Resource files
[file68 library documentation.]


Detailed Description

Provides resource access functions.


Files

file  rsc68.h
 resources header.


Data Structures

struct  rsc68_info_t
 Resource specific information. More...


Typedefs

typedef istream_t *(* rsc68_handler_t )(rsc68_t type, const char *name, int mode, rsc68_info_t *info)
 Resource handle function type.


Enumerations

enum  rsc68_t {
  rsc68_replay, rsc68_config, rsc68_sample, rsc68_dll,
  rsc68_music, rsc68_last
}
 Resource type. More...


Functions

const char * rsc68_set_share (const char *path)
 Set shared resource path.

const char * rsc68_set_user (const char *path)
 Set user resource path.

const char * rsc68_set_music (const char *path)
 Set sc68 local music database path.

const char * rsc68_set_remote_music (const char *path)
 Set sc68 remote music database path.

void rsc68_get_path (const char **share, const char **user, const char **lmusic, const char **rmusic)
 Get resource pathes.

rsc68_handler_t rsc68_set_handler (rsc68_handler_t fct)
 Set/Get resource handler.

istream_trsc68_open (rsc68_t type, const char *name, int mode, rsc68_info_t *info)
 Open a resource in given mode.

istream_trsc68_open_url (const char *url, int mode, rsc68_info_t *info)
 Open a resource URL in given mode.

const char * rsc68_get_music_params (rsc68_info_t *info, const char *str)
 Get music parameters from string.


Enumeration Type Documentation

enum rsc68_t
 

Resource type.

Enumeration values:
rsc68_replay  68000 external replay
rsc68_config  Config file.
rsc68_sample  sc68 sample files
rsc68_dll  sc68 dynamic library
rsc68_music  sc68 music files
rsc68_last  last valid type


Function Documentation

const char* rsc68_set_share const char *  path  ) 
 

Set shared resource path.

The rsc68_set_share() function set the shared resource path. The path will be duplicate by SC68strdup(). If path is null the current path is freed.

Parameters:
path New shared resource path (0 for free).
Returns:
new path (duplicated string).
Return values:
0 error (except for freeing)

const char* rsc68_set_user const char *  path  ) 
 

Set user resource path.

The rsc68_set_user() function set the user resource path. The path will be duplicate by SC68strdup(). If path is null the current path is freed.

Parameters:
path New user resource path (0 for free).
Returns:
new path (duplicated string).
Return values:
0 error (except for freeing)

const char* rsc68_set_music const char *  path  ) 
 

Set sc68 local music database path.

The rsc68_set_music() function set the local music database path. The path will be duplicate by SC68strdup(). If path is null the current path is freed.

Parameters:
path New local music database path (0 for free).
Returns:
new path (duplicated string).
Return values:
0 error (except for freeing)

const char* rsc68_set_remote_music const char *  path  ) 
 

Set sc68 remote music database path.

The rsc68_set_remote_music() function set the remote music database path. The path will be duplicate by SC68strdup(). If path is null the current path is freed.

Parameters:
path New remote music database path (0 for free).
Returns:
new path (duplicated string).
Return values:
0 error (except for freeing)

void rsc68_get_path const char **  share,
const char **  user,
const char **  lmusic,
const char **  rmusic
 

Get resource pathes.

Parameters:
share Get the shared resource path (0 to ignore).
user Get the user resource path (0 to ignore).
lmusic Get the local music database path (0 to ignore).
rmusic Get the remote music database path (0 to ignore).

rsc68_handler_t rsc68_set_handler rsc68_handler_t  fct  ) 
 

Set/Get resource handler.

The rsc68_set_handler() function set the current resource handler. If 0 is given as fct parameter the function does not set the handler. In all case the function returns the current handler. See below for more information about the default resource handler.

Resource handler
The resource handler is a function called by the rsc68_open() function. Some preliminary tests has already been performed. So the handler can assume that the name is not a NULL pointer and the mode is valid (either 1:reading or 2:writing). The resource handler must return an already opened istream_t or 0 in error case.
Default resource handler
The Default handler use a the istream_file_create() function.
  • If open mode is 2 (write mode) the default handler use the user resource path.
  • If open mode is 1 (read mode) the default handler tries in this order the user resource path and the shared resource path.
Parameters:
fct New resource handler (0 for reading current value).
Returns:
previous value.

istream_t* rsc68_open rsc68_t  type,
const char *  name,
int  mode,
rsc68_info_t info
 

Open a resource in given mode.

The function rsc68_open() function opens an istream_t to access a resource.

Parameters:
type Type of resource to open.
name Name of resource.
mode 1:read-access, 2:write-access.
info Get additionnal info (depends on type)
Returns:
already opened istream_t stream.
Return values:
0 error.
See also:
rsc68_set_handler() for more info on resource handler.

istream_t* rsc68_open_url const char *  url,
int  mode,
rsc68_info_t info
 

Open a resource URL in given mode.

Parameters:
url Any valid rsc68://type/ URL
mode 1:read-access, 2:write-access.
info Get additionnal info (depends on type)
Returns:
already opened istream_t stream.
Return values:
0 error.
See also:
rsc68_open()

const char* rsc68_get_music_params rsc68_info_t info,
const char *  str
 

Get music parameters from string.

The rsc68_get_music_params() function parses the str string and stores track loop and time in the info struct. If it successes the info::type is set to rsc68_music else it is set rsc68_last.

Parameters:
info info to fill (0:parse only)
str URL part containing music parameter ":track:loop:time"
Returns:
Parsing stop position
Return values:
str on invalid string
>str next '/' or end of string