28 | 28 |
#include <curses.h>
|
29 | 29 |
#include <sys/ioctl.h>
|
30 | 30 |
#include <fcntl.h>
|
31 | |
#include <sys/mount.h>
|
32 | 31 |
#include <sys/soundcard.h>
|
33 | 32 |
#include <libgen.h>
|
34 | 33 |
#include <time.h>
|
|
37 | 36 |
#include <cdio/cdio.h>
|
38 | 37 |
#include <cdio/iso9660.h>
|
39 | 38 |
|
40 | |
#define VERSION "3.0"
|
|
39 |
#define VERSION "3.1.1"
|
41 | 40 |
#define BUF_SIZE 2048
|
42 | 41 |
#define FACTOR (44100 * 2 * 2)
|
43 | 42 |
|
44 | 43 |
WINDOW *scherm, *titlewin;
|
45 | 44 |
int html_fp, smil_file_fd, discinfo_fp, discinfo = 00, multi = 0;
|
46 | |
int playing, playing_y, playing_page, just_this_item;
|
|
45 |
int playing, playing_y, playing_page, just_this_item, read_from_device_flag;
|
47 | 46 |
char from_page[10], to_page[10], current_book_page[100];
|
48 | 47 |
int bytes_read, ncc_maxPageNormal;
|
49 | 48 |
char ncc_timeInThisSmil[10], page_number[15], label[255];
|
|
106 | 105 |
} // if
|
107 | 106 |
} // while
|
108 | 107 |
closedir (dir);
|
109 | |
return NULL;
|
|
108 |
return name;
|
110 | 109 |
} // realname
|
|
110 |
|
|
111 |
void get_from_iso9660 (char *file)
|
|
112 |
{
|
|
113 |
#define CEILING(x, y) ((x+(y-1))/y)
|
|
114 |
|
|
115 |
#define my_exit(rc) \
|
|
116 |
fclose (w); \
|
|
117 |
free (p_statbuf); \
|
|
118 |
iso9660_close (p_iso); \
|
|
119 |
exit (1);
|
|
120 |
|
|
121 |
iso9660_stat_t *p_statbuf;
|
|
122 |
FILE *w;
|
|
123 |
int i;
|
|
124 |
iso9660_t *p_iso;
|
|
125 |
|
|
126 |
for (i = 0; i < 10; i++)
|
|
127 |
{
|
|
128 |
if ((p_iso = iso9660_open (daisy_dev)) == NULL)
|
|
129 |
{
|
|
130 |
switch (errno)
|
|
131 |
{
|
|
132 |
case EPERM:
|
|
133 |
beep ();
|
|
134 |
endwin ();
|
|
135 |
fprintf (stderr, "\nSorry, couldn't open ISO 9660 image %s\n",
|
|
136 |
daisy_dev);
|
|
137 |
perror (daisy_dev);
|
|
138 |
exit (1);
|
|
139 |
case ENOMEDIUM:
|
|
140 |
sleep (5);
|
|
141 |
continue;
|
|
142 |
case EBUSY:
|
|
143 |
break;
|
|
144 |
} // switch
|
|
145 |
} // if
|
|
146 |
} // for
|
|
147 |
if ((p_statbuf = iso9660_ifs_stat_translate (p_iso, file)) == NULL)
|
|
148 |
{
|
|
149 |
endwin ();
|
|
150 |
fprintf (stderr,
|
|
151 |
"\nCould not get ISO-9660 file information for file %s\n", file);
|
|
152 |
perror (file);
|
|
153 |
fprintf (stderr, "\
|
|
154 |
You ar not permitted to read from this device.\n\
|
|
155 |
To get read permission, make yourself a member of the group cdrom.\n\
|
|
156 |
To do this type:\n\n\
|
|
157 |
sudo usermod -a -G cdrom %s\n\n\
|
|
158 |
or ask the system maintainer to do this for you.\n\
|
|
159 |
(You need to logout and login again to let the change get effect.)\n",
|
|
160 |
getenv ("LOGNAME"));
|
|
161 |
beep ();
|
|
162 |
iso9660_close (p_iso);
|
|
163 |
exit (1);
|
|
164 |
} // if
|
|
165 |
if (! (w = fopen (file, "wb")))
|
|
166 |
{
|
|
167 |
endwin ();
|
|
168 |
perror (file);
|
|
169 |
free (p_statbuf);
|
|
170 |
iso9660_close (p_iso);
|
|
171 |
exit (1);
|
|
172 |
} // if
|
|
173 |
{
|
|
174 |
const unsigned int i_blocks = CEILING (p_statbuf->size, ISO_BLOCKSIZE);
|
|
175 |
for (i = 0; i < i_blocks; i++)
|
|
176 |
{
|
|
177 |
char buf[ISO_BLOCKSIZE];
|
|
178 |
const lsn_t lsn = p_statbuf->lsn + i;
|
|
179 |
|
|
180 |
memset (buf, 0, ISO_BLOCKSIZE);
|
|
181 |
if (ISO_BLOCKSIZE != iso9660_iso_seek_read (p_iso, buf, lsn, 1))
|
|
182 |
{
|
|
183 |
endwin ();
|
|
184 |
fprintf (stderr, "Error reading ISO 9660 file %s at LSN %lu\n",
|
|
185 |
file, (long unsigned int) lsn);
|
|
186 |
my_exit (4);
|
|
187 |
} // if
|
|
188 |
fwrite (buf, ISO_BLOCKSIZE, 1, w);
|
|
189 |
if (ferror (w))
|
|
190 |
{
|
|
191 |
endwin ();
|
|
192 |
perror (file);
|
|
193 |
my_exit (5);
|
|
194 |
} // if
|
|
195 |
} // for
|
|
196 |
}
|
|
197 |
fflush (w);
|
|
198 |
if (ftruncate (fileno (w), p_statbuf->size))
|
|
199 |
{
|
|
200 |
endwin ();
|
|
201 |
perror ("ftruncate()");
|
|
202 |
exit (1);
|
|
203 |
} // if
|
|
204 |
} // get_from_iso9660
|
111 | 205 |
|
112 | 206 |
void put_bookmark ()
|
113 | 207 |
{
|
|
160 | 254 |
{
|
161 | 255 |
if (get_next_clips (smil_file_fd) == EOF)
|
162 | 256 |
{
|
163 | |
sprintf (str, "%s/%s", daisy_mp, realname (daisy[current].smil_file));
|
164 | |
if ((smil_file_fd = open (str, O_RDONLY)) == -1)
|
|
257 |
if (read_from_device_flag)
|
|
258 |
get_from_iso9660 (daisy[current].smil_file);
|
|
259 |
if ((smil_file_fd =
|
|
260 |
open (realname (daisy[current].smil_file), O_RDONLY)) == -1)
|
165 | 261 |
{
|
166 | 262 |
endwin ();
|
167 | |
perror (str);
|
|
263 |
perror (realname (daisy[current].smil_file));
|
168 | 264 |
exit (1);
|
169 | 265 |
} // if
|
170 | 266 |
return;
|
|
527 | 623 |
strcpy (orig, new);
|
528 | 624 |
} // convert_html_entities
|
529 | 625 |
|
530 | |
|
531 | |
|
532 | 626 |
int get_element_or_label (int r)
|
533 | 627 |
{
|
534 | 628 |
char *p;
|
|
606 | 700 |
void get_book_page ()
|
607 | 701 |
{
|
608 | 702 |
int fd;
|
609 | |
char *p, file[100], anchor[100], str[255];
|
|
703 |
char *p, file[100], anchor[100];
|
610 | 704 |
|
611 | 705 |
p = strcasestr (element, "src");
|
612 | 706 |
while (*++p != '=');
|
|
617 | 711 |
while (*p != '"' && *p != '\'' && *p != '>' && *p != '#')
|
618 | 712 |
p++;
|
619 | 713 |
*p++ = 0;
|
620 | |
strcpy (anchor, p);
|
|
714 |
strcpy (anchor, p);
|
621 | 715 |
p = anchor;
|
622 | 716 |
while (*p != '"' && *p != '\'' && *p != '>' && *p != '#')
|
623 | 717 |
p++;
|
624 | 718 |
*p = 0;
|
625 | |
sprintf (str, "%s/%s", daisy_mp, realname (file));
|
626 | |
if ((fd = open (str, O_RDONLY)) == -1)
|
|
719 |
if (read_from_device_flag)
|
|
720 |
get_from_iso9660 (file);
|
|
721 |
if ((fd = open (realname (file), O_RDONLY)) == -1)
|
627 | 722 |
{
|
628 | 723 |
endwin ();
|
629 | |
perror (str);
|
|
724 |
perror (realname (file));
|
630 | 725 |
exit (1);
|
631 | 726 |
} // if
|
632 | 727 |
while (1)
|
|
634 | 729 |
if (get_element_or_label (fd) == EOF)
|
635 | 730 |
{
|
636 | 731 |
close (fd);
|
|
732 |
if (read_from_device_flag)
|
|
733 |
remove (file);
|
637 | 734 |
return;
|
638 | 735 |
} // if
|
639 | 736 |
if (strcasestr (element, anchor))
|
|
644 | 741 |
if (get_element_or_label (fd) == EOF)
|
645 | 742 |
{
|
646 | 743 |
close (fd);
|
|
744 |
if (read_from_device_flag)
|
|
745 |
remove (file);
|
647 | 746 |
return;
|
648 | 747 |
} // if
|
649 | 748 |
strcpy (tag, element + 1);
|
|
651 | 750 |
if ((tag[0] == 'h' || tag[0] == 'H') && isdigit (tag[1]))
|
652 | 751 |
{
|
653 | 752 |
close (fd);
|
|
753 |
if (read_from_device_flag)
|
|
754 |
remove (file);
|
654 | 755 |
return;
|
655 | 756 |
} // if
|
656 | 757 |
if (strcasecmp (tag, "span") == 0)
|
|
661 | 762 |
if (get_element_or_label (fd) == EOF)
|
662 | 763 |
{
|
663 | 764 |
close (fd);
|
|
765 |
if (read_from_device_flag)
|
|
766 |
remove (file);
|
664 | 767 |
return;
|
665 | 768 |
} // if
|
666 | 769 |
if (*label)
|
667 | 770 |
{
|
668 | 771 |
strcpy (current_book_page, label);
|
669 | 772 |
close (fd);
|
|
773 |
if (read_from_device_flag)
|
|
774 |
remove (file);
|
670 | 775 |
return;
|
671 | 776 |
} // if
|
672 | 777 |
} // while
|
673 | 778 |
close (fd);
|
|
779 |
if (read_from_device_flag)
|
|
780 |
remove (file);
|
674 | 781 |
} // get_book_page
|
675 | 782 |
|
676 | 783 |
int get_next_clips (int fd)
|
|
721 | 828 |
} // while
|
722 | 829 |
strcpy (f, strcasestr (element, "src=\"") + 5);
|
723 | 830 |
*strchr (f, '"') = 0;
|
724 | |
sprintf (daisy[current].audio_file, "%s/%s", daisy_mp, realname (f));
|
|
831 |
strcpy (daisy[current].audio_file, realname (f));
|
725 | 832 |
|
726 | 833 |
// fill begin
|
727 | 834 |
p = strcasestr (element, "clip-begin");
|
|
745 | 852 |
|
746 | 853 |
void parse_smil (char *smil_file)
|
747 | 854 |
{
|
748 | |
char str[255], *s;
|
|
855 |
char *s;
|
749 | 856 |
int r;
|
750 | 857 |
|
751 | |
sprintf (str, "%s/%s", daisy_mp, realname (smil_file));
|
752 | |
if ((r = open (str, O_RDONLY)) == -1)
|
|
858 |
if (read_from_device_flag)
|
|
859 |
get_from_iso9660 (smil_file);
|
|
860 |
if ((r = open (realname (smil_file), O_RDONLY)) == -1)
|
753 | 861 |
{
|
754 | 862 |
endwin ();
|
755 | |
perror (str);
|
|
863 |
perror (realname (smil_file));
|
756 | 864 |
exit (1);
|
757 | 865 |
} // if
|
758 | 866 |
while (get_element_or_label (r) != EOF)
|
|
781 | 889 |
} // while
|
782 | 890 |
compose_audio_file (r);
|
783 | 891 |
close (r);
|
|
892 |
if (read_from_device_flag)
|
|
893 |
remove (smil_file);
|
784 | 894 |
} // parse_smil
|
785 | 895 |
|
786 | 896 |
void view_page (int page)
|
|
851 | 961 |
char *p, *str;
|
852 | 962 |
int r;
|
853 | 963 |
|
|
964 |
if (read_from_device_flag)
|
|
965 |
get_from_iso9660 (html_file);
|
854 | 966 |
if ((r = open (html_file, O_RDONLY)) == -1)
|
855 | 967 |
{
|
856 | 968 |
endwin ();
|
857 | 969 |
perror (html_file);
|
858 | |
putchar ('\7');
|
|
970 |
beep ();
|
859 | 971 |
exit (-1);
|
860 | 972 |
} // if
|
861 | 973 |
|
|
889 | 1001 |
do
|
890 | 1002 |
{
|
891 | 1003 |
if (get_element_or_label (r) == EOF)
|
|
1004 |
{
|
|
1005 |
if (read_from_device_flag)
|
|
1006 |
remove (html_file);
|
892 | 1007 |
return;
|
|
1008 |
} // if
|
893 | 1009 |
strcpy (tag, element + 1);
|
894 | 1010 |
get_tag ();
|
895 | 1011 |
if (*label)
|
|
979 | 1095 |
} // while
|
980 | 1096 |
max_items = current - 1;
|
981 | 1097 |
close (r);
|
|
1098 |
if (read_from_device_flag)
|
|
1099 |
remove (html_file);
|
982 | 1100 |
|
983 | 1101 |
int w;
|
984 | 1102 |
|
|
1021 | 1139 |
break;
|
1022 | 1140 |
default:
|
1023 | 1141 |
return;
|
1024 | |
} // switch
|
|
1142 |
} // switch
|
1025 | 1143 |
sprintf (str, "%f", clip_duration);
|
|
1144 |
if (read_from_device_flag)
|
|
1145 |
get_from_iso9660 (daisy[playing].audio_file);
|
1026 | 1146 |
execlp ("madplay", "madplay", "-Q", daisy[playing].audio_file,
|
1027 | |
"-s", clip_begin, "-t", str, "-o", sound_dev, NULL);
|
|
1147 |
"-s", clip_begin, "-t", str, NULL); // "-o", sound_dev, NULL);
|
1028 | 1148 |
} // madplay
|
1029 | 1149 |
|
1030 | 1150 |
void start_playing (char *smil_file, char *anchor)
|
1031 | 1151 |
{
|
1032 | |
char str[100];
|
1033 | |
|
1034 | 1152 |
if (smil_file_fd > -1)
|
1035 | 1153 |
close (smil_file_fd);
|
1036 | |
sprintf (str, "%s/%s", daisy_mp, realname (smil_file));
|
1037 | |
if ((smil_file_fd = open (str, O_RDONLY)) == -1)
|
|
1154 |
if (read_from_device_flag)
|
|
1155 |
get_from_iso9660 (smil_file);
|
|
1156 |
if ((smil_file_fd = open (realname (smil_file), O_RDONLY)) == -1)
|
1038 | 1157 |
{
|
1039 | 1158 |
endwin ();
|
1040 | |
perror (smil_file);
|
|
1159 |
perror (realname (smil_file));
|
1041 | 1160 |
exit (1);
|
1042 | 1161 |
} // if
|
1043 | 1162 |
*current_book_page = 0;
|
|
1046 | 1165 |
if (get_element_or_label (smil_file_fd) == EOF)
|
1047 | 1166 |
{
|
1048 | 1167 |
close (smil_file_fd);
|
|
1168 |
if (read_from_device_flag)
|
|
1169 |
remove (smil_file);
|
1049 | 1170 |
return;
|
1050 | 1171 |
} // if
|
1051 | 1172 |
strcpy (tag, element + 1);
|
|
1091 | 1212 |
case 13:
|
1092 | 1213 |
mvwaddstr (scherm, 8, 0, "Please wait...");
|
1093 | 1214 |
wrefresh (scherm);
|
1094 | |
sprintf (str, "madplay -Q %s -o %s:\"%s.%s\" -s %s",
|
1095 | |
daisy[current].audio_file, format, daisy[current].label,
|
1096 | |
ext, clip_begin);
|
|
1215 |
sprintf (str, "madplay -Q %s -o %s:%s/\"%s.%s\" -s %s",
|
|
1216 |
daisy[current].audio_file, format, getenv ("HOME"),
|
|
1217 |
daisy[current].label, ext, clip_begin);
|
1097 | 1218 |
system (str);
|
1098 | 1219 |
view_page (cur_page);
|
1099 | 1220 |
wmove (scherm, by, bx);
|
1100 | 1221 |
return;
|
1101 | |
case 'q':
|
|
1222 |
case 'q':
|
1102 | 1223 |
view_page (cur_page);
|
1103 | 1224 |
wmove (scherm, by, bx);
|
1104 | 1225 |
return;
|
|
1265 | 1386 |
|
1266 | 1387 |
void skip_left ()
|
1267 | 1388 |
{
|
1268 | |
char str[100], last_clip[255];
|
|
1389 |
char last_clip[255];
|
1269 | 1390 |
|
1270 | 1391 |
if (1)
|
1271 | 1392 |
{
|
|
1281 | 1402 |
} // if
|
1282 | 1403 |
kill_madplay (SIGTERM);
|
1283 | 1404 |
close (smil_file_fd);
|
|
1405 |
if (read_from_device_flag)
|
|
1406 |
remove (daisy[current].smil_file);
|
1284 | 1407 |
current = playing;
|
1285 | 1408 |
while (daisy[--current].level > level);
|
1286 | 1409 |
playing = current;
|
1287 | |
sprintf (str, "%s/%s", daisy_mp, daisy[current].smil_file);
|
1288 | |
if ((smil_file_fd = open (str, O_RDONLY)) == -1)
|
|
1410 |
if (read_from_device_flag)
|
|
1411 |
get_from_iso9660 (daisy[current].smil_file);
|
|
1412 |
if ((smil_file_fd = open (daisy[current].smil_file, O_RDONLY)) == -1)
|
1289 | 1413 |
{
|
1290 | 1414 |
endwin ();
|
1291 | |
perror (str);
|
|
1415 |
perror (daisy[current].smil_file);
|
1292 | 1416 |
exit (-1);
|
1293 | 1417 |
} // if
|
1294 | 1418 |
while (get_element_or_label (smil_file_fd) != EOF)
|
|
1382 | 1506 |
remove (template);
|
1383 | 1507 |
kill_madplay (SIGTERM);
|
1384 | 1508 |
put_bookmark ();
|
1385 | |
umount (daisy_dev);
|
|
1509 |
if (read_from_device_flag)
|
|
1510 |
remove (daisy_mp);
|
1386 | 1511 |
} // quit_daisy_player
|
1387 | 1512 |
|
1388 | 1513 |
void search (int start, char mode)
|
|
1457 | 1582 |
beep ();
|
1458 | 1583 |
return;
|
1459 | 1584 |
} // if
|
|
1585 |
if (read_from_device_flag)
|
|
1586 |
get_from_iso9660 (NCC_HTML);
|
1460 | 1587 |
if ((fd = open (NCC_HTML, O_RDONLY)) == -1)
|
1461 | 1588 |
{
|
1462 | 1589 |
endwin ();
|
|
1500 | 1627 |
*p = 0;
|
1501 | 1628 |
} while (strcmp (label, page_number) != 0);
|
1502 | 1629 |
close (fd);
|
|
1630 |
if (read_from_device_flag)
|
|
1631 |
remove (NCC_HTML);
|
1503 | 1632 |
|
1504 | 1633 |
for (current = 0; current <= max_items; current++)
|
1505 | 1634 |
{
|
|
1518 | 1647 |
|
1519 | 1648 |
void cd_eject (const char *dev)
|
1520 | 1649 |
{
|
1521 | |
cdio_eject_media_drive (daisy_dev);
|
|
1650 |
endwin ();
|
|
1651 |
switch (cdio_eject_media_drive (daisy_dev))
|
|
1652 |
{
|
|
1653 |
case DRIVER_OP_UNSUPPORTED:
|
|
1654 |
fprintf (stderr, "\nEject not supported for %s.\n", daisy_dev);
|
|
1655 |
break;
|
|
1656 |
default:
|
|
1657 |
// fprintf (stderr, "\nEject of CD-ROM drive %s failed.\n", daisy_dev);
|
|
1658 |
break;
|
|
1659 |
} // switch
|
1522 | 1660 |
} // cd_eject
|
1523 | 1661 |
|
1524 | 1662 |
void browse ()
|
|
1546 | 1684 |
view_page (cur_page);
|
1547 | 1685 |
if (discinfo)
|
1548 | 1686 |
{
|
1549 | |
sprintf (str, "%s -m %s/%s -d %s", prog_name, daisy_mp,
|
|
1687 |
sprintf (str, "%s -m %s -d %s", prog_name,
|
1550 | 1688 |
dirname (daisy[current].smil_file), sound_dev);
|
1551 | 1689 |
system (str);
|
1552 | 1690 |
view_page (cur_page);
|
|
1726 | 1864 |
{
|
1727 | 1865 |
// get list of files in a directory of an ISO-9660 image
|
1728 | 1866 |
|
1729 | |
CdioList_t *p_entlist;
|
|
1867 |
CdioList_t *p_entlist;
|
1730 | 1868 |
CdioListNode_t *p_entnode;
|
1731 | 1869 |
iso9660_t *p_iso;
|
1732 | 1870 |
const char *psz_path = "/";
|
|
1735 | 1873 |
{
|
1736 | 1874 |
beep ();
|
1737 | 1875 |
endwin ();
|
1738 | |
fprintf (stderr, "Sorry, couldn't open %s as an ISO-9660 image\n",
|
|
1876 |
fprintf (stderr, "\nSorry, couldn't open %s as an ISO-9660 image\n",
|
1739 | 1877 |
daisy_dev);
|
1740 | 1878 |
exit (1);
|
1741 | 1879 |
} // if
|
|
1757 | 1895 |
|
1758 | 1896 |
int main (int argc, char *argv[])
|
1759 | 1897 |
{
|
1760 | |
int x, mount_it = 1, ret;
|
|
1898 |
int x;
|
1761 | 1899 |
char str[255];
|
1762 | 1900 |
driver_id_t driver_id = DRIVER_DEVICE;
|
1763 | 1901 |
|
|
1771 | 1909 |
if (strcmp (argv[1], "-m") == 0)
|
1772 | 1910 |
multi = 1;
|
1773 | 1911 |
strcpy ((char *) daisy_dev, "/dev/cdrom");
|
|
1912 |
read_from_device_flag = 1;
|
1774 | 1913 |
switch (argc - multi)
|
1775 | 1914 |
{
|
1776 | 1915 |
case 2:
|
|
1779 | 1918 |
if (chdir (argv[multi + 1]) == 0)
|
1780 | 1919 |
{
|
1781 | 1920 |
strcpy ((char *) daisy_mp, argv[multi + 1]);
|
1782 | |
mount_it = 0;
|
|
1921 |
read_from_device_flag = 0;
|
1783 | 1922 |
}
|
1784 | 1923 |
else
|
1785 | 1924 |
strcpy ((char *) daisy_dev, argv[multi + 1]);
|
|
1795 | 1934 |
{
|
1796 | 1935 |
sound_dev = argv[multi + 2];
|
1797 | 1936 |
strcpy ((char *) daisy_mp, argv[multi + 3]);
|
1798 | |
mount_it = 0;
|
|
1937 |
read_from_device_flag = 0;
|
1799 | 1938 |
}
|
1800 | 1939 |
else
|
1801 | 1940 |
if (! strcmp (argv[multi + 2], "-d"))
|
1802 | 1941 |
{
|
1803 | 1942 |
strcpy ((char *) daisy_mp, argv[multi + 1]);
|
1804 | |
mount_it = 0;
|
|
1943 |
read_from_device_flag = 0;
|
1805 | 1944 |
sound_dev = argv[multi + 3];
|
1806 | 1945 |
}
|
1807 | 1946 |
else
|
|
1813 | 1952 |
usage (prog_name);
|
1814 | 1953 |
} // switch
|
1815 | 1954 |
printf ("Reading daisy structure...");
|
1816 | |
if (cdio_close_tray (NULL, &driver_id) != DRIVER_OP_SUCCESS)
|
1817 | |
{
|
1818 | |
perror (prog_name);
|
1819 | |
exit (1);
|
1820 | |
} // if
|
|
1955 |
cdio_close_tray (NULL, &driver_id);
|
1821 | 1956 |
initscr ();
|
1822 | 1957 |
titlewin = newwin (2, 80, 0, 0);
|
1823 | 1958 |
scherm = newwin (23, 80, 2, 0);
|
|
1828 | 1963 |
nonl ();
|
1829 | 1964 |
noecho ();
|
1830 | 1965 |
madplay_pid = -2;
|
1831 | |
if (mount_it)
|
|
1966 |
if (read_from_device_flag)
|
1832 | 1967 |
{
|
1833 | 1968 |
sprintf ((char *) daisy_mp, "/tmp/%s.XXXXXX", prog_name);
|
1834 | 1969 |
if (mkdtemp ((char *) daisy_mp) == NULL)
|
1835 | 1970 |
{
|
1836 | 1971 |
endwin ();
|
|
1972 |
fprintf (stderr, "\nCannot create temporary directory %s\n",
|
|
1973 |
daisy_mp);
|
1837 | 1974 |
perror ("mkdtemp");
|
1838 | 1975 |
exit (1);
|
1839 | 1976 |
} // if
|
1840 | |
ret = mount (daisy_dev, daisy_mp, "iso9660",
|
1841 | |
MS_RDONLY | MS_SILENT | MS_NOATIME | S_WRITE | MS_NODIRATIME, "");
|
1842 | |
switch (ret)
|
1843 | |
{
|
1844 | |
case 0:
|
1845 | |
break;
|
1846 | |
default:
|
1847 | |
beep ();
|
1848 | |
endwin ();
|
1849 | |
fprintf (stderr, "\n%s\n", strerror (errno));
|
1850 | |
fprintf (stderr, "(Try with \"sudo %s\")\n", *argv);
|
1851 | |
exit (1);
|
1852 | |
} // switch
|
1853 | |
} // if
|
1854 | |
sprintf (NCC_HTML, "%s/%s", daisy_mp, realname ("ncc.html"));
|
1855 | |
if (access (NCC_HTML, R_OK))
|
|
1977 |
} // if
|
|
1978 |
if (chdir (daisy_mp) == -1)
|
1856 | 1979 |
{
|
1857 | 1980 |
beep ();
|
1858 | 1981 |
endwin ();
|
1859 | |
perror (NCC_HTML);
|
|
1982 |
perror (daisy_mp);
|
1860 | 1983 |
exit (1);
|
1861 | 1984 |
} // if
|
|
1985 |
strcpy (NCC_HTML, realname ("ncc.html"));
|
|
1986 |
if (read_from_device_flag)
|
|
1987 |
get_from_iso9660 (NCC_HTML);
|
1862 | 1988 |
if ((html_fp = open (NCC_HTML, O_RDONLY)) == -1)
|
1863 | 1989 |
{
|
1864 | |
sprintf (discinfo_html, "%s/discinfo.html", daisy_mp);
|
|
1990 |
strcpy (discinfo_html, "discinfo.html");
|
1865 | 1991 |
if ((discinfo_fp = open (discinfo_html, O_RDONLY)) >= 0)
|
1866 | 1992 |
{
|
1867 | 1993 |
discinfo = 1;
|
|
1869 | 1995 |
browse ();
|
1870 | 1996 |
close (discinfo_fp);
|
1871 | 1997 |
exit (0);
|
|
1998 |
}
|
|
1999 |
else
|
|
2000 |
{
|
|
2001 |
endwin ();
|
|
2002 |
perror (NCC_HTML);
|
|
2003 |
fputs ("Can't find a Daisy structure!\n", stderr);
|
|
2004 |
beep ();
|
|
2005 |
exit (1);
|
1872 | 2006 |
} // if
|
1873 | 2007 |
} // if
|
1874 | 2008 |
wattron (titlewin, A_BOLD);
|
|
1902 | 2036 |
remake_structure (level);
|
1903 | 2037 |
*search_str = 0;
|
1904 | 2038 |
browse ();
|
|
2039 |
if (read_from_device_flag)
|
|
2040 |
remove (daisy_mp);
|
1905 | 2041 |
return 0;
|
1906 | |
} // main
|
|
2042 |
} // main
|