1
  
2
  
3
  
4
  
5
  
6
  
7
  
8
  
9
  
10
  
11
  
12
  
13
  
14
  
15
  
16
  
17
  
18
  
19
  
20
  
21
  
22
  
23
  
24
  
25
  
26
  
27
  
28
  
29
  
30
  
31
  
32
  
33
  
34
  
35
  
36
  
37
  
38
  
39
  
40
  
41
  
42
  
43
  
44
  
45
  
46
  
47
  
48
  
49
  
50
  
51
  
52
  
53
  
54
  
// This file is part of Roxen Search 
// Copyright © 2001 Roxen IS. All rights reserved. 
// 
// $Id: Word.pmod,v 1.2 2001/07/12 22:50:40 nilsson Exp $ 
 
// Filter for text/plain 
 
inherit Search.Filter.Base; 
 
constant contenttypes = ({ "application/msword", "application/vnd.ms-word" }); 
constant fields = ({ "body","title", "keywords"}); 
 
Output filter(Standards.URI uri, string|Stdio.File data, string content_type) 
{ 
  Output res=Output(); 
 
  if(objectp(data)) 
    data=data->read(); 
 
  string s=Process.popen(sprintf("")); 
 
  string fn=tmp_filename(); 
  object f=Stdio.File(fn,"wcb"); 
  f->write(data); 
  f->close(); 
   
  string text=Process.popen(combine_path(__FILE__, "bin/wvware/wvdump")+" "+fn+" -"); 
  rm(fn); 
 
  string md="", body=""; 
  array a=text/"\n----------"; 
 
  if(sizeof(a)>1) 
  { 
    md=a[0]; 
    body=a[1]; 
  } 
 
  string field,value=""; 
  foreach(md/"\n", string md_line) 
    if(sscanf(md_line,"%s: %s",field,value)==2) 
      res->fields[field]=value; 
       
  res->fields->body=body; 
 
  return res;   
} 
 
string _sprintf() 
{ 
  return "Search.Filter.Word"; 
}