Home | History | Annotate | Line # | Download | only in tcpdchk
percent_m.c revision 1.4
      1 /*	$NetBSD: percent_m.c,v 1.4 2000/01/21 17:08:39 mycroft 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.4 2000/01/21 17:08:39 mycroft Exp $");
     15 #endif
     16 #endif
     17 
     18 #include <stdio.h>
     19 #include <errno.h>
     20 #include <string.h>
     21 
     22 #ifndef SYS_ERRLIST_DEFINED
     23 extern char *sys_errlist[];
     24 extern int sys_nerr;
     25 #endif
     26 
     27 #include "mystdarg.h"
     28 #include "percent_m.h"
     29 
     30 char   *percent_m(obuf, ibuf)
     31 char   *obuf;
     32 const char   *ibuf;
     33 {
     34     char   *bp = obuf;
     35     const char   *cp = ibuf;
     36 
     37     while ((*bp = *cp) != '\0')
     38 	if (*cp == '%' && cp[1] == 'm') {
     39 	    strcpy(bp, strerror(errno));
     40 	    bp += strlen(bp);
     41 	    cp += 2;
     42 	} else {
     43 	    bp++, cp++;
     44 	}
     45     return (obuf);
     46 }
     47