+\f/*
+** MAPHOST -- given a host description, produce a mapping.
+**
+** This is done by looking up the name in the alias file,
+** preceeded by an "@". This can be used for UUCP mapping.
+** For example, a call with {blia, ., UUCP} as arguments
+** might return {ucsfcgl, !, blia, ., UUCP} as the result.
+**
+** We first break the input into three parts -- before the
+** lookup, the lookup itself, and after the lookup. We
+** then do the lookup, concatenate them together, and rescan
+** the result.
+**
+** Parameters:
+** pvp -- the parameter vector to map.
+**
+** Returns:
+** The result of the mapping. If nothing found, it
+** should just concatenate the three parts together and
+** return that.
+**
+** Side Effects:
+** none.
+*/
+
+char **
+maphost(pvp)
+ char **pvp;
+{
+ register char **avp;
+ register char **bvp;
+ char *p;
+ char buf1[MAXNAME];
+ char buf2[MAXNAME];
+ char buf3[MAXNAME];
+ extern char **prescan();
+
+ /*
+ ** Extract the three parts of the input as strings.
+ */
+
+ /* find the part before the lookup */
+ for (bvp = pvp; *bvp != NULL && **bvp != MATCHLOOKUP; bvp++)
+ continue;
+ if (*bvp == NULL)
+ return (pvp);
+ p = *bvp;
+ *bvp = NULL;
+ cataddr(pvp, buf1, sizeof buf1);
+ *bvp++ = p;
+
+ /* find the rest of the lookup */
+ for (avp = bvp; *pvp != NULL && **bvp != MATCHELOOKUP; bvp++)
+ continue;
+ if (*bvp == NULL)
+ return (pvp);
+ p = *bvp;
+ *bvp = NULL;
+ cataddr(avp, buf2, sizeof buf2);
+ *bvp++ = p;
+
+ /* save the part after the lookup */
+ cataddr(bvp, buf3, sizeof buf3);
+
+ /*
+ ** Now look up the middle part.
+ */
+
+ p = aliaslookup(buf2);
+ if (p != NULL)
+ strcpy(buf2, p);
+
+ /*
+ ** Put the three parts back together and break into tokens.
+ */
+
+ strcat(buf1, buf2);
+ strcat(buf1, buf3);
+ avp = prescan(buf1, '\0');
+
+ /* return this mapping */
+ return (avp);
+}