示例#1
0
void server() {
    // load Config File and Settings
    fprintf(stdout, "Starting fidistat Server...\n");
    openlog("fidistat-server", LOG_PID, LOG_DAEMON);
    syslog(LOG_INFO, "Started Fidistat Server");

    struct pidfh *pfh = daemon_start('s');

    // Handle Signals
    signal(SIGTERM, handleSigterm_S);
    signal(SIGCHLD, handleChild);

    // Open Socket
    initConf();
    tls_init();
    struct tls* ctx = tls_server();
    int sock = initTLS_S(ctx);
    sckt = sock;

    int connfd, pid;
    listen(sock, 10);

    // Destroy Config
    destroyConf(); 

    while(!term) {
        connfd = accept(sock, (struct sockaddr*) NULL, NULL); 

        if (term) {
            break;
        }
        pid = fork();
        if (pid < 0) {
            syslog(LOG_ERR, "forking new Worker failed");
        } else if (pid == 0) {
            close(sock);
            syslog(LOG_INFO, "New incoming connection");
            worker(connfd, ctx);
            syslog(LOG_INFO, "Closing connection");
            exit(0);
        } else {
            close(connfd);
        }
    }
    syslog(LOG_INFO, "Shutting down Server");
    close(sock);
    tls_close(ctx);
    tls_free(ctx);
    tls_config_free(tlsServer_conf);

    pidfile_remove(pfh);
    syslog(LOG_INFO, "Stopped Fidistat Server");
    closelog();
    exit(0);
}
示例#2
0
void PMN::fill_multi_config(const std::vector<int> &v, int v_ind, int from, std::list< std::vector<int> > elements){

	PMConfig initConf(configurations.back().back());

	bool used = false; //Whether or not we have used the first element
	int c_ind = v[v_ind]/2 - 1; //This is where in the configurations vector we find the order of v[v_ind]

	//Loop through all configurations of the given order. E.g. if v_ind is 4 (kappa^4), then c_ind is 1 and 
	//the for-loop loops over pmpm and ppmm
	for(int i=from; i < configurations[c_ind].size(); i++){

		auto send_set = elements;

		//If we choose the exact same element (both in terms of v_ind and i) we increment how many times
		//we have used that combination to later be able to calculate the combinatorial factor.
		if(send_set.empty()){
			send_set.emplace_back(std::vector<int>({v[v_ind],i,1}));
		}else if( (send_set.back()[0] == v[v_ind]) and (send_set.back()[1] == i) ){
			send_set.back()[2]++;
		}else{
			send_set.emplace_back(std::vector<int>({v[v_ind],i,1}));
		}

		//If we have used the first element, add another one
		if(used){
			configurations.back().emplace_back(initConf);
		}


		//The multiplication operator is overloaded so that it fills in the back if the right hand side
		//is shorter than the right hand side. It also updates the trace_points list
		configurations.back().back() *= configurations[c_ind][i];

		//If there are more elements, recurse
		if( (v_ind + 1) != v.size()){
			fill_multi_config(v,v_ind+1,i,send_set);
		}else{
			//Else, calculate the multiplicative factor from re-ordering. Which is #ofElements!/(product of all
			//individually equal elements!). The numerator is cancelled by the factorial from the series expansion of
			//the exponential.
			PM::pref_type pref_denom = 1;
			for(auto &c_list : send_set){
				pref_denom *= Utility::Factorial<PM::pref_type>(c_list[2]);
			}

			configurations.back().back() /= pref_denom;
		}

		used = true;
	}
}
示例#3
0
int PMN::fillAllConfigs(int from, int to, int left, std::vector<PMConfig> &conf, int counter){

	//First save the initial configuration to a temporary vector, as we will need it
	PMConfig initConf(conf[counter]);

	//If there is only one p left to place, place one at every possible location and return
	if(left == 1){
		for(int i=from; i<to; i++){

			if(i>from){
				conf[counter] = initConf;
			}
			
			conf[counter][i] = Cfg_P;
			counter++;
		}
	}else{
		for(int i=from; i<to; i++){

			if(i>from){
				conf[counter] = initConf;
			}

			conf[counter][i] = Cfg_P;
			
			//If there are more to place, place one and call itself. The to
			//argument is such that if you have 2 left to place, you cannot go
			//to the end of the array, only to the second last element (as there
			//must be room for the last p)
			counter = fillAllConfigs(i+1,to+1,left-1,conf,counter);
		}
	}

	return counter;

}
示例#4
0
void File_Create_TpConfig(Config_Struct* rev_config)
{
		int f;
		//char buf[BUFFERSIZE];
	
		Analogue_Config     analogue_conf;
		Switch_Config       switch_conf;
		Accumulate_Config   accumulate_conf;
		Tristate_Config     tristate_conf;
	
		initConf( &analogue_conf, &switch_conf, &accumulate_conf, &tristate_conf );
	
		f = yaffs_open( "/nand/config/TestpointConfig",  O_CREAT |O_RDWR | O_TRUNC, S_IREAD | S_IWRITE  );
		if ( f >= 0 )
		{
				printf("InfileCre: %u %u\n",rev_config->analogueConfig.testpointNo, rev_config->analogueConfig.sensorName );
	/*			
				File_Set_Config_Analogue( &f, &rev_config->analogueConfig );
				File_Set_Config_Switch( &f, &rev_config->switchConfig );
				File_Set_Config_Accumulate( &f, &rev_config->accumulateConfig );
				File_Set_Config_Tristate( &f, &rev_config->tristateConfig );
	*/		
				strcpy( analogue_conf.location, "淮北矿业集团袁店煤矿");
				File_Set_Config_Analogue( &f, &analogue_conf );
			strcpy( analogue_conf.location, "中船重工矿用装备实验室");
				File_Set_Config_Switch( &f, &switch_conf );
			strcpy( analogue_conf.location, "淮北矿业集团朱仙庄煤矿");
				File_Set_Config_Accumulate( &f, &accumulate_conf );
			strcpy( analogue_conf.location, "淮北创奇监测设备有限公司");
				File_Set_Config_Tristate( &f, &tristate_conf );
				
			/**********************************************************************
			*2014-09-04 刘帅修改,更改安装地点
			**********************************************************************/
			
			strcpy( analogue_conf.location, "四采区832工作面");
				File_Set_Config_Analogue( &f, &analogue_conf );
			strcpy(switch_conf.location,"南大巷机电洞室 ");
				File_Set_Config_Switch( &f, &switch_conf );
			strcpy(accumulate_conf.location,"二采区811掘进工作面");
				File_Set_Config_Accumulate( &f, &accumulate_conf );
				File_Set_Config_Tristate( &f, &tristate_conf );
				
			/**********************************************************************
			*2014-09-04 修改区结束
			**********************************************************************/	
				
				File_Set_Config_Analogue( &f, &analogue_conf );
				File_Set_Config_Switch( &f, &switch_conf );
				File_Set_Config_Accumulate( &f, &accumulate_conf );
				File_Set_Config_Tristate( &f, &tristate_conf );
				
				File_Set_Config_Analogue( &f, &analogue_conf );
				File_Set_Config_Switch( &f, &switch_conf );
				File_Set_Config_Accumulate( &f, &accumulate_conf );
				File_Set_Config_Tristate( &f, &tristate_conf );
			
				yaffs_close(f);
		}
		return;
}
示例#5
0
int main (int argc, char * argv[]) {
    char error[256];
    /* in and out fds are seen as from the clients view point */
    char * conffilename = "server.conf";
    struct actionParameters ap;
    struct serverActionParameters sap;
    union additionalActionParameters aap;
    const int numsems = 2;
    int opt, forkret,comret;
    struct signalfd_siginfo fdsi;
    ssize_t SRret;
    sigset_t mask;

#define EXIT_NO (EXIT_FAILURE * 2+3)
    char shellReturn = EXIT_NO;
    while ((opt = getopt(argc, argv, "ipc")) != -1) {
        switch (opt) {
        case 'c':
            conffilename = optarg;
            break;
        default: /*  '?' */
            print_usage(argv[0]);
            exit(EXIT_FAILURE);
        }
    }

    if ( optind == (argc-1) )
        conffilename = argv[optind];

    if ( initConf(conffilename, error) == -1 ) {
        fputs(error,stderr);
        exit(EXIT_FAILURE);
    }

    if (initap(&ap, error, numsems) == -1) {
        fputs(error,stderr);
        exit(EXIT_FAILURE);
    }
    initializeServerProtocol(&ap);

    if (initsap(&sap) == -1) {
        freeap(&ap);
        logmsg(ap.semid, ap.logfd, LOGLEVEL_FATAL, "%s.\n", error);
        exit(EXIT_FAILURE);
    }

    int sockfd;
    if ( (sockfd = createPassiveSocket(&(conf->port))) == -1) {
        freeap(&ap);
        freesap(&sap);
        logmsg(ap.semid, ap.logfd, LOGLEVEL_FATAL, "Error setting up network.\n");
        exit(EXIT_FAILURE);
    }

    struct pollfd pollfds[2];
    /* Setting up stuff for Polling */
    pollfds[0].fd = sockfd;    /* incoming new connections */
    pollfds[0].events = POLLIN;
    pollfds[0].revents = 0;
    pollfds[1].fd = ap.sigfd; /* communication with signalfd */
    pollfds[1].events = POLLIN;
    pollfds[1].revents = 0;

    /* Main Server Loop */
    while (1) {
        int pollret = poll(pollfds, 2, -1);

        if (pollret < 0 || pollret == 0) {
            if (errno == EINTR) continue; /* Signals */
            logmsg(ap.semid, ap.logfd, LOGLEVEL_FATAL, "Polling Error.\n");
            shellReturn = EXIT_FAILURE;
            break;
        }

        if(pollfds[0].revents & POLLIN) {    /* incoming client */
            logmsg(ap.semid, ap.logfd, LOGLEVEL_VERBOSE, "New client.\n");

            socklen_t iplen = sizeof (ap.comip);
            ap.comfd = accept( sockfd, &(ap.comip), &iplen );
            ap.comport = getPort(&ap.comip);

            switch ((forkret = fork())) {
            /* BUGBUG error handling? */
            case -1:
                close(ap.comfd);
                logmsg(ap.semid, ap.logfd, LOGLEVEL_FATAL,
                       "Error forking off a new client connection\n");
                shellReturn = EXIT_FAILURE;
                break;
            case 0: /* I'm in the child */
                close(sockfd);
                close(ap.sigfd);
                logmsg(ap.semid, ap.logfd, LOGLEVEL_WARN, "Child\n");
                /* fetch old mask, cf. initap!*/
                if (sigprocmask(0, NULL, &mask) ||
                        (ap.sigfd = getSigfd(&mask)) <= 0 ) {
                    fputs("error getting a new signal fd for the fork\n", stderr);
                    _exit(EXIT_FAILURE);
                } else {
                    aap.sap = &sap;
                    comret = comfork(&ap, &aap);
                    /* Do i need to do more */
                    _exit(comret);
                }
            default: /* Parent branch */
                logmsg(ap.semid, ap.logfd, LOGLEVEL_WARN, "Parent\n");
                close(ap.comfd);
            }
        } else if(pollfds[1].revents & POLLIN) { /* incoming signal */
            SRret = read(ap.sigfd, &fdsi, sizeof(struct signalfd_siginfo));
            if (SRret != sizeof(struct signalfd_siginfo)) {
                fprintf(stderr, "signalfd returned something broken");
                shellReturn = EXIT_FAILURE;
            }
            switch(fdsi.ssi_signo) {
            case SIGINT:
            case SIGQUIT:
                fprintf(stderr,"Yeah i found %s\n",
                        (fdsi.ssi_signo==SIGINT) ?"SIGINT": "SIGQUIT");
                shellReturn = EXIT_SUCCESS;
                break;
            case SIGCHLD:
                logmsg(ap.semid, ap.logfd, LOGLEVEL_VERBOSE,
                       "Child %d quit with status %d\n", fdsi.ssi_pid, fdsi.ssi_status);
                break;
            default:
                logmsg(ap.semid, ap.logfd, LOGLEVEL_WARN,
                       "Encountered unknown signal on sigfd %d", fdsi.ssi_signo);
            }
        } else { /* Somethings broken with poll */
            fprintf(stderr, "Dunno what to do with this poll");
            shellReturn = EXIT_FAILURE;
        }
        if (shellReturn !=EXIT_NO) break;
    }

    fputs("Closing down",stderr);
    close(sockfd);
    freeap(&ap);
    freesap(&sap);
    exit(shellReturn);
}
示例#6
0
void installWorker::process() {
    p = new QProcess(this);
    //p->setProcessChannelMode(QProcess::MergedChannels);
    connect(p, SIGNAL(finished(int)), this, SLOT(lastProcessFinished(int)));
    connect(p, SIGNAL(readyReadStandardOutput()), this, SLOT(outputAvaliable()));
    connect(p, SIGNAL(readyReadStandardError()), this, SLOT(errorAvaliable()));

    standardOutput.append("[theos_installer] Executing command umount /mnt\n");
    emit output(standardOutput);

    p->start("umount", QStringList() << "/mnt");
    p->waitForFinished(-1);

    if (parentWindow->formatPartition) {
        lastProcessDone = false;
        emit message("Formatting " + parentWindow->partition + "...");

        standardOutput.append("[theos_installer] Executing command mkfs -t ext4 -F -F " + parentWindow->partition);
        p->start("mkfs -t ext4 -F -F " + parentWindow->partition);
        if (!p->waitForStarted()) {
            standardOutput.append("[theos_installer] Error occurred executing command!\n");
        }

        p->waitForFinished(-1);
    }

    emit message("Mounting " + parentWindow->partition + "...");
    standardOutput.append("[theos_installer] Executing command mount " + parentWindow->partition + " /mnt\n");
    emit output(standardOutput);

    p->start("mount " + parentWindow->partition + " /mnt");
    p->waitForFinished(-1);

    if (QDir("/sys/firmware/efi").exists()) {
        standardOutput.append("This system is EFI, attempting to mount ESP onto /boot\n");
        emit output(standardOutput);

        QProcess* lsblk = new QProcess();
        lsblk->start("lsblk -r --output NAME,PARTTYPE");
        lsblk->waitForStarted(-1);
        lsblk->waitForFinished(-1);

        QString lsblkOutput(lsblk->readAllStandardOutput());

        for (QString partition : lsblkOutput.split("\n")) {
            if (partition.split(" ").count() != 1) {
                if (partition.split(" ").at(1).contains("C12A7328-F81F-11D2-BA4B-00A0C93EC93B", Qt::CaseInsensitive)) {
                    QDir("/mnt").mkdir("boot");

                    emit message("Mounting " + partition.split(" ").at(0) + "...");
                    standardOutput.append("[theos_installer] Executing command mount " + parentWindow->partition + " /mnt/boot\n");
                    emit output(standardOutput);


                    p->start("mount /dev/" + partition.split(" ").at(0) + " /mnt/boot");
                    p->waitForFinished(-1);
                    break;
                }
            }
        }


    }

    emit message("Downloading and copying new files...");
    standardOutput.append("[theos_installer] Executing command pacstrap /mnt base base-devel linux-headers\n");
    emit output(standardOutput);

    p->start("pacstrap /mnt base base-devel linux-headers");
    p->waitForFinished(-1);
    if (p->exitCode() != 0) {
        emit message("An error occurred. Inspect the output to see what happened.");
        emit failed();
        return;
    }

    emit message("Configuring system...");
    standardOutput.append("[theos_installer] Generating fstab...\n");
    emit output(standardOutput);
    QProcess *fstab = new QProcess(this);
    fstab->start("genfstab -p /mnt");
    fstab->waitForFinished();

    QFile fstabFile("/mnt/etc/fstab");
    fstabFile.open(QFile::WriteOnly);
    fstabFile.write(fstab->readAllStandardOutput());
    fstabFile.close();

    standardOutput.append("[theos_installer] Setting hostname...\n");

    while (parentWindow->hostname == "") {} //Stall until hostname is ready

    QFile hostnameFile("/mnt/etc/hostname");
    hostnameFile.open(QFile::WriteOnly);
    hostnameFile.write(parentWindow->hostname.toUtf8());
    hostnameFile.close();

    standardOutput.append("[theos_installer] Generating locales...\n");
    QFile::copy("/etc/locale.gen", "/mnt/etc/locale.gen");

    standardOutput.append("[theos_installer] Executing command arch-chroot /mnt locale-gen \n");
    emit output(standardOutput);

    p->start("arch-chroot /mnt locale-gen");
    p->waitForFinished(-1);


    standardOutput.append("[theos_installer] Executing command arch-chroot /mnt mkinitcpio -p linux\n");
    emit output(standardOutput);

    p->start("arch-chroot /mnt mkinitcpio -p linux");
    p->waitForFinished(-1);

    emit message("Downloading and installing bootloader...");


    standardOutput.append("[theos_installer] Executing command pacstrap /mnt os-prober grub\n");
    emit output(standardOutput);

    p->start("pacstrap /mnt os-prober efibootmgr grub");
    p->waitForFinished(-1);

    QString disk = parentWindow->partition;
    disk.chop(1);

    if (QDir("/sys/firmware/efi").exists()) {
        standardOutput.append("[theos_installer] Executing command arch-chroot /mnt grub-install --target=x86_64-efi --efi-directory=/boot/ --bootloader-id=grub\n");

        p->start("arch-chroot /mnt grub-install --target=x86_64-efi --efi-directory=/boot/ --bootloader-id=grub");
        p->waitForFinished(-1);
    } else {
        standardOutput.append("[theos_installer] Executing command arch-chroot /mnt grub-install --target=i386-pc " + disk + "\n");
        emit output(standardOutput);
        p->start("arch-chroot /mnt grub-install --target=i386-pc " + disk);
        p->waitForFinished(-1);
    }

    QFile grubDefault("/mnt/etc/default/grub");
    grubDefault.open(QFile::ReadOnly);
    QString grubDefaults(grubDefault.readAll());
    grubDefault.close();

    QStringList grubDefaultsArray = grubDefaults.split("\n");
    for (QString line : grubDefaultsArray) {
        if (line.startsWith("GRUB_CMDLINE_LINUX_DEFAULT")) {
            int index = grubDefaultsArray.indexOf(line);
            grubDefaultsArray.removeAt(index);
            grubDefaultsArray.insert(index, "GRUB_CMDLINE_LINUX_DEFAULT=\"quiet splash\"");
        }
    }

    grubDefaults = "";
    for (QString line : grubDefaultsArray) {
        grubDefaults.append(line + "\n");
    }
    p->waitForFinished(-1);

    grubDefault.open(QFile::WriteOnly);
    grubDefault.write(grubDefaults.toUtf8());
    grubDefault.close();

    standardOutput.append("[theos_installer] Executing command arch-chroot /mnt grub-mkconfig -o /boot/grub/grub.cfg\n");
    emit output(standardOutput);

    p->start("arch-chroot /mnt grub-mkconfig -o /boot/grub/grub.cfg");
    p->waitForFinished(-1);

    QFile grubConfig("/mnt/boot/grub/grub.cfg");
    grubConfig.open(QFile::ReadWrite);
    QString grubConfiguration(grubConfig.readAll());
    grubConfig.close();
    grubConfiguration = grubConfiguration.replace("Arch Linux", "theOS");
    grubConfig.open(QFile::ReadWrite);
    grubConfig.write(grubConfiguration.toUtf8());
    grubConfig.close();

    emit message("Downloading and installing new files...");
    standardOutput.append("[theos_installer] Installing additional packages...\n");
    emit output(standardOutput);

    p->start(QString("pacstrap /mnt xf86-video-vesa xf86-video-intel xf86-video-nouveau xf86-video-vmware kde-cli-tools kdesu")
             .append(" virtualbox-guest-utils xorg-server xorg-xinit xf86-input-synaptics lightdm breeze breeze-gtk breeze-icons")
             .append(" breeze-kde4 networkmanager gtk3 breeze-gtk chromium kinfocenter partitionmanager ntfs-3g")
             .append(" hfsprogs kate bluez bluedevil libreoffice-fresh hunspell hunspell-en kdegraphics-okular")
             .append(" ksuperkey kscreen user-manager kdeconnect gstreamer0.10 gstreamer0.10-bad gstreamer0.10-plugins")
             .append(" gstreamer0.10-base gstreamer0.10-base-plugins gstreamer0.10-ffmpeg gstreamer0.10-good")
             .append(" gstreamer0.10-good-plugins gstreamer0.10-ugly gstreamer0.10-ugly-plugins gst-plugins-good")
             .append(" gst-plugins-ugly kmail korganizer cups ark kcalc gwenview alsa-utils pulseaudio pulseaudio-alsa festival festival-english"));
    p->waitForFinished(-1);

    QDir localPackagesDir("/root/.packages/");
    QDirIterator *packageIterator = new QDirIterator(localPackagesDir);
    while (packageIterator->hasNext()) {
        QString packageName = packageIterator->next();
        QString packageToInstall = packageName;
        QString installLocation = "/mnt/var/cache/pacman/pkg/" + packageName.remove("/root/.packages/");
        if (!QFile::copy(packageToInstall, installLocation)) {
            standardOutput.append("[theos_installer] Error copying " + packageToInstall + " to " + installLocation);
            emit output(standardOutput);
        }
        p->start("arch-chroot /mnt pacman -U --noconfirm " + installLocation.remove(0, 4));
        p->waitForFinished(-1);
    }

    emit message("Configuring System...");
    standardOutput.append("[theos_installer] Configuring users...\n");

    QFile chfnDefault("/mnt/etc/login.defs");
    chfnDefault.open(QFile::ReadOnly);
    QString chfnDefaults(chfnDefault.readAll());
    chfnDefault.close();

    QStringList chfnDefaultsArray = chfnDefaults.split("\n");
    for (QString line : chfnDefaultsArray) {
        if (line.startsWith("CHFN_RESTRICT")) {
            int index = chfnDefaultsArray.indexOf(line);
            chfnDefaultsArray.removeAt(index);
            chfnDefaultsArray.insert(index, "CHFN_RESTRICT           frwh");
        }
    }

    chfnDefaults = "";
    for (QString line : chfnDefaultsArray) {
        chfnDefaults.append(line + "\n");
    }

    chfnDefault.open(QFile::WriteOnly);
    chfnDefault.write(chfnDefaults.toUtf8());
    chfnDefault.close();

    p->start("useradd -R /mnt -g wheel -M " + parentWindow->loginname);
    p->waitForFinished(-1);

    p->start("arch-chroot /mnt chfn -f \"" + parentWindow->fullname + "\" " + parentWindow->loginname);
    p->waitForFinished(-1);

    p->start("chpasswd -R /mnt");
    p->write(QString("root:" + parentWindow->password + "\n").toUtf8());
    p->write(QString(parentWindow->loginname + ":" + parentWindow->password + "\n").toUtf8());
    p->closeWriteChannel();
    p->waitForFinished(-1);

    QFile sudoersConfig("/mnt/etc/sudoers");
    sudoersConfig.open(QFile::ReadWrite);
    QString sudoersConfiguration(sudoersConfig.readAll());
    sudoersConfig.close();
    sudoersConfiguration = sudoersConfiguration.replace("# %wheel ALL=(ALL) ALL", "%wheel ALL=(ALL) ALL");
    sudoersConfig.open(QFile::ReadWrite);
    sudoersConfig.write(sudoersConfiguration.toUtf8());
    sudoersConfig.close();

    standardOutput.append("[theos_installer] Configuring services...\n");
    p->start("arch-chroot /mnt systemctl enable NetworkManager");
    p->waitForFinished(-1);
    p->start("arch-chroot /mnt systemctl enable bluetooth");
    p->waitForFinished(-1);
    p->start("arch-chroot /mnt systemctl enable lightdm");
    p->waitForFinished(-1);

    QFile lightdmConf("/mnt/etc/lightdm/lightdm.conf");
    lightdmConf.open(QFile::ReadOnly);
    QString lightdmDefaults(lightdmConf.readAll());
    lightdmConf.close();

    QStringList lightdmDefaultsArray = lightdmDefaults.split("\n");
    for (QString line : lightdmDefaultsArray) {
        if (line.startsWith("#greeter-session=")) {
            int index = lightdmDefaultsArray.indexOf(line);
            lightdmDefaultsArray.removeAt(index);
            lightdmDefaultsArray.insert(index, "greeter-session=lightdm-webkit2-greeter");
        }
    }

    lightdmDefaults = "";
    for (QString line : lightdmDefaultsArray) {
        lightdmDefaults.append(line + "\n");
    }

    lightdmConf.open(QFile::WriteOnly);
    lightdmConf.write(lightdmDefaults.toUtf8());
    lightdmConf.close();

    QFile lightdmWebkitConf("/mnt/etc/lightdm/lightdm-webkit2-greeter.conf");
    lightdmWebkitConf.open(QFile::WriteOnly);
    lightdmWebkitConf.write(QString("[greeter]\nwebkit-theme=contemporary\n").toUtf8());
    lightdmWebkitConf.close();

    QFile initConf("/mnt/etc/mkinitcpio.conf");
    initConf.open(QFile::ReadOnly);
    QString init(initConf.readAll());
    initConf.close();

    QStringList initArray = init.split("\n");
    for (QString line : initArray) {
        if (line.startsWith("HOOKS")) {
            int index = initArray.indexOf(line);
            initArray.removeAt(index);
            initArray.insert(index, "HOOKS=\"base udev plymouth autodetect modconf block filesystems keyboard fsck\"");
        } else if (line.startsWith("MODULES")) {
            int index = initArray.indexOf(line);
            initArray.removeAt(index);
            initArray.insert(index, "MODULES=\"i915\"");
        }
    }

    init = "";
    for (QString line : initArray) {
        init.append(line + "\n");
    }

    initConf.open(QFile::WriteOnly);
    initConf.write(init.toUtf8());
    initConf.close();

    QFile("/etc/os-release").copy("/mnt/etc/os-release");

    p->start("arch-chroot /mnt plymouth-set-default-theme theos --rebuild-initrd" );
    p->waitForFinished(-1);

    p->start("cp -r /root /mnt/home/" + parentWindow->loginname);
    p->waitForFinished(-1);
    p->start("arch-chroot /mnt chown -R " + parentWindow->loginname + " /home/" + parentWindow->loginname + "/ " );
    p->waitForFinished(-1);

    emit finished();
}
示例#7
0
int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
{

	RECT rect;
	int cc;
	wc.style = CS_OWNDC | CS_VREDRAW | CS_HREDRAW;
	wc.lpfnWndProc = WndProc;
	wc.cbClsExtra = wc.cbWndExtra = 0;
	wc.hInstance = 0;
	wc.hIcon = NULL;
	wc.hCursor = LoadCursor(0,IDC_ARROW);
	wc.hbrBackground = NULL;
	wc.lpszMenuName = NULL;
	wc.lpszClassName = "raytracer";
	if (!RegisterClass(&wc)) return FALSE;
	rect.left = rect.top = 0;
	rect.right = SCRWIDTH, rect.bottom = SCRHEIGHT;
	AdjustWindowRect( &rect, WS_POPUP|WS_SYSMENU|WS_CAPTION, 0 );
	rect.right -= rect.left, rect.bottom -= rect.top;
	wnd = CreateWindowEx( 0, "raytracer", "raytracer", WS_OVERLAPPEDWINDOW & ~WS_MAXIMIZEBOX & ~WS_THICKFRAME,
		CW_USEDEFAULT, CW_USEDEFAULT, rect.right, rect.bottom, 0, 0, 0, 0 );
	ShowWindow(wnd,SW_NORMAL);
	for ( cc = 0; cc < sizeof( BITMAPINFOHEADER ) + 16; cc++ ) bitmapbuffer[cc] = 0;
	bh = (BITMAPINFO *)&bitmapbuffer;
	bh->bmiHeader.biSize = sizeof( BITMAPINFOHEADER );
	bh->bmiHeader.biPlanes = 1;
	bh->bmiHeader.biBitCount = 32;
	bh->bmiHeader.biCompression = BI_BITFIELDS;
	bh->bmiHeader.biWidth = SCRWIDTH, bh->bmiHeader.biHeight = -SCRHEIGHT;
	((unsigned long*)bh->bmiColors)[0] = 255 << 16;
	((unsigned long*)bh->bmiColors)[1] = 255 << 8;
	((unsigned long*)bh->bmiColors)[2] = 255;
	window_hdc = GetDC(wnd);
	SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, 0, 0, 0);
	initConf(config);
	// prepare output canvas
	surface = new Surface(SCRWIDTH,SCRHEIGHT);
	buffer = surface->GetBuffer();
	surface->Clear(0);
	AllocConsole();   //Sortie Console
	freopen("CONOUT$","wb",stdout);


	clock_scene.begin(); // ---> start clock_scene

	// prepare renderer
	Scene* maScene = new Scene();
	maScene->chargerScene(config.filename);
	maScene->afficherScene();

	tracer = new Engine(config);
	tracer->SetScene(maScene);
	tracer->SetTarget(surface->GetBuffer(),SCRWIDTH, SCRHEIGHT );
	int tpos = 60;

	clock_scene.end(); // ---> end clock_scene		

	system("Pause");

	
		tracer->InitRender();
	clock_render.begin(); // ---> start clock_render
		tracer->Render(); //calcul de l'image
	clock_render.end(); // ---> end clock_render

	SaveImage("test.ppm",tracer->GetImage());
	
	SaveLogFile("Resultat.log",config);
	afficherClock();

	while (1)
	{
		DrawWindow();
	}

FreeConsole();  // Close the console window

	return 1;
}
示例#8
0
MainFrame::MainFrame(QWidget *parent) : QWidget(parent) {
  
  initLayout(QDir::currentPath() + "/" + "config.ini");
  initConf();
  initPortConnection();
}
示例#9
0
MainFrame::MainFrame(QString configfile, QWidget *parent) : QWidget(parent) {

    initLayout(configfile);
    initConf();
    initPortConnection();
}