Exemplo n.º 1
0
  TimeStats
  globalTimeStats (const Teuchos::RCP< MessengerBase< double > >& comm,
		   const TimeStats& localStats)
  {
    TimeStats globalStats;

    // Casting int to double is exact.
    const double localCount = static_cast<double> (localStats.count());

    // The counts on all MPI processes should be equal if we are going
    // to try to compare them.  We test for this by computing the min
    // and max counts (which should be equal) over all processes.
    const double minCount = comm->globalMin (localCount);
    const double maxCount = comm->globalMax (localCount);
    if (minCount != maxCount)
      throw std::logic_error ("Global stats don\'t make "
			      "sense, because counts differ");
    // minCount == maxCount, so we can use either one of them.  The
    // cast back from double is exact, because the double originally
    // came from an int.
    const int newCount = static_cast<int> (minCount);
      
    // Casting int to double is exact.
    const double P = static_cast<double> (comm->size());
    const double newMin = comm->globalMin (localStats.min());
    const double newMax = comm->globalMax (localStats.max());
    const double newMean = comm->globalSum (localStats.mean() / P);

    // Note that this is not the sum of the totals of all the
    // processes, but rather the "global total."  I've chosen to
    // define that as the max of the totals.
    const double newTotal = comm->globalMax (localStats.total());

    return TimeStats (newCount, newMin, newMax, newMean, newTotal);
  }
Exemplo n.º 2
0
Arquivo: menu.c Projeto: ftnapps/FTNd
void DoMenu(int Type)
{
    int	    Strlen, i, x;
    char    *sPrompt, *sPromptBak, *temp;

    sPrompt    = calloc(81, sizeof(char));
    sPromptBak = calloc(81, sizeof(char));
    temp       = calloc(81, sizeof(char));

    TimeCheck();

    switch(Type) {
	case 0: /* Display Prompt Line Only */
		break;

	case 1:
		/* Goto another menu */
		strncpy(Menus[MenuLevel], menus.OptionalData, 14);
		break;

	case 2:
		/* Gosub another menu */
		if (MenuLevel < 49) {
		    MenuLevel++;
		    strncpy(Menus[MenuLevel], menus.OptionalData, 14);
		} else
		    Syslog('?', "More than 50 menu levels");
		break;

	case 3:
		/* Return from gosub */
		if (MenuLevel > 0) 
		    MenuLevel--;
		break;

	case 4:
		/* Return to top menu */
		MenuLevel = 0;
		break;

	case 5:
		/* Display .a?? file with controlcodes */
		DisplayFile(menus.OptionalData);
		break;

	case 6:
		/* Show menu prompt */
		Strlen = strlen(menus.OptionalData);
		for (x = 0; x < Strlen; x++) {
		    if (menus.OptionalData[x] == '~') {
			strcat(sPrompt, sUserTimeleft);
		    } else {
			snprintf(temp, 81, "%c", menus.OptionalData[x]);
			strcat(sPrompt, temp);
		    }
		}
		strcpy(sPromptBak, sPrompt);
		strcpy(sPrompt, "");
		Strlen = strlen(sPromptBak);
		for (x = 0; x < Strlen; x++) {
		    if (*(sPromptBak + x) == '@')
			strcat(sPrompt, sAreaDesc);
		    else if (*(sPromptBak + x) == '^')
			strcat(sPrompt, sMsgAreaDesc);
		    else if (*(sPromptBak + x) == '#')
			snprintf(sPrompt, 81, "%s%s", sPrompt, (char *) GetLocalHM()); 
		    else {
			snprintf(temp, 81, "%c", *(sPromptBak + x));
			strcat(sPrompt, temp);
		    }
		}
		if (le_int(menus.ForeGnd) || le_int(menus.BackGnd))
		    pout(le_int(menus.ForeGnd), le_int(menus.BackGnd), sPrompt);
		else
		    pout(WHITE, BLACK, sPrompt);
		break;

	case 7:
		/* Run external program */
		if (strlen(menus.DoorName) && !menus.HideDoor) {
		    memset(temp, 0, sizeof(temp));
		    strcpy(temp, menus.DoorName);
		    ExtDoor(menus.OptionalData, menus.NoDoorsys, menus.Y2Kdoorsys, menus.Comport, 
			menus.NoSuid, menus.NoPrompt, menus.SingleUser, temp);
		} else {
		    ExtDoor(menus.OptionalData, menus.NoDoorsys, menus.Y2Kdoorsys, menus.Comport,
			menus.NoSuid, menus.NoPrompt, menus.SingleUser, NULL);
		}
		break;

	case 8:
		/* Show product information */
		cr();
		break;

	case 9:
		/* display todays callers */
		LastCallers(menus.OptionalData);
		break;

	case 10:
		/* display userlist */
		UserList(menus.OptionalData);
		break;

	case 11:
		/* display time statistics */
		TimeStats();
		break;

	case 12:
		/* page sysop for chat */
		Page_Sysop(menus.OptionalData);
		break;

	case 13:
		/* terminate call */
		free(sPrompt);
		free(sPromptBak);
		free(temp);
		Good_Bye(FTNERR_OK);
		break;

	case 14:
		/* make a log entry */
		LogEntry(menus.OptionalData);
		break;

	case 15:
		/* print text to screen */
		if (exitinfo.Security.level >= le_int(menus.MenuSecurity.level)) {
		    for (i = 0; i < strlen(menus.OptionalData); i++)
			if (*(menus.OptionalData + i) == '@')
			    *(menus.OptionalData + i) = '\n';
		    snprintf(temp, 81, "%s\r\n", menus.OptionalData);
		    PUTSTR(temp);
		}
		break;

	case 16:
		/* who's currently online */
		WhosOn(menus.OptionalData);
		Pause();
		break;

	case 17:
		/* comment to sysop */
		SysopComment((char *)"Comment to Sysop");
		break;

	case 18:
		/* send on-line message */
		SendOnlineMsg(menus.OptionalData);
		break;
		
	case 19:
		/* display Textfile with more */
		MoreFile(menus.OptionalData);
		break;

	case 20:
		/* display a?? file with controlcode and wait for enter */
		DisplayFileEnter(menus.OptionalData);
 		break;

	case 21:
		/* display menuline only */
		break;

	case 22:
		/* Chat with any user */
		Chat(NULL, NULL);
		break;

	case 101:
		FileArea_List(menus.OptionalData);
		break;

	case 102:
		File_List();
		break;

	case 103:
		ViewFile(NULL);
		break;

	case 104:
		Download();
		break;

	case 105:
		File_RawDir(menus.OptionalData);
		break;

	case 106:
		KeywordScan();
		break;

	case 107:
		FilenameScan();
		break;

	case 108:
		NewfileScan(TRUE);
		break;

	case 109:
		Upload();
		break;

	case 110:
		EditTaglist();
		break;

	case 111: /* View file in homedir */
		break;

	case 112:
		DownloadDirect(menus.OptionalData, TRUE);
		break;

	case 113:
		Copy_Home();
		break;

	case 114:
		List_Home();
		break;

	case 115:
		Delete_Home();
		break;

	/* 116 Unpack file in homedir */

	/* 117 Pack files in homedir */

	case 118:
		Download_Home();
		break;

	case 119:
		Upload_Home();
		break;

	case 201:
		MsgArea_List(menus.OptionalData);
		break;

	case 202:
		Post_Msg(); 
		break;

	case 203:
		Read_Msgs();
		break;

	case 204:
		CheckMail();
		break;

	case 205:
		QuickScan_Msgs();
		break;

	case 206:
		Delete_Msg();
		break;

	case 207:
		MailStatus();
		break;

	case 208:
		OLR_TagArea();
		break;

	case 209:
		OLR_UntagArea();
		break;

	case 210:
		OLR_ViewTags();
		break;

	case 211:
		OLR_RestrictDate();
		break;

	case 212:
		OLR_Upload();
		break;

	case 213:
		OLR_DownBW();
		break;

	case 214:
		OLR_DownQWK();
		break;

	case 215:
		OLR_DownASCII();
		break;

	case 216:
		Read_Email();
		break;

	case 217:
		Write_Email();
		break;

	case 218:
		Trash_Email();
		break;

	case 219:
		Choose_Mailbox(menus.OptionalData);
		break;

	case 220:
		QuickScan_Email();
		break;

	case 221:
		DisplayRules();
		break;

	case 301:
		Chg_Protocol();
		break;

	case 302:
		Chg_Password();
		break;

	case 303:
		Chg_Location();
		break;

	case 305:
		Chg_VoicePhone();
		break;

	case 306:
		Chg_DataPhone();
		break;

	case 307:
		Chg_News();
		break;

	case 309:
		Chg_DOB();
		break;

	case 310:
		Chg_Language(FALSE);
		break;

	case 311:
		Chg_Hotkeys();
		break;

	case 312:
		Chg_Handle();
		break;

	case 313:
		Chg_MailCheck();
		break;

	case 314:
		Chg_Disturb();
		break;

	case 315:
		Chg_FileCheck();
		break;

	case 316:
		Chg_FsMsged();
		break;

	case 317:
		Chg_FsMsgedKeys();
		break;

	case 318:
		Chg_Address();
		break;

	case 319:
		signature();
		break;

	case 320:
		Chg_OLR_ExtInfo();
		break;

	case 321:
		Chg_Charset();
		break;

	case 322:
		Chg_Archiver();
		break;

	case 401:
		Oneliner_Add();
		break;

	case 402:
		Oneliner_List();
		break;

	case 403:
		Oneliner_Show();
		break;

	case 404:
		Oneliner_Delete();
		break;

	case 405:
		Oneliner_Print();
		break;

	default:
		Enter(1);
		pout(WHITE, BLACK, (char *) Language(339));
		Enter(2);
		Syslog('?', "Option: %s -> Unknown Menu Type: %d on %s", menus.MenuKey, Type, Menus[MenuLevel]); 
		Pause();
	}

	free(sPrompt);
	free(sPromptBak);
	free(temp);
}