1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * Copyright 2001 Sun Microsystems, Inc. All rights reserved. 3*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 4*7c478bd9Sstevel@tonic-gate */ 5*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 6*7c478bd9Sstevel@tonic-gate 7*7c478bd9Sstevel@tonic-gate /* 8*7c478bd9Sstevel@tonic-gate * Replace %m by system error message. 9*7c478bd9Sstevel@tonic-gate * 10*7c478bd9Sstevel@tonic-gate * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands. 11*7c478bd9Sstevel@tonic-gate */ 12*7c478bd9Sstevel@tonic-gate 13*7c478bd9Sstevel@tonic-gate #ifndef lint 14*7c478bd9Sstevel@tonic-gate static char sccsid[] = "@(#) percent_m.c 1.1 94/12/28 17:42:37"; 15*7c478bd9Sstevel@tonic-gate #endif 16*7c478bd9Sstevel@tonic-gate 17*7c478bd9Sstevel@tonic-gate #include <stdio.h> 18*7c478bd9Sstevel@tonic-gate #include <errno.h> 19*7c478bd9Sstevel@tonic-gate #include <string.h> 20*7c478bd9Sstevel@tonic-gate 21*7c478bd9Sstevel@tonic-gate extern int errno; 22*7c478bd9Sstevel@tonic-gate #ifndef SYS_ERRLIST_DEFINED 23*7c478bd9Sstevel@tonic-gate extern char *sys_errlist[]; 24*7c478bd9Sstevel@tonic-gate extern int sys_nerr; 25*7c478bd9Sstevel@tonic-gate #endif 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #include "mystdarg.h" 28*7c478bd9Sstevel@tonic-gate 29*7c478bd9Sstevel@tonic-gate char *percent_m(obuf, ibuf) 30*7c478bd9Sstevel@tonic-gate char *obuf; 31*7c478bd9Sstevel@tonic-gate char *ibuf; 32*7c478bd9Sstevel@tonic-gate { 33*7c478bd9Sstevel@tonic-gate char *bp = obuf; 34*7c478bd9Sstevel@tonic-gate char *cp = ibuf; 35*7c478bd9Sstevel@tonic-gate 36*7c478bd9Sstevel@tonic-gate while (*bp = *cp) 37*7c478bd9Sstevel@tonic-gate if (*cp == '%' && cp[1] == 'm') { 38*7c478bd9Sstevel@tonic-gate if (errno < sys_nerr && errno > 0) { 39*7c478bd9Sstevel@tonic-gate strcpy(bp, sys_errlist[errno]); 40*7c478bd9Sstevel@tonic-gate } else { 41*7c478bd9Sstevel@tonic-gate sprintf(bp, "Unknown error %d", errno); 42*7c478bd9Sstevel@tonic-gate } 43*7c478bd9Sstevel@tonic-gate bp += strlen(bp); 44*7c478bd9Sstevel@tonic-gate cp += 2; 45*7c478bd9Sstevel@tonic-gate } else { 46*7c478bd9Sstevel@tonic-gate bp++, cp++; 47*7c478bd9Sstevel@tonic-gate } 48*7c478bd9Sstevel@tonic-gate return (obuf); 49*7c478bd9Sstevel@tonic-gate } 50