Libgourou

Libgourou Commit Details

Date:2022-12-21 21:23:42 (9 months 1 day ago)
Author:Grégory Soutadé
Branch:master
Commit:e4bd73c03db20e8c6dacb53b51eae2e5244a82f7
Parents: f65e8cd9ebcb78ba232eb6b3cf6b3bd1b72a8c9c
Message: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 !

Changes:
Minclude/libgourou.h (1 diff)
Mutils/acsmdownloader.cpp (4 diffs)
Mutils/adept_loan_mgt.cpp (9 diffs)
Mutils/adept_remove.cpp (3 diffs)

File differences

include/libgourou.h
4040
4141
4242
43
43
4444
4545
4646
#define ACS_SERVER "http://adeactivate.adobe.com/adept"
#endif
#define LIBGOUROU_VERSION "0.8"
#define LIBGOUROU_VERSION "0.8.1"
namespace gourou
{
utils/acsmdownloader.cpp
184184
185185
186186
187
187
188188
189
189190
190191
191192
......
209210
210211
211212
213
212214
213215
214216
......
216218
217219
218220
221
219222
220223
221224
......
230233
231234
232235
233
236
234237
235238
236239
237240
238241
242
243
244
245
246
247
248
249
239250
240251
241252
{
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 << " " << "-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;
int main(int argc, char** argv)
{
int c, ret = -1;
std::string _deviceFile, _activationFile, _devicekeyFile;
const char** files[] = {&devicekeyFile, &deviceFile, &activationFile};
int verbose = gourou::DRMProcessor::getLogLevel();
while (1) {
int option_index = 0;
static struct option long_options[] = {
{"adept-directory", required_argument, 0, 'D' },
{"device-file", required_argument, 0, 'd' },
{"activation-file", required_argument, 0, 'a' },
{"device-key-file", required_argument, 0, 'k' },
{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);
if (c == -1)
break;
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':
deviceFile = optarg;
break;
utils/adept_loan_mgt.cpp
4545
4646
4747
48
48
4949
5050
5151
......
106106
107107
108108
109
109
110110
111111
112112
......
336336
337337
338338
339
339
340340
341
341
342342
343343
344
344
345345
346346
347347
348348
349349
350
350
351351
352352
353353
......
365365
366366
367367
368
368
369369
370370
371
371
372372
373373
374374
......
381381
382382
383383
384
385
384
385
386386
387387
388388
......
392392
393393
394394
395
395
396396
397397
398398
......
432432
433433
434434
435
435
436436
437
437
438438
439439
440440
......
450450
451451
452452
453
454
453
454
455455
456456
457457
458
459
458
459
460460
461461
462
463
462
463
464464
465465
466466
......
472472
473473
474474
475
476
475
476
477477
478478
479479
#define MAX_SIZE_BOOK_NAME 30
static char* activationDir = 0;
static char* adeptDir = 0;
static const char* deviceFile = "device.xml";
static const char* activationFile = "activation.xml";
static const char* devicekeyFile = "devicesalt";
struct Loan* loan;
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()))
return;
{
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 << " " << "-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|--version" << "\t\t" << "Display libgourou version" << std::endl;
std::cout << " " << "-h|--help" << "\t\t" << "This help" << 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 << " * .adept" << std::endl;
std::cout << " * adobe-digital-editions directory" << std::endl;
while (1) {
int option_index = 0;
static struct option long_options[] = {
{"activation-dir", required_argument, 0, 'd' },
{"adept-directory", required_argument, 0, 'D' },
{"list", no_argument, 0, 'l' },
{"return", no_argument, 0, 'r' },
{"delete", no_argument, 0, 'D' },
{"delete", no_argument, 0, 'd' },
{"verbose", no_argument, 0, 'v' },
{"version", no_argument, 0, 'V' },
{"help", no_argument, 0, 'h' },
break;
switch (c) {
case 'd':
activationDir = optarg;
case 'D':
adeptDir = optarg;
break;
case 'l':
list = true;
returnID = optarg;
actions++;
break;
case 'D':
case 'd':
deleteID = optarg;
actions++;
break;
{
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());
}
else
if (hasErrors)
{
// In case of activation dir was provided by user
activationDir = 0;
// In case of adept dir was provided by user
adeptDir = 0;
goto end;
}
if (activationDir)
activationDir = strdup(activationDir); // For below free
if (adeptDir)
adeptDir = strdup(adeptDir); // For below free
else
{
activationDir = strdup(deviceFile);
activationDir = dirname(activationDir);
adeptDir = strdup(deviceFile);
adeptDir = dirname(adeptDir);
}
ret = loanMGT.run();
free((void*)*files[i]);
}
if (activationDir)
free(activationDir);
if (adeptDir)
free(adeptDir);
return ret;
}
utils/adept_remove.cpp
143143
144144
145145
146
146
147147
148
148149
149150
150151
......
169170
170171
171172
173
172174
173175
174176
175177
178
176179
177180
178181
......
186189
187190
188191
189
192
190193
191194
192195
193196
194197
198
199
200
201
202
203
204
205
195206
196207
197208
{
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 << " " << "-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;
const char** files[] = {&devicekeyFile, &deviceFile, &activationFile};
int verbose = gourou::DRMProcessor::getLogLevel();
std::string _deviceFile, _activationFile, _devicekeyFile;
while (1) {
int option_index = 0;
static struct option long_options[] = {
{"adept-directory", required_argument, 0, 'D' },
{"device-file", required_argument, 0, 'd' },
{"activation-file", required_argument, 0, 'a' },
{"device-key-file", required_argument, 0, 'k' },
{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);
if (c == -1)
break;
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':
deviceFile = optarg;
break;

Archive Download the corresponding diff file