/* Error handlers, automatically registered */
static MessageHandler message_handler = {
- error_makecode,
- error_log,
- error_print
+ error_makecode,
+ error_log,
+ error_print
};
/* Scheme handlers automatically registered */
Make the error code */
static MH_ERROR error_makecode(void *user_data, SablotHandle proc, int severity, unsigned short facility, unsigned short code)
{
- return(0);
+ return 0;
}
/* }}} */
/* Parse the error array */
/* Loop through the error array */
if (fields) {
- while (fields && *fields) {
+ while (*fields) {
char *key; /* Key to for the message */
char *val; /* The message itself */
char *ptr; /* Pointer to the location of the ':' (separator) */
key = emalloc(pos + 1);
val = emalloc((len - pos) + 1);
- memcpy(key, *fields, pos);
- memcpy(val, *fields + pos + 1, len - pos - 1);
-
- key[pos] = '\0';
- val[len - pos - 1] = '\0';
+ strlcpy(key, *fields, pos);
+ strlcpy(val, *fields + pos + 1, len - pos - 1);
/* Check to see whether or not we want to save the data */
if (!strcmp(key, "msg")) {
XSLT_LOG(handle).fd = open(XSLT_LOG(handle).path,
O_WRONLY|O_CREAT|O_APPEND,
S_IRUSR|S_IRGRP|S_IROTH|S_IWUSR);
- if (XSLT_LOG(handle).fd < 0) {
+ if (XSLT_LOG(handle).fd == -1) {
php_error(E_WARNING, "Cannot open log file, %s [%d]: %s",
XSLT_LOG(handle).path, errno, strerror(errno));
XSLT_LOG(handle).fd = 0;
/* Write the error to the file */
error = write(XSLT_LOG(handle).fd, msgbuf, strlen(msgbuf));
- if (error < 1) {
+ if (error == -1) {
php_error(E_WARNING, "Cannot write data to log file, %s, with fd, %d [%d]: %s",
(XSLT_LOG(handle).path ? XSLT_LOG(handle).path : "stderr"),
XSLT_LOG(handle).fd,
- error,
- strerror(error));
+ errno,
+ strerror(errno));
return 0;
}
ZVAL_LONG(argv[2], code);
if (fields) {
- while (fields && *fields) {
+ while (*fields) {
char *key; /* Key to for the message */
char *val; /* The message itself */
char *ptr; /* Pointer to the location of the ':' (separator) */
key = emalloc(pos + 1);
val = emalloc((len - pos) + 1);
- memcpy(key, *fields, pos);
- memcpy(val, *fields + pos + 1, len - pos - 1);
- key[pos] = '\0';
- val[len - pos - 1] = '\0';
+ strlcpy(key, *fields, pos);
+ strlcpy(val, *fields + pos + 1, len - pos - 1);
/* Add it */
add_assoc_stringl_ex(argv[3], key, pos, val, len - pos - 1, 1);
key = emalloc(pos + 1);
val = emalloc((len - pos) + 1);
- memcpy(key, *fields, pos);
- memcpy(val, *fields + pos + 1, len - pos - 1);
-
- key[pos] = '\0';
- val[len - pos - 1] = '\0';
+ strlcpy(key, *fields, pos);
+ strlcpy(val, *fields + pos + 1, len - pos - 1);
/* Check to see whether or not we want to save the data */
if (!strcmp(key, "msg")) {