1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 * 22 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 27 /* All Rights Reserved */ 28 29 /* LINTLIBRARY */ 30 31 #if defined(__STDC__) 32 #include "stdarg.h" 33 #else 34 #include "varargs.h" 35 #endif 36 37 #include "string.h" 38 #include "errno.h" 39 #include "stdlib.h" 40 41 #include "lp.h" 42 43 /** 44 ** makepath() - CREATE PATHNAME FROM COMPONENTS 45 **/ 46 47 /*VARARGS1*/ 48 char * 49 #if defined(__STDC__) 50 makepath ( 51 char * s, 52 ... 53 ) 54 #else 55 makepath (s, va_alist) 56 char * s; 57 va_dcl 58 #endif 59 { 60 va_list ap; 61 62 register char *component, 63 *p, 64 *q; 65 66 register int len; 67 68 char *ret; 69 70 71 #if defined(__STDC__) 72 va_start (ap, s); 73 #else 74 va_start (ap); 75 #endif 76 77 for (len = strlen(s) + 1; (component = va_arg(ap, char *)); ) 78 len += strlen(component) + 1; 79 80 va_end (ap); 81 82 if (!len) { 83 errno = 0; 84 return (0); 85 } 86 87 if (!(ret = Malloc(len))) { 88 errno = ENOMEM; 89 return (0); 90 } 91 92 #if defined(__STDC__) 93 va_start (ap, s); 94 #else 95 va_start (ap); 96 #endif 97 98 for ( 99 p = ret, component = s; 100 component; 101 component = va_arg(ap, char *) 102 ) { 103 for (q = component; *q; ) 104 *p++ = *q++; 105 *p++ = '/'; 106 } 107 p[-1] = 0; 108 109 va_end (ap); 110 111 return (ret); 112 } 113