markd@silogic.UUCP (Mark DiVecchio) (12/12/89)
I am trying to get pathalias to run on a 286 SCO Xenix 2.2 box. I have compiled it ok. I can feed it a sub-set of the unpacked maps like: pathalias -f u.usa.ca* and it works ok. If I feed it the entire map: pathalias -f u.* it dies with a Memory Fault (with -DSTATIC=static) I tried -DSTATIC=extern and it fails with a Segmentation Fault. I compiled it with -O -LARGE -M2l -F C000 for [CL]FLAGS. If I make the stack any bigger the compiler complains that data + stack > 64K. I have version 9 dated 10/87 of pathalias. -- Mark DiVecchio, Silogic Systems, 619-549-9841 9888 Carroll Center Road, Suite 113, San Diego, CA 92126 ...!ucsd!celerity!celit!silogic!markd ...!ucsd!ucsdhub!celit!silogic!markd celit!silogic!markd@fps.com
chip@ateng.com (Chip Salzenberg) (12/13/89)
Once in a while, someone needs to port Pathalias to SCO Xenix/286. Once upon a time, I did it; here are the patches. Shar and enjoy. Be forewarned -- this patch uses a hard-coded max number of hosts. Increase the value of REALSIZE if this becomes a problem. Also, all the tests of M_XENIX might be better changed to M_I286. But you get the idea. -- #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the "#! /bin/sh" line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create the files: # Makefile # palias9x.patch # This archive created: Mon Feb 8 14:48:48 1988 export PATH; PATH=/bin:$PATH : echo 'shar: extracting "Makefile" (1348 characters) ' if test -f 'Makefile' then echo 'shar: will not overwrite existing file "Makefile" ' else sed 's/^X//' << \SHAR_EOF > 'Makefile' X#!/bin/make -f X# pathalias -- by steve bellovin, as told to peter honeyman X XSHELL = /bin/sh X X### configuration section X### X# if you can't or don't intend to use dbm files, X# don't bother with DBM or makedb XDBM = -ldbm X# or if you roll your own ... X# DBM = dbm.o X### X# where is getopt (if not in the c library)? X# GETOPT = getopt.o X### end of configuration section X X XCC = cc -M2le XCFLAGS = -O -DSTATIC=static XLDFLAGS = $(GETOPT) -F 2000 XYFLAGS = -d X XOBJ = addlink.o addnode.o local.o main.o mapit.o mapaux.o mem.o parse.o printit.o XHDRS = def.h config.h XCSRC = addlink.c addnode.c local.c main.c mapit.c mapaux.c mem.c printit.c XLSRC = $(CSRC) parse.c XSRC = $(CSRC) parse.y makedb.c arpatxt.c X Xall: pathalias makedb X Xpathalias: $(OBJ) X $(CC) $(OBJ) $(LDFLAGS) -o pathalias X X$(OBJ): $(HDRS) X Xparse.c: parse.y $(HDRS) X $(YACC) $(YFLAGS) parse.y X mv y.tab.c parse.c X Xmakedb: makedb.o X $(CC) makedb.o $(LDFLAGS) $(DBM) -o makedb X Xmakedb.o: config.h X Xarpatxt: arpatxt.o X $(CC) arpatxt.o $(LDFLAGS) -o arpatxt X Xclean: X rm -f *.o y.tab.? parse.c X Xclobber: clean X rm -f pathalias makedb arpatxt X Xtags: $(SRC) $(HDRS) X ctags -w $(HDRS) $(SRC) X Xbundle: X @bundle README CHANGES pathalias.1 Makefile ${HDRS} ${SRC} X Xlint: $(LSRC) X lint $(CFLAGS) $(LSRC) X lint $(CFLAGS) makedb.c X lint $(CFLAGS) arpatxt.c X Xinstall: X copy -om pathalias makedb /usr/local/bin SHAR_EOF if test 1348 -ne `wc -c < 'Makefile'` then echo 'shar: error transmitting "Makefile" (should have been 1348 characters) ' fi chmod 644 'Makefile' fi # end of overwriting check : echo 'shar: extracting "palias9x.patch" (8266 characters) ' if test -f 'palias9x.patch' then echo 'shar: will not overwrite existing file "palias9x.patch" ' else sed 's/^X//' << \SHAR_EOF > 'palias9x.patch' XIndex: addlink.c X*** palias_orig/addlink.c Mon Feb 8 14:34:22 1988 X--- palias/addlink.c Mon Feb 8 09:48:42 1988 X*************** X*** 9,11 **** X extern link *addlink(); X! extern void deadlink(), atrace(); X extern int tracelink(); X--- 9,11 ---- X extern link *addlink(); X! extern void freelink(), deadlink(), atrace(); X extern int tracelink(); XIndex: addnode.c X*** palias_orig/addnode.c Mon Feb 8 14:35:01 1988 X--- palias/addnode.c Mon Feb 8 11:10:09 1988 X*************** X*** 7,14 **** X X- /* exports */ X- node *addnode(), *addprivate(); X- void alias(), hashanalyze(), fixprivate(), penalize(); X- node **Table; /* hash table ^ priority queue */ X- long Tabsize; /* size of Table */ X- X /* imports */ X--- 7,8 ---- X*************** X*** 18,20 **** X extern int Iflag, Tflag, Vflag; X- extern node **Table; X extern long Ncount, Tabsize; X--- 12,13 ---- X*************** X*** 23,24 **** X--- 16,34 ---- X X+ /* exports */ X+ node *addnode(), *addprivate(); X+ void alias(), hashanalyze(), fixprivate(), penalize(); X+ X+ #ifdef M_XENIX X+ X+ #define REALSIZE 21499L /* arbitrary prime number */ X+ node* huge Table[REALSIZE]; /* hash table ^ priority queue */ X+ long Tabsize; /* size of Table */ X+ X+ #else X+ X+ node **Table; /* hash table ^ priority queue */ X+ long Tabsize; /* size of Table */ X+ X+ #endif X+ X /* privates */ X*************** X*** 163,164 **** X--- 173,183 ---- X if (isfull(Ncount)) { X+ #ifdef M_XENIX X+ if (Tabsize == 0) { X+ crcinit(); X+ Tabindex = 0; X+ Tabsize = REALSIZE; X+ Tab128 = (HIGHWATER * Tabsize * 128L)/100L; X+ } else X+ die("Too many hosts (Table[] is full)"); X+ #else X if (Tabsize == 0) { /* first time */ X*************** X*** 171,172 **** X--- 190,192 ---- X rehash(); /* more, more! */ X+ #endif X } X*************** X*** 199,200 **** X--- 219,222 ---- X X+ #ifndef M_XENIX X+ X STATIC void X*************** X*** 229,230 **** X--- 251,254 ---- X } X+ X+ #endif /* !M_XENIX */ X XIndex: config.h X*** palias_orig/config.h Mon Feb 8 14:34:26 1988 X--- palias/config.h Mon Feb 8 09:26:37 1988 X*************** X*** 2,4 **** X X! #undef STRCHR /* have strchr -- system v and many others */ X X--- 2,4 ---- X X! #define STRCHR /* have strchr -- system v and many others */ X X*************** X*** 4,7 **** X X! #undef UNAME /* have uname() -- probably system v or 8th ed. */ X! #undef MEMSET /* have memset() -- probably system v or 8th ed. */ X X--- 4,7 ---- X X! #define UNAME /* have uname() -- probably system v or 8th ed. */ X! #define MEMSET /* have memset() -- probably system v or 8th ed. */ X X*************** X*** 7,10 **** X X! #define GETHOSTNAME /* have gethostname() -- probably bsd */ X! #define BZERO /* have bzero() -- probably bsd */ X X--- 7,10 ---- X X! #undef GETHOSTNAME /* have gethostname() -- probably bsd */ X! #undef BZERO /* have bzero() -- probably bsd */ X X*************** X*** 11,14 **** X /* default place for dbm output of makedb (or use -o at run-time) */ X! #define ALIASDB "/usr/local/lib/palias" X! X X--- 11,13 ---- X /* default place for dbm output of makedb (or use -o at run-time) */ X! #define ALIASDB "/usr/lib/uucp/paths" X XIndex: def.h X*** palias_orig/def.h Mon Feb 8 14:34:28 1988 X--- palias/def.h Sat Jan 9 17:50:15 1988 X*************** X*** 77,78 **** X--- 77,79 ---- X unsigned short n_flag; /* see manifests above */ X+ unsigned short n_filler; X }; XIndex: local.c X*** palias_orig/local.c Mon Feb 8 14:34:31 1988 X--- palias/local.c Mon Feb 8 09:48:42 1988 X*************** X*** 14,16 **** X { X! static struct utsname utsname; X X--- 14,16 ---- X { X! static struct utsname uts; X X*************** X*** 16,19 **** X X! uname(&utsname); X! return(utsname.nodename); X } X--- 16,19 ---- X X! uname(&uts); X! return(uts.nodename); X } XIndex: main.c X*** palias_orig/main.c Mon Feb 8 14:34:34 1988 X--- palias/main.c Mon Feb 8 09:48:42 1988 X*************** X*** 10,12 **** X /* exports */ X! extern void die(); X char *Cfile; /* current input file */ X--- 10,12 ---- X /* exports */ X! extern void die(), printit(); X char *Cfile; /* current input file */ XIndex: mapaux.c X*** palias_orig/mapaux.c Mon Feb 8 14:34:42 1988 X--- palias/mapaux.c Mon Feb 8 10:57:18 1988 X*************** X*** 9,11 **** X extern long Nheap, Hashpart, Tabsize; X! extern node **Table, *Home; X extern char *Graphout, *Linkout, *Netchars, **Argv; X--- 9,11 ---- X extern long Nheap, Hashpart, Tabsize; X! extern node *Home; X extern char *Graphout, *Linkout, *Netchars, **Argv; X*************** X*** 16,17 **** X--- 16,23 ---- X extern char *strsave(); X+ X+ #ifdef M_XENIX X+ extern node* huge Table[]; X+ #else X+ extern node** Table; X+ #endif X XIndex: mapit.c X*** palias_orig/mapit.c Mon Feb 8 14:35:28 1988 X--- palias/mapit.c Mon Feb 8 11:52:57 1988 X*************** X*** 19,21 **** X extern int Tflag, Vflag; X! extern node **Table, *Home; X extern char *Linkout, *Graphout; X--- 19,21 ---- X extern int Tflag, Vflag; X! extern node *Home; X extern char *Linkout, *Graphout; X*************** X*** 22,23 **** X--- 22,29 ---- X X+ #ifdef M_XENIX X+ extern node* huge Table[]; X+ #else X+ extern node** Table; X+ #endif X+ X extern void freelink(), resetnodes(), printit(), dumpgraph(); X*************** X*** 32,33 **** X--- 38,43 ---- X static long Heaphighwater; X+ X+ #ifdef M_XENIX X+ static link* huge* Heap; X+ #else X static link **Heap; X*************** X*** 33,34 **** X--- 43,45 ---- X static link **Heap; X+ #endif X X*************** X*** 51,52 **** X--- 62,66 ---- X /* re-use the hash table space for the heap */ X+ #ifdef M_XENIX X+ Heap = (link * huge *) Table; X+ #else X Heap = (link **) Table; X*************** X*** 52,53 **** X--- 66,68 ---- X Heap = (link **) Table; X+ #endif X Hashpart = pack(0L, Tabsize - 1); X*************** X*** 369,371 **** X { link *rval, *lastlink; X- register link **rheap; X X--- 384,385 ---- X*************** X*** 374,377 **** X X! rheap = Heap; /* in register -- heavily used */ X! rval = rheap[1]; /* return this one */ X X--- 388,390 ---- X X! rval = Heap[1]; /* return this one */ X X*************** X*** 378,381 **** X /* move last entry into root and reheap */ X! lastlink = rheap[Nheap]; X! rheap[Nheap] = 0; X X--- 391,394 ---- X /* move last entry into root and reheap */ X! lastlink = Heap[Nheap]; X! Heap[Nheap] = 0; X X*************** X*** 382,384 **** X if (--Nheap) { X! rheap[1] = lastlink; X lastlink->l_to->n_tloc = 1; X--- 395,397 ---- X if (--Nheap) { X! Heap[1] = lastlink; X lastlink->l_to->n_tloc = 1; X*************** X*** 401,403 **** X { register long pindx, cindx; X- register link **rheap = Heap; /* in register -- heavily used */ X node *child, *rchild, *parent; X--- 414,415 ---- X*************** X*** 405,407 **** X pindx = l->l_to->n_tloc; X! parent = rheap[pindx]->l_to; /* invariant */ X for ( ; (cindx = pindx * 2) <= Nheap; pindx = cindx) { X--- 417,419 ---- X pindx = l->l_to->n_tloc; X! parent = Heap[pindx]->l_to; /* invariant */ X for ( ; (cindx = pindx * 2) <= Nheap; pindx = cindx) { X*************** X*** 408,410 **** X /* pick lhs or rhs child */ X! child = rheap[cindx]->l_to; X if (cindx < Nheap) { X--- 420,422 ---- X /* pick lhs or rhs child */ X! child = Heap[cindx]->l_to; X if (cindx < Nheap) { X*************** X*** 411,413 **** X /* compare with rhs child */ X! rchild = rheap[cindx+1]->l_to; X /* X--- 423,425 ---- X /* compare with rhs child */ X! rchild = Heap[cindx+1]->l_to; X /* X*************** X*** 450,452 **** X long i, j; X! { register link *temp, **rheap; X X--- 462,464 ---- X long i, j; X! { register link *temp; X X*************** X*** 452,459 **** X X! rheap = Heap; /* heavily used -- put in register */ X! temp = rheap[i]; X! rheap[i] = rheap[j]; X! rheap[j] = temp; X! rheap[j]->l_to->n_tloc = j; X! rheap[i]->l_to->n_tloc = i; X } X--- 464,470 ---- X X! temp = Heap[i]; X! Heap[i] = Heap[j]; X! Heap[j] = temp; X! Heap[j]->l_to->n_tloc = j; X! Heap[i]->l_to->n_tloc = i; X } XIndex: mem.c X*** palias_orig/mem.c Mon Feb 8 14:34:45 1988 X--- palias/mem.c Mon Feb 8 09:48:42 1988 X*************** X*** 92,94 **** X #ifdef MYMALLOC X! addtoheap((char *) t, size * sizeof(node *)); X #else X--- 92,94 ---- X #ifdef MYMALLOC X! addtoheap((char *) t, (int)sizeof(node *) * size); X #else SHAR_EOF if test 8266 -ne `wc -c < 'palias9x.patch'` then echo 'shar: error transmitting "palias9x.patch" (should have been 8266 characters) ' fi chmod 444 'palias9x.patch' fi # end of overwriting check # End of shell archive exit 0 -- You may redistribute this article only to those who may freely do likewise. Chip Salzenberg at A T Engineering; <chip@ateng.com> or <uunet!ateng!chip> "The Usenet, in a very real sense, does not exist."