forked from soutade/libgourou
Add global option -D to utils, allowing to specify .adept directory instead of every single files. WARNING : -D has been changed by -d in adept_loan_mgt !
This commit is contained in:
parent
f65e8cd9eb
commit
e4bd73c03d
|
@ -40,7 +40,7 @@
|
||||||
#define ACS_SERVER "http://adeactivate.adobe.com/adept"
|
#define ACS_SERVER "http://adeactivate.adobe.com/adept"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define LIBGOUROU_VERSION "0.8"
|
#define LIBGOUROU_VERSION "0.8.1"
|
||||||
|
|
||||||
namespace gourou
|
namespace gourou
|
||||||
{
|
{
|
||||||
|
|
|
@ -184,8 +184,9 @@ static void usage(const char* cmd)
|
||||||
{
|
{
|
||||||
std::cout << "Download EPUB file from ACSM request file" << std::endl;
|
std::cout << "Download EPUB file from ACSM request file" << std::endl;
|
||||||
|
|
||||||
std::cout << "Usage: " << basename((char*)cmd) << " [(-d|--device-file) device.xml] [(-a|--activation-file) activation.xml] [(-k|--device-key-file) devicesalt] [(-O|--output-dir) dir] [(-o|--output-file) output(.epub|.pdf|.der)] [(-r|--resume)] [(-v|--verbose)] [(-h|--help)] (-f|--acsm-file) file.acsm|(-e|--export-private-key)" << std::endl << std::endl;
|
std::cout << "Usage: " << basename((char*)cmd) << " [(-D|--adept-directory) dir] [(-d|--device-file) device.xml] [(-a|--activation-file) activation.xml] [(-k|--device-key-file) devicesalt] [(-O|--output-dir) dir] [(-o|--output-file) output(.epub|.pdf|.der)] [(-r|--resume)] [(-v|--verbose)] [(-h|--help)] (-f|--acsm-file) file.acsm|(-e|--export-private-key)" << std::endl << std::endl;
|
||||||
|
|
||||||
|
std::cout << " " << "-D|--adept-directory" << "\t" << ".adept directory that must contains device.xml, activation.xml and devicesalt" << std::endl;
|
||||||
std::cout << " " << "-d|--device-file" << "\t" << "device.xml file from eReader" << std::endl;
|
std::cout << " " << "-d|--device-file" << "\t" << "device.xml file from eReader" << std::endl;
|
||||||
std::cout << " " << "-a|--activation-file" << "\t" << "activation.xml file from eReader" << std::endl;
|
std::cout << " " << "-a|--activation-file" << "\t" << "activation.xml file from eReader" << std::endl;
|
||||||
std::cout << " " << "-k|--device-key-file" << "\t" << "private device key file (eg devicesalt/devkey.bin) from eReader" << std::endl;
|
std::cout << " " << "-k|--device-key-file" << "\t" << "private device key file (eg devicesalt/devkey.bin) from eReader" << std::endl;
|
||||||
|
@ -209,6 +210,7 @@ static void usage(const char* cmd)
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
int c, ret = -1;
|
int c, ret = -1;
|
||||||
|
std::string _deviceFile, _activationFile, _devicekeyFile;
|
||||||
|
|
||||||
const char** files[] = {&devicekeyFile, &deviceFile, &activationFile};
|
const char** files[] = {&devicekeyFile, &deviceFile, &activationFile};
|
||||||
int verbose = gourou::DRMProcessor::getLogLevel();
|
int verbose = gourou::DRMProcessor::getLogLevel();
|
||||||
|
@ -216,6 +218,7 @@ int main(int argc, char** argv)
|
||||||
while (1) {
|
while (1) {
|
||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
static struct option long_options[] = {
|
static struct option long_options[] = {
|
||||||
|
{"adept-directory", required_argument, 0, 'D' },
|
||||||
{"device-file", required_argument, 0, 'd' },
|
{"device-file", required_argument, 0, 'd' },
|
||||||
{"activation-file", required_argument, 0, 'a' },
|
{"activation-file", required_argument, 0, 'a' },
|
||||||
{"device-key-file", required_argument, 0, 'k' },
|
{"device-key-file", required_argument, 0, 'k' },
|
||||||
|
@ -230,12 +233,20 @@ int main(int argc, char** argv)
|
||||||
{0, 0, 0, 0 }
|
{0, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
c = getopt_long(argc, argv, "d:a:k:O:o:f:ervVh",
|
c = getopt_long(argc, argv, "D:d:a:k:O:o:f:ervVh",
|
||||||
long_options, &option_index);
|
long_options, &option_index);
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
switch (c) {
|
switch (c) {
|
||||||
|
case 'D':
|
||||||
|
_deviceFile = std::string(optarg) + "/device.xml";
|
||||||
|
_activationFile = std::string(optarg) + "/activation.xml";
|
||||||
|
_devicekeyFile = std::string(optarg) + "/devicesalt";
|
||||||
|
deviceFile = _deviceFile.c_str();
|
||||||
|
activationFile = _activationFile.c_str();
|
||||||
|
devicekeyFile = _devicekeyFile.c_str();
|
||||||
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
deviceFile = optarg;
|
deviceFile = optarg;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
|
|
||||||
#define MAX_SIZE_BOOK_NAME 30
|
#define MAX_SIZE_BOOK_NAME 30
|
||||||
|
|
||||||
static char* activationDir = 0;
|
static char* adeptDir = 0;
|
||||||
static const char* deviceFile = "device.xml";
|
static const char* deviceFile = "device.xml";
|
||||||
static const char* activationFile = "activation.xml";
|
static const char* activationFile = "activation.xml";
|
||||||
static const char* devicekeyFile = "devicesalt";
|
static const char* devicekeyFile = "devicesalt";
|
||||||
|
@ -106,7 +106,7 @@ private:
|
||||||
struct Loan* loan;
|
struct Loan* loan;
|
||||||
char * res;
|
char * res;
|
||||||
|
|
||||||
std::string loanDir = std::string(activationDir) + std::string("/") + LOANS_DIR;
|
std::string loanDir = std::string(adeptDir) + std::string("/") + LOANS_DIR;
|
||||||
|
|
||||||
if (!fileExists(loanDir.c_str()))
|
if (!fileExists(loanDir.c_str()))
|
||||||
return;
|
return;
|
||||||
|
@ -336,18 +336,18 @@ static void usage(const char* cmd)
|
||||||
{
|
{
|
||||||
std::cout << "Manage loaned books" << std::endl;
|
std::cout << "Manage loaned books" << std::endl;
|
||||||
|
|
||||||
std::cout << "Usage: " << basename((char*)cmd) << " [(-d|--activation-dir) dir] (-l|--list)|(-D|--delete loanID)|(-R|--delete loanID) [(-v|--verbose)] [(-h|--help)]" << std::endl << std::endl;
|
std::cout << "Usage: " << basename((char*)cmd) << " [(-D|--adept-directory) dir] (-l|--list)|(-d|--delete loanID)|(-R|--return loanID) [(-v|--verbose)] [(-h|--help)]" << std::endl << std::endl;
|
||||||
|
|
||||||
std::cout << " " << "-d|--activation-dir" << "\t" << "Directory of device.xml/activation.xml and device key" << std::endl;
|
std::cout << " " << "-D|--adept-directory" << "\t" << ".adept directory that must contains device.xml, activation.xml and devicesalt" << std::endl;
|
||||||
std::cout << " " << "-l|--list" << "\t\t" << "List all loaned books" << std::endl;
|
std::cout << " " << "-l|--list" << "\t\t" << "List all loaned books" << std::endl;
|
||||||
std::cout << " " << "-r|--return" << "\t\t" << "Return a loaned book" << std::endl;
|
std::cout << " " << "-r|--return" << "\t\t" << "Return a loaned book" << std::endl;
|
||||||
std::cout << " " << "-D|--delete" << "\t\t" << "Delete a loan entry without returning it" << std::endl;
|
std::cout << " " << "-d|--delete" << "\t\t" << "Delete a loan entry without returning it" << std::endl;
|
||||||
std::cout << " " << "-v|--verbose" << "\t\t" << "Increase verbosity, can be set multiple times" << std::endl;
|
std::cout << " " << "-v|--verbose" << "\t\t" << "Increase verbosity, can be set multiple times" << std::endl;
|
||||||
std::cout << " " << "-V|--version" << "\t\t" << "Display libgourou version" << std::endl;
|
std::cout << " " << "-V|--version" << "\t\t" << "Display libgourou version" << std::endl;
|
||||||
std::cout << " " << "-h|--help" << "\t\t" << "This help" << std::endl;
|
std::cout << " " << "-h|--help" << "\t\t" << "This help" << std::endl;
|
||||||
|
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
std::cout << "Activation directory is optional. If not set, it's looked into :" << std::endl;
|
std::cout << "ADEPT directory is optional. If not set, it's looked into :" << std::endl;
|
||||||
std::cout << " * Current directory" << std::endl;
|
std::cout << " * Current directory" << std::endl;
|
||||||
std::cout << " * .adept" << std::endl;
|
std::cout << " * .adept" << std::endl;
|
||||||
std::cout << " * adobe-digital-editions directory" << std::endl;
|
std::cout << " * adobe-digital-editions directory" << std::endl;
|
||||||
|
@ -365,10 +365,10 @@ int main(int argc, char** argv)
|
||||||
while (1) {
|
while (1) {
|
||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
static struct option long_options[] = {
|
static struct option long_options[] = {
|
||||||
{"activation-dir", required_argument, 0, 'd' },
|
{"adept-directory", required_argument, 0, 'D' },
|
||||||
{"list", no_argument, 0, 'l' },
|
{"list", no_argument, 0, 'l' },
|
||||||
{"return", no_argument, 0, 'r' },
|
{"return", no_argument, 0, 'r' },
|
||||||
{"delete", no_argument, 0, 'D' },
|
{"delete", no_argument, 0, 'd' },
|
||||||
{"verbose", no_argument, 0, 'v' },
|
{"verbose", no_argument, 0, 'v' },
|
||||||
{"version", no_argument, 0, 'V' },
|
{"version", no_argument, 0, 'V' },
|
||||||
{"help", no_argument, 0, 'h' },
|
{"help", no_argument, 0, 'h' },
|
||||||
|
@ -381,8 +381,8 @@ int main(int argc, char** argv)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'd':
|
case 'D':
|
||||||
activationDir = optarg;
|
adeptDir = optarg;
|
||||||
break;
|
break;
|
||||||
case 'l':
|
case 'l':
|
||||||
list = true;
|
list = true;
|
||||||
|
@ -392,7 +392,7 @@ int main(int argc, char** argv)
|
||||||
returnID = optarg;
|
returnID = optarg;
|
||||||
actions++;
|
actions++;
|
||||||
break;
|
break;
|
||||||
case 'D':
|
case 'd':
|
||||||
deleteID = optarg;
|
deleteID = optarg;
|
||||||
actions++;
|
actions++;
|
||||||
break;
|
break;
|
||||||
|
@ -432,9 +432,9 @@ int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
orig = *files[i];
|
orig = *files[i];
|
||||||
|
|
||||||
if (activationDir)
|
if (adeptDir)
|
||||||
{
|
{
|
||||||
std::string path = std::string(activationDir) + std::string("/") + orig;
|
std::string path = std::string(adeptDir) + std::string("/") + orig;
|
||||||
filename = strdup(path.c_str());
|
filename = strdup(path.c_str());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -450,17 +450,17 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
if (hasErrors)
|
if (hasErrors)
|
||||||
{
|
{
|
||||||
// In case of activation dir was provided by user
|
// In case of adept dir was provided by user
|
||||||
activationDir = 0;
|
adeptDir = 0;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (activationDir)
|
if (adeptDir)
|
||||||
activationDir = strdup(activationDir); // For below free
|
adeptDir = strdup(adeptDir); // For below free
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
activationDir = strdup(deviceFile);
|
adeptDir = strdup(deviceFile);
|
||||||
activationDir = dirname(activationDir);
|
adeptDir = dirname(adeptDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = loanMGT.run();
|
ret = loanMGT.run();
|
||||||
|
@ -472,8 +472,8 @@ end:
|
||||||
free((void*)*files[i]);
|
free((void*)*files[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (activationDir)
|
if (adeptDir)
|
||||||
free(activationDir);
|
free(adeptDir);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,8 +143,9 @@ static void usage(const char* cmd)
|
||||||
{
|
{
|
||||||
std::cout << "Remove ADEPT DRM (from Adobe) of EPUB/PDF file" << std::endl;
|
std::cout << "Remove ADEPT DRM (from Adobe) of EPUB/PDF file" << std::endl;
|
||||||
|
|
||||||
std::cout << "Usage: " << basename((char*)cmd) << " [(-d|--device-file) device.xml] [(-a|--activation-file) activation.xml] [(-k|--device-key-file) devicesalt] [(-O|--output-dir) dir] [(-o|--output-file) output(.epub|.pdf|.der)] [(-v|--verbose)] [(-h|--help)] (-f|--input-file) file(.epub|pdf)" << std::endl << std::endl;
|
std::cout << "Usage: " << basename((char*)cmd) << " [(-D|--adept-directory) dir] [(-d|--device-file) device.xml] [(-a|--activation-file) activation.xml] [(-k|--device-key-file) devicesalt] [(-O|--output-dir) dir] [(-o|--output-file) output(.epub|.pdf|.der)] [(-v|--verbose)] [(-h|--help)] (-f|--input-file) file(.epub|pdf)" << std::endl << std::endl;
|
||||||
|
|
||||||
|
std::cout << " " << "-D|--adept-directory" << "\t" << ".adept directory that must contains device.xml, activation.xml and devicesalt" << std::endl;
|
||||||
std::cout << " " << "-d|--device-file" << "\t" << "device.xml file from eReader" << std::endl;
|
std::cout << " " << "-d|--device-file" << "\t" << "device.xml file from eReader" << std::endl;
|
||||||
std::cout << " " << "-a|--activation-file" << "\t" << "activation.xml file from eReader" << std::endl;
|
std::cout << " " << "-a|--activation-file" << "\t" << "activation.xml file from eReader" << std::endl;
|
||||||
std::cout << " " << "-k|--device-key-file" << "\t" << "private device key file (eg devicesalt/devkey.bin) from eReader" << std::endl;
|
std::cout << " " << "-k|--device-key-file" << "\t" << "private device key file (eg devicesalt/devkey.bin) from eReader" << std::endl;
|
||||||
|
@ -169,10 +170,12 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
const char** files[] = {&devicekeyFile, &deviceFile, &activationFile};
|
const char** files[] = {&devicekeyFile, &deviceFile, &activationFile};
|
||||||
int verbose = gourou::DRMProcessor::getLogLevel();
|
int verbose = gourou::DRMProcessor::getLogLevel();
|
||||||
|
std::string _deviceFile, _activationFile, _devicekeyFile;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
static struct option long_options[] = {
|
static struct option long_options[] = {
|
||||||
|
{"adept-directory", required_argument, 0, 'D' },
|
||||||
{"device-file", required_argument, 0, 'd' },
|
{"device-file", required_argument, 0, 'd' },
|
||||||
{"activation-file", required_argument, 0, 'a' },
|
{"activation-file", required_argument, 0, 'a' },
|
||||||
{"device-key-file", required_argument, 0, 'k' },
|
{"device-key-file", required_argument, 0, 'k' },
|
||||||
|
@ -186,12 +189,20 @@ int main(int argc, char** argv)
|
||||||
{0, 0, 0, 0 }
|
{0, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
c = getopt_long(argc, argv, "d:a:k:O:o:f:K:vVh",
|
c = getopt_long(argc, argv, "D:d:a:k:O:o:f:K:vVh",
|
||||||
long_options, &option_index);
|
long_options, &option_index);
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
switch (c) {
|
switch (c) {
|
||||||
|
case 'D':
|
||||||
|
_deviceFile = std::string(optarg) + "/device.xml";
|
||||||
|
_activationFile = std::string(optarg) + "/activation.xml";
|
||||||
|
_devicekeyFile = std::string(optarg) + "/devicesalt";
|
||||||
|
deviceFile = _deviceFile.c_str();
|
||||||
|
activationFile = _activationFile.c_str();
|
||||||
|
devicekeyFile = _devicekeyFile.c_str();
|
||||||
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
deviceFile = optarg;
|
deviceFile = optarg;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user