Dillo v3.1.1-46-g8a360e32
Loading...
Searching...
No Matches
dpid_common.c
Go to the documentation of this file.
1/*
2 * File: dpid_common.c
3 *
4 * Copyright 2008 Jorge Arellano Cid <jcid@dillo.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 */
11
12#include <errno.h>
13#include <stdio.h>
14#include <unistd.h>
15#include "dpid_common.h"
16
17/*
18 * Send a verbose error message.
19 */
20void errmsg(char *caller, char *called, int errornum, char *file, int line)
21{
22 MSG_ERR("%s:%d: %s: %s\n", file, line, caller, called);
23 if (errornum > 0)
24 MSG_ERR("%s\n", dStrerror(errornum));
25}
26
32ssize_t ckd_write(int fd, char *msg, char *file, int line)
33{
34 ssize_t ret;
35
36 do {
37 ret = write(fd, msg, strlen(msg));
38 } while (ret == -1 && errno == EINTR);
39 if (ret == -1) {
40 MSG_ERR("%s:%d: write: %s\n", file, line, dStrerror(errno));
41 }
42 return (ret);
43}
44
50ssize_t ckd_close(int fd, char *file, int line)
51{
52 ssize_t ret;
53
54 ret = dClose(fd);
55 if (ret == -1)
56 MSG_ERR("%s:%d: close: %s\n", file, line, dStrerror(errno));
57 return ret;
58}
59
int dClose(int fd)
Close a FD handling EINTR.
Definition dlib.c:951
#define dStrerror
Definition dlib.h:95
ssize_t ckd_close(int fd, char *file, int line)
Definition dpid_common.c:50
ssize_t ckd_write(int fd, char *msg, char *file, int line)
Definition dpid_common.c:32
void errmsg(char *caller, char *called, int errornum, char *file, int line)
Definition dpid_common.c:20
#define MSG_ERR(...)
Definition dpid_common.h:23