Changed all references to log() to log_message().
This commit is contained in:
parent
154a2e0880
commit
7febdd028c
28
src/utils.c
28
src/utils.c
@ -1,4 +1,4 @@
|
|||||||
/* $Id: utils.c,v 1.3 2001-01-15 17:06:19 rjkaes Exp $
|
/* $Id: utils.c,v 1.4 2001-05-27 02:38:46 rjkaes Exp $
|
||||||
*
|
*
|
||||||
* Misc. routines which are used by the various functions to handle strings
|
* Misc. routines which are used by the various functions to handle strings
|
||||||
* and memory allocation and pretty much anything else we can think of. Also,
|
* and memory allocation and pretty much anything else we can think of. Also,
|
||||||
@ -75,7 +75,7 @@ int httperr(struct conn_s *connptr, int err, char *msg)
|
|||||||
|
|
||||||
connptr->output_message = malloc(MAXBUFFSIZE);
|
connptr->output_message = malloc(MAXBUFFSIZE);
|
||||||
if (!connptr->output_message) {
|
if (!connptr->output_message) {
|
||||||
log(LOG_CRIT, "Out of memory!");
|
log_message(LOG_CRIT, "Out of memory!");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ static int create_file_safely(const char *filename)
|
|||||||
* existing", exit.
|
* existing", exit.
|
||||||
*/
|
*/
|
||||||
if (errno != ENOENT) {
|
if (errno != ENOENT) {
|
||||||
log(LOG_ERR, "Error checking PID file %s: %s",
|
log_message(LOG_ERR, "Error checking PID file %s: %s",
|
||||||
filename, strerror(errno));
|
filename, strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -133,7 +133,7 @@ static int create_file_safely(const char *filename)
|
|||||||
* and open()
|
* and open()
|
||||||
*/
|
*/
|
||||||
if ((fildes = open(filename, O_RDWR | O_CREAT | O_EXCL, 0600)) < 0) {
|
if ((fildes = open(filename, O_RDWR | O_CREAT | O_EXCL, 0600)) < 0) {
|
||||||
log(LOG_ERR, "Could not create PID file %s: %s",
|
log_message(LOG_ERR, "Could not create PID file %s: %s",
|
||||||
filename, strerror(errno));
|
filename, strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -144,7 +144,7 @@ static int create_file_safely(const char *filename)
|
|||||||
* Open an existing file.
|
* Open an existing file.
|
||||||
*/
|
*/
|
||||||
if ((fildes = open(filename, O_RDWR)) < 0) {
|
if ((fildes = open(filename, O_RDWR)) < 0) {
|
||||||
log(LOG_ERR, "Could not open PID file %s: %s",
|
log_message(LOG_ERR, "Could not open PID file %s: %s",
|
||||||
filename, strerror(errno));
|
filename, strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -157,7 +157,7 @@ static int create_file_safely(const char *filename)
|
|||||||
|| lstatinfo.st_mode != fstatinfo.st_mode
|
|| lstatinfo.st_mode != fstatinfo.st_mode
|
||||||
|| lstatinfo.st_ino != fstatinfo.st_ino
|
|| lstatinfo.st_ino != fstatinfo.st_ino
|
||||||
|| lstatinfo.st_dev != fstatinfo.st_dev) {
|
|| lstatinfo.st_dev != fstatinfo.st_dev) {
|
||||||
log(LOG_ERR, "The PID file %s has been changed before it could be opened!",
|
log_message(LOG_ERR, "The PID file %s has been changed before it could be opened!",
|
||||||
filename);
|
filename);
|
||||||
close(fildes);
|
close(fildes);
|
||||||
return -1;
|
return -1;
|
||||||
@ -171,7 +171,7 @@ static int create_file_safely(const char *filename)
|
|||||||
* st_mode check would also find this)
|
* st_mode check would also find this)
|
||||||
*/
|
*/
|
||||||
if (fstatinfo.st_nlink > 1 || !S_ISREG(lstatinfo.st_mode)) {
|
if (fstatinfo.st_nlink > 1 || !S_ISREG(lstatinfo.st_mode)) {
|
||||||
log(LOG_ERR, "The PID file %s has too many links, or is not a regular file: %s",
|
log_message(LOG_ERR, "The PID file %s has too many links, or is not a regular file: %s",
|
||||||
filename, strerror(errno));
|
filename, strerror(errno));
|
||||||
close(fildes);
|
close(fildes);
|
||||||
return -1;
|
return -1;
|
||||||
@ -182,19 +182,19 @@ static int create_file_safely(const char *filename)
|
|||||||
* do is to close the file and reopen it in create mode, which
|
* do is to close the file and reopen it in create mode, which
|
||||||
* unfortunately leads to a race condition, however "systems
|
* unfortunately leads to a race condition, however "systems
|
||||||
* which don't support ftruncate()" is pretty much SCO only,
|
* which don't support ftruncate()" is pretty much SCO only,
|
||||||
* and if you're using that you deserver what you get.
|
* and if you're using that you deserve what you get.
|
||||||
* ("Little sympathy has been extended")
|
* ("Little sympathy has been extended")
|
||||||
*/
|
*/
|
||||||
#if defined NO_FTRUNCATE
|
#ifdef HAVE_FTRUNCATE
|
||||||
|
ftruncate(fildes, 0);
|
||||||
|
#else
|
||||||
close(fildes);
|
close(fildes);
|
||||||
if ((fildes = open(filename, O_RDWR | O_CREAT | O_TRUNC, 0600)) < 0) {
|
if ((fildes = open(filename, O_RDWR | O_CREAT | O_TRUNC, 0600)) < 0) {
|
||||||
log(LOG_ERR, "Could not open PID file %s: %s",
|
log_message(LOG_ERR, "Could not open PID file %s: %s",
|
||||||
filename, strerror(errno));
|
filename, strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#else
|
#endif /* HAVE_FTRUNCATE */
|
||||||
ftruncate(fildes, 0);
|
|
||||||
#endif /* NO_FTRUNCATE */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return fildes;
|
return fildes;
|
||||||
@ -218,7 +218,7 @@ void pidfile_create(const char *filename)
|
|||||||
* Open a stdio file over the low-level one.
|
* Open a stdio file over the low-level one.
|
||||||
*/
|
*/
|
||||||
if ((fd = fdopen(fildes, "w")) == NULL) {
|
if ((fd = fdopen(fildes, "w")) == NULL) {
|
||||||
log(LOG_ERR, "fdopen() error on PID file %s: %s",
|
log_message(LOG_ERR, "fdopen() error on PID file %s: %s",
|
||||||
filename, strerror(errno));
|
filename, strerror(errno));
|
||||||
close(fildes);
|
close(fildes);
|
||||||
unlink(filename);
|
unlink(filename);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: utils.h,v 1.3 2000-09-26 04:58:35 rjkaes Exp $
|
/* $Id: utils.h,v 1.4 2001-05-27 02:38:46 rjkaes Exp $
|
||||||
*
|
*
|
||||||
* See 'utils.h' for a detailed description.
|
* See 'utils.h' for a detailed description.
|
||||||
*
|
*
|
||||||
@ -29,7 +29,12 @@ extern int httperr(struct conn_s *connptr, int err, char *msg);
|
|||||||
extern void makedaemon(void);
|
extern void makedaemon(void);
|
||||||
extern void pidfile_create(const char *path);
|
extern void pidfile_create(const char *path);
|
||||||
|
|
||||||
|
#ifndef HAVE_STRLCAT
|
||||||
extern size_t strlcat(char *dst, const char *src, size_t size);
|
extern size_t strlcat(char *dst, const char *src, size_t size);
|
||||||
|
#endif /* HAVE_STRLCAT */
|
||||||
|
|
||||||
|
#ifndef HAVE_STRLCPY
|
||||||
extern size_t strlcpy(char *dst, const char *src, size_t size);
|
extern size_t strlcpy(char *dst, const char *src, size_t size);
|
||||||
|
#endif /* HAVE_STRLCPY */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user