87e9262001-06-22Martin Nilsson // This file is part of Roxen Search // Copyright © 2001 Roxen IS. All rights reserved. //
94b6102001-08-08Fredrik Noring // $Id: Base.pike,v 1.10 2001/08/08 15:08:09 noring Exp $
87e9262001-06-22Martin Nilsson 
e1d7152000-11-24Johan Schön //! The MIME content types this class can filter.
df57a22001-01-02Johan Schön constant contenttypes = ({ });
e1d7152000-11-24Johan Schön 
300e4c2001-05-17Johan Schön class Output { // Wide strings here mapping(string:string) fields=([]);
8c5dc62001-08-01Johan Schön  // body, title, description, keywords
feb96a2001-05-31Johan Schön  int document_size;
300e4c2001-05-17Johan Schön  mapping(string:string) uri_anchors=([]); // Maps un-normalized URLs to raw text // ([ "http://www.roxen.com": "the Roxen web-server" ]) array(Standards.URI|string) links=({}); void fix_relative_links(Standards.URI base_uri) { for(int i=0; i<sizeof(links); i++)
34df362001-05-29Johan Schön  {
300e4c2001-05-17Johan Schön  links[i]=Standards.URI(links[i], base_uri);
34df362001-05-29Johan Schön  if(links[i]->fragment) links[i]->fragment=0; }
300e4c2001-05-17Johan Schön  } } Output filter(Standards.URI uri, string|Stdio.File data,
e262e52001-06-05Per Hedbor  string content_type, mixed ... more);
32e8b52001-06-28Johan Schön 
94b6102001-08-08Fredrik Noring private string tmp_unique = sprintf("%d.%d", time(), getpid()); private int tmp_sequence = 0;
32e8b52001-06-28Johan Schön string tmp_filename() {
94b6102001-08-08Fredrik Noring  return sprintf("../var/tmp/search.tmp.%s.%d", tmp_unique, tmp_sequence++); } string my_popen(array(string) args) // A smarter version of Process.popen: No need to quote arguments. { Stdio.File pipe0 = Stdio.File(); Stdio.File pipe1 = pipe0->pipe(Stdio.PROP_IPC); if(!pipe1) if(!pipe1) error("my_popen failed (couldn't create pipe).\n"); Process.create_process(args, ([ "env":getenv(), "stdout":pipe1 ])); pipe1->close(); string result = pipe0->read(); if(!result) error("my_popen failed with error "+pipe0->errno()+".\n"); pipe0->close(); return result;
32e8b52001-06-28Johan Schön }