Exemple #1
0
int main(int argc, char *argv[])
{
	char *ext;

	// initialize common controls
	InitCommonControls();

	// set up exception handling
	pass_thru_filter = SetUnhandledExceptionFilter(exception_filter);
	SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);

	// if we're a GUI app, out errors to message boxes
	if (win_is_gui_application() || is_double_click_start(argc))
	{
		// if we are a GUI app, output errors to message boxes
		mame_set_output_channel(OUTPUT_CHANNEL_ERROR, winui_output_error, NULL, NULL, NULL);

		// make sure any console window that opened on our behalf is nuked
		FreeConsole();
	}

	// soft-link optional functions
	soft_link_functions();

	// compute the name of the mapfile
	strcpy(mapfile_name, argv[0]);
	ext = strchr(mapfile_name, '.');
	if (ext != NULL)
		strcpy(ext, ".map");
	else
		strcat(mapfile_name, ".map");

	// parse config and cmdline options
	return cli_execute(argc, argv, mame_win_options);
}
Exemple #2
0
int main(int argc, char *argv[])
{
	// cli_execute does the heavy lifting; if we have osd-specific options, we
	// would pass them as the third parameter here
	mini_osd_interface osd;
	return cli_execute(argc, argv, osd, NULL);
}
Exemple #3
0
int main(int argc, char **argv)
#endif
{
	static char *args[255];	int n=0;
	int ret;
	FILE *f;

	printf("Iniciando\n");


	myosd_init();

	while(1)
	{
		droid_ios_setup_video();

	   // cli_execute does the heavy lifting; if we have osd-specific options, we
	  // would pass them as the third parameter here
		n=0;
		args[n]= (char *)"mame4droid";n++;
		//args[n]= (char *)"-skip_gameinfo"; n++;
		//args[n]= (char *)"starforc"; n++;
		//args[n]= (char *)"1944"; n++;
		//args[n]= (char *)"mslug3"; n++;
		//args[n]= (char *)"outrun"; n++;
		//args[n]= (char *)"-autoframeskip"; n++;
		//args[n]= (char *)"-noautoframeskip"; n++;
		//args[n]= (char *)"-nosound"; n++;
		//args[n]= (char *)"-novideo"; n++;
		//args[n]= (char *)"-nosleep"; n++;
		//args[n]= (char *)"-sleep"; n++;
		//args[n]= (char *)"-jdz"; n++;args[n]= (char *)"0.0"; n++;
		//args[n]= (char *)"-jsat"; n++;args[n]= (char *)"1.0"; n++;
		//args[n]= (char *)"-joystick_deadzone"; n++;args[n]= (char *)"0.0"; n++;
		args[n]= (char *)"-nocoinlock"; n++;

	  f=fopen("mame4droid.cfg","r");
	  if (f) {
			fscanf(f,"%d",&myosd_last_game_selected);
			fclose(f);
	  }

	  ret = cli_execute(n, args, droid_mame_options);

	  f=fopen("mame4droid.cfg","w");
	  if (f) {
		  fprintf(f,"%d",myosd_last_game_selected);
		  fclose(f);
		  sync();

	  }
	}

	myosd_deinit();

	return ret;
}
static int ippool_config_restore(const char *file_name)
{
	int result = 0;
	FILE *file = NULL;
	char *buffer = NULL;
	int count;
	char *cmd[] = { NULL, };

	if (file_name == NULL) {
		result = -EINVAL;
		goto out;
	}

	buffer = malloc(4000);
	if (buffer == NULL) {
		result = -ENOMEM;
		goto out;
	}
	cmd[0] = buffer;

	/* Open the input stream */
	
	file = fopen(file_name, "r");
	if (file == NULL) {
		fprintf(stderr, "Failed to open input file %s: %m\n", file_name);
		result = -errno;
		goto out;
	}

	/* Read line into our input buffer. If a newline is escaped with a '\\',
	 * continue reading next line into buffer.
	 * Ignore lines beginning with '#'.
	 * Ignore blank lines.
	 */
	count = 0;
	for (;;) {
		int chars_read;

		chars_read = ippool_config_get_line(buffer + count, 4000 - count, file);
		if (chars_read == 0) {
			/* blank line */
			if (count > 0) goto got_command;
			continue;
		}
		if (chars_read < 0) {
			/* end of input */
			break;
		}
		if ((count == 0) && (buffer[0] == '#')) {
			/* comment line */
			if (count > 0) goto got_command;
			continue;
		}
		count += chars_read;
		if (buffer[count - 1] == '\\') {
			/* line is continued on next */
			count--;
			buffer[count] = '\0';
			continue;
		}

	got_command:
		/* replay the command  */
		result = cli_execute(1, cmd);
		if (result < 0) {
			fprintf(stderr, "Command replay at command:\n");
			fprintf(stderr, "%s\n", buffer);
			fprintf(stderr, "Aborting.\n");
			result = 0;
			goto out;
		}

		/* get ready for next line */
		count = 0;
	}

out:
	if (buffer != NULL) {
		free(buffer);
	}
	if (file != NULL) {
		fclose(file);
	}

	return result;
}
int main(int argc, char *argv[])
{
	int result;
	int opt;
	int arg = 1;
	static char *exit_cmd[] = { "exit", NULL };
	char *hist_size;

	strcpy(server, "localhost");

	cli_init("ippool");
	result = cli_add_commands(&cmds[0]);
	if (result < 0) {
		fprintf(stderr, "Application initialization error.\n");
		return result;
	}

	cl = clnt_create(server, IPPOOL_PROG, IPPOOL_VERSION, "udp");
	if (cl == NULL) {
		clnt_pcreateerror(server);
		exit(1);
	}
	atexit(cleanup);

	opterr = 0;		/* no error messages please */

	opt = getopt(argc, argv, "qR:");
	switch (opt) {
	case 'q':
		opt_quiet = 1;
		arg++;
		break;
	case 'R':
		strncpy(server, optarg, sizeof(server));
		arg += 2;
		ippool_set_prompt(server);
		break;
	default:
		break;
	}

	/* If user supplied arguments, send them to the CLI now and immediately exit.
	 */
	if (argc > arg) {
		(void) cli_execute(argc - arg, &argv[arg]);
		(void) cli_execute(1, exit_cmd);
	} else {
		/* interactive mode */
		interactive = 1;
		ippool_histfile = getenv("IPPOOL_HISTFILE");
		if (ippool_histfile == NULL) {
			ippool_histfile = "~/.ippool_history";
		}
		hist_size = getenv("IPPOOL_HISTFILESIZE");
		if (hist_size != NULL) {
			ippool_histfile_maxsize = strtoul(hist_size, NULL, 0);
		}

		cli_read_history_file(ippool_histfile);
		cli_run();
	}

	return 0;
}
Exemple #6
0
int main(int argc, char **argv)
{
	int res = 0;

#else

/* gee */
extern "C" DECLSPEC void SDLCALL SDL_SetModuleHandle(void *hInst);

// translated to utf8_main
int main(int argc, char *argv[])
{
	int res = 0;

#if	!(SDL_VERSION_ATLEAST(1,3,0))
	/* Load SDL dynamic link library */
	if ( SDL_Init(SDL_INIT_NOPARACHUTE) < 0 ) {
		fprintf(stderr, "WinMain() error: %s", SDL_GetError());
		return(FALSE);
	}
	SDL_SetModuleHandle(GetModuleHandle(NULL));
#endif
#endif
	// disable I/O buffering
	setvbuf(stdout, (char *) NULL, _IONBF, 0);
	setvbuf(stderr, (char *) NULL, _IONBF, 0);

	#ifdef SDLMAME_OS2
	MorphToPM();
	#endif

#if defined(SDLMAME_X11) && (SDL_MAJOR_VERSION == 1) && (SDL_MINOR_VERSION == 2)
	if (SDL_Linked_Version()->patch < 10)
	/* workaround for SDL choosing a 32-bit ARGB visual */
	{
		Display *display;
		if ((display = XOpenDisplay(NULL)) && (DefaultDepth(display, DefaultScreen(display)) >= 24))
		{
			XVisualInfo vi;
			char buf[130];
			if (XMatchVisualInfo(display, DefaultScreen(display), 24, TrueColor, &vi)) {
				snprintf(buf, sizeof(buf), "0x%lx", vi.visualid);
				osd_setenv(SDLENV_VISUALID, buf, 0);
			}
		}
		if (display)
			XCloseDisplay(display);
	}
#endif

	res = cli_execute(argc, argv, mame_sdl_options);

#ifdef MALLOC_DEBUG
	{
		void check_unfreed_mem(void);
		check_unfreed_mem();
	}
#endif

	// already called...
	//SDL_Quit();

	exit(res);

	return res;
}
Exemple #7
0
static window_event_result con_handler(window *wind,const d_event &event, const unused_window_userdata_t *)
{
	int key;
	static fix64 last_scroll_time = 0;
	
	switch (event.type)
	{
		case EVENT_WINDOW_ACTIVATED:
			key_toggle_repeat(1);
			break;

		case EVENT_WINDOW_DEACTIVATED:
			key_toggle_repeat(0);
			con_size = 0;
			con_state = CON_STATE_CLOSED;
			break;

		case EVENT_KEY_COMMAND:
			key = event_key_get(event);
			switch (key)
			{
				case KEY_SHIFTED + KEY_ESC:
					switch (con_state)
					{
						case CON_STATE_OPEN:
						case CON_STATE_OPENING:
							con_state = CON_STATE_CLOSING;
							break;
						case CON_STATE_CLOSED:
						case CON_STATE_CLOSING:
							con_state = CON_STATE_OPENING;
						default:
							break;
					}
					break;
				case KEY_PAGEUP:
					con_scroll_offset+=CON_SCROLL_OFFSET;
					if (con_scroll_offset >= CON_LINES_MAX-1)
						con_scroll_offset = CON_LINES_MAX-1;
					while (con_buffer[CON_LINES_MAX-1-con_scroll_offset].line[0]=='\0')
						con_scroll_offset--;
					break;
				case KEY_PAGEDOWN:
					con_scroll_offset-=CON_SCROLL_OFFSET;
					if (con_scroll_offset<0)
						con_scroll_offset=0;
					break;
				case KEY_CTRLED + KEY_A:
				case KEY_HOME:              cli_cursor_home();      break;
				case KEY_END:
				case KEY_CTRLED + KEY_E:    cli_cursor_end();       break;
				case KEY_CTRLED + KEY_C:    cli_clear();            break;
				case KEY_LEFT:              cli_cursor_left();      break;
				case KEY_RIGHT:             cli_cursor_right();     break;
				case KEY_BACKSP:            cli_cursor_backspace(); break;
				case KEY_CTRLED + KEY_D:
				case KEY_DELETE:            cli_cursor_del();       break;
				case KEY_UP:                cli_history_prev();     break;
				case KEY_DOWN:              cli_history_next();     break;
				case KEY_TAB:               cli_autocomplete();     break;
				case KEY_ENTER:             cli_execute();          break;
				case KEY_INSERT:
					cli_toggle_overwrite_mode();
					break;
				default:
					int character = key_ascii();
					if (character == 255)
						break;
					cli_add_character(character);
					break;
			}
			return window_event_result::handled;

		case EVENT_WINDOW_DRAW:
			timer_delay2(50);
			if (con_state == CON_STATE_OPENING)
			{
				if (con_size < CON_LINES_ONSCREEN && timer_query() >= last_scroll_time+(F1_0/30))
				{
					last_scroll_time = timer_query();
					if (++ con_size >= CON_LINES_ONSCREEN)
						con_state = CON_STATE_OPEN;
				}
			}
			else if (con_state == CON_STATE_CLOSING)
			{
				if (con_size > 0 && timer_query() >= last_scroll_time+(F1_0/30))
				{
					last_scroll_time = timer_query();
					if (! -- con_size)
						con_state = CON_STATE_CLOSED;
				}
			}
			con_draw();
			if (con_state == CON_STATE_CLOSED && wind)
			{
				return window_event_result::close;
			}
			break;
		case EVENT_WINDOW_CLOSE:
			break;
		default:
			break;
	}
	
	return window_event_result::ignored;
}
Exemple #8
0
int main(int argc, char *argv[]){
	return cli_execute(argc, argv, NULL);
}
Exemple #9
0
int main(int argc, char **argv)
#endif
{
	static char *args[255];	int n=0;
	int ret;
	FILE *f;
    
	printf("Iniciando\n");
    
    
	myosd_init();
    
	while(1)
	{
		droid_ios_setup_video();
        
        // cli_execute does the heavy lifting; if we have osd-specific options, we
        // would pass them as the third parameter here
		n=0;
		args[n]= (char *)"mame4x";n++;

		//args[n]= (char *)"starforc"; n++;
		//args[n]= (char *)"1944"; n++;
		//args[n]= (char *)"mslug3"; n++;
        //args[n]= (char *)"dino"; n++;
		//args[n]= (char *)"outrun"; n++;
		//args[n]= (char *)"-autoframeskip"; n++;
		//args[n]= (char *)"-noautoframeskip"; n++;
		//args[n]= (char *)"-nosound"; n++;
		//args[n]= (char *)"-novideo"; n++;
		//args[n]= (char *)"-nosleep"; n++;
        //args[n]= (char *)"-autosave"; n++;
		//args[n]= (char *)"-sleep"; n++;
		//args[n]= (char *)"-jdz"; n++;args[n]= (char *)"0.0"; n++;
		//args[n]= (char *)"-jsat"; n++;args[n]= (char *)"1.0"; n++;
		//args[n]= (char *)"-joystick_deadzone"; n++;args[n]= (char *)"0.0"; n++;
		args[n]= (char *)"-nocoinlock"; n++;
        
        if(isGridlee){
            args[n]= (char *)"gridlee"; n++;
        }
        
        netplay_t *handle = netplay_get_handle();
        if(handle->has_connection)
        {
            if(!handle->has_begun_game)
            {
                args[n]= (char *)handle->game_name; n++;
            }
            else
            {
                char buf[256];
                sprintf(buf,"%s not found!",handle->game_name);
                handle->netplay_warn(buf);
                handle->has_begun_game = 0;
                handle->has_connection = 0;
            }
        }
                
        if(myosd_reset_filter==0)
        {
            f=fopen("mame4x.cfg","r");
            if (f) {
                fscanf(f,"%d",&myosd_last_game_selected);
                fclose(f);
            }
        }
        else
        {
            myosd_last_game_selected = 0;
            f=fopen("mame4x.cfg","w");
            if (f) {
                fprintf(f,"%d",myosd_last_game_selected);
                fclose(f);
                sync();
            }
            myosd_reset_filter = 0;
        }
        
        ret = cli_execute(n, args, droid_mame_options);
        
        f=fopen("mame4x.cfg","w");
        if (f) {
            fprintf(f,"%d",myosd_last_game_selected);
            fclose(f);
            sync();
        }
	}
    
	myosd_deinit();
    
	return ret;
}