2
* Copyright (c) 1997, 98, 99, 2000, 01
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2, or (at your option)
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
2
* Copyright (c) 1997-2006 Motoyuki Kasahara
4
* Redistribution and use in source and binary forms, with or without
5
* modification, are permitted provided that the following conditions
7
* 1. Redistributions of source code must retain the above copyright
8
* notice, this list of conditions and the following disclaimer.
9
* 2. Redistributions in binary form must reproduce the above copyright
10
* notice, this list of conditions and the following disclaimer in the
11
* documentation and/or other materials provided with the distribution.
12
* 3. Neither the name of the project nor the names of its contributors
13
* may be used to endorse or promote products derived from this software
14
* without specific prior written permission.
16
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
17
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
20
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
16
29
#ifdef HAVE_CONFIG_H
82
69
* Unexported functions.
84
static void output_error_message EB_P((EB_Error_Code));
85
static int output_information EB_P((const char *, int));
86
static void output_help EB_P((void));
87
static void output_multi_information EB_P((EB_Book *));
71
static void output_error_message(EB_Error_Code error_code);
72
static EB_Error_Code output_booklist(const char *url);
73
static EB_Error_Code output_information(const char *book_path, int multi_flag);
74
static EB_Error_Code output_multi_information(EB_Book *book);
75
static void output_help(void);
90
78
* Program name and version.
97
85
* Command line options.
99
static const char *short_options = "hmv";
87
static const char *short_options = "hlmv";
100
88
static struct option long_options[] = {
101
89
{"help", no_argument, NULL, 'h'},
90
{"book-list", no_argument, NULL, 'l'},
102
91
{"multi-search", no_argument, NULL, 'm'},
103
92
{"version", no_argument, NULL, 'v'},
104
93
{NULL, 0, NULL, 0}
185
183
book_path = argv[optind];
187
if (output_information(book_path, multi_flag) < 0)
186
error_code = output_booklist(book_path);
188
error_code = output_information(book_path, multi_flag);
189
if (error_code != EB_SUCCESS)
195
197
* Output an error message to standard error.
198
output_error_message(error_code)
199
EB_Error_Code error_code;
200
output_error_message(EB_Error_Code error_code)
201
202
fprintf(stderr, "%s: %s\n", invoked_name, eb_error_message(error_code));
208
* Output a list of books that an EBNET server provides.
211
output_booklist(const char *url)
213
EB_BookList booklist;
214
EB_Error_Code error_code;
221
error_code = eb_initialize_library();
222
if (error_code != EB_SUCCESS) {
223
output_error_message(error_code);
227
eb_initialize_booklist(&booklist);
229
error_code = eb_bind_booklist(&booklist, url);
230
if (error_code != EB_SUCCESS) {
231
output_error_message(error_code);
235
printf("%-20s %s\n", _("Name"), _("Title"));
237
error_code = eb_booklist_book_count(&booklist, &book_count);
238
if (error_code != EB_SUCCESS) {
239
output_error_message(error_code);
243
for (i = 0; i < book_count; i++) {
244
error_code = eb_booklist_book_name(&booklist, i, &name);
245
if (error_code != EB_SUCCESS) {
246
output_error_message(error_code);
249
error_code = eb_booklist_book_title(&booklist, i, &title);
250
if (error_code != EB_SUCCESS) {
251
output_error_message(error_code);
255
name_length = strlen(name);
257
printf("%-20s ", name);
258
fputs_eucjp_to_locale(title, stdout);
259
if (4 < name_length && strcmp(name + name_length - 4, ".app") == 0)
260
fputs(" (appendix)", stdout);
264
eb_finalize_booklist(&booklist);
265
eb_finalize_library();
207
272
* Output information about the book at `path'.
208
273
* If `multi_flag' is enabled, multi-search information are also output.
211
output_information(book_path, multi_flag)
212
const char *book_path;
276
output_information(const char *book_path, int multi_flag)
279
EB_Error_Code return_code = EB_SUCCESS;
216
280
EB_Error_Code error_code;
217
281
EB_Disc_Code disc_code;
218
282
EB_Character_Code character_code;
229
293
* Start to use a book.
231
295
error_code = eb_initialize_library();
232
if (error_code != EB_SUCCESS)
296
if (error_code != EB_SUCCESS) {
297
output_error_message(error_code);
298
return_code = error_code;
234
301
eb_initialize_book(&book);
235
302
error_code = eb_bind(&book, book_path);
236
if (error_code != EB_SUCCESS)
303
if (error_code != EB_SUCCESS) {
304
output_error_message(error_code);
305
return_code = error_code;
240
310
* Output disc type.
242
312
error_code = eb_disc_type(&book, &disc_code);
243
if (error_code != EB_SUCCESS)
313
if (error_code != EB_SUCCESS) {
314
output_error_message(error_code);
315
return_code = error_code;
245
318
printf(_("disc type: "));
246
319
if (disc_code == EB_DISC_EB)
247
320
printf("EB/EBG/EBXA/EBXA-C/S-EBXA\n");
252
325
* Output character code.
254
327
error_code = eb_character_code(&book, &character_code);
255
if (error_code != EB_SUCCESS)
328
if (error_code != EB_SUCCESS) {
329
output_error_message(error_code);
330
return_code = error_code;
257
333
printf(_("character code: "));
258
334
switch (character_code) {
259
335
case EB_CHARCODE_ISO8859_1:
274
350
* Output the number of subbooks in the book.
276
352
error_code = eb_subbook_list(&book, subbook_list, &subbook_count);
277
if (error_code != EB_SUCCESS)
353
if (error_code != EB_SUCCESS) {
354
output_error_message(error_code);
355
return_code = error_code;
279
358
printf(_("the number of subbooks: %d\n\n"), subbook_count);
288
367
* Output a title of the subbook.
290
369
error_code = eb_subbook_title2(&book, subbook_list[i], title);
291
if (error_code != EB_SUCCESS)
370
if (error_code != EB_SUCCESS) {
371
return_code = error_code;
293
printf(_(" title: %s\n"), title);
374
printf(_(" title: "), title);
375
fputs_eucjp_to_locale(title, stdout);
296
379
* Output a directory name of the subbook.
298
381
error_code = eb_subbook_directory2(&book, subbook_list[i], directory);
299
if (error_code != EB_SUCCESS)
382
if (error_code != EB_SUCCESS) {
383
return_code = error_code;
301
386
printf(_(" directory: %s\n"), directory);
319
405
fputs(_("endword "), stdout);
320
406
if (eb_have_keyword_search(&book))
321
407
fputs(_("keyword "), stdout);
408
if (eb_have_cross_search(&book))
409
fputs(_("cross "), stdout);
322
410
if (eb_have_multi_search(&book))
323
411
fputs(_("multi "), stdout);
324
412
if (eb_have_menu(&book))
325
413
fputs(_("menu "), stdout);
414
if (eb_have_image_menu(&book))
415
fputs(_("image-menu "), stdout);
326
416
if (eb_have_copyright(&book))
327
417
fputs(_("copyright "), stdout);
328
418
fputc('\n', stdout);
335
425
if (error_code != EB_SUCCESS) {
336
426
fputc('\n', stdout);
337
427
output_error_message(error_code);
428
return_code = error_code;
339
430
for (j = 0; j < font_count; j++) {
340
431
error_code = eb_font_height2(font_list[j], &font_height);
341
432
if (error_code == EB_SUCCESS)
342
433
printf("%d ", font_height);
435
output_error_message(error_code);
436
return_code = error_code;
344
439
fputc('\n', stdout);
394
490
fputc('\n', stdout);
395
491
output_error_message(error_code);
492
return_code = error_code;
398
495
fputc('\n', stdout);
402
output_multi_information(&book);
499
error_code = output_multi_information(&book);
500
if (error_code != EB_SUCCESS)
501
return_code = error_code;
403
503
fputc('\n', stdout);
421
output_error_message(error_code);
422
521
eb_finalize_book(&book);
423
522
eb_finalize_library();
429
528
* Output information about multi searches.
432
output_multi_information(book)
531
output_multi_information(EB_Book *book)
533
EB_Error_Code return_code = EB_SUCCESS;
435
534
EB_Error_Code error_code;
436
535
EB_Multi_Search_Code multi_list[EB_MAX_MULTI_SEARCHES];
440
539
char entry_label[EB_MAX_MULTI_LABEL_LENGTH + 1];
543
* Get a list of mutli search codes.
443
545
error_code = eb_multi_search_list(book, multi_list, &multi_count);
444
546
if (error_code != EB_SUCCESS) {
445
547
output_error_message(error_code);
548
return_code = error_code;
553
* Output information.
448
555
for (i = 0; i < multi_count; i++) {
449
556
printf(_(" multi search %d:\n"), i + 1);
450
557
error_code = eb_multi_entry_count(book, multi_list[i], &entry_count);
451
558
if (error_code != EB_SUCCESS) {
452
559
output_error_message(error_code);
560
return_code = error_code;
456
564
error_code = eb_multi_title(book, multi_list[i], search_title);
457
565
if (error_code != EB_SUCCESS) {
458
566
output_error_message(error_code);
567
return_code = error_code;
461
printf(_(" title: %s\n"), search_title);
570
printf(_(" title: "), search_title);
571
fputs_eucjp_to_locale(search_title, stdout);
463
574
for (j = 0; j < entry_count; j++) {
464
575
error_code = eb_multi_entry_label(book, multi_list[i], j,
466
577
if (error_code != EB_SUCCESS) {
467
578
output_error_message(error_code);
579
return_code = error_code;
471
printf(_(" label %d: %s\n"), j + 1, entry_label);
583
printf(_(" label %d: "), j + 1);
584
fputs_eucjp_to_locale(entry_label, stdout);
472
587
fputs(_(" candidates: "), stdout);
473
588
if (eb_multi_entry_have_candidates(book, multi_list[i], j))
474
589
fputs(_("exist\n"), stdout);
476
591
fputs(_("not-exist\n"), stdout);
484
602
* Output help message to stdandard out.
489
607
printf(_("Usage: %s [option...] [book-directory]\n"),
491
609
printf(_("Options:\n"));
492
610
printf(_(" -h --help display this help, then exit\n"));
611
printf(_(" -l --book-list output a list of books on an EBENT server\n"));
493
612
printf(_(" -m --multi-search also output multi-search information\n"));
494
613
printf(_(" -v --version display version number, then exit\n"));
495
614
printf(_("\nArgument:\n"));