#! /usr/local/bin/forth -q \ program to run traceroute and send result back as an html file \ (c) Copyright 1996 Taygeta Scientific Inc. Permission is granted by the \ author to use this software for any application provided this \ copyright notice is preserved. \ rcsid: @(#)trace 1.1 13:38:11 8/1/96 EFC \ ============= A String pointer data structure ============================= : string: \ build a counted string CREATE 0 , \ POINTER to the data 0 , \ the count DOES> DUP @ SWAP CELL+ @ ; string: command string: command-line string: raddr string: rhost 0 VALUE seq-file 0 VALUE log-file 0 VALUE seq-no CREATE NEW-LINE-CHARS 2 ALLOT 10 NEW-LINE-CHARS C! \ 13 NEW-LINE-CHARS 1+ C! create out-buf 32 ALLOT : $! ( addr count 'str -- ) \ store a string >BODY SWAP OVER CELL+ ! ! ; : $len ( addr count -- count ) SWAP DROP ; : $copy ( addr count 'str -- ) HERE 2 PICK ROT $! \ store string pointer to HERE HERE SWAP DUP ALLOT CMOVE ; : $cat ( addr1 count1 addr2 count2 -- addr count ) 2 PICK OVER + DUP >R HERE >R ALLOT 2SWAP R@ SWAP DUP >R CMOVE \ move first string R> R@ + SWAP CMOVE \ move the second string R> R> ; : atol ( addr count -- d ) >R 0. ROT R> >NUMBER 2DROP ; : atoi ( addr count -- n ) atol DROP ; : move-chars ( dest src count -- dest count ) >R OVER R@ CMOVE R> ; : itoa ( n -- addr count ) \ (signed) int to counted string out-buf aligned SWAP DUP >R ABS S>D <# #S R> SIGN #> move-chars ; \ ANS Brute force OPEN-APPEND, depending upon what is under the hood, there may \ be more efficient definitions : OPEN-APPEND R/W OPEN-FILE DUP 0= IF OVER FILE-SIZE 0= IF 3 PICK REPOSITION-FILE DROP THEN THEN ; : nack ( -- ) ."
" CR ." Sorry, I can't figure out where you are so I can't " ." trace how long it takes to get a packet to me " ."
" CR ."
" CR ; : trailer ( -- ) ."
Another CGI script written in" ." Forth !
" CR
." "
." "
." Back to Skips Home page. " CR
."
" CR ; : sig ."
" CR
command-line system
." " CR
ELSE
nack
THEN
trailer
sig
log-file CLOSE-FILE DROP
;
trace bye