예제 #1
0
파일: main.c 프로젝트: israfilistek/ps2sdk
int main( int argc, char *argv[] )
{
	int result;

	if( argc == 4)
	{
		if( strncmp( argv[1], "-L", 2 ) )
		{
			printf("Error: Option '%s' not recognized\n", argv[1]);
			result=EINVAL;
		}
		else
		{
			result=ConvertFile(argv[2], argv[3], 1);
		}
	}
	else if(argc == 3)
	{
		result=ConvertFile(argv[1], argv[2], 0);
	}
	else
	{
		printf(	"ADPCM Encoder %s\n"
			"Usage: sadenc [-L] <input wave> <output sad>\n"
			"Options:\n"
			"  -L  Loop\n", VERSION);
		result=EINVAL;
	}

	return result;
}
예제 #2
0
static void
ImportFile(const char *filename, char *destdir, FILE *tznames)
{
    BongoCalObject *cal;
    BongoJsonObject *obj = NULL;
    BongoHashtable *tzs = NULL;
    BongoHashtableIter iter;
    
    obj = ConvertFile(filename);
    if (!obj) {
        return;
    }

    cal = BongoCalObjectNew(obj);
    if (!cal) {
        return;
    }
    
    tzs = BongoCalObjectGetTimezones(cal);
    if (!tzs) {
        fprintf(stderr, "Couldn't get timezones from ical file %s\n", filename);        
        return;
    }
    
    for (BongoHashtableIterFirst(tzs, &iter);
         iter.key != NULL;
         BongoHashtableIterNext(tzs, &iter)) {
        const char *tzid = iter.key;
        char path[PATH_MAX];
        FILE *f;
        char *tz;
        char *name;
        char *p;

        snprintf(path, PATH_MAX, "%s/%s", destdir, GetFilename(tzid));

        f = fopen(path, "w");
        
        fprintf(f, "{ \"version\": { \"value\": \"2.0\" }, \"components\":[");
        
        tz = BongoJsonObjectToString(((BongoCalTimezone*)iter.value)->json);
        
        fwrite(tz, 1, strlen(tz), f);

        fprintf(f, "] }");

        name = MemStrdup(strrchr(tzid, '/') + 1);
        for (p = name; *p != '\0'; p++) {
            if (*p == '_') {
                *p = ' ';
            }
        }   

        fprintf(tznames, "%s|%s\n", name, tzid);
        
        fclose(f);
    }
}
예제 #3
0
void ConvertDirectory(const char *strFullPath, char *strRelativePath, double MaxMSE)
{
	// Set our current directory
	if (strFullPath)
		SetCurrentDirectory(strFullPath);
	// Get our current pathname
	char strCurrentPath[MAX_PATH];
	GetCurrentDirectory(MAX_PATH, strCurrentPath);

	// Now run through our directory, and find all subdirs
	WIN32_FIND_DATAA FindData;
	char Filename[4] = "*.*";
	HANDLE hFind = FindFirstFile(Filename, &FindData);
	if (hFind != INVALID_HANDLE_VALUE)
	{
		do
		{
			// Check if we've found a subdir
			if (FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
			{
				// ignore any directory starting with a '.'
				if (strnicmp(FindData.cFileName,".",1))
				{
					char strNewFullPath[MAX_PATH];
					char strNewRelativePath[MAX_PATH];
					sprintf(strNewFullPath, "%s\\%s", strCurrentPath, FindData.cFileName);
					if (strRelativePath)
						sprintf(strNewRelativePath, "%s\\%s", strRelativePath, FindData.cFileName);
					else
						sprintf(strNewRelativePath, "%s", FindData.cFileName);
					// Recurse into the new directory
					ConvertDirectory(strNewFullPath, strNewRelativePath, MaxMSE);
					// Restore our current directory
					SetCurrentDirectory(strCurrentPath);
				}
			}
			else
			{	// just files - check if it's an allowed graphics file
				if (IsGraphicsFile(FindData.cFileName))
				{	// got a graphics file
					ConvertFile(strRelativePath,FindData.cFileName, MaxMSE);
				}
				if (IsGraphicsAnim(FindData.cFileName))
				{	// got a .gif anim
					ConvertAnim(strRelativePath,FindData.cFileName, MaxMSE);
				}
			}
		}
		while (FindNextFile(hFind, &FindData));
		FindClose(hFind);
	}
}
예제 #4
0
파일: ftp.c 프로젝트: zhanwwan/lora-gateway
void *FTPLoop(void *some_void_ptr)
{
    while (1)
    {
		DIR *dp;
		struct dirent *ep;
		struct stat st;
		char *SSDVFolder;
		char FileName[100], TempName[100];
	
		SSDVFolder = "/tmp";
				
		dp = opendir(SSDVFolder);
		if (dp != NULL)
		{
			while ((ep = readdir (dp)))
			{
				if (strstr(ep->d_name, ".bin") != NULL)
				{
					sprintf(FileName, "%s/%s", SSDVFolder, ep->d_name);
					stat(FileName, &st);
					// LogMessage("Age of '%s' is %ld seconds\n", FileName, time(0) - st.st_mtime);
					if ((time(0) - st.st_mtime) < 20)
					{
						ConvertFile(ep->d_name);
					}
					else if ((time(0) - st.st_mtime) > 120)
					{
						sprintf(TempName, "/tmp/%s", ep->d_name);
						LogMessage("Removing %s\n", TempName);
						remove(TempName);
					}
				}
			}
		}
		(void) closedir (dp);
		
		sleep(5);
	}
}
예제 #5
0
파일: convmain.cpp 프로젝트: Akehi/RTKLIB
// callback on button-convert -----------------------------------------------
void __fastcall TMainWindow::BtnConvertClick(TObject *Sender)
{
    ConvertFile();
}
예제 #6
0
int convertMain (int argc, char * const argv[])
{
#if TARGET_OS_WIN32
  	QTLicenseRef aacEncoderLicenseRef = nil;
  	QTLicenseRef amrEncoderLicenseRef = nil;
	OSErr localerr;
#endif
	int result = 0;
	CFURLRef inputFileURL = NULL;
	CFURLRef outputFileURL = NULL;
    
#if TARGET_OS_WIN32
	InitializeQTML(0L);
	{
		OSErr localerr;
		const char *licenseDesc = "AAC Encode License Verification";
		const char *amrLicenseDesc = "AMR Encode License Verification";
        
		localerr = QTRequestLicensedTechnology("com.apple.quicktimeplayer","com.apple.aacencoder",
                                               (void *)licenseDesc,strlen(licenseDesc),&aacEncoderLicenseRef);
		localerr = QTRequestLicensedTechnology("com.apple.quicktimeplayer","1D07EB75-3D5E-4DA6-B749-D497C92B06D8",
                                               (void *)amrLicenseDesc,strlen(amrLicenseDesc),&amrEncoderLicenseRef);
	}
#endif
	
	try {
		OSType format = 0;
		Float64 sampleRate = 0;
		AudioFileTypeID outputFileType = kAudioFileCAFType;
 	  	UInt32 outputBitRate = 0;
		UInt32 outputBitDepth = 0;
		
		ParseArgs (argc, argv, format, sampleRate, outputFileType, inputFileURL, outputFileURL, outputBitDepth, outputBitRate);
        
        //	printf ("args:%4.4s, sample rate:%.1f, outputFileType: %4.4s\n", (char*)&format, sampleRate, (char*)&outputFileType);
        
		CAStreamBasicDescription inputFormat;
		CAStreamBasicDescription outputFormat;
		ConstructOutputFormatFromArgs (inputFileURL, outputFileType, format, sampleRate, inputFormat, outputBitDepth, outputFormat);
		
		printf ("Source File format:\n\t"); inputFormat.Print();
		printf ("Dest File format:\n\t"); outputFormat.Print();
		
		result = ConvertFile (inputFileURL, inputFormat, outputFileURL, outputFileType, outputFormat, outputBitRate);
        
		CFStringRef path = CFURLCopyPath(outputFileURL);
		printf("done: "); fflush(stdout); CFShow(path);
		if (path) CFRelease(path);
        
	} catch (CAXException e) {
		char buf[256];
		fprintf(stderr, "Error in: %s\nException thrown: %s\n", e.mOperation, e.FormatError(buf));
		result = 1;
	} catch (...) {
		fprintf(stderr, "Unspecified exception\n");
		result = 1;
	}
	if (inputFileURL) CFRelease(inputFileURL);
	if (outputFileURL) CFRelease(outputFileURL);
	
#if TARGET_OS_WIN32
	TerminateQTML();
 	if (aacEncoderLicenseRef)
	{
		localerr = QTReleaseLicensedTechnology(aacEncoderLicenseRef);
		aacEncoderLicenseRef = nil;
	}
	if(amrEncoderLicenseRef)
	{
		localerr = QTReleaseLicensedTechnology(amrEncoderLicenseRef);
		amrEncoderLicenseRef = nil;
	}
#endif
	return result;
}