Beispiel #1
0
static void module_fill_module(const char* in, char* out, size_t size)
{
    const char  *ptr,*endptr;
    size_t      len, l;

    endptr = in + strlen(in);
    for (ptr = endptr - 1;
         ptr >= in && *ptr != '/' && *ptr != '\\';
         ptr--);
    ptr++;
    len = min(endptr-ptr,size-1);
    memcpy(out, ptr, len);
    out[len] = '\0';
    if (len > 4 && (l = match_ext(out, len)))
        out[len - l] = '\0';
    else if (len > 12 &&
             (!strcasecmp(out + len - 12, "wine-pthread") || 
              !strcasecmp(out + len - 12, "wine-kthread")))
        lstrcpynA(out, "<wine-loader>", size);
    else
    {
        if (len > 3 && !strcasecmp(&out[len - 3], ".so") &&
            (l = match_ext(out, len - 3)))
            strcpy(&out[len - l - 3], "<elf>");
    }
    while ((*out = tolower(*out))) out++;
}
Beispiel #2
0
static int m3u_probe(ByteIOContext *s,const char *file)
{
    if(s)
    {

        char line[1024];
        if(m3u_format_get_line(s,line,1024)>0)
        {

            if(memcmp(line,EXTM3U,strlen(EXTM3U))==0)
            {
                av_log(NULL, AV_LOG_INFO, "get m3u flags!!\n");
                return 100;
            }
        }
    }
    else
    {
        if((match_ext(file, "m3u"))||(match_ext(file, "m3u8")))
        {
            return 50;
        }
    }
    return 0;
}
Beispiel #3
0
t_stat cd_attach (UNIT *uptr, CONST char *cptr)
{
t_stat r;

r = attach_unit (uptr, cptr);
if (r != SCPE_OK)                                       /* attach */
    return r;
if (sim_switches & SWMASK ('T'))                        /* text? */
    uptr->flags = uptr->flags & ~UNIT_CBN;
else if (sim_switches & SWMASK ('C'))                   /* column binary? */
    uptr->flags = uptr->flags | UNIT_CBN;
else if (match_ext (cptr, "TXT"))                       /* .txt? */
    uptr->flags = uptr->flags & ~UNIT_CBN;
else if (match_ext (cptr, "CBN"))                       /* .cbn? */
    uptr->flags = uptr->flags | UNIT_CBN;
return SCPE_OK;
}
Beispiel #4
0
t_stat sim_load (FILE *fileref, char *cptr, char *fnam, int flag)
{
if ((*cptr != 0) || (flag != 0))
    return SCPE_ARG;
if ((sim_switches & SWMASK ('R')) ||                    /* RIM format? */
    (match_ext (fnam, "RIM") && !(sim_switches & SWMASK ('B'))))
    return sim_load_rim (fileref);
else return sim_load_bin (fileref);                     /* no, BIN */
}
Beispiel #5
0
static void module_fill_module(const WCHAR* in, WCHAR* out, size_t size)
{
    const WCHAR *loader = get_wine_loader_name();
    const WCHAR *ptr, *endptr;
    size_t      len, l;

    ptr = get_filename(in, endptr = in + strlenW(in));
    len = min(endptr - ptr, size - 1);
    memcpy(out, ptr, len * sizeof(WCHAR));
    out[len] = '\0';
    if (len > 4 && (l = match_ext(out, len)))
        out[len - l] = '\0';
    else if (len > strlenW(loader) && !strcmpiW(out + len - strlenW(loader), loader))
        lstrcpynW(out, S_WineLoaderW, size);
    else
    {
        if (len > 3 && !strcmpiW(&out[len - 3], S_DotSoW) &&
            (l = match_ext(out, len - 3)))
            strcpyW(&out[len - l - 3], S_ElfW);
    }
    while ((*out = tolowerW(*out))) out++;
}
static int m3u_probe(ByteIOContext *s,const char *file)
{
	if(s)
	{
		char line[1024];
		if(m3u_format_get_line(s,line,1024)>0)
		{

			if(memcmp(line,EXTM3U,strlen(EXTM3U))==0)
			{				
				RLOG("Get m3u file tag\n");
				return 100;
			}
		}	
	}
	else
	{
		if((match_ext(file, "m3u"))||(match_ext(file, "m3u8"))) 
		{
			return 50;
		}
	}
	return 0;
static unsigned int is_chapter_discontinue(play_para_t *p_para)
{
	char *extensions[4] = {"vob", "VOB", "iso", "ISO"};
	int i = 0;
	
	if (p_para->pFormatCtx && p_para->pFormatCtx->pb && 
          url_support_time_seek(p_para->pFormatCtx->pb)) {
		  return 1;
	}
	for (i = 0; i < 4; i ++) {
		//log_print("[%s]file_name=%s ext=%s\n", __FUNCTION__, p_para->file_name, extensions[i]);

		if (match_ext(p_para->file_name, extensions[i])) {
			log_print("[%s]return true\n", __FUNCTION__);
			return 1;
		}
	}
	return 0;
}
Beispiel #8
0
t_stat sim_load (FILE *fileref, char *cptr, char *fnam, int flag)
{
t_stat sta;
int32 fld;

if (flag != 0)
    return SCPE_ARG;
if (cptr && (*cptr != 0)) {
    fld = get_uint (cptr, 8, AMASK, &sta);
    if (sta != SCPE_OK)
        return sta;
    fld = fld & EPCMASK;
    }
else fld = 0;
sta = rim_load (fileref, fld);
if (sta != SCPE_OK)
    return sta;
if ((sim_switches & SWMASK ('B')) || match_ext (fnam, "BIN"))
    return blk_load (fileref, fld);
return SCPE_OK;
}
Beispiel #9
0
//Gets the next music file to play.  If a music file was set in the 
// config, that is used.  Otherwise, fetches a random music file.
s32 get_music_file() 
{
	struct stat st;
	char dirpath[200];
	bool useDir = true;
	DIR_ITER *dir = NULL;

	//check for config set music file or path
	if (*CFG.music_file) {
	
		//if ((strstr(CFG.music_file, ".mp3") != NULL)
		//	|| (strstr(CFG.music_file, ".mod") != NULL)) {
		if (match_ext(CFG.music_file, ".mp3")
			|| match_ext(CFG.music_file, ".mod")) {
			//load a specific file
			strcpy(music_fname, CFG.music_file);
			dbg_printf(gt("Music file: %s"), music_fname);
			dbg_printf("\n");
			if (strlen(music_fname) < 5) return 0;
			if (stat(music_fname, &st) != 0) {
				dbg_printf(gt("File not found! %s"), music_fname);
				dbg_printf("\n");
				return 0;
			}
			useDir = false;
		} else {
			
			//load a specific directory
			dir = diropen(CFG.music_file);
			if (!dir) {
				//not a valid dir so try default
				strcpy(dirpath, USBLOADER_PATH);
			} else {
				dirclose(dir);
				strcpy(dirpath, CFG.music_file);
			}
		}
	} else {
		strcpy(dirpath, USBLOADER_PATH);
	}
	
	//if a directory is being used, then get a random file to play
	if (useDir) {
		// try music.mp3 or music.mod
		get_random_file(".mp3", dirpath);
		//snprintf(music_fname, sizeof(music_fname), "%s/%s", USBLOADER_PATH, "music.mp3");
		if (stat(music_fname, &st) != 0) {
			first_time = true;
			get_random_file(".mod", dirpath);
			//snprintf(music_fname, sizeof(music_fname), "%s/%s", USBLOADER_PATH, "music.mod");
			if (stat(music_fname, &st) != 0) {
				dbg_printf(gt("music.mp3 or music.mod not found!"));
				dbg_printf("\n");
				return 0;
			}
		}
		dbg_printf(gt("Music file from dir: %s"), music_fname);
		dbg_printf("\n");
	}

	music_size = st.st_size;
	dbg_printf(gt("Music file size: %d"), music_size);
	dbg_printf("\n");
	if (music_size <= 0) return 0;

	if (match_ext(music_fname, ".mp3")) {
		music_format = FORMAT_MP3;
	} else if (match_ext(music_fname, ".mod")) {
		music_format = FORMAT_MOD;
	} else {
		music_format = 0;
		return 0;
	}

	music_open();
	if (!music_f) {
		if (*CFG.music_file || CFG.debug) {
			printf(gt("Error opening: %s"), music_fname);
			printf("\n");
		   	sleep(2);
		}
		return 0;
	}
	return 1;  //success
}
Beispiel #10
0
//Creates the random music array (fist time through) and retrieves the
// filepath of the next music file to play.
void get_random_file(char *filetype, char *path)
{
	DIR_ITER *dir = NULL;
	char filename[1024];
	int cnt = 0;
	int next = 0;
	struct stat filestat;
	
	if (fileCount==0 && !first_time) goto out;
	
	dbg_printf(gt("Music: Looking for %s files in: %s"), filetype, path);
		dbg_printf("\n");

	// Open directory
	//snprintf(dirname, sizeof(dirname), "%s", path);
	dir = diropen(path);
	if (!dir) return;

	if (first_time) {
		while (!dirnext(dir, filename, &filestat)) {
			// Ignore invalid entries
			if (match_ext(filename, filetype) && !(filestat.st_mode & S_IFDIR))
				fileCount++;
		}
		dbg_printf(gt("Music: Number of %s files found: %i"), filetype, fileCount);
		dbg_printf("\n");

		first_time = false;
		//if no files found then no need to continue
		if (fileCount==0) goto out;
		
		//allocate the random music array
		musicArray = realloc(musicArray, fileCount * sizeof(int));
		if (!musicArray) {
			fileCount = 0;
			goto out;
		}
		initializeArray(musicArray, fileCount);
		randomizeArray(musicArray, fileCount);

		//check array contents
		int i;
		dbg_printf(gt("Music: musicArray contents: "));
		for (i=0; i<fileCount; i++)
			dbg_printf("%i ", musicArray[i]);
		dbg_printf("\n");

		//reset the directory
		dirreset(dir);
	}

	if (fileCount > 0) {
		//get the next file index
		lastPlayed++;
		if (lastPlayed > fileCount-1) lastPlayed = 0;
		next = musicArray[lastPlayed];
		dbg_printf(gt("Music: Next file index to play: %i"), next);
		dbg_printf("\n");
		
		//iterate through and find our file
		while (!dirnext(dir, filename, &filestat)) {
			if (match_ext(filename, filetype) && !(filestat.st_mode & S_IFDIR)) {
				cnt++;
				if (cnt==next) {
					//save path
					snprintf(music_fname, sizeof(music_fname), "%s/%s", path, filename);
					goto out;
				}
			}
		}
	}

	out:;
	//close the directory
	dirclose(dir);	 
}