//===========================================================================
Update_t CmdMOTD( int nArgs )
{
	TCHAR sText[ CONSOLE_WIDTH ];

	ConsoleBufferPush( TEXT(" Apple ][+ //e Emulator for Windows") );
	CmdVersion(0);
	CmdSymbols(0);
	wsprintf( sText, "  '~' console, '%s' (specific), '%s' (all)"
		 , g_aCommands[ CMD_HELP_SPECIFIC ].m_sName
//		 , g_aCommands[ CMD_HELP_SPECIFIC ].pHelpSummary
		 , g_aCommands[ CMD_HELP_LIST     ].m_sName
//		 , g_aCommands[ CMD_HELP_LIST     ].pHelpSummary
	);
	ConsoleBufferPush( sText );

	ConsoleUpdate();

	return UPDATE_ALL;
}
Esempio n. 2
0
static void *main_loop(void *targ) {
	struct main_loop_arg *arg = (struct main_loop_arg*)targ;
	struct receiver_arg rarg;
	char *cmd = NULL;
	pthread_t reader_thread;
  
	if (arg->usb_present == 1) {
		rarg.run = 1;
		pthread_create(&reader_thread, NULL, &uart_receiver, &rarg);
		// cache Version information now:
		CmdVersion(NULL);
	}

	FILE *script_file = NULL;
	char script_cmd_buf[256] = {0x00};  // iceman, needs lua script the same file_path_buffer as the rest

	if (arg->script_cmds_file) {
		script_file = fopen(arg->script_cmds_file, "r");
		
		if (script_file)
			printf("using 'scripting' commands file %s\n", arg->script_cmds_file);
	}

	read_history(".history");

	while(1)  {

		// If there is a script file
		if (script_file) {
			
			if (!fgets(script_cmd_buf, sizeof(script_cmd_buf), script_file)) {
				fclose(script_file);
				script_file = NULL;
			} else {
				char *nl;
				nl = strrchr(script_cmd_buf, '\r');
				if (nl)
					*nl = '\0';
				
				nl = strrchr(script_cmd_buf, '\n');
				
				if (nl)
					*nl = '\0';
				
				int newlen = strlen(script_cmd_buf);
				if ((cmd = (char*) malloc( newlen + 1)) != NULL) {
					memset(cmd, 0x00, newlen);
					strcpy(cmd, script_cmd_buf);
					printf("%s\n", cmd);
				}
			}
		} else {
			cmd = readline(PROXPROMPT);
		}
		
		// this one should pick up all non-null cmd...
		// why is there a 
		if (cmd) {

			while(cmd[strlen(cmd) - 1] == ' ')
				cmd[strlen(cmd) - 1] = 0x00;

			if (cmd[0] != 0x00) {
				int ret = CommandReceived(cmd);
				add_history(cmd);
				
				// exit or quit
				if (ret == 99) 
					break;
			}
			free(cmd);
			cmd = 0;
		} else {
			printf("\n");
			break;
		}
	}

	if (script_file) {
		fclose(script_file);
		script_file = NULL;
	}
	
	write_history(".history");

	free(cmd);
	cmd = 0;
			
	if (arg->usb_present == 1) {
		rarg.run = 0;
		pthread_join(reader_thread, NULL);
	}

	ExitGraphics();
	pthread_exit(NULL);
	return NULL;
}