Source for funcs.cpp

This document shows the contents of funcs.cpp if you are starting the tutorial in Part 9. Defining the Remaining User Functions.

#include <istring.hpp>
IString Unauthorized(IString Function) {
   return Error("Unauthorized Access",
      "You do not have sufficient authority to access the "
      +Function
      +" function.");
}

IString Error(IString Title, IString Text) {
   return "<html><head><title>"
          +Title
          +"</title></head><body bgcolor=\"#FFFFFF\"><p><h3>"
          +Title
          +"</h3><p>"
          +Text
          +"</p></body></html>";
}

IString ReadFile(IString Path) {
   ifstream In(Path);
   if (!In) return "";
   return IString::lineFrom(In,EOF);
}

int NextTag(IString String, IString Tag, int StartPos=1) {
   return MinNonZero(
      String.indexOf(Tag+">",StartPos),
      String.indexOf(Tag+" ",StartPos),
      String.indexOf(Tag+"\n",StartPos));
   }
int MinNonZero(int a, int b, int c=0) {
   if (c>0) return MinNonZero(a,MinNonZero(b,c));
   if (a==0) return b;
   if (b==0) return a;
   if (a>b) return b;
   return a;
   }