Home | History | Annotate | Line # | Download | only in tcpdchk
percent_m.c revision 1.3
      1 /*	$NetBSD: percent_m.c,v 1.3 1998/05/09 17:22:09 kleink Exp $	*/
      2 
      3  /*
      4   * Replace %m by system error message.
      5   *
      6   * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
      7   */
      8 
      9 #include <sys/cdefs.h>
     10 #ifndef lint
     11 #if 0
     12 static char sccsid[] = "@(#) percent_m.c 1.1 94/12/28 17:42:37";
     13 #else
     14 __RCSID("$NetBSD: percent_m.c,v 1.3 1998/05/09 17:22:09 kleink Exp $");
     15 #endif
     16 #endif
     17 
     18 #include <stdio.h>
     19 #include <errno.h>
     20 #include <string.h>
     21 
     22 extern int errno;
     23 #ifndef SYS_ERRLIST_DEFINED
     24 extern char *sys_errlist[];
     25 extern int sys_nerr;
     26 #endif
     27 
     28 #include "mystdarg.h"
     29 #include "percent_m.h"
     30 
     31 char   *percent_m(obuf, ibuf)
     32 char   *obuf;
     33 const char   *ibuf;
     34 {
     35     char   *bp = obuf;
     36     const char   *cp = ibuf;
     37 
     38     while ((*bp = *cp) != '\0')
     39 	if (*cp == '%' && cp[1] == 'm') {
     40 	    strcpy(bp, strerror(errno));
     41 	    bp += strlen(bp);
     42 	    cp += 2;
     43 	} else {
     44 	    bp++, cp++;
     45 	}
     46     return (obuf);
     47 }
     48