| 1 | /* Quintuple Agent utilities |
| 2 | * Copyright (C) 1999 Robert Bihlmeyer <[email protected]> |
| 3 | * Copyright (C) 2003 g10 Code GmbH |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301. |
| 18 | */ |
| 19 | |
| 20 | #ifndef _UTIL_H |
| 21 | #define _UTIL_Hcxx . . $ `secmem/util.h:21:9`! |
| 22 | |
| 23 | #include <sys/types.h> |
| 24 | |
| 25 | #ifndef HAVE_BYTE_TYPEDEF |
| 26 | # undef byte |
| 27 | # ifdef __riscos__ |
| 28 | /* Norcroft treats char == unsigned char but char* != unsigned char* */ |
| 29 | typedef char byte; |
| 30 | # else |
| 31 | typedef unsigned char bytecxx . . $ byte#; |
| 32 | # endif |
| 33 | # define HAVE_BYTE_TYPEDEFcxx . . $ `secmem/util.h:33:10`! |
| 34 | #endif |
| 35 | |
| 36 | #ifndef HAVE_ULONG_TYPEDEFcxx . . $ `config.h:75:9`! |
| 37 | # undef ulong |
| 38 | typedef unsigned long ulong; |
| 39 | # define HAVE_ULONG_TYPEDEF |
| 40 | #endif |
| 41 | |
| 42 | |
| 43 | ssize_tcxx . . $ ssize_t# xwritecxx . . $ xwrite(41184a59d38b4f65).(int, const void *, size_tcxx . . $ size_t#); /* write until finished */ |
| 44 | int debugmsgcxx . . $ debugmsg(581fddd72a8db8fc).(const char *, ...); /* output a debug message if debugging==on */ |
| 45 | void drop_privscxx . . $ drop_privs(49f6e7a06ebc5aa8).(void); /* finally drop privileges */ |
| 46 | |
| 47 | |
| 48 | /* To avoid that a compiler optimizes certain memset calls away, these |
| 49 | macros may be used instead. */ |
| 50 | #define wipememory2cxx . . $ `secmem/util.h:50:9`!(_ptr,_set,_len) do { \ |
| 51 | volatile char *_vptr=(volatile char *)(_ptr); \ |
| 52 | size_t _vlen=(_len); \ |
| 53 | while(_vlen) { *_vptr=(_set); _vptr++; _vlen--; } \ |
| 54 | } while(0) |
| 55 | #define wipememorycxx . . $ `secmem/util.h:55:9`!(_ptr,_len) wipememory2(_ptr,0,_len) |
| 56 | #define wipecxx . . $ `secmem/util.h:56:9`!(_ptr,_len) wipememory2(_ptr,0,_len) |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 | #define xtoi_1cxx . . $ `secmem/util.h:61:9`!(p) (*(p) <= '9'? (*(p)- '0'): \ |
| 62 | *(p) <= 'F'? (*(p)-'A'+10):(*(p)-'a'+10)) |
| 63 | #define xtoi_2cxx . . $ `secmem/util.h:63:9`!(p) ((xtoi_1(p) * 16) + xtoi_1((p)+1)) |
| 64 | |
| 65 | |
| 66 | #endif |