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 (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 23 /* All Rights Reserved */ 24 25 26 #ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.6 */ 27 /* LINTLIBRARY */ 28 29 #if defined(__STDC__) 30 #include "stdarg.h" 31 #else 32 #include "varargs.h" 33 #endif 34 35 #include "string.h" 36 #include "errno.h" 37 #include "stdlib.h" 38 39 #include "lp.h" 40 41 /** 42 ** makestr() - CONSTRUCT SINGLE STRING FROM SEVERAL 43 **/ 44 45 /*VARARGS1*/ 46 char * 47 #if defined(__STDC__) 48 makestr ( 49 char * s, 50 ... 51 ) 52 #else 53 makestr (s, va_alist) 54 char * s; 55 va_dcl 56 #endif 57 { 58 va_list ap; 59 60 register char *component, 61 *p, 62 *q; 63 64 register int len; 65 66 char *ret; 67 68 69 #if defined(__STDC__) 70 va_start (ap, s); 71 #else 72 va_start (ap); 73 #endif 74 75 for (len = strlen(s); (component = va_arg(ap, char *)); ) 76 len += strlen(component); 77 78 va_end (ap); 79 80 if (!len) { 81 errno = 0; 82 return (0); 83 } 84 85 if (!(ret = Malloc(len + 1))) { 86 errno = ENOMEM; 87 return (0); 88 } 89 90 #if defined(__STDC__) 91 va_start (ap, s); 92 #else 93 va_start (ap); 94 #endif 95 96 for ( 97 p = ret, component = s; 98 component; 99 component = va_arg(ap, char *) 100 ) 101 for (q = component; *q; ) 102 *p++ = *q++; 103 *p = 0; 104 105 va_end(ap); 106 107 return (ret); 108 } 109