Пример #1
0
void writeDisplayFile(QString type, QString writeText) {
    QDir(getSaveDir()).mkpath(".");
    QFile displayFile(getSaveDir() + "/" + type + ".txt");

    if (!displayFile.open(QIODevice::WriteOnly | QIODevice::Text))
        return;
    displayFile.write(writeText.toUtf8());
    openFile(displayFile.fileName());
    displayFile.close();
}
Пример #2
0
void CBranch_patcherDlg::OnButtonPatch() 
{
	UpdateData( true );

	CString diffCmdLine;
	diffCmdLine.Format( "cvs.exe diff -c > %s 2> %s", TEMP_DIFF_FILE, DIFF_ERRORS ); // needs a valid cvs login before! and cvs.exe in the path
	CString text;
	text.Format( "Get diff from directory %s?\n\nCommand (choose No to copy it into the clipboard):\n%s", m_SrcDir, diffCmdLine );
	int result;
	if ( (result = ::MessageBox( m_hWnd, text, "Confirmation", MB_YESNOCANCEL | MB_ICONQUESTION )) == IDYES )
	{
		if ( _chdir( m_SrcDir ) == 0 )
		{
			system( diffCmdLine );
			displayFile( TEMP_DIFF_FILE );
			SaveDiff = true;
			colorizeDiff();
			m_Display->LineScroll( 0 );
			((CButton*)GetDlgItem( IDC_DoPatch ))->EnableWindow( TRUE );

			if ( (m_Display->GetLineCount() == 0) ||
				 (m_Display->GetLineCount() == 1 && m_Display->LineLength(0)<2) )
			{
				displayFile( DIFF_ERRORS );
				displayMessage( "Diff is empty.\r\nIf this is not the expected result:\r\n- check if the source directory is part of a CVS tree\r\n- check if cvs.exe is in your PATH\r\n- check if you are logged to the cvs server with 'cvs login' (set your home cvs directory in the HOME environment variable if needed)\r\n- check if C:\\ has enough free space and access rights to write a file.\n\nHere is the log:\n\n", true );
			}
			else
			{
				m_Filename = TEMP_DIFF_FILE + ":";
				UpdateData( false );
			}
		}
		else
		{
			displayMessage( "Source directory not found" );
		}
	}
	else if ( result == IDNO )
	{
		SendTextToClipboard( diffCmdLine );
	}
}
Пример #3
0
void CBranch_patcherDlg::OnDoPatch() 
{
	UpdateData( true );
	
	if ( SaveDiff )
	{
		// Save the diff from the richedit
		saveFile( TEMP_DIFF_FILE );
	}

	// Apply the patch
	CString patchCmdLine, concatOutput, delPatchErrors;
	patchCmdLine.Format( "%spatch.exe -c -p%u --verbose < %s > %s 2> %s", PatchExeDir, CvsDiffDirLevel, TEMP_DIFF_FILE, PATCH_RESULT, PATCH_ERRORS ); // needs patch.exe in the path
	concatOutput.Format( "copy %s+%s %s", PATCH_RESULT, PATCH_ERRORS, PATCH_RESULT );
	delPatchErrors.Format( "del %s", PATCH_ERRORS );

	CString text;
	text.Format( "Patch diff to directory %s?\n\nCommand (choose No to copy it into the clipboard):\n%s", m_DestDir, patchCmdLine );
	int result;
	if ( (result = ::MessageBox( m_hWnd, text, "Confirmation", MB_YESNOCANCEL | MB_ICONQUESTION )) == IDYES )
	{
		if ( _chdir( m_DestDir ) == 0 )
		{
			system( patchCmdLine );
			system( concatOutput );
			system( delPatchErrors );
			displayFile( PATCH_RESULT );
			SaveDiff = false;
			m_Display->LineScroll( 0 );

			if ( (m_Display->GetLineCount() == 0) ||
				 (m_Display->GetLineCount() == 1 && m_Display->LineLength(0)<2) )
			{
				CString s;
				s.Format( "Nothing was patched.\r\nIf this is not the expected result:\r\n- check if the good patch.exe is in %s\r\n- check if %s exists (generated by previous diff)\r\n- check if C:\\ has enough free space and access rights to write a file.", TEMP_DIFF_FILE );
				displayMessage( s );
			}
			else
			{
				m_Filename = PATCH_RESULT + ":";
				UpdateData( false );
			}
		}
		else
		{
			displayMessage( "Target directory not found" );
		}
	}
	else if ( result == IDNO )
	{
		SendTextToClipboard( patchCmdLine );
	}
}
Пример #4
0
/*!
 * \fn void mainMenu()
 *  Main menu of csuper.
 */
void mainMenu()
{
    int choice;
    int stop = false;

    do
    {
        choice=-1;

        clearScreen();

        printf(_("Csuper - Universal points counter allowing a dispense with reflection v"));
        printf(_("%s"),CSUPER_VERSION);
        printf(_("\n\nWhat do you want to do?\n "
            "(%d) Play a new game\n (%d) Load an existing game\n (%d) Display the results of an existing game"
            "\n (%d) Delete a game\n (%d) Display all existing games\n (%d) Export a file\n"
            " (%d) Display the preferences menu\n (%d) Quit the program\n\nYour choice : ")
            ,newMatch,loadMatch,printFile,deleteFiles,listFile,export_file,pref,quit);

        intKey(&choice);

        switch (choice) {
            case newMatch  :    newGame();
                                break;
            case loadMatch  :   loadGame();
                                break;
            case printFile  :   displayFile();
                                break;
            case deleteFiles  : deleteCsuFileNom();
                                break;
            case listFile  :    listCsuFiles();
                                break;
            case export_file  : exportCsu();
                                break;
            case pref :         preferencesMenu();
                                break;
            case quit  :        printf(_("\nSee you.\n"));
                                systemPause();
                                stop=true;
                                break;
            case easterEggs :   printf(_("\nYes, it's the correct answer, but that doesn't help me to know what you want to do.\n"));
                                systemPause();
                                break;
            default :           wrongChoice();
                                systemPause();
        }

        clearScreen();

	} while (stop==false);
}
Пример #5
0
void writeDisplayFile(QString name, QByteArray data) {
    QFile displayFile(getSaveDir() + "/" + name);

    if (!displayFile.open(QIODevice::WriteOnly | QIODevice::Text))
        return;
    displayFile.write(data);
    openFile(displayFile.fileName());
    displayFile.close();

#ifdef BLACKBERRY
    // Cascades code is not working
/*#if defined(BLACKBERRY)
    QVariantMap data;
    data["title"] = "Links";
    bb::cascades::Invocation* invocation = bb::cascades::Invocation::create(
                bb::cascades::InvokeQuery::create().invokeActionId("bb.action.SHARE").metadata(data).uri("file:///accounts/1000/shared/misc/updates.txt").invokeTargetId(
                                "sys.pim.remember.composer"));
    connect(invocation, SIGNAL(finished()), invocation, SLOT(deleteLater()));
*/
    #endif
}
Пример #6
0
int check_credentials() {

	void de_exit();
	char * getpass();
	char * temp2;
	int pswd_tries;
	int status;
	int username_tries;
	int wait_result;
	pswd_tries = 1;
	status = 0;
	add_entries = malloc(LINESIZE);
	temp2 = malloc(LINESIZE);
	username_tries = 1;

username_prompt:

	if (!(strcmp(username, "interactive"))) {
		 sprintf(username, "");
		username[0] = 0;
		 printf("%s   %s", connect_idm, please_wait);
		 fflush(stdout);
		status = init_bind_to_ds(&assoc); /* Bind no authentication mode */
		if (status != OK) {
			de_exit(-1);
		}
		wait_result = wait_bind_to_ds(assoc, TRUE); /* block */
		if (wait_result != OK) {
			 printf("\n%s", srvr_unava);
			 de_exit(-1);
		} else {
			 printf(done);
		}

		status = get_username();
		if (status != OK) {
			return NOTOK;
		}
		if (!(strcmp(add_entries, yes_string))) {
			if (tmp_org_found == TRUE) {
				 de_unbind();
				pswd_intrctv = TRUE;
				if (status != OK) {
					de_exit(-1);
				}
				goto prompt_pswd;
			} else {
				 de_unbind();
				pswd_intrctv = FALSE;
				status = init_bind_to_ds(&assoc);
				if (status != OK) {
					de_exit(-1);
				}
				return OK;
			}
		}
		if (username == quit_String) {
			de_exit(-1);
		}
		 de_unbind();  /* Unbind from no authentication mode */
	}

prompt_pswd:
	if (pswd_intrctv == TRUE) {
		wait_result = NOTOK; /* Enter loop */
		while (wait_result != OK) {
			 sprintf(temp2, "%s :  ", ask_password);
			 sprintf(password, getpass(temp2));

			if (strlen(password) <= 0) {
				if (pswd_tries < PSWD_TRY_LIMIT) {
					 printf(pswd_must_enter);
					pswd_tries ++;
					goto prompt_pswd;
				} else {
					 printf(pswd_lmt_xcd);
					de_exit(-1);
				}
			} else if (!(strcmp(password, "?"))) {
				displayFile("userPassword", FALSE);
				goto prompt_pswd;
			}
			status = init_bind_to_ds(&assoc);
			if (status != OK) {
				de_exit(-1);
			}

			wait_result = wait_bind_to_ds(assoc, TRUE); /* block */
			if (wait_result == INV_PSWD) {
				if (pswd_tries < PSWD_TRY_LIMIT) {
					 printf(pswd_tryagain);
					pswd_tries ++;
					 sprintf(password, "interactive");
				} else {
					 printf(pswd_lmt_xcd);
					de_exit(-1);
				}
			} else if (wait_result == NOTOK) {
				 printf("%s   ...%s\n", nobind_user, exiting);
				de_exit(-1);
			}
		}
	} else if (pswd_intrctv == FALSE) {
		status = init_bind_to_ds(&assoc);
		if (status == INV_USERNAME) {
			if (username_intrctv == TRUE) {
				if (username_tries >= USERNAME_TRY_LIMIT) {
					 printf(errmsg_invun);
					 printf(username_lmt_xcd);
					de_exit(-1);
				}
				username_tries ++;
				 printf(errmsg_invun);
				 sprintf(username, "interactive");
				goto username_prompt;
			}
		} else if (status != OK) {
			de_exit(-1);
		}
	}

	free(temp2);
	return OK;
}
Пример #7
0
int get_username() {

	struct namelist * clp  = NULLLIST;
	struct namelist * olp  = NULLLIST;
	struct namelist * oulp = NULLLIST;
	struct namelist * plp  = NULLLIST;

	FILE * dn_file;

	int noCos;
	int noOrgs;
	int noOUs;
	int noPersons;
	int objectType;
	int status;
	void de_exit();
	char * add_org_ids;
	char * already_in;
	char * confirm_out;
	char * cp;
	char * full_c;
	char * mapCoName();
	char * str;
	char * tmp_search;
	char addthisorg[LINESIZE];
	char buffer[LINESIZE];
	char posdit_user[LINESIZE];
	char username_save[LINESIZE];
	char save_addorg_posdit[LINESIZE];
	extern char have_department[];
	extern char just_dn[];
	void searchFail();
	void onint1();
	void exit();
	Attr_Sequence at;

	add_org_ids = malloc(LINESIZE);
	already_in	= malloc(LINESIZE);
	confirm_out = malloc(LINESIZE);
	cp		= malloc(LINESIZE);
	full_c	= malloc(LINESIZE);
	str         = malloc(LINESIZE);
	tmp_search	= malloc(LINESIZE);
	orgEntered  = FALSE;
	tmp_org_found = FALSE;

	 printf(enter_country);

	 strcpy(username_save, username);

prompt_country:
	enterString(COUNTRY, co, clp);
	if (strlen(co) == 0) {
		if (!(strcmp(default_country, ""))) {
			 printf("%s %s %s\n", reenter_c, quit_String, to_quit);
			goto prompt_country;
		} else {
			 strcpy(co, default_country);
		}
	} else if (!(strcmp(co, quit_String))) {
		de_prompt_yesno(ask_ifout, confirm_out, no_string);
		if (!(strcmp(confirm_out, yes_string))) {
			de_exit(-1);
		} else {
			highNumber = 0;
			goto prompt_country;
		}
	}

	if (listCos(co, &clp) != OK) {
		 searchFail(co);
		 de_exit(-1);
	}
	noCos = listlen(clp);
	if (noCos <= 0) {
		 printf("%s `%s' \n\n", no_cMatch, co);
		goto prompt_country;
	} else if (noCos == 1) {
		 sprintf(posdit_user, "@%s", clp->name);
		str = copy_string(lastComponent(clp->name, COUNTRY));
		 strcpy(default_country, str);
		 sprintf(full_c, "%s -- %s", default_country, mapCoName(default_country));
		 printf("\n%s\n", full_c);
		for (at = clp->ats; at != NULLATTR; at = at->attr_link) {
			if (strcmp(attr2name(at->attr_type, OIDPART), "masterDSA") == 0) {
				quipuMastersCo = TRUE;
				break;
			}
		}
		highNumber = 0;
		pagerOn(NUMBER_NOT_ALLOWED);
	} else {
		 printf(got_match);
		 printf(type_number);
		pagerOn(NUMBER_ALLOWED);
		printListCos(clp);
		goto prompt_country;
	}
prompt_org:
	 printf("\n");
	enterString(ORG, org, olp);
	if (strlen(org) == 0) {
		if (!(strcmp(default_organisation, ""))) {
			if ((strcmp(org_compel, no_string))) {
				 printf("%s %s %s\n", enter_org, quit_String, to_quit);
				goto prompt_org;
			} else {
				goto prompt_person;
			}
		} else {
			 strcpy(org, default_organisation);
		}
	} else {
		if (!(strcmp(org, quit_String))) {
			de_prompt_yesno(ask_ifout, confirm_out, no_string);
			if (!(strcmp(confirm_out, yes_string))) {
				de_exit(-1);
			} else {
				highNumber = 0;
				pagerOn(NUMBER_NOT_ALLOWED);
				goto prompt_country;
			}
		}
	}
	if (listOrgs(posdit_user, org, &olp) != OK) {
		 searchFail(org);
		 de_exit(-1);
	}
	noOrgs = listlen(olp);
	if (noOrgs <= 0) {
		 printf("%s `%s' \n\n", no_orgMatch, org);
		if (!(strcmp(addorg, yes_string))) {
			 printf("%s   %s", srch_newOrg, please_wait);
			 fflush(stdout);
			 sprintf(save_addorg_posdit, "%s", addorg_posdit);
			 sprintf(addorg_posdit, "%s@%s", addorg_posdit, clp->name);
			if (listOrgs(addorg_posdit, org, &olp) != OK) {
				 printf("%s `%s'\n", unbl_newOrgC, full_c);
				 printf(cntct_hlpdsk);
				de_exit(-1);
			} else {
				 printf(done);
			}
			noOrgs = listlen(olp);
			if ( noOrgs <= 0 ) {
				 sprintf(addthisorg, "%s`%s'?", ask_ifaddorg, org);
				 printf("\n%s `%s' \n\n", no_orgMatch, org);
				de_prompt_yesno(addthisorg, add_org_ids, no_string);
				if (!(strcmp(add_org_ids, yes_string))) {
					displayFile("neworg_confirm", FALSE);
					 sprintf(posdit, "%s", addorg_posdit);
prompt_name_org:
					 sprintf(buffer, newOrgName1);
					 printf(buffer);
					 sprintf(buffer, "%s %s %s\n[%s]  : ", newOrgName2,
								   quit_String, to_quit, org);
					 printf(buffer);
					if (gets(cp) == NULLCP) {
						/* behave as for an interrupt */
						clearerr(stdin);
						onint1();
					}
					if (!(strcmp(cp, quit_String))) {
						de_exit(-1);
					} else if (strlen(cp) > 0) {
						 sprintf(org, "%s", cp);
						 printf("%s   ", check_notAlrIn);
						 fflush(stdout);
						 sprintf(addorg_posdit, "%s@%s", save_addorg_posdit, clp->name);
						if (listOrgs(addorg_posdit, org, &olp) != OK) {
							 printf("%s `%s'\n", unbl_newOrgC, full_c);
							 printf(cntct_hlpdsk);
							de_exit(-1);
						} else {
							 printf(done);
						}
						noOrgs = listlen(olp);
						if ( noOrgs <= 0 ) {
							/* Everything OK */
						} else {
							 printf("\n");
							printListOrgs(org, olp);
							de_prompt_yesno(ask_ifNotAlrIn, already_in, no_string);
							if (!strcmp(already_in, no_string)) {
								freeOrgs(&olp);
								goto prompt_org;
							}
						}
					}
					status = dm_Add_org();
					if (status != OK) {
						goto prompt_name_org;
					}
					tmp_org = TRUE;
					de_prompt_yesno(ask_ifaddent, add_entries, yes_string);
					if (!(strcmp(add_entries, yes_string))) {
						 sprintf(change_posdit, "%s", no_string);
						 sprintf(change_posdn, "%s", no_string);
						 sprintf(username, "%s@cn=%s", posdit, dir_Mngr);
						orgEntered = TRUE;
						return OK;
					} else {
						 displayFile("neworg_added", FALSE);
						 de_exit(-1);
					}
				} else {
					 sprintf(addorg_posdit, "%s", save_addorg_posdit);
					goto prompt_org;
				}
			} else if (noOrgs == 1) {
				str = copy_string(lastComponent(olp->name, ORG));
				 sprintf(default_organisation, str);
				 printf("\n%s\n", default_organisation);
				 sprintf(posdit_user, "%s", olp->name);
				 sprintf(org, "%s", str);
				orgEntered = TRUE;
				 sprintf(posdit, "%s", addorg_posdit);
				 sprintf(posdit, "%s@o=%s", posdit, str);
				 sprintf(change_posdit, "%s", no_string);
				 sprintf(change_posdn, "%s", no_string);
				 sprintf(search_mgr, "%s", yes_string);
				tmp_org = TRUE;
				 sprintf(add_entries, "%s", yes_string);
				highNumber = 0;
				pagerOn(NUMBER_NOT_ALLOWED);
				freeOrgs(&olp);
				tmp_org_found = TRUE;
				orgEntered = TRUE;
				goto prompt_person;
			} else {
				 printf(got_match);
				 printf(type_number);
				pagerOn(NUMBER_ALLOWED);
				printListOrgs(org, olp);
				goto prompt_org;
			}
		} else {
			goto prompt_org;
		}
	} else if (noOrgs == 1) {
		 sprintf(posdit_user, "@%s", olp->name);
		str = copy_string(lastComponent(olp->name, ORG));
		 sprintf(default_organisation, str);
		 printf("\n%s\n", default_organisation);
		orgEntered = TRUE;
		highNumber = 0;
		pagerOn(NUMBER_NOT_ALLOWED);
	} else {
		 printf(got_match);
		 printf(type_number);
		pagerOn(NUMBER_ALLOWED);
		printListOrgs(org, olp);
		goto prompt_org;
	}
	pagerOn(NUMBER_NOT_ALLOWED);

	if (!(strcmp(have_department, no_string))) {
		goto prompt_person;
	} else if ((strcmp(have_department, yes_string))) {
		 sprintf(ou, "%s", "*");
		if (listOUs(posdit_user, ou, &oulp) != OK) {
			 searchFail(ou);
			 de_exit(-1);
		}
		highNumber = 0;  /* disable entering a number, without displaying list */
		noOUs = listlen(oulp);
		if (noOUs <= 0) {
			goto prompt_person;
		} else {
			/*             sprintf(have_department, "%s", yes_string); */
			 sprintf(change_posdit, "%s", yes_string);
		}
	}
prompt_ou:
	 printf("\n");
	enterString(ORGUNIT, ou, oulp);
	if (strlen(ou) == 0) {
		if (!(strcmp(default_department, ""))) {
			goto prompt_person;
		} else {
			 strcpy(ou, default_department);
		}
	} else {
		if (!(strcmp(ou, quit_String))) {
			highNumber = 0;
			pagerOn(NUMBER_NOT_ALLOWED);
			goto prompt_country;
		}
	}
	if (listOUs(posdit_user, ou, &oulp) != OK) {
		 searchFail(ou);
		 de_exit(-1);
	}
	noOUs = listlen(oulp);
	if (noOUs <= 0) {
		 printf("%s `%s' \n\n", no_ouMatch, ou);
		goto prompt_ou;
	} else if (noOUs == 1) {
		 sprintf(posdit_user, "@%s", oulp->name);
		str = copy_string(lastComponent(oulp->name, ORGUNIT));
		 strcpy(default_department, str);
		 printf("\n%s\n", default_department);
		highNumber = 0;
		pagerOn(NUMBER_NOT_ALLOWED);
	} else {
		 printf(got_match);
		 printf(type_number);
		pagerOn(NUMBER_ALLOWED);
		printListOUs(ou, oulp);
		goto prompt_ou;
	}

prompt_person:
	/* Copy to posdit, if not defined */

	if (strlen(posdit) <= 0) {
		 sprintf(posdit, "%s", posdit_user);
		 determine_posdit(&objectType);
		posdit_oc = objectType;
	}
	if (!(strcmp(search_mgr, no_string))) {
		goto prompt_individual;
	}

	 sprintf(person, dir_Mngr);
	 sprintf(tmp_search, "%s@cn=%s", posdit_user,person);
	if (listExactPRRcn(tmp_search, &plp) != OK) {
		 searchFail(person);
		 de_exit(-1);
	}
	noPersons = listlen(plp);
	if (noPersons <= 0) {
		goto prompt_individual;
	} else if (noPersons == 1) {
		 sprintf(username, "@%s", plp->name);
		str = copy_string(lastComponent(plp->name, PERSON));
		free(confirm_out);
		free(full_c);
		free(str);
		highNumber = 0;
		if (!(strcmp(just_dn, yes_string))) {
			dn_file = fopen("/tmp/dn_user", "w");
			 fprintf(dn_file, username);
			 de_unbind();
			 fclose(dn_file);
			exit(0);
		}
		return OK;
	} else {
		 printf(got_match);
		 printf(type_number);
		pagerOn(NUMBER_ALLOWED);
		printListPRRs(person, plp, PERSON, FALSE);
		goto prompt_person;
	}


prompt_individual:
	enterString(USER, person, plp);
	if (strlen(person) == 0) {
		if (!(strcmp(default_person, ""))) {
			 printf("%s %s %s\n", enter_pName, quit_String, to_quit);
			goto prompt_individual;
		} else {
			 strcpy(person, default_person);
		}
	} else if (!(strcmp(person, quit_String))) {
		de_prompt_yesno(ask_ifout, confirm_out, no_string);
		if (!(strcmp(confirm_out, yes_string))) {
			de_exit(-1);
		} else {
			highNumber = 0;
			goto prompt_country;
		}
	}
	if (orgEntered == FALSE) {
		 sprintf(tmp_search, "%s@cn=%s", posdit_user,person);
		if (listExactPRRcn(tmp_search, &plp) != OK) {
			 searchFail(person);
			 de_exit(-1);
		}
	} else {
		if (listPRRs(posdit_user, person, &plp) != OK) {
			 searchFail(person);
			 de_exit(-1);
		}
	}
	noPersons = listlen(plp);
	if (noPersons <= 0) {
		 printf("%s `%s' \n\n", no_pMatch, person);
		goto prompt_individual;
	} else if (noPersons == 1) {
		 sprintf(username, "@%s", plp->name);
		str = copy_string(lastComponent(plp->name, PERSON));
		highNumber = 0;
		if (!(strcmp(just_dn, yes_string))) {
			dn_file = fopen("/tmp/dn_user", "w");
			 fprintf(dn_file, username);
			 de_unbind();
			 fclose(dn_file);
			 exit(0);
		}
	} else {
		 printf(got_match);
		 printf(type_number);
		pagerOn(NUMBER_ALLOWED);
		printListPRRs(person, plp, PERSON, FALSE);
		goto prompt_individual;
	}
	 printf(user_identified);
	 display_posdit(strlen(user_identified), username);
	free(confirm_out);
	free(full_c);
	free(str);
	free(already_in);
	return OK;
}
Пример #8
0
void AboutDialog::licenseButtonClicked()
{
    displayFile(QLatin1String(":LICENSE.GPL2"), tr("License"));
}
Пример #9
0
void AboutDialog::authorsButtonClicked()
{
    displayFile(QLatin1String(":AUTHORS"), tr("Authors"));
}
Пример #10
0
void AboutDialog::contributorsButtonClicked()
{
  displayFile(QLatin1String(":CONTRIBUTORS"), tr("Contributors"));
}
Пример #11
0
int main(void)
{    

    char strInput[20];    
    char *strCommand;
    char *Args1;
    char *Args2;
    char *space = " \t\r\n\a";

    int n;    

    printf("\n****************************************************************************************");     
    printf("\n********\t\t\tHello! Welcome to the C Shell!\t\t\t********");     
     printf("\n**************************************************************************************** \n\n");     
     do{
         printf("\nEnter a command: \n> ");
         //scanf("%s",strCommand);     
         fgets(strInput,sizeof(strInput),stdin);

        strCommand = strtok(strInput, space);
        Args1 = strtok(NULL, space);
        Args2 = strtok(NULL, space);

        /*
        printf("\nThe command you entered : >>%s<<", strCommand);
        printf("\nThe Args1 you entered : >>%s<<", Args1);
        printf("\nThe Args2 you entered : >>%s<<", Args2);

        if(strchr(Args1,'\n') != 0){
            //printf("\n>>>>> String has new line\n");
            strncpy(Args1,Args1,sizeof(Args1)-1);
            //printf("\nAfter StrCopy :  >%s<",Args1);
        }        
        
        printf("\nThe command evaluated : %s\n", strCommand);
        */
         if(strcmp(strCommand,TYPE_CMD) == 0){
            //Validate if the argument is passed
             displayFile(strCommand,Args1,Args2);
         }                 
         else{
             if(strcmp(strCommand,COPY_CMD) == 0){
                //Validate if both the argument are passed
                 copyFile(strCommand,Args1,Args2);                 
             }                 
             else {
                  if(strcmp(strCommand,DEL_CMD) == 0){
                    //Validate if the argument is passed
                     deleteFile(strCommand,Args1,Args2);                     
                  }                    
                  else{
                      if(strncmp(strCommand,EXIT_CMD,4) != 0){                        
                        //Validate if the argument is passed
                        launchApp(strCommand,Args1,Args2);                                            
                      }                          
                  }
             }
         } 



     }    while(strncmp(strCommand,EXIT_CMD,4) != 0);        


    printf("\n****************************************************************************************");     
    printf("\n********\t\t\t   Exiting the Shell!   \t\t\t********");     
     printf("\n**************************************************************************************** \n\n");     
    return 0;

}
Пример #12
0
/**
 * @brief MainWindow::MainWindow
 * @param parent
 */
MainWindow::MainWindow(HashCalcApplication* parent) : QMainWindow()
{
   setWindowTitle(tr("File Hash Calculator"));
   setAttribute(Qt::WA_DeleteOnClose, true);
   setWindowIcon(QIcon(":/mainicon.icns"));

   isOpeningNewProject = false;
   parentapp = parent;

   mainproject = new HashProject;
   filelist = mainproject->getDataTable();

   createActionButtonBox();
   createDirectoryBoxes();
   createOptionsBox();
   createWorkerThreads();
   createFileDisplayBox();

   statusBox = new StatusBoxWidget;

   filedrop = new FileDrop(filelist);
   connect(filedrop, SIGNAL(startProcessWork()), this, SLOT(startFileFinder()));
   connect(filedrop, SIGNAL(directoryDropped(QString)), mainproject->getSourceDirectory(), SLOT(setPath(QString)));

   QVBoxLayout* controlLayout = new QVBoxLayout;
   controlLayout->addWidget(sourceDirectoryBox);
   controlLayout->addWidget(verifyDirectoryBox);
   controlLayout->addWidget(optionsBox);
   controlLayout->addWidget(statusBox);
   controlLayout->addWidget(actionButtonBox);
   controlLayout->addWidget(filedrop);
   controlLayout->setAlignment(displayFileBox, Qt::AlignTop);
   controlLayout->setContentsMargins(0, 0, 0, 0);

   optionsBox->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
   actionButtonBox->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
   statusBox->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
   filedrop->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);

   controlWidgets = new QWidget;
   controlWidgets->setLayout(controlLayout);

   QVBoxLayout* rightLayout = new QVBoxLayout;
   rightLayout->addWidget(displayFileBox);
   rightLayout->addWidget(filelist);

   QWidget *rightWidget = new QWidget;
   rightLayout->setContentsMargins(0, 0, 0, 0);
   rightWidget->setLayout(rightLayout);

   mainWidget = new QSplitter(this);
   mainWidget->addWidget(controlWidgets);
   mainWidget->addWidget(rightWidget);
   mainWidget->setMinimumSize(1000, 750);
   mainWidget->setChildrenCollapsible(false);
   mainWidget->setCollapsible(0, false);
   mainWidget->setCollapsible(1, false);

   mainWidget->setStretchFactor(0, 0);
   mainWidget->setStretchFactor(1, 100);

   setCentralWidget(mainWidget);

   actions = new MenuActions(this);
   actions->createMenus();

   QSettings settings;
   algorithmComboBox->setCurrentText(settings.value("selectedalgorithm", "CRC32").toString());
   calcHashSumWhenFoundCheckbox->setChecked(settings.value("calchashsumwhenfound", false).toBool());
   if (!calcHashSumWhenFoundCheckbox->isChecked()) {
      hashCalculationOwnThreadCheckbox->setEnabled(false);
   }
   hashCalculationOwnThreadCheckbox->setChecked(settings.value("hashcalculationownthread", true).toBool());
   mainWidget->restoreState(settings.value("splittersizes").toByteArray());

   connect(filelist, SIGNAL(displayFile(QString,QString)), this, SLOT(updateFileDisplay(QString,QString)));
   connect(filelist, SIGNAL(fileListSizeChanged(int, int, int, int)), statusBox, SLOT(updateStatusBox(int, int, int, int)));
   connect(filelist, SIGNAL(fileListSizeChanged(int, int, int, int)), actions, SLOT(filelistChanged(int, int, int, int)));
}