1192398Sgnn/*- 2283927Sjhb * Copyright (c) 2009 Hudson River Trading LLC 3192398Sgnn * Written by: George V. Neville-Neil <gnn@FreeBSD.org> 4192398Sgnn * All rights reserved. 5192398Sgnn * 6192398Sgnn * Redistribution and use in source and binary forms, with or without 7192398Sgnn * modification, are permitted provided that the following conditions 8192398Sgnn * are met: 9192398Sgnn * 1. Redistributions of source code must retain the above copyright 10192398Sgnn * notice, this list of conditions and the following disclaimer. 11192398Sgnn * 2. Redistributions in binary form must reproduce the above copyright 12192398Sgnn * notice, this list of conditions and the following disclaimer in the 13192398Sgnn * documentation and/or other materials provided with the distribution. 14192398Sgnn * 15192398Sgnn * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16192398Sgnn * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17192398Sgnn * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18192398Sgnn * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19192398Sgnn * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20192398Sgnn * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21192398Sgnn * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22192398Sgnn * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23192398Sgnn * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24192398Sgnn * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25192398Sgnn * SUCH DAMAGE. 26192398Sgnn */ 27192398Sgnn 28192398Sgnn#include <sys/cdefs.h> 29192398Sgnn__FBSDID("$FreeBSD$"); 30192398Sgnn 31192398Sgnn#include <stdio.h> 32192398Sgnn#include <stdlib.h> 33192398Sgnn#include <string.h> 34192486Sgnn#include <err.h> 35199642Sedwin#include <locale.h> 36192398Sgnn#include <sys/errno.h> 37192398Sgnn 38192997Sdelphijstatic void usage(void); 39192398Sgnn 40192407Sgnnint 41192407Sgnnmain(int argc, char **argv) 42192398Sgnn{ 43192398Sgnn char *cp; 44192486Sgnn char *errstr; 45192486Sgnn long errnum; 46192398Sgnn 47199642Sedwin (void) setlocale(LC_MESSAGES, ""); 48192398Sgnn if (argc != 2) 49192398Sgnn usage(); 50192398Sgnn 51192486Sgnn errno = 0; 52192486Sgnn 53192398Sgnn errnum = strtol(argv[1], &cp, 0); 54192398Sgnn 55192486Sgnn if (errno != 0) 56192486Sgnn err(1, NULL); 57192398Sgnn 58192486Sgnn if ((errstr = strerror(errnum)) == NULL) 59192486Sgnn err(1, NULL); 60192398Sgnn 61192486Sgnn printf("%s\n", errstr); 62192398Sgnn 63192398Sgnn exit(0); 64192398Sgnn} 65192486Sgnn 66192486Sgnnstatic void 67192997Sdelphijusage(void) 68192486Sgnn{ 69192486Sgnn fprintf(stderr, "usage: perror number\n"); 70192486Sgnn exit(1); 71192486Sgnn} 72192486Sgnn 73