# SUSv2
AC_CHECK_FUNCS([ctime_r usleep])
+# SUSv3
+AC_CHECK_FUNCS([strerror_r])
+
# BSD
AC_CHECK_FUNCS([lstat])
# Some public stuff is used even in the core.
libpolypcore_la_SOURCES = \
polyp/channelmap.c polyp/channelmap.h \
+ polyp/error.c polyp/error.h \
polyp/mainloop.c polyp/mainloop.h \
polyp/mainloop-api.c polyp/mainloop-api.h \
polyp/mainloop-signal.c polyp/mainloop-signal.h \
#include <sys/capability.h>
#endif
+#include <polyp/error.h>
+
#include <polypcore/log.h>
#include "caps.h"
cap_clear(caps);
if (cap_set_proc(caps) < 0) {
- pa_log(__FILE__": failed to drop capabilities: %s", strerror(errno));
+ pa_log(__FILE__": failed to drop capabilities: %s", pa_cstrerror(errno));
goto fail;
}
#include <config.h>
#endif
+#include <polyp/error.h>
+
#include <polypcore/core-util.h>
#include <polypcore/log.h>
/* Prepare the main loop pipe */
if (pipe(the_pipe) < 0) {
- pa_log(__FILE__": pipe() failed: %s", strerror(errno));
+ pa_log(__FILE__": pipe() failed: %s", pa_cstrerror(errno));
return -1;
}
#include <assert.h>
#include <unistd.h>
+#include <polyp/error.h>
#include <polyp/xmalloc.h>
#include <polypcore/core-util.h>
pa_open_config_file(DEFAULT_CONFIG_FILE, DEFAULT_CONFIG_FILE_USER, ENV_CONFIG_FILE, &c->config_file, "r");
if (!f && errno != ENOENT) {
- pa_log(__FILE__": WARNING: failed to open configuration file '%s': %s", filename, strerror(errno));
+ pa_log(__FILE__": WARNING: failed to open configuration file '%s': %s", filename, pa_cstrerror(errno));
goto finish;
}
#include "../polypcore/winsock.h"
+#include <polyp/error.h>
#include <polyp/mainloop.h>
#include <polyp/mainloop-signal.h>
#include <polyp/xmalloc.h>
}
if ((child = fork()) < 0) {
- pa_log(__FILE__": fork() failed: %s", strerror(errno));
+ pa_log(__FILE__": fork() failed: %s", pa_cstrerror(errno));
goto finish;
}
daemon_pipe[1] = -1;
if (pa_loop_read(daemon_pipe[0], &retval, sizeof(retval)) != sizeof(retval)) {
- pa_log(__FILE__": read() failed: %s", strerror(errno));
+ pa_log(__FILE__": read() failed: %s", pa_cstrerror(errno));
retval = 1;
}
#include <asoundlib.h>
+#include <polyp/error.h>
#include <polyp/xmalloc.h>
#include <polypcore/core.h>
continue;
}
- pa_log(__FILE__": snd_pcm_readi() failed: %s", strerror(-frames));
+ pa_log(__FILE__": snd_pcm_readi() failed: %s", pa_cstrerror(-frames));
return;
}
#include <sys/types.h>
#include <sys/stat.h>
+#include <polyp/error.h>
#include <polyp/xmalloc.h>
#include <polypcore/module.h>
if (!(f = fopen("/proc/asound/devices", "r"))) {
if (errno != ENOENT)
- pa_log_error(__FILE__": open(\"/proc/asound/devices\") failed: %s", strerror(errno));
+ pa_log_error(__FILE__": open(\"/proc/asound/devices\") failed: %s", pa_cstrerror(errno));
return -1;
}
!(f = fopen("/proc/asound/oss/sndstat", "r"))) {
if (errno != ENOENT)
- pa_log_error(__FILE__": failed to open OSS sndstat device: %s", strerror(errno));
+ pa_log_error(__FILE__": failed to open OSS sndstat device: %s", pa_cstrerror(errno));
return -1;
}
if (stat(dev, &s) < 0) {
if (errno != ENOENT)
- pa_log_error(__FILE__": failed to open device %s: %s", dev, strerror(errno));
+ pa_log_error(__FILE__": failed to open device %s: %s", dev, pa_cstrerror(errno));
return -1;
}
#include <string.h>
#include <errno.h>
+#include <polyp/error.h>
+
#include <polypcore/module.h>
#include <polypcore/modargs.h>
#include <polypcore/core-util.h>
}
if (pa_loop_write(fd, &x, sizeof(x)) != sizeof(x))
- pa_log(__FILE__": WARNING: write(%u, 1, 1) failed: %s", fd, strerror(errno));
+ pa_log(__FILE__": WARNING: write(%u, 1, 1) failed: %s", fd, pa_cstrerror(errno));
close(fd);
#include <errno.h>
#include <signal.h>
+#include <polyp/error.h>
+
#include <polypcore/module.h>
#include <polypcore/core-util.h>
#include <polypcore/modargs.h>
}
if (kill(pid, SIGUSR1) < 0)
- pa_log(__FILE__": WARNING: kill(%u) failed: %s", pid, strerror(errno));
+ pa_log(__FILE__": WARNING: kill(%u) failed: %s", pid, pa_cstrerror(errno));
pa_module_unload_request(m);
#include <unistd.h>
#include <limits.h>
+#include <polyp/error.h>
#include <polyp/xmalloc.h>
#include <polypcore/iochannel.h>
assert(u->write_index < u->write_length);
if ((r = pa_iochannel_write(u->io, (uint8_t*) u->write_data + u->write_index, u->write_length - u->write_index)) <= 0) {
- pa_log(__FILE__": write() failed: %s", strerror(errno));
+ pa_log(__FILE__": write() failed: %s", pa_cstrerror(errno));
return -1;
}
assert(u->memchunk.memblock && u->memchunk.length);
if ((r = pa_iochannel_write(u->io, (uint8_t*) u->memchunk.memblock->data + u->memchunk.index, u->memchunk.length)) < 0) {
- pa_log(__FILE__": write() failed: %s", strerror(errno));
+ pa_log(__FILE__": write() failed: %s", pa_cstrerror(errno));
return -1;
}
/* Process auth data */
if (!*(int32_t*) u->read_data) {
- pa_log(__FILE__": Authentication failed: %s", strerror(errno));
+ pa_log(__FILE__": Authentication failed: %s", pa_cstrerror(errno));
return -1;
}
assert(u->read_index < u->read_length);
if ((r = pa_iochannel_read(u->io, (uint8_t*) u->read_data + u->read_index, u->read_length - u->read_index)) <= 0) {
- pa_log(__FILE__": read() failed: %s", r < 0 ? strerror(errno) : "EOF");
+ pa_log(__FILE__": read() failed: %s", r < 0 ? pa_cstrerror(errno) : "EOF");
cancel(u);
return -1;
}
u->client = NULL;
if (!io) {
- pa_log(__FILE__": connection failed: %s", strerror(errno));
+ pa_log(__FILE__": connection failed: %s", pa_cstrerror(errno));
cancel(u);
return;
}
#include <jack/jack.h>
+#include <polyp/error.h>
#include <polyp/xmalloc.h>
#include <polypcore/iochannel.h>
pthread_cond_init(&u->cond, NULL);
if (pipe(u->pipe_fds) < 0) {
- pa_log(__FILE__": pipe() failed: %s", strerror(errno));
+ pa_log(__FILE__": pipe() failed: %s", pa_cstrerror(errno));
goto fail;
}
#include <jack/jack.h>
+#include <polyp/error.h>
#include <polyp/xmalloc.h>
#include <polypcore/iochannel.h>
pthread_cond_init(&u->cond, NULL);
if (pipe(u->pipe_fds) < 0) {
- pa_log(__FILE__": pipe() failed: %s", strerror(errno));
+ pa_log(__FILE__": pipe() failed: %s", pa_cstrerror(errno));
goto fail;
}
#include <stdio.h>
#include <stdlib.h>
+#include <polyp/error.h>
#include <polyp/xmalloc.h>
#include <polypcore/module.h>
pa_open_config_file(DEFAULT_MATCH_TABLE_FILE, DEFAULT_MATCH_TABLE_FILE_USER, NULL, &fn, "r");
if (!f) {
- pa_log(__FILE__": failed to open file '%s': %s", fn, strerror(errno));
+ pa_log(__FILE__": failed to open file '%s': %s", fn, pa_cstrerror(errno));
goto finish;
}
#include <linux/input.h>
+#include <polyp/error.h>
#include <polyp/xmalloc.h>
#include <polypcore/module.h>
struct input_event ev;
if (pa_loop_read(u->fd, &ev, sizeof(ev)) <= 0) {
- pa_log(__FILE__": failed to read from event device: %s", strerror(errno));
+ pa_log(__FILE__": failed to read from event device: %s", pa_cstrerror(errno));
goto fail;
}
u->fd = -1;
if ((u->fd = open(pa_modargs_get_value(ma, "device", DEFAULT_DEVICE), O_RDONLY)) < 0) {
- pa_log(__FILE__": failed to open evdev device: %s", strerror(errno));
+ pa_log(__FILE__": failed to open evdev device: %s", pa_cstrerror(errno));
goto fail;
}
if (ioctl(u->fd, EVIOCGVERSION, &version) < 0) {
- pa_log(__FILE__": EVIOCGVERSION failed: %s", strerror(errno));
+ pa_log(__FILE__": EVIOCGVERSION failed: %s", pa_cstrerror(errno));
goto fail;
}
pa_log_info(__FILE__": evdev driver version %i.%i.%i", version >> 16, (version >> 8) & 0xff, version & 0xff);
if(ioctl(u->fd, EVIOCGID, &input_id)) {
- pa_log(__FILE__": EVIOCGID failed: %s", strerror(errno));
+ pa_log(__FILE__": EVIOCGID failed: %s", pa_cstrerror(errno));
goto fail;
}
memset(name, 0, sizeof(name));
if(ioctl(u->fd, EVIOCGNAME(sizeof(name)), name) < 0) {
- pa_log(__FILE__": EVIOCGNAME failed: %s", strerror(errno));
+ pa_log(__FILE__": EVIOCGNAME failed: %s", pa_cstrerror(errno));
goto fail;
}
memset(evtype_bitmask, 0, sizeof(evtype_bitmask));
if (ioctl(u->fd, EVIOCGBIT(0, EV_MAX), evtype_bitmask) < 0) {
- pa_log(__FILE__": EVIOCGBIT failed: %s", strerror(errno));
+ pa_log(__FILE__": EVIOCGBIT failed: %s", pa_cstrerror(errno));
goto fail;
}
#include <limits.h>
#include <sys/mman.h>
+#include <polyp/error.h>
#include <polyp/xmalloc.h>
#include <polypcore/iochannel.h>
update_usage(u);
if (ioctl(u->fd, SNDCTL_DSP_GETOPTR, &info) < 0) {
- pa_log(__FILE__": SNDCTL_DSP_GETOPTR: %s", strerror(errno));
+ pa_log(__FILE__": SNDCTL_DSP_GETOPTR: %s", pa_cstrerror(errno));
return;
}
update_usage(u);
if (ioctl(u->fd, SNDCTL_DSP_GETIPTR, &info) < 0) {
- pa_log(__FILE__": SNDCTL_DSP_GETIPTR: %s", strerror(errno));
+ pa_log(__FILE__": SNDCTL_DSP_GETIPTR: %s", pa_cstrerror(errno));
return;
}
assert(s && u);
if (ioctl(u->fd, SNDCTL_DSP_GETOPTR, &info) < 0) {
- pa_log(__FILE__": SNDCTL_DSP_GETOPTR: %s", strerror(errno));
+ pa_log(__FILE__": SNDCTL_DSP_GETOPTR: %s", pa_cstrerror(errno));
return 0;
}
assert(s && u);
if (ioctl(u->fd, SNDCTL_DSP_GETIPTR, &info) < 0) {
- pa_log(__FILE__": SNDCTL_DSP_GETIPTR: %s", strerror(errno));
+ pa_log(__FILE__": SNDCTL_DSP_GETIPTR: %s", pa_cstrerror(errno));
return 0;
}
struct userdata *u = s->userdata;
if (pa_oss_get_pcm_volume(u->fd, &s->sample_spec, &s->hw_volume) < 0) {
- pa_log_info(__FILE__": device doesn't support reading mixer settings: %s", strerror(errno));
+ pa_log_info(__FILE__": device doesn't support reading mixer settings: %s", pa_cstrerror(errno));
s->get_hw_volume = NULL;
return -1;
}
struct userdata *u = s->userdata;
if (pa_oss_set_pcm_volume(u->fd, &s->sample_spec, &s->hw_volume) < 0) {
- pa_log_info(__FILE__": device doesn't support writing mixer settings: %s", strerror(errno));
+ pa_log_info(__FILE__": device doesn't support writing mixer settings: %s", pa_cstrerror(errno));
s->set_hw_volume = NULL;
return -1;
}
struct userdata *u = s->userdata;
if (pa_oss_get_input_volume(u->fd, &s->sample_spec, &s->hw_volume) < 0) {
- pa_log_info(__FILE__": device doesn't support reading mixer settings: %s", strerror(errno));
+ pa_log_info(__FILE__": device doesn't support reading mixer settings: %s", pa_cstrerror(errno));
s->get_hw_volume = NULL;
return -1;
}
struct userdata *u = s->userdata;
if (pa_oss_set_input_volume(u->fd, &s->sample_spec, &s->hw_volume) < 0) {
- pa_log_info(__FILE__": device doesn't support writing mixer settings: %s", strerror(errno));
+ pa_log_info(__FILE__": device doesn't support writing mixer settings: %s", pa_cstrerror(errno));
s->set_hw_volume = NULL;
return -1;
}
if (mode != O_WRONLY) {
if (ioctl(u->fd, SNDCTL_DSP_GETISPACE, &info) < 0) {
- pa_log(__FILE__": SNDCTL_DSP_GETISPACE: %s", strerror(errno));
+ pa_log(__FILE__": SNDCTL_DSP_GETISPACE: %s", pa_cstrerror(errno));
goto fail;
}
pa_log(__FILE__": mmap failed for input. Changing to O_WRONLY mode.");
mode = O_WRONLY;
} else {
- pa_log(__FILE__": mmap(): %s", strerror(errno));
+ pa_log(__FILE__": mmap(): %s", pa_cstrerror(errno));
goto fail;
}
} else {
if (mode != O_RDONLY) {
if (ioctl(u->fd, SNDCTL_DSP_GETOSPACE, &info) < 0) {
- pa_log(__FILE__": SNDCTL_DSP_GETOSPACE: %s", strerror(errno));
+ pa_log(__FILE__": SNDCTL_DSP_GETOSPACE: %s", pa_cstrerror(errno));
goto fail;
}
pa_log(__FILE__": mmap filed for output. Changing to O_RDONLY mode.");
mode = O_RDONLY;
} else {
- pa_log(__FILE__": mmap(): %s", strerror(errno));
+ pa_log(__FILE__": mmap(): %s", pa_cstrerror(errno));
goto fail;
}
} else {
zero = 0;
if (ioctl(u->fd, SNDCTL_DSP_SETTRIGGER, &zero) < 0) {
- pa_log(__FILE__": SNDCTL_DSP_SETTRIGGER: %s", strerror(errno));
+ pa_log(__FILE__": SNDCTL_DSP_SETTRIGGER: %s", pa_cstrerror(errno));
goto fail;
}
if (ioctl(u->fd, SNDCTL_DSP_SETTRIGGER, &enable_bits) < 0) {
- pa_log(__FILE__": SNDCTL_DSP_SETTRIGGER: %s", strerror(errno));
+ pa_log(__FILE__": SNDCTL_DSP_SETTRIGGER: %s", pa_cstrerror(errno));
goto fail;
}
#include <unistd.h>
#include <limits.h>
+#include <polyp/error.h>
#include <polyp/xmalloc.h>
#include <polypcore/iochannel.h>
assert(memchunk->length);
if ((r = pa_iochannel_write(u->io, (uint8_t*) memchunk->memblock->data + memchunk->index, memchunk->length)) < 0) {
- pa_log(__FILE__": write() failed: %s", strerror(errno));
+ pa_log(__FILE__": write() failed: %s", pa_cstrerror(errno));
break;
}
if ((r = pa_iochannel_read(u->io, memchunk.memblock->data, memchunk.memblock->length)) < 0) {
pa_memblock_unref(memchunk.memblock);
if (errno != EAGAIN)
- pa_log(__FILE__": read() failed: %s", strerror(errno));
+ pa_log(__FILE__": read() failed: %s", pa_cstrerror(errno));
break;
}
assert(s && u && u->sink);
if (ioctl(u->fd, SNDCTL_DSP_GETODELAY, &arg) < 0) {
- pa_log_info(__FILE__": device doesn't support SNDCTL_DSP_GETODELAY: %s", strerror(errno));
+ pa_log_info(__FILE__": device doesn't support SNDCTL_DSP_GETODELAY: %s", pa_cstrerror(errno));
s->get_latency = NULL;
return 0;
}
struct userdata *u = s->userdata;
if (pa_oss_get_pcm_volume(u->fd, &s->sample_spec, &s->hw_volume) < 0) {
- pa_log_info(__FILE__": device doesn't support reading mixer settings: %s", strerror(errno));
+ pa_log_info(__FILE__": device doesn't support reading mixer settings: %s", pa_cstrerror(errno));
s->get_hw_volume = NULL;
return -1;
}
struct userdata *u = s->userdata;
if (pa_oss_set_pcm_volume(u->fd, &s->sample_spec, &s->hw_volume) < 0) {
- pa_log_info(__FILE__": device doesn't support writing mixer settings: %s", strerror(errno));
+ pa_log_info(__FILE__": device doesn't support writing mixer settings: %s", pa_cstrerror(errno));
s->set_hw_volume = NULL;
return -1;
}
struct userdata *u = s->userdata;
if (pa_oss_get_input_volume(u->fd, &s->sample_spec, &s->hw_volume) < 0) {
- pa_log_info(__FILE__": device doesn't support reading mixer settings: %s", strerror(errno));
+ pa_log_info(__FILE__": device doesn't support reading mixer settings: %s", pa_cstrerror(errno));
s->get_hw_volume = NULL;
return -1;
}
struct userdata *u = s->userdata;
if (pa_oss_set_input_volume(u->fd, &s->sample_spec, &s->hw_volume) < 0) {
- pa_log_info(__FILE__": device doesn't support writing mixer settings: %s", strerror(errno));
+ pa_log_info(__FILE__": device doesn't support writing mixer settings: %s", pa_cstrerror(errno));
s->set_hw_volume = NULL;
return -1;
}
goto fail;
if (ioctl(fd, SNDCTL_DSP_GETBLKSIZE, &frag_size) < 0) {
- pa_log(__FILE__": SNDCTL_DSP_GETBLKSIZE: %s", strerror(errno));
+ pa_log(__FILE__": SNDCTL_DSP_GETBLKSIZE: %s", pa_cstrerror(errno));
goto fail;
}
assert(frag_size);
#include <unistd.h>
#include <limits.h>
+#include <polyp/error.h>
#include <polyp/xmalloc.h>
#include <polypcore/iochannel.h>
assert(u->memchunk.memblock && u->memchunk.length);
if ((r = pa_iochannel_write(u->io, (uint8_t*) u->memchunk.memblock->data + u->memchunk.index, u->memchunk.length)) < 0) {
- pa_log(__FILE__": write() failed: %s", strerror(errno));
+ pa_log(__FILE__": write(): %s", pa_cstrerror(errno));
return;
}
mkfifo(p = pa_modargs_get_value(ma, "file", DEFAULT_FIFO_NAME), 0777);
if ((fd = open(p, O_RDWR)) < 0) {
- pa_log(__FILE__": open('%s'): %s", p, strerror(errno));
+ pa_log(__FILE__": open('%s'): %s", p, pa_cstrerror(errno));
goto fail;
}
pa_fd_set_cloexec(fd, 1);
if (fstat(fd, &st) < 0) {
- pa_log(__FILE__": fstat('%s'): %s", p, strerror(errno));
+ pa_log(__FILE__": fstat('%s'): %s", p, pa_cstrerror(errno));
goto fail;
}
#include <unistd.h>
#include <limits.h>
+#include <polyp/error.h>
#include <polyp/xmalloc.h>
#include <polypcore/iochannel.h>
assert(u->chunk.memblock && u->chunk.memblock->length > u->chunk.index);
if ((r = pa_iochannel_read(u->io, (uint8_t*) u->chunk.memblock->data + u->chunk.index, u->chunk.memblock->length - u->chunk.index)) <= 0) {
- pa_log(__FILE__": read() failed: %s", strerror(errno));
+ pa_log(__FILE__": read(): %s", pa_cstrerror(errno));
return;
}
mkfifo(p = pa_modargs_get_value(ma, "file", DEFAULT_FIFO_NAME), 0777);
if ((fd = open(p, O_RDWR)) < 0) {
- pa_log(__FILE__": open('%s'): %s", p, strerror(errno));
+ pa_log(__FILE__": open('%s'): %s", p, pa_cstrerror(errno));
goto fail;
}
pa_fd_set_cloexec(fd, 1);
if (fstat(fd, &st) < 0) {
- pa_log(__FILE__": fstat('%s'): %s", p, strerror(errno));
+ pa_log(__FILE__": fstat('%s'): %s", p, pa_cstrerror(errno));
goto fail;
}
#include "../polypcore/winsock.h"
+#include <polyp/error.h>
#include <polyp/xmalloc.h>
#include <polypcore/module.h>
}
if ((r = pa_unix_socket_remove_stale(tmp)) < 0) {
- pa_log(__FILE__": Failed to remove stale UNIX socket '%s': %s", tmp, strerror(errno));
+ pa_log(__FILE__": Failed to remove stale UNIX socket '%s': %s", tmp, pa_cstrerror(errno));
goto fail;
}
if ((p = pa_parent_dir(u->socket_path))) {
if (rmdir(p) < 0 && errno != ENOENT && errno != ENOTEMPTY)
- pa_log(__FILE__": Failed to remove %s: %s.", u->socket_path, strerror(errno));
+ pa_log(__FILE__": Failed to remove %s: %s.", u->socket_path, pa_cstrerror(errno));
pa_xfree(p);
}
#include <sys/conf.h>
#include <sys/audio.h>
+#include <polyp/error.h>
#include <polyp/mainloop-signal.h>
#include <polyp/xmalloc.h>
}
if ((r = pa_iochannel_write(u->io, (uint8_t*) memchunk->memblock->data + memchunk->index, len)) < 0) {
- pa_log(__FILE__": write() failed: %s", strerror(errno));
+ pa_log(__FILE__": write() failed: %s", pa_cstrerror(errno));
return;
}
if ((r = pa_iochannel_read(u->io, memchunk.memblock->data, memchunk.memblock->length)) < 0) {
pa_memblock_unref(memchunk.memblock);
if (errno != EAGAIN)
- pa_log(__FILE__": read() failed: %s", strerror(errno));
+ pa_log(__FILE__": read() failed: %s", pa_cstrerror(errno));
return;
}
if (errno == EINVAL)
pa_log(__FILE__": AUDIO_SETINFO: Unsupported volume.");
else
- pa_log(__FILE__": AUDIO_SETINFO: %s", strerror(errno));
+ pa_log(__FILE__": AUDIO_SETINFO: %s", pa_cstrerror(errno));
return -1;
}
info.output_muted = !!s->hw_muted;
if (ioctl(u->fd, AUDIO_SETINFO, &info) < 0) {
- pa_log(__FILE__": AUDIO_SETINFO: %s", strerror(errno));
+ pa_log(__FILE__": AUDIO_SETINFO: %s", pa_cstrerror(errno));
return -1;
}
if (errno == EINVAL)
pa_log(__FILE__": AUDIO_SETINFO: Unsupported volume.");
else
- pa_log(__FILE__": AUDIO_SETINFO: %s", strerror(errno));
+ pa_log(__FILE__": AUDIO_SETINFO: %s", pa_cstrerror(errno));
return -1;
}
if (errno == EINVAL)
pa_log(__FILE__": AUDIO_SETINFO: Unsupported sample format.");
else
- pa_log(__FILE__": AUDIO_SETINFO: %s", strerror(errno));
+ pa_log(__FILE__": AUDIO_SETINFO: %s", pa_cstrerror(errno));
return -1;
}
if (errno == EINVAL)
pa_log(__FILE__": AUDIO_SETINFO: Unsupported buffer size.");
else
- pa_log(__FILE__": AUDIO_SETINFO: %s", strerror(errno));
+ pa_log(__FILE__": AUDIO_SETINFO: %s", pa_cstrerror(errno));
return -1;
}
#include <stdlib.h>
#include <ctype.h>
+#include <polyp/error.h>
#include <polyp/xmalloc.h>
#include <polypcore/module.h>
pa_log_info(__FILE__": starting with empty ruleset.");
ret = 0;
} else
- pa_log(__FILE__": failed to open file '%s': %s", u->table_file, strerror(errno));
+ pa_log(__FILE__": failed to open file '%s': %s", u->table_file, pa_cstrerror(errno));
goto finish;
}
pa_open_config_file(NULL, DEFAULT_VOLUME_TABLE_FILE, NULL, &u->table_file, "w");
if (!f) {
- pa_log(__FILE__": failed to open file '%s': %s", u->table_file, strerror(errno));
+ pa_log(__FILE__": failed to open file '%s': %s", u->table_file, pa_cstrerror(errno));
goto finish;
}
#include <sys/stat.h>
#include <fcntl.h>
+#include <polyp/error.h>
+
#include <polypcore/core-util.h>
#include <polypcore/log.h>
tcaps = pcaps ? pcaps : &dcaps;
if (ioctl(fd, SNDCTL_DSP_GETCAPS, tcaps) < 0) {
- pa_log(__FILE__": SNDCTL_DSP_GETCAPS: %s", strerror(errno));
+ pa_log(__FILE__": SNDCTL_DSP_GETCAPS: %s", pa_cstrerror(errno));
goto fail;
}
if ((fd = open(device, (*mode = O_WRONLY)|O_NDELAY)) < 0) {
if ((fd = open(device, (*mode = O_RDONLY)|O_NDELAY)) < 0) {
- pa_log(__FILE__": open('%s'): %s", device, strerror(errno));
+ pa_log(__FILE__": open('%s'): %s", device, pa_cstrerror(errno));
goto fail;
}
}
} else {
if ((fd = open(device, *mode|O_NDELAY)) < 0) {
- pa_log(__FILE__": open('%s'): %s", device, strerror(errno));
+ pa_log(__FILE__": open('%s'): %s", device, pa_cstrerror(errno));
goto fail;
}
}
if (pcaps) {
if (ioctl(fd, SNDCTL_DSP_GETCAPS, pcaps) < 0) {
- pa_log(__FILE__": SNDCTL_DSP_GETCAPS: %s", strerror(errno));
+ pa_log(__FILE__": SNDCTL_DSP_GETCAPS: %s", pa_cstrerror(errno));
goto fail;
}
}
if (ioctl(fd, SNDCTL_DSP_SETFMT, &format) < 0 || format != f) {
format = AFMT_U8;
if (ioctl(fd, SNDCTL_DSP_SETFMT, &format) < 0 || format != AFMT_U8) {
- pa_log(__FILE__": SNDCTL_DSP_SETFMT: %s", format != AFMT_U8 ? "No supported sample format" : strerror(errno));
+ pa_log(__FILE__": SNDCTL_DSP_SETFMT: %s", format != AFMT_U8 ? "No supported sample format" : pa_cstrerror(errno));
return -1;
} else
ss->format = PA_SAMPLE_U8;
channels = ss->channels;
if (ioctl(fd, SNDCTL_DSP_CHANNELS, &channels) < 0) {
- pa_log(__FILE__": SNDCTL_DSP_CHANNELS: %s", strerror(errno));
+ pa_log(__FILE__": SNDCTL_DSP_CHANNELS: %s", pa_cstrerror(errno));
return -1;
}
assert(channels);
speed = ss->rate;
if (ioctl(fd, SNDCTL_DSP_SPEED, &speed) < 0) {
- pa_log(__FILE__": SNDCTL_DSP_SPEED: %s", strerror(errno));
+ pa_log(__FILE__": SNDCTL_DSP_SPEED: %s", pa_cstrerror(errno));
return -1;
}
assert(speed);
arg = ((int) nfrags << 16) | simple_log2(frag_size);
if (ioctl(fd, SNDCTL_DSP_SETFRAGMENT, &arg) < 0) {
- pa_log(__FILE__": SNDCTL_DSP_SETFRAGMENT: %s", strerror(errno));
+ pa_log(__FILE__": SNDCTL_DSP_SETFRAGMENT: %s", pa_cstrerror(errno));
return -1;
}
!(f = fopen("/proc/asound/oss/sndstat", "r"))) {
if (errno != ENOENT)
- pa_log_warn(__FILE__": failed to open OSS sndstat device: %s", strerror(errno));
+ pa_log_warn(__FILE__": failed to open OSS sndstat device: %s", pa_cstrerror(errno));
return -1;
}
#include <string.h>
#include <unistd.h>
+#include <polyp/error.h>
#include <polyp/timeval.h>
#include <polyp/xmalloc.h>
af = sa->sa_family;
if ((fd = socket(af, SOCK_DGRAM, 0)) < 0) {
- pa_log(__FILE__": Failed to create socket: %s", strerror(errno));
+ pa_log(__FILE__": Failed to create socket: %s", pa_cstrerror(errno));
goto fail;
}
one = 1;
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)) < 0) {
- pa_log(__FILE__": SO_REUSEADDR failed: %s", strerror(errno));
+ pa_log(__FILE__": SO_REUSEADDR failed: %s", pa_cstrerror(errno));
goto fail;
}
}
if (r < 0) {
- pa_log_info(__FILE__": Joining mcast group failed: %s", strerror(errno));
+ pa_log_info(__FILE__": Joining mcast group failed: %s", pa_cstrerror(errno));
goto fail;
}
if (bind(fd, sa, salen) < 0) {
- pa_log(__FILE__": bind() failed: %s", strerror(errno));
+ pa_log(__FILE__": bind() failed: %s", pa_cstrerror(errno));
goto fail;
}
#include <string.h>
#include <unistd.h>
+#include <polyp/error.h>
#include <polyp/timeval.h>
#include <polyp/util.h>
#include <polyp/xmalloc.h>
}
if ((fd = socket(af, SOCK_DGRAM, 0)) < 0) {
- pa_log(__FILE__": socket() failed: %s", strerror(errno));
+ pa_log(__FILE__": socket() failed: %s", pa_cstrerror(errno));
goto fail;
}
if (connect(fd, af == AF_INET ? (struct sockaddr*) &sa4 : (struct sockaddr*) &sa6, af == AF_INET ? sizeof(sa4) : sizeof(sa6)) < 0) {
- pa_log(__FILE__": connect() failed: %s", strerror(errno));
+ pa_log(__FILE__": connect() failed: %s", pa_cstrerror(errno));
goto fail;
}
if ((sap_fd = socket(af, SOCK_DGRAM, 0)) < 0) {
- pa_log(__FILE__": socket() failed: %s", strerror(errno));
+ pa_log(__FILE__": socket() failed: %s", pa_cstrerror(errno));
goto fail;
}
if (connect(sap_fd, af == AF_INET ? (struct sockaddr*) &sap_sa4 : (struct sockaddr*) &sap_sa6, af == AF_INET ? sizeof(sap_sa4) : sizeof(sap_sa6)) < 0) {
- pa_log(__FILE__": connect() failed: %s", strerror(errno));
+ pa_log(__FILE__": connect() failed: %s", pa_cstrerror(errno));
goto fail;
}
if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_LOOP, &loop, sizeof(loop)) < 0 ||
setsockopt(sap_fd, IPPROTO_IP, IP_MULTICAST_LOOP, &loop, sizeof(loop)) < 0) {
- pa_log(__FILE__": IP_MULTICAST_LOOP failed: %s", strerror(errno));
+ pa_log(__FILE__": IP_MULTICAST_LOOP failed: %s", pa_cstrerror(errno));
goto fail;
}
#include <sys/filio.h>
#endif
+#include <polyp/error.h>
+
#include <polypcore/log.h>
#include "rtp.h"
if (k < 0) {
if (errno != EAGAIN) /* If the queue is full, just ignore it */
- pa_log(__FILE__": sendmsg() failed: %s", strerror(errno));
+ pa_log(__FILE__": sendmsg() failed: %s", pa_cstrerror(errno));
return -1;
}
chunk->memblock = NULL;
if (ioctl(c->fd, FIONREAD, &size) < 0) {
- pa_log(__FILE__": FIONREAD failed: %s", strerror(errno));
+ pa_log(__FILE__": FIONREAD failed: %s", pa_cstrerror(errno));
goto fail;
}
m.msg_flags = 0;
if ((r = recvmsg(c->fd, &m, 0)) != size) {
- pa_log(__FILE__": recvmsg() failed: %s", r < 0 ? strerror(errno) : "size mismatch");
+ pa_log(__FILE__": recvmsg() failed: %s", r < 0 ? pa_cstrerror(errno) : "size mismatch");
goto fail;
}
#include <sys/filio.h>
#endif
+#include <polyp/error.h>
#include <polyp/xmalloc.h>
#include <polypcore/core-util.h>
int k;
if (getsockname(c->fd, sa, &salen) < 0) {
- pa_log("getsockname() failed: %s\n", strerror(errno));
+ pa_log("getsockname() failed: %s\n", pa_cstrerror(errno));
return -1;
}
m.msg_flags = 0;
if ((k = sendmsg(c->fd, &m, MSG_DONTWAIT)) < 0)
- pa_log("sendmsg() failed: %s\n", strerror(errno));
+ pa_log("sendmsg() failed: %s\n", pa_cstrerror(errno));
return k;
}
assert(goodbye);
if (ioctl(c->fd, FIONREAD, &size) < 0) {
- pa_log(__FILE__": FIONREAD failed: %s", strerror(errno));
+ pa_log(__FILE__": FIONREAD failed: %s", pa_cstrerror(errno));
goto fail;
}
m.msg_flags = 0;
if ((r = recvmsg(c->fd, &m, 0)) != size) {
- pa_log(__FILE__": recvmsg() failed: %s", r < 0 ? strerror(errno) : "size mismatch");
+ pa_log(__FILE__": recvmsg() failed: %s", r < 0 ? pa_cstrerror(errno) : "size mismatch");
goto fail;
}
#include <errno.h>
#include <string.h>
+#include <polyp/error.h>
#include <polyp/xmalloc.h>
#include <polypcore/log.h>
pa_open_config_file(DEFAULT_CLIENT_CONFIG_FILE, DEFAULT_CLIENT_CONFIG_FILE_USER, ENV_CLIENT_CONFIG_FILE, &fn, "r");
if (!f && errno != EINTR) {
- pa_log(__FILE__": WARNING: failed to open configuration file '%s': %s", filename, strerror(errno));
+ pa_log(__FILE__": WARNING: failed to open configuration file '%s': %s", filename, pa_cstrerror(errno));
goto finish;
}
#include "../polypcore/winsock.h"
+#include <polyp/error.h>
#include <polyp/version.h>
#include <polyp/xmalloc.h>
pa_context_ref(c);
if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds) < 0) {
- pa_log(__FILE__": socketpair() failed: %s", strerror(errno));
+ pa_log(__FILE__": socketpair(): %s", pa_cstrerror(errno));
pa_context_fail(c, PA_ERR_INTERNAL);
goto fail;
}
c->spawn_api.prefork();
if ((pid = fork()) < 0) {
- pa_log(__FILE__": fork() failed: %s", strerror(errno));
+ pa_log(__FILE__": fork(): %s", pa_cstrerror(errno));
pa_context_fail(c, PA_ERR_INTERNAL);
if (c->spawn_api.postfork)
c->spawn_api.postfork();
if (r < 0) {
- pa_log(__FILE__": waitpid() failed: %s", strerror(errno));
+ pa_log(__FILE__": waitpid(): %s", pa_cstrerror(errno));
pa_context_fail(c, PA_ERR_INTERNAL);
goto fail;
} else if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
#include <config.h>
#endif
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
+#ifdef HAVE_PTHREAD
+#include <pthread.h>
+#endif
+
+#ifdef HAVE_WINDOWS_H
+#include <windows.h>
+#endif
+
+#include <polyp/utf8.h>
+#include <polyp/xmalloc.h>
+
+#include <polypcore/core-util.h>
#include <polypcore/native-common.h>
#include "error.h"
return errortab[error];
}
+
+#ifdef HAVE_PTHREAD
+
+static pthread_once_t cstrerror_once = PTHREAD_ONCE_INIT;
+static pthread_key_t tlsstr_key;
+
+static void inittls(void) {
+ int ret;
+
+ ret = pthread_key_create(&tlsstr_key, pa_xfree);
+ if (ret) {
+ fprintf(stderr, __FILE__ ": CRITICAL: Unable to allocate TLS key (%d)\n", errno);
+ exit(-1);
+ }
+}
+
+#elif HAVE_WINDOWS_H
+
+static __declspec(thread) char *tlsstr;
+
+#else
+
+/* Unsafe, but we have no choice */
+static char *tlsstr;
+
+#endif
+
+char* pa_cstrerror(int errnum) {
+ const char *origbuf;
+
+#ifdef HAVE_STRERROR_R
+ char errbuf[128];
+#endif
+
+#ifdef HAVE_PTHREAD
+ char *tlsstr;
+
+ pthread_once(&cstrerror_once, inittls);
+
+ tlsstr = pthread_getspecific(tlsstr_key);
+#endif
+
+ if (tlsstr)
+ pa_xfree(tlsstr);
+
+#ifdef HAVE_STRERROR_R
+
+#ifdef __GLIBC__
+ origbuf = strerror_r(errnum, errbuf, sizeof(errbuf));
+ if (origbuf == NULL)
+ origbuf = "";
+#else
+ if (strerror_r(errnum, errbuf, sizeof(errbuf)) == 0) {
+ origbuf = errbuf;
+ errbuf[sizeof(errbuf) - 1] = '\0';
+ } else
+ origbuf = "";
+#endif
+
+#else
+ /* This might not be thread safe, but we hope for the best */
+ origbuf = strerror(errnum);
+#endif
+
+ tlsstr = pa_locale_to_utf8(origbuf);
+ if (!tlsstr) {
+ fprintf(stderr, "Unable to convert, filtering\n");
+ tlsstr = pa_utf8_filter(origbuf);
+ }
+
+#ifdef HAVE_PTHREAD
+ pthread_setspecific(tlsstr_key, tlsstr);
+#endif
+
+ return tlsstr;
+}
/** Return a human readable error message for the specified numeric error code */
const char* pa_strerror(int error);
+/** A wrapper around the standard strerror() function that converts the
+ * string to UTF-8. The function is thread safe but the returned string is
+ * only guaranteed to exist until the thread exits or pa_cstrerror() is
+ * called again from the same thread. */
+char* pa_cstrerror(int errnum);
+
PA_C_DECL_END
#endif
#include <windows.h>
#endif
+#include <polyp/error.h>
#include <polyp/xmalloc.h>
#include <polypcore/core-util.h>
if (errno == EAGAIN)
return;
- pa_log(__FILE__": read(): %s", strerror(errno));
+ pa_log(__FILE__": read(): %s", pa_cstrerror(errno));
return;
}
assert(!api && a && signal_pipe[0] == -1 && signal_pipe[1] == -1 && !io_event);
if (pipe(signal_pipe) < 0) {
- pa_log(__FILE__": pipe() failed: %s", strerror(errno));
+ pa_log(__FILE__": pipe(): %s", pa_cstrerror(errno));
return -1;
}
#include "../polypcore/pipe.h"
#endif
+#include <polyp/error.h>
#include <polyp/timeval.h>
#include <polyp/xmalloc.h>
if (errno == EINTR)
r = 0;
else
- pa_log(__FILE__": poll(): %s", strerror(errno));
+ pa_log(__FILE__": poll(): %s", pa_cstrerror(errno));
}
}
#include "../polypcore/winsock.h"
+#include <polyp/error.h>
+
#include <polypcore/log.h>
#include <polypcore/core-util.h>
char *pa_get_host_name(char *s, size_t l) {
assert(s && l > 0);
if (gethostname(s, l) < 0) {
- pa_log(__FILE__": gethostname(): %s", strerror(errno));
+ pa_log(__FILE__": gethostname(): %s", pa_cstrerror(errno));
return NULL;
}
s[l-1] = 0;
#include <limits.h>
#include <sys/stat.h>
+#include <polyp/error.h>
#include <polyp/util.h>
#include <polypcore/core-util.h>
#include <polypcore/log.h>
ftruncate(fd, 0);
if ((r = pa_loop_write(fd, ret_data, length)) < 0 || (size_t) r != length) {
- pa_log(__FILE__": failed to write cookie file: %s", strerror(errno));
+ pa_log(__FILE__": failed to write cookie file: %s", pa_cstrerror(errno));
return -1;
}
if ((fd = open(fn, O_RDWR|O_CREAT|O_BINARY, S_IRUSR|S_IWUSR)) < 0) {
if (errno != EACCES || (fd = open(fn, O_RDONLY|O_BINARY)) < 0) {
- pa_log(__FILE__": failed to open cookie file '%s': %s", fn, strerror(errno));
+ pa_log(__FILE__": failed to open cookie file '%s': %s", fn, pa_cstrerror(errno));
goto finish;
} else
writable = 0;
unlock = pa_lock_fd(fd, 1) >= 0;
if ((r = pa_loop_read(fd, data, length)) < 0) {
- pa_log(__FILE__": failed to read cookie file '%s': %s", fn, strerror(errno));
+ pa_log(__FILE__": failed to read cookie file '%s': %s", fn, pa_cstrerror(errno));
goto finish;
}
if (ret < 0)
pa_log(__FILE__": Failed to load authorization key '%s': %s", path,
- (ret == -1) ? strerror(errno) : "file corrupt");
+ (ret == -1) ? pa_cstrerror(errno) : "file corrupt");
return ret;
}
return -2;
if ((fd = open(p, O_RDWR|O_CREAT, S_IRUSR|S_IWUSR)) < 0) {
- pa_log(__FILE__": failed to open cookie file '%s': %s", fn, strerror(errno));
+ pa_log(__FILE__": failed to open cookie file '%s': %s", fn, pa_cstrerror(errno));
goto finish;
}
unlock = pa_lock_fd(fd, 1) >= 0;
if ((r = pa_loop_write(fd, data, length)) < 0 || (size_t) r != length) {
- pa_log(__FILE__": failed to read cookie file '%s': %s", fn, strerror(errno));
+ pa_log(__FILE__": failed to read cookie file '%s': %s", fn, pa_cstrerror(errno));
goto finish;
}
#include <stdlib.h>
#include <errno.h>
+#include <polyp/error.h>
#include <polyp/xmalloc.h>
#include <polypcore/module.h>
assert(c && fn && buf);
if (!(f = fopen(fn, "r"))) {
- pa_strbuf_printf(buf, "open('%s') failed: %s\n", fn, strerror(errno));
+ pa_strbuf_printf(buf, "open('%s') failed: %s\n", fn, pa_cstrerror(errno));
if (!*fail)
ret = 0;
goto fail;
#include <stdio.h>
#include <errno.h>
+#include <polyp/error.h>
#include <polyp/xmalloc.h>
#include <polypcore/log.h>
goto finish;
}
- pa_log(__FILE__": WARNING: failed to open configuration file '%s': %s", filename, strerror(errno));
+ pa_log_warn(__FILE__": WARNING: failed to open configuration file '%s': %s",
+ filename, pa_cstrerror(errno));
goto finish;
}
if (feof(f))
break;
- pa_log(__FILE__": WARNING: failed to read configuration file '%s': %s", filename, strerror(errno));
+ pa_log_warn(__FILE__": WARNING: failed to read configuration file '%s': %s",
+ filename, pa_cstrerror(errno));
goto finish;
}
#include <windows.h>
#endif
+#include <polyp/error.h>
#include <polyp/mainloop.h>
#include <polyp/channelmap.h>
#include <polyp/timeval.h>
e = pa_path_get_filename(pathname);
if (stat(pathname, &st) < 0) {
- pa_log(__FILE__": stat('%s') failed: %s", pathname, strerror(errno));
+ pa_log(__FILE__": stat('%s'): %s", pathname, pa_cstrerror(errno));
return;
}
/* If that fails, try to open it as shell glob */
if (glob(pathname, GLOB_ERR|GLOB_NOSORT, NULL, &p) < 0) {
- pa_log(__FILE__": Failed to open directory: %s", strerror(errno));
+ pa_log(__FILE__": failed to open directory '%s': %s", pathname, pa_cstrerror(errno));
return -1;
}
#include <samplerate.h>
+#include <polyp/error.h>
#include <polyp/xmalloc.h>
#include <polyp/util.h>
if (pthread_sigmask(SIG_SETMASK, NULL, &set) < 0) {
#endif
if (sigprocmask(SIG_SETMASK, NULL, &set) < 0) {
- pa_log(__FILE__": sigprocmask() failed: %s", strerror(errno));
+ pa_log(__FILE__": sigprocmask(): %s", pa_cstrerror(errno));
return;
}
#ifdef HAVE_PTHREAD
/* Check whether the signal is trapped */
if (sigaction(sig, NULL, &sa) < 0) {
- pa_log(__FILE__": sigaction() failed: %s", strerror(errno));
+ pa_log(__FILE__": sigaction(): %s", pa_cstrerror(errno));
return;
}
#ifdef HAVE_SYS_RESOURCE_H
if (setpriority(PRIO_PROCESS, 0, NICE_LEVEL) < 0)
- pa_log_warn(__FILE__": setpriority() failed: %s", strerror(errno));
+ pa_log_warn(__FILE__": setpriority(): %s", pa_cstrerror(errno));
else
pa_log_info(__FILE__": Successfully gained nice level %i.", NICE_LEVEL);
#endif
struct sched_param sp;
if (sched_getparam(0, &sp) < 0) {
- pa_log(__FILE__": sched_getparam() failed: %s", strerror(errno));
+ pa_log(__FILE__": sched_getparam(): %s", pa_cstrerror(errno));
return;
}
sp.sched_priority = 1;
if (sched_setscheduler(0, SCHED_FIFO, &sp) < 0) {
- pa_log_warn(__FILE__": sched_setscheduler() failed: %s", strerror(errno));
+ pa_log_warn(__FILE__": sched_setscheduler(): %s", pa_cstrerror(errno));
return;
}
data = pa_xmalloc(n);
if (getgrgid_r(gid, &group, data, n, &result) < 0 || !result) {
- pa_log(__FILE__ ": getgrgid_r(%u) failed: %s", gid, strerror(errno));
+ pa_log(__FILE__": getgrgid_r(%u): %s", gid, pa_cstrerror(errno));
goto finish;
}
/* XXX Not thread-safe, but needed on OSes (e.g. FreeBSD 4.X) that do not
* support getgrgid_r. */
if ((result = getgrgid(gid)) == NULL) {
- pa_log(__FILE__ ": getgrgid(%u) failed: %s", gid, strerror(errno));
- goto finish;
+ pa_log(__FILE__": getgrgid(%u): %s", gid, pa_cstrerror(errno));
+ goto finish;
}
r = strcmp(name, result->gr_name) == 0;
gids = pa_xmalloc(sizeof(GETGROUPS_T)*n);
if ((n = getgroups(n, gids)) < 0) {
- pa_log(__FILE__": getgroups() failed: %s", strerror(errno));
+ pa_log(__FILE__": getgroups(): %s", pa_cstrerror(errno));
goto finish;
}
return 0;
}
- pa_log(__FILE__": %slock failed: %s", !b ? "un" : "", strerror(errno));
+ pa_log(__FILE__": %slock: %s", !b? "un" : "",
+ pa_cstrerror(errno));
#endif
#ifdef OS_IS_WIN32
struct stat st;
if ((fd = open(fn, O_CREAT|O_RDWR, S_IRUSR|S_IWUSR)) < 0) {
- pa_log(__FILE__": failed to create lock file '%s': %s", fn, strerror(errno));
+ pa_log(__FILE__": failed to create lock file '%s': %s", fn,
+ pa_cstrerror(errno));
goto fail;
}
assert(fn && fd >= 0);
if (unlink(fn) < 0) {
- pa_log_warn(__FILE__": WARNING: unable to remove lock file '%s': %s", fn, strerror(errno));
+ pa_log_warn(__FILE__": WARNING: unable to remove lock file '%s': %s",
+ fn, pa_cstrerror(errno));
r = -1;
}
}
if (close(fd) < 0) {
- pa_log_warn(__FILE__": WARNING: failed to close lock file '%s': %s", fn, strerror(errno));
+ pa_log_warn(__FILE__": WARNING: failed to close lock file '%s': %s",
+ fn, pa_cstrerror(errno));
r = -1;
}
#include "winsock.h"
+#include <polyp/error.h>
#include <polyp/xmalloc.h>
#include <polypcore/core-util.h>
assert(io->ifd >= 0);
if (setsockopt(io->ifd, SOL_SOCKET, SO_PASSCRED, &t, sizeof(t)) < 0) {
- pa_log_error("setsockopt(SOL_SOCKET, SO_PASSCRED): %s", strerror(errno));
+ pa_log_error("setsockopt(SOL_SOCKET, SO_PASSCRED): %s", pa_cstrerror(errno));
return -1;
}
#include <stdlib.h>
#include <string.h>
+#include <polyp/error.h>
#include <polyp/xmalloc.h>
#include <polypcore/log.h>
pa_ioline_puts(l, "\nExiting.\n");
do_write(l);
} else if (r < 0) {
- pa_log(__FILE__": read() failed: %s", strerror(errno));
+ pa_log(__FILE__": read(): %s", pa_cstrerror(errno));
failure(l);
return -1;
}
while (!l->dead && pa_iochannel_is_writable(l->io) && l->wbuf_valid_length) {
if ((r = pa_iochannel_write(l->io, l->wbuf+l->wbuf_index, l->wbuf_valid_length)) < 0) {
- pa_log(__FILE__": write() failed: %s", r < 0 ? strerror(errno) : "EOF");
+ pa_log(__FILE__": write(): %s", r < 0 ? pa_cstrerror(errno) : "EOF");
failure(l);
return -1;
}
text = pa_vsprintf_malloc(format, ap);
+ if (!pa_utf8_valid(text))
+ pa_log_level(level, __FILE__": invalid UTF-8 string following below:");
+
for (t = text; t; t = n) {
if ((n = strchr(t, '\n'))) {
*n = 0;
#include <windows.h>
#endif
+#include <polyp/error.h>
#include <polyp/xmalloc.h>
#include <polypcore/core-util.h>
assert(fn && fd >= 0);
if ((r = pa_loop_read(fd, t, sizeof(t)-1)) < 0) {
- pa_log(__FILE__": WARNING: failed to read PID file '%s': %s", fn, strerror(errno));
+ pa_log_warn(__FILE__": WARNING: failed to read PID file '%s': %s",
+ fn, pa_cstrerror(errno));
return (pid_t) -1;
}
if ((fd = open(fn, mode, S_IRUSR|S_IWUSR)) < 0) {
if (mode != O_RDONLY || errno != ENOENT)
- pa_log(__FILE__": WARNING: failed to open PID file '%s': %s", fn, strerror(errno));
+ pa_log_warn(__FILE__": WARNING: failed to open PID file '%s': %s",
+ fn, pa_cstrerror(errno));
goto fail;
}
goto fail;
if (fstat(fd, &st) < 0) {
- pa_log(__FILE__": Failed to fstat() PID file '%s': %s", fn, strerror(errno));
+ pa_log_warn(__FILE__": WARNING: failed to fstat() PID file '%s': %s",
+ fn, pa_cstrerror(errno));
goto fail;
}
goto fail;
if (close(fd) < 0) {
- pa_log(__FILE__": Failed to close file '%s': %s", fn, strerror(errno));
+ pa_log_warn(__FILE__": WARNING: failed to close file '%s': %s",
+ fn, pa_cstrerror(errno));
goto fail;
}
/* Overwrite the current PID file */
if (lseek(fd, 0, SEEK_SET) == (off_t) -1 || ftruncate(fd, 0) < 0) {
- pa_log(__FILE__": failed to truncate PID fil: %s.", strerror(errno));
+ pa_log(__FILE__": failed to truncate PID file '%s': %s",
+ fn, pa_cstrerror(errno));
goto fail;
}
pa_runtime_path("pid", fn, sizeof(fn));
if ((fd = open_pid_file(fn, O_RDWR)) < 0) {
- pa_log(__FILE__": WARNING: failed to open PID file '%s': %s", fn, strerror(errno));
+ pa_log_warn(__FILE__": WARNING: failed to open PID file '%s': %s",
+ fn, pa_cstrerror(errno));
goto fail;
}
}
if (ftruncate(fd, 0) < 0) {
- pa_log(__FILE__": failed to truncate PID file '%s': %s", fn, strerror(errno));
+ pa_log_warn(__FILE__": WARNING: failed to truncate PID file '%s': %s",
+ fn, pa_cstrerror(errno));
goto fail;
}
#endif
if (unlink(fn) < 0) {
- pa_log(__FILE__": failed to remove PID file '%s': %s", fn, strerror(errno));
+ pa_log_warn(__FILE__": WARNING: failed to remove PID file '%s': %s",
+ fn, pa_cstrerror(errno));
goto fail;
}
#include <stdlib.h>
#include <limits.h>
+#include <polyp/error.h>
#include <polyp/sample.h>
#include <polyp/timeval.h>
#include <polyp/utf8.h>
assert(c->read_data_length < sizeof(c->request));
if ((r = pa_iochannel_read(c->io, ((uint8_t*) &c->request) + c->read_data_length, sizeof(c->request) - c->read_data_length)) <= 0) {
- pa_log_debug(__FILE__": read() failed: %s", r < 0 ? strerror(errno) : "EOF");
+ pa_log_debug(__FILE__": read(): %s", r < 0 ? pa_cstrerror(errno) : "EOF");
return -1;
}
assert(c->read_data && c->read_data_length < handler->data_length);
if ((r = pa_iochannel_read(c->io, (uint8_t*) c->read_data + c->read_data_length, handler->data_length - c->read_data_length)) <= 0) {
- pa_log_debug(__FILE__": read() failed: %s", r < 0 ? strerror(errno) : "EOF");
+ pa_log_debug(__FILE__": read(): %s", r < 0 ? pa_cstrerror(errno) : "EOF");
return -1;
}
assert(c->scache.memchunk.memblock && c->scache.name && c->scache.memchunk.index < c->scache.memchunk.length);
if ((r = pa_iochannel_read(c->io, (uint8_t*) c->scache.memchunk.memblock->data+c->scache.memchunk.index, c->scache.memchunk.length-c->scache.memchunk.index)) <= 0) {
- pa_log_debug(__FILE__": read() failed: %s", r < 0 ? strerror(errno) : "EOF");
+ pa_log_debug(__FILE__": read(): %s", r < 0 ? pa_cstrerror(errno) : "EOF");
return -1;
}
}
if ((r = pa_iochannel_read(c->io, (uint8_t*) c->playback.current_memblock->data+c->playback.memblock_index, l)) <= 0) {
- pa_log_debug(__FILE__": read() failed: %s", r < 0 ? strerror(errno) : "EOF");
+ pa_log_debug(__FILE__": read(): %s", r < 0 ? pa_cstrerror(errno) : "EOF");
return -1;
}
assert(c->write_data_index < c->write_data_length);
if ((r = pa_iochannel_write(c->io, (uint8_t*) c->write_data+c->write_data_index, c->write_data_length-c->write_data_index)) < 0) {
- pa_log(__FILE__": write() failed: %s", strerror(errno));
+ pa_log(__FILE__": write(): %s", pa_cstrerror(errno));
return -1;
}
if ((r = pa_iochannel_write(c->io, (uint8_t*) chunk.memblock->data+chunk.index, chunk.length)) < 0) {
pa_memblock_unref(chunk.memblock);
- pa_log(__FILE__": write(): %s", strerror(errno));
+ pa_log(__FILE__": write(): %s", pa_cstrerror(errno));
return -1;
}
#include <errno.h>
#include <string.h>
+#include <polyp/error.h>
#include <polyp/xmalloc.h>
#include <polypcore/sink-input.h>
}
if ((r = pa_iochannel_read(c->io, (uint8_t*) c->playback.current_memblock->data+c->playback.memblock_index, l)) <= 0) {
- pa_log_debug(__FILE__": read() failed: %s", r == 0 ? "EOF" : strerror(errno));
+ pa_log_debug(__FILE__": read(): %s", r == 0 ? "EOF" : pa_cstrerror(errno));
return -1;
}
if ((r = pa_iochannel_write(c->io, (uint8_t*) chunk.memblock->data+chunk.index, chunk.length)) < 0) {
pa_memblock_unref(chunk.memblock);
- pa_log(__FILE__": write(): %s", strerror(errno));
+ pa_log(__FILE__": write(): %s", pa_cstrerror(errno));
return -1;
}
#include "winsock.h"
+#include <polyp/error.h>
#include <polyp/timeval.h>
#include <polyp/xmalloc.h>
lerror = sizeof(error);
if (getsockopt(c->fd, SOL_SOCKET, SO_ERROR, (void*)&error, &lerror) < 0) {
- pa_log(__FILE__": getsockopt(): %s", strerror(errno));
+ pa_log(__FILE__": getsockopt(): %s", pa_cstrerror(errno));
goto finish;
}
}
if (error != 0) {
- pa_log_debug(__FILE__": connect(): %s", strerror(error));
+ pa_log_debug(__FILE__": connect(): %s", pa_cstrerror(errno));
errno = error;
goto finish;
}
pa_log_debug(__FILE__": connect(): %d", WSAGetLastError());
#else
if (errno != EINPROGRESS) {
- pa_log_debug(__FILE__": connect(): %s (%d)", strerror(errno), errno);
+ pa_log_debug(__FILE__": connect(): %s (%d)", pa_cstrerror(errno), errno);
#endif
return -1;
}
}
if ((c->fd = socket(sa->sa_family, SOCK_STREAM, 0)) < 0) {
- pa_log(__FILE__": socket(): %s", strerror(errno));
+ pa_log(__FILE__": socket(): %s", pa_cstrerror(errno));
return -1;
}
#include <polyp/xmalloc.h>
#include <polyp/util.h>
+#include <polyp/error.h>
#include <polypcore/socket-util.h>
#include <polypcore/core-util.h>
pa_socket_server_ref(s);
if ((nfd = accept(fd, NULL, NULL)) < 0) {
- pa_log(__FILE__": accept(): %s", strerror(errno));
+ pa_log(__FILE__": accept(): %s", pa_cstrerror(errno));
goto finish;
}
assert(m && filename);
if ((fd = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) {
- pa_log(__FILE__": socket(): %s", strerror(errno));
+ pa_log(__FILE__": socket(): %s", pa_cstrerror(errno));
goto fail;
}
pa_socket_low_delay(fd);
if (bind(fd, (struct sockaddr*) &sa, SUN_LEN(&sa)) < 0) {
- pa_log(__FILE__": bind(): %s", strerror(errno));
+ pa_log(__FILE__": bind(): %s", pa_cstrerror(errno));
goto fail;
}
if (listen(fd, 5) < 0) {
- pa_log(__FILE__": listen(): %s", strerror(errno));
+ pa_log(__FILE__": listen(): %s", pa_cstrerror(errno));
goto fail;
}
assert(m && port);
if ((fd = socket(PF_INET, SOCK_STREAM, 0)) < 0) {
- pa_log(__FILE__": socket(PF_INET): %s", strerror(errno));
+ pa_log(__FILE__": socket(PF_INET): %s", pa_cstrerror(errno));
goto fail;
}
#ifdef SO_REUSEADDR
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) < 0)
- pa_log(__FILE__": setsockopt(): %s", strerror(errno));
+ pa_log(__FILE__": setsockopt(): %s", pa_cstrerror(errno));
#endif
pa_socket_tcp_low_delay(fd);
sa.sin_addr.s_addr = htonl(address);
if (bind(fd, (struct sockaddr *) &sa, sizeof(sa)) < 0) {
- pa_log(__FILE__": bind(): %s", strerror(errno));
+ pa_log(__FILE__": bind(): %s", pa_cstrerror(errno));
goto fail;
}
if (listen(fd, 5) < 0) {
- pa_log(__FILE__": listen(): %s", strerror(errno));
+ pa_log(__FILE__": listen(): %s", pa_cstrerror(errno));
goto fail;
}
assert(m && port);
if ((fd = socket(PF_INET6, SOCK_STREAM, 0)) < 0) {
- pa_log(__FILE__": socket(PF_INET6): %s", strerror(errno));
+ pa_log(__FILE__": socket(PF_INET6): %s", pa_cstrerror(errno));
goto fail;
}
#ifdef IPV6_V6ONLY
if (setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on)) < 0)
- pa_log(__FILE__": setsockopt(IPPROTO_IPV6, IPV6_V6ONLY): %s", strerror(errno));
+ pa_log(__FILE__": setsockopt(IPPROTO_IPV6, IPV6_V6ONLY): %s", pa_cstrerror(errno));
#endif
#ifdef SO_REUSEADDR
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) < 0)
- pa_log(__FILE__": setsockopt(SOL_SOCKET, SO_REUSEADDR, 1): %s", strerror(errno));
+ pa_log(__FILE__": setsockopt(SOL_SOCKET, SO_REUSEADDR, 1): %s", pa_cstrerror(errno));
#endif
pa_socket_tcp_low_delay(fd);
memcpy(sa.sin6_addr.s6_addr, address, 16);
if (bind(fd, (struct sockaddr *) &sa, sizeof(sa)) < 0) {
- pa_log(__FILE__": bind(): %s", strerror(errno));
+ pa_log(__FILE__": bind(): %s", pa_cstrerror(errno));
goto fail;
}
if (listen(fd, 5) < 0) {
- pa_log(__FILE__": listen(): %s", strerror(errno));
+ pa_log(__FILE__": listen(): %s", pa_cstrerror(errno));
goto fail;
}
socklen_t sa_len = sizeof(sa);
if (getsockname(s->fd, (struct sockaddr*) &sa, &sa_len) < 0) {
- pa_log(__FILE__": getsockname() failed: %s", strerror(errno));
+ pa_log(__FILE__": getsockname(): %s", pa_cstrerror(errno));
return NULL;
}
char ip[INET6_ADDRSTRLEN];
if (!inet_ntop(AF_INET6, &sa.sin6_addr, ip, sizeof(ip))) {
- pa_log(__FILE__": inet_ntop() failed: %s", strerror(errno));
+ pa_log(__FILE__": inet_ntop(): %s", pa_cstrerror(errno));
return NULL;
}
socklen_t sa_len = sizeof(sa);
if (getsockname(s->fd, (struct sockaddr*) &sa, &sa_len) < 0) {
- pa_log(__FILE__": getsockname() failed: %s", strerror(errno));
+ pa_log(__FILE__": getsockname(): %s", pa_cstrerror(errno));
return NULL;
}
char ip[INET_ADDRSTRLEN];
if (!inet_ntop(AF_INET, &sa.sin_addr, ip, sizeof(ip))) {
- pa_log(__FILE__": inet_ntop() failed: %s", strerror(errno));
+ pa_log(__FILE__": inet_ntop(): %s", pa_cstrerror(errno));
return NULL;
}
#include "winsock.h"
+#include <polyp/error.h>
#include <polyp/xmalloc.h>
#include <polypcore/core-util.h>
int fd = -1, ret = -1;
if ((fd = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) {
- pa_log(__FILE__": socket(): %s", strerror(errno));
+ pa_log(__FILE__": socket(): %s", pa_cstrerror(errno));
goto finish;
}
#include <string.h>
#include <sys/un.h>
+#include <polyp/error.h>
#include <polyp/util.h>
#include <polypcore/core-util.h>
}
if ((fd = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) {
- pa_log(__FILE__": socket(PF_UNIX, SOCK_STREAM, 0): %s", strerror(errno));
+ pa_log(__FILE__": socket(PF_UNIX, SOCK_STREAM, 0): %s", pa_cstrerror(errno));
goto fail;
}
int r;
if ((r = connect(fd, (struct sockaddr*) &sa, sizeof(sa))) < 0 && (errno != ECONNREFUSED && errno != ENOENT)) {
- pa_log(__FILE__": connect() failed: %s", strerror(errno));
+ pa_log(__FILE__": connect(): %s", pa_cstrerror(errno));
goto fail;
}
for (;;) {
if (select(FD_SETSIZE, &ifds, &ofds, NULL, NULL) < 0) {
- pa_log(__FILE__": select() failed: %s", strerror(errno));
+ pa_log(__FILE__": select(): %s", pa_cstrerror(errno));
goto fail;
}
if (r == 0)
break;
- pa_log(__FILE__": read() failed: %s", strerror(errno));
+ pa_log(__FILE__": read(): %s", pa_cstrerror(errno));
goto fail;
}
if (r == 0)
break;
- pa_log(__FILE__": read() failed: %s", strerror(errno));
+ pa_log(__FILE__": read(): %s", pa_cstrerror(errno));
goto fail;
}
assert(obuf_length);
if ((r = write(1, obuf + obuf_index, obuf_length)) < 0) {
- pa_log(__FILE__": write() failed: %s", strerror(errno));
+ pa_log(__FILE__": write(): %s", pa_cstrerror(errno));
goto fail;
}
assert(ibuf_length);
if ((r = write(fd, ibuf + ibuf_index, ibuf_length)) < 0) {
- pa_log(__FILE__": write() failed: %s", strerror(errno));
+ pa_log(__FILE__": write(): %s", pa_cstrerror(errno));
goto fail;
}