(FILECREATED " 9-Feb-85 16:38:54" {ERIS}<LISPCORE>LIBRARY>HTE.;1 5687 changes to: (VARS HTECOMS) (FNS ADDASSOC \HTE.PARSE.ENTRY \HTE.READ.FILE \HTE.READ; \HTE.READLINE) previous date: " 3-Feb-85 17:28:16" {ERIS}<SCHOEN>HTE.;5) (* Copyright (c) 1985 by Xerox Corporation. All rights reserved.) (PRETTYCOMPRINT HTECOMS) (RPAQQ HTECOMS ((RECORDS HOSTS.TXT.ENTRY HTELINE) (FNS ADDASSOC \HTE.PARSE.ENTRY \HTE.READ.FILE \HTE.READ; \HTE.READLINE) (INITVARS (HOSTS.TEXT.DIRECTORIES)))) [DECLARE: EVAL@COMPILE (DATATYPE HOSTS.TXT.ENTRY (HTE.TYPE HTE.ADDRESSES HTE.NAMES HTE.MACHINE.TYPE HTE.OS.TYPE HTE.PROTOCOLS)) (RECORD HTELINE (TYPE ADDRESSES NAMES MACHINE.TYPE OS.TYPE PROTOCOLS)) ] (/DECLAREDATATYPE (QUOTE HOSTS.TXT.ENTRY) (QUOTE (POINTER POINTER POINTER POINTER POINTER POINTER))) (DEFINEQ (ADDASSOC (LAMBDA (KEY VAL ALIST) (* ejs: "27-Jan-85 21:15") (LET ((OLDLST (FASSOC KEY ALIST))) (COND (OLDLST (push (CDR OLDLST) VAL)) (T (NCONC1 ALIST (LIST KEY VAL))))))) (\HTE.PARSE.ENTRY (LAMBDA (ENTRY) (* ejs: "27-Jan-85 21:43") (LET ((HTE.ENTRY (create HOSTS.TXT.ENTRY HTE.TYPE ←(CAR (fetch (HTELINE TYPE) of ENTRY)) HTE.ADDRESSES ←(for X in (fetch (HTELINE ADDRESSES) of ENTRY) collect (\IP.READ.STRING.ADDRESS (MKSTRING X))) HTE.NAMES ←(fetch (HTELINE NAMES) of ENTRY) HTE.MACHINE.TYPE ←(CAR (fetch (HTELINE MACHINE.TYPE) of ENTRY)) HTE.OS.TYPE ←(CAR (fetch (HTELINE OS.TYPE) of ENTRY)))) (PROTOLST (fetch (HTELINE PROTOCOLS) of ENTRY)) (PROTOCOLS (CONS))) (for PROTOENTRY in PROTOLST do (COND ((STRPOS (QUOTE /) PROTOENTRY) (ADDASSOC (SUBATOM PROTOENTRY 1 (SUB1 (STRPOS (QUOTE /) PROTOENTRY))) (SUBATOM PROTOENTRY (STRPOS (QUOTE /) PROTOENTRY NIL NIL NIL T)) PROTOCOLS)))) (replace (HOSTS.TXT.ENTRY HTE.PROTOCOLS) of HTE.ENTRY with (CDR PROTOCOLS)) (for NAME in (fetch (HTELINE NAMES) of ENTRY) do (PUTHASH NAME HTE.ENTRY \IP.HOSTNAMES))))) (\HTE.READ.FILE (LAMBDA (FILE WANTEDTYPES) (* ejs: "27-Jan-85 21:52") (DECLARE (GLOBALVARS \IP.HOSTNAMES)) (CLRHASH \IP.HOSTNAMES) (SETQ FILE (OPENSTREAM FILE (QUOTE INPUT) (QUOTE OLD))) (OR WANTEDTYPES (SETQ WANTEDTYPES (QUOTE (HOST)))) (bind (SCRATCHLST ←(LIST NIL NIL NIL NIL NIL NIL)) ENTRY until (EOFP FILE) do (SETQ ENTRY (\HTE.READLINE FILE SCRATCHLST)) (COND ((FMEMB (CAR (fetch (HTELINE TYPE) of ENTRY)) WANTEDTYPES) (\HTE.PARSE.ENTRY ENTRY)))) (CLOSEF FILE))) (\HTE.READ; (LAMBDA (FL RDTBL) (* ejs: "27-Jan-85 20:19") (until (SELCHARQ (BIN FL) ((CR LF EOL) T) NIL)) NIL)) (\HTE.READLINE (LAMBDA (STREAM SCRATCHLST WANTEDTYPES) (* ejs: "27-Jan-85 21:55") (COND (SCRATCHLST (for X on SCRATCHLST do (RPLACA X NIL))) (T (SETQ SCRATCHLST (LIST NIL NIL NIL NIL NIL NIL)))) (bind CHARS FIELDCONTENTS CH (FIELD# ← 1) do (COND ((NOT (EOFP STREAM)) (SETQ CH (BIN STREAM)) (SELCHARQ CH (: (COND (CHARS (push FIELDCONTENTS (PACKC (DREVERSE CHARS))) (SETQ CHARS))) (COND (FIELDCONTENTS (RPLACA (FNTH SCRATCHLST FIELD#) (DREVERSE FIELDCONTENTS)) (SETQ FIELDCONTENTS) (add FIELD# 1) (COND ((AND (EQ FIELD# 2) (NOT (FMEMB (CAAR SCRATCHLST) WANTEDTYPES))) (until (OR (EOFP STREAM) (NOT (SELCHARQ (\PEEKBIN STREAM) ((CR EOL LF) T) NIL))) do (\HTE.READ; STREAM))))))) (; (\HTE.READ; STREAM) (RETURN)) ((SPACE TAB ,) (COND (CHARS (push FIELDCONTENTS (PACKC (DREVERSE CHARS))) (SETQ CHARS)))) ((EOL CR LF) (until (OR (EOFP STREAM) (NOT (SELCHARQ (\PEEKBIN STREAM) ((CR EOL LF) T) NIL))) do (BIN STREAM)) (COND ((OR (EOFP STREAM) (SELCHARQ (\PEEKBIN STREAM) ((SPACE TAB) NIL) T)) (RETURN SCRATCHLST)))) (push CHARS CH))) (T (COND (CHARS (push FIELDCONTENTS (PACKC (DREVERSE CHARS))) (SETQ CHARS))) (COND (FIELDCONTENTS (RPLACA (FNTH SCRATCHLST FIELD#) (DREVERSE FIELDCONTENTS)) (SETQ FIELDCONTENTS) (add FIELD# 1) (COND ((AND (EQ FIELD# 2) (NOT (FMEMB (CAAR SCRATCHLST) WANTEDTYPES))) (until (OR (EOFP STREAM) (NOT (SELCHARQ (\PEEKBIN STREAM) ((CR EOL LF) T) NIL))) do (\HTE.READ; STREAM)))))) (RETURN SCRATCHLST)))))) ) (RPAQ? HOSTS.TEXT.DIRECTORIES ) (PUTPROPS HTE COPYRIGHT ("Xerox Corporation" 1985)) (DECLARE: DONTCOPY (FILEMAP (NIL (845 5576 (ADDASSOC 855 . 1116) (\HTE.PARSE.ENTRY 1118 . 2410) (\HTE.READ.FILE 2412 . 3080) (\HTE.READ; 3082 . 3286) (\HTE.READLINE 3288 . 5574))))) STOP