Attempting to add ID3 support
This commit is contained in:
parent
8a4d47d71d
commit
ef53cb83f6
31
src/link.c
31
src/link.c
|
@ -67,7 +67,11 @@ LinkTable *LinkSystem_init(const char *url)
|
|||
ROOT_LINK_TBL = LinkTable_new(url);
|
||||
} else {
|
||||
sonic_config_init(url, CONFIG.sonic_username, CONFIG.sonic_password);
|
||||
ROOT_LINK_TBL = sonic_LinkTable_new(0);
|
||||
if (!CONFIG.sonic_id3) {
|
||||
ROOT_LINK_TBL = sonic_LinkTable_new_index_mode(0);
|
||||
} else {
|
||||
ROOT_LINK_TBL = sonic_LinkTable_new_id3_mode("/");
|
||||
}
|
||||
}
|
||||
return ROOT_LINK_TBL;
|
||||
}
|
||||
|
@ -597,11 +601,16 @@ LinkTable *LinkTable_disk_open(const char *dirn)
|
|||
LinkTable *path_to_Link_LinkTable_new(const char *path)
|
||||
{
|
||||
Link *link = path_to_Link(path);
|
||||
if (!link->next_table) {
|
||||
LinkTable *next_table = link->next_table;
|
||||
if (next_table) {
|
||||
if (!CONFIG.sonic_mode) {
|
||||
link->next_table = LinkTable_new(link->f_url);
|
||||
next_table = LinkTable_new(link->f_url);
|
||||
} else {
|
||||
link->next_table = sonic_LinkTable_new(link->sonic_id);
|
||||
if (!CONFIG.sonic_id3) {
|
||||
next_table = sonic_LinkTable_new_index_mode(link->sonic_id);
|
||||
} else {
|
||||
next_table = sonic_LinkTable_new_index_mode(link->sonic_id_str);
|
||||
}
|
||||
}
|
||||
}
|
||||
return link->next_table;
|
||||
|
@ -645,13 +654,19 @@ static Link *path_to_Link_recursive(char *path, LinkTable *linktbl)
|
|||
for (int i = 1; i < linktbl->num; i++) {
|
||||
if (!strncmp(path, linktbl->links[i]->linkname, MAX_FILENAME_LEN)) {
|
||||
/* The next sub-directory exists */
|
||||
if (!linktbl->links[i]->next_table) {
|
||||
LinkTable *next_table = linktbl->links[i]->next_table;
|
||||
if (!next_table) {
|
||||
if (!CONFIG.sonic_mode) {
|
||||
linktbl->links[i]->next_table = LinkTable_new(
|
||||
next_table = LinkTable_new(
|
||||
linktbl->links[i]->f_url);
|
||||
} else {
|
||||
linktbl->links[i]->next_table = sonic_LinkTable_new(
|
||||
linktbl->links[i]->sonic_id);
|
||||
if (!CONFIG.sonic_id3) {
|
||||
next_table = sonic_LinkTable_new_index_mode(
|
||||
linktbl->links[i]->sonic_id);
|
||||
} else {
|
||||
next_table = sonic_LinkTable_new_id3_mode(
|
||||
linktbl->links[i]->sonic_id_str);
|
||||
}
|
||||
}
|
||||
}
|
||||
return path_to_Link_recursive(
|
||||
|
|
|
@ -227,6 +227,7 @@ parse_arg_list(int argc, char **argv, char ***fuse_argv, int *fuse_argc)
|
|||
break;
|
||||
case 17:
|
||||
CONFIG.sonic_id3 = 1;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "see httpdirfs -h for usage\n");
|
||||
return 1;
|
||||
|
|
30
src/sonic.c
30
src/sonic.c
|
@ -104,7 +104,7 @@ static char *sonic_stream_link(const int id)
|
|||
}
|
||||
|
||||
/**
|
||||
* \brief Process a single element output by the parser
|
||||
* \brief The parser for Sonic index mode
|
||||
* \details This is the callback function called by the the XML parser.
|
||||
* \param[in] data user supplied data, in this case it is the pointer to the
|
||||
* LinkTable.
|
||||
|
@ -117,7 +117,7 @@ static char *sonic_stream_link(const int id)
|
|||
* parser terminates the strings properly, which is a fair assumption,
|
||||
* considering how mature expat is.
|
||||
*/
|
||||
static void XMLCALL XML_process_single_element(void *data, const char *elem,
|
||||
static void XMLCALL XML_parser_index_mode(void *data, const char *elem,
|
||||
const char **attr)
|
||||
{
|
||||
LinkTable *linktbl = (LinkTable *) data;
|
||||
|
@ -231,6 +231,16 @@ static void XMLCALL XML_process_single_element(void *data, const char *elem,
|
|||
LinkTable_add(linktbl, link);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief The parser for Sonic ID3 mode
|
||||
* \details Please refer to the details for XML_parser_index_mode()
|
||||
*/
|
||||
static void XMLCALL XML_parser_id3_mode(void *data, const char *elem,
|
||||
const char **attr)
|
||||
{
|
||||
LinkTable *linktbl = (LinkTable *) data;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief parse a XML string in order to fill in the LinkTable
|
||||
*/
|
||||
|
@ -238,7 +248,13 @@ static void sonic_XML_to_LinkTable(DataStruct ds, LinkTable *linktbl)
|
|||
{
|
||||
XML_Parser parser = XML_ParserCreate(NULL);
|
||||
XML_SetUserData(parser, linktbl);
|
||||
XML_SetStartElementHandler(parser, XML_process_single_element);
|
||||
|
||||
if (!CONFIG.sonic_id3) {
|
||||
XML_SetStartElementHandler(parser, XML_parser_index_mode);
|
||||
} else {
|
||||
XML_SetStartElementHandler(parser, XML_parser_id3_mode);
|
||||
}
|
||||
|
||||
if (XML_Parse(parser, ds.data, ds.size, 1) == XML_STATUS_ERROR) {
|
||||
fprintf(stderr,
|
||||
"sonic_XML_to_LinkTable(): Parse error at line %lu: %s\n",
|
||||
|
@ -248,7 +264,7 @@ static void sonic_XML_to_LinkTable(DataStruct ds, LinkTable *linktbl)
|
|||
XML_ParserFree(parser);
|
||||
}
|
||||
|
||||
LinkTable *sonic_LinkTable_new(const int id)
|
||||
LinkTable *sonic_LinkTable_new_index_mode(const int id)
|
||||
{
|
||||
char *url;
|
||||
if (id > 0) {
|
||||
|
@ -276,3 +292,9 @@ LinkTable *sonic_LinkTable_new(const int id)
|
|||
free(url);
|
||||
return linktbl;
|
||||
}
|
||||
|
||||
LinkTable *sonic_LinkTable_new_id3_mode(const char *sonic_id_str)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
10
src/sonic.h
10
src/sonic.h
|
@ -14,7 +14,13 @@ void sonic_config_init(const char *server, const char *username,
|
|||
const char *password);
|
||||
|
||||
/**
|
||||
* \brief Create a new Sonic LinkTable
|
||||
* \brief Create a new Sonic LinkTable in index mode)
|
||||
*/
|
||||
LinkTable *sonic_LinkTable_new(const int id);
|
||||
LinkTable *sonic_LinkTable_new_index_mode(const int id);
|
||||
|
||||
/**
|
||||
* \brief Create a new Sonic LinkTable in ID3 mode)
|
||||
*/
|
||||
LinkTable *sonic_LinkTable_new_id3_mode(const char *sonic_id_str);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue