summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert James Kaes <rjkaes@users.sourceforge.net>2001-05-27 02:38:46 +0000
committerRobert James Kaes <rjkaes@users.sourceforge.net>2001-05-27 02:38:46 +0000
commit7febdd028c9d455ae99879c053f44df25b3db28f (patch)
treed3f0f3436387159488f219e978616b50b3958ab4
parent154a2e0880425d383a4c2dedd17b9ddcb1ce0ccf (diff)
downloadtinyproxy-7febdd028c9d455ae99879c053f44df25b3db28f.tar.gz
tinyproxy-7febdd028c9d455ae99879c053f44df25b3db28f.zip
Changed all references to log() to log_message().
-rw-r--r--src/utils.c42
-rw-r--r--src/utils.h7
2 files changed, 27 insertions, 22 deletions
diff --git a/src/utils.c b/src/utils.c
index fef9ff0..50110ab 100644
--- a/src/utils.c
+++ b/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
* 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);
if (!connptr->output_message) {
- log(LOG_CRIT, "Out of memory!");
+ log_message(LOG_CRIT, "Out of memory!");
return -1;
}
@@ -122,8 +122,8 @@ static int create_file_safely(const char *filename)
* existing", exit.
*/
if (errno != ENOENT) {
- log(LOG_ERR, "Error checking PID file %s: %s",
- filename, strerror(errno));
+ log_message(LOG_ERR, "Error checking PID file %s: %s",
+ filename, strerror(errno));
return -1;
}
@@ -133,8 +133,8 @@ static int create_file_safely(const char *filename)
* and open()
*/
if ((fildes = open(filename, O_RDWR | O_CREAT | O_EXCL, 0600)) < 0) {
- log(LOG_ERR, "Could not create PID file %s: %s",
- filename, strerror(errno));
+ log_message(LOG_ERR, "Could not create PID file %s: %s",
+ filename, strerror(errno));
return -1;
}
} else {
@@ -144,8 +144,8 @@ static int create_file_safely(const char *filename)
* Open an existing file.
*/
if ((fildes = open(filename, O_RDWR)) < 0) {
- log(LOG_ERR, "Could not open PID file %s: %s",
- filename, strerror(errno));
+ log_message(LOG_ERR, "Could not open PID file %s: %s",
+ filename, strerror(errno));
return -1;
}
@@ -157,8 +157,8 @@ static int create_file_safely(const char *filename)
|| lstatinfo.st_mode != fstatinfo.st_mode
|| lstatinfo.st_ino != fstatinfo.st_ino
|| lstatinfo.st_dev != fstatinfo.st_dev) {
- log(LOG_ERR, "The PID file %s has been changed before it could be opened!",
- filename);
+ log_message(LOG_ERR, "The PID file %s has been changed before it could be opened!",
+ filename);
close(fildes);
return -1;
}
@@ -171,8 +171,8 @@ static int create_file_safely(const char *filename)
* st_mode check would also find this)
*/
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",
- filename, strerror(errno));
+ log_message(LOG_ERR, "The PID file %s has too many links, or is not a regular file: %s",
+ filename, strerror(errno));
close(fildes);
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
* unfortunately leads to a race condition, however "systems
* 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")
*/
-#if defined NO_FTRUNCATE
+#ifdef HAVE_FTRUNCATE
+ ftruncate(fildes, 0);
+#else
close(fildes);
if ((fildes = open(filename, O_RDWR | O_CREAT | O_TRUNC, 0600)) < 0) {
- log(LOG_ERR, "Could not open PID file %s: %s",
- filename, strerror(errno));
+ log_message(LOG_ERR, "Could not open PID file %s: %s",
+ filename, strerror(errno));
return -1;
}
-#else
- ftruncate(fildes, 0);
-#endif /* NO_FTRUNCATE */
+#endif /* HAVE_FTRUNCATE */
}
return fildes;
@@ -218,8 +218,8 @@ void pidfile_create(const char *filename)
* Open a stdio file over the low-level one.
*/
if ((fd = fdopen(fildes, "w")) == NULL) {
- log(LOG_ERR, "fdopen() error on PID file %s: %s",
- filename, strerror(errno));
+ log_message(LOG_ERR, "fdopen() error on PID file %s: %s",
+ filename, strerror(errno));
close(fildes);
unlink(filename);
exit(1);
diff --git a/src/utils.h b/src/utils.h
index 2e80567..cd53fae 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -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.
*
@@ -29,7 +29,12 @@ extern int httperr(struct conn_s *connptr, int err, char *msg);
extern void makedaemon(void);
extern void pidfile_create(const char *path);
+#ifndef HAVE_STRLCAT
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);
+#endif /* HAVE_STRLCPY */
#endif