-
+ 9CB4E6A599501CCB7615C4DA88439D29C483B03D85BA4FC5A02C2B2FBF2920AEDE4E99F0438D86802183B05F3A113CA597A676B18D373F2D5E39D9D6F65553B2
eucrypt/mpi/include/util.h
(0 . 0)(1 . 86)
1938 /* util.h
1939 * Modified by No Such Labs. (C) 2015. See README.
1940 *
1941 * This file was originally part of Gnu Privacy Guard (GPG), ver. 1.4.10,
1942 * SHA256(gnupg-1.4.10.tar.gz):
1943 * 0bfd74660a2f6cedcf7d8256db4a63c996ffebbcdc2cf54397bfb72878c5a85a
1944 * (C) 1994-2005 Free Software Foundation, Inc.
1945 *
1946 * This program is free software: you can redistribute it and/or modify
1947 * it under the terms of the GNU General Public License as published by
1948 * the Free Software Foundation, either version 3 of the License, or
1949 * (at your option) any later version.
1950 *
1951 * This program is distributed in the hope that it will be useful,
1952 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1953 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1954 * GNU General Public License for more details.
1955 *
1956 * You should have received a copy of the GNU General Public License
1957 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1958 */
1959
1960 #ifndef G10_UTIL_H
1961 #define G10_UTIL_H
1962
1963 #if defined (_WIN32) || defined (__CYGWIN32__)
1964 #include <stdarg.h>
1965 #endif
1966
1967 #include "types.h"
1968 #include "types.h"
1969 #include "mpi.h"
1970
1971 #define log_hexdump printf
1972 #define log_bug printf
1973 #define log_bug0 printf
1974 #define log_fatal printf
1975 #define log_error printf
1976 #define log_info printf
1977 #define log_warning printf
1978 #define log_debug printf
1979
1980 #define g10_log_print_prefix printf
1981
1982
1983 #ifndef HAVE_MEMMOVE
1984 #define memmove(d, s, n) bcopy((s), (d), (n))
1985 #endif
1986
1987
1988 /**** other missing stuff ****/
1989 #ifndef HAVE_ATEXIT /* For SunOS */
1990 #define atexit(a) (on_exit((a),0))
1991 #endif
1992
1993 #ifndef HAVE_RAISE
1994 #define raise(a) kill(getpid(), (a))
1995 #endif
1996
1997 /******** some macros ************/
1998 #ifndef STR
1999 #define STR(v) #v
2000 #endif
2001 #define STR2(v) STR(v)
2002 #define DIM(v) (sizeof(v)/sizeof((v)[0]))
2003 #define DIMof(type,member) DIM(((type *)0)->member)
2004
2005 #define wipememory2(_ptr,_set,_len) do { volatile char *_vptr=(volatile char *)(_ptr); size_t _vlen=(_len); while(_vlen) { *_vptr=(_set); _vptr++; _vlen--; } } while(0)
2006 #define wipememory(_ptr,_len) wipememory2(_ptr,0,_len)
2007
2008 /*-- macros to replace ctype ones and avoid locale problems --*/
2009 #define spacep(p) (*(p) == ' ' || *(p) == '\t')
2010 #define digitp(p) (*(p) >= '0' && *(p) <= '9')
2011 #define hexdigitp(a) (digitp (a) \
2012 || (*(a) >= 'A' && *(a) <= 'F') \
2013 || (*(a) >= 'a' && *(a) <= 'f'))
2014 /* the atoi macros assume that the buffer has only valid digits */
2015 #define atoi_1(p) (*(p) - '0' )
2016 #define atoi_2(p) ((atoi_1(p) * 10) + atoi_1((p)+1))
2017 #define atoi_4(p) ((atoi_2(p) * 100) + atoi_2((p)+2))
2018 #define xtoi_1(p) (*(p) <= '9'? (*(p)- '0'): \
2019 *(p) <= 'F'? (*(p)-'A'+10):(*(p)-'a'+10))
2020 #define xtoi_2(p) ((xtoi_1(p) * 16) + xtoi_1((p)+1))
2021
2022
2023 #endif /*G10_UTIL_H*/