示例#1
0
Board::Board(int rows, int columns, int num_mines) {
	this->m_rows = rows;
	this->m_columns = columns;
	this->m_num_mines = num_mines;
	int board_size = rows * columns;
	board = (char *) calloc(board_size, sizeof(char));
	for (int m = 0; m < num_mines; m++) {
		bool found = false;
		while (!found) {
			int candidate = rand() % board_size;
			if (! NTH_HAS_MINE(candidate)) {
				MINE_NTH(candidate);
				found = true;
			}
		}
	}
	for (int row = 0; row < rows; row ++) {
		for (int column = 0; column < columns; column ++) {
			int number = 0;
			for (int adj = 0; adj < 8; adj ++) {
				int adj_row = row + adjacent_squares[adj][0];
				int adj_column = column + adjacent_squares[adj][1];
				if(adj_row >= 0 && adj_row < m_rows && adj_column >= 0 && adj_column < m_columns && MINE(adj_row, adj_column)) {
					number ++;
				}
			}
			SET_NUMBER(row, column, number);
		}
	}
}
示例#2
0
int rtsp_fillStreamMenu(interfaceMenu_t *pMenu, void* pArg)
{
	int which;
	//int position = 0;
	char *str;

	which = GET_NUMBER(pArg);

	interface_clearMenuEntries((interfaceMenu_t*)&rtspStreamMenu);

	str = _T("SEARCHING_MOVIES");
	interface_addMenuEntryDisabled((interfaceMenu_t*)&rtspStreamMenu, str, thumbnail_search);

	collectFlag++;

	if( collectThread == 0)
	{
		pthread_create(&collectThread, NULL, rtsp_list_updater, SET_NUMBER(which));
		pthread_detach(collectThread);
	}

	interface_setSelectedItem((interfaceMenu_t*)&rtspStreamMenu, MENU_ITEM_MAIN);

	interface_menuActionShowMenu(pMenu, (void*)&rtspStreamMenu);

	return 0;
}
示例#3
0
文件: mono.c 项目: kmizumar/Mono
//deep-bindによる。シンボルが見つからなかったら登録。
//見つかったらそこに値をいれておく。
void bindsym(int symaddr, int valaddr){
        int addr,num;
    char *name;
    
    name = symname(symaddr);
    if((addr=findsym(name)) == NIL){
        addr = freshcell();
        SET_NAME(addr,name);
        SET_CDR(addr,E);
        E = addr;
    }
    switch(GET_TAG(valaddr)){
                case NUM: {     SET_TAG(addr,NUM);
                                num = GET_NUMBER(valaddr);
                    SET_NUMBER(addr,num);
                    break; }
        case SYM: {     SET_TAG(addr,SYM);
                                name = GET_NAME(valaddr);
                                SET_NAME(addr,name);
                                break; }
        case LIS: {     SET_TAG(addr,LIS);
                                SET_BIND(addr,valaddr);
                                break; }
    }
}
示例#4
0
文件: mlis.c 项目: kzfm1024/misc
int makenum(int num){
    int addr;
    
    addr = freshcell();
    SET_TAG(addr,NUM);
    SET_NUMBER(addr,num);
    return(addr);
}
示例#5
0
static void *rtsp_list_updater(void *pArg)
{
	int i;
	int which;
	int sleepTime = 1;

	which = GET_NUMBER(pArg);

	while (collectFlag)
	{
		interface_showLoadingAnimation();

		dprintf("%s: rtsp_list_updater: collecting/waiting\n", __FUNCTION__);

		i = 0;
		while (i++ < sleepTime*10)
		{
			if (collectFlag)
			{
				usleep(100000);
			} else
			{
				dprintf("%s: stop waiting\n", __FUNCTION__);
				interface_hideLoadingAnimation();
				break;
			}
		}

		if (collectFlag)
		{
			get_rtsp_streams(ppstream_head);

			if(ppstream_head == NULL)
			{
				collectFlag--;
			} else
			{
				collectFlag = 0;
			}

			interface_hideLoadingAnimation();

			rtsp_displayStreamMenu(SET_NUMBER(which));

			sleepTime = 2;
		}
	}

	collectThread = 0;

	dprintf("%s: exit normal\n", __FUNCTION__);

	return NULL;
}
示例#6
0
static int menu_keyCallback(interfaceMenu_t *pMenu, pinterfaceCommandEvent_t cmd, void* pArg)
{
	switch (cmd->command)
	{
#ifdef ENABLE_FAVORITES
		case interfaceCommandBlue:
			interface_menuActionShowMenu(pMenu, &playlistMenu);
			return 0;
#endif
#ifdef ENABLE_PVR
		case interfaceCommandRecord:
			pvr_initPvrMenu(pMenu, SET_NUMBER(pvrJobTypeRTP));
			return 0;
#endif
		default:;
	}
	return 1;
}
示例#7
0
void menu_buildMainMenu()
{
	char *str = NULL;
	int main_icons[4] = { 0, 0, 0,
#if (defined ENABLE_FAVORITES) && !(defined ENABLE_VIDIMAX) && !(defined ENABLE_FUSION)
		statusbar_f4_favorites
#else
		0
#endif
	};

	createListMenu(&interfaceMainMenu, str, thumbnail_logo, main_icons, NULL,
				   /* interfaceInfo.clientX, interfaceInfo.clientY,
				   interfaceInfo.clientWidth, interfaceInfo.clientHeight,*/ interfaceListMenuBigThumbnail,//interfaceListMenuIconThumbnail,
				   NULL, NULL, NULL);
	interface_setCustomKeysCallback(_M &interfaceMainMenu, menu_keyCallback);
/*
	interface_addMenuEntry(_M &interfaceMainMenu, str, 0, NULL, NULL, IMAGE_DIR "splash.png");
*/

#ifndef ENABLE_VIDIMAX
#ifdef ENABLE_DVB
	 
#ifdef HIDE_EXTRA_FUNCTIONS
	if ( offair_tunerPresent() )
#endif // #ifdef HIDE_EXTRA_FUNCTIONS
	{
		offair_buildDVBTMenu(_M &interfaceMainMenu);
		str = _T("DVB_CHANNELS");
		interface_addMenuEntry(_M &interfaceMainMenu, str, interface_menuActionShowMenu, &DVBTMenu, thumbnail_dvb);
	}
#endif // #ifdef ENABLE_DVB
#ifdef ENABLE_TELETES
	teletes_buildMenu(_M &interfaceMainMenu);
	str = _T("CAMERAS");
	interface_addMenuEntry(_M &interfaceMainMenu, str, interface_menuActionShowMenu, &teletesMediaMenu, thumbnail_tvinfo);
#endif
#ifdef ENABLE_IPTV
	rtp_buildMenu(_M &interfaceMainMenu);
	str = _T("TV_CHANNELS");

#ifdef ENABLE_FUSION
	interface_addMenuEntry(_M &interfaceMainMenu, str, fusion_askPassword_FillStreamMenu, NULL, thumbnail_multicast);
#else
	interface_addMenuEntry(_M &interfaceMainMenu, str, rtp_initStreamMenu, NULL, thumbnail_multicast);
#endif
#endif // #ifdef ENABLE_IPTV
#ifdef ENABLE_PVR
	pvr_buildPvrMenu((interfaceMenu_t *) &interfaceMainMenu);
#endif
#ifdef ENABLE_VOD
	rtsp_buildMenu(_M &interfaceMainMenu);
	str = _T("MOVIES");

#ifdef ENABLE_FUSION
	interface_addMenuEntry(_M &interfaceMainMenu, str, fusion_askPassword_FillStreamMenu, NULL, thumbnail_vod);
#else
	interface_addMenuEntry(_M &interfaceMainMenu, str, rtsp_fillStreamMenu, NULL, thumbnail_vod);
#endif

#endif // #ifdef ENABLE_VOD
#ifdef ENABLE_FAVORITES
	playlist_buildMenu(_M &interfaceMainMenu);
	str = _T("PLAYLIST");

#ifdef ENABLE_FUSION
	interface_addMenuEntry(_M &interfaceMainMenu, str, fusion_askPassword_SwitchMenu, &playlistMenu, thumbnail_favorites);
#else
	interface_addMenuEntry(_M &interfaceMainMenu, str, interface_menuActionShowMenu, &playlistMenu, thumbnail_favorites);
#endif

#endif // #ifdef ENABLE_FAVORITES

	media_buildMediaMenu(_M &interfaceMainMenu);
#ifdef ENABLE_USB
	str = _T("RECORDED");

#ifdef ENABLE_FUSION
	interface_addMenuEntry(_M &interfaceMainMenu, str, fusion_askPassword_USBBrowserMenu, SET_NUMBER(mediaVideo), thumbnail_usb);
#else
	interface_addMenuEntry(_M &interfaceMainMenu, str, media_initUSBBrowserMenu, SET_NUMBER(mediaVideo), thumbnail_usb);
#endif
#endif // #ifdef ENABLE_USB

#ifdef ENABLE_WEB_SERVICES
#ifndef ENABLE_FUSION
	{
		str = _T("WEB_SERVICES");
		interface_addMenuEntry(_M &interfaceMainMenu, str, interface_menuActionShowMenu, &WebServicesMenu, thumbnail_internet);
		createListMenu(&WebServicesMenu, _T("WEB_SERVICES"), thumbnail_internet, NULL, _M &interfaceMainMenu,
					/* interfaceInfo.clientX, interfaceInfo.clientY,
					interfaceInfo.clientWidth, interfaceInfo.clientHeight,*/ interfaceListMenuIconThumbnail,
					NULL, NULL, NULL);
#ifdef ENABLE_RUTUBE
		rutube_buildMenu(_M &WebServicesMenu);
		str = "RuTube";
		interface_addMenuEntry(_M &WebServicesMenu, str, interface_menuActionShowMenu, &RutubeCategories, thumbnail_rutube);
	
#endif // #ifdef ENABLE_RUTUBE
#ifdef ENABLE_YOUTUBE
		youtube_buildMenu(_M &WebServicesMenu);
		str = "YouTube";
		interface_addMenuEntry(_M &WebServicesMenu, str, interface_menuActionShowMenu, &YoutubeMenu, thumbnail_youtube);
#endif // #ifdef ENABLE_YOUTUBE
		
#ifdef ENABLE_REGPLAT
		regplat_buildMenu(_M &WebServicesMenu);
		str = "RegPlat";
		interface_addMenuEntry(_M &WebServicesMenu, str, interface_menuActionShowMenu, &regplatLoginMenu, thumbnail_regplat);
#endif// #ifdef ENABLE_REGPLAT

#ifdef ENABLE_SAMBA
		samba_buildMenu(_M &WebServicesMenu);
		str = _T("NETWORK_PLACES");
		interface_addMenuEntry(_M &WebServicesMenu, str, media_initSambaBrowserMenu, NULL, thumbnail_network);
		str = _T("NETWORK_BROWSING");
		interface_addMenuEntry(_M &WebServicesMenu, str, interface_menuActionShowMenu, &SambaMenu, thumbnail_workstation);
		
#endif // #ifdef ENABLE_SAMBA
#ifdef ENABLE_DLNA
		dlna_buildDLNAMenu(_M &WebServicesMenu);
		str = _T("MEDIA_SERVERS");
		interface_addMenuEntry(_M &WebServicesMenu, str, dlna_initServerBrowserMenu, NULL, thumbnail_movies);
		
#endif // #ifdef ENABLE_DLNA
#ifdef ENABLE_BROWSER		
		str = _T("INTERNET_BROWSING");
		interface_addMenuEntry(_M &WebServicesMenu, str, open_browser, NULL, thumbnail_internet);
#ifndef HIDE_EXTRA_FUNCTIONS
		if (helperFileExists(MW_CONFIG_FILE))
		{
			str = _T("MIDDLEWARE");
			interface_addMenuEntry(_M &interfaceMainMenu, str, open_browser_mw, NULL, thumbnail_elecardtv);
		}
#endif // #ifndef HIDE_EXTRA_FUNCTIONS
		
#endif // #ifdef ENABLE_BROWSER
#ifdef ENABLE_SMIL
		str = _T("RTMP");
		interface_addMenuEntry((interfaceMenu_t *)&WebServicesMenu, str, smil_enterURL, SET_NUMBER(-1), thumbnail_add_url);
#endif
	}
#endif // ifndef ENABLE_FUSION
#endif // #ifdef ENABLE_WEB_SERVICES

#ifdef ENABLE_VOIP
	voip_buildMenu(_M &interfaceMainMenu);
		//if(appControlInfo.voipInfo.status == 0)
		{
			str = _T("VOIP");
			interface_addMenuEntry(_M &interfaceMainMenu, str, voip_fillMenu, SET_NUMBER(1), thumbnail_voip);
		}
	
#endif
#ifdef SHOW_CARD_MENU
	{
		card_buildMenu(_M &interfaceMainMenu);
		str = _T("CARD");
		interface_addMenuEntry(_M &interfaceMainMenu, str, card_fillInfoMenu, SET_NUMBER(1), thumbnail_rd);
		str = _T("QUIZ");
		interface_addMenuEntry(_M &interfaceMainMenu, str, card_fillQuizMenu, &cardMenu, thumbnail_account);
	}
#endif // #ifdef SHOW_CARD_MENU
	{
		output_buildMenu(_M &interfaceMainMenu);
		str = _T("SETTINGS");

#ifdef ENABLE_FUSION
	interface_addMenuEntry(_M &interfaceMainMenu, str, fusion_askPassword_SwitchMenu, &OutputMenu, thumbnail_configure);
#else
		interface_addMenuEntry(_M &interfaceMainMenu, str, interface_menuActionShowMenu, &OutputMenu, thumbnail_configure);
#endif
	}
#else // NOT ENABLE_VIDIMAX
//#ifdef ENABLE_VIDIMAX	
	vidimax_buildCascadedMenu(_M &interfaceMainMenu);
	str = _T("Vidimax");
	interface_addMenuEntry (_M &interfaceMainMenu, str, vidimax_fillMenu, NULL, thumbnail_vidimax);
	/////////////////////////////////////////////////////////////////////////////////
#ifdef ENABLE_DVB
#ifdef HIDE_EXTRA_FUNCTIONS
		if (offair_tunerPresent())
#endif // #ifdef HIDE_EXTRA_FUNCTIONS
	{
		offair_buildDVBTMenu(_M &interfaceMainMenu);
		str = _T("DVB_CHANNELS");
		interface_addMenuEntry(_M &interfaceMainMenu, str, interface_menuActionShowMenu, &DVBTMenu, thumbnail_dvb);
	}
#endif // #ifdef ENABLE_DVB

#ifdef ENABLE_IPTV
	rtp_buildMenu(_M &interfaceMainMenu);
	str = _T("TV_CHANNELS");
	interface_addMenuEntry(_M &interfaceMainMenu, str, rtp_initStreamMenu, NULL, thumbnail_multicast);
	
#endif // #ifdef ENABLE_IPTV
#ifdef ENABLE_PVR
	pvr_buildPvrMenu((interfaceMenu_t *) &interfaceMainMenu);
#endif

#ifdef ENABLE_FAVORITES
	playlist_buildMenu(_M &interfaceMainMenu);
	str = _T("PLAYLIST");
	interface_addMenuEntry(_M &interfaceMainMenu, str, interface_menuActionShowMenu, &playlistMenu, thumbnail_favorites);
	
#endif // #ifdef ENABLE_FAVORITES

	media_buildMediaMenu(_M &interfaceMainMenu);
#ifdef ENABLE_USB
	str = _T("RECORDED");
	interface_addMenuEntry(_M &interfaceMainMenu, str, media_initUSBBrowserMenu, SET_NUMBER(mediaVideo), thumbnail_usb);
	
#endif // #ifdef ENABLE_USB

#ifdef ENABLE_WEB_SERVICES
	{
		str = _T("WEB_SERVICES");
		interface_addMenuEntry(_M &interfaceMainMenu, str, interface_menuActionShowMenu, &WebServicesMenu, thumbnail_internet);
		createListMenu(&WebServicesMenu, _T("WEB_SERVICES"), thumbnail_internet, NULL, _M &interfaceMainMenu,
					/* interfaceInfo.clientX, interfaceInfo.clientY,
					interfaceInfo.clientWidth, interfaceInfo.clientHeight,*/ interfaceListMenuIconThumbnail,
					NULL, NULL, NULL);
					
#ifdef ENABLE_RUTUBE
		rutube_buildMenu(_M &WebServicesMenu);
		str = "RuTube";
		interface_addMenuEntry(_M &WebServicesMenu, str, interface_menuActionShowMenu, &RutubeCategories, thumbnail_rutube);
	
#endif // #ifdef ENABLE_RUTUBE
#ifdef ENABLE_YOUTUBE
		youtube_buildMenu(_M &WebServicesMenu);
		str = "YouTube";
		interface_addMenuEntry(_M &WebServicesMenu, str, interface_menuActionShowMenu, &YoutubeMenu, thumbnail_youtube);
#endif // #ifdef ENABLE_YOUTUBE

#ifdef ENABLE_BROWSER		
		str = _T("INTERNET_BROWSING");
		interface_addMenuEntry(_M &WebServicesMenu, str, open_browser, NULL, thumbnail_internet);
#ifndef HIDE_EXTRA_FUNCTIONS
		if (helperFileExists(MW_CONFIG_FILE))
		{
			str = _T("MIDDLEWARE");
			interface_addMenuEntry(_M &interfaceMainMenu, str, open_browser_mw, NULL, thumbnail_elecardtv);
		}
#endif // #ifndef HIDE_EXTRA_FUNCTIONS
#endif // #ifdef ENABLE_BROWSER

#ifdef ENABLE_SAMBA
		samba_buildMenu(_M &WebServicesMenu);
		str = _T("NETWORK_PLACES");
		interface_addMenuEntry(_M &WebServicesMenu, str, media_initSambaBrowserMenu, NULL, thumbnail_network);
		str = _T("NETWORK_BROWSING");
		interface_addMenuEntry(_M &WebServicesMenu, str, interface_menuActionShowMenu, &SambaMenu, thumbnail_workstation);
		
#endif // #ifdef ENABLE_SAMBA
	}
#endif // #ifdef ENABLE_WEB_SERVICES

#ifdef ENABLE_VOIP
	voip_buildMenu(_M &interfaceMainMenu);
		//if(appControlInfo.voipInfo.status == 0)
		{
			str = _T("VOIP");
			interface_addMenuEntry(_M &interfaceMainMenu, str, voip_fillMenu, SET_NUMBER(1), thumbnail_voip);
		}
#endif
	{
		output_buildMenu(_M &interfaceMainMenu);
		str = _T("SETTINGS");
		interface_addMenuEntry(_M &interfaceMainMenu, str, interface_menuActionShowMenu, &OutputMenu, thumbnail_configure);
	}

#endif // ENABLE_VIDIMAX
	/*
	str = _T("MUSIC");
	interface_addMenuEntry(_M &interfaceMainMenu, str, interface_menuActionShowMenu, NULL, IMAGE_DIR "thumbnail_music.png");
	str = _T("PAUSED_CONTENT");
	interface_addMenuEntry(_M &interfaceMainMenu, str, interface_menuActionShowMenu, NULL, IMAGE_DIR "thumbnail_paused.png");
	str = _T("ACCOUNT");
	interface_addMenuEntry(_M &interfaceMainMenu, str, interface_menuActionShowMenu, NULL, IMAGE_DIR "thumbnail_account.png");
	*/
	switch( interface_getMenuEntryCount( _M &interfaceMainMenu ))
	{
		case 4:case 6:case 9: break;
		default:
			str = _T("SHUTDOWN");
			interface_addMenuEntry(_M &interfaceMainMenu, str, power_callback, NULL, thumbnail_power);
	}

}
示例#8
0
static int rtsp_keyCallback(interfaceMenu_t *pMenu, pinterfaceCommandEvent_t cmd, void* pArg)
{
	unsigned int streamNumber;
	char URL[MAX_URL];

	if( cmd->command == interfaceCommandBlue )
	{
		rtsp_enterURL(pMenu, (void*)screenMain);
		return 0;
	}

	if(pMenu->selectedItem < 0)
	{
		return 1;
	}

	streamNumber = CHANNEL_INFO_GET_CHANNEL(pArg);

	if (GET_NUMBER(pArg) >= 0)
	{
		if (cmd->command == interfaceCommandYellow || cmd->command == interfaceCommandGreen)
		{
			if ( pstream_head == NULL ) {
				int ret=get_rtsp_streams(ppstream_head);
				if (ret != 0 || pstream_head == NULL) {
					eprintf("%s: Failed to find default stream\n", __FUNCTION__);
					interface_showMessageBox(_T("ERR_DEFAULT_STREAM"), thumbnail_warning, 0);
					return 0;
				}
			}
			streams_struct* stream_ptr = get_stream(streamNumber);
			if ( !stream_ptr ) {
				interface_showMessageBox(_T("ERR_STREAM_IN_LIST"), thumbnail_error, 0);
				eprintf("RTSP: Stream number not found in linked list\n");
				return 0;
			}

			sprintf(URL, "rtsp://%s:%d/%s", appControlInfo.rtspInfo.streamIP, appControlInfo.rtspInfo.RTSPPort, stream_ptr->stream);
			if( cmd->command == interfaceCommandYellow )
			{
				eprintf("RTSP: Add to Playlist '%s'\n",URL);
				playlist_addUrl(URL, stream_ptr->name ? stream_ptr->name : stream_ptr->stream);
			} else if (cmd->command == interfaceCommandGreen ||
			           cmd->command == interfaceCommandInfo)
			{
				eprintf("RTSP: Stream %03d: '%s'\n", streamNumber, URL);
				if( stream_ptr->poster && stream_ptr->poster[0] )
				{
					interface_showPosterBox( stream_ptr->description,
					                         stream_ptr->name ? stream_ptr->name : stream_ptr->stream,
					                         INTERFACE_BORDER_RED, INTERFACE_BORDER_GREEN, INTERFACE_BORDER_BLUE, INTERFACE_BORDER_ALPHA,
					                         thumbnail_vod,
					                         stream_ptr->poster, NULL, SET_NUMBER(streamNumber));
				}
				//interface_showMessageBox(URL, thumbnail_info, 0);
			}
			return 0;
		}
	}

	return 1;
}
示例#9
0
int rtsp_playURL(int which, const char *URL, const char* description, const char* thumbnail)
{
	return rtsp_setChannelFromURL(interfaceInfo.currentMenu, URL, description, thumbnail, SET_NUMBER(which));
}