Ejemplo n.º 1
0
int
__cdecl
vfprintf_s(FILE* file, const char *format, va_list argptr)
{
    int result;

    if(!MSVCRT_CHECK_PMT(format != NULL)) {
        _set_errno(EINVAL);
        return -1;
    }

    _lock_file(file);
    result = streamout(file, format, argptr);
    _unlock_file(file);

    return result;
}
Ejemplo n.º 2
0
void PyXPCOM_LogError(const char *fmt, ...)
{
	va_list marker;
	va_start(marker, fmt);
	// NOTE: It is tricky to use logger.exception here - the exception
	// state when called back from the C code is clear.  Only Python 2.4
	// and later allows an explicit exc_info tuple().

	// Don't use VLogF here, instead arrange for exception info and
	// traceback to be in the same buffer.
	char buff[512];
	PR_vsnprintf(buff, sizeof(buff), fmt, marker);
	// If we have a Python exception, also log that:
	nsCAutoString streamout(buff);
	if (PyXPCOM_FormatCurrentException(streamout)) {
		LogMessage(LOGGER_ERROR, streamout);
	}
    va_end(marker);
}
Ejemplo n.º 3
0
int main(int argc,char ** argv)
{

  TApplication application("app",&argc,argv);

  Signals::SignalSet signals("Meine Signale");
  Signals::Signal a(3.125);
  Signals::Signal b(3.125);
  a.SetSignalLength(200);
  b.SetSignalLength(200);
  a.CreateHeaviside(100,-1,1);
  b.CreateHeaviside(150,-2,2);

  unsigned int index=signals.SetSignal(-1,"signal",a);
  signals.SetSignal(index,"b",b);

  Tools::ASCIIOutStream streamout("test.sig");
  streamout<<signals;
  
  Tools::ASCIIInStream streamin("test.sig");
  Signals::SignalSet sigtest("Test");
  streamin>>sigtest;
  Signals::Signal& ra=sigtest.GetSignal(0,"signal");
  Signals::Signal& rb=sigtest.GetSignal(0,"b");

  TCanvas * canvas1=new TCanvas;
  a.Graph()->Draw("AL*");
  canvas1->Update();

  TCanvas * canvas2=new TCanvas;
  b.Graph()->Draw("AL*");
  canvas2->Update();

  application.Run(kTRUE);

  return 0;
}
Ejemplo n.º 4
0
/* Write AT MOSt size bytes */
int vsnprintf(char *str, size_t size, const char *format, va_list ap)
{
	int result;
	result = streamout(&str, size, format, ap);
	return result;
}
Ejemplo n.º 5
0
void TSC_value::streamout_withtype(QBinTagWriter &writer)
{
	if ((datatype==NULL)||(content==NULL)) throw QError(_text("Undefined value"));
	writer.write_shortstring(datatype->G_name());
	streamout(writer);
}
Ejemplo n.º 6
0
void NetworkInterface::wifiQuickConnect(QString SSID, QString netKey, QString DeviceName, bool WEPHex){
  /* 
     This function uses a set of defaults to connect to a wifi access point with a minimum
     of information from the user. It does *NOT* (currently) support the WPA-Enterprise encryption
  */
  
    //do nothing if no SSID given
    if( SSID.isEmpty() ){
      return;
    }
  
    QString tmp;
    QString ifConfigLine;
    
    //Set defaults for quick-connect
    ifConfigLine="DHCP"; //Use DHCP

    // Check if we need to enable the device config in rc.conf
    if ( Utils::getConfFileValue("/etc/rc.conf", "ifconfig_" + DeviceName).isEmpty()) {
      Utils::setConfFileValue( "/etc/rc.conf", "ifconfig_lagg0", "", -1);
      Utils::setConfFileValue( "/etc/rc.conf", "ifconfig_" + DeviceName, \
        "ifconfig_" + DeviceName + "=\"WPA " + ifConfigLine + "\"", -1);
    }

	
    //Determine if the wpa_supplicant file exists already or is empty
    bool newWPASup = true;
    bool existingSSID = false;
    QStringList tmpFileList;
    QString tmpEntry;
    QFile fileout( "/etc/wpa_supplicant.conf" );
    if( fileout.open( QIODevice::ReadOnly ) ){
      QTextStream streamtmp(&fileout);
      streamtmp.setCodec("UTF-8");
        QString line;
        bool inEntry = false;
        bool eStart, eEnd;
        while ( !streamtmp.atEnd() ) {
            eStart = false; 
            eEnd = false;	
            line = streamtmp.readLine();
	    if ( line.contains("ctrl_interface=/var/run/wpa_supplicant") ) {
   		newWPASup = false;
	    }else if(line.contains("ssid=") && line.contains(SSID)){
	    	existingSSID=true;
	    }else if(line.contains("network={")){eStart = true;}
	    else if(line.contains("}")){eEnd = true; }
	    
	    //Save the file by entry temporarily
	    if(eStart){ tmpEntry = line; inEntry = true; }
	    else if(eEnd){ tmpEntry.append(" ::: "+line); tmpFileList << tmpEntry; inEntry=false; }	    
	    else if(inEntry){ tmpEntry.append(" ::: "+line); }
	    else{ tmpFileList << line; }
	}
	fileout.close();
    }
    //If the desired SSID already has an entry, remove it from wpa_supplicant.conf
    if(existingSSID){
      QFile tmpFile( "/etc/wpa_supplicant.conf.tmp" );
      if(tmpFile.open(QIODevice::WriteOnly | QIODevice::Text )){
        QTextStream oStr(&tmpFile);
        for(int i=0; i<tmpFileList.length(); i++){
          if(tmpFileList[i].contains("network={")){
            QStringList tmp = tmpFileList[i].split(" ::: ");
            //skip it if the new SSID
	    int idx = tmp.indexOf("ssid=");
            if( (idx!= -1) && !tmp[idx].contains(SSID) ){
              for(int j=0; j<tmp.length(); j++){
            	oStr << tmp[j] + "\n";    	    
              }
            }
          }else{
            oStr << tmpFileList[i] + "\n";	  
          }			
        }
      }
      tmpFile.close();
      Utils::runShellCommand("mv /etc/wpa_supplicant.conf.tmp /etc/wpa_supplicant.conf");
    }
    
    // Create the wpa_supplicant file based on saved configuration    
    if ( fileout.open( QIODevice::Append ) ) {
       QTextStream streamout( &fileout );

       // Fix to prevent kernel panic
       if(newWPASup)
	   streamout << "ctrl_interface=/var/run/wpa_supplicant\n\n";
       //Use SSID for network connection
       streamout << "\nnetwork={\n ssid=\"" + SSID + "\"\n";
       streamout << " priority=" << 146 << "\n";
       streamout << " scan_ssid=1\n";

       //Determine the security type for the given SSID
       QString SecType = getWifiSecurity(SSID,DeviceName);
       
       //Configure the wifi Security Settings for the proper type
       if ( SecType.contains("None") ){
          streamout << " key_mgmt=NONE\n";
	  
       } else if ( SecType.contains("WEP") ) {
	  //Set WEP Defaults
	  int WEPIndex = 0;
          //bool WEPHex = true; //Use Hex WEP key
          streamout << " key_mgmt=NONE\n";
          streamout << " wep_tx_keyidx=" + tmp.setNum(WEPIndex) + "\n";
          // Check if we are using a plaintext WEP or not
          if ( WEPHex ) {
            streamout << " wep_key" + tmp.setNum(WEPIndex) + "=" + netKey + "\n";
          } else {
            streamout << " wep_key" + tmp.setNum(WEPIndex) + "=\"" + netKey + "\"\n";
          }

       } else if ( SecType.contains("WPA") ) {
          streamout << " psk=\"" + netKey + "\"\n";	
       } 

       streamout << "}\n\n";

       fileout.close();
     } 

    // Flush to disk, so that when we restart network it picks up the changes
    sync();

    Utils::restartNetworking();
   
   return;
}
void spatialRobocodeCreatureMvP::saveCreature(ofstream &fout)
{
	streamout(fout,critter);
}
void spatialRobocodeCreatureDelta::saveCreature(ofstream &fout)
{
	streamout(fout,critter,geneticAge);
}
void spatialRobocodeParasiteDelta::saveParasite(ofstream &fout)
{
	streamout(fout,ParasiteDelta,geneticAge);
}
void spatialRobocodeParasite::saveParasite(ofstream &fout)
{
	streamout(fout,parasite);
}
Ejemplo n.º 11
0
bool MainWindow::setConfFileValue( QString oFile, QString oldKey, QString newKey, int occur )
{
    	// Lets the dev save a value into a specified config file. 
	// The occur value tells which occurance of "oldKey" to replace
    	// If occur is set to -1, it will remove any duplicates of "oldKey"
    
	//copy the original file to create a temporary file for editing
	QString oFileTmp = oFile + ".tmp";
	QString cmd = "cp "+oFile+" "+oFileTmp;
	runShellCommand(cmd);
	
	//Continue evaluating the temporary file
    	QStringList SavedFile;
    	int found = 1;

    	// Load the old file, find the oldKey, remove it and replace with newKey
    	QFile file( oFileTmp );
	if ( ! file.open( QIODevice::ReadOnly ) )
		return false;

        QTextStream stream( &file );
        QString line;
        while ( !stream.atEnd() ) {
        	line = stream.readLine(); // line of text excluding '\n'
            
		// Key is not found at all
		if ( line.indexOf(oldKey, 0) == -1 ) {
	        	SavedFile << line ;
			continue;
		}

		// Found the key, but it is commented out, so don't worry about this line
		if ( line.trimmed().indexOf("#", 0) == 0 ) {
	         	SavedFile << line ;
			continue;
		}

		// If the KEY is found, and we are just on wrong occurance, save it and continue to search  
		if ( occur != -1 && found != occur ) {
	         	SavedFile << line ;
			found++;
			continue;
		}

            	// If the KEY is found in the line and this matches the occurance that must be processed
            	if ( ! newKey.isEmpty() && found == occur )
           	{
	         	SavedFile << newKey ;
			newKey.clear();
	    		found++;
			continue;
            	} 

             	// If the KEY is found and we just want one occurance of the key
            	if ( occur == -1 && ! newKey.isEmpty() ) {
	         	SavedFile << newKey ;
			newKey.clear();
			found++;	
			continue;
		}

        }

   	file.close();

	// Didn't find the key? Write it!
	if ( ! newKey.isEmpty() )
	    SavedFile << newKey;
	
    
    	// Save the new file
    	QFile fileout( oFileTmp );
    	if ( ! fileout.open( QIODevice::WriteOnly ) )
		return false;

  	QTextStream streamout( &fileout );
	for (int i = 0; i < SavedFile.size(); ++i)
          	streamout << SavedFile.at(i) << "\n";

       	fileout.close();

	//Have the temporary file with new changes overwrite the original file
	cmd = "mv "+oFileTmp+" "+oFile;
	runShellCommand(cmd);	
	
	return true;
    
}