int main(int argc, char *argv[])
{
	int ret;

	ret = init_uffs_fs();

	if (ret != 0) {
		printf ("Init file system fail: %d\n", ret);
		return -1;
	}

	cli_add_commandset(get_helper_cmds());
	cli_add_commandset(get_test_cmds());
	cliMain();

	release_uffs_fs();

	return 0;
}
Example #2
0
void cliMain()
{
	char line[80];
	int linelen = 0;

	printf("$ ");
	cli_add_commandset(default_cmdset);

	while (!m_exit) {
		char ch;
		ch = getc(stdin);
		switch (ch) {
		case 8:
		case 127:
			if (linelen > 0) {
				--linelen;
				printf("\x08 \x08");
			}
			break;

		case '\r':
		case '\n':
			//printf("\r\n");
			if (linelen > 0) {
				line[linelen] = 0;
				cliInterpret(line);
			}
			linelen = 0;
			printf("$ ");
			break;

		case 21:
			while (linelen > 0) {
				--linelen;
				printf("\x08 \x08");
			}
			break;

		default:
			if (ch >= ' ' && ch < 127 && linelen < sizeof(line) - 1) {
				line[linelen++] = ch;
				//printf("%c", ch);
			}
		}
	}
}
int main(int argc, char *argv[])
{
	int ret;

#ifdef UNIX
	signal(SIGSEGV, crash_handler);
#endif

	uffs_SetupDebugOutput(); 	// setup debug output as early as possible

	if (parse_options(argc, argv) < 0) {
		return -1;
	}
	
	if (conf_verbose_mode) {
		#if 1
		MSGLN("Internal data structure size:");
		MSGLN("  TreeNode: %d", sizeof(TreeNode));
		MSGLN("  struct BlockListSt: %d", sizeof(struct BlockListSt));
		MSGLN("  struct DirhSt: %d", sizeof(struct DirhSt));
		MSGLN("  struct FilehSt: %d", sizeof(struct FilehSt));
		MSGLN("  struct FdataSt: %d", sizeof(struct FdataSt));
		MSGLN("  struct uffs_TagStoreSt: %d", sizeof(struct uffs_TagStoreSt));
		MSGLN("  uffs_Buf: %d", sizeof(uffs_Buf));
		MSGLN("  struct uffs_BlockInfoSt: %d", sizeof(struct uffs_BlockInfoSt));
		MSGLN("");
		#endif
		print_params();
		print_mount_points();
	}

	// setup file emulator storage with parameters from command line
	setup_storage(femu_GetStorage());

	// setup file emulator private data
	setup_emu_private(femu_GetPrivate());

	ret = init_uffs_fs();
	if (ret != 0) {
		MSGLN ("Init file system fail: %d", ret);
		return -1;
	}

	cli_add_commandset(get_helper_cmds());
	cli_add_commandset(get_test_cmds());
	if (conf_command_line_mode) {
		if (conf_exec_script) {
			cli_interpret(script_command);
		}
		cli_main_entry();
	}
	else {
		if (conf_exec_script) {
			cli_interpret(script_command);
		}
		else {
			cli_main_entry();
		}
	}

	release_uffs_fs();

	return 0;
}