//=-- PagePlugin.cpp - Abstract base class for page plugins to derive from ---=
//
//  This class provides the framework for plugins to extend.
//
//=---------------------------------------------------------------------------=
//  This file is copyright (c) 1997-1998 Chris Lattner
//=---------------------------------------------------------------------------=

#include "FilterHandle.h"
#include "FilterManager.h"
#include "PagePlugin.h"
#include "Options.h"
#include "AccessFormatPlugin.h"
#include "VarTable.h"

PagePlugin::PagePlugin(const String &Name) : Plugin(Name) { 
  Flags = FClear; 
}

int PagePlugin::ValidateName(String &name) { 
  return name.iCompare(Name); 
}

void PagePlugin::MetaProcessAccess(AccessFormatPlugin &A) {
  if (Flags & FNoAccesses)  // Ignore all hits?
    return;

  if ((Flags & FIgnoreErrors) && (A.GetStatusCode() >= 400))
    return;  // Ignore the errors.

  if (Flags & FAutoFilter)
    if (!DefFilter.Match(A)) 
      return;

  ProcessAccess(A);
}

void PagePlugin::MetaLoadSettings(VarTable *KL, int UF) {
  UpdateFreq = UF;

  // Set the current fullname to reflect the options...
  GetFullName(*KL, FullName, UpdateFreq);

  // Process the default filter operation...
  DefFilter = FilterManager::GetFilter(KL, "Filter");

  LoadSettings(KL);
}
