2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License, Version 1.0 only
2N/A * (the "License"). You may not use this file except in compliance
2N/A * with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A
2N/A/*
2N/A * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
2N/A * Use is subject to license terms.
2N/A */
2N/A
2N/A/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
2N/A/* All Rights Reserved */
2N/A
2N/A#pragma ident "%Z%%M% %I% %E% SMI"
2N/A
2N/A#include "mt.h"
2N/A#include "uucp.h"
2N/A
2N/A/*
2N/A * generate a vector of pointers (arps) to the
2N/A * substrings in string "s".
2N/A * Each substring is separated by blanks and/or tabs.
2N/A * s -> string to analyze -- s GETS MODIFIED
2N/A * arps -> array of pointers -- count + 1 pointers
2N/A * count -> max number of fields
2N/A * returns:
2N/A * i -> # of subfields
2N/A * arps[i] = NULL
2N/A */
2N/A
2N/Astatic int
2N/Agetargs(char *s, char *arps[], int count)
2N/A{
2N/A int i;
2N/A
2N/A for (i = 0; i < count; i++) {
2N/A while (*s == ' ' || *s == '\t')
2N/A *s++ = '\0';
2N/A if (*s == '\n')
2N/A *s = '\0';
2N/A if (*s == '\0')
2N/A break;
2N/A arps[i] = s++;
2N/A while (*s != '\0' && *s != ' ' && *s != '\t' && *s != '\n')
2N/A s++;
2N/A }
2N/A arps[i] = NULL;
2N/A return (i);
2N/A}
2N/A
2N/A/*
2N/A * bsfix(args) - remove backslashes from args
2N/A *
2N/A * \123 style strings are collapsed into a single character
2N/A * \000 gets mapped into \N for further processing downline.
2N/A * \ at end of string is removed
2N/A * \t gets replaced by a tab
2N/A * \n gets replaced by a newline
2N/A * \r gets replaced by a carriage return
2N/A * \b gets replaced by a backspace
2N/A * \s gets replaced by a blank
2N/A * any other unknown \ sequence is left intact for further processing
2N/A * downline.
2N/A */
2N/A
2N/Astatic void
2N/Absfix(char **args)
2N/A{
2N/A char *str, *to, *cp;
2N/A int num;
2N/A
2N/A for (; *args; args++) {
2N/A str = *args;
2N/A for (to = str; *str; str++) {
2N/A if (*str == '\\') {
2N/A if (str[1] == '\0')
2N/A break;
2N/A switch (*++str) {
2N/A case '0':
2N/A case '1':
2N/A case '2':
2N/A case '3':
2N/A case '4':
2N/A case '5':
2N/A case '6':
2N/A case '7':
2N/A for (num = 0, cp = str;
2N/A cp - str < 3; cp++) {
2N/A if ('0' <= *cp && *cp <= '7') {
2N/A num <<= 3;
2N/A num += *cp - '0';
2N/A } else
2N/A break;
2N/A }
2N/A if (num == 0) {
2N/A *to++ = '\\';
2N/A *to++ = 'N';
2N/A } else
2N/A *to++ = (char)num;
2N/A str = cp-1;
2N/A break;
2N/A
2N/A case 't':
2N/A *to++ = '\t';
2N/A break;
2N/A
2N/A case 's':
2N/A *to++ = ' ';
2N/A break;
2N/A
2N/A case 'n':
2N/A *to++ = '\n';
2N/A break;
2N/A
2N/A case 'r':
2N/A *to++ = '\r';
2N/A break;
2N/A
2N/A case 'b':
2N/A *to++ = '\b';
2N/A break;
2N/A
2N/A default:
2N/A *to++ = '\\';
2N/A *to++ = *str;
2N/A break;
2N/A }
2N/A }
2N/A else
2N/A *to++ = *str;
2N/A }
2N/A *to = '\0';
2N/A }
2N/A}