MachineSelect::MachineSelect(QString pref, QWidget *parent) :
	QDialog(parent)
{
	this->setFixedSize(300,100);
	vLayout = new QVBoxLayout(this);
	hLayout = new QHBoxLayout();
	ok_pButton = new QPushButton("ok", this);
	cancel_pButton = new QPushButton("cancel", this);
	machineList_combo = new QComboBox();
	vLayout->addWidget(machineList_combo);
	vLayout->addStretch();
	vLayout->addLayout(hLayout);
	hLayout->addWidget(cancel_pButton);
	hLayout->addStretch();
	hLayout->addWidget(ok_pButton);
	QDir::setCurrent("MachineSettings");
	QStringList fileList = QDir::current().entryList();
	for(int i = 2; i < fileList.size(); i++) {
	machineList_combo->addItem(fileList.at(i));
	if(fileList.at(i) == pref)
		machineList_combo->setCurrentIndex(i);
	}
	if(fileList.contains(pref))
	machineList_combo->setCurrentIndex(fileList.indexOf(QRegExp(pref))-2);
	connect(ok_pButton, SIGNAL(clicked()), this, SLOT(okay()));
	connect(cancel_pButton, SIGNAL(clicked()), this, SLOT(cancel()));
}
Exemple #2
0
void pop3_user(char *arg)
{
  if (!*arg) { err_syntax(); return; }
  okay();
  seenuser = 1;
  if (!stralloc_copys(&username,arg)) die_nomem(); 
  if (!stralloc_0(&username)) die_nomem(); 
}
Exemple #3
0
static void
emmcio(int write, uchar *buf, int len)
{
	u32int *r;
	int i;

	r = (u32int*)EMMCREGS;
	assert((len&3) == 0);
	okay(1);
	if(waserror()){
		okay(0);
		nexterror();
	}
	if(write)
		dmastart(DmaChanEmmc, DmaDevEmmc, DmaM2D,
			buf, &r[Data], len);
	else
		dmastart(DmaChanEmmc, DmaDevEmmc, DmaD2M,
			&r[Data], buf, len);
	if(dmawait(DmaChanEmmc) < 0)
		error(Eio);
	if(!write)
		cachedinvse(buf, len);
	WR(Irpten, Datadone|Err);
	tsleep(&emmc.r, datadone, 0, 3000);
	WR(Irpten, 0);
	emmc.datadone = 0;
	i = r[Interrupt];
	if((i & Datadone) == 0){
		print("emmcio: %d timeout intr %ux stat %ux\n",
			write, i, r[Status]);
		WR(Interrupt, i);
		error(Eio);
	}
	if(i & Err){
		print("emmcio: %d error intr %ux stat %ux\n",
			write, r[Interrupt], r[Status]);
		WR(Interrupt, i);
		error(Eio);
	}
	if(i)
		WR(Interrupt, i);
	poperror();
	okay(0);
}
/* This code, on the other hand, should NOT cause a compiler error, since we gave an
 * explicit comparison function.
 */
static void customComparatorNoError() {
    struct Meh {};

    Map<Meh, int> okay([](const Meh&, const Meh&) {
        return true;
    });

    (void) okay;
}
Exemple #5
0
// class helpBrowser Constructor=================================================================================================
// Displays a simple dialog for browsing manual/index.html
helpBrowser::helpBrowser (QUrl helpUrl, QWidget *parent) : QDialog (parent)
{
    uiB.setupUi(this);
    //connect okay pushButton SLOTs ----------------
    connect ( uiB.button_ok, SIGNAL( clicked() ), this, SLOT( okay() ) );
    uiB.browser -> setOpenLinks(TRUE);
    uiB.browser -> setOpenExternalLinks(FALSE);
    uiB.browser -> setSource(helpUrl);
}
myOpenHierarchy::myOpenHierarchy(QWidget *parent)
{
	ui.setupUi(this); // this sets up GUI

	// signals/slots mechanism in action
	connect( ui.pushButton_ok, SIGNAL( clicked() ), this, SLOT( okay() ) );
	connect( ui.pushButton_hierarchy_browse, SIGNAL( clicked() ), this, SLOT( getPathHierarchy() ) );
	this->setWindowModality( Qt::ApplicationModal );
}
int TransactionsForm::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: okay(); break;
        default: ;
        }
        _id -= 1;
    }
    return _id;
}
Exemple #8
0
void
main(void)
{
	extern char edata[], end[];
	uint rev;

	okay(1);
	m = (Mach*)MACHADDR;
	memset(edata, 0, end - edata);	/* clear bss */
	machinit();
	mmuinit1();

	optionsinit("/boot/boot boot");
	quotefmtinstall();
	
	ataginit((Atag*)BOOTARGS);
	confinit();		/* figures out amount of memory */
	xinit();
	uartconsinit();
	screeninit();

	print("\nPlan 9 from Bell Labs\n");
	rev = getfirmware();
	print("firmware: rev %d\n", rev);
	if(rev < Minfirmrev){
		print("Sorry, firmware (start.elf) must be at least rev %d (%s)\n",
			Minfirmrev, Minfirmdate);
		for(;;)
			;
	}
	trapinit();
	clockinit();
	printinit();
	timersinit();
	cpuidprint();
	archreset();

	procinit0();
	initseg();
	links();
	chandevreset();			/* most devices are discovered here */
	pageinit();
	swapinit();
	userinit();
	gpiomeminit();
	schedinit();
	assert(0);			/* shouldn't have returned */
}
Exemple #9
0
static void
walkfrom(int x, int y)
{
	int q,a,dir;
	int dirs[4];

	levl[x][y].typ = ROOM;
	while(1) {
		q = 0;
		for(a = 0; a < 4; a++)
			if(okay(x,y,a)) dirs[q++]= a;
		if(!q) return;
		dir = dirs[rn2(q)];
		move(&x,&y,dir);
		levl[x][y].typ = ROOM;
		move(&x,&y,dir);
		walkfrom(x,y);
	}
}
Exemple #10
0
Fichier : 1012.c Projet : bopie/ACM
int main()
{
	int i, j, k, table[13], flag;

	for (i = 1; i < 14; i++) {
		flag = 0;
		for (j = i + 1; ; j += 2 * i) {
			for (k = 0; k < i; k++) {
				if (okay(i, j + k)) {
					table[i - 1] = j + k;
					flag = 1;
				}
			}
			if (flag == 1)
				break;
		}
	}
	while (scanf("%d", &k), k)
		printf("%d\n", table[k - 1]);

	return 0;
}
Exemple #11
0
/*
    Returns the recommended indent for the bottom line of program.
    Unless null, typedIn stores the character of yyProgram that
    triggered reindentation.

    This function works better if typedIn is set properly; it is
    slightly more conservative if typedIn is completely wild, and
    slighly more liberal if typedIn is always null. The user might be
    annoyed by the liberal behavior.
*/
int indentForBottomLine( const QStringList& program, QChar typedIn )
{
    if ( program.isEmpty() )
        return 0;

    initializeIndenter();

    yyProgram = new QStringList( program );
    startLinizer();

    const QString& bottomLine = program.last();
    QChar firstCh = firstNonWhiteSpace( bottomLine );
    int indent;

    if ( bottomLineStartsInCComment() ) {
        /*
            The bottom line starts in a C-style comment. Indent it
            smartly, unless the user has already played around with it,
            in which case it's better to leave her stuff alone.
        */
        if ( isOnlyWhiteSpace(bottomLine) ) {
            indent = indentWhenBottomLineStartsInCComment();
        } else {
            indent = indentOfLine( bottomLine );
        }
    } else if ( okay(typedIn, '#') && firstCh == QChar('#') ) {
        /*
            Preprocessor directives go flush left.
        */
        indent = 0;
    } else {
        if ( isUnfinishedLine() ) {
            indent = indentForContinuationLine();
        } else {
            indent = indentForStandaloneLine();
        }

        if ( okay(typedIn, '}') && firstCh == QChar('}') ) {
            /*
                A closing brace is one level more to the left than the
                code it follows.
            */
            indent -= ppIndentSize;
        } else if ( okay(typedIn, ':') ) {
            QRegExp caseLabel(
                "\\s*(?:case\\b(?:[^:]|::)+"
                "|(?:public|protected|private|signals|default)(?:\\s+slots)?\\s*"
                ")?:.*" );

            if ( caseLabel.exactMatch(bottomLine) ) {
                /*
                    Move a case label (or the ':' in front of a
                    constructor initialization list) one level to the
                    left, but only if the user did not play around with
                    it yet. Some users have exotic tastes in the
                    matter, and most users probably are not patient
                    enough to wait for the final ':' to format their
                    code properly.

                    We don't attempt the same for goto labels, as the
                    user is probably the middle of "foo::bar". (Who
                    uses goto, anyway?)
                */
                if ( indentOfLine(bottomLine) <= indent )
                    indent -= ppIndentSize;
                else
                    indent = indentOfLine( bottomLine );
            }
        }
    }
    delete yyProgram;
    terminateIndenter();
    return qMax( 0, indent );
}
Exemple #12
0
int main ( int argc , char *argv[] )
{
	int now , a , b , c , d ;
	struct stat sb_dir ;
	struct stat sb_file ;
	char *filename , *ip1 , *ip2 , *ip3 , *ip4 ;
	char ipbuf[16] ;

	read_env() ;

	if ( JGREYLIST_LOG_PID )
		snprintf ( title , 31 , "jgreylist[%d]: " , getpid() ) ;

	/***************************************
	* make sure we have a command to run
	*  if we decide to allow the connection
	*/

	if ( argc < 2 )
		die ( "no command specified on command line" ) ;

	/***************************************
	* make sure we have an IP address to check
	*/

	if ( ! ( TCPREMOTEIP && *TCPREMOTEIP ) )
		die ( "TCPREMOTEIP is empty or missing" ) ;

	/***************************************
	* if JGREYLIST is set, either approve or deny automatically
	*/

	if ( JGREYLIST )
	{
		if ( *JGREYLIST )
		{
			if ( JGREYLIST_LOG )
				logit2 ( TCPREMOTEIP , ": DENY blacklisted" ) ;
			fake ( 0 , JGREYLIST ) ;
		}
		if ( JGREYLIST_LOG )
			logit2 ( TCPREMOTEIP , ": OK whitelisted" ) ;
		okay ( argc , argv ) ;
	}

	if ( JGREYLIST_NOREV && *JGREYLIST_NOREV )
		if ( ! ( TCPREMOTEHOST && *TCPREMOTEHOST ) )
		{
			if ( JGREYLIST_LOG )
				logit2 ( TCPREMOTEIP , ": DENY no reverse DNS" ) ;
			fake ( 0 , JGREYLIST_NOREV ) ;
		}

	/***************************************
	* make sure the JGREYLIST_DIR directory exists and is writable
	*/

	if ( ! ( JGREYLIST_DIR && *JGREYLIST_DIR ) )	/* defined */
		die ( "JGREYLIST_DIR is not set" ) ;

	if ( stat ( JGREYLIST_DIR , &sb_dir ) )		/* exists */
		pdie ( JGREYLIST_DIR ) ;

	if ( ! ( sb_dir.st_mode & S_IFDIR ) )		/* is a directory */
		die2 ( JGREYLIST_DIR , " is not a directory" ) ;

	if ( access ( JGREYLIST_DIR , R_OK | W_OK | X_OK ) )
		pdie ( JGREYLIST_DIR ) ;

	/***************************************
	* copy the IP, break it into four separate segments
	*/

	strncpy ( ipbuf , TCPREMOTEIP , 16 ) ;
	ipbuf[15] = '\0' ; /* just in case */
	ip1 = ip2 = ipbuf ;
	while ( *ip2 && *ip2 != '.' ) ip2++ ;
	if ( *ip2 ) *ip2++ = '\0' ;
	ip3 = ip2 ;
	while ( *ip3 && *ip3 != '.' ) ip3++ ;
	if ( *ip3 ) *ip3++ = '\0' ;
	ip4 = ip3 ;
	while ( *ip4 && *ip4 != '.' ) ip4++ ;
	if ( *ip4 ) *ip4++ = '\0' ;

	/***************************************
	* change "1.2.3.4" to "001.002.003.004"
	*/

	a = atoi ( ip1 ) ;
	b = atoi ( ip2 ) ;
	c = atoi ( ip3 ) ;
	d = atoi ( ip4 ) ;

	snprintf ( ipbuf , 16 , "%03d.%03d.%03d.%03d" , a , b , c , d ) ;

	/***************************************
	* break it into separate strings for each octet
	*/

	ipbuf[3] = ipbuf[7] = ipbuf[11] = '\0' ;
	ip2 = &(ipbuf[4]) ;
	ip3 = &(ipbuf[8]) ;
	ip4 = &(ipbuf[12]) ;

	/***************************************
	* walk into the directory structure, creating directories as we go.
	* then reassemble the portions of the IP address which will become
	* the actual filename within the directory, and build the final
	* filename whose timestamps we need.
	*/

	filename = malloc ( strlen ( JGREYLIST_DIR ) + 32 ) ;
	if ( ! filename )
		die ( "out of memory" ) ;

	strcpy ( filename , JGREYLIST_DIR ) ;
	strcat ( filename , "/" ) ;
	strcat ( filename , ip1 ) ;
	if ( mkdir ( filename , 0700 ) && errno != EEXIST )
		pdie ( filename ) ;
	strcat ( filename , "/" ) ;
	strcat ( filename , ip2 ) ;
	if ( mkdir ( filename , 0700 ) && errno != EEXIST )
		pdie ( filename ) ;
	strcat ( filename , "/" ) ;
	strcat ( filename , ip3 ) ;

	if ( JGREYLIST_BY_IP )
	{
		if ( mkdir ( filename , 0700 ) && errno != EEXIST )
			pdie ( filename ) ;
		strcat ( filename , "/" ) ;
		strcat ( filename , ip4 ) ;
	}

	/***************************************
	* try to get the file's timestamps
	* if not exist, create it and fake conversation first time
	* if other error, die
	*/

	if ( stat ( filename , &sb_file ) )
	{
		if ( errno == ENOENT )
		{
			if ( JGREYLIST_LOG )
				logit2 ( TCPREMOTEIP , ": GREY first time" ) ;
			file_create ( filename ) ;
			fake ( 1 , GREY1 ) ;
		}
		pdie ( filename ) ;
	}

	/***************************************
	* is it too soon to let them in?
	*/

	now = time ( 0 ) ;

	if ( ( sb_file.st_mtime + JGREYLIST_HOLDTIME ) > now )
	{
		if ( JGREYLIST_LOG )
			if ( JGREYLIST_LOG )
				logit2 ( TCPREMOTEIP , ": GREY too soon" ) ;
		file_touch ( filename , now ) ;
		fake ( 2 , GREY2 ) ;
	}

	/***************************************
	* they're okay
	*/

	if ( JGREYLIST_LOG )
		logit2 ( TCPREMOTEIP , ": OK known" ) ;
	file_touch ( filename , now ) ;
	okay ( argc , argv ) ;

	return 0 ;
}
Exemple #13
0
int
main(int ac, char *av[])
{
	int r, sd, portnum, l;
        struct sockaddr_in sin;
	int errflg = 0;

	int nfd;
	fd_set rds;

	ssize_t nr;

	char *dumpf, buf[BUFMAX];

	pcap_t *p;
	pcap_dumper_t *dp;
	struct pcap_pkthdr phd;

	prog = av[0];

	while ((r = getopt(ac, av, "drb:p:P:")) != -1) {
		switch (r) {
		case 'd':
			debug++;
			break;
		case 'r':
			reflect++;
			break;
		case 'b':
			maxbytes = (ssize_t) atol(optarg);
			break;
		case 'p':
			maxpkts = (ssize_t) atoi(optarg);
			break;
		case 'P':
			strcpy(pidfile, optarg);
			break;
		case '?':
		default:
			errflg++;
			break;
		}
	}

	if ((ac - optind) != 2 || errflg)
		usage();

	portnum = atoi(av[optind++]);
	dumpf = av[optind];

if (debug) fprintf(stderr, "bind to %d.\ndump to '%s'.\n", portnum, dumpf);

	if ((r = socket(PF_INET, SOCK_RAW, IPPROTO_DIVERT)) == -1) {
		perror("socket(DIVERT)");
		exit(2);
	}
	sd = r;

	sin.sin_port = htons(portnum);
	sin.sin_family = AF_INET;
	sin.sin_addr.s_addr = INADDR_ANY;

	if (bind(sd, (struct sockaddr *)&sin, sizeof(sin)) == -1) {
		perror("bind(divert)");
		exit(3);
	}

	p = pcap_open_dead(DLT_RAW, BUFMAX);
	dp = pcap_dump_open(p, dumpf);
	if (dp == NULL) {
		pcap_perror(p, dumpf);
		exit(4);
	}

	okay(portnum);

	nfd = sd + 1;
	for (;;) {
		FD_ZERO(&rds);
		FD_SET(sd, &rds);

		r = select(nfd, &rds, NULL, NULL, NULL);
		if (r == -1) {
			if (errno == EINTR) continue;
			perror("select");
			quit(11);
		}

		if (!FD_ISSET(sd, &rds))
			/* hmm. no work. */
			continue;

		/*
		 * use recvfrom(3 and sendto(3) as in natd(8).
		 * see /usr/src/sbin/natd/natd.c
		 * see ipfw(8) about using 'divert' and 'tee'.
		 */

		/*
		 * read packet.
		 */
		l = sizeof(sin);
		nr = recvfrom(sd, buf, sizeof(buf), 0, (struct sockaddr *)&sin, &l);
if (debug) fprintf(stderr, "recvfrom(%d) = %zd (%d)\n", sd, nr, l);
		if (nr < 0 && errno != EINTR) {
			perror("recvfrom(sd)");
			quit(12);
		}
		if (nr <= 0) continue;

		if (reflect) {
			/*
			 * write packet back so it can continue
			 * being processed by any further IPFW rules.
			 */
			l = sizeof(sin);
			r = sendto(sd, buf, nr, 0, (struct sockaddr *)&sin, l);
if (debug) fprintf(stderr, "  sendto(%d) = %d\n", sd, r);
			if (r < 0) { perror("sendto(sd)"); quit(13); }
		}

		/*
		 * check maximums, if any.
		 * but don't quit if must continue reflecting packets.
		 */
		if (maxpkts) {
			totpkts++;
			if (totpkts > maxpkts) {
				if (reflect == 1) continue;
				quit(0);
			}
		}
		if (maxbytes) {
			totbytes += nr;
			if (totbytes > maxbytes) {
				if (reflect == 1) continue;
				quit(0);
			}
		}

		/*
		 * save packet in tcpdump(1) format. see pcap(3).
		 * divert packets are fully assembled. see ipfw(8).
		 */
		(void) gettimeofday(&(phd.ts), NULL);
		phd.caplen = phd.len = nr;
		pcap_dump((u_char *)dp, &phd, buf);
		if (ferror((FILE *)dp)) { perror(dumpf); quit(14); }
		(void) fflush((FILE *)dp);
	}

	quit(0);
}
Exemple #14
0
void pop3_quit(void) { okay(); die(); }