chiark / gitweb /
gpg agent lockup fix: Interrupt main loop when active_connections_value==0
[gnupg2.git] / common / sysutils.h
1 /* sysutils.h - System utility functions for Gnupg
2  *      Copyright (C) 2002 Free Software Foundation, Inc.
3  *
4  * This file is part of GnuPG.
5  *
6  * This file is free software; you can redistribute it and/or modify
7  * it under the terms of either
8  *
9  *   - the GNU Lesser General Public License as published by the Free
10  *     Software Foundation; either version 3 of the License, or (at
11  *     your option) any later version.
12  *
13  * or
14  *
15  *   - the GNU General Public License as published by the Free
16  *     Software Foundation; either version 2 of the License, or (at
17  *     your option) any later version.
18  *
19  * or both in parallel, as here.
20  *
21  * This file is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24  * GNU General Public License for more details.
25  *
26  * You should have received a copy of the GNU General Public License
27  * along with this program; if not, see <https://www.gnu.org/licenses/>.
28  */
29
30 #ifndef GNUPG_COMMON_SYSUTILS_H
31 #define GNUPG_COMMON_SYSUTILS_H
32
33 /* Because we use system handles and not libc low level file
34    descriptors on W32, we need to declare them as HANDLE (which
35    actually is a plain pointer).  This is required to eventually
36    support 64 bits Windows systems.  */
37 #ifdef HAVE_W32_SYSTEM
38 typedef void *gnupg_fd_t;
39 #define GNUPG_INVALID_FD ((void*)(-1))
40 #define INT2FD(s) ((void *)(s))
41 #define FD2INT(h) ((unsigned int)(h))
42 #else
43 typedef int gnupg_fd_t;
44 #define GNUPG_INVALID_FD (-1)
45 #define INT2FD(s) (s)
46 #define FD2INT(h) (h)
47 #endif
48
49
50 void trap_unaligned (void);
51 int  disable_core_dumps (void);
52 int  enable_core_dumps (void);
53 void enable_special_filenames (void);
54 const unsigned char *get_session_marker (size_t *rlen);
55 unsigned int get_uint_nonce (void);
56 /*int check_permissions (const char *path,int extension,int checkonly);*/
57 void gnupg_sleep (unsigned int seconds);
58 void gnupg_usleep (unsigned int usecs);
59 int translate_sys2libc_fd (gnupg_fd_t fd, int for_write);
60 int translate_sys2libc_fd_int (int fd, int for_write);
61 int check_special_filename (const char *fname, int for_write, int notranslate);
62 FILE *gnupg_tmpfile (void);
63 void gnupg_reopen_std (const char *pgmname);
64 void gnupg_allow_set_foregound_window (pid_t pid);
65 int  gnupg_remove (const char *fname);
66 gpg_error_t gnupg_rename_file (const char *oldname, const char *newname,
67                                int *block_signals);
68 int  gnupg_mkdir (const char *name, const char *modestr);
69 int gnupg_chmod (const char *name, const char *modestr);
70 char *gnupg_mkdtemp (char *template);
71 int  gnupg_setenv (const char *name, const char *value, int overwrite);
72 int  gnupg_unsetenv (const char *name);
73 char *gnupg_getcwd (void);
74 char *gnupg_get_socket_name (int fd);
75
76 gpg_error_t gnupg_inotify_watch_socket (int *r_fd, const char *socket_name);
77 int gnupg_inotify_has_name (int fd, const char *name);
78
79
80 #ifdef HAVE_W32_SYSTEM
81 void *w32_get_user_sid (void);
82
83 #include "../common/w32help.h"
84
85 #endif /*HAVE_W32_SYSTEM*/
86
87 #endif /*GNUPG_COMMON_SYSUTILS_H*/