+
+/*****************************************************************************
+ * MRLSections: parse title and seekpoint info from the Media Resource Locator.
+ *
+ * Syntax:
+ * [url][@[title-start][,chapter-start][-[title-end][,chapter-end]]]
+ *****************************************************************************/
+static void MRLSections( input_thread_t *p_input, char *psz_source,
+ int *pi_title_start, int *pi_title_end,
+ int *pi_chapter_start, int *pi_chapter_end )
+{
+ char *psz, *psz_end, *psz_next;
+
+ *pi_title_start = *pi_title_end = -1;
+ *pi_chapter_start = *pi_chapter_end = -1;
+
+ /* Start by parsing titles and chapters */
+ if( !psz_source || !( psz = strrchr( psz_source, '@' ) ) ) return;
+
+ *psz++ = 0;
+
+ /* Separate start and end */
+ if( ( psz_end = strchr( psz, '-' ) ) ) *psz_end++ = 0;
+
+ /* Look for the start title */
+ *pi_title_start = strtol( psz, &psz_next, 0 );
+ if( !*pi_title_start && psz == psz_next ) *pi_title_start = -1;
+ *pi_title_end = *pi_title_start;
+ psz = psz_next;
+
+ /* Look for the start chapter */
+ if( *psz ) psz++;
+ *pi_chapter_start = strtol( psz, &psz_next, 0 );
+ if( !*pi_chapter_start && psz == psz_next ) *pi_chapter_start = -1;
+ *pi_chapter_end = *pi_chapter_start;
+
+ if( psz_end )
+ {
+ /* Look for the end title */
+ *pi_title_end = strtol( psz_end, &psz_next, 0 );
+ if( !*pi_title_end && psz_end == psz_next ) *pi_title_end = -1;
+ psz_end = psz_next;
+
+ /* Look for the end chapter */
+ if( *psz_end ) psz_end++;
+ *pi_chapter_end = strtol( psz_end, &psz_next, 0 );
+ if( !*pi_chapter_end && psz_end == psz_next ) *pi_chapter_end = -1;
+ }
+
+ msg_Dbg( p_input, "source=`%s' title=%d/%d seekpoint=%d/%d",
+ psz_source, *pi_title_start, *pi_chapter_start,
+ *pi_title_end, *pi_chapter_end );
+}