Exemplo n.º 1
0
void CreateRshell (void)
{
    CString root   = GetGlobal("Root");
    CString config = GetGlobal("CustomizationList");

    CString destPath = root + "\\Configs\\" + config + "\\Rshell";

    CWnd Mywnd;

//		Mywnd.MessageBox(CString(iniFilePath),iniFilePath,MB_OK);

//		Mywnd.MessageBox(CString(customizationPath),customizationPath,MB_OK);

    ifstream part1("part1.ini");
    ifstream part2("part2.ini");
    _mkdir (destPath);
    CString Rsh = destPath + "\\" +"rshell.ini";
//	FILE* rshell = theApp.OpenAFile(CDdir +"rshell.ini", "w");

    ofstream rshell(Rsh);
    CString fvalue1=GetGlobal("ShellTitleText");
    CString fvalue2=GetGlobal("ShellBgBitmap");
//	char *fvalue3=GetGlobal("dialog_title_text");
    CString fvalue4=GetGlobal("ShellInstallTextFile");
    char jsprefname[200];

    if(!part1) {
        cout << "cannot open the file \n";
    }
    while (!part1.eof()) {

        part1.getline(jsprefname,200);
//		fprintf(globs, jsprefname);
//		fprintf(globs, "\n");

        rshell <<jsprefname<<"\n";
    }
    rshell <<"caption="<<fvalue1<<"\n";
    rshell <<"bk_bitmap="<<fvalue2<<"\n";
    rshell <<"button2_cmdline="<<fvalue4<<"\n";

//	rshell <<"dialog_title_txt="<<fvalue3<<"\n";
    if(!part2) {
        cout << "cannot open the file \n";
    }
    while (!part2.eof()) {

        part2.getline(jsprefname,200);
        rshell <<jsprefname<<"\n";
    }
    rshell.close();

}
Exemplo n.º 2
0
/**
 * Function: main()
 * Description: main routine of the shell.
 * Synopsis: int main(int argc, char* argv[]) (conforms to ANSI C)
 * Return value:
 *   o An integer, indicating exit status.
 */
int
main(int argc, char* argv[])
{
	char* prompts[] =
	{
		"msh",
		"rshell",
		"rsnoop"
	};

	enum
	{
		P_MSH,
		P_RSHELL,
		P_RSNOOP
	};

	int prompt = P_MSH;

	printf
	(
		"\nWelcome to Microshell Client\nVersion: %s\nType '?' for help.\n",
		MICROSHELL_VERSION
	);

	memset(&status, 0, sizeof(sh_status_t));
	init();

	/* We loop until we get the quit signal */
	while(status.curr_signal != SH_QUIT)
	{
		char        cmdline[CMD_LINE_MAX_CHARS] = {0};
		/*sh_commands cmd_type;*/

		/* Save our state here to restart from here
		 * in case we got interrupted by a SIGALRM
		 */
		if(sigsetjmp(jmpbuf, SIGALRM))
		{
		}

		/* Prompt */
		printf("\n%s> ", prompts[prompt]);

		fgets(cmdline, CMD_LINE_MAX_CHARS, stdin);

		/* A copy of a command line for processing */
		strcpy(status.cmdline, cmdline);

		if(status.curr_signal == SH_REMOTE)
		{
			if(prompt == P_RSHELL)
				rshell(cmdline);
			else
				rsnoop(cmdline);
		}
		else
		{
			/* Parse the command line */
			status.curr_cmd = parseCmd(cmdline);

			prompt = P_MSH;

			/* Dispatch according to the command type */
			switch(status.curr_cmd)
			{
				case QUIT:
					status.curr_signal = SH_QUIT;
					/*disconnect();*/
					break;

				case SRV_RSHELL:
					/*rshell(cmdline);*/
					connectSnoopSrv(cmdline);
					prompt = P_RSHELL;
					break;

				case SRV_RSNOOP:
					/*rsnoop(cmdline);*/
					connectSnoopSrv(cmdline);
					prompt = P_RSNOOP;
					break;

				case REGISTER: /* Send connection request */

					if(status.connected == true)
						fprintf(stderr, "This client already opened a connection to the server!\n");
					else
					{
						connectTimeSrv();
						initSignals();
					}

					break;


				case SRV_VERSION: /* Send version request */

					if(status.connected == false)
						fprintf(stderr, "Server Version Request: Not connected to the server yet.\n");
					else
						srvVersion();

					break;


				case SRV_ELAPSED_TIME: /* Send eslsapsed time request */

					if(status.connected == false)
						fprintf(stderr, "Elapsed Time Request: Not connected to the server yet.\n");
					else
						srvElapsedTime();

					break;


				case SRV_TOD:/* Send time-of-the-day request */
					if(status.connected == false)
						fprintf(stderr, "Time of the Day Request: Not connected to the server yet.\n");
					else
						srvTOD();

					break;


				case PIPELINE:
					execPipeline(status.pipeline_size, -1);
					reset();
					break;


				case HELP:
					showHelp();
					break;


				case BLANK:
				case UNKNOWN: /* UNKNOWN was meant for error checking. Unused. */
					reset();
					break;


				default:
					fprintf(stderr, "msh: Unexpected command type: %d (internal error)\n", status.curr_cmd);
					exit(1);
			} /* switch(status.curr_cmd) */
		} /* !SH_REMOTE */

		/* Make sure we don't have anything in those streams */
		fflush(stdout);
		fflush(stdin);
		fflush(stderr);

	} /*  while(not QUIT) */

	exit(0);

} /* main() */