-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdbupdate.cpp
43 lines (34 loc) · 1.75 KB
/
dbupdate.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <iostream>
#include "lensfun_dbupdate.h"
//print error and exit:
void err(std::string msg)
{
printf("Error: %s\n",msg.c_str());
exit(0);
}
int main(int argc, char ** argv)
{
lf_db_return result;
if (argc == 2 && std::string(argv[1]) == "help") {
std::cout << "\nUsage: dbupdate version [localpath] [url]\n\n";
std::cout << "Where:\n";
std::cout << "\tversion:\tlensfun database version to be retrieved.\n\t\t\tDefault=1\n\n";
std::cout << "\tlocalpath:\talready-existing path in which to install version_x directory\n\t\t\tcontaining the lensfun XMl files and timestamp.txt.\n\t\t\tDefault=cwd\n\n";
std::cout << "\turl:\t\tURL of the lensfun database repository.\n\t\t\tDefault=http://lensfun.sourceforge.net/db/\n\n";
std::cout << "Note 1: using any of the above parameters requires specifying the preceding parameters.\n";
exit(EXIT_SUCCESS);
}
if (argc == 1) {
std::cout << "dbupdate needs a database version." << std::endl;
exit(EXIT_FAILURE);
}
else if (argc == 2) result = lensfun_dbupdate(atoi(argv[1])); //version
else if (argc == 3) result = lensfun_dbupdate(atoi(argv[1]), std::string(argv[2])); //version + localpath
else if (argc >= 4) result = lensfun_dbupdate(atoi(argv[1]), std::string(argv[2]), std::string(argv[3]));//version + localpath + url
switch (result) {
case LENSFUN_DBUPDATE_OK: std::cout << "database updated" << std::endl; exit(EXIT_SUCCESS); break;
case LENSFUN_DBUPDATE_NOVERSION: std::cout << "no version available" << std::endl; exit(EXIT_FAILURE); break;
case LENSFUN_DBUPDATE_CURRENTVERSION: std::cout << "local database is latest" << std::endl; exit(EXIT_FAILURE); break;
case LENSFUN_DBUPDATE_RETRIEVFAIL: std::cout << "database retrieve failed" << std::endl; exit(EXIT_FAILURE); break;
}
}