1 |
# |
2 |
# -*- Perl -*- |
3 |
# $Id: taro.pl,v 1.7 2001/06/19 09:08:15 fumiya Exp $ |
4 |
# Copyright (C) 2000 Ken-ichi Hirose, |
5 |
# 2000 Namazu Project All rights reserved. |
6 |
# This is free software with ABSOLUTELY NO WARRANTY. |
7 |
# |
8 |
# This program is free software; you can redistribute it and/or modify |
9 |
# it under the terms of the GNU General Public License as published by |
10 |
# the Free Software Foundation; either versions 2, or (at your option) |
11 |
# any later version. |
12 |
# |
13 |
# This program is distributed in the hope that it will be useful |
14 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 |
# GNU General Public License for more details. |
17 |
# |
18 |
# You should have received a copy of the GNU General Public License |
19 |
# along with this program; if not, write to the Free Software |
20 |
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
21 |
# 02111-1307, USA |
22 |
# |
23 |
# This file must be encoded in EUC-JP encoding |
24 |
# |
25 |
|
26 |
package taro; |
27 |
use strict; |
28 |
use File::Copy; |
29 |
require 'util.pl'; |
30 |
require 'gfilter.pl'; |
31 |
|
32 |
my $taroconvpath = undef; |
33 |
|
34 |
sub mediatype() { |
35 |
# File::MMagic detects Ichitaro 6 document as `application/ichitaro6' |
36 |
return qw( |
37 |
application/x-js-taro |
38 |
application/ichitaro6 |
39 |
); |
40 |
} |
41 |
|
42 |
sub status() { |
43 |
$taroconvpath = util::checkcmd('doccat'); |
44 |
return 'yes' if defined $taroconvpath; |
45 |
return 'no'; |
46 |
} |
47 |
|
48 |
sub recursive() { |
49 |
return 0; |
50 |
} |
51 |
|
52 |
sub pre_codeconv() { |
53 |
return 0; |
54 |
} |
55 |
|
56 |
sub post_codeconv () { |
57 |
return 0; |
58 |
} |
59 |
|
60 |
sub add_magic ($) { |
61 |
my ($magic) = @_; |
62 |
|
63 |
# Ichitaro 6, 7 |
64 |
$magic->addFileExts('\\.j[bf]w$', 'application/x-js-taro'); |
65 |
# Ichitaro 8, 9, 10 |
66 |
$magic->addFileExts('\\.jt[dt]$', 'application/x-js-taro'); |
67 |
return; |
68 |
} |
69 |
|
70 |
sub filter ($$$$$) { |
71 |
my ($orig_cfile, $cont, $weighted_str, $headings, $fields) |
72 |
= @_; |
73 |
my $cfile = defined $orig_cfile ? $$orig_cfile : ''; |
74 |
|
75 |
my $tmpfile = util::tmpnam('NMZ.taro'); |
76 |
my $tmpfile2 = util::tmpnam('NMZ.taro2'); |
77 |
copy("$cfile", "$tmpfile2"); |
78 |
|
79 |
system("$taroconvpath -o e $tmpfile2 > $tmpfile"); |
80 |
|
81 |
{ |
82 |
my $fh = util::efopen("< $tmpfile"); |
83 |
$$cont = util::readfile($fh); |
84 |
} |
85 |
|
86 |
unlink($tmpfile); |
87 |
unlink($tmpfile2); |
88 |
|
89 |
gfilter::line_adjust_filter($cont); |
90 |
gfilter::line_adjust_filter($weighted_str); |
91 |
gfilter::white_space_adjust_filter($cont); |
92 |
$fields->{'title'} = gfilter::filename_to_title($cfile, $weighted_str) |
93 |
unless $fields->{'title'}; |
94 |
gfilter::show_filter_debug_info($cont, $weighted_str, |
95 |
$fields, $headings); |
96 |
return undef; |
97 |
} |
98 |
|
99 |
1; |