Usage of EXIT_SUCCESS/FAILURE instead of hard-coded values

This commit is contained in:
Luis Díaz Más 2022-03-22 15:36:29 +01:00
parent 5b0418d136
commit c5c315b6e7
32 changed files with 224 additions and 216 deletions

View File

@ -131,7 +131,7 @@ int main(int argc, char* const argv[]) {
return 0;
}
int returnCode = 0;
int returnCode = EXIT_SUCCESS;
try {
// Create the required action class
@ -141,7 +141,7 @@ int main(int argc, char* const argv[]) {
auto filesCount = params.files_.size();
if (params.action_ & Action::extract && params.target_ & Params::ctStdInOut && filesCount > 1) {
std::cerr << params.progname() << ": " << _("Only one file is allowed when extracting to stdout") << std::endl;
returnCode = 1;
returnCode = EXIT_FAILURE;
} else {
int w = filesCount > 9 ? filesCount > 99 ? 3 : 2 : 1;
int n = 1;
@ -153,7 +153,7 @@ int main(int argc, char* const argv[]) {
}
task->setBinary(params.binary_);
int ret = task->run(file);
if (returnCode == 0)
if (returnCode == EXIT_SUCCESS)
returnCode = ret;
}
@ -162,7 +162,7 @@ int main(int argc, char* const argv[]) {
}
} catch (const std::exception& exc) {
std::cerr << "Uncaught exception: " << exc.what() << std::endl;
returnCode = 1;
returnCode = EXIT_FAILURE;
}
// Return a positive one byte code for better consistency across platforms

View File

@ -15,7 +15,7 @@ int main(int argc, char* const argv[]) {
if (argc != 2) {
std::cout << "Usage: " << argv[0] << " file\n";
return 1;
return EXIT_FAILURE;
}
std::string file(argv[1]);
@ -105,9 +105,9 @@ int main(int argc, char* const argv[]) {
image->setExifData(exifData);
image->writeMetadata();
return 0;
return EXIT_SUCCESS;
} catch (Exiv2::Error& e) {
std::cout << "Caught Exiv2 exception '" << e << "'\n";
return -1;
return EXIT_FAILURE;
}
}

View File

@ -81,7 +81,7 @@ int main(int argc, const char** argv) {
if (argc < 2) {
std::cout << "Usage: " << argv[0] << " url {-http1_0}" << std::endl;
return 1;
return EXIT_FAILURE;
}
std::string url(argv[1]);
Exiv2::Protocol prot = Exiv2::fileProtocol(url);
@ -107,14 +107,14 @@ int main(int argc, const char** argv) {
}
} catch (const Exiv2::Error& e) {
std::cout << "Error: '" << e << "'" << std::endl;
return -1;
return EXIT_FAILURE;
}
if (!isOk)
std::cout << "The protocol is unsupported." << std::endl;
else
std::cout << "OK." << std::endl;
return 0;
return EXIT_SUCCESS;
}
// That's all Folks!

View File

@ -15,7 +15,7 @@ int main(int argc, char* const argv[]) {
if (argc != 2) {
std::cout << "Usage: " << argv[0] << " file\n";
return 1;
return EXIT_FAILURE;
}
auto image = Exiv2::ImageFactory::open(argv[1]);
@ -31,9 +31,9 @@ int main(int argc, char* const argv[]) {
image->setExifData(exifData);
image->writeMetadata();
return 0;
return EXIT_SUCCESS;
} catch (Exiv2::Error& e) {
std::cout << "Caught Exiv2 exception '" << e << "'\n";
return -1;
return EXIT_FAILURE;
}
}

View File

@ -57,7 +57,7 @@ int main(int argc, char** argv) {
if (argc != 2) {
std::cout << "Usage: " << argv[0] << " file\n";
return 1;
return EXIT_FAILURE;
}
auto image = Exiv2::ImageFactory::open(argv[1]);
@ -75,9 +75,9 @@ int main(int argc, char** argv) {
}
}
return 0;
return EXIT_SUCCESS;
} catch (Exiv2::Error& e) {
std::cout << "Caught Exiv2 exception '" << e << "'\n";
return -1;
return EXIT_FAILURE;
}
}

View File

@ -16,7 +16,7 @@ int main(int argc, char* const argv[]) {
if (argc != 2) {
std::cout << "Usage: " << argv[0] << " file\n";
return 1;
return EXIT_FAILURE;
}
auto image = Exiv2::ImageFactory::open(argv[1]);
@ -44,9 +44,9 @@ int main(int argc, char* const argv[]) {
image->writeMetadata();
return 0;
return EXIT_SUCCESS;
} catch (Exiv2::Error& e) {
std::cout << "Caught Exiv2 exception '" << e << "'\n";
return -1;
return EXIT_FAILURE;
}
}

View File

@ -18,7 +18,7 @@ int main(int argc, char* const argv[]) {
if (argc != 2) {
std::cout << "Usage: " << argv[0] << " file\n";
return 1;
return EXIT_FAILURE;
}
std::string file(argv[1]);
@ -84,10 +84,10 @@ int main(int argc, char* const argv[]) {
write(file, ed4);
print(file);
return 0;
return EXIT_SUCCESS;
} catch (Exiv2::Error& e) {
std::cout << "Caught Exiv2 exception '" << e << "'\n";
return -1;
return EXIT_FAILURE;
}
}

View File

@ -23,10 +23,10 @@ int main(int argc, char* const argv[]) {
const char* prog = argv[0];
if (argc == 1) {
std::cout << "Usage: " << prog << " [ [--lint] path | --version | --version-test ]" << std::endl;
return 1;
return EXIT_FAILURE;
}
int rc = 0;
int rc = EXIT_SUCCESS;
const char* file = argv[1];
bool bLint = strcmp(file, "--lint") == 0 && argc == 3;
if (bLint)
@ -110,6 +110,6 @@ int main(int argc, char* const argv[]) {
return rc;
} catch (Exiv2::Error& e) {
std::cout << "Caught Exiv2 exception '" << e.what() << "'\n";
return -1;
return EXIT_FAILURE;
}
}

View File

@ -14,7 +14,7 @@ int main(int argc, char* const argv[]) {
if (argc != 3) {
std::cerr << "Usage: " << argv[0] << " file key\n";
return 1;
return EXIT_FAILURE;
}
const char* file = argv[1];
@ -26,18 +26,18 @@ int main(int argc, char* const argv[]) {
if (exifData.empty()) {
std::cerr << "no metadata found in file " << file << std::endl;
exit(2);
return EXIT_FAILURE;
}
try {
std::cout << exifData[key] << std::endl;
} catch (Exiv2::Error& e) {
std::cerr << "Caught Exiv2 exception '" << e << "'" << std::endl;
exit(3);
return EXIT_FAILURE;
} catch (...) {
std::cerr << "Caught a cold!" << std::endl;
exit(4);
return EXIT_FAILURE;
}
return 0;
return EXIT_SUCCESS;
}

View File

@ -252,7 +252,7 @@ int main(int argc, char* const argv[]) {
if (argc < 2 || argc > 3) {
std::cout << "Usage: " << argv[0] << " [-option] file" << std::endl;
std::cout << "Option: all | exif | iptc | xmp | filesystem" << std::endl;
return 1;
return EXIT_FAILURE;
}
const char* path = argv[argc - 1];
const char* opt = argc == 3 ? argv[1] : "-all";

View File

@ -114,5 +114,5 @@ int main(int argc, char** const argv) {
Params params;
params.getopt(argc, argv);
return 0;
return EXIT_SUCCESS;
}

View File

@ -19,13 +19,12 @@ int main() {
Exiv2::enableBMFF();
#endif
int result = 0;
const char* ini = "ini-test.ini";
Exiv2::INIReader reader(ini);
if (reader.ParseError() < 0) {
std::cerr << "Can't load '" << ini << "'" << std::endl;
result = 1;
return EXIT_FAILURE;
} else {
std::cout << "Config loaded from : '" << ini << "' "
<< "version=" << reader.GetInteger("protocol", "version", -1)
@ -37,5 +36,5 @@ int main() {
<< ", 170=" << reader.Get("canon", "170", "UNDEFINED") << std::endl;
}
return result;
return EXIT_SUCCESS;
}

View File

@ -92,7 +92,7 @@ int main(int argc, char* const argv[]) {
// Make sure they are all the same size
if (fileIn.size() != memIo1.size() || memIo1.size() != fileOut1.size()) {
std::cerr << argv[0] << ": Sizes do not match\n";
return 1;
return EXIT_FAILURE;
}
// Read writereadseek test on MemIo
@ -134,10 +134,10 @@ int main(int argc, char* const argv[]) {
}
}
return 0;
return EXIT_SUCCESS;
} catch (Exiv2::Error& e) {
std::cerr << "Caught Exiv2 exception '" << e << "'\n";
return 20;
return EXIT_FAILURE;
}
}

View File

@ -14,7 +14,7 @@ int main(int argc, char* const argv[]) try {
if (argc != 2) {
std::cout << "Usage: " << argv[0] << " file\n";
return 1;
return EXIT_FAILURE;
}
std::string file(argv[1]);
@ -41,8 +41,8 @@ int main(int argc, char* const argv[]) try {
image->setIptcData(iptcData);
image->writeMetadata();
return 0;
return EXIT_SUCCESS;
} catch (Exiv2::Error& e) {
std::cout << "Caught Exiv2 exception '" << e << "'\n";
return -1;
return EXIT_FAILURE;
}

View File

@ -14,7 +14,7 @@ int main(int argc, char* const argv[]) try {
if (argc != 2) {
std::cout << "Usage: " << argv[0] << " file\n";
return 1;
return EXIT_FAILURE;
}
auto image = Exiv2::ImageFactory::open(argv[1]);
@ -35,11 +35,11 @@ int main(int argc, char* const argv[]) try {
<< std::setfill(' ') << std::right << md->count() << " " << std::dec << md->value() << std::endl;
}
return 0;
return EXIT_SUCCESS;
} catch (Exiv2::Error& e) {
std::cout << "Caught Exiv2 exception '" << e << "'\n";
return 1;
return EXIT_FAILURE;
} catch (const std::exception& e) {
std::cout << "Caught exception: '" << e.what() << "'\n";
return 1;
return EXIT_FAILURE;
}

View File

@ -24,7 +24,7 @@ int main(int argc, char* const argv[]) {
if (argc != 2) {
std::cout << "Usage: " << argv[0] << " image\n";
std::cout << "Commands read from stdin.\n";
return 1;
return EXIT_FAILURE;
}
auto image = ImageFactory::open(argv[1]);
@ -41,10 +41,10 @@ int main(int argc, char* const argv[]) {
// Save any changes
image->writeMetadata();
return 0;
return EXIT_SUCCESS;
} catch (Error& e) {
std::cout << "Caught Exiv2 exception '" << e << "'\n";
return -1;
return EXIT_FAILURE;
}
}

View File

@ -16,7 +16,7 @@ int main(int argc, char* const argv[]) {
if (argc != 3) {
std::cout << "Usage: " << argv[0] << " image datafile\n";
return 1;
return EXIT_FAILURE;
}
std::string file(argv[1]);
std::string data(argv[2]);
@ -69,9 +69,9 @@ int main(int argc, char* const argv[]) {
// Set Iptc data and write it to the file
image->writeMetadata();
return 0;
return EXIT_SUCCESS;
} catch (Exiv2::Error& e) {
std::cout << "Caught Exiv2 exception '" << e << "'\n";
return -1;
return EXIT_FAILURE;
}
}

View File

@ -55,13 +55,13 @@ int main(int argc, char* const argv[]) {
writeImg->writeMetadata();
} catch (const Exiv2::Error&) {
std::cerr << params.progname() << ": Could not write metadata to (" << params.write_ << ")\n";
return 8;
return EXIT_FAILURE;
}
return 0;
return EXIT_SUCCESS;
} catch (Exiv2::Error& e) {
std::cerr << "Caught Exiv2 exception '" << e << "'\n";
return 10;
return EXIT_FAILURE;
}
}

View File

@ -7,36 +7,39 @@
using namespace Exiv2;
int main(int argc, char* const argv[]) try {
Exiv2::XmpParser::initialize();
::atexit(Exiv2::XmpParser::terminate);
int main(int argc, char* const argv[]) {
try {
Exiv2::XmpParser::initialize();
::atexit(Exiv2::XmpParser::terminate);
#ifdef EXV_ENABLE_BMFF
Exiv2::enableBMFF();
Exiv2::enableBMFF();
#endif
if (argc != 2) {
std::cout << "Usage: " << argv[0] << " file\n";
return 1;
}
const char* path = argv[1];
if (argc != 2) {
std::cout << "Usage: " << argv[0] << " file\n";
return EXIT_FAILURE;
}
const char* path = argv[1];
FileIo file(path);
// Open the file in read mode
if (file.open("rb") != 0) {
throw Error(ErrorCode::kerFileOpenFailed, path, "rb", strError());
}
// Map it to memory
const Exiv2::byte* pData = file.mmap();
DataBuf buf(file.size());
// Read from the memory mapped region
buf.copyBytes(0, pData, buf.size());
// Reopen file in write mode and write to it
file.write(buf.c_data(), buf.size());
// Read from the mapped region again
buf.copyBytes(0, pData, buf.size());
file.close();
FileIo file(path);
// Open the file in read mode
if (file.open("rb") != 0) {
throw Error(ErrorCode::kerFileOpenFailed, path, "rb", strError());
}
// Map it to memory
const Exiv2::byte* pData = file.mmap();
DataBuf buf(file.size());
// Read from the memory mapped region
buf.copyBytes(0, pData, buf.size());
// Reopen file in write mode and write to it
file.write(buf.c_data(), buf.size());
// Read from the mapped region again
buf.copyBytes(0, pData, buf.size());
file.close();
return 0;
} catch (const Error& e) {
std::cout << e << "\n";
return EXIT_SUCCESS;
} catch (const Error& e) {
std::cout << e << "\n";
return EXIT_FAILURE;
}
}

View File

@ -14,7 +14,7 @@ int main(int argc, char* const argv[]) {
try {
if (argc != 2) {
std::cout << "Usage: " << argv[0] << " file\n";
return 1;
return EXIT_FAILURE;
}
auto image = Exiv2::ImageFactory::open(argv[1]);
@ -43,9 +43,9 @@ int main(int argc, char* const argv[]) {
file.close();
}
return 0;
return EXIT_SUCCESS;
} catch (Exiv2::Error& e) {
std::cout << "Caught Exiv2 exception '" << e << "'\n";
return -1;
return EXIT_FAILURE;
}
}

View File

@ -17,12 +17,12 @@ int main(int argc, char* const argv[]) {
if (argc != 2) {
std::cout << "Usage: " << argv[0] << " file\n";
return 1;
return EXIT_FAILURE;
}
std::ifstream file(argv[1]);
if (!file) {
std::cerr << *argv[1] << ": Failed to open file for reading\n";
return 1;
return EXIT_FAILURE;
}
std::string line;
while (std::getline(file, line)) {
@ -38,5 +38,5 @@ int main(int argc, char* const argv[]) {
}
}
return 0;
return EXIT_SUCCESS;
}

View File

@ -14,7 +14,7 @@ int main(int argc, char* const argv[]) try {
if (argc != 2) {
std::cout << "Usage: " << argv[0] << " file\n";
return 1;
return EXIT_FAILURE;
}
std::string filename(argv[1]);
@ -35,8 +35,8 @@ int main(int argc, char* const argv[]) try {
// Cleanup
Exiv2::XmpParser::terminate();
return 0;
return EXIT_SUCCESS;
} catch (Exiv2::Error& e) {
std::cout << "Caught Exiv2 exception '" << e << "'\n";
return -1;
return EXIT_FAILURE;
}

View File

@ -7,96 +7,99 @@
#include <iomanip>
#include <iostream>
int main(int argc, char* const argv[]) try {
Exiv2::XmpParser::initialize();
::atexit(Exiv2::XmpParser::terminate);
int main(int argc, char* const argv[]) {
try {
Exiv2::XmpParser::initialize();
::atexit(Exiv2::XmpParser::terminate);
#ifdef EXV_ENABLE_BMFF
Exiv2::enableBMFF();
Exiv2::enableBMFF();
#endif
if (argc < 2) {
std::cout << "Usage: " << argv[0] << " file {--nocurl | --curl}\n\n";
return 1;
if (argc < 2) {
std::cout << "Usage: " << argv[0] << " file {--nocurl | --curl}\n\n";
return EXIT_FAILURE;
}
bool useCurlFromExiv2TestApps = true;
for (int a = 1; a < argc; a++) {
std::string arg(argv[a]);
if (arg == "--nocurl")
useCurlFromExiv2TestApps = false;
else if (arg == "--curl")
useCurlFromExiv2TestApps = true;
}
std::string file(argv[1]);
// set/add metadata
std::cout << "Modify the metadata ...\n";
Exiv2::ExifData exifData;
exifData["Exif.Photo.UserComment"] = "Hello World"; // AsciiValue
exifData["Exif.Image.Software"] = "Exiv2"; // AsciiValue
exifData["Exif.Image.Copyright"] = "Exiv2"; // AsciiValue
exifData["Exif.Image.Make"] = "Canon"; // AsciiValue
exifData["Exif.Canon.OwnerName"] = "Tuan"; // UShortValue
exifData["Exif.CanonCs.LensType"] = uint16_t(65535); // LongValue
Exiv2::Value::UniquePtr v = Exiv2::Value::create(Exiv2::asciiString);
v->read("2013:06:09 14:30:30");
Exiv2::ExifKey key("Exif.Image.DateTime");
exifData.add(key, v.get());
auto writeTest = Exiv2::ImageFactory::open(file, useCurlFromExiv2TestApps);
writeTest->setExifData(exifData);
writeTest->writeMetadata();
// read the result to make sure everything fine
std::cout << "Print out the new metadata ...\n";
auto readTest = Exiv2::ImageFactory::open(file, useCurlFromExiv2TestApps);
readTest->readMetadata();
Exiv2::ExifData& exifReadData = readTest->exifData();
if (exifReadData.empty()) {
std::string error(argv[1]);
error += ": No Exif data found in the file";
throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, error);
}
auto end = exifReadData.end();
for (auto i = exifReadData.begin(); i != end; ++i) {
const char* tn = i->typeName();
std::cout << std::setw(44) << std::setfill(' ') << std::left << i->key() << " "
<< "0x" << std::setw(4) << std::setfill('0') << std::right << std::hex << i->tag() << " "
<< std::setw(9) << std::setfill(' ') << std::left << (tn ? tn : "Unknown") << " " << std::dec
<< std::setw(3) << std::setfill(' ') << std::right << i->count() << " " << std::dec << i->value()
<< "\n";
}
// del, reset the metadata
std::cout << "Reset ...\n";
exifReadData["Exif.Photo.UserComment"] = "Have a nice day"; // AsciiValue
exifReadData["Exif.Image.Software"] = "Exiv2.org"; // AsciiValue
exifReadData["Exif.Image.Copyright"] = "Exiv2.org"; // AsciiValue
key = Exiv2::ExifKey("Exif.Image.Make");
auto pos = exifReadData.findKey(key);
if (pos == exifReadData.end())
throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, "Exif.Image.Make not found");
exifReadData.erase(pos);
key = Exiv2::ExifKey("Exif.Image.DateTime");
pos = exifReadData.findKey(key);
if (pos == exifReadData.end())
throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, "Exif.Image.DateTime not found");
exifReadData.erase(pos);
key = Exiv2::ExifKey("Exif.Canon.OwnerName");
pos = exifReadData.findKey(key);
if (pos == exifReadData.end())
throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, "Exif.Canon.OwnerName not found");
exifReadData.erase(pos);
key = Exiv2::ExifKey("Exif.CanonCs.LensType");
pos = exifReadData.findKey(key);
if (pos == exifReadData.end())
throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, "Exif.CanonCs.LensType not found");
exifReadData.erase(pos);
readTest->setExifData(exifReadData);
readTest->writeMetadata();
return EXIT_SUCCESS;
} catch (Exiv2::Error& e) {
std::cout << "Caught Exiv2 exception '" << e << "'\n";
return EXIT_FAILURE;
}
bool useCurlFromExiv2TestApps = true;
for (int a = 1; a < argc; a++) {
std::string arg(argv[a]);
if (arg == "--nocurl")
useCurlFromExiv2TestApps = false;
else if (arg == "--curl")
useCurlFromExiv2TestApps = true;
}
std::string file(argv[1]);
// set/add metadata
std::cout << "Modify the metadata ...\n";
Exiv2::ExifData exifData;
exifData["Exif.Photo.UserComment"] = "Hello World"; // AsciiValue
exifData["Exif.Image.Software"] = "Exiv2"; // AsciiValue
exifData["Exif.Image.Copyright"] = "Exiv2"; // AsciiValue
exifData["Exif.Image.Make"] = "Canon"; // AsciiValue
exifData["Exif.Canon.OwnerName"] = "Tuan"; // UShortValue
exifData["Exif.CanonCs.LensType"] = uint16_t(65535); // LongValue
Exiv2::Value::UniquePtr v = Exiv2::Value::create(Exiv2::asciiString);
v->read("2013:06:09 14:30:30");
Exiv2::ExifKey key("Exif.Image.DateTime");
exifData.add(key, v.get());
auto writeTest = Exiv2::ImageFactory::open(file, useCurlFromExiv2TestApps);
writeTest->setExifData(exifData);
writeTest->writeMetadata();
// read the result to make sure everything fine
std::cout << "Print out the new metadata ...\n";
auto readTest = Exiv2::ImageFactory::open(file, useCurlFromExiv2TestApps);
readTest->readMetadata();
Exiv2::ExifData& exifReadData = readTest->exifData();
if (exifReadData.empty()) {
std::string error(argv[1]);
error += ": No Exif data found in the file";
throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, error);
}
auto end = exifReadData.end();
for (auto i = exifReadData.begin(); i != end; ++i) {
const char* tn = i->typeName();
std::cout << std::setw(44) << std::setfill(' ') << std::left << i->key() << " "
<< "0x" << std::setw(4) << std::setfill('0') << std::right << std::hex << i->tag() << " " << std::setw(9)
<< std::setfill(' ') << std::left << (tn ? tn : "Unknown") << " " << std::dec << std::setw(3)
<< std::setfill(' ') << std::right << i->count() << " " << std::dec << i->value() << "\n";
}
// del, reset the metadata
std::cout << "Reset ...\n";
exifReadData["Exif.Photo.UserComment"] = "Have a nice day"; // AsciiValue
exifReadData["Exif.Image.Software"] = "Exiv2.org"; // AsciiValue
exifReadData["Exif.Image.Copyright"] = "Exiv2.org"; // AsciiValue
key = Exiv2::ExifKey("Exif.Image.Make");
auto pos = exifReadData.findKey(key);
if (pos == exifReadData.end())
throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, "Exif.Image.Make not found");
exifReadData.erase(pos);
key = Exiv2::ExifKey("Exif.Image.DateTime");
pos = exifReadData.findKey(key);
if (pos == exifReadData.end())
throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, "Exif.Image.DateTime not found");
exifReadData.erase(pos);
key = Exiv2::ExifKey("Exif.Canon.OwnerName");
pos = exifReadData.findKey(key);
if (pos == exifReadData.end())
throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, "Exif.Canon.OwnerName not found");
exifReadData.erase(pos);
key = Exiv2::ExifKey("Exif.CanonCs.LensType");
pos = exifReadData.findKey(key);
if (pos == exifReadData.end())
throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, "Exif.CanonCs.LensType not found");
exifReadData.erase(pos);
readTest->setExifData(exifReadData);
readTest->writeMetadata();
return 0;
} catch (Exiv2::Error& e) {
std::cout << "Caught Exiv2 exception '" << e << "'\n";
return -1;
}

View File

@ -81,9 +81,9 @@ int main() {
std::cout << std::endl;
} catch (Exiv2::Error& e) {
std::cout << "Caught Exiv2 exception '" << e << "'\n";
return -1;
return EXIT_FAILURE;
}
}
return 0;
return EXIT_SUCCESS;
}

View File

@ -15,25 +15,28 @@ void print(const ExifData& exifData);
void mini1(const char* path);
void mini9(const char* path);
int main(int argc, char* const argv[]) try {
Exiv2::XmpParser::initialize();
::atexit(Exiv2::XmpParser::terminate);
int main(int argc, char* const argv[]) {
try {
Exiv2::XmpParser::initialize();
::atexit(Exiv2::XmpParser::terminate);
#ifdef EXV_ENABLE_BMFF
Exiv2::enableBMFF();
Exiv2::enableBMFF();
#endif
if (argc != 2) {
std::cout << "Usage: " << argv[0] << " file\n";
return 1;
if (argc != 2) {
std::cout << "Usage: " << argv[0] << " file\n";
return EXIT_FAILURE;
}
const char* path = argv[1];
mini1(path);
mini9(path);
return EXIT_SUCCESS;
} catch (const Error& e) {
std::cout << e << "\n";
return EXIT_FAILURE;
}
const char* path = argv[1];
mini1(path);
mini9(path);
return 0;
} catch (const Error& e) {
std::cout << e << "\n";
}
void mini1(const char* path) {

View File

@ -26,7 +26,7 @@ int main(int argc, char* const argv[]) {
if (argc != 3) {
std::cout << "Usage: write-test file case\n\n"
<< "where case is an integer between 1 and 11\n";
return 1;
return EXIT_FAILURE;
}
std::string testFile = argv[1];
@ -34,7 +34,7 @@ int main(int argc, char* const argv[]) {
int testNo = 0;
iss >> testNo;
int rc = 0;
int rc = EXIT_SUCCESS;
switch (testNo) {
case 1:
std::cerr << "Case 1: ";
@ -101,14 +101,14 @@ int main(int argc, char* const argv[]) {
default:
std::cout << "Usage: exiftest file case\n\n"
<< "where case is an integer between 1 and 11\n";
rc = 1;
rc = EXIT_FAILURE;
break;
}
return rc;
} catch (Error& e) {
std::cerr << "Caught Exiv2 exception '" << e << "'\n";
return 1;
return EXIT_FAILURE;
}
}

View File

@ -18,7 +18,7 @@ int main(int argc, char* const argv[]) {
try {
if (argc != 2) {
std::cout << "Usage: " << argv[0] << " file\n";
return 1;
return EXIT_FAILURE;
}
std::string file(argv[1]);
@ -186,10 +186,10 @@ int main(int argc, char* const argv[]) {
write(file, ed7);
print(file);
return 0;
return EXIT_SUCCESS;
} catch (Exiv2::Error& e) {
std::cout << "Caught Exiv2 exception '" << e << "'\n";
return -1;
return EXIT_FAILURE;
}
}

View File

@ -14,7 +14,7 @@ int main(int argc, char* const argv[]) {
try {
if (argc != 2) {
std::cout << "Usage: " << argv[0] << " file\n";
return 1;
return EXIT_FAILURE;
}
auto image = Exiv2::ImageFactory::open(argv[1]);
@ -28,9 +28,9 @@ int main(int argc, char* const argv[]) {
}
std::cout << xmpPacket << "\n";
return 0;
return EXIT_SUCCESS;
} catch (Exiv2::Error& e) {
std::cout << "Caught Exiv2 exception '" << e << "'\n";
return -1;
return EXIT_FAILURE;
}
}

View File

@ -13,7 +13,7 @@ int main(int argc, char* const argv[]) try {
if (argc != 2) {
std::cout << "Usage: " << argv[0] << " file\n";
return 1;
return EXIT_FAILURE;
}
Exiv2::DataBuf buf = Exiv2::readFile(argv[1]);
@ -36,8 +36,8 @@ int main(int argc, char* const argv[]) try {
<< md.count() << " " << std::dec << md.toString() << std::endl;
}
Exiv2::XmpParser::terminate();
return 0;
return EXIT_SUCCESS;
} catch (Exiv2::Error& e) {
std::cout << "Caught Exiv2 exception '" << e << "'\n";
return -1;
return EXIT_FAILURE;
}

View File

@ -13,7 +13,7 @@ int main(int argc, char* const argv[]) try {
if (argc != 2) {
std::cout << "Usage: " << argv[0] << " file\n";
return 1;
return EXIT_FAILURE;
}
std::string filename(argv[1]);
Exiv2::DataBuf buf = Exiv2::readFile(filename);
@ -51,8 +51,8 @@ int main(int argc, char* const argv[]) try {
throw Exiv2::Error(Exiv2::ErrorCode::kerCallFailed, filename, Exiv2::strError(), "FileIo::write");
}
Exiv2::XmpParser::terminate();
return 0;
return EXIT_SUCCESS;
} catch (Exiv2::Error& e) {
std::cout << "Caught Exiv2 exception '" << e << "'\n";
return -1;
return EXIT_FAILURE;
}

View File

@ -16,7 +16,7 @@ int main(int argc, char** argv) {
try {
if (argc != 2) {
std::cout << "Usage: " << argv[0] << " file\n";
return 1;
return EXIT_FAILURE;
}
auto image = Exiv2::ImageFactory::open(argv[1]);
@ -42,9 +42,9 @@ int main(int argc, char** argv) {
Exiv2::XmpParser::terminate();
return 0;
return EXIT_SUCCESS;
} catch (Exiv2::Error& e) {
std::cout << "Caught Exiv2 exception '" << e << "'\n";
return -1;
return EXIT_FAILURE;
}
}

View File

@ -202,8 +202,8 @@ int main() try {
// Cleanup
Exiv2::XmpParser::terminate();
return 0;
return EXIT_SUCCESS;
} catch (Exiv2::Error &e) {
std::cout << "Caught Exiv2 exception '" << e << "'\n";
return -1;
return EXIT_FAILURE;
}