patch-lsdvd_c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. $OpenBSD: patch-lsdvd_c,v 1.7 2015/05/02 19:58:47 ajacoutot Exp $
  2. --- lsdvd.c.orig Sat Oct 4 07:09:14 2014
  3. +++ lsdvd.c Sat May 2 21:56:45 2015
  4. @@ -21,6 +21,7 @@
  5. #include <unistd.h>
  6. #include <getopt.h>
  7. #include <dvdread/ifo_read.h>
  8. +#include <dvdread/ifo_print.h>
  9. #include "lsdvd.h"
  10. #include "ocode.h"
  11. @@ -122,6 +123,7 @@ static void converttime(playback_time_t *pt, dvd_time_
  12. /*
  13. * The following method is based on code from vobcopy, by Robos, with thanks.
  14. + * It fails opening a directory (like /home/movies/casablanca/VIDEO_TS/)
  15. */
  16. static int get_title_name(const char* dvd_device, char* title)
  17. {
  18. @@ -133,20 +135,28 @@ static int get_title_name(const char* dvd_device, char
  19. strcpy(title, "unknown");
  20. return -1;
  21. }
  22. + fprintf(stderr, "opening %s for title\n", dvd_device);
  23. - if ( fseek(filehandle, 32808, SEEK_SET )) {
  24. + if ( fseek(filehandle, 32768, SEEK_SET )) {
  25. fclose(filehandle);
  26. fprintf(stderr, "Couldn't seek in %s for title\n", dvd_device);
  27. strcpy(title, "unknown");
  28. return -1;
  29. }
  30. - if ( 32 != (i = fread(title, 1, 32, filehandle)) ) {
  31. + {
  32. + #define DVD_SEC_SIZ 2048
  33. + char tempBuf[ DVD_SEC_SIZ ];
  34. +
  35. + if ( DVD_SEC_SIZ != fread(tempBuf, 1, DVD_SEC_SIZ, filehandle) ) {
  36. fclose(filehandle);
  37. fprintf(stderr, "Couldn't read enough bytes for title.\n");
  38. strcpy(title, "unknown");
  39. return -1;
  40. }
  41. + snprintf( title, 32, "%s", tempBuf + 40 );
  42. + i=32;
  43. + }
  44. fclose (filehandle);
  45. @@ -199,7 +209,7 @@ static void usage(void)
  46. fprintf(stderr, "\n");
  47. }
  48. -int opt_a=0, opt_c=0, opt_n=0, opt_p=0, opt_q=0, opt_s=0, opt_t=0, opt_v=0, opt_x=0, opt_d=0, opt_P=0;
  49. +int opt_a=0, opt_c=0, opt_m=0, opt_n=0, opt_p=0, opt_q=0, opt_s=0, opt_t=0, opt_v=0, opt_x=0, opt_d=0, opt_P=0;
  50. char opt_O='h';
  51. static char output_option(char *arg)
  52. @@ -238,7 +248,7 @@ int main(int argc, char *argv[])
  53. pgc_t *pgc;
  54. int i, j, k, c, titles, cell, vts_ttn, title_set_nr;
  55. char lang_code[3];
  56. - char *dvd_device = "/dev/dvd";
  57. + char *dvd_device = "/dev/rcd0c";
  58. int has_title = 0, ret = 0;
  59. int max_length = 0, max_track = 0;
  60. struct stat dvd_stat;
  61. @@ -255,18 +265,20 @@ int main(int argc, char *argv[])
  62. case 's': opt_s = 1; break;
  63. case 'q': opt_q = 1; break;
  64. case 'c': opt_c = 1; break;
  65. + case 'm': opt_m = 1; break;
  66. case 'n': opt_n = 1; break;
  67. case 'p': opt_p = 1; break;
  68. case 'P': opt_P = 1; break;
  69. case 't': opt_t = atoi(optarg); break;
  70. case 'O': opt_O = output_option(optarg); break;
  71. - case 'v': opt_v = 1; break;
  72. + case 'v': opt_v++; break;
  73. case 'x': opt_x = 1;
  74. opt_a = 1;
  75. opt_c = 1;
  76. opt_s = 1;
  77. opt_P = 1;
  78. opt_d = 1;
  79. + opt_m = 1;
  80. opt_n = 1;
  81. opt_v = 1; break;
  82. }
  83. @@ -280,6 +292,9 @@ int main(int argc, char *argv[])
  84. return 1;
  85. }
  86. + /* On at least NetBSD this fails if called after DVDOpen */
  87. + has_title = get_title_name(dvd_device, title);
  88. +
  89. dvd = DVDOpen(dvd_device);
  90. if( !dvd ) {
  91. fprintf( stderr, "Can't open disc %s!\n", dvd_device);
  92. @@ -290,6 +305,12 @@ int main(int argc, char *argv[])
  93. fprintf( stderr, "Can't open main ifo!\n");
  94. return 3;
  95. }
  96. + if (opt_v > 2) {
  97. + printf("Title 0 IFO dump\n");
  98. + printf("================\n");
  99. + ifo_print(dvd, 0);
  100. + printf("\n");
  101. + }
  102. ifo = (ifo_handle_t **)malloc((ifo_zero->vts_atrt->nr_of_vtss + 1) * sizeof(ifo_handle_t *));
  103. @@ -299,6 +320,12 @@ int main(int argc, char *argv[])
  104. fprintf( stderr, "Can't open ifo %d!\n", i);
  105. return 4;
  106. }
  107. + if (opt_v > 2) {
  108. + printf("Title %2d IFO dump\n", i);
  109. + printf("=================\n");
  110. + ifo_print(dvd, i);
  111. + printf("\n");
  112. + }
  113. }
  114. titles = ifo_zero->tt_srpt->nr_of_srpts;
  115. @@ -308,8 +335,6 @@ int main(int argc, char *argv[])
  116. return 5;
  117. }
  118. - has_title = get_title_name(dvd_device, title);
  119. -
  120. vmgi_mat = ifo_zero->vmgi_mat;
  121. struct dvd_info dvd_info;
  122. @@ -404,6 +429,11 @@ int main(int argc, char *argv[])
  123. dvd_info.titles[j].angle_count = ifo_zero->tt_srpt->title[j].nr_of_angles;
  124. } else {
  125. dvd_info.titles[j].angle_count = 0;
  126. + }
  127. +
  128. + // MENU STRUCTURE
  129. + if (opt_m) {
  130. + // void ifo_print(dvd_reader_t *, int);
  131. }
  132. /* AUDIO */