2 * User FTP Server, Share folders over FTP without being root.
3 * Copyright (C) 2008 Isaac Jurado
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License as published by the Free Software
7 * Foundation; either version 2 of the License, or (at your option) any later
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
34 * Logging utility. Display a printf()-like formatted message (msg, args) with
35 * the current PID and a severity label at the beginning of the line. If
36 * show_error is true, append a human readable version of the last system error.
38 static void message ( int show_error
,
48 * The value in SS.pid prevents calling getpid() for each message,
49 * saving the expense of a system call.
51 printf("(%5d) [%-7s] ", SS
.pid
, severity
);
54 if (show_error
&& error_code
!= 0)
55 printf(": %s.\n", strerror(error_code
));
62 * Debug message. Only enabled for debug compilations.
65 void debug (const char *msg
, ...)
70 message(0, "DEBUG", msg
, args
);
77 * Informational message.
79 void notice (const char *msg
, ...)
84 message(0, "NOTICE", msg
, args
);
90 * Program error message.
92 void warning (const char *msg
, ...)
97 message(0, "WARNING", msg
, args
);
103 * System error message. Displays system error information when the last error
106 void error (const char *msg
, ...)
111 message(1, "ERROR", msg
, args
);
117 * Fatal error. Displays a message similar to error() but also terminates the
120 void fatal (const char *msg
, ...)
125 message(1, "FATAL", msg
, args
);