17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 77c478bd9Sstevel@tonic-gate * with the License. 87c478bd9Sstevel@tonic-gate * 97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate * and limitations under the License. 137c478bd9Sstevel@tonic-gate * 147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate * 207c478bd9Sstevel@tonic-gate * CDDL HEADER END 217c478bd9Sstevel@tonic-gate */ 22*61961e0fSrobinson 23*61961e0fSrobinson /* 24*61961e0fSrobinson * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 25*61961e0fSrobinson * Use is subject to license terms. 26*61961e0fSrobinson */ 27*61961e0fSrobinson 287c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 297c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 307c478bd9Sstevel@tonic-gate 31*61961e0fSrobinson #pragma ident "%Z%%M% %I% %E% SMI" 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate #include "uucp.h" 347c478bd9Sstevel@tonic-gate 35*61961e0fSrobinson #ifndef SMALL 367c478bd9Sstevel@tonic-gate /* 37*61961e0fSrobinson * strecpy(output, input, except) 38*61961e0fSrobinson * strccpy copys the input string to the output string expanding 39*61961e0fSrobinson * any non-graphic character with the C escape sequence. 40*61961e0fSrobinson * Escape sequences produced are those defined in "The C Programming 41*61961e0fSrobinson * Language" pages 180-181. 42*61961e0fSrobinson * Characters in the except string will not be expanded. 437c478bd9Sstevel@tonic-gate */ 447c478bd9Sstevel@tonic-gate 45*61961e0fSrobinson static char * 46*61961e0fSrobinson strecpy(char *pout, char *pin, char *except) 477c478bd9Sstevel@tonic-gate { 48*61961e0fSrobinson unsigned c; 49*61961e0fSrobinson char *output; 507c478bd9Sstevel@tonic-gate 517c478bd9Sstevel@tonic-gate output = pout; 527c478bd9Sstevel@tonic-gate while ((c = *pin++) != 0) { 537c478bd9Sstevel@tonic-gate if (!isprint(c) && (!except || !strchr(except, c))) { 547c478bd9Sstevel@tonic-gate *pout++ = '\\'; 557c478bd9Sstevel@tonic-gate switch (c) { 567c478bd9Sstevel@tonic-gate case '\n': 577c478bd9Sstevel@tonic-gate *pout++ = 'n'; 587c478bd9Sstevel@tonic-gate continue; 597c478bd9Sstevel@tonic-gate case '\t': 607c478bd9Sstevel@tonic-gate *pout++ = 't'; 617c478bd9Sstevel@tonic-gate continue; 627c478bd9Sstevel@tonic-gate case '\b': 637c478bd9Sstevel@tonic-gate *pout++ = 'b'; 647c478bd9Sstevel@tonic-gate continue; 657c478bd9Sstevel@tonic-gate case '\r': 667c478bd9Sstevel@tonic-gate *pout++ = 'r'; 677c478bd9Sstevel@tonic-gate continue; 687c478bd9Sstevel@tonic-gate case '\f': 697c478bd9Sstevel@tonic-gate *pout++ = 'f'; 707c478bd9Sstevel@tonic-gate continue; 717c478bd9Sstevel@tonic-gate case '\v': 727c478bd9Sstevel@tonic-gate *pout++ = 'v'; 737c478bd9Sstevel@tonic-gate continue; 747c478bd9Sstevel@tonic-gate case '\\': 757c478bd9Sstevel@tonic-gate continue; 767c478bd9Sstevel@tonic-gate default: 777c478bd9Sstevel@tonic-gate sprintf(pout, "%.3o", c); 787c478bd9Sstevel@tonic-gate pout += 3; 797c478bd9Sstevel@tonic-gate continue; 807c478bd9Sstevel@tonic-gate } 817c478bd9Sstevel@tonic-gate } 827c478bd9Sstevel@tonic-gate if (c == '\\' && (!except || !strchr(except, c))) 837c478bd9Sstevel@tonic-gate *pout++ = '\\'; 847c478bd9Sstevel@tonic-gate *pout++ = (char)c; 857c478bd9Sstevel@tonic-gate } 867c478bd9Sstevel@tonic-gate *pout = '\0'; 877c478bd9Sstevel@tonic-gate return (output); 887c478bd9Sstevel@tonic-gate } 89*61961e0fSrobinson #endif 90