1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 23*7c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 24*7c478bd9Sstevel@tonic-gate 25*7c478bd9Sstevel@tonic-gate 26*7c478bd9Sstevel@tonic-gate #ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.1 */ 27*7c478bd9Sstevel@tonic-gate 28*7c478bd9Sstevel@tonic-gate #include "uucp.h" 29*7c478bd9Sstevel@tonic-gate #include <rpc/trace.h> 30*7c478bd9Sstevel@tonic-gate 31*7c478bd9Sstevel@tonic-gate /* 32*7c478bd9Sstevel@tonic-gate * generate a vector of pointers (arps) to the 33*7c478bd9Sstevel@tonic-gate * substrings in string "s". 34*7c478bd9Sstevel@tonic-gate * Each substring is separated by blanks and/or tabs. 35*7c478bd9Sstevel@tonic-gate * s -> string to analyze -- s GETS MODIFIED 36*7c478bd9Sstevel@tonic-gate * arps -> array of pointers -- count + 1 pointers 37*7c478bd9Sstevel@tonic-gate * count -> max number of fields 38*7c478bd9Sstevel@tonic-gate * returns: 39*7c478bd9Sstevel@tonic-gate * i -> # of subfields 40*7c478bd9Sstevel@tonic-gate * arps[i] = NULL 41*7c478bd9Sstevel@tonic-gate */ 42*7c478bd9Sstevel@tonic-gate 43*7c478bd9Sstevel@tonic-gate GLOBAL int 44*7c478bd9Sstevel@tonic-gate getargs(s, arps, count) 45*7c478bd9Sstevel@tonic-gate register char *s, *arps[]; 46*7c478bd9Sstevel@tonic-gate register int count; 47*7c478bd9Sstevel@tonic-gate { 48*7c478bd9Sstevel@tonic-gate register int i; 49*7c478bd9Sstevel@tonic-gate 50*7c478bd9Sstevel@tonic-gate trace2(TR_getargs, 0, count); 51*7c478bd9Sstevel@tonic-gate for (i = 0; i < count; i++) { 52*7c478bd9Sstevel@tonic-gate while (*s == ' ' || *s == '\t') 53*7c478bd9Sstevel@tonic-gate *s++ = '\0'; 54*7c478bd9Sstevel@tonic-gate if (*s == '\n') 55*7c478bd9Sstevel@tonic-gate *s = '\0'; 56*7c478bd9Sstevel@tonic-gate if (*s == '\0') 57*7c478bd9Sstevel@tonic-gate break; 58*7c478bd9Sstevel@tonic-gate arps[i] = s++; 59*7c478bd9Sstevel@tonic-gate while (*s != '\0' && *s != ' ' 60*7c478bd9Sstevel@tonic-gate && *s != '\t' && *s != '\n') 61*7c478bd9Sstevel@tonic-gate s++; 62*7c478bd9Sstevel@tonic-gate } 63*7c478bd9Sstevel@tonic-gate arps[i] = NULL; 64*7c478bd9Sstevel@tonic-gate trace1(TR_getargs, 1); 65*7c478bd9Sstevel@tonic-gate return (i); 66*7c478bd9Sstevel@tonic-gate } 67*7c478bd9Sstevel@tonic-gate 68*7c478bd9Sstevel@tonic-gate /* 69*7c478bd9Sstevel@tonic-gate * bsfix(args) - remove backslashes from args 70*7c478bd9Sstevel@tonic-gate * 71*7c478bd9Sstevel@tonic-gate * \123 style strings are collapsed into a single character 72*7c478bd9Sstevel@tonic-gate * \000 gets mapped into \N for further processing downline. 73*7c478bd9Sstevel@tonic-gate * \ at end of string is removed 74*7c478bd9Sstevel@tonic-gate * \t gets replaced by a tab 75*7c478bd9Sstevel@tonic-gate * \n gets replaced by a newline 76*7c478bd9Sstevel@tonic-gate * \r gets replaced by a carriage return 77*7c478bd9Sstevel@tonic-gate * \b gets replaced by a backspace 78*7c478bd9Sstevel@tonic-gate * \s gets replaced by a blank 79*7c478bd9Sstevel@tonic-gate * any other unknown \ sequence is left intact for further processing 80*7c478bd9Sstevel@tonic-gate * downline. 81*7c478bd9Sstevel@tonic-gate */ 82*7c478bd9Sstevel@tonic-gate 83*7c478bd9Sstevel@tonic-gate GLOBAL void 84*7c478bd9Sstevel@tonic-gate bsfix (args) 85*7c478bd9Sstevel@tonic-gate char **args; 86*7c478bd9Sstevel@tonic-gate { 87*7c478bd9Sstevel@tonic-gate register char *str, *to, *cp; 88*7c478bd9Sstevel@tonic-gate register int num; 89*7c478bd9Sstevel@tonic-gate 90*7c478bd9Sstevel@tonic-gate trace1(TR_bsfix, 0); 91*7c478bd9Sstevel@tonic-gate for (; *args; args++) { 92*7c478bd9Sstevel@tonic-gate str = *args; 93*7c478bd9Sstevel@tonic-gate for (to = str; *str; str++) { 94*7c478bd9Sstevel@tonic-gate if (*str == '\\') { 95*7c478bd9Sstevel@tonic-gate if (str[1] == '\0') 96*7c478bd9Sstevel@tonic-gate break; 97*7c478bd9Sstevel@tonic-gate switch (*++str) { 98*7c478bd9Sstevel@tonic-gate case '0': 99*7c478bd9Sstevel@tonic-gate case '1': 100*7c478bd9Sstevel@tonic-gate case '2': 101*7c478bd9Sstevel@tonic-gate case '3': 102*7c478bd9Sstevel@tonic-gate case '4': 103*7c478bd9Sstevel@tonic-gate case '5': 104*7c478bd9Sstevel@tonic-gate case '6': 105*7c478bd9Sstevel@tonic-gate case '7': 106*7c478bd9Sstevel@tonic-gate for ( num = 0, cp = str 107*7c478bd9Sstevel@tonic-gate ; cp - str < 3 108*7c478bd9Sstevel@tonic-gate ; cp++ 109*7c478bd9Sstevel@tonic-gate ) { 110*7c478bd9Sstevel@tonic-gate if ('0' <= *cp && *cp <= '7') { 111*7c478bd9Sstevel@tonic-gate num <<= 3; 112*7c478bd9Sstevel@tonic-gate num += *cp - '0'; 113*7c478bd9Sstevel@tonic-gate } 114*7c478bd9Sstevel@tonic-gate else 115*7c478bd9Sstevel@tonic-gate break; 116*7c478bd9Sstevel@tonic-gate } 117*7c478bd9Sstevel@tonic-gate if (num == 0) { 118*7c478bd9Sstevel@tonic-gate *to++ = '\\'; 119*7c478bd9Sstevel@tonic-gate *to++ = 'N'; 120*7c478bd9Sstevel@tonic-gate } else 121*7c478bd9Sstevel@tonic-gate *to++ = (char) num; 122*7c478bd9Sstevel@tonic-gate str = cp-1; 123*7c478bd9Sstevel@tonic-gate break; 124*7c478bd9Sstevel@tonic-gate 125*7c478bd9Sstevel@tonic-gate case 't': 126*7c478bd9Sstevel@tonic-gate *to++ = '\t'; 127*7c478bd9Sstevel@tonic-gate break; 128*7c478bd9Sstevel@tonic-gate 129*7c478bd9Sstevel@tonic-gate case 's': 130*7c478bd9Sstevel@tonic-gate *to++ = ' '; 131*7c478bd9Sstevel@tonic-gate break; 132*7c478bd9Sstevel@tonic-gate 133*7c478bd9Sstevel@tonic-gate case 'n': 134*7c478bd9Sstevel@tonic-gate *to++ = '\n'; 135*7c478bd9Sstevel@tonic-gate break; 136*7c478bd9Sstevel@tonic-gate 137*7c478bd9Sstevel@tonic-gate case 'r': 138*7c478bd9Sstevel@tonic-gate *to++ = '\r'; 139*7c478bd9Sstevel@tonic-gate break; 140*7c478bd9Sstevel@tonic-gate 141*7c478bd9Sstevel@tonic-gate case 'b': 142*7c478bd9Sstevel@tonic-gate *to++ = '\b'; 143*7c478bd9Sstevel@tonic-gate break; 144*7c478bd9Sstevel@tonic-gate 145*7c478bd9Sstevel@tonic-gate default: 146*7c478bd9Sstevel@tonic-gate *to++ = '\\'; 147*7c478bd9Sstevel@tonic-gate *to++ = *str; 148*7c478bd9Sstevel@tonic-gate break; 149*7c478bd9Sstevel@tonic-gate } 150*7c478bd9Sstevel@tonic-gate } 151*7c478bd9Sstevel@tonic-gate else 152*7c478bd9Sstevel@tonic-gate *to++ = *str; 153*7c478bd9Sstevel@tonic-gate } 154*7c478bd9Sstevel@tonic-gate *to = '\0'; 155*7c478bd9Sstevel@tonic-gate } 156*7c478bd9Sstevel@tonic-gate trace1(TR_bsfix, 1); 157*7c478bd9Sstevel@tonic-gate return; 158*7c478bd9Sstevel@tonic-gate } 159