Пример #1
0
QueryData genXattr(QueryContext &context) {
  QueryData results;
  auto paths = context.constraints["path"].getAll(EQUALS);

  for (const auto &path_string : paths) {
    boost::filesystem::path path = path_string;
    // Folders can have extended attributes too
    if (!(boost::filesystem::is_regular_file(path) ||
          boost::filesystem::is_directory(path))) {
      continue;
    }
    getFileData(results, path.string());
  }

  auto directories = context.constraints["directory"].getAll(EQUALS);
  for (const auto &directory : directories) {
    if (!boost::filesystem::is_directory(directory)) {
      continue;
    }
    std::vector<std::string> files;
    listFilesInDirectory(directory, files);

    for (auto &file : files) {
      getFileData(results, file);
    }
  }
  return results;
}
Пример #2
0
int get_inputs(FILE *f_i, struct io_struct *h)
{
    int i, w;
    char ret, *buf = malloc(8*sizeof(char));
    if(buf == NULL)
    {
        printf("! error: not enough memory!\n");
        return 1;
    }

    while(ret != '\n' && ret != EOF)
    {
        // getting input valuse from file and
        // searching for inputs wires and then setting them
        // but if the first char is EOF return 1, beause thats mean that
        // the file pointer is already on the end of it
        if(getFileData(':', buf, f_i) != EOF)
        {
            i = atoi(buf);
            ret = getFileData(' ', buf, f_i);
            w = atoi(buf);
        }
        else { free(buf); return 1; }

        while(h != NULL)
        {
            if(h->num == i) { (h->adr)->walue = w; break; }
            h = h->next;
        }
    }

    free(buf);
    return 0;
}
Пример #3
0
int main(int argc, char** argv) {

	char dataFile[MAX];
	int aux = 0;

	while(1){
		
		printf("Monitoreando a COORDINADOR\n");
		getFileData("death_note.log", dataFile);
		

		if (strlen(dataFile) > 0) {
			if (strcmp(dataFile, "error") < 0) {
			    aux = atoi(dataFile);
			}
		}

		if(aux!=0){
			printf("Coordinador fallido. Procediendo a reactivar. PID: %d\n",aux);
			sleep(150);
			remove("death_note.log");
			system("./coordinador");
		
		}
		sleep(10);
	}

}
TEST_F(ExtendedAttributesTests, test_extended_attributes) {
  QueryData results;
  getFileData(results, kTestFilePath);

  const std::map<std::string, std::string> expected = {
      {"quarantine_agent", "Google Chrome"},
      {"quarantine_type", "LSQuarantineTypeWebDownload"},
      {"quarantine_timestamp", "1430867421"},
      {"quarantine_event_id", "6A0EC92D-1882-4358-A315-586BA65F8F77"},
      {"quarantine_data_url",
       "https://dl.google.com/chrome/mac/stable/GGRO/googlechrome.dmg"},
      {"quarantine_origin_url",
       "https://www.google.com/chrome/browser/thankyou.html?platform=mac"},
      {"foobar", "baz"},
      {kFsckKey, kDiskImagefsckBase64}};

  for (auto row : results) {
    for (auto elems : row) {
      auto key = elems.first;
      auto value = elems.second;
      if (expected.count(key) > 0) {
        if (key == "quarantime_timestamp") {
          long timeExpected = std::stol(expected.at("quarantine_timestamp"));
          long actual = std::stol(value);
          EXPECT_GE(timeExpected, actual);
        } else {
          EXPECT_EQ(expected.at(key), value);
        }
      }
    }
  }
}
Пример #5
0
int main(int argc, char* argv[]) {
	// Show help if we didn't get the proper args
	if (argc > 2) {
		showHelp();
		return 0;
	}

	// Grab filename
	string fileName = argv[1];

	// Set up our storage containers
	FileData csvFile;

	// Used to determine which columns are visible
	int*  visibleColumns;

	Stats* colStats;
	int numColumns = 0;

	// Flag to determine if we need to recalc the median if a row has been sorted
	bool sorted = false;
	
	cout << "Loading file: " << fileName << endl;
	// Initial load
	int totalRows = getFileData(fileName, csvFile, colStats, numColumns);

	// Something went wrong, lets just say we couldn't open the file
	if (totalRows == 0) {
		cout << "Could not open file. " << fileName << endl;
		return 0;
	}

	cout << "Loaded file with: " << totalRows << " rows, and " << numColumns << " columns. \n>: ";

	// By default, all columns are visible
	visibleColumns = new int[numColumns];
	for (int i = 0; i < numColumns; ++i) {
		visibleColumns[i] = 1;
	}

	string command;
	while (command != "exit") {
		string col, col2;
		string value;
		int op = -1;
		// Grab the command as it should be the first thing they type
		cin >> command;
		if (command == "sort") {
			cin >> col;
			int column = atoi(col.c_str());
			
			if (column < 0 || column >= numColumns) {
				cout << "Please enter a valid column number between 0 and " << numColumns << endl;	
			} else {
				// If we got a valid input, sort up the column
				heapSort(csvFile, totalRows, column);		
				sorted = true;
			}
		} else if (command == "print") {
Пример #6
0
NSString* NSString::createWithContentsOfFile(const char* pszFileName)
{
    unsigned long size = 0;
    unsigned char* pData = 0;
    NSString* pRet = NULL;
    pData = getFileData(pszFileName, "rb", &size);
    pRet = NSString::createWithData(pData, size);
    NS_SAFE_DELETE_ARRAY(pData);
    return pRet;
}
Пример #7
0
Common::SeekableReadStream *PakFile::createReadStream(const Common::String &fileName) {
	debugC(1, kDebugResource, "createReadStream(%s)", fileName.c_str());

	uint32 fileSize = 0;
	uint8 *buffer = getFileData(fileName, &fileSize);
	if (buffer)
		return new Common::MemoryReadStream(buffer, fileSize, DisposeAfterUse::YES);
	else
		return 0;
}
Пример #8
0
int main()
{
   int numGames = 0;
   char code[MAXGAMES];
   int auRuns[MAXGAMES], oppRuns[MAXGAMES], innings[MAXGAMES], attend[MAXGAMES]; 
   
   numGames = getFileData(code, auRuns, oppRuns, innings, attend);
   if (numGames > 0)
      printSummary(code, auRuns, oppRuns, innings, attend, numGames);
   else
      printf ("No data read. Program ending.");    
   //fclose(filePtr);
   return 0;
}
Пример #9
0
void JsonHelp::LoadBaseRoleJsonFile( const char* szFile )
{
	rapidjson::Document doc;
	unsigned long size = 0;

	unsigned char * pBuffer = getFileData(szFile,"r",&size);

	if (pBuffer == NULL)
		return;
	else
	{
		std::string loadstr((char*)pBuffer,size);

		CC_SAFE_DELETE(pBuffer);

		doc.Parse<0>(loadstr.c_str());

		//解析错误
		if (doc.HasParseError())
			return;

		//是否是数组
		if (!doc.IsArray())
			return;

		const rapidjson::Value &pArray = doc;

		for (int i = 0; i < pArray.Size(); ++i)
		{
			const rapidjson::Value &pTmp = pArray[i];

			BaseRoleData *pData = new BaseRoleData();

			pData->idx = i+1;

			pData->name = pTmp["name"].GetString();
			pData->png = pTmp["halfPath"].GetString();
			pData->skillPath = pTmp["skillPath"].GetString();
			pData->nAttack = pTmp["attack"].GetInt();
			pData->nMapHp = pTmp["hp"].GetInt();
			pData->nAttackEffect = pTmp["attackEffect"].GetInt();
			pData->fAttackAddtion = pTmp["attackAddition"].GetDouble();
			pData->nSkillEffect = pTmp["skillEffect"].GetInt();
			pData->fEffectAddtion = pTmp["skillAddition"].GetDouble();

			BaseRoleVector.push_back(pData);
		}
	}
}
Пример #10
0
//*****MAIN*****
int main()
{
   char title[TITLE_LEN],
        date[MAXGAMES][DATE_LEN],
        team[MAXGAMES][TEAM_LEN];
   int gameStats[MAXGAMES][NUMCOLS],
       numGames;
   double hours[MAXGAMES];
   // calculate number of games
   numGames = getFileData(title, date, team, gameStats, hours);
   if (numGames < 1)
      printf ("No data available.\n");
   else
      printSummary (title, date, team, gameStats, hours, numGames);
}
Пример #11
0
void CCZipFile::getFileDataOrder(const char *filename)
{
    unsigned long size;
    unsigned char* buf = getFileData(filename, &size);
	CCLuaStack* stack = CCLuaEngine::defaultEngine()->getLuaStack();
	stack->clean();
	if (NULL==buf) 
	{
		stack->pushNil();
		return;
	}
    stack->pushString((const char*)buf, size);
    delete []buf;
    return;   
}
Пример #12
0
	bool Zip::openXML(const char* filename, rapidxml::xml_document<>& doc)
	{
		unsigned long size = 0;
		char* data = getFileData(filename, size);

		if (!data) return false;

		char* pData = new char[size + 1];
		strncpy(pData, data, size);
		pData[size] = 0;
		doc.parse<0>(pData);

		if (data)
			delete[] data;
		//if (pData)
		//	delete[] pData;

		return true;
	}
Пример #13
0
// MAIN PROTOTYPES ===============================================================================
int main() 
{
    char code[MAXGAMES]; 
    int gameInfo[MAXGAMES][NUMCOLS]; 
    double gameLength[MAXGAMES]; 
    int numGames = 0; 
    // INPUT 
    numGames = getFileData( code, gameInfo, gameLength ); 
    if (numGames > 0) 
    { 
      // OUTPUT 
      printSummary( code, gameInfo, gameLength, numGames ); 
    }
    else 
    { 
      printf("No data read. Program ending."); 
    }
    return 0; 
}
void PeerguardianInfo::getLoadedIps()
{
    
    if ( QFile::exists(m_LogPath) )
    {
        QStringList fileData = getFileData( m_LogPath );
        QString blocklist_line("");
        
        for(int i=0; i < fileData.size(); i++)
        {
            if ( fileData[i].contains("INFO:") && fileData[i].contains("Blocking") )
                blocklist_line = fileData[i];
        }
        
        if ( ! blocklist_line.isEmpty() )
        {
            QStringList parts = blocklist_line.split("INFO:", QString::SkipEmptyParts);
            m_LoadedRanges = parts[1];
        } 
    }
    
}
Пример #15
0
int main(int argc, char** argv) {

	char dataFile[20];
	int aux;

	while(1){
		printf("Monitoreando al proceso DOS\n");
		getFileData("death_note_p2.log", dataFile);

		if (strlen(dataFile) > 0) {
			if (strcmp(dataFile, "error") < 0) {
			    aux = atoi(dataFile);
			}
		}

		if(aux!=0){
			printf("P2 fallido. Procediendo a reactivar. PID: %d\n",aux);
			sleep(6);
			system("./proceso_dos");
		}
		sleep(10);
	}

}
Пример #16
0
void WContact::finished()
{
//	m_menu->setDisabled( false );

	if ( m_name.isEmpty() )
		setNamev2( m_wmanager->getLoc( "dnam" ) );

	QString msgWeatherT = getFileData( "weatherT.html" );
	QString msgWeatherHtmlT = getFileData( "weatherHtmlT.html" );
	QString msgForecastT, msgForecastHtmlT;

	QHashIterator< QString, QString > it( *m_wmanager->getCC() );
	while ( it.hasNext() )
	{
		it.next();

		msgWeatherT.replace( "%" + it.key() + "%", it.value() );
		msgWeatherHtmlT.replace( "%" + it.key() + "%", it.value() );
	}

	if ( m_forecast )
	{
		QString tMsgForecastT, tMsgForecastHtmlT;

		msgForecastT = getFileData( "forecastTitle.html" );
		msgForecastHtmlT = getFileData( "forecastHtmlTitle.html" ).arg( m_wmanager->getDayF( -1, "lsup" ) );

		for ( int i = 0; i <= 4; i++ )
		{
			QHash<QString, QString> h = *m_wmanager->getDayF( i );
			it = h;

			tMsgForecastT = getFileData( "forecastT.html" );
			tMsgForecastHtmlT = getFileData( "forecastHtmlT.html" );

			while ( it.hasNext() )
			{
				it.next();

				tMsgForecastT.replace( "%" + it.key() + "%", it.value() );
				tMsgForecastHtmlT.replace( "%" + it.key() + "%", it.value() );
			}

			msgForecastT += tMsgForecastT;
			msgForecastHtmlT += tMsgForecastHtmlT;
		}
	}
	else
	{
		Status previous = m_status;
		m_status.setIcon( QIcon( QString( ":/icons/%1.png" ).arg( m_wmanager->getCC( "icon" ) ) ) );
		if ( ( ( WAccount * )account() )->getShowStatusRow() )
			m_status.setText( QString::fromUtf8( "Weather: %1 °%2" ).arg( m_wmanager->getCC( "tmp" ) ).arg( m_wmanager->getUnit( "ut" ) ) );
		emit statusChanged( m_status, previous );
	}

	it = *m_wmanager->getLoc();
	while ( it.hasNext() )
	{
		it.next();

		msgWeatherT.replace( "%loc_" + it.key() + "%", it.value() );
		msgWeatherHtmlT.replace( "%loc_" + it.key() + "%", it.value() );

		msgForecastT.replace( "%loc_" + it.key() + "%", it.value() );
		msgForecastHtmlT.replace( "%loc_" + it.key() + "%", it.value() );
	}

	it = *m_wmanager->getUnit();
	while ( it.hasNext() )
	{
		it.next();

		msgWeatherT.replace( "%unit_" + it.key() + "%", it.value() );
		msgWeatherHtmlT.replace( "%unit_" + it.key() + "%", it.value() );

		msgForecastT.replace( "%unit_" + it.key() + "%", it.value() );
		msgForecastHtmlT.replace( "%unit_" + it.key() + "%", it.value() );
	}

	Message message( m_forecast ? msgForecastT : msgWeatherT );
	message.setProperty( "html", m_forecast ? msgForecastHtmlT : msgWeatherHtmlT ); 
	message.setIncoming( 1 );
	message.setTime( QDateTime::currentDateTime() );
	message.setChatUnit( this );

	if ( !m_forStatus && false )
		ChatLayer::get( this, true )->appendMessage( message );

	m_forecast = false;
	m_forStatus = false;
}
Пример #17
0
int main(int argc, char **argv)
{
	int sock, chunkSock;
	int offset;
	sockaddr_x dag;
	socklen_t daglen;
	char sdag[1024];
	char *p;
	const char *fin;
	const char *fout;
	char cmd[512];
	char reply[512];
	int status = 0;

	say ("\n%s (%s): started\n", TITLE, VERSION);

	if (argc != 3)
		die(-1, "usage: cftp <source file> <dest file>\n");

	fin = argv[1];
	fout = argv[2];

    // lookup the xia service 
	daglen = sizeof(dag);
    if (XgetDAGbyName(NAME, &dag, &daglen) < 0)
		die(-1, "unable to locate: %s\n", NAME);


	// create a socket, and listen for incoming connections
	if ((sock = Xsocket(AF_XIA, SOCK_STREAM, 0)) < 0)
		 die(-1, "Unable to create the listening socket\n");
    
	if (Xconnect(sock, (struct sockaddr*)&dag, daglen) < 0) {
		Xclose(sock);
		 die(-1, "Unable to bind to the dag: %s\n", dag);
	}

	// save the AD and HID for later. This seems hacky
	// we need to find a better way to deal with this
	Graph g(&dag);
	strncpy(sdag, g.dag_string().c_str(), sizeof(sdag));
	ad = strstr(sdag, "AD:");
	p = strchr(ad, ' ');
	*p = 0;
	hid = p + 1;
	hid = strstr(hid, "HID:");
	p = strchr(hid, ' ');
	*p = 0;

	// send the file request
	sprintf(cmd, "get %s",  fin);
	sendCmd(sock, cmd);

	// get back number of chunks in the file
	getReply(sock, reply, sizeof(reply));

	int count = atoi(&reply[4]);

	if ((chunkSock = Xsocket(AF_XIA, XSOCK_CHUNK, 0)) < 0)
		die(-1, "unable to create chunk socket\n");

	FILE *f = fopen(fout, "w");

	offset = 0;
	while (offset < count) {
		int num = NUM_CHUNKS;
		if (count - offset < num)
			num = count - offset;

		// tell the server we want a list of <num> cids starting at location <offset>
		sprintf(cmd, "block %d:%d", offset, num);
		sendCmd(sock, cmd);

		getReply(sock, reply, sizeof(reply));
		offset += NUM_CHUNKS;

		if (getFileData(chunkSock, f, &reply[4]) < 0) {
			status= -1;
			break;
		}
	}
	
	fclose(f);

	if (status < 0) {
		unlink(fin);
	}

	say("shutting down\n");
	sendCmd(sock, "done");
	Xclose(sock);
	Xclose(chunkSock);
	return status;
}
Пример #18
0
/*
 * Connect to the host and read/write a file
 */
int initClient(char *hostname, int port, char *filename) {
	struct hostent *he;

	printf("\tResolving hostname: %s\n", hostname);
	if ((he=gethostbyname(hostname)) == NULL) {
		perror("Error resolving hostname");
		return 1;
	}

	printf("\tInitialising socket on port %d\n", port);
	if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
		perror("Error initialising socket.");
		return 1;
	}

	server_addr.sin_family = AF_INET;
	server_addr.sin_port = htons(port);
	server_addr.sin_addr = *((struct in_addr*)he->h_addr);
	memset(&(server_addr.sin_zero), '\0', 8);

	struct timeval tv;
	tv.tv_sec = 10;  /* 10 Secs Timeout */
	tv.tv_usec = 0;  // Not init'ing this can cause strange errors
	setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv,sizeof(struct timeval));

	// create a thread listening for packets
	pthread_t listener_thread;
	pthread_create(&listener_thread, NULL, (void*(*)(void*))listenForPackets, NULL);


	if (isReadMode) {
		printf("\tSending read request for file: %s\n", filename);
		struct packet *p;
		if ((p = createReadWritePacket(1, filename)) == NULL) {
			printf("\tError creating packet.");
		}
		else { 
			int i;
			for (i = 0; ; i++) {
				if (i == 4) {
					printf("\tTransfer timed out.\n");
					exit(1);
				}
				// send RRQ
				sendPacket(p->buffer, p->bufferLen, sockfd, (struct sockaddr *)&server_addr);

				usleep(1000000);

				if (receivedERROR) {
					printf("\tError code %d: %s\n", packet[1], getData(packet, numbytes));
					exit(1);
				}
				if (receivedACK) {
					receivedACK = 0;
					break;
				}
			}

			int dataBlock = 1;
			FILE *fp = fopen(filename, "wb");
			if (fp != NULL) {
				for (i = 0; ; i++) {
					if (receivedDATA) {
						receivedDATA = 0;

						// write data
						char *theData = getData(packet, numbytes);
						fwrite(theData, sizeof(char), numbytes-4, fp);

						// send ACK
						for (i = 0; ; i++) {
							if (i == 4) {
								printf("\tTransfer timed out.\n");
								exit(1);
							}
							struct packet *ack = createACKPacket(dataBlock); 
							sendPacket(ack->buffer, ack->bufferLen, sockfd, (struct sockaddr*)&server_addr);

							usleep(1000000);

							if (receivedERROR) {
								printf("\tError code %d: %s\n", packet[1], getData(packet, numbytes));
								exit(1);
							}
							if (receivedDATA) {
								receivedDATA = 0;
								dataBlock++;
								break;
							} 
							if (numbytes < 512) exit(1);
						}
					}
				}
				fclose(fp);
			}
			else {
				printf("Error code 0: unable to open/read file.\n");
				exit(1);
			}
		}

	}
	else if (isWriteMode) {
		printf("\tSending write request for file: %s\n", filename);
		struct packet *p;
		if ((p = createReadWritePacket(2, filename)) == NULL) {
			printf("\tError creating packet.");
		} 
		else {
			// send WRQ
			int i;
			for (i = 0; ; i++) {
				if (i == 4) {
					printf("\tTransfer timed out.\n");
					exit(1);
				}
				// send RRQ
				sendPacket(p->buffer, p->bufferLen, sockfd, (struct sockaddr *)&server_addr);

				usleep(1000000);

				if (receivedERROR) {
					printf("\tError code %d: %s\n", packet[1], getData(packet, numbytes));
					exit(1);
				}
				if (receivedACK) {
					receivedACK = 0;
					break;
				}
			}
			
			// get the file data into a buffer
			struct packet *f;
			if ((f = getFileData(filename)) != NULL) {
				int dataBlock = 1, count = 0;
				printf("Buffer size: %d\n", f[0].bufferLen);
				if (f[0].bufferLen <= 0) {
					printf("\tError code 0: File is of size 0 bytes.\n");
					exit(1);
				}
				while (dataBlock < f[0].bufferLen) {
					struct packet *d = createDataPacket(dataBlock, f[dataBlock].buffer);
					sendPacket(d->buffer, d->bufferLen, sockfd, (struct sockaddr*)&server_addr);

					// wait for ACK
					printf("\tWaiting for ACK packet.\n");
					int c;
					for (c = 0; ; c++) {
						if (c == 8) {
							break; // resend the data
						}
						if (receivedACK) {
							dataBlock++;
							break;
						}
						usleep(500000);
					}
					count++;
					usleep(1000000); // without this you end up with race conditions because of threads...
				}
			}
			else {
				printf("\tError code 4: File not found.\n");
				exit(1);
			}
		}
	}

	return 0;
}
Пример #19
0
unsigned char* FileUtils::getFileData(const QString & pszFileName, const char* pszMode, unsigned long * pSize)
{
    return getFileData(pszFileName.toStdString().c_str(), pszMode, pSize);
}
Пример #20
0
int get_io(char *io_name, struct io_struct** head, FILE *f_io)
{
    struct io_struct *io_new;
    struct io_struct *last;
    
    char *buf = malloc(8*sizeof(char));
    if(buf == NULL)
    {
        printf("! error: not enough memory!\n");
        free(buf);
        return 1;
    }

    // getting the first word in file line, it should be equal to io_name
    getFileData(' ', buf, f_io);

    if(!strcmp(buf, io_name))
    {
        // now program takes node number and create the first element
        // of input nodes list
        getFileData(' ', buf, f_io);

        // first inputs list element
        io_new = malloc(sizeof(struct io_struct));
        if(io_new == NULL)
        {
            printf("! error: not enough memory!\n");
            free(buf);
            return 1;
        }
        *head = io_new;
        io_new->num = atoi(buf);
        io_new->adr = NULL;
        io_new->next = NULL;
        last = io_new;

        while(true)
        {
            getFileData(' ', buf, f_io);

            if(atoi(buf))
            {
                io_new = malloc(sizeof(struct io_struct));
                if(io_new == NULL)
                {
                    printf("! error: not enough memory!\n");
                    free(buf);
                    return 1;
                }
                io_new->num = atoi(buf);
                io_new->adr = NULL;
                io_new->next = NULL;
                last->next = io_new;
                last = io_new;
            } else break;
        }
    }
    else
    {
        printf("! error: wrong file format!\n");
        return 1;
    }

    // because of getFileData() function now we have to move file pointer
    // backward by one word
    fseek(f_io, ftell(f_io)-(1+strlen(buf)), SEEK_SET);
    free(buf);

    return 0;
}
Пример #21
0
int main(int argc, char* argv[])
{
    long size;
    char *filedata;
    term_size terminal;
    ModPlugFile *f2;
    int mlen;
    struct timeval tvstart;
    struct timeval tv;
    struct timeval tvpause, tvunpause;
    struct timeval tvptotal;
    char status[161];
    char songname[41];
    char notpaus[4];

    int loop=0; // kontest
    
    int songsplayed = 0;

    int nFiles = 0, fnOffset[100];
    int i;

    ModPlug_Settings settings;
    ModPlug_GetSettings(&settings);

    ao_device *device;
    ao_sample_format format = {0};
    int default_driver;
    
    ao_initialize();
    default_driver = ao_default_driver_id();

    for (i=1; i<argc; i++) {
     /* check if arguments need to be parsed */
     if (argv[i][0] == '-') {
      if (strstr(argv[i],"-h")) {
        printf("\n");
        help(argv[0],0);
      } else if (strstr(argv[i],"-v")) {
	versioninfo();
        exit(0);
      } else if (strstr(argv[i],"-l")) {
        loop=1;
        continue;
      } else if (strstr(argv[i],"-ao")) {
        default_driver = ao_driver_id(argv[++i]);
        continue;
      }
      if (argv[i][1] == '-') { // not a song
        if (strstr(argv[i],"--help")) {
          help(argv[0],0);
        } else if (strstr(argv[i],"--version")) {
	  versioninfo();
	  exit(0);
	}
        continue;
       }
      }
      /* "valid" filename - store it */
      fnOffset[nFiles++] = i;
    }

    format.bits = 16;
    format.channels = 2;
    format.rate = 44100;
    format.byte_format = AO_FMT_LITTLE;
//	printf("Default driver = %i\n", default_driver);

    char buffer[128];
    int result, nread;
    struct pollfd pollfds;
    int timeout = 1;            /* Timeout in msec. */
    int pause=0;
    int mono=0;
    int bits=0;
    int song;

    // [rev--dly--] [sur--dly--] [bas--rng--]
    int rev=0;    // a
    int revdly=0; // s
    int sur=0;    // d
    int surdly=0; // y
    int bas=0;    // x
    int basrng=0; // c

    /* Initialize pollfds; we're looking at input, stdin */
    pollfds.fd = 0;             /* stdin */
    pollfds.events = POLLIN;    /* Wait for input */

    if (argc==1) {
	help(argv[0],1);
    }

    if (!get_term_size(STDIN_FILENO,&terminal)) {
	fprintf(stderr,"warning: failed to get terminal size\n");
    }
    
    srand(time(NULL));

for (song=0; song<nFiles; song++) {

    char *filename = argv[fnOffset[song]];

/* -- Open driver -- */
    if (default_driver == ao_driver_id("wav")) {
        device = ao_open_file(default_driver, "output.wav", 1, &format, NULL /*no options*/);
    } else {
        device = ao_open_live(default_driver, &format, NULL /* no options */);
    }
    if (device == NULL) {
 	fprintf(stderr, "Error opening device. (%s)\n", filename);
	fprintf(stderr, "ERROR: %i\n", errno);
        return 1;
    }
    printf("%s ",filename);
    printf("[%d/%d]",song+1,nFiles);

    filedata = getFileData(filename, &size);
    if (filedata == NULL) continue;
    printf(" [%ld]\n",size);

    // Note: All "Basic Settings" must be set before ModPlug_Load.
    settings.mResamplingMode = MODPLUG_RESAMPLE_FIR; /* RESAMP */
    settings.mChannels = 2;
    settings.mBits = 16;
    settings.mFrequency = 44100;
    settings.mStereoSeparation = 128;
    settings.mMaxMixChannels = 256;
    /* insert more setting changes here */
    ModPlug_SetSettings(&settings);

    f2 = ModPlug_Load(filedata, size);
    if (!f2) {
	printf("could not load %s\n", filename);
	close(audio_fd);
	free(filedata); /* ? */
    } else {
      songsplayed++;
/*    settings.mFlags=MODPLUG_ENABLE_OVERSAMPLING | \
                    MODPLUG_ENABLE_NOISE_REDUCTION | \
		    MODPLUG_ENABLE_REVERB | \
		    MODPLUG_ENABLE_MEGABASS | \
		    MODPLUG_ENABLE_SURROUND;*/

//    settings.mReverbDepth = 100; /* 0 - 100 */ *   [REV--DLY--]
//    settings.mReverbDelay = 200; /* 40 - 200 ms  00-FF */ 
//    settings.mSurroundDepth = 100; /* 0 - 100 */   [SUR--DLY--]
//    settings.mSurroundDelay = 40; /* 5 - 40 ms */  
//    settings.mBassAmount  = 100; /* 0 - 100 */     [BAS--RNG--]
//    settings.mBassRange   = 100; /* 10 - 100 hz */ 
// [REV--DLY--] [SUR--DLY--] [BAS--RNG--]
// [rev--dly--] [sur--dly--] [bas--rng--]


    set_keypress();
    strcpy(songname, ModPlug_GetName(f2));

    /* if no modplug "name" - use last 41 characters of filename */
    if (strlen(songname)==0) {
        int l = strlen(filename);
	char *st = filename;
        if (l >= 41) st = filename + l - 41;
        strncpy(songname,st,41);
        songname[40] = 0;
    }
    sprintf(status,"playing %s (%%d.%%d/%d\") (%%d/%%d/%%d)    \b\b\b\b",songname,ModPlug_GetLength(f2)/1000);
    if (loop) sprintf(status,"looping %s (%%d.%%d/%d\") (%%d/%%d/%%d)    \b\b\b\b",songname,ModPlug_GetLength(f2)/1000);

    gettimeofday(&tvstart,NULL);
    tvptotal.tv_sec=tvptotal.tv_usec=0;
    mlen=1;
    
    while(mlen!=0) {
	if (mlen==0) { break; }

	if (!pause) {
	    gettimeofday(&tv,NULL);
	    mlen = ModPlug_Read(f2,audio_buffer,BUF_SIZE);
            if (mlen > 0 && ao_play(device, audio_buffer, mlen) == 0) {
		perror("audio write");
		exit(1);
    	    }
        }
        printf(status,tv.tv_sec-tvstart.tv_sec-tvptotal.tv_sec,tv.tv_usec/100000,format.rate,format.channels,settings.mBits/*,rev,revdly,sur,surdly,bas,basrng*/);
	fflush(stdout);

	if ((mlen==0) && (loop==1)) {
	    /*printf("LOOPING NOW\n");*/
	    ModPlug_Seek(f2,0);
	    gettimeofday(&tvstart,NULL);
	    mlen=ModPlug_Read(f2,audio_buffer,BUF_SIZE);
	    tvptotal.tv_sec=tvptotal.tv_usec=0;
	}

        result = poll(&pollfds, 1, timeout);
        switch (result) {
        case 0:
            /*printf(".");*/
            break;
        case -1:
            perror("select");
            exit(1);

        default:
            if (pollfds.revents && POLLIN) {
	        nread = read(0, buffer, 1); /* s/nread/1/2 */
                if (nread == 0) {
                    printf("keyboard done\n");
                    exit(0);
               } else {
                    buffer[nread] = 0;
                    /* printf("%s", buffer); */

		    if (buffer[0]=='q') { mlen=0; song=nFiles;  } /* quit */

		    if (buffer[0]=='f') {
			if ((tv.tv_sec-tvstart.tv_sec-tvptotal.tv_sec+10) < (ModPlug_GetLength(f2)/1000)) {
			    ModPlug_Seek(f2,(tv.tv_sec-tvstart.tv_sec-tvptotal.tv_sec)*1000+10000);
			    tvstart.tv_sec-=10;
			}
		    } /* forward 10" */

		    if (buffer[0]=='b') {
			if ((tv.tv_sec-tvstart.tv_sec-tvptotal.tv_sec-10) > 0) {
			    ModPlug_Seek(f2,(tv.tv_sec-tvstart.tv_sec-tvptotal.tv_sec)*1000-10000);
			    tvstart.tv_sec+=10;
			}
		    } /* backward 10" */
		    
		    /*
		    if (buffer[0]=='i') {
			printf("\n");
		    } */

/*
		    if (buffer[0]=='a') {
			rev++; settings.mReverbDepth=rev;
			ModPlug_SetSettings(&settings);
		    }
		    if (buffer[0]=='A') {
			rev--; settings.mReverbDepth=rev;
			ModPlug_SetSettings(&settings);
		    }
		    if (buffer[0]=='s') {
			revdly++; settings.mReverbDelay=revdly;
			ModPlug_SetSettings(&settings);
		    }
		    if (buffer[0]=='S') {
			revdly--; settings.mReverbDelay=revdly;
			ModPlug_SetSettings(&settings);
		    }
		    if (buffer[0]=='d') {
			sur++; settings.mSurroundDepth=sur;
			ModPlug_SetSettings(&settings);
		    }
		    if (buffer[0]=='D') {
			sur--; settings.mSurroundDepth=sur;
			ModPlug_SetSettings(&settings);
		    }
		    if (buffer[0]=='y') {
			surdly++; settings.mSurroundDelay=surdly;
			ModPlug_SetSettings(&settings);
		    }
		    if (buffer[0]=='Y') {
			surdly--; settings.mSurroundDelay=surdly;
			ModPlug_SetSettings(&settings);
		    }
		    if (buffer[0]=='x') {
			bas++; settings.mBassAmount=bas;
			ModPlug_SetSettings(&settings);
		    }
		    if (buffer[0]=='X') {
			bas--; settings.mBassAmount=bas;
			ModPlug_SetSettings(&settings);
		    }
		    if (buffer[0]=='c') {
			basrng++; settings.mBassRange=basrng;
			ModPlug_SetSettings(&settings);
		    }
		    if (buffer[0]=='C') {
			basrng--; settings.mBassRange=basrng;
			ModPlug_SetSettings(&settings);
		    }
*/
		    
		    if (buffer[0]=='n') {
			if (song<argc) { mlen=0; pause=0; }
		    }

		    if (buffer[0]=='N') {
			if (song>1) { song-=2; mlen=0; pause=0; }
		    }
		    
		    if (buffer[0]=='r') {
			song=(int) ((float)(argc-1)*rand()/(RAND_MAX+1.0));
			mlen=0; pause=0;
//			ioctl(audio_fd,SNDCTL_DSP_RESET,0);
			/* printf("\n[%d?]\n",song+1); */
		    }
		    
		    /*if (buffer[0]=='R') {
			song=(int) ((float)(argc-1)*rand()/(RAND_MAX+1.0));
			mlen=0; pause=0;
		    }*/
		    
/*		    if (buffer[0]=='m') {
			// mono/stereo 
			mono^=1;
			if (mono) format.channels=1; else format.channels=2;
			ioctl(audio_fd,SNDCTL_DSP_RESET,0);
			if (ioctl(audio_fd, SNDCTL_DSP_CHANNELS, &channels) == -1) {
			    perror("SNDCTL_DSP_CHANNELS");
			    exit(1);
			}
			if (mono) settings.mChannels=1; else settings.mChannels=2;
			ModPlug_SetSettings(&settings);
			f2=ModPlug_Load(d,size);
			ModPlug_Seek(f2,(tv.tv_sec-tvstart.tv_sec-tvptotal.tv_sec)*1000+10000);
		    }
		    */
		    if (buffer[0]=='l') {
			loop^=1;
			if (loop) {
			    memcpy(status+4,"loop",4);
			} else {
			    memcpy(status+4,"play",4);
			}
		    } /* loop */
		    
		    if (buffer[0]=='p') {
			pause^=1;
			if (pause) {
			    gettimeofday(&tvpause,NULL);
			    memcpy(notpaus,status+4,4);
			    memcpy(status+4,"paus",4);
			} else {
			    gettimeofday(&tvunpause,NULL);
			    memcpy(status+4,notpaus,4);
			    tvptotal.tv_sec+=tvunpause.tv_sec-tvpause.tv_sec;
			    tvptotal.tv_usec+=tvunpause.tv_usec-tvpause.tv_usec;
			    /* printf(status,tv.tv_sec-tvstart.tv_sec,tv.tv_usec/100000); */
			}
		    } /* pause */
                }
            }
        }
    }
    printf("\n");

    reset_keypress();
    ModPlug_Unload(f2);
    ao_close(device);
    fprintf(stderr, "Closing audio device.\n");
    free(filedata);
    } /* valid module */
    
} /* for */
    ao_shutdown();

    return 0;
}
Пример #22
0
int get_gates(struct gates_list **head, struct io_struct** i_h, struct io_struct** o_h, FILE *f_c)
{
    int i, j, w;
    struct gates_list* gate_new  = NULL;
    struct gates_list* gate_last = NULL;
    
    char *buf = malloc(8*sizeof(char));
    if(buf == NULL)
    {
        printf("! error: not enough memory!\n");
        return 1;
    }

    while(true)
    {
        // if file pointer reach the EOF, end the process
        if(EOF == getFileData(' ', buf, f_c)) break;

        // create new gate
        gate_new = malloc(sizeof(struct gates_list));
        if(gate_new == NULL)
        {
            printf("! error: not enough memory!\n");
            free(buf);
            return 1;
        }

        // if it is the first gate, set all pointers on it
        // else make connection between last created gate and the new one
        if(*head == NULL) *head =  gate_last = gate_new;
        else gate_last->next = gate_new;

        // settings all gate pointers to NULL
        for(i = 0; i < 3; i++) gate_new->w[i] = NULL;
        gate_new->next = NULL;

        // defining gates type using only first 2 or just one chars
        // from its name
        switch(buf[0])
        {
            case 'A': gate_new->name = AND; break;
            case 'O': gate_new->name = OR; break;
            case 'X': gate_new->name = (buf[1] == 'O')?XOR:XNOR; break;
            case 'N': switch(buf[1])
                      {
                          case 'A': gate_new->name = NAND; break;
                          case 'O': gate_new->name = NOR; break;
                          case 'E': gate_new->name = NEG; break;
                          default: printf("! error: wrong file format (gate name)!\n");
                          free(buf);
                          return 1;
                      } break;
            default: printf("! error: wrong file format (gate name)!\n");
                     free(buf);
                     return 1;
        }

        // creat wires and connekting them with their gates
        for(i = 0; i < 3; i++)
        {
            // exception for NEG gate
            // pointers for second input and output are the same
            if(gate_new->name == NEG && gate_new->w[1] != NULL)
            {
                gate_new->w[2] = gate_new->w[1];
                break;
            }

            // getting wire number
            getFileData(' ', buf, f_c); w = atoi(buf);

            // checking if wire is already created
            // loop goes through all previously created gates and checking
            // whether the wire has already been created
            gate_last = *head;
            while(gate_last->next != NULL)
            {
                for(j=0; j<3; j++)
                    if((gate_last->w[j])->num == w) gate_new->w[i]=gate_last->w[j];
                gate_last = gate_last->next;
            }

            // if not, create new wire, and set it value to -1
            if(gate_new->w[i] == NULL)
            {
                gate_new->w[i] = malloc(sizeof(struct wire));
                if(gate_new->w[i] == NULL)
                {
                    printf("! error: not enough memory!\n");
                    free(buf);
                    return 1;
                }
                (gate_new->w[i])->num = w;
                (gate_new->w[i])->walue = -1;
            } else continue;

            // searching inputs and connecting them to their wires
            search_for_io(w, gate_new->w[i], *i_h);
            // searching outputs and connecting them to their wires
            search_for_io(w, gate_new->w[i], *o_h);

        }

        // printing gates structure 
        printf("\tgate type number: %d, wires:", gate_new->name);
        for(i=0; i<3; i++) printf(" %d", (gate_new->w[i])->num);
        printf("\n");

    }

    free(buf);
    return 0;
}
Пример #23
0
/*
 * Proceso 3
 */
int main(int argc, char** argv) {
    struct sockaddr_in direccion;
    FILE *filenew;
    char bufferr[1024];
    char peticion[220];
    char nameImage[20];
    int contadorImagen;
    unsigned long fileLen;
    int params[2];
    int rec, rest, kl;
    int sock, i, envio, bytes;

    char toWriteFile[BUF_SIZE];
    char nameFile[20];
    char dataFile[20];
    int aux = 0; //variable donde se almacenará el valor del archivo contador.log
    strcpy(nameFile, "contador.log");
    getFileData(nameFile, dataFile);

    if (strlen(dataFile) > 0) {
        if (strcmp(dataFile, "error") < 0) {
            aux = atoi(dataFile);
        }
    }

    contadorImagen = aux;




    while (contadorImagen < 5) {
        sock = socket(AF_INET, SOCK_STREAM, 0);
        if (sock < 0)
            printf("ERROR: Socket no construido.");
        else
            printf("Socket creado.");

        sprintf(nameImage, "im%d.bmp", contadorImagen);
        bzero((char*) &direccion, sizeof (direccion));

        direccion.sin_family = AF_INET;
        direccion.sin_port = htons(3393);
        direccion.sin_addr.s_addr = inet_addr("192.168.1.69");
        printf("--------CLIENTE QUE PIDE IMAGEN----------------\n");

        if (connect(sock, (struct sockaddr*) &direccion, sizeof (direccion)) < 0) {//conectando con servidor
            printf("\n ERROR CONNECT: no connect para pedir imagen.");
            sleep(1);
        } else {
            strcpy(peticion, "get_imagen");
            if (send(sock, peticion, strlen(peticion), 0) == -1)
                printf("ERROR SEND: Error al enviar solicitud.\n");
            //COMENZANDO A RECIBIR IMAGEN
            char mensaje_r[10];
            if (recv(sock, mensaje_r, sizeof (mensaje_r), 0) == -1) {
                printf("Error recibiendo respuesta");
            }

            //Mientras no recivamos si preguntamos.
            if (strcmp(mensaje_r, "SI") != 0) {
                sleep(1);
                continue;
            }

            char mensaje_e[] = "LISTO";
            send(sock, mensaje_e, sizeof (mensaje_e), 0);
            //recibiendo imagen
            receive_image(sock,nameImage);
            
/*
            bytes = recv(sock, (char *) &params, 2 * sizeof (int), 0);
            if (bytes < 0)
                printf("ERROR RECV: no se recibieron caracteristicas de la imagen.\n");
            else
                printf("Caracteristicas recibidas en RECV\n");

            rec = params[0]; //recivido
            rest = params[1]; //restante

            printf("Recorrer archivo %d veces \n", rec);
            printf("Resta de b %d \n", rest);
            //writeDataFile(nameImage,sock,params);

            filenew = fopen(nameImage, "w");
            for (kl = 0; kl < rec; kl++) {
                recv(sock, (char *) &bufferr, sizeof (bufferr), 0);
                fwrite(bufferr, 1024, sizeof (char), filenew);
                memset(bufferr, 0, strlen(bufferr));
                printf("Escrito \n");
            }

            if (rest > 0) {
                recv(sock, (char *) &bufferr, rest * sizeof (char), 0);
                fwrite(bufferr, rest, sizeof (char), filenew);
                memset(bufferr, 0, strlen(bufferr));
            }

            fclose(filenew);
*/
            printf("\nEscrito totalmente \n");
            contadorImagen++;
            close(sock);
            sprintf(toWriteFile, "%d", contadorImagen);
            setFileData(nameFile, toWriteFile);
            imageProcessing(nameImage, contadorImagen);

            //Enviar petición para borrar la imagen al servidor


            sock = socket(AF_INET, SOCK_STREAM, 0);
            if (sock < 0)
                printf("ERROR: Socket no construido.");
            else
                printf("Socket creado.");

            bzero((char*) &direccion, sizeof (direccion));

            direccion.sin_family = AF_INET;
            direccion.sin_port = htons(3393);
            direccion.sin_addr.s_addr = inet_addr("192.168.1.69");
            printf("--------CLIENTE QUE PIDE BORRAR IMAGEN----------------\n");

            if (connect(sock, (struct sockaddr*) &direccion, sizeof (direccion)) < 0) {//conectando con servidor
                printf("\n ERROR CONNECT: no connect para pedir imagen.");
                sleep(1);
            } else {
                memset(peticion, 0, sizeof (peticion));
                strcpy(peticion, "borrar_imagen");
                if (send(sock, peticion, strlen(peticion), 0) == -1)
                    printf("ERROR SEND: Error al enviar solicitud.\n");
                if (recv(sock, (char *) &bufferr, sizeof (bufferr), 0) < 0) {
                    printf("ERROR RECV: no se recibieron caracteristicas de la imagen.\n");
                }
                if (strcmp(bufferr, "OK") == 0) {
                    printf("Imagen borrada\n");
                } else if (strcmp(bufferr, "NO") == 0) {
                    printf("Permiso denegado\n");
                }
                close(sock);
            }


        }
    }


    return (EXIT_SUCCESS);
}
Пример #24
0
int main(int argc, char *argv[])
{
	int allowEdit, allowHintSub, fixStems, debug, badParam;
	char *fontInfoFileName=NULL; /* font info file name, or suffix of environment variable holding the fontfino string. */
	char *fontinfo = NULL; /* the string of fontinfo data */
	int firstFileNameIndex = -1; /* arg index for first bez file name, or  suffix of environment variable holding the bez string. */
	register char *current_arg;
	short total_files = 0; 
	int result, argi;
  
	badParam = fixStems = debug = doAligns = doStems = allstems = FALSE;
	allowEdit = allowHintSub = TRUE;
	fileSuffix = (char*)dfltExt;

	/* read in options */
	argi = 0;
	while (++argi < argc)
		{
	   current_arg = argv[argi];
	   
		if (current_arg[0] == '\0')
			continue;
		else if (current_arg[0] != '-')
			{
			if (firstFileNameIndex == -1)
				firstFileNameIndex = argi;
			total_files++;
			continue;
			}
		else if (firstFileNameIndex != -1)
			{
			fprintf(OUTPUTBUFF, "Error. Illegal command line. \"-\" option found after first file name.\n");
			exit(1);
 			}

		switch (current_arg[1])
			{
			case '\0':
				badParam = TRUE;
				break;
			case 'u':
				printUsage();
				#ifdef EXECUTABLE
				  exit(0);
				#else
					longjmp(aclibmark, 1);
				#endif
				break;
			case 'h':
				printHelp();
				#ifdef EXECUTABLE
				  exit(0);
				#else
					longjmp(aclibmark, 1);
				#endif
				break;
			 case 'e':
				allowEdit = FALSE;
				break;
			 case 'f':
				fontInfoFileName = argv[++argi];
				if  ((fontInfoFileName[0] == '\0') || (fontInfoFileName[0] == '-'))
					{
					fprintf(OUTPUTBUFF, "Error. Illegal command line. \"-f\" option must be followed by a file name.\n");
					exit(1);
					}
				break;
			 case 's':
				fileSuffix = argv[++argi];
				if  ((fileSuffix[0] == '\0') || (fileSuffix[0] == '-'))
					{
					fprintf(OUTPUTBUFF, "Error. Illegal command line. \"-s\" option must be followed by a string, and the string must not begin with '-'.\n");
					exit(1);
					}
				break;
			case 'n':
				allowHintSub = FALSE;
				break;
			case 'q':
				verbose = FALSE;
				break;
			 case 'D':
				debug = TRUE;
				break;
			case 'F':
				fixStems = TRUE;
			  break;
			case 'a':
				allstems = 1;
				break;
				
			case 'r':
				allowEdit = allowHintSub = FALSE;
				fileSuffix = (char *)reportExt;
				switch (current_arg[2])
					{
					case 'a':
						reportRetryCB = reportRetry;
						addCharExtremesCB = charZoneCB;
						addStemExtremesCB = stemZoneCB;
						doAligns = 1;

						addHStemCB = NULL;
						addVStemCB = NULL;
						doStems = 0;
						break;
					case 's':
						reportRetryCB = reportRetry;
						addHStemCB = hstemCB;
						addVStemCB = vstemCB;
						doStems = 1;

						addCharExtremesCB = NULL;
						addStemExtremesCB = NULL;
						doAligns = 0;
						break;
					default:
						fprintf(OUTPUTBUFF, "Error. %s is an invalid parameter.\n", current_arg);
						badParam = TRUE;
						break;
					}
					break;
			case 'v':
				printVersions();
				exit(0);
				break;
			  break;
#if ALLOWCSOUTPUT
			case 'C':
				charstringoutput = TRUE;
				break;
#endif
			default:
				fprintf(OUTPUTBUFF, "Error. %s is an invalid parameter.\n", current_arg);
				badParam = TRUE;
				break;
			}
		}

	if (firstFileNameIndex == -1)
		{
		fprintf(OUTPUTBUFF, "Error. Illegal command line. Must provide bez file name.\n");
		badParam = TRUE;
		}
	if (fontInfoFileName == NULL)
		{
		fprintf(OUTPUTBUFF, "Error. Illegal command line. Must provide font info file name.\n");
		badParam = TRUE;
		}
		
	if (badParam) 
#ifdef EXECUTABLE
		exit(NONFATALERROR);
#else
		longjmp(aclibmark, -1);
#endif

#if ALLOWCSOUTPUT
	if (charstringoutput)
		read_char_widths();
#endif

	AC_SetReportCB(reportCB, verbose);
	fontinfo = getFileData(fontInfoFileName);
	argi = firstFileNameIndex-1;
	while (++argi < argc)
		{
		char *bezdata;
		char *output;
		size_t outputsize = 0;
		bezName = argv[argi];
		bezdata = getFileData(bezName);
		outputsize = 4*strlen(bezdata);
		output = malloc(outputsize); 

		if (doAligns || doStems)
			openReportFile(bezName, fileSuffix);
			
		result = AutoColorString(bezdata, fontinfo, output, (int*)&outputsize, allowEdit, allowHintSub, debug);
		if (result == AC_DestBuffOfloError)
			{
			free(output);
			if (reportFile != NULL)
				closeReportFile();
			if (doAligns || doStems)
				openReportFile(bezName, fileSuffix);
			output = malloc(outputsize); 
			/* printf("NOTE: trying again. Input size %d output size %d.\n", strlen(bezdata), outputsize); */
			AC_SetReportCB(reportCB, FALSE);
			result = AutoColorString(bezdata, fontinfo, output, (int*)&outputsize, allowEdit, allowHintSub, debug);
			AC_SetReportCB(reportCB, verbose);
			}
		if (reportFile != NULL)
			closeReportFile();
		else
			{
			if ((outputsize != 0) && (result == AC_Success))
				writeFileData(bezName, output, fileSuffix);
			}
		free(output);
		main_cleanup( (result == AC_Success) ? OK : FATALERROR);
		}
		

  return 0;
  }