Category : UNIX Files
Archive   : PC-MAIL2.ZIP
Filename : PERCENTM.C

 
Output of file : PERCENTM.C contained in archive : PC-MAIL2.ZIP
/*++
/* NAME
/* percentm 3
/* SUMMARY
/* convert %m to system error message
/* PROJECT
/* pc-mail
/* PACKAGE
/* nfs
/* SYNOPSIS
/* #include percentm.h
/*
/* char *percentm(string, err)
/* char *string;
/* int err;
/* DESCRIPTION
/* percentm() interprets %m format specificiers in \fIstring\fR
/* In the output, %m will be replaced by the error message that
/* corresponds with the error value \fIerr\fR (see .
/* BUGS
/* The result is stored in static memory that is overwritten with
/* each call.
/* AUTHOR(S)
/* Wietse Z. Venema
/* Eindhoven University of Technology
/* Department of Mathematics and Computer Science
/* Den Dolech 2, P.O. Box 513, 5600 MB Eindhoven, The Netherlands
/* CREATION DATE
/* Sun Oct 29 15:29:37 MET 1989
/* LAST MODIFICATION
/* 12/5/89 22:03:27
/* VERSION/RELEASE
/* 1.2
/*--*/

#ifndef lint
static char sccsid[] = "@(#) percentm.c 1.2 12/5/89 22:03:27";

#endif

#include
#include "percentm.h"

extern int errno;
extern char *sys_errlist[];
extern int sys_nerr;
extern char *strcpy();

/* percentm - replace %m by error message associated with value in err */

char *percentm(str, err)
char *str;
int err;
{
static char buf[BUFSIZ];
register char *ip = str;
register char *op = buf;

while (*ip) {
switch (*ip) {
case '%':
switch (ip[1]) {
case '\0': /* don't fall off end */
*op++ = *ip++;
break;
case 'm': /* replace %m */
(void) strcpy(op,
sys_errlist[(err < sys_nerr && err > 0) ? err : 0]);
op += strlen(op);
ip += 2;
break;
default: /* leave % alone */
*op++ = *ip++, *op++ = *ip++;
break;
}
default:
*op++ = *ip++;
}
}
*op = '\0';
return (buf);
}



  3 Responses to “Category : UNIX Files
Archive   : PC-MAIL2.ZIP
Filename : PERCENTM.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/