PostScript Referral Log Reader
By Don Lancaster                                                                   
Version 1.3 February 15, 1998
Copyright c. 1998 by Don Lancaster and Synergetics, Box 809, Thatcher AZ, 85552
(520) 428-4073. synergetics@tinaja.com All commercial rights and all electronic media
rights are *fully* reserved. Linking welcome. Reposting is expressly forbidden.

Consulting services available.
Further support on www.tinaja.com/info01.html  


(The following is believed correct. Please report any errors or differing experiences.)

% This is yet another example of PostScript-as-language applied
% to solving real world problems. These particular routines read
% an extended virtual log file and rewrite it in PostScript friendly
% format for a single client. A filtered list of referrals is also
% generated.

% Arrangements have to be made with your ISP to get a copy of the
% current log file resident on your local host.

% The Microsoft Server extended file format is based on one ASCII
% line per hit, with each field of that line delimited by ", "

% A format example might be...

% field numbers have been added to the beginning of each example
% above; they are NOT in the actual file listing.

%%%%%%%%%%%% (A) INSTALL AND RUN GONZO UTILITIES %%%%%%%%%%%%%%%%%%

% This optionally uses my gonzo utilities from
%
http://www.tinaja.com/psutils/gonzo20.ps

% (C:\\windows\\desktop\\gonzo\\gonzo.ps) run % run the gonzo utilities

% gonzo begin          % activate the gonzo utilities
% ps.util.1 begin
% % printerror
% nuisance begin

%%%%%% (B) FORMAT EXTENDED LOG FILE INTO POSTSCRIPT ARRAYS %%%%%%%

/rawlogfilename (C:\\windows\\desktop\\Zeketo~1\\full.log) def
/fmtlogfilename (C:\\windows\\desktop\\Zeketo~1\\cust.log) def
/reflogfilename (C:\\windows\\desktop\\Zeketo~1\\refer.log) def

/sourcefile rawlogfilename (r) file def       % create files
/targetfile fmtlogfilename (w) file def
/referfile reflogfilename (w) file def
/str 1000 string def /delim (, ) def          % delimiter
/logelementcount 18 def                       % expected valid log fields
/serverfilename (www.tinaja.com) def          % customer web site
/refexcludeif                                 % self-referrals to exclude [(tinaja)(inaja)(TINAJA)(file:)] def  % also local bookmarks

% /writecurmat writes the current customer log file line to targetfile
% in a "PostScript friendly" array-of-strings format...

/writecurmat { targetfile (\n [ ) writestring % start array
curmat { targetfile (\() writestring          % start paren targetfile
exch writestring                              % write filename
targetfile (\)) writestring } forall          % end paren repeat
targetfile ( ]\n) writestring                 % end array
} def

% /extractarray converts the log text line into an array of strings...

/extractarray {

mark curline 30 {delim search {exch pop exch}{ exit} ifelse } repeat
pop ]

/curmat exch store                           % save matrix

curmat length logelementcount eq {           % valid # of entries?
curmat 6 get serverfilename eq               % valid customer?

{writecurmat reportref} if } if % yes, report } def

%%%%%%%%% (C) REFERRAL FILTER AND REPORTER %%%%%%%%%%%%%%%%%%

% /reportref filters the referrals and reports only the chosen ones
% to referfile. At present, all filtered referrals are reported;
% they can later easily be ranked and duplicates counted, etc...

/reportref { true                           % assume valid

% filter for your self-references

refexcludeif {/cursearch exch store curmat 15 get cursearch search
              {pop pop pop pop false}{pop} ifelse } forall

% remove any search engine by assuming a (?) character in it...

curmat 15 get (?) search                % false if an engine
          {pop pop pop pop false}{pop} ifelse

% remove blank hits by eliminating short ones...

curmat 15 get length 3 lt {pop false} if     % no dashes

% and report valid remaining referrals (not host, engine, or (-))

{curmat 15 get referfile exch writestring    % write referral referfile
(\n) writestring } if                        % and cr
} def

%%%%%%%%%%%% (D) MAIN SUPERVISORAY SCAN CODE %%%%%%%%%%%%%%%%%%%%%%%%%%

% /processrawlogline is a supervisory proc that saves the line
% and then converts it to a PostScript friendly array of strings...

/processrawlogline {/curline exch store extractarray} def

% /scaninput reads the raw log file a line at a time and processes it...

/scaninput {{sourcefile str readline {processrawlogline} {processrawlogline exit} ifelse} loop } def

%%%%%%%%% (E) DEMO - REMOVE OR ALTER BEFORE REUSE %%%%%%%%%%%%

% this actually does the whole job...
% Be sure to alter the filenames above!

scaninput

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Copyright c. 1998 by Don Lancaster and Synergetics, Box 809,
% Thatcher AZ, 85552 (520) 428-4073. synergetics@tinaja.com
% All commercial rights and all electronic media rights are
% *fully* reserved. Linking welcome. Reposting is expressly forbidden.

% Consulting services avaialable
% Further support on www.tinaja.com/info01.html

%EOF



Please click here to...