home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / compsrcs / unix / volume07 / paths.mk < prev    next >
Encoding:
Text File  |  1988-09-11  |  28.1 KB  |  953 lines

  1. Reply-To: tron@nsc.UUCP (Ronald S. Karr)
  2. Subject:  v07i087:  Makefile to build UUCP paths
  3. Newsgroups: mod.sources
  4. Approved: mirror!rs
  5.  
  6. Submitted by: Ronald S. Karr <tron@nsc.NSC.COM>
  7. Mod.sources: Volume 7, Issue 87
  8. Archive-name: paths.mk
  9.  
  10. The following is a shell archive containing a Makefile and sample data
  11. files for creating a paths file suitable for smail and other UUCP-domain
  12. routing programs.
  13.  
  14. Also included is the patch to smail that I posted to net.sources.
  15. The patch allows the specification of a site to send any mail
  16. that you can't route.
  17.  
  18. This package assumes that you have pathalias, makedb (part of the pathalias
  19. distribution) and the compress utilities running on your system.  If you
  20. are not using makedb or the compress utilities, you will need to edit
  21. the Makefile to remove references to these programs.
  22.  
  23. If you are running uuhosts to unbatch USENET map files, you will need to
  24. modify it to use the Makefile given here to create paths file.  This
  25. makefile will run uuwhere, to create the paths file annotated by location.
  26. If you don't use this or have the uuwhere program somewhere other than
  27. where we have it on our system, you will need to modify the Makefile.
  28.  
  29. ======
  30.   Ronald S. Karr            USENET: hplabs!nsc!tron
  31.   National Semiconductor        ARPA:   decwrl!nsc!tron@ucbvax.ARPA
  32.   Sunnyvale, CA                DOMAIN: tron@nsc.NSC.COM
  33. -------------------------  Cut here ------------------------
  34. #!/bin/sh
  35. # shar:    Shell Archiver
  36. #    Run the following text with /bin/sh to create:
  37. #    Makefile
  38. #    README
  39. #    dead.samp
  40. #    domain.com.samp
  41. #    forces.samp
  42. #    local.map.samp
  43. #    oursite.samp
  44. #    pathmerge.c
  45. #    smail.patch
  46. #    stripdom.c
  47. #    sub.domain.com.samp
  48. # This archive created: Wed Oct 15 01:04:39 1986
  49. echo shar: extracting Makefile '(5119 characters)'
  50. sed 's/^XX//' << \SHAR_EOF > Makefile
  51. XX#!/bin/make -f
  52. XX# MAKEFILE FOR THE PATHALIAS DATABASE
  53. XX#
  54. XX#    @(#)Makefile    1.9    9/25/86
  55. XX#    @(#) Ronald S. Karr <tron@SC.NSC.COM>
  56. XX#    @(#) National Seiconductor, Sunnyvale
  57. XX#
  58. XX# keywords:
  59. XX#    full.paths - make pathalias database with domain and USENET maps.
  60. XX#    domain.paths - make pathalias database with only domain maps.
  61. XX#    local.paths - make the local domain paths.
  62. XX#    extern.paths - make the domain-external paths.
  63. XX#    dead.script - make sed script out of dead file.
  64. XX#    hostmapfile - install our current entry in the USENET maps.
  65. XX#    stripdom - make the stripdom program.
  66. XX#    pathmerge - make the pathmerge program.
  67. XX
  68. XX# HOST INFORMATION
  69. XX#    who we are
  70. XXHOST        = oursite
  71. XX#
  72. XX#    the USENET map file containing our map entry
  73. XX#    For example:  nsc is currently in u.usa.ca.4.
  74. XX#    This can change, so be prepared to make sure it is
  75. XX#    correct every once in a while.
  76. XX#
  77. XX#    If you don't know, leave this blank
  78. XXHOSTMAPFILE    = u.usa.ca.1
  79. XX#
  80. XX#    our own, current, map entry file
  81. XX#    If HOSTMAPFILE is blank, leave HOSTFILE blank as well.
  82. XXHOSTFILE    = oursite.samp
  83. XX#
  84. XX#    define this to be the site we forward mail to that
  85. XX#    we cannot find a path to in our database.
  86. XX#    Set it to nothing if we do not have a more intelligent
  87. XX#    mail forwarding site.
  88. XX#
  89. XX#    The format should be:  forwarding-relay = hostname
  90. XX#    If you hard-coded the mail forwarding site in the smail
  91. XX#    defs.h program, don't worry about this one.
  92. XXFORWARD        = 
  93. XX
  94. XX# DOMAIN INFORMATION
  95. XX#    List here domains that we wish to be able to abbreviate.
  96. XX#    I.e., if you wished to be able to abbreviate the domain
  97. XX#    .subdomain.domain to allow the use of only .subdomain,
  98. XX#    define that here.
  99. XXDOMAINS        = .domain.com .sub.domain.com .far.domain.com
  100. XX#
  101. XX#    Files to include for domain map.
  102. XXDOMAINFILES    = domain.com.samp sub.domain.com.samp
  103. XX
  104. XX# USENET MAP DATABASE
  105. XX#    Make this the directory containing the compressed
  106. XX#    USENET map files.
  107. XXMAPS        = /usr/spool/uumaps
  108. XX
  109. XX# EXTERNAL INFORATION
  110. XX#    Files for generation of external paths
  111. XX#    (not including USENET Map database)
  112. XXEXTERNFILES    = local.map
  113. XX
  114. XX# DESTINATION
  115. XX#    Directory containing the paths file and DBM database.
  116. XXPATHDIR        = /usr/lib/uucp
  117. XX
  118. XX#    PATH variable for the shell
  119. XXPATH        = .:/usr/local:/usr/local/bin:/usr/new:/usr/ucb:/usr/bin:/bin
  120. XX
  121. XXSHELL        = /bin/sh
  122. XX
  123. XX#    If you are including the USENET maps, make this full.paths
  124. XX#    Otherwise, make this domain.paths.
  125. XXall:        full.paths
  126. XX
  127. XX# build paths file given full USENET and local domain information.
  128. XX# The pathmerge seems to make mistakes when given more than two files,
  129. XX# so we only give it two files at a time, here.
  130. XXfull.paths:    .full.paths
  131. XX.full.paths:    stripdom pathmerge extern.paths local.paths forces
  132. XX        sed    -e '/^#/d' \
  133. XX            -e '/^[     ]*$$/d' \
  134. XX            -e 's/[     ][     ]*/    /' \
  135. XX            < forces | sort | \
  136. XX            pathmerge - local.paths | pathmerge - extern.paths | \
  137. XX            stripdom ${DOMAINS} > ${PATHDIR}/.pa.temp
  138. XX        makedb -o ${PATHDIR}/.pa.temp ${PATHDIR}/.pa.temp
  139. XX        mv -f ${PATHDIR}/.pa.temp     ${PATHDIR}/paths
  140. XX        -if test makedb != true; then \
  141. XX            mv -f ${PATHDIR}/.pa.temp.dir ${PATHDIR}/paths.dir;\
  142. XX            mv -f ${PATHDIR}/.pa.temp.pag ${PATHDIR}/paths.pag;\
  143. XX        fi
  144. XX        rm -f .domain.paths
  145. XX        touch .full.paths
  146. XX
  147. XX# build paths file only with domain information.
  148. XXdomain.paths:    .domain.paths
  149. XX.domain.paths:    stripdom pathmerge local.paths forces
  150. XX        sed    -e '/^#/d' \
  151. XX            -e '/^[     ]*$$/d' \
  152. XX            -e 's/[     ][     ]*/    /' \
  153. XX            < forces | sort | \
  154. XX            pathmerge - local.paths | \
  155. XX            stripdom ${DOMAINS} > ${PATHDIR}/.pa.temp
  156. XX        makedb -o ${PATHDIR}/.pa.temp ${PATHDIR}/.pa.temp
  157. XX        mv -f ${PATHDIR}/.pa.temp     ${PATHDIR}/paths
  158. XX        mv -f ${PATHDIR}/.pa.temp.dir ${PATHDIR}/paths.dir
  159. XX        mv -f ${PATHDIR}/.pa.temp.pag ${PATHDIR}/paths.pag
  160. XX        rm -f .full.paths
  161. XX        touch .domain.paths
  162. XX
  163. XX# build a file containing paths for the local domain.
  164. XXlocal.paths:    ${DOMAINFILES}
  165. XX        (    echo ${FORWARD}; \
  166. XX            cat ${DOMAINFILES}; \
  167. XX        ) | pathalias -l ${HOST} -i 2>> ERRORS | sort > local.paths
  168. XX
  169. XX# build a file containing paths for the USENET.
  170. XX# the uuwhere stuff isn't critical, so ignore any errors from it.
  171. XXextern.paths:    /DONE .hostmapfile ${EXTERNFILES} dead.script
  172. XX        (    echo ${FORWARD}; \
  173. XX            zcat ${MAPS}/u.*.Z; \
  174. XX            cat ${EXTERNFILES}; \
  175. XX        ) | pathalias -l ${HOST} -i `cat dead.script` 2>> ERRORS | \
  176. XX            sort > extern.paths
  177. XX        -if test -f ${MAPS}/lib/uuwhere; then ${MAPS}/lib/uuwhere; fi
  178. XX
  179. XX# The file DONE should exist if you use uuhosts -unbatch for news.
  180. XX# but if it doesn't, then this will keep extern.paths happy.
  181. XX/DONE:
  182. XX        -touch /DONE
  183. XX
  184. XX# Remove the comments here to enable the automatic editing of
  185. XX# the map files to include an up-to-date copy of your map entry.
  186. XXhostmapfile:    
  187. XX.hostmapfile:    ${MAPS}/${HOSTMAPFILE}.Z ${HOSTFILE}
  188. XX#        -zcat ${MAPS}/${HOSTMAPFILE}.Z > ${MAPS}/.ho.temp
  189. XX#        (    echo   "1;/^#N[     ]*${HOSTFILE}$$/,//;/^#N/-2d"; \
  190. XX#            echo    ".-1r ${HOST}"; \
  191. XX#            echo    "w"; \
  192. XX#            echo    "q"; \
  193. XX#        ) | ed - ${MAPS}/.ho.temp
  194. XX#        -compress ${MAPS}/.ho.temp
  195. XX#        -mv -f ${MAPS}/.ho.temp.Z ${MAPS}/${HOSTMAPFILE}.Z
  196. XX        touch .hostmapfile
  197. XX
  198. XX# Create a file which can be cat'ed into the argument list for pathalias.
  199. XXdead.script:    dead
  200. XX        awk '/^[^#     ]/ { print "-d " $$1 }' < dead > dead.script
  201. XX
  202. XXstripdom:    stripdom.c
  203. XX        ${CC} ${CFLAGS} -o stripdom stripdom.c
  204. XXpathmerge:    pathmerge.c
  205. XX        ${CC} ${CFLAGS} -o pathmerge pathmerge.c
  206. SHAR_EOF
  207. if test 5119 -ne "`wc -c Makefile`"
  208. then
  209. echo shar: error transmitting Makefile '(should have been 5119 characters)'
  210. fi
  211. echo shar: extracting README '(2965 characters)'
  212. sed 's/^XX//' << \SHAR_EOF > README
  213. XX@(#)README    1.3    9/23/86
  214. XX@(#) Ronald S. Karr
  215. XX@(#) National Semiconductor, Sunnyvale
  216. XX
  217. XX    The files in this distribution comprise a set of programs
  218. XX    and sample data files for the generation of a paths file
  219. XX    for use with smail or other mailers that can use the data
  220. XX    generated by pathalias.
  221. XX
  222. XX    To configure the system for your site, write some local
  223. XX    connections maps in some files in this directory, write
  224. XX    a dead, forces and local.map file, using the samples as
  225. XX    guidelines, and edit the Makefile to reflect your current
  226. XX    domain configuration.
  227. XX
  228. XXThe files in this directory:
  229. XX
  230. XXDocumentation
  231. XX
  232. XX README
  233. XX    This file.
  234. XX
  235. XX
  236. XXFiles used for generating local connection paths
  237. XX
  238. XX domain.com.samp
  239. XX    The connection map for the top level of the DOMAIN.COM domain.
  240. XX    A path file is generated for this independently of the
  241. XX    the path file generation for external references.  Then,
  242. XX    the paths in this file are merged into the normal paths
  243. XX    file, overriding any of its paths.
  244. XX
  245. XX sub.domain.com.samp
  246. XX    The connection map for the local subdomain of the domain
  247. XX    DOMAIN.COM.  This is used concurrently with the domain.com
  248. XX    file for path generation.
  249. XX
  250. XX local.paths
  251. XX    The paths computed from pathalias operating upon domain.com
  252. XX    and sub.domain.com.
  253. XX
  254. XX
  255. XXFiles used for generating external connection paths
  256. XX
  257. XX oursite.samp
  258. XX    The external connection map for this host.  This should
  259. XX    only contain information for machines talking to other
  260. XX    machines outside of the DOMAIN.COM domain and should not
  261. XX    contain information on connections within the DOMAIN.COM
  262. XX    domain.
  263. XX
  264. XX local.map.samp
  265. XX    General connection map that contains information which
  266. XX    we know about, but which is not broadcast.  This can also
  267. XX    be used to give lower values to connections, so that
  268. XX    they will be used in preference to other connections.
  269. XX    This file is used concurrently with external maps path
  270. XX    generation.
  271. XX
  272. XX dead.samp
  273. XX    A list of links we consider to be dead, thus overriding
  274. XX    whatever anybody else says.
  275. XX
  276. XX extern.paths.samp
  277. XX    The paths computed from the USENET maps and the above
  278. XX    files.
  279. XX
  280. XX
  281. XXOther files
  282. XX forces.samp
  283. XX    A file of explicit paths to override any paths computed
  284. XX    by Pathalias.
  285. XX Makefile.FORM
  286. XX    A makefile for generating the complete path database
  287. XX    in /usr/lib/uucp/paths{,.dir,.pag}.  Also generates
  288. XX    the intermediate file local.paths and stripdom.
  289. XX stripdom.c
  290. XX    Source for a program that filters pathalias output to
  291. XX    generate multiple lines for each hostname having the
  292. XX    form:
  293. XX
  294. XX        host.xx.domain.com
  295. XX
  296. XX            to make these names equivalent:
  297. XX
  298. XX        host.xx
  299. XX        host.xx.domain
  300. XX        host.xx.domain.com
  301. XX
  302. XX    Alternate domains to simplify can be specified in the
  303. XX    Makefile.
  304. XX pathmerge.c
  305. XX    Source for a program to take multiple sorted path files
  306. XX    as input files and produce on the standard output one path
  307. XX    to all machines listed, with preference given to paths
  308. XX    in the first files referenced in the argument list.
  309. XX
  310. XX    At present, this program does not work correctly when
  311. XX    given more than two input files.  However, pathmerge
  312. XX    can be cascaded as shown in Makefile.
  313. SHAR_EOF
  314. if test 2965 -ne "`wc -c README`"
  315. then
  316. echo shar: error transmitting README '(should have been 2965 characters)'
  317. fi
  318. echo shar: extracting dead.samp '(529 characters)'
  319. sed 's/^XX//' << \SHAR_EOF > dead.samp
  320. XX# SAMPLE DEAD LINKS FILE
  321. XX#
  322. XX#    @(#)dead.samp    1.1    9/8/86
  323. XX#    @(#) Ronald S. Karr <tron@mesa.nsc.com>
  324. XX#    @(#) National Semiconductor, Sunnyvale
  325. XX#
  326. XX#    This file contains links which are known to be dead, should not
  327. XX#    be used (for monetary purposes), or which are not reliable.
  328. XX#    As a result, these will be used only as a last resort when
  329. XX#    pathalias computes the paths it intends to use.
  330. XX
  331. XX#    Paths links we consider unreliable.
  332. XXmachineA!machineB
  333. XXmachineC!machineD
  334. XX
  335. XX#    Paths we would rather not use, for monetary reasons.
  336. XXourmachine!machineE
  337. SHAR_EOF
  338. if test 529 -ne "`wc -c dead.samp`"
  339. then
  340. echo shar: error transmitting dead.samp '(should have been 529 characters)'
  341. fi
  342. echo shar: extracting domain.com.samp '(1139 characters)'
  343. sed 's/^XX//' << \SHAR_EOF > domain.com.samp
  344. XX# SAMPLE CONNECTIVITY OF THE DOMAIN.COM DOMAIN
  345. XX#
  346. XX#    @(#)domain.com.samp    1.2    10/15/86
  347. XX#    @(#) Ronald S. Karr <tron@mesa.nsc.com>
  348. XX#    @(#) National Semiconductor, Sunnyvale
  349. XX#
  350. XX#    This file contains the connectivity maps for the top level
  351. XX#    of the DOMAIN.COM domain.  All gateways to DOMAIN.COM must
  352. XX#    have a current copy of this map.  Also, all other machines within
  353. XX#    DOMAIN.COM must either have a current copy of this map or be
  354. XX#    able to forward to a machine that does.
  355. XX
  356. XX#    Our site.
  357. XXoursite    near-site(DIRECT),
  358. XX    far-site(HOURLY)
  359. XX
  360. XX#    A nearby site in our organization.
  361. XXnear-site
  362. XX    oursite(DIRECT),
  363. XX    other-site(HOURLY)
  364. XX
  365. XX#    A far-away site in our organization.
  366. XXfar-site
  367. XX    oursite(HOURLY)
  368. XX
  369. XX#    Top-level machines in .DOMAIN.COM
  370. XXoursite        .domain.com    # we are a gateway site
  371. XXnear-site    .domain.com    # not a gateway, but top-level anyway
  372. XXfar-site    .domain.com    # far-site is also a gateway
  373. XX
  374. XX#    Aliases
  375. XXoursite        = oursite.domain.com
  376. XXnear-site    = near-site.domain.com
  377. XXfar-site    = far-site.domain.com
  378. XX
  379. XX# SUBNETS OF DOMAIN.COM (with gateways)
  380. XX
  381. XX#    Near subnet (we are gateway)
  382. XXoursite        = .sub.domain.com
  383. XX#    Far subnet (far-site is gateway)
  384. XXfar-site    = .far.domain.com
  385. SHAR_EOF
  386. if test 1139 -ne "`wc -c domain.com.samp`"
  387. then
  388. echo shar: error transmitting domain.com.samp '(should have been 1139 characters)'
  389. fi
  390. echo shar: extracting forces.samp '(773 characters)'
  391. sed 's/^XX//' << \SHAR_EOF > forces.samp
  392. XX# SAMPLE FORCED CONNECTION FILE
  393. XX#
  394. XX#    @(#)forces.samp    1.1    9/8/86
  395. XX#    @(#) Ronald S. Karr <tron@mesa.nsc.com>
  396. XX#    @(#) National Semiconductor, Sunnyvale
  397. XX#
  398. XX#    This file contains a list of literal paths which will be placed
  399. XX#    into the pathalias database in preference to those computed by
  400. XX#    the pathalias program.  The format of each data line is a name
  401. XX#    followed by white space followed by a literal path to the machine,
  402. XX#    including a %s for the user name.
  403. XX#
  404. XX#    The purpose of this file is to insulate you from problems caused
  405. XX#    by inconsistencies between yours and your neighbors' map entries,
  406. XX#    making sure that your lines to important sites do not change.  It
  407. XX#    can also be used just to hard-code particular paths.
  408. XX
  409. XXimportant_site    machineA!important_site!%s
  410. XXneighbor    neighbor!%s
  411. SHAR_EOF
  412. if test 773 -ne "`wc -c forces.samp`"
  413. then
  414. echo shar: error transmitting forces.samp '(should have been 773 characters)'
  415. fi
  416. echo shar: extracting local.map.samp '(535 characters)'
  417. sed 's/^XX//' << \SHAR_EOF > local.map.samp
  418. XX# SAMPLE LOCAL MAP MODIFICATIONS
  419. XX#
  420. XX#    @(#)local.map.samp    1.1    9/8/86
  421. XX#    @(#) Ronald S. Karr <tron@mesa.nsc.com>
  422. XX#    @(#) National Semiconductor, Sunnyvale
  423. XX#
  424. XX#    This file contains pathalias entries which we would prefer to
  425. XX#    which we would like to add to the USENET map files.  It can
  426. XX#    be used to add things that we know should exist or to add
  427. XX#    information about local connectivity that doesn't exist
  428. XX#    elsewhere.
  429. XX
  430. XX# Information that should be in the USENET map database.
  431. XXsun        = sun.com
  432. XXpyramid        = pyramid.com
  433. XX
  434. XXoursite        neighborsite(LOCAL)
  435. SHAR_EOF
  436. if test 535 -ne "`wc -c local.map.samp`"
  437. then
  438. echo shar: error transmitting local.map.samp '(should have been 535 characters)'
  439. fi
  440. echo shar: extracting oursite.samp '(639 characters)'
  441. sed 's/^XX//' << \SHAR_EOF > oursite.samp
  442. XX#N    oursite
  443. XX#S    GENERIC UNIX BOX; 4.3 BSD UNIX
  444. XX#O    The Corporation of Antarctica
  445. XX#
  446. XX#C    Contact Person
  447. XX#E    oursite!postmast, oursite!Contact
  448. XX#T    +1 111 222-3333
  449. XX#
  450. XX#P    1st street / Nowheresville, Antarctica
  451. XX#L    120 0 16 W / 88 23 18 S
  452. XX#
  453. XX#R    Gateway to ourdomain.com
  454. XX#
  455. XX#U    newsfeed downstream
  456. XX#W    Entry Writer <writer@oursite.ourdomain.com>;     @(#)oursite.samp    1.2    9/25/86
  457. XX# 
  458. XXoursite    ucbvax(WEEKLY*4), ihnp4(HOURLY),
  459. XX    seismo(HOURLY), cbosgd(HOURLY)
  460. XX    mcvax(DIRECT)
  461. XX# You can include a line like this if you are a gateway.
  462. XX# For NSC.COM, `nsc' will broadcast gateway information in its
  463. XX# map entries.  Other gateways need not do so.
  464. XXoursite    .ourdomain.com
  465. SHAR_EOF
  466. if test 639 -ne "`wc -c oursite.samp`"
  467. then
  468. echo shar: error transmitting oursite.samp '(should have been 639 characters)'
  469. fi
  470. echo shar: extracting pathmerge.c '(2813 characters)'
  471. sed 's/^XX//' << \SHAR_EOF > pathmerge.c
  472. XX/*
  473. XX * PATH-FILE MERGING PROGRAM
  474. XX *
  475. XX *    @(#)pathmerge.c    1.2    9/19/86
  476. XX *    @(#) Ronald S. Karr <tron@mesa.nsc.com>
  477. XX *    @(#) National Semiconductor, Sunnyvale
  478. XX *
  479. XX *    This program takes a set of sorted path files, as produced
  480. XX *    by pathalias, and generates on the standard output a merge
  481. XX *    of the path information, with one path given for each
  482. XX *    hostname.  Precedence in preferred paths goes to the files
  483. XX *    given earliest in the argument list.  One of the filenames
  484. XX *    given in the argument list can be `-' for the standard
  485. XX *    input.
  486. XX */
  487. XX#include <stdio.h>
  488. XX
  489. XXextern errno;
  490. XXchar *malloc();
  491. XX
  492. XX#define SMLBUF    512
  493. XX
  494. XXmain(argc,argv)
  495. XX    register int argc;
  496. XX    char *argv[];
  497. XX{
  498. XX    register int i;
  499. XX
  500. XX    /* current input line, per file */
  501. XX    register char **s  = (char **)malloc((argc - 1) * sizeof(char **));
  502. XX    /* true if the per-file line is valid */
  503. XX    register short *p  = (short *)malloc((argc - 1) * sizeof(short *));
  504. XX    /* per-file file descriptors */
  505. XX    register FILE **fd = (FILE **)malloc((argc - 1) * sizeof(FILE **));
  506. XX
  507. XX    register int k;
  508. XX
  509. XX    argv++; argc--;            /* we don't care about the prog name */
  510. XX
  511. XX    if (argc == 0) exit(0);        /* an unusual case */
  512. XX
  513. XX    /* initialize all of the variables */
  514. XX    k = 0;
  515. XX    for (i = 0; i < argc; i++) {
  516. XX        if (strcmp(argv[i], "-") == 0) {
  517. XX            if (k) {
  518. XX                fprintf(stderr, "cannot open the standard input more than once\n");
  519. XX            }
  520. XX            fd[i] = stdin;
  521. XX        } else {
  522. XX            if ((fd[i] = fopen(argv[i], "r")) == NULL) {
  523. XX                perror(argv[i]);
  524. XX                exit(errno);
  525. XX            }
  526. XX        }
  527. XX        s[i] = (char *)malloc(SMLBUF);
  528. XX        p[i] = 0;        /* lines not valid yet */
  529. XX    }
  530. XX
  531. XX    /* take care of special case of one file */
  532. XX    if (argc == 1) {
  533. XX        while ((i = getc(fd[0])) != EOF) putchar(i);
  534. XX        exit(0);
  535. XX    }
  536. XX
  537. XX    /* main operating loop */
  538. XX    for (;;) {
  539. XX
  540. XX        /* for files that need a line, read one in */
  541. XX        k = 0;            /* count how many are at end of file */
  542. XX        for (i = 0; i < argc; i++) {
  543. XX            if (p[i] == 0) {
  544. XX                if (fgets(s[i], SMLBUF, fd[i]) != NULL) p[i]++;
  545. XX                else k++;
  546. XX            }
  547. XX        }
  548. XX        if (k == argc) exit(0);        /* if all files then done */
  549. XX
  550. XX        /* find the alphabetically least line */
  551. XX        k = 0;
  552. XX        for (i = 1; i < argc; i++) {
  553. XX            if (p[k] == 0) k = i;    /* only use valid lines */
  554. XX            if (p[i] == 0) continue;    /* no line yet */
  555. XX            switch (cmp(s[i], s[k])) {
  556. XX
  557. XX            case 0:
  558. XX                /* if two files have the same hostname
  559. XX                 * don't use the second
  560. XX                 */
  561. XX                p[i] = 0;
  562. XX                break;
  563. XX            case -1:
  564. XX                k = i;
  565. XX                break;
  566. XX            }
  567. XX        }
  568. XX        fputs(s[k], stdout);        /* write out that line */
  569. XX        p[k] = 0;            /* read in the next */
  570. XX    }
  571. XX}
  572. XX
  573. XX/* compare two strings up to the first tab character
  574. XX * to determine if the first is less than, equal to,
  575. XX * or greater than the second, returning -1, 0 and 1
  576. XX * respectively.
  577. XX */
  578. XXcmp(s, t)
  579. XX    register char *s, *t;
  580. XX{
  581. XX    while (*s == *t && *s != '\t' && *s != '\0') s++, t++;
  582. XX    if (*s == *t) return (0);
  583. XX    if (*s == '\t') return (-1);
  584. XX    if (*t == '\t') return (1);
  585. XX    return (*s<*t? -1: 1);
  586. XX}
  587. SHAR_EOF
  588. if test 2813 -ne "`wc -c pathmerge.c`"
  589. then
  590. echo shar: error transmitting pathmerge.c '(should have been 2813 characters)'
  591. fi
  592. echo shar: extracting smail.patch '(4182 characters)'
  593. sed 's/^XX//' << \SHAR_EOF > smail.patch
  594. XXHere is a diff of changes from the smail sent out by Mark Horton
  595. XXto the version we are running here at nsc for auto-forwarding
  596. XXcapability (unfortunately, this is only approximate, but it does
  597. XXcontain the most important changes):
  598. XX
  599. XX*** defs.h.old    Oct  3 20:37:48 1986
  600. XX--- defs.h    Oct  3 20:37:48 1986
  601. XX***************
  602. XX*** 56,61
  603. XX  /* # define HOSTDOMAIN "host.dom"    /* replacement for HOSTNAME.MYDOM */
  604. XX  
  605. XX  /*
  606. XX  **  Locations of files:
  607. XX  **    PATHS is where the pathalias output is.  This is mandatory.
  608. XX  **    Define LOG if you want a log of mail.  This can be handy for
  609. XX
  610. XX--- 58,73 -----
  611. XX  /* # define HOSTDOMAIN "host.dom"    /* replacement for HOSTNAME.MYDOM */
  612. XX  
  613. XX  /*
  614. XX+  * FORWARD is set to the site that we wish to send mail that we can't
  615. XX+  * address to.  Does not need to be a direct connection.
  616. XX+  *
  617. XX+  * This hack local to National Semiconductor.
  618. XX+  */
  619. XX+ /* #ifndef FORWARD
  620. XX+  * # define FORWARD    "forwarding-relay"
  621. XX+  * #endif */
  622. XX+ 
  623. XX+ /*
  624. XX  **  Locations of files:
  625. XX  **    PATHS is where the pathalias output is.  This is mandatory.
  626. XX  **    Define LOG if you want a log of mail.  This can be handy for
  627. XX*** resolve.c.old    Fri Oct  3 20:46:45 1986
  628. XX--- resolve.c        Fri Oct  3 20:46:46 1986
  629. XX***************
  630. XX*** 68,74
  631. XX      char *partv[MAXPATH];        /* "  "      "        */
  632. XX      char temp[SMLBUF];        /* "  "      "        */
  633. XX      int i;
  634. XX!         
  635. XX  
  636. XX  /*
  637. XX  **  If we set REROUTE and are prepared to deliver UUCP mail, we split the 
  638. XX
  639. XX--- 68,74 -----
  640. XX      char *partv[MAXPATH];        /* "  "      "        */
  641. XX      char temp[SMLBUF];        /* "  "      "        */
  642. XX      int i;
  643. XX!     int route_done = 0;        /* set if everything routed */
  644. XX  
  645. XX  /*
  646. XX  **  If we set REROUTE and are prepared to deliver UUCP mail, we split the 
  647. XX***************
  648. XX*** 100,106
  649. XX  **  we are set to route ALWAYS or REROUTE) or a ROUTE form.
  650. XX  */
  651. XX          if ( rsvp( form ) != ROUTE && 
  652. XX!             ( rsvp( form ) != UUCP || routing == JUSTDOMAIN ) )
  653. XX              break;
  654. XX  /*
  655. XX  **  Apply router.  If BULLYing and routing failed, try next larger substring.
  656. XX
  657. XX--- 100,107 -----
  658. XX  **  we are set to route ALWAYS or REROUTE) or a ROUTE form.
  659. XX  */
  660. XX          if ( rsvp( form ) != ROUTE && 
  661. XX!             ( rsvp( form ) != UUCP || routing == JUSTDOMAIN ) ) {
  662. XX!             route_done++;
  663. XX              break;
  664. XX          }
  665. XX  /*
  666. XX***************
  667. XX*** 102,107
  668. XX          if ( rsvp( form ) != ROUTE && 
  669. XX              ( rsvp( form ) != UUCP || routing == JUSTDOMAIN ) )
  670. XX              break;
  671. XX  /*
  672. XX  **  Apply router.  If BULLYing and routing failed, try next larger substring.
  673. XX  */
  674. XX
  675. XX--- 103,109 -----
  676. XX              ( rsvp( form ) != UUCP || routing == JUSTDOMAIN ) ) {
  677. XX              route_done++;
  678. XX              break;
  679. XX+         }
  680. XX  /*
  681. XX  **  Apply router.  If BULLYing and routing failed, try next larger substring.
  682. XX  */
  683. XX***************
  684. XX*** 112,117
  685. XX  */
  686. XX          form = parse( temp, domain, user );
  687. XX      DEBUG("parse route '%s' = %s @ %s (%d)\n",temp,user,domain,form);
  688. XX          break;
  689. XX      }
  690. XX  /*
  691. XX
  692. XX--- 114,120 -----
  693. XX  */
  694. XX          form = parse( temp, domain, user );
  695. XX      DEBUG("parse route '%s' = %s @ %s (%d)\n",temp,user,domain,form);
  696. XX+         route_done++;
  697. XX          break;
  698. XX      }
  699. XX  /*
  700. XX***************
  701. XX*** 125,130
  702. XX          (void) strcpy( domain, "" );
  703. XX          form = LOCAL;
  704. XX      }
  705. XX  /*
  706. XX  **  If we were supposed to route and address but failed (form == ERROR), 
  707. XX  **  or after routing once we are left with an address that still needs to
  708. XX
  709. XX--- 128,168 -----
  710. XX          (void) strcpy( domain, "" );
  711. XX          form = LOCAL;
  712. XX      }
  713. XX+ 
  714. XX+ /*
  715. XX+ **  Local NSC hack to forward unrouted messages
  716. XX+ */
  717. XX+ #ifdef FORWARD
  718. XX+     if ( !route_done )
  719. XX+     {
  720. XX+         char forward[SMLBUF];
  721. XX+ 
  722. XX+         /* get the path to the forwarding machine */
  723. XX+         if ( getpath( FORWARD, forward) == EX_OK ) {
  724. XX+             char *p;
  725. XX+ 
  726. XX+             /* splice in the address */
  727. XX+             sprintf( temp, forward, address );
  728. XX+ 
  729. XX+             /* split the address at the first ! */
  730. XX+             p = index( temp, '!' );
  731. XX+ 
  732. XX+             if ( p ) {
  733. XX+                 *p = '\0';
  734. XX+                 (void) strcpy( user, p+1 );
  735. XX+                 (void) strcpy( domain, temp );
  736. XX+                 ADVISE( "forward '%s' = %s @ %s (%d)\n",
  737. XX+                     address, user, domain, UUCP );
  738. XX+                 return ( UUCP );
  739. XX+             }
  740. XX+         }
  741. XX+         exitstat = EX_NOHOST;
  742. XX+         printf( "%s...couldn't forward to %s.\n", address, FORWARD );
  743. XX+         form = ERROR;
  744. XX+         return( form );
  745. XX+     }
  746. XX+ #endif FORWARD
  747. XX+ 
  748. XX  /*
  749. XX  **  If we were supposed to route and address but failed (form == ERROR), 
  750. XX  **  or after routing once we are left with an address that still needs to
  751. XX
  752. SHAR_EOF
  753. if test 4182 -ne "`wc -c smail.patch`"
  754. then
  755. echo shar: error transmitting smail.patch '(should have been 4182 characters)'
  756. fi
  757. echo shar: extracting stripdom.c '(3353 characters)'
  758. sed 's/^XX//' << \SHAR_EOF > stripdom.c
  759. XX/*
  760. XX * LOCAL DOMAIN QUALIFICATION PROGRAM
  761. XX *
  762. XX *    @(#)stripdom.c    1.2    9/19/86
  763. XX *    @(#) Ronald S. Karr <tron@mesa.nsc.com>
  764. XX *    @(#) National Semiconductor, Sunnyvale
  765. XX *
  766. XX *    This program accepts on the standard input a pathalias path
  767. XX *    database and an argument list containing fully qualified
  768. XX *    domains that the current machine is in.  Then on the standard
  769. XX *    output this list is reproduced with any hosts in the given
  770. XX *    fully-qualified domains reproduced on separate lines in less
  771. XX *    qualified domains.  The output is ordered such that a sorted
  772. XX *    file on input will be sorted on output as well.
  773. XX *
  774. XX * USAGE:
  775. XX *    pathalias ... | stripdomain full-domain full-domain ... | ...
  776. XX *
  777. XX * NOTE:
  778. XX *    ordering of full-domains in the argument list is not important
  779. XX *    as the arguments are sorted by size before processing starts.
  780. XX *    Also:  Domains should be given with the initial dot.
  781. XX *
  782. XX * EXAMPLE:
  783. XX *    Given the command "stripdomain .nsc.com .sc.nsc.com" the following
  784. XX *    input:
  785. XX *        a.sc.nsc.com    m!a!%s
  786. XX *        b.b16.sc.nsc.com    n!b!%s
  787. XX *        c.nsc.com    o!c!%s
  788. XX *        d.ta.nsc.com    p!d!%s
  789. XX *        e    q!e!%s
  790. XX *        f.com    r!f!%s
  791. XX *
  792. XX *    produces the following output:
  793. XX *        a.sc    m!a!%s
  794. XX *        a.sc.nsc    m!a!%s
  795. XX *        a.sc.nsc.com    m!a!%s
  796. XX *        b.b16.sc    n!b!%s
  797. XX *        b.b16.sc.nsc    n!b!%s
  798. XX *        b.b16.sc.nsc.com    n!b!%s
  799. XX *        c.nsc    o!c!%s
  800. XX *        c.nsc.com    o!c!%s
  801. XX *        d.ta.nsc    p!d!%s
  802. XX *        d.ta.nsc.com    p!d!%s
  803. XX *        e    q!e!%s
  804. XX *        f.com    r!f!%s
  805. XX */
  806. XX
  807. XX#include <stdio.h>
  808. XX#include <ctype.h>
  809. XX
  810. XX#define SMLBUF    512
  811. XX
  812. XX/* read input strings into here */
  813. XXchar buf[SMLBUF];
  814. XX
  815. XXmain(argc,argv)
  816. XX    int argc;
  817. XX    register char *argv[];
  818. XX{
  819. XX    register char *p, *s;
  820. XX    register i;
  821. XX    static int lencompare();
  822. XX
  823. XX    /* for quick reference, make a table of lengths for the
  824. XX     * the various arguments.
  825. XX     */
  826. XX    register int *l = (int *)malloc((--argc) * sizeof(int));
  827. XX
  828. XX    argv++;
  829. XX
  830. XX    /* sort arguments by size (largest to smallest) */
  831. XX    qsort(argv, argc, sizeof(char *), lencompare);
  832. XX    for (i = 0; argv[i] != NULL; i++) {
  833. XX        l[i] = strlen(argv[i]);
  834. XX    }
  835. XX
  836. XX    p = NULL;
  837. XX    s = buf;
  838. XX
  839. XX    /* main processing loop, just get and process characters */
  840. XX    for (;;) switch (*s++ = getchar()) {
  841. XX
  842. XX    /* mark the first white space we see in a line */
  843. XX    case '\t':
  844. XX    case ' ':
  845. XX        if (p == NULL) {
  846. XX            p = s - 1;
  847. XX        }
  848. XX        break;
  849. XX
  850. XX    /* end of line processing */
  851. XX    case '\n':
  852. XX        s[-1] = 0;        /* terminate the line */
  853. XX        s = p;            /* keep track of the mark */
  854. XX        if (p == NULL) break;    /* something is odd, but ignore */
  855. XX
  856. XX        /* look for local domain names before the mark */
  857. XX        for (i = 0; argv[i] != NULL; i++) {
  858. XX            p -= l[i];    /* note potential start of the domain */
  859. XX
  860. XX            /* if it couldn't possibly fit, try the next one */
  861. XX            if (p - buf < 0) {
  862. XX                p += l[i];
  863. XX                continue;
  864. XX            }
  865. XX
  866. XX            /* if it isn't a match, try the next one */
  867. XX            if (strncmp(argv[i], p, l[i]) != 0) {
  868. XX                p += l[i];
  869. XX                continue;
  870. XX            }
  871. XX
  872. XX            /* found a match with a domain name */
  873. XX            for (;;) {
  874. XX
  875. XX                /* look for the NEXT dot */
  876. XX                while (*++p != '.' && !isspace(*p)) ;
  877. XX
  878. XX                /* no more dots in domain */
  879. XX                if (isspace(*p)) break;
  880. XX
  881. XX                /* output before the dot and from the mark */
  882. XX                *p = '\0';
  883. XX                fputs(buf, stdout);
  884. XX                puts(s);
  885. XX                *p = '.';
  886. XX            }
  887. XX            break;
  888. XX        }
  889. XX        p = NULL;
  890. XX        s = buf;
  891. XX        puts(s);        /* output the line as is */
  892. XX        break;
  893. XX
  894. XX    case EOF:
  895. XX        exit(0);        /* all done */
  896. XX    }
  897. XX}
  898. XX
  899. XXstatic int
  900. XXlencompare(a,b)
  901. XX    char **a,**b;
  902. XX{
  903. XX    register la,lb;
  904. XX
  905. XX    la = strlen(*a);
  906. XX    lb = strlen(*b);
  907. XX    if (la == lb) return (0);
  908. XX    if (la < lb) return (1);
  909. XX    else return (-1);
  910. XX}
  911. SHAR_EOF
  912. if test 3353 -ne "`wc -c stripdom.c`"
  913. then
  914. echo shar: error transmitting stripdom.c '(should have been 3353 characters)'
  915. fi
  916. echo shar: extracting sub.domain.com.samp '(823 characters)'
  917. sed 's/^XX//' << \SHAR_EOF > sub.domain.com.samp
  918. XX# SAMPLE CONNECTIVITY OF THE SUB.DOMAIN.COM DOMAIN
  919. XX#
  920. XX#    @(#)sub.domain.com.samp    1.2    10/15/86
  921. XX#    @(#) Ronald S. Karr <tron@mesa.nsc.com>
  922. XX#    @(#) National Semiconductor, Sunnyvale
  923. XX#
  924. XX#    This file contains the connectivity maps for the top level
  925. XX#    of the SUB.DOMAIN.COM domain.  All gateways to SUB.DOMAIN.COM
  926. XX#    must have a current copy of this map.  Also, all other machines
  927. XX#    within DOMAIN.COM must either have a current copy of this map
  928. XX#    or be able to forward to a machine that does.
  929. XX
  930. XX#    Our site
  931. XXoursite    close-site(DIRECT),
  932. XX    this-site(DIRECT),
  933. XX    another-site(LOCAL),
  934. XX    OUR-ETHERNET
  935. XX
  936. XXOUR-ETHERNET    = { a,b,c,d }(DEAD)
  937. XX
  938. XX#    The top level of SUB.DOMAIN.COM
  939. XXoursite        = oursite.sub.domain.com
  940. XXclose-site    = close-site.sub.domain.com
  941. XXthis-site    = this-site.sub.domain.com
  942. XX
  943. XX#    Subnets of SUB.DOMAIN.COM
  944. XXanother-site    .sub.sub.domain.com
  945. SHAR_EOF
  946. if test 823 -ne "`wc -c sub.domain.com.samp`"
  947. then
  948. echo shar: error transmitting sub.domain.com.samp '(should have been 823 characters)'
  949. fi
  950. #    End of shell archive
  951. exit 0
  952.  
  953.