32e8b52001-06-28Johan Schön // This file is part of Roxen Search
4b23672001-07-13Martin Nilsson // Copyright © 2001 Roxen IS. All rights reserved.
32e8b52001-06-28Johan Schön //
31aeb92001-09-03Marcus Comstedt // $Id: Word.pmod,v 1.6 2001/09/03 21:42:10 marcus Exp $
32e8b52001-06-28Johan Schön 
13e9832001-08-08Fredrik Noring inherit Search.Filter.HTML;
32e8b52001-06-28Johan Schön  constant contenttypes = ({ "application/msword", "application/vnd.ms-word" });
13e9832001-08-08Fredrik Noring constant fields = ({ "body", "title", "keywords"});
32e8b52001-06-28Johan Schön 
31aeb92001-09-03Marcus Comstedt #if constant(PIKE_MODULE_RELOC) #define RELFILE(n) combine_path(getcwd(), master()->relocate_module(__FILE__), "../"n) #else #define RELFILE(n) combine_path(getcwd(), __FILE__, "../"n) #endif
32e8b52001-06-28Johan Schön Output filter(Standards.URI uri, string|Stdio.File data, string content_type) { Output res=Output(); if(objectp(data)) data=data->read();
13e9832001-08-08Fredrik Noring  string fn = tmp_filename(); object f = Stdio.File(fn, "wct"); int r = f->write(data);
32e8b52001-06-28Johan Schön  f->close();
13e9832001-08-08Fredrik Noring  if(r != sizeof(data)) error("Failed to write data for %O (returned %O, not %O)\n", fn, r, sizeof(data));
31aeb92001-09-03Marcus Comstedt  string text = my_popen(({ RELPATH("../../../bin/wvWare"),
13e9832001-08-08Fredrik Noring  "-c", "utf-8",
31aeb92001-09-03Marcus Comstedt  "-x", RELPATH("wvHtml.xml"),
13e9832001-08-08Fredrik Noring  fn }));
32e8b52001-06-28Johan Schön 
2e3bde2001-08-14Johan Schön  if(!rm(fn)) werror("Search: Failed to remove temporary file: %s\n", fn);
13e9832001-08-08Fredrik Noring  return ::filter(uri, text, "text/html", ([]), "utf-8");
32e8b52001-06-28Johan Schön } string _sprintf() { return "Search.Filter.Word"; }