17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * Copyright 2001 Sun Microsystems, Inc. All rights reserved. 37c478bd9Sstevel@tonic-gate * Use is subject to license terms. 47c478bd9Sstevel@tonic-gate */ 57c478bd9Sstevel@tonic-gate /* 67c478bd9Sstevel@tonic-gate * Replace %m by system error message. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands. 97c478bd9Sstevel@tonic-gate */ 107c478bd9Sstevel@tonic-gate 117c478bd9Sstevel@tonic-gate #ifndef lint 127c478bd9Sstevel@tonic-gate static char sccsid[] = "@(#) percent_m.c 1.1 94/12/28 17:42:37"; 137c478bd9Sstevel@tonic-gate #endif 147c478bd9Sstevel@tonic-gate 157c478bd9Sstevel@tonic-gate #include <stdio.h> 167c478bd9Sstevel@tonic-gate #include <errno.h> 177c478bd9Sstevel@tonic-gate #include <string.h> 187c478bd9Sstevel@tonic-gate 197c478bd9Sstevel@tonic-gate extern int errno; 207c478bd9Sstevel@tonic-gate 217c478bd9Sstevel@tonic-gate #include "mystdarg.h" 227c478bd9Sstevel@tonic-gate 237c478bd9Sstevel@tonic-gate char *percent_m(obuf, ibuf) 247c478bd9Sstevel@tonic-gate char *obuf; 257c478bd9Sstevel@tonic-gate char *ibuf; 267c478bd9Sstevel@tonic-gate { 277c478bd9Sstevel@tonic-gate char *bp = obuf; 287c478bd9Sstevel@tonic-gate char *cp = ibuf; 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate while (*bp = *cp) 317c478bd9Sstevel@tonic-gate if (*cp == '%' && cp[1] == 'm') { 32*9584cebbSAlexander Pyhalov strcpy(bp, strerror(errno)); 337c478bd9Sstevel@tonic-gate bp += strlen(bp); 347c478bd9Sstevel@tonic-gate cp += 2; 357c478bd9Sstevel@tonic-gate } else { 367c478bd9Sstevel@tonic-gate bp++, cp++; 377c478bd9Sstevel@tonic-gate } 387c478bd9Sstevel@tonic-gate return (obuf); 397c478bd9Sstevel@tonic-gate } 40