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