예제 #1
0
bool ReadJPEGInfo(const char *filename, JPEG_INFO& info)
{
	EXIFINFO exinfo;
	Exif exif(&exinfo);
	FILE *fp;
	bool success = false;

	memset(&exinfo, 0, sizeof(exinfo));

	if ((fp = fopen(filename, "rb")) != NULL) {
		if (exif.DecodeExif(fp)) {
			info.CameraMake  = exinfo.CameraMake;
			info.CameraModel = exinfo.CameraModel;
			info.Width  	 = exinfo.Width;
			info.Height 	 = exinfo.Height;
			info.Orientation = exinfo.Orientation;
			info.bDateValid  = false;
			info.Comments    = exinfo.Comments;

			AString str = exinfo.DateTime;

			if (str.Valid()) {
				//printf("File '%s' has date '%s'\n", filename, str.str());

				str.Replace(":/-.", "    ");
				
				ADateTime& dt = info.DateTime;
				uint_t word = 0;
				
				uint16_t year   = str.Word(word++);
				uint8_t  month  = str.Word(word++);
				uint8_t  day    = str.Word(word++);
				uint8_t  hour   = str.Word(word++);
				uint8_t  minute = str.Word(word++);
				uint8_t  second = str.Word(word++);

				if ((year >= 1980) && RANGE(month, 1, 12) && RANGE(day, 1, 31) && (hour <= 23) && (minute <= 59) && (second <= 61)) {
					dt.Set(day, month, year, hour, minute, second);
					
					info.bDateValid = true;
				}
			}

			success = true;
		}
		
		fclose(fp);
	}

	return success;
}
예제 #2
0
/*--------------------------------------------------------------------------------*/
AString PostgresDatabase::GetColumnType(const AString& column) const
{
	AString ctype = column.Word(1);
	AString type;

	if ((type = ConvertSimpleType(ctype)).Empty())
	{
		if	    (ctype == "references")   	type.printf("integer references %s", column.Word(2).str());					                        // reference to another table
		else if	(ctype == "references64")   type.printf("bigint references %s", column.Word(2).str());						                    // reference to another table (with 64-bit id)
		else							  	type = ctype;
	}

	return type;
}
예제 #3
0
bool ADVBConfig::ReadReplacementsFile(std::vector<REPLACEMENT>& replacements, const AString& filename) const
{
	AStdFile fp;
	bool success = false;

	if (fp.open(filename)) {
		AString line;

		//printf("Reading replacements file '%s':", filename.str());

		while (line.ReadLn(fp) >= 0) {
			int p = 0;

			if ((line.Word(0)[0] != ';') && ((p = line.Pos("=")) >= 0)) {
				REPLACEMENT repl = {
					line.Left(p).Word(0).DeQuotify(),
					line.Mid(p + 1).Word(0).DeQuotify(),
				};

				//printf("Replacement: '%s' -> '%s'", repl.search.str(), repl.replace.str());

				replacements.push_back(repl);
			}
		}

		fp.close();

		success = true;
	}
	else logit("Failed to open replacements file '%s'", filename.str());

	return success;
}
예제 #4
0
/*--------------------------------------------------------------------------------*/
bool PostgresDatabase::CreateTable(const AString& name, const AString& columns)
{
	AString sql;
	SQLQuery *query = NULL;
	uint_t i, n = columns.CountColumns();

	sql.printf("create table %s (", name.str());
	for (i = 0; i < n; i++) {
		AString column = columns.Column(i);
		if (i > 0) sql.printf(", ");
		sql.printf("%s %s", column.Word(0).str(), GetColumnType(column).str());
	}
	sql.printf(")");

	if ((query = RunQuery(sql)) != NULL) {
		bool success = query->GetResult();
		delete query;
		return success;
	}

	return false;
}