annotate dpid/dpid_common.c @ 2104:3e7e5395f0bc

non-ASCII keybindings Alexander Voigt has kindly done some testing, and it seems that this makes bindings to most keys on a German keyboard possible -- except those that need AltGr don't work yet.
author corvid <corvid@lavabit.com>
date Thu, 23 Jun 2011 19:24:11 +0000
parents c1c822f70582
children
rev   line source
779
49735e578039 [mq]: add-dpid-copyright
Jeremy Henty <onepoint@starurchin.org>
parents: 0
diff changeset
1 /*
49735e578039 [mq]: add-dpid-copyright
Jeremy Henty <onepoint@starurchin.org>
parents: 0
diff changeset
2 * File: dpid_common.c
49735e578039 [mq]: add-dpid-copyright
Jeremy Henty <onepoint@starurchin.org>
parents: 0
diff changeset
3 *
49735e578039 [mq]: add-dpid-copyright
Jeremy Henty <onepoint@starurchin.org>
parents: 0
diff changeset
4 * Copyright 2008 Jorge Arellano Cid <jcid@dillo.org>
49735e578039 [mq]: add-dpid-copyright
Jeremy Henty <onepoint@starurchin.org>
parents: 0
diff changeset
5 *
49735e578039 [mq]: add-dpid-copyright
Jeremy Henty <onepoint@starurchin.org>
parents: 0
diff changeset
6 * This program is free software; you can redistribute it and/or modify
49735e578039 [mq]: add-dpid-copyright
Jeremy Henty <onepoint@starurchin.org>
parents: 0
diff changeset
7 * it under the terms of the GNU General Public License as published by
49735e578039 [mq]: add-dpid-copyright
Jeremy Henty <onepoint@starurchin.org>
parents: 0
diff changeset
8 * the Free Software Foundation; either version 3 of the License, or
49735e578039 [mq]: add-dpid-copyright
Jeremy Henty <onepoint@starurchin.org>
parents: 0
diff changeset
9 * (at your option) any later version.
49735e578039 [mq]: add-dpid-copyright
Jeremy Henty <onepoint@starurchin.org>
parents: 0
diff changeset
10 */
49735e578039 [mq]: add-dpid-copyright
Jeremy Henty <onepoint@starurchin.org>
parents: 0
diff changeset
11
1223
a09dbf132be6 Remove system includes for dpid
Jorge Arellano Cid <jcid@dillo.org>
parents: 779
diff changeset
12 #include <errno.h>
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
13 #include <stdio.h>
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
14 #include <unistd.h>
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
15 #include "dpid_common.h"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
16
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
17 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
18 * Send a verbose error message.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
19 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
20 void errmsg(char *caller, char *called, int errornum, char *file, int line)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
21 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
22 MSG_ERR("%s:%d: %s: %s\n", file, line, caller, called);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
23 if (errornum > 0)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
24 MSG_ERR("%s\n", dStrerror(errornum));
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
25 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
26
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
27 /*! Selector function for scandir
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
28 * Do not scan files starting with '.'
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
29 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
30 int no_dotfiles(const struct dirent *filedat)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
31 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
32 if (filedat->d_name[0] == '.')
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
33 return 0;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
34 else
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
35 return 1;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
36 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
37
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
38 /*!
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
39 * Provides an error checked write command.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
40 * Call this via the CKD_WRITE macro
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
41 * \return write return value
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
42 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
43 ssize_t ckd_write(int fd, char *msg, char *file, int line)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
44 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
45 ssize_t ret;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
46
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
47 do {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
48 ret = write(fd, msg, strlen(msg));
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
49 } while (ret == -1 && errno == EINTR);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
50 if (ret == -1) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
51 MSG_ERR("%s:%d: write: %s\n", file, line, dStrerror(errno));
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
52 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
53 return (ret);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
54 }
1389
c1c822f70582 Removed the write/fwrite mix in dpip. Introduced a_Dpip_dsh_trywrite()
Jorge Arellano Cid <jcid@dillo.org>
parents: 1223
diff changeset
55
c1c822f70582 Removed the write/fwrite mix in dpip. Introduced a_Dpip_dsh_trywrite()
Jorge Arellano Cid <jcid@dillo.org>
parents: 1223
diff changeset
56 /*!
c1c822f70582 Removed the write/fwrite mix in dpip. Introduced a_Dpip_dsh_trywrite()
Jorge Arellano Cid <jcid@dillo.org>
parents: 1223
diff changeset
57 * Provides an error checked close() call.
c1c822f70582 Removed the write/fwrite mix in dpip. Introduced a_Dpip_dsh_trywrite()
Jorge Arellano Cid <jcid@dillo.org>
parents: 1223
diff changeset
58 * Call this via the CKD_CLOSE macro
c1c822f70582 Removed the write/fwrite mix in dpip. Introduced a_Dpip_dsh_trywrite()
Jorge Arellano Cid <jcid@dillo.org>
parents: 1223
diff changeset
59 * \return close return value
c1c822f70582 Removed the write/fwrite mix in dpip. Introduced a_Dpip_dsh_trywrite()
Jorge Arellano Cid <jcid@dillo.org>
parents: 1223
diff changeset
60 */
c1c822f70582 Removed the write/fwrite mix in dpip. Introduced a_Dpip_dsh_trywrite()
Jorge Arellano Cid <jcid@dillo.org>
parents: 1223
diff changeset
61 ssize_t ckd_close(int fd, char *file, int line)
c1c822f70582 Removed the write/fwrite mix in dpip. Introduced a_Dpip_dsh_trywrite()
Jorge Arellano Cid <jcid@dillo.org>
parents: 1223
diff changeset
62 {
c1c822f70582 Removed the write/fwrite mix in dpip. Introduced a_Dpip_dsh_trywrite()
Jorge Arellano Cid <jcid@dillo.org>
parents: 1223
diff changeset
63 ssize_t ret;
c1c822f70582 Removed the write/fwrite mix in dpip. Introduced a_Dpip_dsh_trywrite()
Jorge Arellano Cid <jcid@dillo.org>
parents: 1223
diff changeset
64
c1c822f70582 Removed the write/fwrite mix in dpip. Introduced a_Dpip_dsh_trywrite()
Jorge Arellano Cid <jcid@dillo.org>
parents: 1223
diff changeset
65 do {
c1c822f70582 Removed the write/fwrite mix in dpip. Introduced a_Dpip_dsh_trywrite()
Jorge Arellano Cid <jcid@dillo.org>
parents: 1223
diff changeset
66 ret = close(fd);
c1c822f70582 Removed the write/fwrite mix in dpip. Introduced a_Dpip_dsh_trywrite()
Jorge Arellano Cid <jcid@dillo.org>
parents: 1223
diff changeset
67 } while (ret == -1 && errno == EINTR);
c1c822f70582 Removed the write/fwrite mix in dpip. Introduced a_Dpip_dsh_trywrite()
Jorge Arellano Cid <jcid@dillo.org>
parents: 1223
diff changeset
68 if (ret == -1) {
c1c822f70582 Removed the write/fwrite mix in dpip. Introduced a_Dpip_dsh_trywrite()
Jorge Arellano Cid <jcid@dillo.org>
parents: 1223
diff changeset
69 MSG_ERR("%s:%d: close: %s\n", file, line, dStrerror(errno));
c1c822f70582 Removed the write/fwrite mix in dpip. Introduced a_Dpip_dsh_trywrite()
Jorge Arellano Cid <jcid@dillo.org>
parents: 1223
diff changeset
70 }
c1c822f70582 Removed the write/fwrite mix in dpip. Introduced a_Dpip_dsh_trywrite()
Jorge Arellano Cid <jcid@dillo.org>
parents: 1223
diff changeset
71 return (ret);
c1c822f70582 Removed the write/fwrite mix in dpip. Introduced a_Dpip_dsh_trywrite()
Jorge Arellano Cid <jcid@dillo.org>
parents: 1223
diff changeset
72 }
c1c822f70582 Removed the write/fwrite mix in dpip. Introduced a_Dpip_dsh_trywrite()
Jorge Arellano Cid <jcid@dillo.org>
parents: 1223
diff changeset
73