table of contents
other sections
ERR(3) | Linux Programmer's Manual | ERR(3) |
NOME¶
err, verr, errx, verrx, warn, vwarn, warnx, vwarnx - messaggi di errore formattatiSINTASSI¶
#include <err.h>void err(int eval, const char *fmt, ...);void errx(int eval, const char *fmt, ...);void warn(const char *fmt, ...);void warnx(const char *fmt, ...);#include <stdarg.h>void verr(int eval, const char *fmt, va_list args);void verrx(int eval, const char *fmt, va_list args);void vwarn(const char *fmt, va_list args);void vwarnx(const char *fmt, va_list args);
DESCRIZIONE¶
Le famiglie di funzioni err e warn visualizzano un messaggio di errore formattato sull'uscita dello standard error. In ogni caso vengono stampati l'ultimo componente del nome del programma, un carattere di due punti, e uno spazio. Se l'argomento fmt non è NULL viene emesso un messaggio di errore formattato in stile printf(3)-like. L'output è concluso da un carattere newline. Le funzioni err(), verr(), warn(), e vwarn() aggiungono un messaggio di errore ottenuto da strerror(3) basato su un codice o sulla variabile globale R errno , preceduto da un altro ":" e uno spazio a meno che l'argomento fmt sia NULL. Le funzioni err(), verr(), warn(), e vwarn() usano la variabile globale errno per trovare il messaggio di errore. Le funzioni errx() e warnx() non aggiungono un messaggio di errore. Le funzioni err(), verr(), errx(), e verrx() non ritornano, ma escono con il valore dell'argomento R eval .ESEMPI¶
Mostra la stringa di informazione attuale errno ed esce:if ((p = malloc(size)) == NULL) err(1, NULL); if ((fd = open(file_name, O_RDONLY, 0)) == -1) err(1, "%s", file_name);
Visualizza un messaggio di errore ed esce:
if (tm.tm_hour < START_TIME) errx(1, "too early, wait until %s", start_time_string);
Avvisa di un errore:
if ((fd = open(raw_device, O_RDONLY, 0)) == -1) warnx("%s: %s: trying the block device", raw_device, strerror(errno)); if ((fd = open(block_device, O_RDONLY, 0)) == -1) err(1, "%s", block_device);
CONFORME A¶
Queste funzioni sono estensioni BSD non standard.STORIA¶
VEDERE ANCHE¶
error(3), exit(3), printf(3), perror(3), strerror(3)COLOPHON¶
Questa pagina fa parte del rilascio 2.75 del progetto man-pages di Linux. Si può trovare una descrizione del progetto, e informazioni su come riportare bachi, presso http://www.kernel.org/doc/man-pages/. Per la traduzione in italiano si può fare riferimento a http://www.pluto.it/ildp/collaborare/28 dicembre 2007 | Linux |