/[suikacvs]/www/namazu/filter/dvi.pl
Suika

Contents of /www/namazu/filter/dvi.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (show annotations) (download) (vendor branch)
Fri Nov 30 07:56:45 2001 UTC (22 years, 5 months ago) by wakaba
Branch: MAIN, wakaba
CVS Tags: initial, HEAD
Changes since 1.1: +0 -0 lines
File MIME type: text/plain

1 #
2 # -*- Perl -*-
3 # $Id: dvi.pl,v 1.2 2001/01/04 01:57:58 baba Exp $
4 # Copyright (C) 2000 Namazu Project All rights reserved ,
5 # This is free software with ABSOLUTELY NO WARRANTY.
6 #
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either versions 2, or (at your option)
10 # any later version.
11 #
12 # This program is distributed in the hope that it will be useful
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 # 02111-1307, USA
21 #
22 # This file must be encoded in EUC-JP encoding
23 #
24
25 package dvi;
26 use strict;
27 require 'util.pl';
28
29 my $dvipath = undef;
30 my $nkfpath = undef;
31
32 sub mediatype() {
33 return ('application/x-dvi');
34 }
35
36 sub status() {
37 $dvipath = util::checkcmd('dvi2tty');
38 if (util::islang("ja")) {
39 $nkfpath = util::checkcmd('nkf');
40 }
41 return 'no' unless (defined $dvipath);
42 return 'yes';
43 }
44
45 sub recursive() {
46 return 0;
47 }
48
49 sub pre_codeconv() {
50 return 0;
51 }
52
53 sub post_codeconv () {
54 return 0;
55 }
56
57 sub add_magic ($) {
58 return;
59 }
60
61 sub filter ($$$$$) {
62 my ($orig_cfile, $cont, $weighted_str, $headings, $fields)
63 = @_;
64 my $cfile = defined $orig_cfile ? $$orig_cfile : '';
65
66 my $tmpfile = util::tmpnam('NMZ.dvi');
67 my $tmpfile2 = util::tmpnam('NMZ.dvi2');
68
69 # note that dvi2tty need suffix .dvi
70 my $fh = util::efopen("> $tmpfile.dvi");
71 print $fh $$cont;
72 undef $fh;
73
74 util::vprint("Processing dvi file ... (using '$dvipath')\n");
75 if (util::islang("ja")) {
76 # -J option: dvi2tty-5.1 for Debian
77 # system("$dvipath -J -q $tmpfile -o $tmpfile2");
78 # ugly: nkf is needed because of prevent 'mojibake' :-(
79 system("$dvipath -J -q $tmpfile | $nkfpath -e > $tmpfile2");
80 } else {
81 system("$dvipath -q $tmpfile -o $tmpfile2");
82 }
83 unless (-e $tmpfile2) {
84 unlink("$tmpfile.dvi");
85 unlink($tmpfile2);
86 return 'Unable to convert dvi file';
87 }
88
89 $fh = util::efopen("$tmpfile2");
90 my $size = util::filesize($fh);
91 if ($size > $conf::FILE_SIZE_MAX) {
92 unlink("$tmpfile.dvi");
93 unlink($tmpfile2);
94 return 'too_large_dvi_file';
95 }
96 $$cont = util::readfile($fh);
97 undef $fh;
98 unlink("$tmpfile.dvi");
99 unlink($tmpfile2);
100 return undef;
101 }
102
103 1;

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24